added progress callback stuff, changed the callback typedefs to be public

This commit is contained in:
Daniel Stenberg
2000-06-08 15:11:39 +00:00
parent dd730b09db
commit 4fd4a6888a
2 changed files with 13 additions and 24 deletions

View File

@@ -96,7 +96,6 @@
#endif #endif
#include "urldata.h" #include "urldata.h"
#include <curl/curl.h>
#include "netrc.h" #include "netrc.h"
#include "formdata.h" #include "formdata.h"
@@ -388,7 +387,7 @@ CURLcode curl_setopt(CURL *curl, CURLoption option, ...)
data->bits.ftp_use_port = data->ftpport?1:0; data->bits.ftp_use_port = data->ftpport?1:0;
break; break;
case CURLOPT_HTTPHEADER: case CURLOPT_HTTPHEADER:
data->headers = va_arg(param, struct HttpHeader *); data->headers = va_arg(param, struct curl_slist *);
break; break;
case CURLOPT_CUSTOMREQUEST: case CURLOPT_CUSTOMREQUEST:
data->customrequest = va_arg(param, char *); data->customrequest = va_arg(param, char *);
@@ -449,6 +448,12 @@ CURLcode curl_setopt(CURL *curl, CURLoption option, ...)
case CURLOPT_POSTQUOTE: case CURLOPT_POSTQUOTE:
data->postquote = va_arg(param, struct curl_slist *); data->postquote = va_arg(param, struct curl_slist *);
break; break;
case CURLOPT_PROGRESSFUNCTION:
data->fprogress = va_arg(param, curl_progress_callback);
break;
case CURLOPT_PROGRESSDATA:
data->progress_client = va_arg(param, void *);
break;
case CURLOPT_PROXYUSERPWD: case CURLOPT_PROXYUSERPWD:
data->proxyuserpwd = va_arg(param, char *); data->proxyuserpwd = va_arg(param, char *);
data->bits.proxy_user_passwd = data->proxyuserpwd?1:0; data->bits.proxy_user_passwd = data->proxyuserpwd?1:0;
@@ -464,13 +469,13 @@ CURLcode curl_setopt(CURL *curl, CURLoption option, ...)
data->err = va_arg(param, FILE *); data->err = va_arg(param, FILE *);
break; break;
case CURLOPT_WRITEFUNCTION: case CURLOPT_WRITEFUNCTION:
data->fwrite = va_arg(param, write_callback); data->fwrite = va_arg(param, curl_write_callback);
break; break;
case CURLOPT_WRITEINFO: case CURLOPT_WRITEINFO:
data->writeinfo = va_arg(param, char *); data->writeinfo = va_arg(param, char *);
break; break;
case CURLOPT_READFUNCTION: case CURLOPT_READFUNCTION:
data->fread = va_arg(param, read_callback); data->fread = va_arg(param, curl_read_callback);
break; break;
case CURLOPT_SSLCERT: case CURLOPT_SSLCERT:
data->cert = va_arg(param, char *); data->cert = va_arg(param, char *);

View File

@@ -92,7 +92,7 @@
#include "timeval.h" #include "timeval.h"
#include <curl/curl.h>
/* Download buffer size, keep it fairly big for speed reasons */ /* Download buffer size, keep it fairly big for speed reasons */
#define BUFSIZE (1024*50) #define BUFSIZE (1024*50)
@@ -263,22 +263,6 @@ struct Configbits {
bool verbose; bool verbose;
}; };
typedef size_t (*progress_callback)(void *clientp,
size_t dltotal,
size_t dlnow,
size_t ultotal,
size_t ulnow);
typedef size_t (*write_callback)(char *buffer,
size_t size,
size_t nitems,
FILE *outstream);
typedef size_t (*read_callback)(char *buffer,
size_t size,
size_t nitems,
FILE *instream);
/* What type of interface that intiated this struct */ /* What type of interface that intiated this struct */
typedef enum { typedef enum {
CURLI_NONE, CURLI_NONE,
@@ -355,13 +339,13 @@ struct UrlData {
char *ftpport; /* port to send with the PORT command */ char *ftpport; /* port to send with the PORT command */
/* function that stores the output:*/ /* function that stores the output:*/
write_callback fwrite; curl_write_callback fwrite;
/* function that reads the input:*/ /* function that reads the input:*/
read_callback fread; curl_read_callback fread;
/* function that wants progress information */ /* function that wants progress information */
progress_callback fprogress; curl_progress_callback fprogress;
void *progress_client; /* pointer to pass to the progress callback */ void *progress_client; /* pointer to pass to the progress callback */
long timeout; /* in seconds, 0 means no timeout */ long timeout; /* in seconds, 0 means no timeout */