1 #ifndef __CURL_TYPECHECK_GCC_H 2 #define __CURL_TYPECHECK_GCC_H 3 /*************************************************************************** 4 * _ _ ____ _ 5 * Project ___| | | | _ \| | 6 * / __| | | | |_) | | 7 * | (__| |_| | _ <| |___ 8 * \___|\___/|_| \_\_____| 9 * 10 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, 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 http://curl.haxx.se/docs/copyright.html. 15 * 16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell 17 * licensed versions 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 ***************************************************************************/ 24 25 /* wraps curl_easy_setopt() with typechecking */ 26 27 /* To add a new kind of warning, add an 28 * if(_curl_is_sometype_option(_curl_opt)) 29 * if(!_curl_is_sometype(value)) 30 * _curl_easy_setopt_err_sometype(); 31 * block and define _curl_is_sometype_option, _curl_is_sometype and 32 * _curl_easy_setopt_err_sometype below 33 * 34 * NOTE: We use two nested 'if' statements here instead of the && operator 35 * to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x 36 * when compiling with -Wlogical-op. 37 * 38 * To add an option that uses the same type as an existing option, 39 * extend the appropriate _curl_*_option macro 40 */ 41 #define curl_easy_setopt(handle, option, value) \ 42 __extension__ ({ \ 43 __typeof__ (option) _curl_opt = option; \ 44 if(__builtin_constant_p(_curl_opt)) { \ 45 if(_curl_is_long_option(_curl_opt)) \ 46 if(!_curl_is_long(value)) \ 47 _curl_easy_setopt_err_long(); \ 48 if(_curl_is_off_t_option(_curl_opt)) \ 49 if(!_curl_is_off_t(value)) \ 50 _curl_easy_setopt_err_curl_off_t(); \ 51 if(_curl_is_string_option(_curl_opt)) \ 52 if(!_curl_is_string(value)) \ 53 _curl_easy_setopt_err_string(); \ 54 if(_curl_is_write_cb_option(_curl_opt)) \ 55 if(!_curl_is_write_cb(value)) \ 56 _curl_easy_setopt_err_write_callback(); \ 57 if((_curl_opt) == CURLOPT_READFUNCTION) \ 58 if(!_curl_is_read_cb(value)) \ 59 _curl_easy_setopt_err_read_cb(); \ 60 if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \ 61 if(!_curl_is_ioctl_cb(value)) \ 62 _curl_easy_setopt_err_ioctl_cb(); \ 63 if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \ 64 if(!_curl_is_sockopt_cb(value)) \ 65 _curl_easy_setopt_err_sockopt_cb(); \ 66 if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \ 67 if(!_curl_is_opensocket_cb(value)) \ 68 _curl_easy_setopt_err_opensocket_cb(); \ 69 if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \ 70 if(!_curl_is_progress_cb(value)) \ 71 _curl_easy_setopt_err_progress_cb(); \ 72 if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \ 73 if(!_curl_is_debug_cb(value)) \ 74 _curl_easy_setopt_err_debug_cb(); \ 75 if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \ 76 if(!_curl_is_ssl_ctx_cb(value)) \ 77 _curl_easy_setopt_err_ssl_ctx_cb(); \ 78 if(_curl_is_conv_cb_option(_curl_opt)) \ 79 if(!_curl_is_conv_cb(value)) \ 80 _curl_easy_setopt_err_conv_cb(); \ 81 if((_curl_opt) == CURLOPT_SEEKFUNCTION) \ 82 if(!_curl_is_seek_cb(value)) \ 83 _curl_easy_setopt_err_seek_cb(); \ 84 if(_curl_is_cb_data_option(_curl_opt)) \ 85 if(!_curl_is_cb_data(value)) \ 86 _curl_easy_setopt_err_cb_data(); \ 87 if((_curl_opt) == CURLOPT_ERRORBUFFER) \ 88 if(!_curl_is_error_buffer(value)) \ 89 _curl_easy_setopt_err_error_buffer(); \ 90 if((_curl_opt) == CURLOPT_STDERR) \ 91 if(!_curl_is_FILE(value)) \ 92 _curl_easy_setopt_err_FILE(); \ 93 if(_curl_is_postfields_option(_curl_opt)) \ 94 if(!_curl_is_postfields(value)) \ 95 _curl_easy_setopt_err_postfields(); \ 96 if((_curl_opt) == CURLOPT_HTTPPOST) \ 97 if(!_curl_is_arr((value), struct curl_httppost)) \ 98 _curl_easy_setopt_err_curl_httpost(); \ 99 if(_curl_is_slist_option(_curl_opt)) \ 100 if(!_curl_is_arr((value), struct curl_slist)) \ 101 _curl_easy_setopt_err_curl_slist(); \ 102 if((_curl_opt) == CURLOPT_SHARE) \ 103 if(!_curl_is_ptr((value), CURLSH)) \ 104 _curl_easy_setopt_err_CURLSH(); \ 105 } \ 106 curl_easy_setopt(handle, _curl_opt, value); \ 107 }) 108 109 /* wraps curl_easy_getinfo() with typechecking */ 110 /* FIXME: do not allow const pointers */ 111 #define curl_easy_getinfo(handle, info, arg) \ 112 __extension__ ({ \ 113 __typeof__ (info) _curl_info = info; \ 114 if(__builtin_constant_p(_curl_info)) { \ 115 if(_curl_is_string_info(_curl_info)) \ 116 if(!_curl_is_arr((arg), char *)) \ 117 _curl_easy_getinfo_err_string(); \ 118 if(_curl_is_long_info(_curl_info)) \ 119 if(!_curl_is_arr((arg), long)) \ 120 _curl_easy_getinfo_err_long(); \ 121 if(_curl_is_double_info(_curl_info)) \ 122 if(!_curl_is_arr((arg), double)) \ 123 _curl_easy_getinfo_err_double(); \ 124 if(_curl_is_slist_info(_curl_info)) \ 125 if(!_curl_is_arr((arg), struct curl_slist *)) \ 126 _curl_easy_getinfo_err_curl_slist(); \ 127 } \ 128 curl_easy_getinfo(handle, _curl_info, arg); \ 129 }) 130 131 /* TODO: typechecking for curl_share_setopt() and curl_multi_setopt(), 132 * for now just make sure that the functions are called with three 133 * arguments 134 */ 135 #define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param) 136 #define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param) 137 138 139 /* the actual warnings, triggered by calling the _curl_easy_setopt_err* 140 * functions */ 141 142 /* To define a new warning, use _CURL_WARNING(identifier, "message") */ 143 #define _CURL_WARNING(id, message) \ 144 static void __attribute__((warning(message))) __attribute__((unused)) \ 145 __attribute__((noinline)) id(void) { __asm__(""); } 146 147 _CURL_WARNING(_curl_easy_setopt_err_long, 148 "curl_easy_setopt expects a long argument for this option") 149 _CURL_WARNING(_curl_easy_setopt_err_curl_off_t, 150 "curl_easy_setopt expects a curl_off_t argument for this option") 151 _CURL_WARNING(_curl_easy_setopt_err_string, 152 "curl_easy_setopt expects a " 153 "string (char* or char[]) argument for this option" 154 ) 155 _CURL_WARNING(_curl_easy_setopt_err_write_callback, 156 "curl_easy_setopt expects a curl_write_callback argument for this option") 157 _CURL_WARNING(_curl_easy_setopt_err_read_cb, 158 "curl_easy_setopt expects a curl_read_callback argument for this option") 159 _CURL_WARNING(_curl_easy_setopt_err_ioctl_cb, 160 "curl_easy_setopt expects a curl_ioctl_callback argument for this option") 161 _CURL_WARNING(_curl_easy_setopt_err_sockopt_cb, 162 "curl_easy_setopt expects a curl_sockopt_callback argument for this option") 163 _CURL_WARNING(_curl_easy_setopt_err_opensocket_cb, 164 "curl_easy_setopt expects a " 165 "curl_opensocket_callback argument for this option" 166 ) 167 _CURL_WARNING(_curl_easy_setopt_err_progress_cb, 168 "curl_easy_setopt expects a curl_progress_callback argument for this option") 169 _CURL_WARNING(_curl_easy_setopt_err_debug_cb, 170 "curl_easy_setopt expects a curl_debug_callback argument for this option") 171 _CURL_WARNING(_curl_easy_setopt_err_ssl_ctx_cb, 172 "curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option") 173 _CURL_WARNING(_curl_easy_setopt_err_conv_cb, 174 "curl_easy_setopt expects a curl_conv_callback argument for this option") 175 _CURL_WARNING(_curl_easy_setopt_err_seek_cb, 176 "curl_easy_setopt expects a curl_seek_callback argument for this option") 177 _CURL_WARNING(_curl_easy_setopt_err_cb_data, 178 "curl_easy_setopt expects a " 179 "private data pointer as argument for this option") 180 _CURL_WARNING(_curl_easy_setopt_err_error_buffer, 181 "curl_easy_setopt expects a " 182 "char buffer of CURL_ERROR_SIZE as argument for this option") 183 _CURL_WARNING(_curl_easy_setopt_err_FILE, 184 "curl_easy_setopt expects a FILE* argument for this option") 185 _CURL_WARNING(_curl_easy_setopt_err_postfields, 186 "curl_easy_setopt expects a void* or char* argument for this option") 187 _CURL_WARNING(_curl_easy_setopt_err_curl_httpost, 188 "curl_easy_setopt expects a struct curl_httppost* argument for this option") 189 _CURL_WARNING(_curl_easy_setopt_err_curl_slist, 190 "curl_easy_setopt expects a struct curl_slist* argument for this option") 191 _CURL_WARNING(_curl_easy_setopt_err_CURLSH, 192 "curl_easy_setopt expects a CURLSH* argument for this option") 193 194 _CURL_WARNING(_curl_easy_getinfo_err_string, 195 "curl_easy_getinfo expects a pointer to char * for this info") 196 _CURL_WARNING(_curl_easy_getinfo_err_long, 197 "curl_easy_getinfo expects a pointer to long for this info") 198 _CURL_WARNING(_curl_easy_getinfo_err_double, 199 "curl_easy_getinfo expects a pointer to double for this info") 200 _CURL_WARNING(_curl_easy_getinfo_err_curl_slist, 201 "curl_easy_getinfo expects a pointer to struct curl_slist * for this info") 202 203 /* groups of curl_easy_setops options that take the same type of argument */ 204 205 /* To add a new option to one of the groups, just add 206 * (option) == CURLOPT_SOMETHING 207 * to the or-expression. If the option takes a long or curl_off_t, you do not 208 * have to do anything 209 */ 210 211 /* evaluates to true if option takes a long argument */ 212 #define _curl_is_long_option(option) \ 213 (0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT) 214 215 #define _curl_is_off_t_option(option) \ 216 ((option) > CURLOPTTYPE_OFF_T) 217 218 /* evaluates to true if option takes a char* argument */ 219 #define _curl_is_string_option(option) \ 220 ((option) == CURLOPT_URL || \ 221 (option) == CURLOPT_PROXY || \ 222 (option) == CURLOPT_INTERFACE || \ 223 (option) == CURLOPT_NETRC_FILE || \ 224 (option) == CURLOPT_USERPWD || \ 225 (option) == CURLOPT_USERNAME || \ 226 (option) == CURLOPT_PASSWORD || \ 227 (option) == CURLOPT_PROXYUSERPWD || \ 228 (option) == CURLOPT_PROXYUSERNAME || \ 229 (option) == CURLOPT_PROXYPASSWORD || \ 230 (option) == CURLOPT_NOPROXY || \ 231 (option) == CURLOPT_ACCEPT_ENCODING || \ 232 (option) == CURLOPT_REFERER || \ 233 (option) == CURLOPT_USERAGENT || \ 234 (option) == CURLOPT_COOKIE || \ 235 (option) == CURLOPT_COOKIEFILE || \ 236 (option) == CURLOPT_COOKIEJAR || \ 237 (option) == CURLOPT_COOKIELIST || \ 238 (option) == CURLOPT_FTPPORT || \ 239 (option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \ 240 (option) == CURLOPT_FTP_ACCOUNT || \ 241 (option) == CURLOPT_RANGE || \ 242 (option) == CURLOPT_CUSTOMREQUEST || \ 243 (option) == CURLOPT_SSLCERT || \ 244 (option) == CURLOPT_SSLCERTTYPE || \ 245 (option) == CURLOPT_SSLKEY || \ 246 (option) == CURLOPT_SSLKEYTYPE || \ 247 (option) == CURLOPT_KEYPASSWD || \ 248 (option) == CURLOPT_SSLENGINE || \ 249 (option) == CURLOPT_CAINFO || \ 250 (option) == CURLOPT_CAPATH || \ 251 (option) == CURLOPT_RANDOM_FILE || \ 252 (option) == CURLOPT_EGDSOCKET || \ 253 (option) == CURLOPT_SSL_CIPHER_LIST || \ 254 (option) == CURLOPT_KRBLEVEL || \ 255 (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \ 256 (option) == CURLOPT_SSH_PUBLIC_KEYFILE || \ 257 (option) == CURLOPT_SSH_PRIVATE_KEYFILE || \ 258 (option) == CURLOPT_CRLFILE || \ 259 (option) == CURLOPT_ISSUERCERT || \ 260 (option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \ 261 (option) == CURLOPT_SSH_KNOWNHOSTS || \ 262 (option) == CURLOPT_MAIL_FROM || \ 263 (option) == CURLOPT_RTSP_SESSION_ID || \ 264 (option) == CURLOPT_RTSP_STREAM_URI || \ 265 (option) == CURLOPT_RTSP_TRANSPORT || \ 266 0) 267 268 /* evaluates to true if option takes a curl_write_callback argument */ 269 #define _curl_is_write_cb_option(option) \ 270 ((option) == CURLOPT_HEADERFUNCTION || \ 271 (option) == CURLOPT_WRITEFUNCTION) 272 273 /* evaluates to true if option takes a curl_conv_callback argument */ 274 #define _curl_is_conv_cb_option(option) \ 275 ((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \ 276 (option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \ 277 (option) == CURLOPT_CONV_FROM_UTF8_FUNCTION) 278 279 /* evaluates to true if option takes a data argument to pass to a callback */ 280 #define _curl_is_cb_data_option(option) \ 281 ((option) == CURLOPT_WRITEDATA || \ 282 (option) == CURLOPT_READDATA || \ 283 (option) == CURLOPT_IOCTLDATA || \ 284 (option) == CURLOPT_SOCKOPTDATA || \ 285 (option) == CURLOPT_OPENSOCKETDATA || \ 286 (option) == CURLOPT_PROGRESSDATA || \ 287 (option) == CURLOPT_WRITEHEADER || \ 288 (option) == CURLOPT_DEBUGDATA || \ 289 (option) == CURLOPT_SSL_CTX_DATA || \ 290 (option) == CURLOPT_SEEKDATA || \ 291 (option) == CURLOPT_PRIVATE || \ 292 (option) == CURLOPT_SSH_KEYDATA || \ 293 (option) == CURLOPT_INTERLEAVEDATA || \ 294 (option) == CURLOPT_CHUNK_DATA || \ 295 (option) == CURLOPT_FNMATCH_DATA || \ 296 0) 297 298 /* evaluates to true if option takes a POST data argument (void* or char*) */ 299 #define _curl_is_postfields_option(option) \ 300 ((option) == CURLOPT_POSTFIELDS || \ 301 (option) == CURLOPT_COPYPOSTFIELDS || \ 302 0) 303 304 /* evaluates to true if option takes a struct curl_slist * argument */ 305 #define _curl_is_slist_option(option) \ 306 ((option) == CURLOPT_HTTPHEADER || \ 307 (option) == CURLOPT_HTTP200ALIASES || \ 308 (option) == CURLOPT_QUOTE || \ 309 (option) == CURLOPT_POSTQUOTE || \ 310 (option) == CURLOPT_PREQUOTE || \ 311 (option) == CURLOPT_TELNETOPTIONS || \ 312 (option) == CURLOPT_MAIL_RCPT || \ 313 0) 314 315 /* groups of curl_easy_getinfo infos that take the same type of argument */ 316 317 /* evaluates to true if info expects a pointer to char * argument */ 318 #define _curl_is_string_info(info) \ 319 (CURLINFO_STRING < (info) && (info) < CURLINFO_LONG) 320 321 /* evaluates to true if info expects a pointer to long argument */ 322 #define _curl_is_long_info(info) \ 323 (CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE) 324 325 /* evaluates to true if info expects a pointer to double argument */ 326 #define _curl_is_double_info(info) \ 327 (CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST) 328 329 /* true if info expects a pointer to struct curl_slist * argument */ 330 #define _curl_is_slist_info(info) \ 331 (CURLINFO_SLIST < (info)) 332 333 334 /* typecheck helpers -- check whether given expression has requested type*/ 335 336 /* For pointers, you can use the _curl_is_ptr/_curl_is_arr macros, 337 * otherwise define a new macro. Search for __builtin_types_compatible_p 338 * in the GCC manual. 339 * NOTE: these macros MUST NOT EVALUATE their arguments! The argument is 340 * the actual expression passed to the curl_easy_setopt macro. This 341 * means that you can only apply the sizeof and __typeof__ operators, no 342 * == or whatsoever. 343 */ 344 345 /* XXX: should evaluate to true iff expr is a pointer */ 346 #define _curl_is_any_ptr(expr) \ 347 (sizeof(expr) == sizeof(void*)) 348 349 /* evaluates to true if expr is NULL */ 350 /* XXX: must not evaluate expr, so this check is not accurate */ 351 #define _curl_is_NULL(expr) \ 352 (__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL))) 353 354 /* evaluates to true if expr is type*, const type* or NULL */ 355 #define _curl_is_ptr(expr, type) \ 356 (_curl_is_NULL(expr) || \ 357 __builtin_types_compatible_p(__typeof__(expr), type *) || \ 358 __builtin_types_compatible_p(__typeof__(expr), const type *)) 359 360 /* evaluates to true if expr is one of type[], type*, NULL or const type* */ 361 #define _curl_is_arr(expr, type) \ 362 (_curl_is_ptr((expr), type) || \ 363 __builtin_types_compatible_p(__typeof__(expr), type [])) 364 365 /* evaluates to true if expr is a string */ 366 #define _curl_is_string(expr) \ 367 (_curl_is_arr((expr), char) || \ 368 _curl_is_arr((expr), signed char) || \ 369 _curl_is_arr((expr), unsigned char)) 370 371 /* evaluates to true if expr is a long (no matter the signedness) 372 * XXX: for now, int is also accepted (and therefore short and char, which 373 * are promoted to int when passed to a variadic function) */ 374 #define _curl_is_long(expr) \ 375 (__builtin_types_compatible_p(__typeof__(expr), long) || \ 376 __builtin_types_compatible_p(__typeof__(expr), signed long) || \ 377 __builtin_types_compatible_p(__typeof__(expr), unsigned long) || \ 378 __builtin_types_compatible_p(__typeof__(expr), int) || \ 379 __builtin_types_compatible_p(__typeof__(expr), signed int) || \ 380 __builtin_types_compatible_p(__typeof__(expr), unsigned int) || \ 381 __builtin_types_compatible_p(__typeof__(expr), short) || \ 382 __builtin_types_compatible_p(__typeof__(expr), signed short) || \ 383 __builtin_types_compatible_p(__typeof__(expr), unsigned short) || \ 384 __builtin_types_compatible_p(__typeof__(expr), char) || \ 385 __builtin_types_compatible_p(__typeof__(expr), signed char) || \ 386 __builtin_types_compatible_p(__typeof__(expr), unsigned char)) 387 388 /* evaluates to true if expr is of type curl_off_t */ 389 #define _curl_is_off_t(expr) \ 390 (__builtin_types_compatible_p(__typeof__(expr), curl_off_t)) 391 392 /* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */ 393 /* XXX: also check size of an char[] array? */ 394 #define _curl_is_error_buffer(expr) \ 395 (__builtin_types_compatible_p(__typeof__(expr), char *) || \ 396 __builtin_types_compatible_p(__typeof__(expr), char[])) 397 398 /* evaluates to true if expr is of type (const) void* or (const) FILE* */ 399 #if 0 400 #define _curl_is_cb_data(expr) \ 401 (_curl_is_ptr((expr), void) || \ 402 _curl_is_ptr((expr), FILE)) 403 #else /* be less strict */ 404 #define _curl_is_cb_data(expr) \ 405 _curl_is_any_ptr(expr) 406 #endif 407 408 /* evaluates to true if expr is of type FILE* */ 409 #define _curl_is_FILE(expr) \ 410 (__builtin_types_compatible_p(__typeof__(expr), FILE *)) 411 412 /* evaluates to true if expr can be passed as POST data (void* or char*) */ 413 #define _curl_is_postfields(expr) \ 414 (_curl_is_ptr((expr), void) || \ 415 _curl_is_arr((expr), char)) 416 417 /* FIXME: the whole callback checking is messy... 418 * The idea is to tolerate char vs. void and const vs. not const 419 * pointers in arguments at least 420 */ 421 /* helper: __builtin_types_compatible_p distinguishes between functions and 422 * function pointers, hide it */ 423 #define _curl_callback_compatible(func, type) \ 424 (__builtin_types_compatible_p(__typeof__(func), type) || \ 425 __builtin_types_compatible_p(__typeof__(func), type*)) 426 427 /* evaluates to true if expr is of type curl_read_callback or "similar" */ 428 #define _curl_is_read_cb(expr) \ 429 (_curl_is_NULL(expr) || \ 430 __builtin_types_compatible_p(__typeof__(expr), __typeof__(fread)) || \ 431 __builtin_types_compatible_p(__typeof__(expr), curl_read_callback) || \ 432 _curl_callback_compatible((expr), _curl_read_callback1) || \ 433 _curl_callback_compatible((expr), _curl_read_callback2) || \ 434 _curl_callback_compatible((expr), _curl_read_callback3) || \ 435 _curl_callback_compatible((expr), _curl_read_callback4) || \ 436 _curl_callback_compatible((expr), _curl_read_callback5) || \ 437 _curl_callback_compatible((expr), _curl_read_callback6)) 438 typedef size_t (_curl_read_callback1)(char *, size_t, size_t, void*); 439 typedef size_t (_curl_read_callback2)(char *, size_t, size_t, const void*); 440 typedef size_t (_curl_read_callback3)(char *, size_t, size_t, FILE*); 441 typedef size_t (_curl_read_callback4)(void *, size_t, size_t, void*); 442 typedef size_t (_curl_read_callback5)(void *, size_t, size_t, const void*); 443 typedef size_t (_curl_read_callback6)(void *, size_t, size_t, FILE*); 444 445 /* evaluates to true if expr is of type curl_write_callback or "similar" */ 446 #define _curl_is_write_cb(expr) \ 447 (_curl_is_read_cb(expr) || \ 448 __builtin_types_compatible_p(__typeof__(expr), __typeof__(fwrite)) || \ 449 __builtin_types_compatible_p(__typeof__(expr), curl_write_callback) || \ 450 _curl_callback_compatible((expr), _curl_write_callback1) || \ 451 _curl_callback_compatible((expr), _curl_write_callback2) || \ 452 _curl_callback_compatible((expr), _curl_write_callback3) || \ 453 _curl_callback_compatible((expr), _curl_write_callback4) || \ 454 _curl_callback_compatible((expr), _curl_write_callback5) || \ 455 _curl_callback_compatible((expr), _curl_write_callback6)) 456 typedef size_t (_curl_write_callback1)(const char *, size_t, size_t, void*); 457 typedef size_t (_curl_write_callback2)(const char *, size_t, size_t, 458 const void*); 459 typedef size_t (_curl_write_callback3)(const char *, size_t, size_t, FILE*); 460 typedef size_t (_curl_write_callback4)(const void *, size_t, size_t, void*); 461 typedef size_t (_curl_write_callback5)(const void *, size_t, size_t, 462 const void*); 463 typedef size_t (_curl_write_callback6)(const void *, size_t, size_t, FILE*); 464 465 /* evaluates to true if expr is of type curl_ioctl_callback or "similar" */ 466 #define _curl_is_ioctl_cb(expr) \ 467 (_curl_is_NULL(expr) || \ 468 __builtin_types_compatible_p(__typeof__(expr), curl_ioctl_callback) || \ 469 _curl_callback_compatible((expr), _curl_ioctl_callback1) || \ 470 _curl_callback_compatible((expr), _curl_ioctl_callback2) || \ 471 _curl_callback_compatible((expr), _curl_ioctl_callback3) || \ 472 _curl_callback_compatible((expr), _curl_ioctl_callback4)) 473 typedef curlioerr (_curl_ioctl_callback1)(CURL *, int, void*); 474 typedef curlioerr (_curl_ioctl_callback2)(CURL *, int, const void*); 475 typedef curlioerr (_curl_ioctl_callback3)(CURL *, curliocmd, void*); 476 typedef curlioerr (_curl_ioctl_callback4)(CURL *, curliocmd, const void*); 477 478 /* evaluates to true if expr is of type curl_sockopt_callback or "similar" */ 479 #define _curl_is_sockopt_cb(expr) \ 480 (_curl_is_NULL(expr) || \ 481 __builtin_types_compatible_p(__typeof__(expr), curl_sockopt_callback) || \ 482 _curl_callback_compatible((expr), _curl_sockopt_callback1) || \ 483 _curl_callback_compatible((expr), _curl_sockopt_callback2)) 484 typedef int (_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype); 485 typedef int (_curl_sockopt_callback2)(const void *, curl_socket_t, 486 curlsocktype); 487 488 /* evaluates to true if expr is of type curl_opensocket_callback or 489 "similar" */ 490 #define _curl_is_opensocket_cb(expr) \ 491 (_curl_is_NULL(expr) || \ 492 __builtin_types_compatible_p(__typeof__(expr), curl_opensocket_callback) ||\ 493 _curl_callback_compatible((expr), _curl_opensocket_callback1) || \ 494 _curl_callback_compatible((expr), _curl_opensocket_callback2) || \ 495 _curl_callback_compatible((expr), _curl_opensocket_callback3) || \ 496 _curl_callback_compatible((expr), _curl_opensocket_callback4)) 497 typedef curl_socket_t (_curl_opensocket_callback1) 498 (void *, curlsocktype, struct curl_sockaddr *); 499 typedef curl_socket_t (_curl_opensocket_callback2) 500 (void *, curlsocktype, const struct curl_sockaddr *); 501 typedef curl_socket_t (_curl_opensocket_callback3) 502 (const void *, curlsocktype, struct curl_sockaddr *); 503 typedef curl_socket_t (_curl_opensocket_callback4) 504 (const void *, curlsocktype, const struct curl_sockaddr *); 505 506 /* evaluates to true if expr is of type curl_progress_callback or "similar" */ 507 #define _curl_is_progress_cb(expr) \ 508 (_curl_is_NULL(expr) || \ 509 __builtin_types_compatible_p(__typeof__(expr), curl_progress_callback) || \ 510 _curl_callback_compatible((expr), _curl_progress_callback1) || \ 511 _curl_callback_compatible((expr), _curl_progress_callback2)) 512 typedef int (_curl_progress_callback1)(void *, 513 double, double, double, double); 514 typedef int (_curl_progress_callback2)(const void *, 515 double, double, double, double); 516 517 /* evaluates to true if expr is of type curl_debug_callback or "similar" */ 518 #define _curl_is_debug_cb(expr) \ 519 (_curl_is_NULL(expr) || \ 520 __builtin_types_compatible_p(__typeof__(expr), curl_debug_callback) || \ 521 _curl_callback_compatible((expr), _curl_debug_callback1) || \ 522 _curl_callback_compatible((expr), _curl_debug_callback2) || \ 523 _curl_callback_compatible((expr), _curl_debug_callback3) || \ 524 _curl_callback_compatible((expr), _curl_debug_callback4)) 525 typedef int (_curl_debug_callback1) (CURL *, 526 curl_infotype, char *, size_t, void *); 527 typedef int (_curl_debug_callback2) (CURL *, 528 curl_infotype, char *, size_t, const void *); 529 typedef int (_curl_debug_callback3) (CURL *, 530 curl_infotype, const char *, size_t, void *); 531 typedef int (_curl_debug_callback4) (CURL *, 532 curl_infotype, const char *, size_t, const void *); 533 534 /* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */ 535 /* this is getting even messier... */ 536 #define _curl_is_ssl_ctx_cb(expr) \ 537 (_curl_is_NULL(expr) || \ 538 __builtin_types_compatible_p(__typeof__(expr), curl_ssl_ctx_callback) || \ 539 _curl_callback_compatible((expr), _curl_ssl_ctx_callback1) || \ 540 _curl_callback_compatible((expr), _curl_ssl_ctx_callback2) || \ 541 _curl_callback_compatible((expr), _curl_ssl_ctx_callback3) || \ 542 _curl_callback_compatible((expr), _curl_ssl_ctx_callback4) || \ 543 _curl_callback_compatible((expr), _curl_ssl_ctx_callback5) || \ 544 _curl_callback_compatible((expr), _curl_ssl_ctx_callback6) || \ 545 _curl_callback_compatible((expr), _curl_ssl_ctx_callback7) || \ 546 _curl_callback_compatible((expr), _curl_ssl_ctx_callback8)) 547 typedef CURLcode (_curl_ssl_ctx_callback1)(CURL *, void *, void *); 548 typedef CURLcode (_curl_ssl_ctx_callback2)(CURL *, void *, const void *); 549 typedef CURLcode (_curl_ssl_ctx_callback3)(CURL *, const void *, void *); 550 typedef CURLcode (_curl_ssl_ctx_callback4)(CURL *, const void *, const void *); 551 #ifdef HEADER_SSL_H 552 /* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX 553 * this will of course break if we have included OpenSSL headers earlier... 554 */ 555 typedef CURLcode (_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *); 556 typedef CURLcode (_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *); 557 typedef CURLcode (_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *); 558 typedef CURLcode (_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX, 559 const void *); 560 #else 561 typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5; 562 typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6; 563 typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7; 564 typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8; 565 #endif 566 567 /* evaluates to true if expr is of type curl_conv_callback or "similar" */ 568 #define _curl_is_conv_cb(expr) \ 569 (_curl_is_NULL(expr) || \ 570 __builtin_types_compatible_p(__typeof__(expr), curl_conv_callback) || \ 571 _curl_callback_compatible((expr), _curl_conv_callback1) || \ 572 _curl_callback_compatible((expr), _curl_conv_callback2) || \ 573 _curl_callback_compatible((expr), _curl_conv_callback3) || \ 574 _curl_callback_compatible((expr), _curl_conv_callback4)) 575 typedef CURLcode (*_curl_conv_callback1)(char *, size_t length); 576 typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length); 577 typedef CURLcode (*_curl_conv_callback3)(void *, size_t length); 578 typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length); 579 580 /* evaluates to true if expr is of type curl_seek_callback or "similar" */ 581 #define _curl_is_seek_cb(expr) \ 582 (_curl_is_NULL(expr) || \ 583 __builtin_types_compatible_p(__typeof__(expr), curl_seek_callback) || \ 584 _curl_callback_compatible((expr), _curl_seek_callback1) || \ 585 _curl_callback_compatible((expr), _curl_seek_callback2)) 586 typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int); 587 typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int); 588 589 590 #endif /* __CURL_TYPECHECK_GCC_H */ 591