cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Request To Memory Buffer

From: Uygar Gümüs <uygar.gumus_at_vestel.com.tr>
Date: Fri, 8 Jun 2007 11:10:44 +0300

SAX interface of libxml has a similar ability. You can read xml data from a file or a memory block like this

#include <libxml/parser.h>

int xmlSAXUserParseFile( xmlSAXHandlerPtr sax,
        void * user_data,
        const char * filename);
int xmlSAXUserParseMemory( xmlSAXHandlerPtr sax,
        void * user_data,
        char * buffer,
        int size);

http://www.jamesh.id.au/articles/libxml-sax/libxml-sax.html

i don`t know if i could tell what i mean :(

uygar

-----Original Message-----
From: Uygar Gümüs
Sent: Fri 6/8/2007 11:05 AM
To: libcurl development
Subject: RE: Request To Memory Buffer
 

Thanks for quick reply but that example shows saving to memory. My case is about reading from that memory block like reading from server url.

For example
I saved data for http:///xxx.y to buffer as shown in example and than at second attempt to request http:///xxx.y do not make a curl request to server but read data from that buffer with curl callbacks (write callback actually) My code should be like this...

if(url not in cache)
{
     curl_easy_setopt(curl_handle, CURLOPT_URL, "http://cool.haxx.se/");

    curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteCallback);

    curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);

   
}
else
{
  [do something to force curl read from memory]
}

I am doing this because there are some code blocks which assumes that "data will be given from CURLOPT_WRITEFUNCTION callback, not directly" and i don`t want to change that part because of possible changes by developers of that parts.

curl_easy_perform(curl_handle);

curl_easy_cleanup(curl_handle);

Uygar....

-----Original Message-----
From: curl-library-bounces_at_cool.haxx.se on behalf of Aleksandar Lazic
Sent: Fri 6/8/2007 10:18 AM
To: libcurl development
Subject: Re: Request To Memory Buffer
 
Hi,

On Fre 08.06.2007 09:40, Uygar Gümüs wrote:
>
>I need some help about libcurl interface. Please help me.

Have you try to look into the *excellent* examples dir:

http://curl.haxx.se/libcurl/c/example.html

=> http://curl.haxx.se/lxr/source/docs/examples/getinmemory.c

>Can you please reply... Thanks a lot

Ht the urls help ;-)

Cheers

Aleks
Received on 2007-06-08