1 #ifndef __CURL_TYPECHECK_GCC_H 2 #define __CURL_TYPECHECK_GCC_H 41 #define curl_easy_setopt(handle, option, value) \ 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_is_conv_cb_option(_curl_opt)) \ 76 if(!_curl_is_conv_cb(value)) \ 77 _curl_easy_setopt_err_conv_cb(); \ 78 if((_curl_opt) == CURLOPT_SEEKFUNCTION) \ 79 if(!_curl_is_seek_cb(value)) \ 80 _curl_easy_setopt_err_seek_cb(); \ 81 if(_curl_is_cb_data_option(_curl_opt)) \ 82 if(!_curl_is_cb_data(value)) \ 83 _curl_easy_setopt_err_cb_data(); \ 84 if((_curl_opt) == CURLOPT_ERRORBUFFER) \ 85 if(!_curl_is_error_buffer(value)) \ 86 _curl_easy_setopt_err_error_buffer(); \ 87 if((_curl_opt) == CURLOPT_STDERR) \ 88 if(!_curl_is_FILE(value)) \ 89 _curl_easy_setopt_err_FILE(); \ 90 if(_curl_is_postfields_option(_curl_opt)) \ 91 if(!_curl_is_postfields(value)) \ 92 _curl_easy_setopt_err_postfields(); \ 93 if((_curl_opt) == CURLOPT_HTTPPOST) \ 94 if(!_curl_is_arr((value), struct curl_httppost)) \ 95 _curl_easy_setopt_err_curl_httpost(); \ 96 if(_curl_is_slist_option(_curl_opt)) \ 97 if(!_curl_is_arr((value), struct curl_slist)) \ 98 _curl_easy_setopt_err_curl_slist(); \ 99 if((_curl_opt) == CURLOPT_SHARE) \ 100 if(!_curl_is_ptr((value), CURLSH)) \ 101 _curl_easy_setopt_err_CURLSH(); \ 103 curl_easy_setopt(handle, _curl_opt, value); \ 108 #define curl_easy_getinfo(handle, info, arg) \ 110 __typeof__ (info) _curl_info = info; \ 111 if(__builtin_constant_p(_curl_info)) { \ 112 if(_curl_is_string_info(_curl_info)) \ 113 if(!_curl_is_arr((arg), char *)) \ 114 _curl_easy_getinfo_err_string(); \ 115 if(_curl_is_long_info(_curl_info)) \ 116 if(!_curl_is_arr((arg), long)) \ 117 _curl_easy_getinfo_err_long(); \ 118 if(_curl_is_double_info(_curl_info)) \ 119 if(!_curl_is_arr((arg), double)) \ 120 _curl_easy_getinfo_err_double(); \ 121 if(_curl_is_slist_info(_curl_info)) \ 122 if(!_curl_is_arr((arg), struct curl_slist *)) \ 123 _curl_easy_getinfo_err_curl_slist(); \ 125 curl_easy_getinfo(handle, _curl_info, arg); \ 132 #define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param) 133 #define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param) 140 #define _CURL_WARNING(id, message) \ 141 static void __attribute__((warning(message))) __attribute__((unused)) \ 142 __attribute__((noinline)) id(void) { __asm__(""); } 145 "curl_easy_setopt expects a long argument for this option")
150 "
string (
char* or
char[]) argument for this option"
176 "private
data pointer as argument for this option")
209 #define _curl_is_long_option(option) \ 210 (0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT) 212 #define _curl_is_off_t_option(option) \ 213 ((option) > CURLOPTTYPE_OFF_T) 216 #define _curl_is_string_option(option) \ 217 ((option) == CURLOPT_URL || \ 218 (option) == CURLOPT_PROXY || \ 219 (option) == CURLOPT_INTERFACE || \ 220 (option) == CURLOPT_NETRC_FILE || \ 221 (option) == CURLOPT_USERPWD || \ 222 (option) == CURLOPT_USERNAME || \ 223 (option) == CURLOPT_PASSWORD || \ 224 (option) == CURLOPT_PROXYUSERPWD || \ 225 (option) == CURLOPT_PROXYUSERNAME || \ 226 (option) == CURLOPT_PROXYPASSWORD || \ 227 (option) == CURLOPT_NOPROXY || \ 228 (option) == CURLOPT_ACCEPT_ENCODING || \ 229 (option) == CURLOPT_REFERER || \ 230 (option) == CURLOPT_USERAGENT || \ 231 (option) == CURLOPT_COOKIE || \ 232 (option) == CURLOPT_COOKIEFILE || \ 233 (option) == CURLOPT_COOKIEJAR || \ 234 (option) == CURLOPT_COOKIELIST || \ 235 (option) == CURLOPT_FTPPORT || \ 236 (option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \ 237 (option) == CURLOPT_FTP_ACCOUNT || \ 238 (option) == CURLOPT_RANGE || \ 239 (option) == CURLOPT_CUSTOMREQUEST || \ 240 (option) == CURLOPT_KRBLEVEL || \ 241 (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \ 242 (option) == CURLOPT_SSH_PUBLIC_KEYFILE || \ 243 (option) == CURLOPT_SSH_PRIVATE_KEYFILE || \ 244 (option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \ 245 (option) == CURLOPT_SSH_KNOWNHOSTS || \ 246 (option) == CURLOPT_MAIL_FROM || \ 247 (option) == CURLOPT_RTSP_SESSION_ID || \ 248 (option) == CURLOPT_RTSP_STREAM_URI || \ 249 (option) == CURLOPT_RTSP_TRANSPORT || \ 253 #define _curl_is_write_cb_option(option) \ 254 ((option) == CURLOPT_HEADERFUNCTION || \ 255 (option) == CURLOPT_WRITEFUNCTION) 258 #define _curl_is_conv_cb_option(option) \ 259 ((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \ 260 (option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \ 261 (option) == CURLOPT_CONV_FROM_UTF8_FUNCTION) 264 #define _curl_is_cb_data_option(option) \ 265 ((option) == CURLOPT_WRITEDATA || \ 266 (option) == CURLOPT_READDATA || \ 267 (option) == CURLOPT_IOCTLDATA || \ 268 (option) == CURLOPT_SOCKOPTDATA || \ 269 (option) == CURLOPT_OPENSOCKETDATA || \ 270 (option) == CURLOPT_PROGRESSDATA || \ 271 (option) == CURLOPT_WRITEHEADER || \ 272 (option) == CURLOPT_DEBUGDATA || \ 273 (option) == CURLOPT_SEEKDATA || \ 274 (option) == CURLOPT_PRIVATE || \ 275 (option) == CURLOPT_SSH_KEYDATA || \ 276 (option) == CURLOPT_INTERLEAVEDATA || \ 277 (option) == CURLOPT_CHUNK_DATA || \ 278 (option) == CURLOPT_FNMATCH_DATA || \ 282 #define _curl_is_postfields_option(option) \ 283 ((option) == CURLOPT_POSTFIELDS || \ 284 (option) == CURLOPT_COPYPOSTFIELDS || \ 288 #define _curl_is_slist_option(option) \ 289 ((option) == CURLOPT_HTTPHEADER || \ 290 (option) == CURLOPT_HTTP200ALIASES || \ 291 (option) == CURLOPT_QUOTE || \ 292 (option) == CURLOPT_POSTQUOTE || \ 293 (option) == CURLOPT_PREQUOTE || \ 294 (option) == CURLOPT_TELNETOPTIONS || \ 295 (option) == CURLOPT_MAIL_RCPT || \ 301 #define _curl_is_string_info(info) \ 302 (CURLINFO_STRING < (info) && (info) < CURLINFO_LONG) 305 #define _curl_is_long_info(info) \ 306 (CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE) 309 #define _curl_is_double_info(info) \ 310 (CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST) 313 #define _curl_is_slist_info(info) \ 314 (CURLINFO_SLIST < (info)) 329 #define _curl_is_any_ptr(expr) \ 330 (sizeof(expr) == sizeof(void*)) 334 #define _curl_is_NULL(expr) \ 335 (__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL))) 338 #define _curl_is_ptr(expr, type) \ 339 (_curl_is_NULL(expr) || \ 340 __builtin_types_compatible_p(__typeof__(expr), type *) || \ 341 __builtin_types_compatible_p(__typeof__(expr), const type *)) 344 #define _curl_is_arr(expr, type) \ 345 (_curl_is_ptr((expr), type) || \ 346 __builtin_types_compatible_p(__typeof__(expr), type [])) 349 #define _curl_is_string(expr) \ 350 (_curl_is_arr((expr), char) || \ 351 _curl_is_arr((expr), signed char) || \ 352 _curl_is_arr((expr), unsigned char)) 357 #define _curl_is_long(expr) \ 358 (__builtin_types_compatible_p(__typeof__(expr), long) || \ 359 __builtin_types_compatible_p(__typeof__(expr), signed long) || \ 360 __builtin_types_compatible_p(__typeof__(expr), unsigned long) || \ 361 __builtin_types_compatible_p(__typeof__(expr), int) || \ 362 __builtin_types_compatible_p(__typeof__(expr), signed int) || \ 363 __builtin_types_compatible_p(__typeof__(expr), unsigned int) || \ 364 __builtin_types_compatible_p(__typeof__(expr), short) || \ 365 __builtin_types_compatible_p(__typeof__(expr), signed short) || \ 366 __builtin_types_compatible_p(__typeof__(expr), unsigned short) || \ 367 __builtin_types_compatible_p(__typeof__(expr), char) || \ 368 __builtin_types_compatible_p(__typeof__(expr), signed char) || \ 369 __builtin_types_compatible_p(__typeof__(expr), unsigned char)) 372 #define _curl_is_off_t(expr) \ 373 (__builtin_types_compatible_p(__typeof__(expr), curl_off_t)) 377 #define _curl_is_error_buffer(expr) \ 378 (__builtin_types_compatible_p(__typeof__(expr), char *) || \ 379 __builtin_types_compatible_p(__typeof__(expr), char[])) 383 #define _curl_is_cb_data(expr) \ 384 (_curl_is_ptr((expr), void) || \ 385 _curl_is_ptr((expr), FILE)) 387 #define _curl_is_cb_data(expr) \ 388 _curl_is_any_ptr(expr) 392 #define _curl_is_FILE(expr) \ 393 (__builtin_types_compatible_p(__typeof__(expr), FILE *)) 396 #define _curl_is_postfields(expr) \ 397 (_curl_is_ptr((expr), void) || \ 398 _curl_is_arr((expr), char)) 406 #define _curl_callback_compatible(func, type) \ 407 (__builtin_types_compatible_p(__typeof__(func), type) || \ 408 __builtin_types_compatible_p(__typeof__(func), type*)) 411 #define _curl_is_read_cb(expr) \ 412 (_curl_is_NULL(expr) || \ 413 __builtin_types_compatible_p(__typeof__(expr), __typeof__(fread)) || \ 414 __builtin_types_compatible_p(__typeof__(expr), curl_read_callback) || \ 415 _curl_callback_compatible((expr), _curl_read_callback1) || \ 416 _curl_callback_compatible((expr), _curl_read_callback2) || \ 417 _curl_callback_compatible((expr), _curl_read_callback3) || \ 418 _curl_callback_compatible((expr), _curl_read_callback4) || \ 419 _curl_callback_compatible((expr), _curl_read_callback5) || \ 420 _curl_callback_compatible((expr), _curl_read_callback6)) 429 #define _curl_is_write_cb(expr) \ 430 (_curl_is_read_cb(expr) || \ 431 __builtin_types_compatible_p(__typeof__(expr), __typeof__(fwrite)) || \ 432 __builtin_types_compatible_p(__typeof__(expr), curl_write_callback) || \ 433 _curl_callback_compatible((expr), _curl_write_callback1) || \ 434 _curl_callback_compatible((expr), _curl_write_callback2) || \ 435 _curl_callback_compatible((expr), _curl_write_callback3) || \ 436 _curl_callback_compatible((expr), _curl_write_callback4) || \ 437 _curl_callback_compatible((expr), _curl_write_callback5) || \ 438 _curl_callback_compatible((expr), _curl_write_callback6)) 449 #define _curl_is_ioctl_cb(expr) \ 450 (_curl_is_NULL(expr) || \ 451 __builtin_types_compatible_p(__typeof__(expr), curl_ioctl_callback) || \ 452 _curl_callback_compatible((expr), _curl_ioctl_callback1) || \ 453 _curl_callback_compatible((expr), _curl_ioctl_callback2) || \ 454 _curl_callback_compatible((expr), _curl_ioctl_callback3) || \ 455 _curl_callback_compatible((expr), _curl_ioctl_callback4)) 462 #define _curl_is_sockopt_cb(expr) \ 463 (_curl_is_NULL(expr) || \ 464 __builtin_types_compatible_p(__typeof__(expr), curl_sockopt_callback) || \ 465 _curl_callback_compatible((expr), _curl_sockopt_callback1) || \ 466 _curl_callback_compatible((expr), _curl_sockopt_callback2)) 473 #define _curl_is_opensocket_cb(expr) \ 474 (_curl_is_NULL(expr) || \ 475 __builtin_types_compatible_p(__typeof__(expr), curl_opensocket_callback) ||\ 476 _curl_callback_compatible((expr), _curl_opensocket_callback1) || \ 477 _curl_callback_compatible((expr), _curl_opensocket_callback2) || \ 478 _curl_callback_compatible((expr), _curl_opensocket_callback3) || \ 479 _curl_callback_compatible((expr), _curl_opensocket_callback4)) 490 #define _curl_is_progress_cb(expr) \ 491 (_curl_is_NULL(expr) || \ 492 __builtin_types_compatible_p(__typeof__(expr), curl_progress_callback) || \ 493 _curl_callback_compatible((expr), _curl_progress_callback1) || \ 494 _curl_callback_compatible((expr), _curl_progress_callback2)) 496 double, double, double, double);
498 double, double, double, double);
501 #define _curl_is_debug_cb(expr) \ 502 (_curl_is_NULL(expr) || \ 503 __builtin_types_compatible_p(__typeof__(expr), curl_debug_callback) || \ 504 _curl_callback_compatible((expr), _curl_debug_callback1) || \ 505 _curl_callback_compatible((expr), _curl_debug_callback2) || \ 506 _curl_callback_compatible((expr), _curl_debug_callback3) || \ 507 _curl_callback_compatible((expr), _curl_debug_callback4)) 519 #define _curl_is_ssl_ctx_cb(expr) \ 520 (_curl_is_NULL(expr) || \ 521 __builtin_types_compatible_p(__typeof__(expr), curl_ssl_ctx_callback) || \ 522 _curl_callback_compatible((expr), _curl_ssl_ctx_callback1) || \ 523 _curl_callback_compatible((expr), _curl_ssl_ctx_callback2) || \ 524 _curl_callback_compatible((expr), _curl_ssl_ctx_callback3) || \ 525 _curl_callback_compatible((expr), _curl_ssl_ctx_callback4) || \ 526 _curl_callback_compatible((expr), _curl_ssl_ctx_callback5) || \ 527 _curl_callback_compatible((expr), _curl_ssl_ctx_callback6) || \ 528 _curl_callback_compatible((expr), _curl_ssl_ctx_callback7) || \ 529 _curl_callback_compatible((expr), _curl_ssl_ctx_callback8)) 551 #define _curl_is_conv_cb(expr) \ 552 (_curl_is_NULL(expr) || \ 553 __builtin_types_compatible_p(__typeof__(expr), curl_conv_callback) || \ 554 _curl_callback_compatible((expr), _curl_conv_callback1) || \ 555 _curl_callback_compatible((expr), _curl_conv_callback2) || \ 556 _curl_callback_compatible((expr), _curl_conv_callback3) || \ 557 _curl_callback_compatible((expr), _curl_conv_callback4)) 564 #define _curl_is_seek_cb(expr) \ 565 (_curl_is_NULL(expr) || \ 566 __builtin_types_compatible_p(__typeof__(expr), curl_seek_callback) || \ 567 _curl_callback_compatible((expr), _curl_seek_callback1) || \ 568 _curl_callback_compatible((expr), _curl_seek_callback2)) CURLcode(* _curl_conv_callback1)(char *, size_t length)
_curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8
curl_socket_t() _curl_opensocket_callback1(void *, curlsocktype, struct curl_sockaddr *)
CURLcode() _curl_ssl_ctx_callback1(CURL *, void *, void *)
int() _curl_progress_callback1(void *, double, double, double, double)
curl_socket_t() _curl_opensocket_callback2(void *, curlsocktype, const struct curl_sockaddr *)
size_t() _curl_read_callback4(void *, size_t, size_t, void *)
CURLcode(* _curl_conv_callback3)(void *, size_t length)
curlioerr() _curl_ioctl_callback3(CURL *, curliocmd, void *)
curlioerr() _curl_ioctl_callback1(CURL *, int, void *)
CURLcode(* curl_ssl_ctx_callback)(CURL *curl, void *ssl_ctx, void *userptr)
curlioerr() _curl_ioctl_callback2(CURL *, int, const void *)
size_t() _curl_write_callback4(const void *, size_t, size_t, void *)
size_t() _curl_write_callback5(const void *, size_t, size_t, const void *)
CURLcode(* curl_conv_callback)(char *buffer, size_t length)
#define curl_easy_setopt(handle, option, value)
int(* curl_seek_callback)(void *instream, curl_off_t offset, int origin)
CURLcode(* _curl_seek_callback2)(const void *, curl_off_t, int)
int(* curl_debug_callback)(CURL *handle, curl_infotype type, char *data, size_t size, void *userptr)
curl_socket_t() _curl_opensocket_callback4(const void *, curlsocktype, const struct curl_sockaddr *)
_curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6
curlioerr() _curl_ioctl_callback4(CURL *, curliocmd, const void *)
int() _curl_sockopt_callback1(void *, curl_socket_t, curlsocktype)
#define curl_easy_getinfo(handle, info, arg)
_curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7
int(* curl_sockopt_callback)(void *clientp, curl_socket_t curlfd, curlsocktype purpose)
CURLcode() _curl_ssl_ctx_callback2(CURL *, void *, const void *)
curl_socket_t(* curl_opensocket_callback)(void *clientp, curlsocktype purpose, struct curl_sockaddr *address)
CURL_TYPEOF_CURL_OFF_T curl_off_t
size_t() _curl_read_callback2(char *, size_t, size_t, const void *)
curlioerr(* curl_ioctl_callback)(CURL *handle, int cmd, void *clientp)
size_t() _curl_write_callback3(const char *, size_t, size_t, FILE *)
CURLcode(* _curl_conv_callback2)(const char *, size_t length)
int() _curl_debug_callback4(CURL *, curl_infotype, const char *, size_t, const void *)
size_t() _curl_read_callback3(char *, size_t, size_t, FILE *)
size_t() _curl_write_callback6(const void *, size_t, size_t, FILE *)
size_t(* curl_read_callback)(char *buffer, size_t size, size_t nitems, void *instream)
#define _CURL_WARNING(id, message)
int(* curl_progress_callback)(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
int() _curl_debug_callback2(CURL *, curl_infotype, char *, size_t, const void *)
size_t(* curl_write_callback)(char *buffer, size_t size, size_t nitems, void *outstream)
size_t() _curl_read_callback6(void *, size_t, size_t, FILE *)
CURLcode(* _curl_seek_callback1)(void *, curl_off_t, int)
int() _curl_debug_callback1(CURL *, curl_infotype, char *, size_t, void *)
size_t() _curl_write_callback2(const char *, size_t, size_t, const void *)
_curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5
int() _curl_debug_callback3(CURL *, curl_infotype, const char *, size_t, void *)
size_t() _curl_write_callback1(const char *, size_t, size_t, void *)
CURLcode(* _curl_conv_callback4)(const void *, size_t length)
CURLcode() _curl_ssl_ctx_callback4(CURL *, const void *, const void *)
int() _curl_progress_callback2(const void *, double, double, double, double)
size_t() _curl_read_callback5(void *, size_t, size_t, const void *)
curl_socket_t() _curl_opensocket_callback3(const void *, curlsocktype, struct curl_sockaddr *)
size_t() _curl_read_callback1(char *, size_t, size_t, void *)
CURLcode() _curl_ssl_ctx_callback3(CURL *, const void *, void *)
int() _curl_sockopt_callback2(const void *, curl_socket_t, curlsocktype)