cURL / Mailing Lists / curl-library / Single Mail

curl-library

Need clarification on tutorial

From: Igor Korot <ikorot01_at_gmail.com>
Date: Mon, 9 Jul 2012 20:08:15 -0700

Hi, ALL,
My name is Igor Korot and I'm starting to use CURL library as a developer.

However I need some clarification since I'm not comprehending what is written in
tutorial.

I'm trying to read
http://curl.haxx.se/libcurl/c/libcurl-tutorial.html, part "Uploading
data to a Remote Site". Here is excerpt from it:

"
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?

And "filedata = bufptr". Is this correct?

I'm just reading this so to better understand the concepts and to see
how things done.

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.

Thank you for the answers and sorry if the second one was already answered.
Like I said I'm new to the library. ;-)
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-07-10