├── bin └── curl.exe ├── lib └── libcurl_a.lib ├── README.md └── include └── curl ├── stdcheaders.h ├── mprintf.h ├── options.h ├── header.h ├── curlver.h ├── easy.h ├── urlapi.h ├── multi.h ├── system.h └── typecheck-gcc.h /bin/curl.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zkteco-home/curl/HEAD/bin/curl.exe -------------------------------------------------------------------------------- /lib/libcurl_a.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zkteco-home/curl/HEAD/lib/libcurl_a.lib -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # curl 2 | 3 | version:7.84.0 4 | 5 | x64 for windows 6 | 7 | static library 8 | -------------------------------------------------------------------------------- /include/curl/stdcheaders.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_STDCHEADERS_H 2 | #define CURLINC_STDCHEADERS_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2022, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * SPDX-License-Identifier: curl 24 | * 25 | ***************************************************************************/ 26 | 27 | #include 28 | 29 | size_t fread(void *, size_t, size_t, FILE *); 30 | size_t fwrite(const void *, size_t, size_t, FILE *); 31 | 32 | int strcasecmp(const char *, const char *); 33 | int strncasecmp(const char *, const char *, size_t); 34 | 35 | #endif /* CURLINC_STDCHEADERS_H */ 36 | -------------------------------------------------------------------------------- /include/curl/mprintf.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_MPRINTF_H 2 | #define CURLINC_MPRINTF_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2022, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * SPDX-License-Identifier: curl 24 | * 25 | ***************************************************************************/ 26 | 27 | #include 28 | #include /* needed for FILE */ 29 | #include "curl.h" /* for CURL_EXTERN */ 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | CURL_EXTERN int curl_mprintf(const char *format, ...); 36 | CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...); 37 | CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...); 38 | CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength, 39 | const char *format, ...); 40 | CURL_EXTERN int curl_mvprintf(const char *format, va_list args); 41 | CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args); 42 | CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args); 43 | CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength, 44 | const char *format, va_list args); 45 | CURL_EXTERN char *curl_maprintf(const char *format, ...); 46 | CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* CURLINC_MPRINTF_H */ 53 | -------------------------------------------------------------------------------- /include/curl/options.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_OPTIONS_H 2 | #define CURLINC_OPTIONS_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 2018 - 2022, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * SPDX-License-Identifier: curl 24 | * 25 | ***************************************************************************/ 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | typedef enum { 32 | CURLOT_LONG, /* long (a range of values) */ 33 | CURLOT_VALUES, /* (a defined set or bitmask) */ 34 | CURLOT_OFF_T, /* curl_off_t (a range of values) */ 35 | CURLOT_OBJECT, /* pointer (void *) */ 36 | CURLOT_STRING, /* (char * to zero terminated buffer) */ 37 | CURLOT_SLIST, /* (struct curl_slist *) */ 38 | CURLOT_CBPTR, /* (void * passed as-is to a callback) */ 39 | CURLOT_BLOB, /* blob (struct curl_blob *) */ 40 | CURLOT_FUNCTION /* function pointer */ 41 | } curl_easytype; 42 | 43 | /* Flag bits */ 44 | 45 | /* "alias" means it is provided for old programs to remain functional, 46 | we prefer another name */ 47 | #define CURLOT_FLAG_ALIAS (1<<0) 48 | 49 | /* The CURLOPTTYPE_* id ranges can still be used to figure out what type/size 50 | to use for curl_easy_setopt() for the given id */ 51 | struct curl_easyoption { 52 | const char *name; 53 | CURLoption id; 54 | curl_easytype type; 55 | unsigned int flags; 56 | }; 57 | 58 | CURL_EXTERN const struct curl_easyoption * 59 | curl_easy_option_by_name(const char *name); 60 | 61 | CURL_EXTERN const struct curl_easyoption * 62 | curl_easy_option_by_id(CURLoption id); 63 | 64 | CURL_EXTERN const struct curl_easyoption * 65 | curl_easy_option_next(const struct curl_easyoption *prev); 66 | 67 | #ifdef __cplusplus 68 | } /* end of extern "C" */ 69 | #endif 70 | #endif /* CURLINC_OPTIONS_H */ 71 | -------------------------------------------------------------------------------- /include/curl/header.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_HEADER_H 2 | #define CURLINC_HEADER_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 2018 - 2022, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * SPDX-License-Identifier: curl 24 | * 25 | ***************************************************************************/ 26 | 27 | struct curl_header { 28 | char *name; /* this might not use the same case */ 29 | char *value; 30 | size_t amount; /* number of headers using this name */ 31 | size_t index; /* ... of this instance, 0 or higher */ 32 | unsigned int origin; /* see bits below */ 33 | void *anchor; /* handle privately used by libcurl */ 34 | }; 35 | 36 | /* 'origin' bits */ 37 | #define CURLH_HEADER (1<<0) /* plain server header */ 38 | #define CURLH_TRAILER (1<<1) /* trailers */ 39 | #define CURLH_CONNECT (1<<2) /* CONNECT headers */ 40 | #define CURLH_1XX (1<<3) /* 1xx headers */ 41 | #define CURLH_PSEUDO (1<<4) /* pseudo headers */ 42 | 43 | typedef enum { 44 | CURLHE_OK, 45 | CURLHE_BADINDEX, /* header exists but not with this index */ 46 | CURLHE_MISSING, /* no such header exists */ 47 | CURLHE_NOHEADERS, /* no headers at all exist (yet) */ 48 | CURLHE_NOREQUEST, /* no request with this number was used */ 49 | CURLHE_OUT_OF_MEMORY, /* out of memory while processing */ 50 | CURLHE_BAD_ARGUMENT, /* a function argument was not okay */ 51 | CURLHE_NOT_BUILT_IN /* if API was disabled in the build */ 52 | } CURLHcode; 53 | 54 | CURL_EXTERN CURLHcode curl_easy_header(CURL *easy, 55 | const char *name, 56 | size_t index, 57 | unsigned int origin, 58 | int request, 59 | struct curl_header **hout); 60 | 61 | CURL_EXTERN struct curl_header *curl_easy_nextheader(CURL *easy, 62 | unsigned int origin, 63 | int request, 64 | struct curl_header *prev); 65 | 66 | #endif /* CURLINC_HEADER_H */ 67 | -------------------------------------------------------------------------------- /include/curl/curlver.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_CURLVER_H 2 | #define CURLINC_CURLVER_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2022, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * SPDX-License-Identifier: curl 24 | * 25 | ***************************************************************************/ 26 | 27 | /* This header file contains nothing but libcurl version info, generated by 28 | a script at release-time. This was made its own header file in 7.11.2 */ 29 | 30 | /* This is the global package copyright */ 31 | #define LIBCURL_COPYRIGHT "1996 - 2022 Daniel Stenberg, ." 32 | 33 | /* This is the version number of the libcurl package from which this header 34 | file origins: */ 35 | #define LIBCURL_VERSION "7.84.0" 36 | 37 | /* The numeric version number is also available "in parts" by using these 38 | defines: */ 39 | #define LIBCURL_VERSION_MAJOR 7 40 | #define LIBCURL_VERSION_MINOR 84 41 | #define LIBCURL_VERSION_PATCH 0 42 | 43 | /* This is the numeric version of the libcurl version number, meant for easier 44 | parsing and comparisons by programs. The LIBCURL_VERSION_NUM define will 45 | always follow this syntax: 46 | 47 | 0xXXYYZZ 48 | 49 | Where XX, YY and ZZ are the main version, release and patch numbers in 50 | hexadecimal (using 8 bits each). All three numbers are always represented 51 | using two digits. 1.2 would appear as "0x010200" while version 9.11.7 52 | appears as "0x090b07". 53 | 54 | This 6-digit (24 bits) hexadecimal number does not show pre-release number, 55 | and it is always a greater number in a more recent release. It makes 56 | comparisons with greater than and less than work. 57 | 58 | Note: This define is the full hex number and _does not_ use the 59 | CURL_VERSION_BITS() macro since curl's own configure script greps for it 60 | and needs it to contain the full number. 61 | */ 62 | #define LIBCURL_VERSION_NUM 0x075400 63 | 64 | /* 65 | * This is the date and time when the full source package was created. The 66 | * timestamp is not stored in git, as the timestamp is properly set in the 67 | * tarballs by the maketgz script. 68 | * 69 | * The format of the date follows this template: 70 | * 71 | * "2007-11-23" 72 | */ 73 | #define LIBCURL_TIMESTAMP "2022-06-27" 74 | 75 | #define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z)) 76 | #define CURL_AT_LEAST_VERSION(x,y,z) \ 77 | (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z)) 78 | 79 | #endif /* CURLINC_CURLVER_H */ 80 | -------------------------------------------------------------------------------- /include/curl/easy.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_EASY_H 2 | #define CURLINC_EASY_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2022, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * SPDX-License-Identifier: curl 24 | * 25 | ***************************************************************************/ 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Flag bits in the curl_blob struct: */ 31 | #define CURL_BLOB_COPY 1 /* tell libcurl to copy the data */ 32 | #define CURL_BLOB_NOCOPY 0 /* tell libcurl to NOT copy the data */ 33 | 34 | struct curl_blob { 35 | void *data; 36 | size_t len; 37 | unsigned int flags; /* bit 0 is defined, the rest are reserved and should be 38 | left zeroes */ 39 | }; 40 | 41 | CURL_EXTERN CURL *curl_easy_init(void); 42 | CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...); 43 | CURL_EXTERN CURLcode curl_easy_perform(CURL *curl); 44 | CURL_EXTERN void curl_easy_cleanup(CURL *curl); 45 | 46 | /* 47 | * NAME curl_easy_getinfo() 48 | * 49 | * DESCRIPTION 50 | * 51 | * Request internal information from the curl session with this function. The 52 | * third argument MUST be a pointer to a long, a pointer to a char * or a 53 | * pointer to a double (as the documentation describes elsewhere). The data 54 | * pointed to will be filled in accordingly and can be relied upon only if the 55 | * function returns CURLE_OK. This function is intended to get used *AFTER* a 56 | * performed transfer, all results from this function are undefined until the 57 | * transfer is completed. 58 | */ 59 | CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...); 60 | 61 | 62 | /* 63 | * NAME curl_easy_duphandle() 64 | * 65 | * DESCRIPTION 66 | * 67 | * Creates a new curl session handle with the same options set for the handle 68 | * passed in. Duplicating a handle could only be a matter of cloning data and 69 | * options, internal state info and things like persistent connections cannot 70 | * be transferred. It is useful in multithreaded applications when you can run 71 | * curl_easy_duphandle() for each new thread to avoid a series of identical 72 | * curl_easy_setopt() invokes in every thread. 73 | */ 74 | CURL_EXTERN CURL *curl_easy_duphandle(CURL *curl); 75 | 76 | /* 77 | * NAME curl_easy_reset() 78 | * 79 | * DESCRIPTION 80 | * 81 | * Re-initializes a CURL handle to the default values. This puts back the 82 | * handle to the same state as it was in when it was just created. 83 | * 84 | * It does keep: live connections, the Session ID cache, the DNS cache and the 85 | * cookies. 86 | */ 87 | CURL_EXTERN void curl_easy_reset(CURL *curl); 88 | 89 | /* 90 | * NAME curl_easy_recv() 91 | * 92 | * DESCRIPTION 93 | * 94 | * Receives data from the connected socket. Use after successful 95 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. 96 | */ 97 | CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, 98 | size_t *n); 99 | 100 | /* 101 | * NAME curl_easy_send() 102 | * 103 | * DESCRIPTION 104 | * 105 | * Sends data over the connected socket. Use after successful 106 | * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. 107 | */ 108 | CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer, 109 | size_t buflen, size_t *n); 110 | 111 | 112 | /* 113 | * NAME curl_easy_upkeep() 114 | * 115 | * DESCRIPTION 116 | * 117 | * Performs connection upkeep for the given session handle. 118 | */ 119 | CURL_EXTERN CURLcode curl_easy_upkeep(CURL *curl); 120 | 121 | #ifdef __cplusplus 122 | } 123 | #endif 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /include/curl/urlapi.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_URLAPI_H 2 | #define CURLINC_URLAPI_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 2018 - 2022, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * SPDX-License-Identifier: curl 24 | * 25 | ***************************************************************************/ 26 | 27 | #include "curl.h" 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /* the error codes for the URL API */ 34 | typedef enum { 35 | CURLUE_OK, 36 | CURLUE_BAD_HANDLE, /* 1 */ 37 | CURLUE_BAD_PARTPOINTER, /* 2 */ 38 | CURLUE_MALFORMED_INPUT, /* 3 */ 39 | CURLUE_BAD_PORT_NUMBER, /* 4 */ 40 | CURLUE_UNSUPPORTED_SCHEME, /* 5 */ 41 | CURLUE_URLDECODE, /* 6 */ 42 | CURLUE_OUT_OF_MEMORY, /* 7 */ 43 | CURLUE_USER_NOT_ALLOWED, /* 8 */ 44 | CURLUE_UNKNOWN_PART, /* 9 */ 45 | CURLUE_NO_SCHEME, /* 10 */ 46 | CURLUE_NO_USER, /* 11 */ 47 | CURLUE_NO_PASSWORD, /* 12 */ 48 | CURLUE_NO_OPTIONS, /* 13 */ 49 | CURLUE_NO_HOST, /* 14 */ 50 | CURLUE_NO_PORT, /* 15 */ 51 | CURLUE_NO_QUERY, /* 16 */ 52 | CURLUE_NO_FRAGMENT, /* 17 */ 53 | CURLUE_NO_ZONEID, /* 18 */ 54 | CURLUE_BAD_FILE_URL, /* 19 */ 55 | CURLUE_BAD_FRAGMENT, /* 20 */ 56 | CURLUE_BAD_HOSTNAME, /* 21 */ 57 | CURLUE_BAD_IPV6, /* 22 */ 58 | CURLUE_BAD_LOGIN, /* 23 */ 59 | CURLUE_BAD_PASSWORD, /* 24 */ 60 | CURLUE_BAD_PATH, /* 25 */ 61 | CURLUE_BAD_QUERY, /* 26 */ 62 | CURLUE_BAD_SCHEME, /* 27 */ 63 | CURLUE_BAD_SLASHES, /* 28 */ 64 | CURLUE_BAD_USER, /* 29 */ 65 | CURLUE_LAST 66 | } CURLUcode; 67 | 68 | typedef enum { 69 | CURLUPART_URL, 70 | CURLUPART_SCHEME, 71 | CURLUPART_USER, 72 | CURLUPART_PASSWORD, 73 | CURLUPART_OPTIONS, 74 | CURLUPART_HOST, 75 | CURLUPART_PORT, 76 | CURLUPART_PATH, 77 | CURLUPART_QUERY, 78 | CURLUPART_FRAGMENT, 79 | CURLUPART_ZONEID /* added in 7.65.0 */ 80 | } CURLUPart; 81 | 82 | #define CURLU_DEFAULT_PORT (1<<0) /* return default port number */ 83 | #define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set, 84 | if the port number matches the 85 | default for the scheme */ 86 | #define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if 87 | missing */ 88 | #define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */ 89 | #define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */ 90 | #define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */ 91 | #define CURLU_URLDECODE (1<<6) /* URL decode on get */ 92 | #define CURLU_URLENCODE (1<<7) /* URL encode on set */ 93 | #define CURLU_APPENDQUERY (1<<8) /* append a form style part */ 94 | #define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */ 95 | #define CURLU_NO_AUTHORITY (1<<10) /* Allow empty authority when the 96 | scheme is unknown. */ 97 | #define CURLU_ALLOW_SPACE (1<<11) /* Allow spaces in the URL */ 98 | 99 | typedef struct Curl_URL CURLU; 100 | 101 | /* 102 | * curl_url() creates a new CURLU handle and returns a pointer to it. 103 | * Must be freed with curl_url_cleanup(). 104 | */ 105 | CURL_EXTERN CURLU *curl_url(void); 106 | 107 | /* 108 | * curl_url_cleanup() frees the CURLU handle and related resources used for 109 | * the URL parsing. It will not free strings previously returned with the URL 110 | * API. 111 | */ 112 | CURL_EXTERN void curl_url_cleanup(CURLU *handle); 113 | 114 | /* 115 | * curl_url_dup() duplicates a CURLU handle and returns a new copy. The new 116 | * handle must also be freed with curl_url_cleanup(). 117 | */ 118 | CURL_EXTERN CURLU *curl_url_dup(CURLU *in); 119 | 120 | /* 121 | * curl_url_get() extracts a specific part of the URL from a CURLU 122 | * handle. Returns error code. The returned pointer MUST be freed with 123 | * curl_free() afterwards. 124 | */ 125 | CURL_EXTERN CURLUcode curl_url_get(CURLU *handle, CURLUPart what, 126 | char **part, unsigned int flags); 127 | 128 | /* 129 | * curl_url_set() sets a specific part of the URL in a CURLU handle. Returns 130 | * error code. The passed in string will be copied. Passing a NULL instead of 131 | * a part string, clears that part. 132 | */ 133 | CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what, 134 | const char *part, unsigned int flags); 135 | 136 | /* 137 | * curl_url_strerror() turns a CURLUcode value into the equivalent human 138 | * readable error string. This is useful for printing meaningful error 139 | * messages. 140 | */ 141 | CURL_EXTERN const char *curl_url_strerror(CURLUcode); 142 | 143 | #ifdef __cplusplus 144 | } /* end of extern "C" */ 145 | #endif 146 | 147 | #endif /* CURLINC_URLAPI_H */ 148 | -------------------------------------------------------------------------------- /include/curl/multi.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_MULTI_H 2 | #define CURLINC_MULTI_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2022, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * SPDX-License-Identifier: curl 24 | * 25 | ***************************************************************************/ 26 | /* 27 | This is an "external" header file. Don't give away any internals here! 28 | 29 | GOALS 30 | 31 | o Enable a "pull" interface. The application that uses libcurl decides where 32 | and when to ask libcurl to get/send data. 33 | 34 | o Enable multiple simultaneous transfers in the same thread without making it 35 | complicated for the application. 36 | 37 | o Enable the application to select() on its own file descriptors and curl's 38 | file descriptors simultaneous easily. 39 | 40 | */ 41 | 42 | /* 43 | * This header file should not really need to include "curl.h" since curl.h 44 | * itself includes this file and we expect user applications to do #include 45 | * without the need for especially including multi.h. 46 | * 47 | * For some reason we added this include here at one point, and rather than to 48 | * break existing (wrongly written) libcurl applications, we leave it as-is 49 | * but with this warning attached. 50 | */ 51 | #include "curl.h" 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | #if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER) 58 | typedef struct Curl_multi CURLM; 59 | #else 60 | typedef void CURLM; 61 | #endif 62 | 63 | typedef enum { 64 | CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or 65 | curl_multi_socket*() soon */ 66 | CURLM_OK, 67 | CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */ 68 | CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */ 69 | CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */ 70 | CURLM_INTERNAL_ERROR, /* this is a libcurl bug */ 71 | CURLM_BAD_SOCKET, /* the passed in socket argument did not match */ 72 | CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */ 73 | CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was 74 | attempted to get added - again */ 75 | CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a 76 | callback */ 77 | CURLM_WAKEUP_FAILURE, /* wakeup is unavailable or failed */ 78 | CURLM_BAD_FUNCTION_ARGUMENT, /* function called with a bad parameter */ 79 | CURLM_ABORTED_BY_CALLBACK, 80 | CURLM_UNRECOVERABLE_POLL, 81 | CURLM_LAST 82 | } CURLMcode; 83 | 84 | /* just to make code nicer when using curl_multi_socket() you can now check 85 | for CURLM_CALL_MULTI_SOCKET too in the same style it works for 86 | curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */ 87 | #define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM 88 | 89 | /* bitmask bits for CURLMOPT_PIPELINING */ 90 | #define CURLPIPE_NOTHING 0L 91 | #define CURLPIPE_HTTP1 1L 92 | #define CURLPIPE_MULTIPLEX 2L 93 | 94 | typedef enum { 95 | CURLMSG_NONE, /* first, not used */ 96 | CURLMSG_DONE, /* This easy handle has completed. 'result' contains 97 | the CURLcode of the transfer */ 98 | CURLMSG_LAST /* last, not used */ 99 | } CURLMSG; 100 | 101 | struct CURLMsg { 102 | CURLMSG msg; /* what this message means */ 103 | CURL *easy_handle; /* the handle it concerns */ 104 | union { 105 | void *whatever; /* message-specific data */ 106 | CURLcode result; /* return code for transfer */ 107 | } data; 108 | }; 109 | typedef struct CURLMsg CURLMsg; 110 | 111 | /* Based on poll(2) structure and values. 112 | * We don't use pollfd and POLL* constants explicitly 113 | * to cover platforms without poll(). */ 114 | #define CURL_WAIT_POLLIN 0x0001 115 | #define CURL_WAIT_POLLPRI 0x0002 116 | #define CURL_WAIT_POLLOUT 0x0004 117 | 118 | struct curl_waitfd { 119 | curl_socket_t fd; 120 | short events; 121 | short revents; /* not supported yet */ 122 | }; 123 | 124 | /* 125 | * Name: curl_multi_init() 126 | * 127 | * Desc: inititalize multi-style curl usage 128 | * 129 | * Returns: a new CURLM handle to use in all 'curl_multi' functions. 130 | */ 131 | CURL_EXTERN CURLM *curl_multi_init(void); 132 | 133 | /* 134 | * Name: curl_multi_add_handle() 135 | * 136 | * Desc: add a standard curl handle to the multi stack 137 | * 138 | * Returns: CURLMcode type, general multi error code. 139 | */ 140 | CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle, 141 | CURL *curl_handle); 142 | 143 | /* 144 | * Name: curl_multi_remove_handle() 145 | * 146 | * Desc: removes a curl handle from the multi stack again 147 | * 148 | * Returns: CURLMcode type, general multi error code. 149 | */ 150 | CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle, 151 | CURL *curl_handle); 152 | 153 | /* 154 | * Name: curl_multi_fdset() 155 | * 156 | * Desc: Ask curl for its fd_set sets. The app can use these to select() or 157 | * poll() on. We want curl_multi_perform() called as soon as one of 158 | * them are ready. 159 | * 160 | * Returns: CURLMcode type, general multi error code. 161 | */ 162 | CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle, 163 | fd_set *read_fd_set, 164 | fd_set *write_fd_set, 165 | fd_set *exc_fd_set, 166 | int *max_fd); 167 | 168 | /* 169 | * Name: curl_multi_wait() 170 | * 171 | * Desc: Poll on all fds within a CURLM set as well as any 172 | * additional fds passed to the function. 173 | * 174 | * Returns: CURLMcode type, general multi error code. 175 | */ 176 | CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle, 177 | struct curl_waitfd extra_fds[], 178 | unsigned int extra_nfds, 179 | int timeout_ms, 180 | int *ret); 181 | 182 | /* 183 | * Name: curl_multi_poll() 184 | * 185 | * Desc: Poll on all fds within a CURLM set as well as any 186 | * additional fds passed to the function. 187 | * 188 | * Returns: CURLMcode type, general multi error code. 189 | */ 190 | CURL_EXTERN CURLMcode curl_multi_poll(CURLM *multi_handle, 191 | struct curl_waitfd extra_fds[], 192 | unsigned int extra_nfds, 193 | int timeout_ms, 194 | int *ret); 195 | 196 | /* 197 | * Name: curl_multi_wakeup() 198 | * 199 | * Desc: wakes up a sleeping curl_multi_poll call. 200 | * 201 | * Returns: CURLMcode type, general multi error code. 202 | */ 203 | CURL_EXTERN CURLMcode curl_multi_wakeup(CURLM *multi_handle); 204 | 205 | /* 206 | * Name: curl_multi_perform() 207 | * 208 | * Desc: When the app thinks there's data available for curl it calls this 209 | * function to read/write whatever there is right now. This returns 210 | * as soon as the reads and writes are done. This function does not 211 | * require that there actually is data available for reading or that 212 | * data can be written, it can be called just in case. It returns 213 | * the number of handles that still transfer data in the second 214 | * argument's integer-pointer. 215 | * 216 | * Returns: CURLMcode type, general multi error code. *NOTE* that this only 217 | * returns errors etc regarding the whole multi stack. There might 218 | * still have occurred problems on individual transfers even when 219 | * this returns OK. 220 | */ 221 | CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle, 222 | int *running_handles); 223 | 224 | /* 225 | * Name: curl_multi_cleanup() 226 | * 227 | * Desc: Cleans up and removes a whole multi stack. It does not free or 228 | * touch any individual easy handles in any way. We need to define 229 | * in what state those handles will be if this function is called 230 | * in the middle of a transfer. 231 | * 232 | * Returns: CURLMcode type, general multi error code. 233 | */ 234 | CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle); 235 | 236 | /* 237 | * Name: curl_multi_info_read() 238 | * 239 | * Desc: Ask the multi handle if there's any messages/informationals from 240 | * the individual transfers. Messages include informationals such as 241 | * error code from the transfer or just the fact that a transfer is 242 | * completed. More details on these should be written down as well. 243 | * 244 | * Repeated calls to this function will return a new struct each 245 | * time, until a special "end of msgs" struct is returned as a signal 246 | * that there is no more to get at this point. 247 | * 248 | * The data the returned pointer points to will not survive calling 249 | * curl_multi_cleanup(). 250 | * 251 | * The 'CURLMsg' struct is meant to be very simple and only contain 252 | * very basic information. If more involved information is wanted, 253 | * we will provide the particular "transfer handle" in that struct 254 | * and that should/could/would be used in subsequent 255 | * curl_easy_getinfo() calls (or similar). The point being that we 256 | * must never expose complex structs to applications, as then we'll 257 | * undoubtably get backwards compatibility problems in the future. 258 | * 259 | * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out 260 | * of structs. It also writes the number of messages left in the 261 | * queue (after this read) in the integer the second argument points 262 | * to. 263 | */ 264 | CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle, 265 | int *msgs_in_queue); 266 | 267 | /* 268 | * Name: curl_multi_strerror() 269 | * 270 | * Desc: The curl_multi_strerror function may be used to turn a CURLMcode 271 | * value into the equivalent human readable error string. This is 272 | * useful for printing meaningful error messages. 273 | * 274 | * Returns: A pointer to a null-terminated error message. 275 | */ 276 | CURL_EXTERN const char *curl_multi_strerror(CURLMcode); 277 | 278 | /* 279 | * Name: curl_multi_socket() and 280 | * curl_multi_socket_all() 281 | * 282 | * Desc: An alternative version of curl_multi_perform() that allows the 283 | * application to pass in one of the file descriptors that have been 284 | * detected to have "action" on them and let libcurl perform. 285 | * See man page for details. 286 | */ 287 | #define CURL_POLL_NONE 0 288 | #define CURL_POLL_IN 1 289 | #define CURL_POLL_OUT 2 290 | #define CURL_POLL_INOUT 3 291 | #define CURL_POLL_REMOVE 4 292 | 293 | #define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD 294 | 295 | #define CURL_CSELECT_IN 0x01 296 | #define CURL_CSELECT_OUT 0x02 297 | #define CURL_CSELECT_ERR 0x04 298 | 299 | typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */ 300 | curl_socket_t s, /* socket */ 301 | int what, /* see above */ 302 | void *userp, /* private callback 303 | pointer */ 304 | void *socketp); /* private socket 305 | pointer */ 306 | /* 307 | * Name: curl_multi_timer_callback 308 | * 309 | * Desc: Called by libcurl whenever the library detects a change in the 310 | * maximum number of milliseconds the app is allowed to wait before 311 | * curl_multi_socket() or curl_multi_perform() must be called 312 | * (to allow libcurl's timed events to take place). 313 | * 314 | * Returns: The callback should return zero. 315 | */ 316 | typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */ 317 | long timeout_ms, /* see above */ 318 | void *userp); /* private callback 319 | pointer */ 320 | 321 | CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s, 322 | int *running_handles); 323 | 324 | CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle, 325 | curl_socket_t s, 326 | int ev_bitmask, 327 | int *running_handles); 328 | 329 | CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle, 330 | int *running_handles); 331 | 332 | #ifndef CURL_ALLOW_OLD_MULTI_SOCKET 333 | /* This macro below was added in 7.16.3 to push users who recompile to use 334 | the new curl_multi_socket_action() instead of the old curl_multi_socket() 335 | */ 336 | #define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z) 337 | #endif 338 | 339 | /* 340 | * Name: curl_multi_timeout() 341 | * 342 | * Desc: Returns the maximum number of milliseconds the app is allowed to 343 | * wait before curl_multi_socket() or curl_multi_perform() must be 344 | * called (to allow libcurl's timed events to take place). 345 | * 346 | * Returns: CURLM error code. 347 | */ 348 | CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle, 349 | long *milliseconds); 350 | 351 | typedef enum { 352 | /* This is the socket callback function pointer */ 353 | CURLOPT(CURLMOPT_SOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 1), 354 | 355 | /* This is the argument passed to the socket callback */ 356 | CURLOPT(CURLMOPT_SOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 2), 357 | 358 | /* set to 1 to enable pipelining for this multi handle */ 359 | CURLOPT(CURLMOPT_PIPELINING, CURLOPTTYPE_LONG, 3), 360 | 361 | /* This is the timer callback function pointer */ 362 | CURLOPT(CURLMOPT_TIMERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 4), 363 | 364 | /* This is the argument passed to the timer callback */ 365 | CURLOPT(CURLMOPT_TIMERDATA, CURLOPTTYPE_OBJECTPOINT, 5), 366 | 367 | /* maximum number of entries in the connection cache */ 368 | CURLOPT(CURLMOPT_MAXCONNECTS, CURLOPTTYPE_LONG, 6), 369 | 370 | /* maximum number of (pipelining) connections to one host */ 371 | CURLOPT(CURLMOPT_MAX_HOST_CONNECTIONS, CURLOPTTYPE_LONG, 7), 372 | 373 | /* maximum number of requests in a pipeline */ 374 | CURLOPT(CURLMOPT_MAX_PIPELINE_LENGTH, CURLOPTTYPE_LONG, 8), 375 | 376 | /* a connection with a content-length longer than this 377 | will not be considered for pipelining */ 378 | CURLOPT(CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 9), 379 | 380 | /* a connection with a chunk length longer than this 381 | will not be considered for pipelining */ 382 | CURLOPT(CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 10), 383 | 384 | /* a list of site names(+port) that are blocked from pipelining */ 385 | CURLOPT(CURLMOPT_PIPELINING_SITE_BL, CURLOPTTYPE_OBJECTPOINT, 11), 386 | 387 | /* a list of server types that are blocked from pipelining */ 388 | CURLOPT(CURLMOPT_PIPELINING_SERVER_BL, CURLOPTTYPE_OBJECTPOINT, 12), 389 | 390 | /* maximum number of open connections in total */ 391 | CURLOPT(CURLMOPT_MAX_TOTAL_CONNECTIONS, CURLOPTTYPE_LONG, 13), 392 | 393 | /* This is the server push callback function pointer */ 394 | CURLOPT(CURLMOPT_PUSHFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 14), 395 | 396 | /* This is the argument passed to the server push callback */ 397 | CURLOPT(CURLMOPT_PUSHDATA, CURLOPTTYPE_OBJECTPOINT, 15), 398 | 399 | /* maximum number of concurrent streams to support on a connection */ 400 | CURLOPT(CURLMOPT_MAX_CONCURRENT_STREAMS, CURLOPTTYPE_LONG, 16), 401 | 402 | CURLMOPT_LASTENTRY /* the last unused */ 403 | } CURLMoption; 404 | 405 | 406 | /* 407 | * Name: curl_multi_setopt() 408 | * 409 | * Desc: Sets options for the multi handle. 410 | * 411 | * Returns: CURLM error code. 412 | */ 413 | CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle, 414 | CURLMoption option, ...); 415 | 416 | 417 | /* 418 | * Name: curl_multi_assign() 419 | * 420 | * Desc: This function sets an association in the multi handle between the 421 | * given socket and a private pointer of the application. This is 422 | * (only) useful for curl_multi_socket uses. 423 | * 424 | * Returns: CURLM error code. 425 | */ 426 | CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle, 427 | curl_socket_t sockfd, void *sockp); 428 | 429 | 430 | /* 431 | * Name: curl_push_callback 432 | * 433 | * Desc: This callback gets called when a new stream is being pushed by the 434 | * server. It approves or denies the new stream. It can also decide 435 | * to completely fail the connection. 436 | * 437 | * Returns: CURL_PUSH_OK, CURL_PUSH_DENY or CURL_PUSH_ERROROUT 438 | */ 439 | #define CURL_PUSH_OK 0 440 | #define CURL_PUSH_DENY 1 441 | #define CURL_PUSH_ERROROUT 2 /* added in 7.72.0 */ 442 | 443 | struct curl_pushheaders; /* forward declaration only */ 444 | 445 | CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h, 446 | size_t num); 447 | CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h, 448 | const char *name); 449 | 450 | typedef int (*curl_push_callback)(CURL *parent, 451 | CURL *easy, 452 | size_t num_headers, 453 | struct curl_pushheaders *headers, 454 | void *userp); 455 | 456 | #ifdef __cplusplus 457 | } /* end of extern "C" */ 458 | #endif 459 | 460 | #endif 461 | -------------------------------------------------------------------------------- /include/curl/system.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_SYSTEM_H 2 | #define CURLINC_SYSTEM_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2022, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * SPDX-License-Identifier: curl 24 | * 25 | ***************************************************************************/ 26 | 27 | /* 28 | * Try to keep one section per platform, compiler and architecture, otherwise, 29 | * if an existing section is reused for a different one and later on the 30 | * original is adjusted, probably the piggybacking one can be adversely 31 | * changed. 32 | * 33 | * In order to differentiate between platforms/compilers/architectures use 34 | * only compiler built in predefined preprocessor symbols. 35 | * 36 | * curl_off_t 37 | * ---------- 38 | * 39 | * For any given platform/compiler curl_off_t must be typedef'ed to a 64-bit 40 | * wide signed integral data type. The width of this data type must remain 41 | * constant and independent of any possible large file support settings. 42 | * 43 | * As an exception to the above, curl_off_t shall be typedef'ed to a 32-bit 44 | * wide signed integral data type if there is no 64-bit type. 45 | * 46 | * As a general rule, curl_off_t shall not be mapped to off_t. This rule shall 47 | * only be violated if off_t is the only 64-bit data type available and the 48 | * size of off_t is independent of large file support settings. Keep your 49 | * build on the safe side avoiding an off_t gating. If you have a 64-bit 50 | * off_t then take for sure that another 64-bit data type exists, dig deeper 51 | * and you will find it. 52 | * 53 | */ 54 | 55 | #if defined(__DJGPP__) || defined(__GO32__) 56 | # if defined(__DJGPP__) && (__DJGPP__ > 1) 57 | # define CURL_TYPEOF_CURL_OFF_T long long 58 | # define CURL_FORMAT_CURL_OFF_T "lld" 59 | # define CURL_FORMAT_CURL_OFF_TU "llu" 60 | # define CURL_SUFFIX_CURL_OFF_T LL 61 | # define CURL_SUFFIX_CURL_OFF_TU ULL 62 | # else 63 | # define CURL_TYPEOF_CURL_OFF_T long 64 | # define CURL_FORMAT_CURL_OFF_T "ld" 65 | # define CURL_FORMAT_CURL_OFF_TU "lu" 66 | # define CURL_SUFFIX_CURL_OFF_T L 67 | # define CURL_SUFFIX_CURL_OFF_TU UL 68 | # endif 69 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 70 | 71 | #elif defined(__SALFORDC__) 72 | # define CURL_TYPEOF_CURL_OFF_T long 73 | # define CURL_FORMAT_CURL_OFF_T "ld" 74 | # define CURL_FORMAT_CURL_OFF_TU "lu" 75 | # define CURL_SUFFIX_CURL_OFF_T L 76 | # define CURL_SUFFIX_CURL_OFF_TU UL 77 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 78 | 79 | #elif defined(__BORLANDC__) 80 | # if (__BORLANDC__ < 0x520) 81 | # define CURL_TYPEOF_CURL_OFF_T long 82 | # define CURL_FORMAT_CURL_OFF_T "ld" 83 | # define CURL_FORMAT_CURL_OFF_TU "lu" 84 | # define CURL_SUFFIX_CURL_OFF_T L 85 | # define CURL_SUFFIX_CURL_OFF_TU UL 86 | # else 87 | # define CURL_TYPEOF_CURL_OFF_T __int64 88 | # define CURL_FORMAT_CURL_OFF_T "I64d" 89 | # define CURL_FORMAT_CURL_OFF_TU "I64u" 90 | # define CURL_SUFFIX_CURL_OFF_T i64 91 | # define CURL_SUFFIX_CURL_OFF_TU ui64 92 | # endif 93 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 94 | 95 | #elif defined(__TURBOC__) 96 | # define CURL_TYPEOF_CURL_OFF_T long 97 | # define CURL_FORMAT_CURL_OFF_T "ld" 98 | # define CURL_FORMAT_CURL_OFF_TU "lu" 99 | # define CURL_SUFFIX_CURL_OFF_T L 100 | # define CURL_SUFFIX_CURL_OFF_TU UL 101 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 102 | 103 | #elif defined(__POCC__) 104 | # if (__POCC__ < 280) 105 | # define CURL_TYPEOF_CURL_OFF_T long 106 | # define CURL_FORMAT_CURL_OFF_T "ld" 107 | # define CURL_FORMAT_CURL_OFF_TU "lu" 108 | # define CURL_SUFFIX_CURL_OFF_T L 109 | # define CURL_SUFFIX_CURL_OFF_TU UL 110 | # elif defined(_MSC_VER) 111 | # define CURL_TYPEOF_CURL_OFF_T __int64 112 | # define CURL_FORMAT_CURL_OFF_T "I64d" 113 | # define CURL_FORMAT_CURL_OFF_TU "I64u" 114 | # define CURL_SUFFIX_CURL_OFF_T i64 115 | # define CURL_SUFFIX_CURL_OFF_TU ui64 116 | # else 117 | # define CURL_TYPEOF_CURL_OFF_T long long 118 | # define CURL_FORMAT_CURL_OFF_T "lld" 119 | # define CURL_FORMAT_CURL_OFF_TU "llu" 120 | # define CURL_SUFFIX_CURL_OFF_T LL 121 | # define CURL_SUFFIX_CURL_OFF_TU ULL 122 | # endif 123 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 124 | 125 | #elif defined(__LCC__) 126 | # if defined(__MCST__) /* MCST eLbrus Compiler Collection */ 127 | # define CURL_TYPEOF_CURL_OFF_T long 128 | # define CURL_FORMAT_CURL_OFF_T "ld" 129 | # define CURL_FORMAT_CURL_OFF_TU "lu" 130 | # define CURL_SUFFIX_CURL_OFF_T L 131 | # define CURL_SUFFIX_CURL_OFF_TU UL 132 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t 133 | # define CURL_PULL_SYS_TYPES_H 1 134 | # define CURL_PULL_SYS_SOCKET_H 1 135 | # else /* Local (or Little) C Compiler */ 136 | # define CURL_TYPEOF_CURL_OFF_T long 137 | # define CURL_FORMAT_CURL_OFF_T "ld" 138 | # define CURL_FORMAT_CURL_OFF_TU "lu" 139 | # define CURL_SUFFIX_CURL_OFF_T L 140 | # define CURL_SUFFIX_CURL_OFF_TU UL 141 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 142 | # endif 143 | 144 | #elif defined(__SYMBIAN32__) 145 | # if defined(__EABI__) /* Treat all ARM compilers equally */ 146 | # define CURL_TYPEOF_CURL_OFF_T long long 147 | # define CURL_FORMAT_CURL_OFF_T "lld" 148 | # define CURL_FORMAT_CURL_OFF_TU "llu" 149 | # define CURL_SUFFIX_CURL_OFF_T LL 150 | # define CURL_SUFFIX_CURL_OFF_TU ULL 151 | # elif defined(__CW32__) 152 | # pragma longlong on 153 | # define CURL_TYPEOF_CURL_OFF_T long long 154 | # define CURL_FORMAT_CURL_OFF_T "lld" 155 | # define CURL_FORMAT_CURL_OFF_TU "llu" 156 | # define CURL_SUFFIX_CURL_OFF_T LL 157 | # define CURL_SUFFIX_CURL_OFF_TU ULL 158 | # elif defined(__VC32__) 159 | # define CURL_TYPEOF_CURL_OFF_T __int64 160 | # define CURL_FORMAT_CURL_OFF_T "lld" 161 | # define CURL_FORMAT_CURL_OFF_TU "llu" 162 | # define CURL_SUFFIX_CURL_OFF_T LL 163 | # define CURL_SUFFIX_CURL_OFF_TU ULL 164 | # endif 165 | # define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int 166 | 167 | #elif defined(__MWERKS__) 168 | # define CURL_TYPEOF_CURL_OFF_T long long 169 | # define CURL_FORMAT_CURL_OFF_T "lld" 170 | # define CURL_FORMAT_CURL_OFF_TU "llu" 171 | # define CURL_SUFFIX_CURL_OFF_T LL 172 | # define CURL_SUFFIX_CURL_OFF_TU ULL 173 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 174 | 175 | #elif defined(_WIN32_WCE) 176 | # define CURL_TYPEOF_CURL_OFF_T __int64 177 | # define CURL_FORMAT_CURL_OFF_T "I64d" 178 | # define CURL_FORMAT_CURL_OFF_TU "I64u" 179 | # define CURL_SUFFIX_CURL_OFF_T i64 180 | # define CURL_SUFFIX_CURL_OFF_TU ui64 181 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 182 | 183 | #elif defined(__MINGW32__) 184 | # define CURL_TYPEOF_CURL_OFF_T long long 185 | # define CURL_FORMAT_CURL_OFF_T "I64d" 186 | # define CURL_FORMAT_CURL_OFF_TU "I64u" 187 | # define CURL_SUFFIX_CURL_OFF_T LL 188 | # define CURL_SUFFIX_CURL_OFF_TU ULL 189 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t 190 | # define CURL_PULL_SYS_TYPES_H 1 191 | # define CURL_PULL_WS2TCPIP_H 1 192 | 193 | #elif defined(__VMS) 194 | # if defined(__VAX) 195 | # define CURL_TYPEOF_CURL_OFF_T long 196 | # define CURL_FORMAT_CURL_OFF_T "ld" 197 | # define CURL_FORMAT_CURL_OFF_TU "lu" 198 | # define CURL_SUFFIX_CURL_OFF_T L 199 | # define CURL_SUFFIX_CURL_OFF_TU UL 200 | # else 201 | # define CURL_TYPEOF_CURL_OFF_T long long 202 | # define CURL_FORMAT_CURL_OFF_T "lld" 203 | # define CURL_FORMAT_CURL_OFF_TU "llu" 204 | # define CURL_SUFFIX_CURL_OFF_T LL 205 | # define CURL_SUFFIX_CURL_OFF_TU ULL 206 | # endif 207 | # define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int 208 | 209 | #elif defined(__OS400__) 210 | # if defined(__ILEC400__) 211 | # define CURL_TYPEOF_CURL_OFF_T long long 212 | # define CURL_FORMAT_CURL_OFF_T "lld" 213 | # define CURL_FORMAT_CURL_OFF_TU "llu" 214 | # define CURL_SUFFIX_CURL_OFF_T LL 215 | # define CURL_SUFFIX_CURL_OFF_TU ULL 216 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t 217 | # define CURL_PULL_SYS_TYPES_H 1 218 | # define CURL_PULL_SYS_SOCKET_H 1 219 | # endif 220 | 221 | #elif defined(__MVS__) 222 | # if defined(__IBMC__) || defined(__IBMCPP__) 223 | # if defined(_ILP32) 224 | # elif defined(_LP64) 225 | # endif 226 | # if defined(_LONG_LONG) 227 | # define CURL_TYPEOF_CURL_OFF_T long long 228 | # define CURL_FORMAT_CURL_OFF_T "lld" 229 | # define CURL_FORMAT_CURL_OFF_TU "llu" 230 | # define CURL_SUFFIX_CURL_OFF_T LL 231 | # define CURL_SUFFIX_CURL_OFF_TU ULL 232 | # elif defined(_LP64) 233 | # define CURL_TYPEOF_CURL_OFF_T long 234 | # define CURL_FORMAT_CURL_OFF_T "ld" 235 | # define CURL_FORMAT_CURL_OFF_TU "lu" 236 | # define CURL_SUFFIX_CURL_OFF_T L 237 | # define CURL_SUFFIX_CURL_OFF_TU UL 238 | # else 239 | # define CURL_TYPEOF_CURL_OFF_T long 240 | # define CURL_FORMAT_CURL_OFF_T "ld" 241 | # define CURL_FORMAT_CURL_OFF_TU "lu" 242 | # define CURL_SUFFIX_CURL_OFF_T L 243 | # define CURL_SUFFIX_CURL_OFF_TU UL 244 | # endif 245 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t 246 | # define CURL_PULL_SYS_TYPES_H 1 247 | # define CURL_PULL_SYS_SOCKET_H 1 248 | # endif 249 | 250 | #elif defined(__370__) 251 | # if defined(__IBMC__) || defined(__IBMCPP__) 252 | # if defined(_ILP32) 253 | # elif defined(_LP64) 254 | # endif 255 | # if defined(_LONG_LONG) 256 | # define CURL_TYPEOF_CURL_OFF_T long long 257 | # define CURL_FORMAT_CURL_OFF_T "lld" 258 | # define CURL_FORMAT_CURL_OFF_TU "llu" 259 | # define CURL_SUFFIX_CURL_OFF_T LL 260 | # define CURL_SUFFIX_CURL_OFF_TU ULL 261 | # elif defined(_LP64) 262 | # define CURL_TYPEOF_CURL_OFF_T long 263 | # define CURL_FORMAT_CURL_OFF_T "ld" 264 | # define CURL_FORMAT_CURL_OFF_TU "lu" 265 | # define CURL_SUFFIX_CURL_OFF_T L 266 | # define CURL_SUFFIX_CURL_OFF_TU UL 267 | # else 268 | # define CURL_TYPEOF_CURL_OFF_T long 269 | # define CURL_FORMAT_CURL_OFF_T "ld" 270 | # define CURL_FORMAT_CURL_OFF_TU "lu" 271 | # define CURL_SUFFIX_CURL_OFF_T L 272 | # define CURL_SUFFIX_CURL_OFF_TU UL 273 | # endif 274 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t 275 | # define CURL_PULL_SYS_TYPES_H 1 276 | # define CURL_PULL_SYS_SOCKET_H 1 277 | # endif 278 | 279 | #elif defined(TPF) 280 | # define CURL_TYPEOF_CURL_OFF_T long 281 | # define CURL_FORMAT_CURL_OFF_T "ld" 282 | # define CURL_FORMAT_CURL_OFF_TU "lu" 283 | # define CURL_SUFFIX_CURL_OFF_T L 284 | # define CURL_SUFFIX_CURL_OFF_TU UL 285 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 286 | 287 | #elif defined(__TINYC__) /* also known as tcc */ 288 | # define CURL_TYPEOF_CURL_OFF_T long long 289 | # define CURL_FORMAT_CURL_OFF_T "lld" 290 | # define CURL_FORMAT_CURL_OFF_TU "llu" 291 | # define CURL_SUFFIX_CURL_OFF_T LL 292 | # define CURL_SUFFIX_CURL_OFF_TU ULL 293 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t 294 | # define CURL_PULL_SYS_TYPES_H 1 295 | # define CURL_PULL_SYS_SOCKET_H 1 296 | 297 | #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Oracle Solaris Studio */ 298 | # if !defined(__LP64) && (defined(__ILP32) || \ 299 | defined(__i386) || \ 300 | defined(__sparcv8) || \ 301 | defined(__sparcv8plus)) 302 | # define CURL_TYPEOF_CURL_OFF_T long long 303 | # define CURL_FORMAT_CURL_OFF_T "lld" 304 | # define CURL_FORMAT_CURL_OFF_TU "llu" 305 | # define CURL_SUFFIX_CURL_OFF_T LL 306 | # define CURL_SUFFIX_CURL_OFF_TU ULL 307 | # elif defined(__LP64) || \ 308 | defined(__amd64) || defined(__sparcv9) 309 | # define CURL_TYPEOF_CURL_OFF_T long 310 | # define CURL_FORMAT_CURL_OFF_T "ld" 311 | # define CURL_FORMAT_CURL_OFF_TU "lu" 312 | # define CURL_SUFFIX_CURL_OFF_T L 313 | # define CURL_SUFFIX_CURL_OFF_TU UL 314 | # endif 315 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t 316 | # define CURL_PULL_SYS_TYPES_H 1 317 | # define CURL_PULL_SYS_SOCKET_H 1 318 | 319 | #elif defined(__xlc__) /* IBM xlc compiler */ 320 | # if !defined(_LP64) 321 | # define CURL_TYPEOF_CURL_OFF_T long long 322 | # define CURL_FORMAT_CURL_OFF_T "lld" 323 | # define CURL_FORMAT_CURL_OFF_TU "llu" 324 | # define CURL_SUFFIX_CURL_OFF_T LL 325 | # define CURL_SUFFIX_CURL_OFF_TU ULL 326 | # else 327 | # define CURL_TYPEOF_CURL_OFF_T long 328 | # define CURL_FORMAT_CURL_OFF_T "ld" 329 | # define CURL_FORMAT_CURL_OFF_TU "lu" 330 | # define CURL_SUFFIX_CURL_OFF_T L 331 | # define CURL_SUFFIX_CURL_OFF_TU UL 332 | # endif 333 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t 334 | # define CURL_PULL_SYS_TYPES_H 1 335 | # define CURL_PULL_SYS_SOCKET_H 1 336 | 337 | /* ===================================== */ 338 | /* KEEP MSVC THE PENULTIMATE ENTRY */ 339 | /* ===================================== */ 340 | 341 | #elif defined(_MSC_VER) 342 | # if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64) 343 | # define CURL_TYPEOF_CURL_OFF_T __int64 344 | # define CURL_FORMAT_CURL_OFF_T "I64d" 345 | # define CURL_FORMAT_CURL_OFF_TU "I64u" 346 | # define CURL_SUFFIX_CURL_OFF_T i64 347 | # define CURL_SUFFIX_CURL_OFF_TU ui64 348 | # else 349 | # define CURL_TYPEOF_CURL_OFF_T long 350 | # define CURL_FORMAT_CURL_OFF_T "ld" 351 | # define CURL_FORMAT_CURL_OFF_TU "lu" 352 | # define CURL_SUFFIX_CURL_OFF_T L 353 | # define CURL_SUFFIX_CURL_OFF_TU UL 354 | # endif 355 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 356 | 357 | /* ===================================== */ 358 | /* KEEP GENERIC GCC THE LAST ENTRY */ 359 | /* ===================================== */ 360 | 361 | #elif defined(__GNUC__) && !defined(_SCO_DS) 362 | # if !defined(__LP64__) && \ 363 | (defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \ 364 | defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \ 365 | defined(__sparc__) || defined(__mips__) || defined(__sh__) || \ 366 | defined(__XTENSA__) || \ 367 | (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \ 368 | (defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L)) 369 | # define CURL_TYPEOF_CURL_OFF_T long long 370 | # define CURL_FORMAT_CURL_OFF_T "lld" 371 | # define CURL_FORMAT_CURL_OFF_TU "llu" 372 | # define CURL_SUFFIX_CURL_OFF_T LL 373 | # define CURL_SUFFIX_CURL_OFF_TU ULL 374 | # elif defined(__LP64__) || \ 375 | defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \ 376 | defined(__e2k__) || \ 377 | (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \ 378 | (defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L) 379 | # define CURL_TYPEOF_CURL_OFF_T long 380 | # define CURL_FORMAT_CURL_OFF_T "ld" 381 | # define CURL_FORMAT_CURL_OFF_TU "lu" 382 | # define CURL_SUFFIX_CURL_OFF_T L 383 | # define CURL_SUFFIX_CURL_OFF_TU UL 384 | # endif 385 | # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t 386 | # define CURL_PULL_SYS_TYPES_H 1 387 | # define CURL_PULL_SYS_SOCKET_H 1 388 | 389 | #else 390 | /* generic "safe guess" on old 32 bit style */ 391 | # define CURL_TYPEOF_CURL_OFF_T long 392 | # define CURL_FORMAT_CURL_OFF_T "ld" 393 | # define CURL_FORMAT_CURL_OFF_TU "lu" 394 | # define CURL_SUFFIX_CURL_OFF_T L 395 | # define CURL_SUFFIX_CURL_OFF_TU UL 396 | # define CURL_TYPEOF_CURL_SOCKLEN_T int 397 | #endif 398 | 399 | #ifdef _AIX 400 | /* AIX needs */ 401 | #define CURL_PULL_SYS_POLL_H 402 | #endif 403 | 404 | 405 | /* CURL_PULL_WS2TCPIP_H is defined above when inclusion of header file */ 406 | /* ws2tcpip.h is required here to properly make type definitions below. */ 407 | #ifdef CURL_PULL_WS2TCPIP_H 408 | # include 409 | # include 410 | # include 411 | #endif 412 | 413 | /* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */ 414 | /* sys/types.h is required here to properly make type definitions below. */ 415 | #ifdef CURL_PULL_SYS_TYPES_H 416 | # include 417 | #endif 418 | 419 | /* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */ 420 | /* sys/socket.h is required here to properly make type definitions below. */ 421 | #ifdef CURL_PULL_SYS_SOCKET_H 422 | # include 423 | #endif 424 | 425 | /* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */ 426 | /* sys/poll.h is required here to properly make type definitions below. */ 427 | #ifdef CURL_PULL_SYS_POLL_H 428 | # include 429 | #endif 430 | 431 | /* Data type definition of curl_socklen_t. */ 432 | #ifdef CURL_TYPEOF_CURL_SOCKLEN_T 433 | typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; 434 | #endif 435 | 436 | /* Data type definition of curl_off_t. */ 437 | 438 | #ifdef CURL_TYPEOF_CURL_OFF_T 439 | typedef CURL_TYPEOF_CURL_OFF_T curl_off_t; 440 | #endif 441 | 442 | /* 443 | * CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow 444 | * these to be visible and exported by the external libcurl interface API, 445 | * while also making them visible to the library internals, simply including 446 | * curl_setup.h, without actually needing to include curl.h internally. 447 | * If some day this section would grow big enough, all this should be moved 448 | * to its own header file. 449 | */ 450 | 451 | /* 452 | * Figure out if we can use the ## preprocessor operator, which is supported 453 | * by ISO/ANSI C and C++. Some compilers support it without setting __STDC__ 454 | * or __cplusplus so we need to carefully check for them too. 455 | */ 456 | 457 | #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \ 458 | defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \ 459 | defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \ 460 | defined(__ILEC400__) 461 | /* This compiler is believed to have an ISO compatible preprocessor */ 462 | #define CURL_ISOCPP 463 | #else 464 | /* This compiler is believed NOT to have an ISO compatible preprocessor */ 465 | #undef CURL_ISOCPP 466 | #endif 467 | 468 | /* 469 | * Macros for minimum-width signed and unsigned curl_off_t integer constants. 470 | */ 471 | 472 | #if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551) 473 | # define CURLINC_OFF_T_C_HLPR2(x) x 474 | # define CURLINC_OFF_T_C_HLPR1(x) CURLINC_OFF_T_C_HLPR2(x) 475 | # define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \ 476 | CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T) 477 | # define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \ 478 | CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU) 479 | #else 480 | # ifdef CURL_ISOCPP 481 | # define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix 482 | # else 483 | # define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix 484 | # endif 485 | # define CURLINC_OFF_T_C_HLPR1(Val,Suffix) CURLINC_OFF_T_C_HLPR2(Val,Suffix) 486 | # define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T) 487 | # define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU) 488 | #endif 489 | 490 | #endif /* CURLINC_SYSTEM_H */ 491 | -------------------------------------------------------------------------------- /include/curl/typecheck-gcc.h: -------------------------------------------------------------------------------- 1 | #ifndef CURLINC_TYPECHECK_GCC_H 2 | #define CURLINC_TYPECHECK_GCC_H 3 | /*************************************************************************** 4 | * _ _ ____ _ 5 | * Project ___| | | | _ \| | 6 | * / __| | | | |_) | | 7 | * | (__| |_| | _ <| |___ 8 | * \___|\___/|_| \_\_____| 9 | * 10 | * Copyright (C) 1998 - 2022, Daniel Stenberg, , et al. 11 | * 12 | * This software is licensed as described in the file COPYING, which 13 | * you should have received as part of this distribution. The terms 14 | * are also available at https://curl.se/docs/copyright.html. 15 | * 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 | * copies of the Software, and permit persons to whom the Software is 18 | * furnished to do so, under the terms of the COPYING file. 19 | * 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 21 | * KIND, either express or implied. 22 | * 23 | * SPDX-License-Identifier: curl 24 | * 25 | ***************************************************************************/ 26 | 27 | /* wraps curl_easy_setopt() with typechecking */ 28 | 29 | /* To add a new kind of warning, add an 30 | * if(curlcheck_sometype_option(_curl_opt)) 31 | * if(!curlcheck_sometype(value)) 32 | * _curl_easy_setopt_err_sometype(); 33 | * block and define curlcheck_sometype_option, curlcheck_sometype and 34 | * _curl_easy_setopt_err_sometype below 35 | * 36 | * NOTE: We use two nested 'if' statements here instead of the && operator, in 37 | * order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x 38 | * when compiling with -Wlogical-op. 39 | * 40 | * To add an option that uses the same type as an existing option, you'll just 41 | * need to extend the appropriate _curl_*_option macro 42 | */ 43 | #define curl_easy_setopt(handle, option, value) \ 44 | __extension__({ \ 45 | __typeof__(option) _curl_opt = option; \ 46 | if(__builtin_constant_p(_curl_opt)) { \ 47 | if(curlcheck_long_option(_curl_opt)) \ 48 | if(!curlcheck_long(value)) \ 49 | _curl_easy_setopt_err_long(); \ 50 | if(curlcheck_off_t_option(_curl_opt)) \ 51 | if(!curlcheck_off_t(value)) \ 52 | _curl_easy_setopt_err_curl_off_t(); \ 53 | if(curlcheck_string_option(_curl_opt)) \ 54 | if(!curlcheck_string(value)) \ 55 | _curl_easy_setopt_err_string(); \ 56 | if(curlcheck_write_cb_option(_curl_opt)) \ 57 | if(!curlcheck_write_cb(value)) \ 58 | _curl_easy_setopt_err_write_callback(); \ 59 | if((_curl_opt) == CURLOPT_RESOLVER_START_FUNCTION) \ 60 | if(!curlcheck_resolver_start_callback(value)) \ 61 | _curl_easy_setopt_err_resolver_start_callback(); \ 62 | if((_curl_opt) == CURLOPT_READFUNCTION) \ 63 | if(!curlcheck_read_cb(value)) \ 64 | _curl_easy_setopt_err_read_cb(); \ 65 | if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \ 66 | if(!curlcheck_ioctl_cb(value)) \ 67 | _curl_easy_setopt_err_ioctl_cb(); \ 68 | if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \ 69 | if(!curlcheck_sockopt_cb(value)) \ 70 | _curl_easy_setopt_err_sockopt_cb(); \ 71 | if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \ 72 | if(!curlcheck_opensocket_cb(value)) \ 73 | _curl_easy_setopt_err_opensocket_cb(); \ 74 | if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \ 75 | if(!curlcheck_progress_cb(value)) \ 76 | _curl_easy_setopt_err_progress_cb(); \ 77 | if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \ 78 | if(!curlcheck_debug_cb(value)) \ 79 | _curl_easy_setopt_err_debug_cb(); \ 80 | if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \ 81 | if(!curlcheck_ssl_ctx_cb(value)) \ 82 | _curl_easy_setopt_err_ssl_ctx_cb(); \ 83 | if(curlcheck_conv_cb_option(_curl_opt)) \ 84 | if(!curlcheck_conv_cb(value)) \ 85 | _curl_easy_setopt_err_conv_cb(); \ 86 | if((_curl_opt) == CURLOPT_SEEKFUNCTION) \ 87 | if(!curlcheck_seek_cb(value)) \ 88 | _curl_easy_setopt_err_seek_cb(); \ 89 | if(curlcheck_cb_data_option(_curl_opt)) \ 90 | if(!curlcheck_cb_data(value)) \ 91 | _curl_easy_setopt_err_cb_data(); \ 92 | if((_curl_opt) == CURLOPT_ERRORBUFFER) \ 93 | if(!curlcheck_error_buffer(value)) \ 94 | _curl_easy_setopt_err_error_buffer(); \ 95 | if((_curl_opt) == CURLOPT_STDERR) \ 96 | if(!curlcheck_FILE(value)) \ 97 | _curl_easy_setopt_err_FILE(); \ 98 | if(curlcheck_postfields_option(_curl_opt)) \ 99 | if(!curlcheck_postfields(value)) \ 100 | _curl_easy_setopt_err_postfields(); \ 101 | if((_curl_opt) == CURLOPT_HTTPPOST) \ 102 | if(!curlcheck_arr((value), struct curl_httppost)) \ 103 | _curl_easy_setopt_err_curl_httpost(); \ 104 | if((_curl_opt) == CURLOPT_MIMEPOST) \ 105 | if(!curlcheck_ptr((value), curl_mime)) \ 106 | _curl_easy_setopt_err_curl_mimepost(); \ 107 | if(curlcheck_slist_option(_curl_opt)) \ 108 | if(!curlcheck_arr((value), struct curl_slist)) \ 109 | _curl_easy_setopt_err_curl_slist(); \ 110 | if((_curl_opt) == CURLOPT_SHARE) \ 111 | if(!curlcheck_ptr((value), CURLSH)) \ 112 | _curl_easy_setopt_err_CURLSH(); \ 113 | } \ 114 | curl_easy_setopt(handle, _curl_opt, value); \ 115 | }) 116 | 117 | /* wraps curl_easy_getinfo() with typechecking */ 118 | #define curl_easy_getinfo(handle, info, arg) \ 119 | __extension__({ \ 120 | __typeof__(info) _curl_info = info; \ 121 | if(__builtin_constant_p(_curl_info)) { \ 122 | if(curlcheck_string_info(_curl_info)) \ 123 | if(!curlcheck_arr((arg), char *)) \ 124 | _curl_easy_getinfo_err_string(); \ 125 | if(curlcheck_long_info(_curl_info)) \ 126 | if(!curlcheck_arr((arg), long)) \ 127 | _curl_easy_getinfo_err_long(); \ 128 | if(curlcheck_double_info(_curl_info)) \ 129 | if(!curlcheck_arr((arg), double)) \ 130 | _curl_easy_getinfo_err_double(); \ 131 | if(curlcheck_slist_info(_curl_info)) \ 132 | if(!curlcheck_arr((arg), struct curl_slist *)) \ 133 | _curl_easy_getinfo_err_curl_slist(); \ 134 | if(curlcheck_tlssessioninfo_info(_curl_info)) \ 135 | if(!curlcheck_arr((arg), struct curl_tlssessioninfo *)) \ 136 | _curl_easy_getinfo_err_curl_tlssesssioninfo(); \ 137 | if(curlcheck_certinfo_info(_curl_info)) \ 138 | if(!curlcheck_arr((arg), struct curl_certinfo *)) \ 139 | _curl_easy_getinfo_err_curl_certinfo(); \ 140 | if(curlcheck_socket_info(_curl_info)) \ 141 | if(!curlcheck_arr((arg), curl_socket_t)) \ 142 | _curl_easy_getinfo_err_curl_socket(); \ 143 | if(curlcheck_off_t_info(_curl_info)) \ 144 | if(!curlcheck_arr((arg), curl_off_t)) \ 145 | _curl_easy_getinfo_err_curl_off_t(); \ 146 | } \ 147 | curl_easy_getinfo(handle, _curl_info, arg); \ 148 | }) 149 | 150 | /* 151 | * For now, just make sure that the functions are called with three arguments 152 | */ 153 | #define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param) 154 | #define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param) 155 | 156 | 157 | /* the actual warnings, triggered by calling the _curl_easy_setopt_err* 158 | * functions */ 159 | 160 | /* To define a new warning, use _CURL_WARNING(identifier, "message") */ 161 | #define CURLWARNING(id, message) \ 162 | static void __attribute__((__warning__(message))) \ 163 | __attribute__((__unused__)) __attribute__((__noinline__)) \ 164 | id(void) { __asm__(""); } 165 | 166 | CURLWARNING(_curl_easy_setopt_err_long, 167 | "curl_easy_setopt expects a long argument for this option") 168 | CURLWARNING(_curl_easy_setopt_err_curl_off_t, 169 | "curl_easy_setopt expects a curl_off_t argument for this option") 170 | CURLWARNING(_curl_easy_setopt_err_string, 171 | "curl_easy_setopt expects a " 172 | "string ('char *' or char[]) argument for this option" 173 | ) 174 | CURLWARNING(_curl_easy_setopt_err_write_callback, 175 | "curl_easy_setopt expects a curl_write_callback argument for this option") 176 | CURLWARNING(_curl_easy_setopt_err_resolver_start_callback, 177 | "curl_easy_setopt expects a " 178 | "curl_resolver_start_callback argument for this option" 179 | ) 180 | CURLWARNING(_curl_easy_setopt_err_read_cb, 181 | "curl_easy_setopt expects a curl_read_callback argument for this option") 182 | CURLWARNING(_curl_easy_setopt_err_ioctl_cb, 183 | "curl_easy_setopt expects a curl_ioctl_callback argument for this option") 184 | CURLWARNING(_curl_easy_setopt_err_sockopt_cb, 185 | "curl_easy_setopt expects a curl_sockopt_callback argument for this option") 186 | CURLWARNING(_curl_easy_setopt_err_opensocket_cb, 187 | "curl_easy_setopt expects a " 188 | "curl_opensocket_callback argument for this option" 189 | ) 190 | CURLWARNING(_curl_easy_setopt_err_progress_cb, 191 | "curl_easy_setopt expects a curl_progress_callback argument for this option") 192 | CURLWARNING(_curl_easy_setopt_err_debug_cb, 193 | "curl_easy_setopt expects a curl_debug_callback argument for this option") 194 | CURLWARNING(_curl_easy_setopt_err_ssl_ctx_cb, 195 | "curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option") 196 | CURLWARNING(_curl_easy_setopt_err_conv_cb, 197 | "curl_easy_setopt expects a curl_conv_callback argument for this option") 198 | CURLWARNING(_curl_easy_setopt_err_seek_cb, 199 | "curl_easy_setopt expects a curl_seek_callback argument for this option") 200 | CURLWARNING(_curl_easy_setopt_err_cb_data, 201 | "curl_easy_setopt expects a " 202 | "private data pointer as argument for this option") 203 | CURLWARNING(_curl_easy_setopt_err_error_buffer, 204 | "curl_easy_setopt expects a " 205 | "char buffer of CURL_ERROR_SIZE as argument for this option") 206 | CURLWARNING(_curl_easy_setopt_err_FILE, 207 | "curl_easy_setopt expects a 'FILE *' argument for this option") 208 | CURLWARNING(_curl_easy_setopt_err_postfields, 209 | "curl_easy_setopt expects a 'void *' or 'char *' argument for this option") 210 | CURLWARNING(_curl_easy_setopt_err_curl_httpost, 211 | "curl_easy_setopt expects a 'struct curl_httppost *' " 212 | "argument for this option") 213 | CURLWARNING(_curl_easy_setopt_err_curl_mimepost, 214 | "curl_easy_setopt expects a 'curl_mime *' " 215 | "argument for this option") 216 | CURLWARNING(_curl_easy_setopt_err_curl_slist, 217 | "curl_easy_setopt expects a 'struct curl_slist *' argument for this option") 218 | CURLWARNING(_curl_easy_setopt_err_CURLSH, 219 | "curl_easy_setopt expects a CURLSH* argument for this option") 220 | 221 | CURLWARNING(_curl_easy_getinfo_err_string, 222 | "curl_easy_getinfo expects a pointer to 'char *' for this info") 223 | CURLWARNING(_curl_easy_getinfo_err_long, 224 | "curl_easy_getinfo expects a pointer to long for this info") 225 | CURLWARNING(_curl_easy_getinfo_err_double, 226 | "curl_easy_getinfo expects a pointer to double for this info") 227 | CURLWARNING(_curl_easy_getinfo_err_curl_slist, 228 | "curl_easy_getinfo expects a pointer to 'struct curl_slist *' for this info") 229 | CURLWARNING(_curl_easy_getinfo_err_curl_tlssesssioninfo, 230 | "curl_easy_getinfo expects a pointer to " 231 | "'struct curl_tlssessioninfo *' for this info") 232 | CURLWARNING(_curl_easy_getinfo_err_curl_certinfo, 233 | "curl_easy_getinfo expects a pointer to " 234 | "'struct curl_certinfo *' for this info") 235 | CURLWARNING(_curl_easy_getinfo_err_curl_socket, 236 | "curl_easy_getinfo expects a pointer to curl_socket_t for this info") 237 | CURLWARNING(_curl_easy_getinfo_err_curl_off_t, 238 | "curl_easy_getinfo expects a pointer to curl_off_t for this info") 239 | 240 | /* groups of curl_easy_setops options that take the same type of argument */ 241 | 242 | /* To add a new option to one of the groups, just add 243 | * (option) == CURLOPT_SOMETHING 244 | * to the or-expression. If the option takes a long or curl_off_t, you don't 245 | * have to do anything 246 | */ 247 | 248 | /* evaluates to true if option takes a long argument */ 249 | #define curlcheck_long_option(option) \ 250 | (0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT) 251 | 252 | #define curlcheck_off_t_option(option) \ 253 | (((option) > CURLOPTTYPE_OFF_T) && ((option) < CURLOPTTYPE_BLOB)) 254 | 255 | /* evaluates to true if option takes a char* argument */ 256 | #define curlcheck_string_option(option) \ 257 | ((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \ 258 | (option) == CURLOPT_ACCEPT_ENCODING || \ 259 | (option) == CURLOPT_ALTSVC || \ 260 | (option) == CURLOPT_CAINFO || \ 261 | (option) == CURLOPT_CAPATH || \ 262 | (option) == CURLOPT_COOKIE || \ 263 | (option) == CURLOPT_COOKIEFILE || \ 264 | (option) == CURLOPT_COOKIEJAR || \ 265 | (option) == CURLOPT_COOKIELIST || \ 266 | (option) == CURLOPT_CRLFILE || \ 267 | (option) == CURLOPT_CUSTOMREQUEST || \ 268 | (option) == CURLOPT_DEFAULT_PROTOCOL || \ 269 | (option) == CURLOPT_DNS_INTERFACE || \ 270 | (option) == CURLOPT_DNS_LOCAL_IP4 || \ 271 | (option) == CURLOPT_DNS_LOCAL_IP6 || \ 272 | (option) == CURLOPT_DNS_SERVERS || \ 273 | (option) == CURLOPT_DOH_URL || \ 274 | (option) == CURLOPT_EGDSOCKET || \ 275 | (option) == CURLOPT_FTPPORT || \ 276 | (option) == CURLOPT_FTP_ACCOUNT || \ 277 | (option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \ 278 | (option) == CURLOPT_HSTS || \ 279 | (option) == CURLOPT_INTERFACE || \ 280 | (option) == CURLOPT_ISSUERCERT || \ 281 | (option) == CURLOPT_KEYPASSWD || \ 282 | (option) == CURLOPT_KRBLEVEL || \ 283 | (option) == CURLOPT_LOGIN_OPTIONS || \ 284 | (option) == CURLOPT_MAIL_AUTH || \ 285 | (option) == CURLOPT_MAIL_FROM || \ 286 | (option) == CURLOPT_NETRC_FILE || \ 287 | (option) == CURLOPT_NOPROXY || \ 288 | (option) == CURLOPT_PASSWORD || \ 289 | (option) == CURLOPT_PINNEDPUBLICKEY || \ 290 | (option) == CURLOPT_PRE_PROXY || \ 291 | (option) == CURLOPT_PROXY || \ 292 | (option) == CURLOPT_PROXYPASSWORD || \ 293 | (option) == CURLOPT_PROXYUSERNAME || \ 294 | (option) == CURLOPT_PROXYUSERPWD || \ 295 | (option) == CURLOPT_PROXY_CAINFO || \ 296 | (option) == CURLOPT_PROXY_CAPATH || \ 297 | (option) == CURLOPT_PROXY_CRLFILE || \ 298 | (option) == CURLOPT_PROXY_ISSUERCERT || \ 299 | (option) == CURLOPT_PROXY_KEYPASSWD || \ 300 | (option) == CURLOPT_PROXY_PINNEDPUBLICKEY || \ 301 | (option) == CURLOPT_PROXY_SERVICE_NAME || \ 302 | (option) == CURLOPT_PROXY_SSLCERT || \ 303 | (option) == CURLOPT_PROXY_SSLCERTTYPE || \ 304 | (option) == CURLOPT_PROXY_SSLKEY || \ 305 | (option) == CURLOPT_PROXY_SSLKEYTYPE || \ 306 | (option) == CURLOPT_PROXY_SSL_CIPHER_LIST || \ 307 | (option) == CURLOPT_PROXY_TLS13_CIPHERS || \ 308 | (option) == CURLOPT_PROXY_TLSAUTH_PASSWORD || \ 309 | (option) == CURLOPT_PROXY_TLSAUTH_TYPE || \ 310 | (option) == CURLOPT_PROXY_TLSAUTH_USERNAME || \ 311 | (option) == CURLOPT_RANDOM_FILE || \ 312 | (option) == CURLOPT_RANGE || \ 313 | (option) == CURLOPT_REFERER || \ 314 | (option) == CURLOPT_REQUEST_TARGET || \ 315 | (option) == CURLOPT_RTSP_SESSION_ID || \ 316 | (option) == CURLOPT_RTSP_STREAM_URI || \ 317 | (option) == CURLOPT_RTSP_TRANSPORT || \ 318 | (option) == CURLOPT_SASL_AUTHZID || \ 319 | (option) == CURLOPT_SERVICE_NAME || \ 320 | (option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \ 321 | (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \ 322 | (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 || \ 323 | (option) == CURLOPT_SSH_KNOWNHOSTS || \ 324 | (option) == CURLOPT_SSH_PRIVATE_KEYFILE || \ 325 | (option) == CURLOPT_SSH_PUBLIC_KEYFILE || \ 326 | (option) == CURLOPT_SSLCERT || \ 327 | (option) == CURLOPT_SSLCERTTYPE || \ 328 | (option) == CURLOPT_SSLENGINE || \ 329 | (option) == CURLOPT_SSLKEY || \ 330 | (option) == CURLOPT_SSLKEYTYPE || \ 331 | (option) == CURLOPT_SSL_CIPHER_LIST || \ 332 | (option) == CURLOPT_TLS13_CIPHERS || \ 333 | (option) == CURLOPT_TLSAUTH_PASSWORD || \ 334 | (option) == CURLOPT_TLSAUTH_TYPE || \ 335 | (option) == CURLOPT_TLSAUTH_USERNAME || \ 336 | (option) == CURLOPT_UNIX_SOCKET_PATH || \ 337 | (option) == CURLOPT_URL || \ 338 | (option) == CURLOPT_USERAGENT || \ 339 | (option) == CURLOPT_USERNAME || \ 340 | (option) == CURLOPT_AWS_SIGV4 || \ 341 | (option) == CURLOPT_USERPWD || \ 342 | (option) == CURLOPT_XOAUTH2_BEARER || \ 343 | (option) == CURLOPT_SSL_EC_CURVES || \ 344 | 0) 345 | 346 | /* evaluates to true if option takes a curl_write_callback argument */ 347 | #define curlcheck_write_cb_option(option) \ 348 | ((option) == CURLOPT_HEADERFUNCTION || \ 349 | (option) == CURLOPT_WRITEFUNCTION) 350 | 351 | /* evaluates to true if option takes a curl_conv_callback argument */ 352 | #define curlcheck_conv_cb_option(option) \ 353 | ((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \ 354 | (option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \ 355 | (option) == CURLOPT_CONV_FROM_UTF8_FUNCTION) 356 | 357 | /* evaluates to true if option takes a data argument to pass to a callback */ 358 | #define curlcheck_cb_data_option(option) \ 359 | ((option) == CURLOPT_CHUNK_DATA || \ 360 | (option) == CURLOPT_CLOSESOCKETDATA || \ 361 | (option) == CURLOPT_DEBUGDATA || \ 362 | (option) == CURLOPT_FNMATCH_DATA || \ 363 | (option) == CURLOPT_HEADERDATA || \ 364 | (option) == CURLOPT_HSTSREADDATA || \ 365 | (option) == CURLOPT_HSTSWRITEDATA || \ 366 | (option) == CURLOPT_INTERLEAVEDATA || \ 367 | (option) == CURLOPT_IOCTLDATA || \ 368 | (option) == CURLOPT_OPENSOCKETDATA || \ 369 | (option) == CURLOPT_PREREQDATA || \ 370 | (option) == CURLOPT_PROGRESSDATA || \ 371 | (option) == CURLOPT_READDATA || \ 372 | (option) == CURLOPT_SEEKDATA || \ 373 | (option) == CURLOPT_SOCKOPTDATA || \ 374 | (option) == CURLOPT_SSH_KEYDATA || \ 375 | (option) == CURLOPT_SSL_CTX_DATA || \ 376 | (option) == CURLOPT_WRITEDATA || \ 377 | (option) == CURLOPT_RESOLVER_START_DATA || \ 378 | (option) == CURLOPT_TRAILERDATA || \ 379 | (option) == CURLOPT_SSH_HOSTKEYDATA || \ 380 | 0) 381 | 382 | /* evaluates to true if option takes a POST data argument (void* or char*) */ 383 | #define curlcheck_postfields_option(option) \ 384 | ((option) == CURLOPT_POSTFIELDS || \ 385 | (option) == CURLOPT_COPYPOSTFIELDS || \ 386 | 0) 387 | 388 | /* evaluates to true if option takes a struct curl_slist * argument */ 389 | #define curlcheck_slist_option(option) \ 390 | ((option) == CURLOPT_HTTP200ALIASES || \ 391 | (option) == CURLOPT_HTTPHEADER || \ 392 | (option) == CURLOPT_MAIL_RCPT || \ 393 | (option) == CURLOPT_POSTQUOTE || \ 394 | (option) == CURLOPT_PREQUOTE || \ 395 | (option) == CURLOPT_PROXYHEADER || \ 396 | (option) == CURLOPT_QUOTE || \ 397 | (option) == CURLOPT_RESOLVE || \ 398 | (option) == CURLOPT_TELNETOPTIONS || \ 399 | (option) == CURLOPT_CONNECT_TO || \ 400 | 0) 401 | 402 | /* groups of curl_easy_getinfo infos that take the same type of argument */ 403 | 404 | /* evaluates to true if info expects a pointer to char * argument */ 405 | #define curlcheck_string_info(info) \ 406 | (CURLINFO_STRING < (info) && (info) < CURLINFO_LONG && \ 407 | (info) != CURLINFO_PRIVATE) 408 | 409 | /* evaluates to true if info expects a pointer to long argument */ 410 | #define curlcheck_long_info(info) \ 411 | (CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE) 412 | 413 | /* evaluates to true if info expects a pointer to double argument */ 414 | #define curlcheck_double_info(info) \ 415 | (CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST) 416 | 417 | /* true if info expects a pointer to struct curl_slist * argument */ 418 | #define curlcheck_slist_info(info) \ 419 | (((info) == CURLINFO_SSL_ENGINES) || ((info) == CURLINFO_COOKIELIST)) 420 | 421 | /* true if info expects a pointer to struct curl_tlssessioninfo * argument */ 422 | #define curlcheck_tlssessioninfo_info(info) \ 423 | (((info) == CURLINFO_TLS_SSL_PTR) || ((info) == CURLINFO_TLS_SESSION)) 424 | 425 | /* true if info expects a pointer to struct curl_certinfo * argument */ 426 | #define curlcheck_certinfo_info(info) ((info) == CURLINFO_CERTINFO) 427 | 428 | /* true if info expects a pointer to struct curl_socket_t argument */ 429 | #define curlcheck_socket_info(info) \ 430 | (CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T) 431 | 432 | /* true if info expects a pointer to curl_off_t argument */ 433 | #define curlcheck_off_t_info(info) \ 434 | (CURLINFO_OFF_T < (info)) 435 | 436 | 437 | /* typecheck helpers -- check whether given expression has requested type*/ 438 | 439 | /* For pointers, you can use the curlcheck_ptr/curlcheck_arr macros, 440 | * otherwise define a new macro. Search for __builtin_types_compatible_p 441 | * in the GCC manual. 442 | * NOTE: these macros MUST NOT EVALUATE their arguments! The argument is 443 | * the actual expression passed to the curl_easy_setopt macro. This 444 | * means that you can only apply the sizeof and __typeof__ operators, no 445 | * == or whatsoever. 446 | */ 447 | 448 | /* XXX: should evaluate to true if expr is a pointer */ 449 | #define curlcheck_any_ptr(expr) \ 450 | (sizeof(expr) == sizeof(void *)) 451 | 452 | /* evaluates to true if expr is NULL */ 453 | /* XXX: must not evaluate expr, so this check is not accurate */ 454 | #define curlcheck_NULL(expr) \ 455 | (__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL))) 456 | 457 | /* evaluates to true if expr is type*, const type* or NULL */ 458 | #define curlcheck_ptr(expr, type) \ 459 | (curlcheck_NULL(expr) || \ 460 | __builtin_types_compatible_p(__typeof__(expr), type *) || \ 461 | __builtin_types_compatible_p(__typeof__(expr), const type *)) 462 | 463 | /* evaluates to true if expr is one of type[], type*, NULL or const type* */ 464 | #define curlcheck_arr(expr, type) \ 465 | (curlcheck_ptr((expr), type) || \ 466 | __builtin_types_compatible_p(__typeof__(expr), type [])) 467 | 468 | /* evaluates to true if expr is a string */ 469 | #define curlcheck_string(expr) \ 470 | (curlcheck_arr((expr), char) || \ 471 | curlcheck_arr((expr), signed char) || \ 472 | curlcheck_arr((expr), unsigned char)) 473 | 474 | /* evaluates to true if expr is a long (no matter the signedness) 475 | * XXX: for now, int is also accepted (and therefore short and char, which 476 | * are promoted to int when passed to a variadic function) */ 477 | #define curlcheck_long(expr) \ 478 | (__builtin_types_compatible_p(__typeof__(expr), long) || \ 479 | __builtin_types_compatible_p(__typeof__(expr), signed long) || \ 480 | __builtin_types_compatible_p(__typeof__(expr), unsigned long) || \ 481 | __builtin_types_compatible_p(__typeof__(expr), int) || \ 482 | __builtin_types_compatible_p(__typeof__(expr), signed int) || \ 483 | __builtin_types_compatible_p(__typeof__(expr), unsigned int) || \ 484 | __builtin_types_compatible_p(__typeof__(expr), short) || \ 485 | __builtin_types_compatible_p(__typeof__(expr), signed short) || \ 486 | __builtin_types_compatible_p(__typeof__(expr), unsigned short) || \ 487 | __builtin_types_compatible_p(__typeof__(expr), char) || \ 488 | __builtin_types_compatible_p(__typeof__(expr), signed char) || \ 489 | __builtin_types_compatible_p(__typeof__(expr), unsigned char)) 490 | 491 | /* evaluates to true if expr is of type curl_off_t */ 492 | #define curlcheck_off_t(expr) \ 493 | (__builtin_types_compatible_p(__typeof__(expr), curl_off_t)) 494 | 495 | /* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */ 496 | /* XXX: also check size of an char[] array? */ 497 | #define curlcheck_error_buffer(expr) \ 498 | (curlcheck_NULL(expr) || \ 499 | __builtin_types_compatible_p(__typeof__(expr), char *) || \ 500 | __builtin_types_compatible_p(__typeof__(expr), char[])) 501 | 502 | /* evaluates to true if expr is of type (const) void* or (const) FILE* */ 503 | #if 0 504 | #define curlcheck_cb_data(expr) \ 505 | (curlcheck_ptr((expr), void) || \ 506 | curlcheck_ptr((expr), FILE)) 507 | #else /* be less strict */ 508 | #define curlcheck_cb_data(expr) \ 509 | curlcheck_any_ptr(expr) 510 | #endif 511 | 512 | /* evaluates to true if expr is of type FILE* */ 513 | #define curlcheck_FILE(expr) \ 514 | (curlcheck_NULL(expr) || \ 515 | (__builtin_types_compatible_p(__typeof__(expr), FILE *))) 516 | 517 | /* evaluates to true if expr can be passed as POST data (void* or char*) */ 518 | #define curlcheck_postfields(expr) \ 519 | (curlcheck_ptr((expr), void) || \ 520 | curlcheck_arr((expr), char) || \ 521 | curlcheck_arr((expr), unsigned char)) 522 | 523 | /* helper: __builtin_types_compatible_p distinguishes between functions and 524 | * function pointers, hide it */ 525 | #define curlcheck_cb_compatible(func, type) \ 526 | (__builtin_types_compatible_p(__typeof__(func), type) || \ 527 | __builtin_types_compatible_p(__typeof__(func) *, type)) 528 | 529 | /* evaluates to true if expr is of type curl_resolver_start_callback */ 530 | #define curlcheck_resolver_start_callback(expr) \ 531 | (curlcheck_NULL(expr) || \ 532 | curlcheck_cb_compatible((expr), curl_resolver_start_callback)) 533 | 534 | /* evaluates to true if expr is of type curl_read_callback or "similar" */ 535 | #define curlcheck_read_cb(expr) \ 536 | (curlcheck_NULL(expr) || \ 537 | curlcheck_cb_compatible((expr), __typeof__(fread) *) || \ 538 | curlcheck_cb_compatible((expr), curl_read_callback) || \ 539 | curlcheck_cb_compatible((expr), _curl_read_callback1) || \ 540 | curlcheck_cb_compatible((expr), _curl_read_callback2) || \ 541 | curlcheck_cb_compatible((expr), _curl_read_callback3) || \ 542 | curlcheck_cb_compatible((expr), _curl_read_callback4) || \ 543 | curlcheck_cb_compatible((expr), _curl_read_callback5) || \ 544 | curlcheck_cb_compatible((expr), _curl_read_callback6)) 545 | typedef size_t (*_curl_read_callback1)(char *, size_t, size_t, void *); 546 | typedef size_t (*_curl_read_callback2)(char *, size_t, size_t, const void *); 547 | typedef size_t (*_curl_read_callback3)(char *, size_t, size_t, FILE *); 548 | typedef size_t (*_curl_read_callback4)(void *, size_t, size_t, void *); 549 | typedef size_t (*_curl_read_callback5)(void *, size_t, size_t, const void *); 550 | typedef size_t (*_curl_read_callback6)(void *, size_t, size_t, FILE *); 551 | 552 | /* evaluates to true if expr is of type curl_write_callback or "similar" */ 553 | #define curlcheck_write_cb(expr) \ 554 | (curlcheck_read_cb(expr) || \ 555 | curlcheck_cb_compatible((expr), __typeof__(fwrite) *) || \ 556 | curlcheck_cb_compatible((expr), curl_write_callback) || \ 557 | curlcheck_cb_compatible((expr), _curl_write_callback1) || \ 558 | curlcheck_cb_compatible((expr), _curl_write_callback2) || \ 559 | curlcheck_cb_compatible((expr), _curl_write_callback3) || \ 560 | curlcheck_cb_compatible((expr), _curl_write_callback4) || \ 561 | curlcheck_cb_compatible((expr), _curl_write_callback5) || \ 562 | curlcheck_cb_compatible((expr), _curl_write_callback6)) 563 | typedef size_t (*_curl_write_callback1)(const char *, size_t, size_t, void *); 564 | typedef size_t (*_curl_write_callback2)(const char *, size_t, size_t, 565 | const void *); 566 | typedef size_t (*_curl_write_callback3)(const char *, size_t, size_t, FILE *); 567 | typedef size_t (*_curl_write_callback4)(const void *, size_t, size_t, void *); 568 | typedef size_t (*_curl_write_callback5)(const void *, size_t, size_t, 569 | const void *); 570 | typedef size_t (*_curl_write_callback6)(const void *, size_t, size_t, FILE *); 571 | 572 | /* evaluates to true if expr is of type curl_ioctl_callback or "similar" */ 573 | #define curlcheck_ioctl_cb(expr) \ 574 | (curlcheck_NULL(expr) || \ 575 | curlcheck_cb_compatible((expr), curl_ioctl_callback) || \ 576 | curlcheck_cb_compatible((expr), _curl_ioctl_callback1) || \ 577 | curlcheck_cb_compatible((expr), _curl_ioctl_callback2) || \ 578 | curlcheck_cb_compatible((expr), _curl_ioctl_callback3) || \ 579 | curlcheck_cb_compatible((expr), _curl_ioctl_callback4)) 580 | typedef curlioerr (*_curl_ioctl_callback1)(CURL *, int, void *); 581 | typedef curlioerr (*_curl_ioctl_callback2)(CURL *, int, const void *); 582 | typedef curlioerr (*_curl_ioctl_callback3)(CURL *, curliocmd, void *); 583 | typedef curlioerr (*_curl_ioctl_callback4)(CURL *, curliocmd, const void *); 584 | 585 | /* evaluates to true if expr is of type curl_sockopt_callback or "similar" */ 586 | #define curlcheck_sockopt_cb(expr) \ 587 | (curlcheck_NULL(expr) || \ 588 | curlcheck_cb_compatible((expr), curl_sockopt_callback) || \ 589 | curlcheck_cb_compatible((expr), _curl_sockopt_callback1) || \ 590 | curlcheck_cb_compatible((expr), _curl_sockopt_callback2)) 591 | typedef int (*_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype); 592 | typedef int (*_curl_sockopt_callback2)(const void *, curl_socket_t, 593 | curlsocktype); 594 | 595 | /* evaluates to true if expr is of type curl_opensocket_callback or 596 | "similar" */ 597 | #define curlcheck_opensocket_cb(expr) \ 598 | (curlcheck_NULL(expr) || \ 599 | curlcheck_cb_compatible((expr), curl_opensocket_callback) || \ 600 | curlcheck_cb_compatible((expr), _curl_opensocket_callback1) || \ 601 | curlcheck_cb_compatible((expr), _curl_opensocket_callback2) || \ 602 | curlcheck_cb_compatible((expr), _curl_opensocket_callback3) || \ 603 | curlcheck_cb_compatible((expr), _curl_opensocket_callback4)) 604 | typedef curl_socket_t (*_curl_opensocket_callback1) 605 | (void *, curlsocktype, struct curl_sockaddr *); 606 | typedef curl_socket_t (*_curl_opensocket_callback2) 607 | (void *, curlsocktype, const struct curl_sockaddr *); 608 | typedef curl_socket_t (*_curl_opensocket_callback3) 609 | (const void *, curlsocktype, struct curl_sockaddr *); 610 | typedef curl_socket_t (*_curl_opensocket_callback4) 611 | (const void *, curlsocktype, const struct curl_sockaddr *); 612 | 613 | /* evaluates to true if expr is of type curl_progress_callback or "similar" */ 614 | #define curlcheck_progress_cb(expr) \ 615 | (curlcheck_NULL(expr) || \ 616 | curlcheck_cb_compatible((expr), curl_progress_callback) || \ 617 | curlcheck_cb_compatible((expr), _curl_progress_callback1) || \ 618 | curlcheck_cb_compatible((expr), _curl_progress_callback2)) 619 | typedef int (*_curl_progress_callback1)(void *, 620 | double, double, double, double); 621 | typedef int (*_curl_progress_callback2)(const void *, 622 | double, double, double, double); 623 | 624 | /* evaluates to true if expr is of type curl_debug_callback or "similar" */ 625 | #define curlcheck_debug_cb(expr) \ 626 | (curlcheck_NULL(expr) || \ 627 | curlcheck_cb_compatible((expr), curl_debug_callback) || \ 628 | curlcheck_cb_compatible((expr), _curl_debug_callback1) || \ 629 | curlcheck_cb_compatible((expr), _curl_debug_callback2) || \ 630 | curlcheck_cb_compatible((expr), _curl_debug_callback3) || \ 631 | curlcheck_cb_compatible((expr), _curl_debug_callback4) || \ 632 | curlcheck_cb_compatible((expr), _curl_debug_callback5) || \ 633 | curlcheck_cb_compatible((expr), _curl_debug_callback6) || \ 634 | curlcheck_cb_compatible((expr), _curl_debug_callback7) || \ 635 | curlcheck_cb_compatible((expr), _curl_debug_callback8)) 636 | typedef int (*_curl_debug_callback1) (CURL *, 637 | curl_infotype, char *, size_t, void *); 638 | typedef int (*_curl_debug_callback2) (CURL *, 639 | curl_infotype, char *, size_t, const void *); 640 | typedef int (*_curl_debug_callback3) (CURL *, 641 | curl_infotype, const char *, size_t, void *); 642 | typedef int (*_curl_debug_callback4) (CURL *, 643 | curl_infotype, const char *, size_t, const void *); 644 | typedef int (*_curl_debug_callback5) (CURL *, 645 | curl_infotype, unsigned char *, size_t, void *); 646 | typedef int (*_curl_debug_callback6) (CURL *, 647 | curl_infotype, unsigned char *, size_t, const void *); 648 | typedef int (*_curl_debug_callback7) (CURL *, 649 | curl_infotype, const unsigned char *, size_t, void *); 650 | typedef int (*_curl_debug_callback8) (CURL *, 651 | curl_infotype, const unsigned char *, size_t, const void *); 652 | 653 | /* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */ 654 | /* this is getting even messier... */ 655 | #define curlcheck_ssl_ctx_cb(expr) \ 656 | (curlcheck_NULL(expr) || \ 657 | curlcheck_cb_compatible((expr), curl_ssl_ctx_callback) || \ 658 | curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback1) || \ 659 | curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback2) || \ 660 | curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback3) || \ 661 | curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback4) || \ 662 | curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback5) || \ 663 | curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback6) || \ 664 | curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback7) || \ 665 | curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback8)) 666 | typedef CURLcode (*_curl_ssl_ctx_callback1)(CURL *, void *, void *); 667 | typedef CURLcode (*_curl_ssl_ctx_callback2)(CURL *, void *, const void *); 668 | typedef CURLcode (*_curl_ssl_ctx_callback3)(CURL *, const void *, void *); 669 | typedef CURLcode (*_curl_ssl_ctx_callback4)(CURL *, const void *, 670 | const void *); 671 | #ifdef HEADER_SSL_H 672 | /* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX 673 | * this will of course break if we're included before OpenSSL headers... 674 | */ 675 | typedef CURLcode (*_curl_ssl_ctx_callback5)(CURL *, SSL_CTX *, void *); 676 | typedef CURLcode (*_curl_ssl_ctx_callback6)(CURL *, SSL_CTX *, const void *); 677 | typedef CURLcode (*_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX *, void *); 678 | typedef CURLcode (*_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX *, 679 | const void *); 680 | #else 681 | typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5; 682 | typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6; 683 | typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7; 684 | typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8; 685 | #endif 686 | 687 | /* evaluates to true if expr is of type curl_conv_callback or "similar" */ 688 | #define curlcheck_conv_cb(expr) \ 689 | (curlcheck_NULL(expr) || \ 690 | curlcheck_cb_compatible((expr), curl_conv_callback) || \ 691 | curlcheck_cb_compatible((expr), _curl_conv_callback1) || \ 692 | curlcheck_cb_compatible((expr), _curl_conv_callback2) || \ 693 | curlcheck_cb_compatible((expr), _curl_conv_callback3) || \ 694 | curlcheck_cb_compatible((expr), _curl_conv_callback4)) 695 | typedef CURLcode (*_curl_conv_callback1)(char *, size_t length); 696 | typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length); 697 | typedef CURLcode (*_curl_conv_callback3)(void *, size_t length); 698 | typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length); 699 | 700 | /* evaluates to true if expr is of type curl_seek_callback or "similar" */ 701 | #define curlcheck_seek_cb(expr) \ 702 | (curlcheck_NULL(expr) || \ 703 | curlcheck_cb_compatible((expr), curl_seek_callback) || \ 704 | curlcheck_cb_compatible((expr), _curl_seek_callback1) || \ 705 | curlcheck_cb_compatible((expr), _curl_seek_callback2)) 706 | typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int); 707 | typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int); 708 | 709 | 710 | #endif /* CURLINC_TYPECHECK_GCC_H */ 711 | --------------------------------------------------------------------------------