cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Need clarification on tutorial

From: Igor Korot <ikorot01_at_gmail.com>
Date: Wed, 11 Jul 2012 00:56:22 -0700

Thank you for the clarification, Lijo.

1. Would it be possible to clarify at least point one in the link I referenced?

2. Does anybody works with libcurl on Windows with MSVC 2010?
I did successfully compile the library with it by using provided
vc6.dsw file, but then
trying to use it in my own project I am getting a link error on every single
libcurl.
I did update my project properties, the compiler didn't complain, only linker.

I can post my project if needed.

Thank you.

On Tue, Jul 10, 2012 at 10:31 PM, Lijo Antony <lta_at_one.com> wrote:
> On 07/10/2012 07:08 AM, Igor Korot wrote:
>>
>> The read callback should have a prototype similar to:
>>
>> size_t function(char *bufptr, size_t size, size_t nitems, void *userp);
>>
>> Where bufptr is the pointer to a buffer we fill in with data to upload
>> and size*nitems is the size of the buffer and therefore also the
>> maximum amount of data we can return to libcurl in this call. The
>> 'userp' pointer is the custom pointer we set to point to a struct of
>> ours to pass private data between the application and the callback.
>>
>> curl_easy_setopt(easyhandle, CURLOPT_READFUNCTION, read_function);
>>
>> curl_easy_setopt(easyhandle, CURLOPT_READDATA,&filedata);
>>
>> Tell libcurl that we want to upload:
>>
>> curl_easy_setopt(easyhandle, CURLOPT_UPLOAD, 1L);
>> "
>>
>> Now in this piece if I'm reading correctly, "read_function =
>> function". Is this correct?
>
>
> yes. read_function stands for a function with signature "size_t
> function(char *bufptr, size_t size, size_t nitems, void *userp);", which is
> provided by the user.
>
>
>>
>> And "filedata = bufptr". Is this correct?
>
>
> No. bufptr is a pointer to a char buffer allocated by libcurl. read function
> is supposed to fill this buffer with the data to be uploaded.
>
> filedata is an optional pointer, which user may want to associate with the
> read_function, using curl_easy_setopt. The same pointer will be available as
> userp param of the read_funciton callback. libcurl will not touch this.
>
> Along with the man pages, you can see the examples provided at
> http://curl.haxx.se/libcurl/c/options-in-examples.html for the usages.
>
>
>> Also on unrelated note.
>> I need to perform multipart file transfer. The file is the bitmap and
>> it will be transferred thru
>> HTTP POST. However, prior to this I need to send 2 strings: one that
>> will identify the beginning
>> of the transfer (boundary) and another that will identify the name of the
>> file.
>> I will also need to send the boundary string at the end of the transfer.
>>
>> My question is: Is there a simple way of transferring the "char *"
>> (string) or I will have to
>> declare a callback and just assign the string to the data pointer
>> according to the part
>> I mentioned above.
>
>
> There are examples for POST at the above link, which shows different usages.
>
> -lijo
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-07-11