Loading docs/curl_easy_setopt.3 +30 −42 Original line number Original line Diff line number Diff line Loading @@ -42,54 +42,43 @@ call. These options are in a bit of random order, but you'll figure it out! These options are in a bit of random order, but you'll figure it out! .TP 0.8i .TP 0.8i .B CURLOPT_FILE .B CURLOPT_FILE Data pointer to pass instead of FILE * to the file write function. Note that Data pointer to pass to file write function. Note that if you specify the if you specify the .I CURLOPT_WRITEFUNCTION .I CURLOPT_WRITEFUNCTION , this is the pointer you'll get as input. , this is the pointer you'll get as input. If you don't use a callback, you must pass a 'FILE *' as libcurl passes it to fwrite() when writing data. NOTE: If you're using libcurl as a win32 .DLL, you MUST use a NOTE: If you're using libcurl as a win32 DLL, you MUST use the .I CURLOPT_WRITEFUNCTION \fICURLOPT_WRITEFUNCTION\fP if you set this option. if you set the .I CURLOPT_FILE option. .TP .TP .B CURLOPT_WRITEFUNCTION .B CURLOPT_WRITEFUNCTION Function pointer that should match the following prototype: Function pointer that should match the following prototype: .BI "size_t function( void *ptr, size_t size, size_t nmemb, FILE *stream);" .BI "size_t function( void *ptr, size_t size, size_t nmemb, void *stream);" This function gets called by libcurl as soon as there is received data that This function gets called by libcurl as soon as there is received data that needs to be written down. The size of the data pointed to by needs to be written down. The size of the data pointed to by \fIptr\fP is .I ptr \fIsize\fP multiplied with \fInmemb\fP. Return the number of bytes actually is written or return -1 to signal error to the library (it will cause it to abort .I size the transfer with CURLE_WRITE_ERROR). multiplied with .I nmemb. Set the \fIstream\fP argument with the \fBCURLOPT_FILE\fP option. Return the number of bytes actually written or return -1 to signal error to the library (it will cause it to abort the transfer). .TP .TP .B CURLOPT_INFILE .B CURLOPT_INFILE Data pointer to pass instead of FILE * to the file read function. Note that if Data pointer to pass to the file read function. Note that if you specify the you specify the \fICURLOPT_READFUNCTION\fP, this is the pointer you'll get as input. If you .I CURLOPT_READFUNCTION don't specify a read callback, this must be a valid FILE *. , this is the pointer you'll get as input. NOTE: If you're using libcurl as a win32 .DLL, you MUST use a NOTE: If you're using libcurl as a win32 DLL, you MUST use a .I CURLOPT_READFUNCTION \fICURLOPT_READFUNCTION\fP if you set this option. if you set the .I CURLOPT_INFILE option. .TP .TP .B CURLOPT_READFUNCTION .B CURLOPT_READFUNCTION Function pointer that should match the following prototype: Function pointer that should match the following prototype: .BI "size_t function( void *ptr, size_t size, size_t nmemb, FILE *stream);" .BI "size_t function( void *ptr, size_t size, size_t nmemb, void *stream);" This function gets called by libcurl as soon as it needs to read data in order This function gets called by libcurl as soon as it needs to read data in order to send it to the peer. The data area pointed at by the pointer to send it to the peer. The data area pointed at by the pointer \fIptr\fP may .I ptr be filled with at most \fIsize\fP multiplied with \fInmemb\fP number of may be filled with at most bytes. Your function must return the actual number of bytes that you stored in .I size that memory area. Returning -1 will signal an error to the library and cause multiplied with it to abort the current transfer immediately (with a CURLE_READ_ERROR return .I nmemb code). number of bytes. Your function must return the actual number of bytes that you stored in that memory area. Returning -1 will signal an error to the library and cause it to abort the current transfer immediately. .TP .TP .B CURLOPT_INFILESIZE .B CURLOPT_INFILESIZE When uploading a file to a remote site, this option should be used to tell When uploading a file to a remote site, this option should be used to tell Loading Loading @@ -317,16 +306,15 @@ struct curl_slist structs properly filled in as described for .I "CURLOPT_QUOTE" .I "CURLOPT_QUOTE" .TP .TP .B CURLOPT_WRITEHEADER .B CURLOPT_WRITEHEADER Pass a FILE * to be used to write the header part of the received data to. The Pass a pointer to be used to write the header part of the received data to. If headers are guaranteed to be written one-by-one to this file handle and only you don't use a callback to take care of the writing, this must be a FILE complete lines are written. Parsing headers should be easy enough using *. The headers are guaranteed to be written one-by-one and only complete lines this. See also the are written. Parsing headers should be easy enough using this. See also the .I CURLOPT_HEADERFUNCTION \fICURLOPT_HEADERFUNCTION\fP option. option. .TP .TP .B CURLOPT_HEADERFUNCTION .B CURLOPT_HEADERFUNCTION Function pointer that should match the following prototype: Function pointer that should match the following prototype: .BI "size_t function( void *ptr, size_t size, size_t nmemb, FILE *stream);" .BI "size_t function( void *ptr, size_t size, size_t nmemb, void *stream);" This function gets called by libcurl as soon as there is received header data This function gets called by libcurl as soon as there is received header data that needs to be written down. The function will be called once for each that needs to be written down. The function will be called once for each header with a complete header line in each invoke. The size of the data header with a complete header line in each invoke. The size of the data Loading include/curl/curl.h +5 −4 Original line number Original line Diff line number Diff line Loading @@ -76,12 +76,12 @@ typedef int (*curl_progress_callback)(void *clientp, typedef size_t (*curl_write_callback)(char *buffer, typedef size_t (*curl_write_callback)(char *buffer, size_t size, size_t size, size_t nitems, size_t nitems, FILE *outstream); void *outstream); typedef size_t (*curl_read_callback)(char *buffer, typedef size_t (*curl_read_callback)(char *buffer, size_t size, size_t size, size_t nitems, size_t nitems, FILE *instream); void *instream); typedef int (*curl_passwd_callback)(void *clientp, typedef int (*curl_passwd_callback)(void *clientp, char *prompt, char *prompt, Loading Loading @@ -173,7 +173,7 @@ typedef enum { typedef enum { typedef enum { CINIT(NOTHING, LONG, 0), /********* the first one is unused ************/ CINIT(NOTHING, LONG, 0), /********* the first one is unused ************/ /* This is the FILE * the regular output should be written to. */ /* This is the FILE * or void * the regular output should be written to. */ CINIT(FILE, OBJECTPOINT, 1), CINIT(FILE, OBJECTPOINT, 1), /* The full URL to get/put */ /* The full URL to get/put */ Loading Loading @@ -276,7 +276,8 @@ typedef enum { /* send linked-list of QUOTE commands */ /* send linked-list of QUOTE commands */ CINIT(QUOTE, OBJECTPOINT, 28), CINIT(QUOTE, OBJECTPOINT, 28), /* send FILE * to store headers to */ /* send FILE * or void * to store headers to, if you use a callback it is simply passed to the callback unmodified */ CINIT(WRITEHEADER, OBJECTPOINT, 29), CINIT(WRITEHEADER, OBJECTPOINT, 29), #ifdef MULTIDOC #ifdef MULTIDOC Loading lib/url.c +2 −2 Original line number Original line Diff line number Diff line Loading @@ -216,10 +216,10 @@ CURLcode Curl_open(CURL **curl, char *url) data->err = stderr; /* default stderr to stderr */ data->err = stderr; /* default stderr to stderr */ /* use fwrite as default function to store output */ /* use fwrite as default function to store output */ data->fwrite = (size_t (*)(char *, size_t, size_t, FILE *))fwrite; data->fwrite = (curl_write_callback)fwrite; /* use fread as default function to read input */ /* use fread as default function to read input */ data->fread = (size_t (*)(char *, size_t, size_t, FILE *))fread; data->fread = (curl_read_callback)fread; /* set the default passwd function */ /* set the default passwd function */ data->fpasswd = my_getpass; data->fpasswd = my_getpass; Loading lib/urldata.h +4 −3 Original line number Original line Diff line number Diff line Loading @@ -456,9 +456,10 @@ struct UrlData { long header_size; /* size of read header(s) in bytes */ long header_size; /* size of read header(s) in bytes */ long request_size; /* the amount of bytes sent in the request(s) */ long request_size; /* the amount of bytes sent in the request(s) */ FILE *out; /* the fetched file goes here */ void *out; /* the fetched file goes here */ FILE *in; /* the uploaded file is read from here */ void *in; /* the uploaded file is read from here */ FILE *writeheader; /* write the header to this is non-NULL */ void *writeheader; /* write the header to this is non-NULL */ char *url; /* what to get */ char *url; /* what to get */ char *freethis; /* if non-NULL, an allocated string for the URL */ char *freethis; /* if non-NULL, an allocated string for the URL */ long use_port; /* which port to use (when not using default) */ long use_port; /* which port to use (when not using default) */ Loading src/main.c +1 −1 Original line number Original line Diff line number Diff line Loading @@ -1268,7 +1268,7 @@ struct OutStruct { struct Configurable *config; struct Configurable *config; }; }; int my_fwrite(void *buffer, size_t size, size_t nmemb, FILE *stream) int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) { { struct OutStruct *out=(struct OutStruct *)stream; struct OutStruct *out=(struct OutStruct *)stream; if(out && !out->stream) { if(out && !out->stream) { Loading Loading
docs/curl_easy_setopt.3 +30 −42 Original line number Original line Diff line number Diff line Loading @@ -42,54 +42,43 @@ call. These options are in a bit of random order, but you'll figure it out! These options are in a bit of random order, but you'll figure it out! .TP 0.8i .TP 0.8i .B CURLOPT_FILE .B CURLOPT_FILE Data pointer to pass instead of FILE * to the file write function. Note that Data pointer to pass to file write function. Note that if you specify the if you specify the .I CURLOPT_WRITEFUNCTION .I CURLOPT_WRITEFUNCTION , this is the pointer you'll get as input. , this is the pointer you'll get as input. If you don't use a callback, you must pass a 'FILE *' as libcurl passes it to fwrite() when writing data. NOTE: If you're using libcurl as a win32 .DLL, you MUST use a NOTE: If you're using libcurl as a win32 DLL, you MUST use the .I CURLOPT_WRITEFUNCTION \fICURLOPT_WRITEFUNCTION\fP if you set this option. if you set the .I CURLOPT_FILE option. .TP .TP .B CURLOPT_WRITEFUNCTION .B CURLOPT_WRITEFUNCTION Function pointer that should match the following prototype: Function pointer that should match the following prototype: .BI "size_t function( void *ptr, size_t size, size_t nmemb, FILE *stream);" .BI "size_t function( void *ptr, size_t size, size_t nmemb, void *stream);" This function gets called by libcurl as soon as there is received data that This function gets called by libcurl as soon as there is received data that needs to be written down. The size of the data pointed to by needs to be written down. The size of the data pointed to by \fIptr\fP is .I ptr \fIsize\fP multiplied with \fInmemb\fP. Return the number of bytes actually is written or return -1 to signal error to the library (it will cause it to abort .I size the transfer with CURLE_WRITE_ERROR). multiplied with .I nmemb. Set the \fIstream\fP argument with the \fBCURLOPT_FILE\fP option. Return the number of bytes actually written or return -1 to signal error to the library (it will cause it to abort the transfer). .TP .TP .B CURLOPT_INFILE .B CURLOPT_INFILE Data pointer to pass instead of FILE * to the file read function. Note that if Data pointer to pass to the file read function. Note that if you specify the you specify the \fICURLOPT_READFUNCTION\fP, this is the pointer you'll get as input. If you .I CURLOPT_READFUNCTION don't specify a read callback, this must be a valid FILE *. , this is the pointer you'll get as input. NOTE: If you're using libcurl as a win32 .DLL, you MUST use a NOTE: If you're using libcurl as a win32 DLL, you MUST use a .I CURLOPT_READFUNCTION \fICURLOPT_READFUNCTION\fP if you set this option. if you set the .I CURLOPT_INFILE option. .TP .TP .B CURLOPT_READFUNCTION .B CURLOPT_READFUNCTION Function pointer that should match the following prototype: Function pointer that should match the following prototype: .BI "size_t function( void *ptr, size_t size, size_t nmemb, FILE *stream);" .BI "size_t function( void *ptr, size_t size, size_t nmemb, void *stream);" This function gets called by libcurl as soon as it needs to read data in order This function gets called by libcurl as soon as it needs to read data in order to send it to the peer. The data area pointed at by the pointer to send it to the peer. The data area pointed at by the pointer \fIptr\fP may .I ptr be filled with at most \fIsize\fP multiplied with \fInmemb\fP number of may be filled with at most bytes. Your function must return the actual number of bytes that you stored in .I size that memory area. Returning -1 will signal an error to the library and cause multiplied with it to abort the current transfer immediately (with a CURLE_READ_ERROR return .I nmemb code). number of bytes. Your function must return the actual number of bytes that you stored in that memory area. Returning -1 will signal an error to the library and cause it to abort the current transfer immediately. .TP .TP .B CURLOPT_INFILESIZE .B CURLOPT_INFILESIZE When uploading a file to a remote site, this option should be used to tell When uploading a file to a remote site, this option should be used to tell Loading Loading @@ -317,16 +306,15 @@ struct curl_slist structs properly filled in as described for .I "CURLOPT_QUOTE" .I "CURLOPT_QUOTE" .TP .TP .B CURLOPT_WRITEHEADER .B CURLOPT_WRITEHEADER Pass a FILE * to be used to write the header part of the received data to. The Pass a pointer to be used to write the header part of the received data to. If headers are guaranteed to be written one-by-one to this file handle and only you don't use a callback to take care of the writing, this must be a FILE complete lines are written. Parsing headers should be easy enough using *. The headers are guaranteed to be written one-by-one and only complete lines this. See also the are written. Parsing headers should be easy enough using this. See also the .I CURLOPT_HEADERFUNCTION \fICURLOPT_HEADERFUNCTION\fP option. option. .TP .TP .B CURLOPT_HEADERFUNCTION .B CURLOPT_HEADERFUNCTION Function pointer that should match the following prototype: Function pointer that should match the following prototype: .BI "size_t function( void *ptr, size_t size, size_t nmemb, FILE *stream);" .BI "size_t function( void *ptr, size_t size, size_t nmemb, void *stream);" This function gets called by libcurl as soon as there is received header data This function gets called by libcurl as soon as there is received header data that needs to be written down. The function will be called once for each that needs to be written down. The function will be called once for each header with a complete header line in each invoke. The size of the data header with a complete header line in each invoke. The size of the data Loading
include/curl/curl.h +5 −4 Original line number Original line Diff line number Diff line Loading @@ -76,12 +76,12 @@ typedef int (*curl_progress_callback)(void *clientp, typedef size_t (*curl_write_callback)(char *buffer, typedef size_t (*curl_write_callback)(char *buffer, size_t size, size_t size, size_t nitems, size_t nitems, FILE *outstream); void *outstream); typedef size_t (*curl_read_callback)(char *buffer, typedef size_t (*curl_read_callback)(char *buffer, size_t size, size_t size, size_t nitems, size_t nitems, FILE *instream); void *instream); typedef int (*curl_passwd_callback)(void *clientp, typedef int (*curl_passwd_callback)(void *clientp, char *prompt, char *prompt, Loading Loading @@ -173,7 +173,7 @@ typedef enum { typedef enum { typedef enum { CINIT(NOTHING, LONG, 0), /********* the first one is unused ************/ CINIT(NOTHING, LONG, 0), /********* the first one is unused ************/ /* This is the FILE * the regular output should be written to. */ /* This is the FILE * or void * the regular output should be written to. */ CINIT(FILE, OBJECTPOINT, 1), CINIT(FILE, OBJECTPOINT, 1), /* The full URL to get/put */ /* The full URL to get/put */ Loading Loading @@ -276,7 +276,8 @@ typedef enum { /* send linked-list of QUOTE commands */ /* send linked-list of QUOTE commands */ CINIT(QUOTE, OBJECTPOINT, 28), CINIT(QUOTE, OBJECTPOINT, 28), /* send FILE * to store headers to */ /* send FILE * or void * to store headers to, if you use a callback it is simply passed to the callback unmodified */ CINIT(WRITEHEADER, OBJECTPOINT, 29), CINIT(WRITEHEADER, OBJECTPOINT, 29), #ifdef MULTIDOC #ifdef MULTIDOC Loading
lib/url.c +2 −2 Original line number Original line Diff line number Diff line Loading @@ -216,10 +216,10 @@ CURLcode Curl_open(CURL **curl, char *url) data->err = stderr; /* default stderr to stderr */ data->err = stderr; /* default stderr to stderr */ /* use fwrite as default function to store output */ /* use fwrite as default function to store output */ data->fwrite = (size_t (*)(char *, size_t, size_t, FILE *))fwrite; data->fwrite = (curl_write_callback)fwrite; /* use fread as default function to read input */ /* use fread as default function to read input */ data->fread = (size_t (*)(char *, size_t, size_t, FILE *))fread; data->fread = (curl_read_callback)fread; /* set the default passwd function */ /* set the default passwd function */ data->fpasswd = my_getpass; data->fpasswd = my_getpass; Loading
lib/urldata.h +4 −3 Original line number Original line Diff line number Diff line Loading @@ -456,9 +456,10 @@ struct UrlData { long header_size; /* size of read header(s) in bytes */ long header_size; /* size of read header(s) in bytes */ long request_size; /* the amount of bytes sent in the request(s) */ long request_size; /* the amount of bytes sent in the request(s) */ FILE *out; /* the fetched file goes here */ void *out; /* the fetched file goes here */ FILE *in; /* the uploaded file is read from here */ void *in; /* the uploaded file is read from here */ FILE *writeheader; /* write the header to this is non-NULL */ void *writeheader; /* write the header to this is non-NULL */ char *url; /* what to get */ char *url; /* what to get */ char *freethis; /* if non-NULL, an allocated string for the URL */ char *freethis; /* if non-NULL, an allocated string for the URL */ long use_port; /* which port to use (when not using default) */ long use_port; /* which port to use (when not using default) */ Loading
src/main.c +1 −1 Original line number Original line Diff line number Diff line Loading @@ -1268,7 +1268,7 @@ struct OutStruct { struct Configurable *config; struct Configurable *config; }; }; int my_fwrite(void *buffer, size_t size, size_t nmemb, FILE *stream) int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) { { struct OutStruct *out=(struct OutStruct *)stream; struct OutStruct *out=(struct OutStruct *)stream; if(out && !out->stream) { if(out && !out->stream) { Loading