1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 16:18:48 -05:00

Michal Marek's cleanup of how curl_easy_setopt() is used in examples and

test code. Thanks to his curl_easy_setopt() typechecker work...
This commit is contained in:
Daniel Stenberg 2008-02-27 09:06:15 +00:00
parent 6cc8df95dd
commit b12fef3f31
7 changed files with 16 additions and 16 deletions

View File

@ -77,7 +77,7 @@ static const char *urls[] = {
#define MAX 10 /* number of simultaneous transfers */ #define MAX 10 /* number of simultaneous transfers */
#define CNT sizeof(urls)/sizeof(char*) /* total number of transfers to do */ #define CNT sizeof(urls)/sizeof(char*) /* total number of transfers to do */
static int cb(char *d, size_t n, size_t l, void *p) static size_t cb(char *d, size_t n, size_t l, void *p)
{ {
/* take care of the data here, ignored in this example */ /* take care of the data here, ignored in this example */
(void)d; (void)d;

View File

@ -37,7 +37,7 @@
/* ioctl callback function */ /* ioctl callback function */
static curlioerr my_ioctl(CURL *handle, curliocmd cmd, void *userp) static curlioerr my_ioctl(CURL *handle, curliocmd cmd, void *userp)
{ {
int fd = (int)userp; intptr_t fd = (intptr_t)userp;
(void)handle; /* not used in here */ (void)handle; /* not used in here */
@ -61,7 +61,7 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{ {
size_t retcode; size_t retcode;
int fd = (int)stream; intptr_t fd = (intptr_t)stream;
retcode = read(fd, ptr, size * nmemb); retcode = read(fd, ptr, size * nmemb);
@ -74,7 +74,7 @@ int main(int argc, char **argv)
{ {
CURL *curl; CURL *curl;
CURLcode res; CURLcode res;
int hd ; intptr_t hd ;
struct stat file_info; struct stat file_info;
char *file; char *file;
@ -100,13 +100,13 @@ int main(int argc, char **argv)
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback); curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* which file to upload */ /* which file to upload */
curl_easy_setopt(curl, CURLOPT_READDATA, hd); curl_easy_setopt(curl, CURLOPT_READDATA, (void*)hd);
/* set the ioctl function */ /* set the ioctl function */
curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, my_ioctl); curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, my_ioctl);
/* pass the file descriptor to the ioctl callback as well */ /* pass the file descriptor to the ioctl callback as well */
curl_easy_setopt(curl, CURLOPT_IOCTLDATA, hd); curl_easy_setopt(curl, CURLOPT_IOCTLDATA, (void*)hd);
/* enable "uploading" (which means PUT when doing HTTP) */ /* enable "uploading" (which means PUT when doing HTTP) */
curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ; curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ;

View File

@ -65,7 +65,7 @@ void dump(const char *text,
static static
int my_trace(CURL *handle, curl_infotype type, int my_trace(CURL *handle, curl_infotype type,
unsigned char *data, size_t size, char *data, size_t size,
void *userp) void *userp)
{ {
struct data *config = (struct data *)userp; struct data *config = (struct data *)userp;
@ -98,7 +98,7 @@ int my_trace(CURL *handle, curl_infotype type,
break; break;
} }
dump(text, stderr, data, size, config->trace_ascii); dump(text, stderr, (unsigned char *)data, size, config->trace_ascii);
return 0; return 0;
} }

View File

@ -26,7 +26,7 @@ struct FtpFile {
FILE *stream; FILE *stream;
}; };
static int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
{ {
struct FtpFile *out=(struct FtpFile *)stream; struct FtpFile *out=(struct FtpFile *)stream;
if(out && !out->stream) { if(out && !out->stream) {

View File

@ -74,7 +74,7 @@ void dump(const char *text,
static static
int my_trace(CURL *handle, curl_infotype type, int my_trace(CURL *handle, curl_infotype type,
unsigned char *data, size_t size, char *data, size_t size,
void *userp) void *userp)
{ {
const char *text; const char *text;

View File

@ -107,10 +107,10 @@ static void *fire(void *ptr)
headers = sethost(NULL); headers = sethost(NULL);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, (void*)headers); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, (void*)tdata->url); curl_easy_setopt(curl, CURLOPT_URL, tdata->url);
printf( "CURLOPT_SHARE\n" ); printf( "CURLOPT_SHARE\n" );
curl_easy_setopt(curl, CURLOPT_SHARE, (void*)tdata->share); curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share);
printf( "PERFORM\n" ); printf( "PERFORM\n" );
code = curl_easy_perform(curl); code = curl_easy_perform(curl);
@ -222,7 +222,7 @@ int test(char *URL)
url = suburl( URL, i ); url = suburl( URL, i );
headers = sethost( NULL ); headers = sethost( NULL );
curl_easy_setopt( curl, CURLOPT_HTTPHEADER, (void*)headers ); curl_easy_setopt( curl, CURLOPT_HTTPHEADER, headers );
curl_easy_setopt( curl, CURLOPT_URL, url ); curl_easy_setopt( curl, CURLOPT_URL, url );
printf( "CURLOPT_SHARE\n" ); printf( "CURLOPT_SHARE\n" );
curl_easy_setopt( curl, CURLOPT_SHARE, share ); curl_easy_setopt( curl, CURLOPT_SHARE, share );

View File

@ -67,7 +67,7 @@ void dump(const char *text,
static static
int my_trace(CURL *handle, curl_infotype type, int my_trace(CURL *handle, curl_infotype type,
unsigned char *data, size_t size, char *data, size_t size,
void *userp) void *userp)
{ {
struct data *config = (struct data *)userp; struct data *config = (struct data *)userp;
@ -100,7 +100,7 @@ int my_trace(CURL *handle, curl_infotype type,
break; break;
} }
dump(text, stderr, data, size, config->trace_ascii); dump(text, stderr, (unsigned char *)data, size, config->trace_ascii);
return 0; return 0;
} }