conversion stream a string

cgillopez
12 de Agosto del 2008
Hola, estoy haciendo un programa que envia un http request (GET) a un servidor. El servidor responde con un stream que contiene todo los datos… bueno esto es lo que tendria que hacer y no hace..

#include <stdio.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <curl/curl.h>
#include <errno.h>

int main(){
CURL *curl;
char *url; //10
char *stream;
char *s;

FILE *fd;
char *file;

url="http://192.168.0.63/cgi-axis/admin/serverreport.cgi";

/* get a curl handle */
curl = curl_easy_init();

if(curl) {
/* specify target URL, and note that this URL should also include a file
name, not only a directory (as you can do with GTP uploads) */
curl_easy_setopt(curl,CURLOPT_URL, url);

/* tell libcurl we can use "basic" auth */

curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);

/* set user name and password for the authentication */
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:pass");

curl_easy_setopt(curl,CURLOPT_HTTPGET, (long)stream);
if (CURLE_OK==0){printf("OKn");}

fd=fmemopen(stream,sizeof(stream),"r+");

if (fd==NULL){
printf("errorn");
perror("error");}
else{
printf("fmemopen OKn");

int i;
i=fgets(s,100,fd);
printf("FIRST fgets %d n",i); // quiero leer la primera linea del stream (que es linea vacia) para que en la segunda lectura comience a leer datos pero el valor que da I es muy grande asi que creo que devuelve todo el stream otra vez..
i=fgets(s,100,fd);
printf("SECOND fgets %d n", i); // aqui tendria que leer algun caracter pero no i es 0

if (s!=NULL){
printf("%s",s); // lo que sale por pantalla es algo asi… &#65533;&#65533; asi que supongo que es un stream cuando deberia de ser un string
}

}
}
/* always cleanup */
curl_easy_cleanup(curl);

fclose(fd);

return 0;
}

Ademas me da unos warnings a la hora de compilar..

assignment makes pointer from integer without a cast --> por el fmemopen
assignment makes integer from pointer without a cast --> uno por cada gets

Me podeis ayudar con esto????

gratzie mile