cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: getting html to buffer?

From: Admir Efendic <admir_at_softwell.se>
Date: Mon, 01 Oct 2001 11:47:30 +0200

Daniel Stenberg wrote:

>On Mon, 1 Oct 2001, Admir Efendic wrote:
>
>[CC'ing this reply to the libcurl list which seems a more appropriate list
>for this discussion.]
>
>>I'm trying to get an html-file to char* buffer with curl. I am using
>>multiple threads, each thread have their own instance of curl and are
>>fetching different html pages. Is there a straightforward way to do this,
>>or do I have to write html to a file, and then open the file (or mmap
>>it)? Specifying custom write function to curl doesn't really help,
>>because I am forced to use global buffer (visible to both thread_function
>>& write_function ) and that's a nono with threads ;-).
>>
>
>I don't understand your situation. Why are you forced to use a global buffer?
>Why can't each thread simply download the file into its own thread-specific
>buffer?
>
That is what I am trying to do, but I don't really understand how am I
supposed to do that. Is there an API to that, beside specyfing custom
write function? The problem with using custom write and local buffer is:

//-----------------------------------------------------------
size_t my_write(void* p, size_t size, size_t n, void* stream);

void* thread_func(void* arg)
{
    ...
    char* buffer;
    rc = curl_easy_setopt (h_curl, CURLOPT_WRITEFUNCTION, my_write);
    ...
}

size_t my_write(void* p, size_t size, size_t n, void* stream)
{
    ...
}
//-----------------------------------------------------------

...inside "my_write" i cannot see "buffer", or am I missing something?

mvh Admir
Received on 2001-10-01