cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Win32 curl_easy_setopt( ): CURLOPT_WRITEDATA question

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 17 Feb 2010 22:47:01 +0100 (CET)

On Wed, 17 Feb 2010, Pete Wilson wrote:

> "If you're using libcurl as a win32 DLL, you MUST use the
> CURLOPT_WRITEFUNCTION if you set this option or you will experience
> crashes."
>
> The final sentence of the paragraph is ambiguous and I want to understand
> its meaning clearly.

I don't see how it is ambiguous.

> I use libcurl as a DLL under win32. I will always set my
> CURLOPT_WRITEFUNCTION to NULL. I will always use this (the
> CURLOPT_WRITEDATA) option; and I will always set it to a FILE *.
>
> I do this because I never want to call fwrite( ). Instead, I want the
> internal CURLOPT_WRITEFUNCTION always to call fwrite().

The docs says this: if you use CURLOPT_WRITEDATA and you use a win32 DLL,
which you say you are, then you "you MUST use the CURLOPT_WRITEFUNCTION".

To me that is clear.

> But the quoted sentence might mean that I will therefore "experience
> crashes."

It does indeed mean that you _will_ experience crashes.

> So does the warning mean that the internal CURLOPT_WRITEFUNCTION is not
> useful under win32?

Yes, if you use libcurl as a DLL.

> IOW, do I always have to implement a CURLOPT_WRITEFUNCTION if my code is
> running under win32?

Yes, if you use libcurl as a DLL and set CURLOPT_WRITEDATA.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-02-17