curl-library
bitmap buffer (c++)
Date: 13 Nov 2008 12:51:42 -0000
I must explain better the code...
struct MemoryStruct {
unsigned char *memory;
size_t size;
};
size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
{
register int realsize = size * nmemb;
struct MemoryStruct *mem = (struct MemoryStruct *)data;
mem->memory = (unsigned char *)realloc(mem->memory, mem->size + realsize + 1);
if (mem->memory) {
memcpy(&(mem->memory[mem->size]), ptr, realsize);
mem->size += realsize;
mem->memory[mem->size] = 0;
}
return realsize;
}
void conta() throw (std::runtime_error){
...
...
...
CURL *curl_handle;
while(true){
char* info;
struct MemoryStruct chunk;
chunk.memory=NULL;
chunk.size = 0;
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle, CURLOPT_URL, "http:/111.111.11.11/axis-cgi/bmp/image.bmp");
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
curl_easy_setopt(curl_handle, CURLOPT_HEADER,false);
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
CURLcode error;
error=curl_easy_perform(curl_handle);
//Here i use the buffer stored in the chunk
curl_easy_cleanup(curl_handle);
...
...
... }
}
----------------------------------------------------------------------------
Vuoi essere presente online?
Vuoi dare voce alla tua attivita`?
Acquista un dominio su domini.interfree.it.
A partire da 18,59 euro
----------------------------------------------------------------------------
Received on 2008-11-13