Skip to content

Commit

Permalink
fixup added cbptr for pointers passed to callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
bagder committed May 11, 2020
1 parent ae07b6a commit 674c62a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 45 deletions.
41 changes: 22 additions & 19 deletions include/curl/curl.h
Original file line number Diff line number Diff line change
Expand Up @@ -959,12 +959,15 @@ typedef enum {

/* CURLOPT aliases that make no run-time difference */

/* 'char *' arguments to a string with a trailing zero */
/* 'char *' argument to a string with a trailing zero */
#define CURLOPTTYPE_STRINGPOINT CURLOPTTYPE_OBJECTPOINT

/* 'struct curl_slist *' arguments */
/* 'struct curl_slist *' argument */
#define CURLOPTTYPE_SLISTPOINT CURLOPTTYPE_OBJECTPOINT

/* 'void *' argument passed untouched to callback */
#define CURLOPTTYPE_CBPOINT CURLOPTTYPE_OBJECTPOINT

/* 'long' argument with a set of values/bitmask */
#define CURLOPTTYPE_VALUES CURLOPTTYPE_LONG

Expand All @@ -974,7 +977,7 @@ typedef enum {

typedef enum {
/* This is the FILE * or void * the regular output should be written to. */
CURLOPT(CURLOPT_WRITEDATA, CURLOPTTYPE_OBJECTPOINT, 1),
CURLOPT(CURLOPT_WRITEDATA, CURLOPTTYPE_CBPOINT, 1),

/* The full URL to get/put */
CURLOPT(CURLOPT_URL, CURLOPTTYPE_STRINGPOINT, 2),
Expand All @@ -997,7 +1000,7 @@ typedef enum {
/* not used */

/* Specified file stream to upload from (use as input): */
CURLOPT(CURLOPT_READDATA, CURLOPTTYPE_OBJECTPOINT, 9),
CURLOPT(CURLOPT_READDATA, CURLOPTTYPE_CBPOINT, 9),

/* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE
* bytes big. */
Expand Down Expand Up @@ -1082,7 +1085,7 @@ typedef enum {

/* send FILE * or void * to store headers to, if you use a callback it
is simply passed to the callback unmodified */
CURLOPT(CURLOPT_HEADERDATA, CURLOPTTYPE_OBJECTPOINT, 29),
CURLOPT(CURLOPT_HEADERDATA, CURLOPTTYPE_CBPOINT, 29),

/* point to a file to read the initial cookies from, also enables
"cookie awareness" */
Expand Down Expand Up @@ -1168,7 +1171,7 @@ typedef enum {

/* Data passed to the CURLOPT_PROGRESSFUNCTION and CURLOPT_XFERINFOFUNCTION
callbacks */
CURLOPT(CURLOPT_PROGRESSDATA, CURLOPTTYPE_OBJECTPOINT, 57),
CURLOPT(CURLOPT_PROGRESSDATA, CURLOPTTYPE_CBPOINT, 57),
#define CURLOPT_XFERINFODATA CURLOPT_PROGRESSDATA

/* We want the referrer field set automatically when following locations */
Expand Down Expand Up @@ -1302,7 +1305,7 @@ typedef enum {
CURLOPT(CURLOPT_DEBUGFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 94),

/* set the data for the debug function */
CURLOPT(CURLOPT_DEBUGDATA, CURLOPTTYPE_OBJECTPOINT, 95),
CURLOPT(CURLOPT_DEBUGDATA, CURLOPTTYPE_CBPOINT, 95),

/* mark this as start of a cookie session */
CURLOPT(CURLOPT_COOKIESESSION, CURLOPTTYPE_LONG, 96),
Expand Down Expand Up @@ -1360,7 +1363,7 @@ typedef enum {

/* Set the userdata for the ssl context callback function's third
argument */
CURLOPT(CURLOPT_SSL_CTX_DATA, CURLOPTTYPE_OBJECTPOINT, 109),
CURLOPT(CURLOPT_SSL_CTX_DATA, CURLOPTTYPE_CBPOINT, 109),

/* FTP Option that causes missing dirs to be created on the remote server.
In 7.19.4 we introduced the convenience enums for this option using the
Expand Down Expand Up @@ -1447,7 +1450,7 @@ typedef enum {
CURLOPT(CURLOPT_FTPSSLAUTH, CURLOPTTYPE_VALUES, 129),

CURLOPT(CURLOPT_IOCTLFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 130),
CURLOPT(CURLOPT_IOCTLDATA, CURLOPTTYPE_OBJECTPOINT, 131),
CURLOPT(CURLOPT_IOCTLDATA, CURLOPTTYPE_CBPOINT, 131),

/* 132 OBSOLETE. Gone in 7.16.0 */
/* 133 OBSOLETE. Gone in 7.16.0 */
Expand Down Expand Up @@ -1507,7 +1510,7 @@ typedef enum {

/* callback function for setting socket options */
CURLOPT(CURLOPT_SOCKOPTFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 148),
CURLOPT(CURLOPT_SOCKOPTDATA, CURLOPTTYPE_OBJECTPOINT, 149),
CURLOPT(CURLOPT_SOCKOPTDATA, CURLOPTTYPE_CBPOINT, 149),

/* set to 0 to disable session ID re-use for this transfer, default is
enabled (== 1) */
Expand Down Expand Up @@ -1549,7 +1552,7 @@ typedef enum {
CURL_SOCKET_BAD. The callback should have type
curl_opensocket_callback */
CURLOPT(CURLOPT_OPENSOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 163),
CURLOPT(CURLOPT_OPENSOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 164),
CURLOPT(CURLOPT_OPENSOCKETDATA, CURLOPTTYPE_CBPOINT, 164),

/* POST volatile input fields. */
CURLOPT(CURLOPT_COPYPOSTFIELDS, CURLOPTTYPE_OBJECTPOINT, 165),
Expand All @@ -1559,7 +1562,7 @@ typedef enum {

/* Callback function for seeking in the input stream */
CURLOPT(CURLOPT_SEEKFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 167),
CURLOPT(CURLOPT_SEEKDATA, CURLOPTTYPE_OBJECTPOINT, 168),
CURLOPT(CURLOPT_SEEKDATA, CURLOPTTYPE_CBPOINT, 168),

/* CRL file */
CURLOPT(CURLOPT_CRLFILE, CURLOPTTYPE_STRINGPOINT, 169),
Expand Down Expand Up @@ -1620,7 +1623,7 @@ typedef enum {
CURLOPT(CURLOPT_SSH_KEYFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 184),

/* set the SSH host key callback custom pointer */
CURLOPT(CURLOPT_SSH_KEYDATA, CURLOPTTYPE_OBJECTPOINT, 185),
CURLOPT(CURLOPT_SSH_KEYDATA, CURLOPTTYPE_CBPOINT, 185),

/* set the SMTP mail originator */
CURLOPT(CURLOPT_MAIL_FROM, CURLOPTTYPE_STRINGPOINT, 186),
Expand Down Expand Up @@ -1650,7 +1653,7 @@ typedef enum {
CURLOPT(CURLOPT_RTSP_SERVER_CSEQ, CURLOPTTYPE_LONG, 194),

/* The stream to pass to INTERLEAVEFUNCTION. */
CURLOPT(CURLOPT_INTERLEAVEDATA, CURLOPTTYPE_OBJECTPOINT, 195),
CURLOPT(CURLOPT_INTERLEAVEDATA, CURLOPTTYPE_CBPOINT, 195),

/* Let the application define a custom write method for RTP data */
CURLOPT(CURLOPT_INTERLEAVEFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 196),
Expand All @@ -1670,10 +1673,10 @@ typedef enum {
CURLOPT(CURLOPT_FNMATCH_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 200),

/* Let the application define custom chunk data pointer */
CURLOPT(CURLOPT_CHUNK_DATA, CURLOPTTYPE_OBJECTPOINT, 201),
CURLOPT(CURLOPT_CHUNK_DATA, CURLOPTTYPE_CBPOINT, 201),

/* FNMATCH_FUNCTION user pointer */
CURLOPT(CURLOPT_FNMATCH_DATA, CURLOPTTYPE_OBJECTPOINT, 202),
CURLOPT(CURLOPT_FNMATCH_DATA, CURLOPTTYPE_CBPOINT, 202),

/* send linked-list of name:port:address sets */
CURLOPT(CURLOPT_RESOLVE, CURLOPTTYPE_SLISTPOINT, 203),
Expand Down Expand Up @@ -1702,7 +1705,7 @@ typedef enum {
/* Callback function for closing socket (instead of close(2)). The callback
should have type curl_closesocket_callback */
CURLOPT(CURLOPT_CLOSESOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 208),
CURLOPT(CURLOPT_CLOSESOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 209),
CURLOPT(CURLOPT_CLOSESOCKETDATA, CURLOPTTYPE_CBPOINT, 209),

/* allow GSSAPI credential delegation */
CURLOPT(CURLOPT_GSSAPI_DELEGATION, CURLOPTTYPE_VALUES, 210),
Expand Down Expand Up @@ -1915,7 +1918,7 @@ typedef enum {
CURLOPT(CURLOPT_RESOLVER_START_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 272),

/* User data to pass to the resolver start callback. */
CURLOPT(CURLOPT_RESOLVER_START_DATA, CURLOPTTYPE_OBJECTPOINT, 273),
CURLOPT(CURLOPT_RESOLVER_START_DATA, CURLOPTTYPE_CBPOINT, 273),

/* send HAProxy PROXY protocol header? */
CURLOPT(CURLOPT_HAPROXYPROTOCOL, CURLOPTTYPE_LONG, 274),
Expand Down Expand Up @@ -1946,7 +1949,7 @@ typedef enum {
CURLOPT(CURLOPT_TRAILERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 283),

/* pointer to be passed to HTTP_TRAILER_FUNCTION */
CURLOPT(CURLOPT_TRAILERDATA, CURLOPTTYPE_OBJECTPOINT, 284),
CURLOPT(CURLOPT_TRAILERDATA, CURLOPTTYPE_CBPOINT, 284),

/* set this to 1L to allow HTTP/0.9 responses or 0L to disallow */
CURLOPT(CURLOPT_HTTP09_ALLOWED, CURLOPTTYPE_LONG, 285),
Expand Down
13 changes: 8 additions & 5 deletions include/curl/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ extern "C" {

typedef enum {
CURLOT_LONG, /* long (a range of values) */
CURLOT_VALUES, /* long (a defined set or bitmask) */
CURLOT_OFF_T, /* curl_off_t */
CURLOT_OBJECT, /* void * */
CURLOT_STRING, /* char * */
CURLOT_SLIST, /* struct curl_slist * */
CURLOT_VALUES, /* (a defined set or bitmask) */
CURLOT_OFF_T, /* curl_off_t (a range of values) */
CURLOT_OBJECT, /* pointer (void *) */
CURLOT_STRING, /* (char * to zero terminated buffer) */
CURLOT_SLIST, /* (struct curl_slist *) */
CURLOT_CBPTR, /* (void * passed as-is to a callback) */
CURLOT_FUNCTION /* function pointer */
} curl_easytype;

/* The CURLOPTTYPE_* id ranges can still be used to figure out what type/size
to use for curl_easy_setopt() for the given id */
struct curl_easyoption {
const char *name;
CURLoption id;
Expand Down
42 changes: 21 additions & 21 deletions lib/easyoptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ struct curl_easyoption Curl_easyopts[] = {
{"CHUNK_BGN_FUNCTION",
CURLOPT_CHUNK_BGN_FUNCTION, CURLOT_FUNCTION},
{"CHUNK_DATA",
CURLOPT_CHUNK_DATA, CURLOT_OBJECT},
CURLOPT_CHUNK_DATA, CURLOT_CBPTR},
{"CHUNK_END_FUNCTION",
CURLOPT_CHUNK_END_FUNCTION, CURLOT_FUNCTION},
{"CLOSESOCKETDATA",
CURLOPT_CLOSESOCKETDATA, CURLOT_OBJECT},
CURLOPT_CLOSESOCKETDATA, CURLOT_CBPTR},
{"CLOSESOCKETFUNCTION",
CURLOPT_CLOSESOCKETFUNCTION, CURLOT_FUNCTION},
{"CONNECTTIMEOUT",
Expand Down Expand Up @@ -96,7 +96,7 @@ struct curl_easyoption Curl_easyopts[] = {
{"CUSTOMREQUEST",
CURLOPT_CUSTOMREQUEST, CURLOT_STRING},
{"DEBUGDATA",
CURLOPT_DEBUGDATA, CURLOT_OBJECT},
CURLOPT_DEBUGDATA, CURLOT_CBPTR},
{"DEBUGFUNCTION",
CURLOPT_DEBUGFUNCTION, CURLOT_FUNCTION},
{"DEFAULT_PROTOCOL",
Expand Down Expand Up @@ -134,11 +134,11 @@ struct curl_easyoption Curl_easyopts[] = {
CURLOPT_FAILONERROR, CURLOT_LONG},
/* FILE is an alias for WRITEDATA */
{"FILE",
CURLOPT_WRITEDATA, CURLOT_OBJECT},
CURLOPT_WRITEDATA, CURLOT_CBPTR},
{"FILETIME",
CURLOPT_FILETIME, CURLOT_LONG},
{"FNMATCH_DATA",
CURLOPT_FNMATCH_DATA, CURLOT_OBJECT},
CURLOPT_FNMATCH_DATA, CURLOT_CBPTR},
{"FNMATCH_FUNCTION",
CURLOPT_FNMATCH_FUNCTION, CURLOT_FUNCTION},
{"FOLLOWLOCATION",
Expand Down Expand Up @@ -189,7 +189,7 @@ struct curl_easyoption Curl_easyopts[] = {
{"HEADER",
CURLOPT_HEADER, CURLOT_LONG},
{"HEADERDATA",
CURLOPT_HEADERDATA, CURLOT_OBJECT},
CURLOPT_HEADERDATA, CURLOT_CBPTR},
{"HEADERFUNCTION",
CURLOPT_HEADERFUNCTION, CURLOT_FUNCTION},
{"HEADEROPT",
Expand Down Expand Up @@ -218,19 +218,19 @@ struct curl_easyoption Curl_easyopts[] = {
CURLOPT_IGNORE_CONTENT_LENGTH, CURLOT_LONG},
/* INFILE is an alias for READDATA */
{"INFILE",
CURLOPT_READDATA, CURLOT_OBJECT},
CURLOPT_READDATA, CURLOT_CBPTR},
{"INFILESIZE",
CURLOPT_INFILESIZE, CURLOT_LONG},
{"INFILESIZE_LARGE",
CURLOPT_INFILESIZE_LARGE, CURLOT_OFF_T},
{"INTERFACE",
CURLOPT_INTERFACE, CURLOT_STRING},
{"INTERLEAVEDATA",
CURLOPT_INTERLEAVEDATA, CURLOT_OBJECT},
CURLOPT_INTERLEAVEDATA, CURLOT_CBPTR},
{"INTERLEAVEFUNCTION",
CURLOPT_INTERLEAVEFUNCTION, CURLOT_FUNCTION},
{"IOCTLDATA",
CURLOPT_IOCTLDATA, CURLOT_OBJECT},
CURLOPT_IOCTLDATA, CURLOT_CBPTR},
{"IOCTLFUNCTION",
CURLOPT_IOCTLFUNCTION, CURLOT_FUNCTION},
{"IPRESOLVE",
Expand Down Expand Up @@ -301,7 +301,7 @@ struct curl_easyoption Curl_easyopts[] = {
{"OBSOLETE72",
CURLOPT_OBSOLETE72, CURLOT_LONG},
{"OPENSOCKETDATA",
CURLOPT_OPENSOCKETDATA, CURLOT_OBJECT},
CURLOPT_OPENSOCKETDATA, CURLOT_CBPTR},
{"OPENSOCKETFUNCTION",
CURLOPT_OPENSOCKETFUNCTION, CURLOT_FUNCTION},
{"PASSWORD",
Expand Down Expand Up @@ -336,7 +336,7 @@ struct curl_easyoption Curl_easyopts[] = {
{"PRIVATE",
CURLOPT_PRIVATE, CURLOT_OBJECT},
{"PROGRESSDATA",
CURLOPT_PROGRESSDATA, CURLOT_OBJECT},
CURLOPT_PROGRESSDATA, CURLOT_CBPTR},
{"PROGRESSFUNCTION",
CURLOPT_PROGRESSFUNCTION, CURLOT_FUNCTION},
{"PROTOCOLS",
Expand Down Expand Up @@ -406,7 +406,7 @@ struct curl_easyoption Curl_easyopts[] = {
{"RANGE",
CURLOPT_RANGE, CURLOT_STRING},
{"READDATA",
CURLOPT_READDATA, CURLOT_OBJECT},
CURLOPT_READDATA, CURLOT_CBPTR},
{"READFUNCTION",
CURLOPT_READFUNCTION, CURLOT_FUNCTION},
{"REDIR_PROTOCOLS",
Expand All @@ -418,7 +418,7 @@ struct curl_easyoption Curl_easyopts[] = {
{"RESOLVE",
CURLOPT_RESOLVE, CURLOT_SLIST},
{"RESOLVER_START_DATA",
CURLOPT_RESOLVER_START_DATA, CURLOT_OBJECT},
CURLOPT_RESOLVER_START_DATA, CURLOT_CBPTR},
{"RESOLVER_START_FUNCTION",
CURLOPT_RESOLVER_START_FUNCTION, CURLOT_FUNCTION},
{"RESUME_FROM",
Expand All @@ -445,7 +445,7 @@ struct curl_easyoption Curl_easyopts[] = {
{"SASL_IR",
CURLOPT_SASL_IR, CURLOT_LONG},
{"SEEKDATA",
CURLOPT_SEEKDATA, CURLOT_OBJECT},
CURLOPT_SEEKDATA, CURLOT_CBPTR},
{"SEEKFUNCTION",
CURLOPT_SEEKFUNCTION, CURLOT_FUNCTION},
/* SERVER_RESPONSE_TIMEOUT is an alias for FTP_RESPONSE_TIMEOUT */
Expand All @@ -456,7 +456,7 @@ struct curl_easyoption Curl_easyopts[] = {
{"SHARE",
CURLOPT_SHARE, CURLOT_OBJECT},
{"SOCKOPTDATA",
CURLOPT_SOCKOPTDATA, CURLOT_OBJECT},
CURLOPT_SOCKOPTDATA, CURLOT_CBPTR},
{"SOCKOPTFUNCTION",
CURLOPT_SOCKOPTFUNCTION, CURLOT_FUNCTION},
{"SOCKS5_AUTH",
Expand All @@ -472,7 +472,7 @@ struct curl_easyoption Curl_easyopts[] = {
{"SSH_HOST_PUBLIC_KEY_MD5",
CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, CURLOT_STRING},
{"SSH_KEYDATA",
CURLOPT_SSH_KEYDATA, CURLOT_OBJECT},
CURLOPT_SSH_KEYDATA, CURLOT_CBPTR},
{"SSH_KEYFUNCTION",
CURLOPT_SSH_KEYFUNCTION, CURLOT_FUNCTION},
{"SSH_KNOWNHOSTS",
Expand Down Expand Up @@ -504,7 +504,7 @@ struct curl_easyoption Curl_easyopts[] = {
{"SSL_CIPHER_LIST",
CURLOPT_SSL_CIPHER_LIST, CURLOT_STRING},
{"SSL_CTX_DATA",
CURLOPT_SSL_CTX_DATA, CURLOT_OBJECT},
CURLOPT_SSL_CTX_DATA, CURLOT_CBPTR},
{"SSL_CTX_FUNCTION",
CURLOPT_SSL_CTX_FUNCTION, CURLOT_FUNCTION},
{"SSL_ENABLE_ALPN",
Expand Down Expand Up @@ -568,7 +568,7 @@ struct curl_easyoption Curl_easyopts[] = {
{"TLSAUTH_USERNAME",
CURLOPT_TLSAUTH_USERNAME, CURLOT_STRING},
{"TRAILERDATA",
CURLOPT_TRAILERDATA, CURLOT_OBJECT},
CURLOPT_TRAILERDATA, CURLOT_CBPTR},
{"TRAILERFUNCTION",
CURLOPT_TRAILERFUNCTION, CURLOT_FUNCTION},
{"TRANSFERTEXT",
Expand Down Expand Up @@ -600,15 +600,15 @@ struct curl_easyoption Curl_easyopts[] = {
{"WILDCARDMATCH",
CURLOPT_WILDCARDMATCH, CURLOT_LONG},
{"WRITEDATA",
CURLOPT_WRITEDATA, CURLOT_OBJECT},
CURLOPT_WRITEDATA, CURLOT_CBPTR},
{"WRITEFUNCTION",
CURLOPT_WRITEFUNCTION, CURLOT_FUNCTION},
/* WRITEHEADER is an alias for HEADERDATA */
{"WRITEHEADER",
CURLOPT_HEADERDATA, CURLOT_OBJECT},
CURLOPT_HEADERDATA, CURLOT_CBPTR},
/* XFERINFODATA is an alias for PROGRESSDATA */
{"XFERINFODATA",
CURLOPT_PROGRESSDATA, CURLOT_OBJECT},
CURLOPT_PROGRESSDATA, CURLOT_CBPTR},
{"XFERINFOFUNCTION",
CURLOPT_XFERINFOFUNCTION, CURLOT_FUNCTION},
{"XOAUTH2_BEARER",
Expand Down
1 change: 1 addition & 0 deletions lib/optiontable.pl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
$name=$1;
}
$ext =~ s/CURLOPTTYPE_//;
$ext =~ s/CBPOINT/CBPTR/;
$ext =~ s/POINT\z//;
$type = "CURLOT_$ext";

Expand Down

0 comments on commit 674c62a

Please sign in to comment.