Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:06:45

0001 #ifndef CURLINC_TYPECHECK_GCC_H
0002 #define CURLINC_TYPECHECK_GCC_H
0003 /***************************************************************************
0004  *                                  _   _ ____  _
0005  *  Project                     ___| | | |  _ \| |
0006  *                             / __| | | | |_) | |
0007  *                            | (__| |_| |  _ <| |___
0008  *                             \___|\___/|_| \_\_____|
0009  *
0010  * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
0011  *
0012  * This software is licensed as described in the file COPYING, which
0013  * you should have received as part of this distribution. The terms
0014  * are also available at https://curl.se/docs/copyright.html.
0015  *
0016  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
0017  * copies of the Software, and permit persons to whom the Software is
0018  * furnished to do so, under the terms of the COPYING file.
0019  *
0020  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
0021  * KIND, either express or implied.
0022  *
0023  * SPDX-License-Identifier: curl
0024  *
0025  ***************************************************************************/
0026 
0027 /* wraps curl_easy_setopt() with type checking */
0028 
0029 /* To add a new kind of warning, add an
0030  *   if(curlcheck_sometype_option(_curl_opt))
0031  *     if(!curlcheck_sometype(value))
0032  *       Wcurl_easy_setopt_err_sometype();
0033  * block and define curlcheck_sometype_option, curlcheck_sometype and
0034  * Wcurl_easy_setopt_err_sometype below
0035  *
0036  * NOTE: We use two nested 'if' statements here instead of the && operator, in
0037  *       order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x
0038  *       when compiling with -Wlogical-op.
0039  *
0040  * To add an option that uses the same type as an existing option, you need
0041  * to extend the appropriate _curl_*_option macro
0042  */
0043 
0044 #define curl_easy_setopt(handle, option, value)                         \
0045   __extension__({                                                       \
0046     if(__builtin_constant_p(option)) {                                  \
0047       CURL_IGNORE_DEPRECATION(                                          \
0048         if(curlcheck_long_option(option))                               \
0049           if(!curlcheck_long(value))                                    \
0050             Wcurl_easy_setopt_err_long();                               \
0051         if(curlcheck_off_t_option(option))                              \
0052           if(!curlcheck_off_t(value))                                   \
0053             Wcurl_easy_setopt_err_curl_off_t();                         \
0054         if(curlcheck_string_option(option))                             \
0055           if(!curlcheck_string(value))                                  \
0056             Wcurl_easy_setopt_err_string();                             \
0057         if((option) == CURLOPT_PRIVATE) { }                             \
0058         if(curlcheck_write_cb_option(option))                           \
0059           if(!curlcheck_write_cb(value))                                \
0060             Wcurl_easy_setopt_err_write_callback();                     \
0061         if(curlcheck_curl_option(option))                               \
0062           if(!curlcheck_curl(value))                                    \
0063             Wcurl_easy_setopt_err_curl();                               \
0064         if((option) == CURLOPT_RESOLVER_START_FUNCTION)                 \
0065           if(!curlcheck_resolver_start_callback(value))                 \
0066             Wcurl_easy_setopt_err_resolver_start_callback();            \
0067         if((option) == CURLOPT_READFUNCTION)                            \
0068           if(!curlcheck_read_cb(value))                                 \
0069             Wcurl_easy_setopt_err_read_cb();                            \
0070         if((option) == CURLOPT_IOCTLFUNCTION)                           \
0071           if(!curlcheck_ioctl_cb(value))                                \
0072             Wcurl_easy_setopt_err_ioctl_cb();                           \
0073         if((option) == CURLOPT_SOCKOPTFUNCTION)                         \
0074           if(!curlcheck_sockopt_cb(value))                              \
0075             Wcurl_easy_setopt_err_sockopt_cb();                         \
0076         if((option) == CURLOPT_OPENSOCKETFUNCTION)                      \
0077           if(!curlcheck_opensocket_cb(value))                           \
0078             Wcurl_easy_setopt_err_opensocket_cb();                      \
0079         if((option) == CURLOPT_PROGRESSFUNCTION)                        \
0080           if(!curlcheck_progress_cb(value))                             \
0081             Wcurl_easy_setopt_err_progress_cb();                        \
0082         if((option) == CURLOPT_XFERINFOFUNCTION)                        \
0083           if(!curlcheck_xferinfo_cb(value))                             \
0084             Wcurl_easy_setopt_err_xferinfo_cb();                        \
0085         if((option) == CURLOPT_DEBUGFUNCTION)                           \
0086           if(!curlcheck_debug_cb(value))                                \
0087             Wcurl_easy_setopt_err_debug_cb();                           \
0088         if((option) == CURLOPT_SSL_CTX_FUNCTION)                        \
0089           if(!curlcheck_ssl_ctx_cb(value))                              \
0090             Wcurl_easy_setopt_err_ssl_ctx_cb();                         \
0091         if(curlcheck_conv_cb_option(option))                            \
0092           if(!curlcheck_conv_cb(value))                                 \
0093             Wcurl_easy_setopt_err_conv_cb();                            \
0094         if((option) == CURLOPT_SEEKFUNCTION)                            \
0095           if(!curlcheck_seek_cb(value))                                 \
0096             Wcurl_easy_setopt_err_seek_cb();                            \
0097         if((option) == CURLOPT_CHUNK_BGN_FUNCTION)                      \
0098           if(!curlcheck_chunk_bgn_cb(value))                            \
0099             Wcurl_easy_setopt_err_chunk_bgn_cb();                       \
0100         if((option) == CURLOPT_CHUNK_END_FUNCTION)                      \
0101           if(!curlcheck_chunk_end_cb(value))                            \
0102             Wcurl_easy_setopt_err_chunk_end_cb();                       \
0103         if((option) == CURLOPT_CLOSESOCKETFUNCTION)                     \
0104           if(!curlcheck_close_socket_cb(value))                         \
0105             Wcurl_easy_setopt_err_close_socket_cb();                    \
0106         if((option) == CURLOPT_FNMATCH_FUNCTION)                        \
0107           if(!curlcheck_fnmatch_cb(value))                              \
0108             Wcurl_easy_setopt_err_fnmatch_cb();                         \
0109         if((option) == CURLOPT_HSTSREADFUNCTION)                        \
0110           if(!curlcheck_hstsread_cb(value))                             \
0111             Wcurl_easy_setopt_err_hstsread_cb();                        \
0112         if((option) == CURLOPT_HSTSWRITEFUNCTION)                       \
0113           if(!curlcheck_hstswrite_cb(value))                            \
0114             Wcurl_easy_setopt_err_hstswrite_cb();                       \
0115         if((option) == CURLOPT_SSH_HOSTKEYFUNCTION)                     \
0116           if(!curlcheck_ssh_hostkey_cb(value))                          \
0117             Wcurl_easy_setopt_err_ssh_hostkey_cb();                     \
0118         if((option) == CURLOPT_SSH_KEYFUNCTION)                         \
0119           if(!curlcheck_ssh_key_cb(value))                              \
0120             Wcurl_easy_setopt_err_ssh_key_cb();                         \
0121         if((option) == CURLOPT_INTERLEAVEFUNCTION)                      \
0122           if(!curlcheck_interleave_cb(value))                           \
0123             Wcurl_easy_setopt_err_interleave_cb();                      \
0124         if((option) == CURLOPT_PREREQFUNCTION)                          \
0125           if(!curlcheck_prereq_cb(value))                               \
0126             Wcurl_easy_setopt_err_prereq_cb();                          \
0127         if((option) == CURLOPT_TRAILERFUNCTION)                         \
0128           if(!curlcheck_trailer_cb(value))                              \
0129             Wcurl_easy_setopt_err_trailer_cb();                         \
0130         if(curlcheck_cb_data_option(option))                            \
0131           if(!curlcheck_cb_data(value))                                 \
0132             Wcurl_easy_setopt_err_cb_data();                            \
0133         if((option) == CURLOPT_ERRORBUFFER)                             \
0134           if(!curlcheck_error_buffer(value))                            \
0135             Wcurl_easy_setopt_err_error_buffer();                       \
0136         if((option) == CURLOPT_CURLU)                                   \
0137           if(!curlcheck_ptr((value), CURLU))                            \
0138             Wcurl_easy_setopt_err_curlu();                              \
0139         if((option) == CURLOPT_STDERR)                                  \
0140           if(!curlcheck_FILE(value))                                    \
0141             Wcurl_easy_setopt_err_FILE();                               \
0142         if(curlcheck_postfields_option(option))                         \
0143           if(!curlcheck_postfields(value))                              \
0144             Wcurl_easy_setopt_err_postfields();                         \
0145         if((option) == CURLOPT_HTTPPOST)                                \
0146           if(!curlcheck_arr((value), struct curl_httppost))             \
0147             Wcurl_easy_setopt_err_curl_httpost();                       \
0148         if((option) == CURLOPT_MIMEPOST)                                \
0149           if(!curlcheck_ptr((value), curl_mime))                        \
0150             Wcurl_easy_setopt_err_curl_mimepost();                      \
0151         if(curlcheck_slist_option(option))                              \
0152           if(!curlcheck_arr((value), struct curl_slist))                \
0153             Wcurl_easy_setopt_err_curl_slist();                         \
0154         if((option) == CURLOPT_SHARE)                                   \
0155           if(!curlcheck_ptr((value), CURLSH))                           \
0156             Wcurl_easy_setopt_err_CURLSH();                             \
0157       )                                                                 \
0158     }                                                                   \
0159     (curl_easy_setopt)(handle, option, value);                          \
0160   })
0161 
0162 /* wraps curl_easy_getinfo() with type checking */
0163 #define curl_easy_getinfo(handle, info, arg)                            \
0164   __extension__({                                                       \
0165     if(__builtin_constant_p(info)) {                                    \
0166       CURL_IGNORE_DEPRECATION(                                          \
0167         if(curlcheck_string_info(info))                                 \
0168           if(!curlcheck_arr((arg), char *))                             \
0169             Wcurl_easy_getinfo_err_string();                            \
0170         if(curlcheck_long_info(info))                                   \
0171           if(!curlcheck_arr((arg), long))                               \
0172             Wcurl_easy_getinfo_err_long();                              \
0173         if(curlcheck_double_info(info))                                 \
0174           if(!curlcheck_arr((arg), double))                             \
0175             Wcurl_easy_getinfo_err_double();                            \
0176         if(curlcheck_slist_info(info))                                  \
0177           if(!curlcheck_arr((arg), struct curl_slist *))                \
0178             Wcurl_easy_getinfo_err_curl_slist();                        \
0179         if(curlcheck_tlssessioninfo_info(info))                         \
0180           if(!curlcheck_arr((arg), struct curl_tlssessioninfo *))       \
0181             Wcurl_easy_getinfo_err_curl_tlssessioninfo();               \
0182         if(curlcheck_certinfo_info(info))                               \
0183           if(!curlcheck_arr((arg), struct curl_certinfo *))             \
0184             Wcurl_easy_getinfo_err_curl_certinfo();                     \
0185         if(curlcheck_socket_info(info))                                 \
0186           if(!curlcheck_arr((arg), curl_socket_t))                      \
0187             Wcurl_easy_getinfo_err_curl_socket();                       \
0188         if(curlcheck_off_t_info(info))                                  \
0189           if(!curlcheck_arr((arg), curl_off_t))                         \
0190             Wcurl_easy_getinfo_err_curl_off_t();                        \
0191       )                                                                 \
0192     }                                                                   \
0193     (curl_easy_getinfo)(handle, info, arg);                             \
0194   })
0195 
0196 #define curl_multi_setopt(handle, option, value)                        \
0197   __extension__({                                                       \
0198     if(__builtin_constant_p(option)) {                                  \
0199       if(curlcheck_long_option(option))                                 \
0200         if(!curlcheck_long(value))                                      \
0201           Wcurl_multi_setopt_err_long();                                \
0202       if(curlcheck_off_t_option(option))                                \
0203         if(!curlcheck_off_t(value))                                     \
0204           Wcurl_multi_setopt_err_curl_off_t();                          \
0205       if(curlcheck_multicb_data_option(option))                         \
0206         if(!curlcheck_cb_data(value))                                   \
0207           Wcurl_multi_setopt_err_cb_data();                             \
0208       if(curlcheck_charpp_option(option))                               \
0209         if(!curlcheck_ptrptr(value, char))                              \
0210           Wcurl_multi_setopt_err_charpp();                              \
0211       if((option) == CURLMOPT_NOTIFYFUNCTION)                           \
0212         if(!curlcheck_multinotify_cb(value))                            \
0213           Wcurl_multi_setopt_err_notifycb();                            \
0214       if((option) == CURLMOPT_PUSHFUNCTION)                             \
0215         if(!curlcheck_multipush_cb(value))                              \
0216           Wcurl_multi_setopt_err_pushcb();                              \
0217       if((option) == CURLMOPT_SOCKETFUNCTION)                           \
0218         if(!curlcheck_multisocket_cb(value))                            \
0219           Wcurl_multi_setopt_err_socketcb();                            \
0220       if((option) == CURLMOPT_TIMERFUNCTION)                            \
0221         if(!curlcheck_multitimer_cb(value))                             \
0222           Wcurl_multi_setopt_err_timercb();                             \
0223     }                                                                   \
0224     (curl_multi_setopt)(handle, option, value);                         \
0225   })
0226 
0227 /* evaluates to true if the option takes a data argument to pass to a
0228    callback */
0229 #define curlcheck_multicb_data_option(option)                           \
0230   ((option) == CURLMOPT_NOTIFYDATA ||                                   \
0231    (option) == CURLMOPT_PUSHDATA ||                                     \
0232    (option) == CURLMOPT_SOCKETDATA ||                                   \
0233    (option) == CURLMOPT_TIMERDATA ||                                    \
0234    0)
0235 
0236 /* evaluates to true if the option takes a char ** argument */
0237 #define curlcheck_charpp_option(option)                                 \
0238   ((option) == CURLMOPT_PIPELINING_SERVER_BL ||                         \
0239    (option) == CURLMOPT_PIPELINING_SITE_BL ||                           \
0240    0)
0241 
0242 /* evaluates to true if expr is of type curl_multi_timer_callback */
0243 #define curlcheck_multitimer_cb(expr)                                   \
0244   (curlcheck_NULL(expr) ||                                              \
0245    curlcheck_cb_compatible((expr), curl_multi_timer_callback))
0246 
0247 /* evaluates to true if expr is of type curl_socket_callback */
0248 #define curlcheck_multisocket_cb(expr)                                  \
0249   (curlcheck_NULL(expr) ||                                              \
0250    curlcheck_cb_compatible((expr), curl_socket_callback))
0251 
0252 /* evaluates to true if expr is of type curl_push_callback */
0253 #define curlcheck_multipush_cb(expr)                                    \
0254   (curlcheck_NULL(expr) ||                                              \
0255    curlcheck_cb_compatible((expr), curl_push_callback))
0256 
0257 /* evaluates to true if expr is of type curl_push_callback */
0258 #define curlcheck_multinotify_cb(expr)                                  \
0259   (curlcheck_NULL(expr) ||                                              \
0260    curlcheck_cb_compatible((expr), curl_notify_callback))
0261 
0262 /*
0263  * Make sure that the functions are called with three arguments
0264  */
0265 #define curl_share_setopt(share, opt, param) \
0266   (curl_share_setopt)(share, opt, param)
0267 
0268 /* the actual warnings, triggered by calling the Wcurl_easy_setopt_err*
0269  * functions */
0270 
0271 /* To define a new warning, use _CURL_WARNING(identifier, "message") */
0272 #define CURLWARNING(id, message)                                        \
0273   static void __attribute__((__warning__(message)))                     \
0274   __attribute__((__unused__)) __attribute__((__noinline__))             \
0275   id(void) { __asm__(""); }
0276 
0277 CURLWARNING(Wcurl_multi_setopt_err_long,
0278             "curl_multi_setopt expects a long argument")
0279 CURLWARNING(Wcurl_multi_setopt_err_curl_off_t,
0280             "curl_multi_setopt expects a curl_off_t argument")
0281 CURLWARNING(Wcurl_multi_setopt_err_cb_data,
0282             "curl_multi_setopt expects a 'void *' argument")
0283 CURLWARNING(Wcurl_multi_setopt_err_charpp,
0284             "curl_multi_setopt expects a 'char **' argument")
0285 CURLWARNING(Wcurl_multi_setopt_err_pushcb,
0286             "curl_multi_setopt expects a curl_push_callback argument")
0287 CURLWARNING(Wcurl_multi_setopt_err_notifycb,
0288             "curl_multi_setopt expects a curl_notify_callback argument")
0289 CURLWARNING(Wcurl_multi_setopt_err_socketcb,
0290             "curl_multi_setopt expects a curl_socket_callback argument")
0291 CURLWARNING(Wcurl_multi_setopt_err_timercb,
0292             "curl_multi_setopt expects a curl_multi_timer_callback argument")
0293 
0294 CURLWARNING(Wcurl_easy_setopt_err_long,
0295             "curl_easy_setopt expects a long argument")
0296 CURLWARNING(Wcurl_easy_setopt_err_curl_off_t,
0297             "curl_easy_setopt expects a curl_off_t argument")
0298 CURLWARNING(Wcurl_easy_setopt_err_string,
0299             "curl_easy_setopt expects a "
0300             "string ('char *' or char[]) argument")
0301 CURLWARNING(Wcurl_easy_setopt_err_write_callback,
0302             "curl_easy_setopt expects a curl_write_callback argument")
0303 CURLWARNING(Wcurl_easy_setopt_err_resolver_start_callback,
0304             "curl_easy_setopt expects a "
0305             "curl_resolver_start_callback argument")
0306 CURLWARNING(Wcurl_easy_setopt_err_read_cb,
0307             "curl_easy_setopt expects a curl_read_callback argument")
0308 CURLWARNING(Wcurl_easy_setopt_err_ioctl_cb,
0309             "curl_easy_setopt expects a curl_ioctl_callback argument")
0310 CURLWARNING(Wcurl_easy_setopt_err_sockopt_cb,
0311             "curl_easy_setopt expects a curl_sockopt_callback argument")
0312 CURLWARNING(Wcurl_easy_setopt_err_opensocket_cb,
0313             "curl_easy_setopt expects a "
0314             "curl_opensocket_callback argument")
0315 CURLWARNING(Wcurl_easy_setopt_err_progress_cb,
0316             "curl_easy_setopt expects a curl_progress_callback argument")
0317 CURLWARNING(Wcurl_easy_setopt_err_xferinfo_cb,
0318             "curl_easy_setopt expects a curl_xferinfo_callback argument")
0319 CURLWARNING(Wcurl_easy_setopt_err_debug_cb,
0320             "curl_easy_setopt expects a curl_debug_callback argument")
0321 CURLWARNING(Wcurl_easy_setopt_err_ssl_ctx_cb,
0322             "curl_easy_setopt expects a curl_ssl_ctx_callback argument")
0323 CURLWARNING(Wcurl_easy_setopt_err_conv_cb,
0324             "curl_easy_setopt expects a curl_conv_callback argument")
0325 CURLWARNING(Wcurl_easy_setopt_err_seek_cb,
0326             "curl_easy_setopt expects a curl_seek_callback argument")
0327 CURLWARNING(Wcurl_easy_setopt_err_cb_data,
0328             "curl_easy_setopt expects a "
0329             "private data pointer as argument")
0330 CURLWARNING(Wcurl_easy_setopt_err_chunk_bgn_cb,
0331             "curl_easy_setopt expects a curl_chunk_bgn_callback argument")
0332 CURLWARNING(Wcurl_easy_setopt_err_chunk_end_cb,
0333             "curl_easy_setopt expects a curl_chunk_end_callback argument")
0334 CURLWARNING(Wcurl_easy_setopt_err_close_socket_cb,
0335             "curl_easy_setopt expects a curl_closesocket_callback argument")
0336 CURLWARNING(Wcurl_easy_setopt_err_fnmatch_cb,
0337             "curl_easy_setopt expects a curl_fnmatch_callback argument")
0338 CURLWARNING(Wcurl_easy_setopt_err_hstsread_cb,
0339             "curl_easy_setopt expects a curl_hstsread_callback argument")
0340 CURLWARNING(Wcurl_easy_setopt_err_hstswrite_cb,
0341             "curl_easy_setopt expects a curl_hstswrite_callback argument")
0342 CURLWARNING(Wcurl_easy_setopt_err_ssh_key_cb,
0343             "curl_easy_setopt expects a curl_sshkeycallback argument")
0344 CURLWARNING(Wcurl_easy_setopt_err_ssh_hostkey_cb,
0345             "curl_easy_setopt expects a curl_sshhostkeycallback argument")
0346 CURLWARNING(Wcurl_easy_setopt_err_interleave_cb,
0347             "curl_easy_setopt expects a curl_interleave_callback argument")
0348 CURLWARNING(Wcurl_easy_setopt_err_prereq_cb,
0349             "curl_easy_setopt expects a curl_prereq_callback argument")
0350 CURLWARNING(Wcurl_easy_setopt_err_trailer_cb,
0351             "curl_easy_setopt expects a curl_trailerfunc_ok argument")
0352 CURLWARNING(Wcurl_easy_setopt_err_error_buffer,
0353             "curl_easy_setopt expects a "
0354             "char buffer of CURL_ERROR_SIZE as argument")
0355 CURLWARNING(Wcurl_easy_setopt_err_curlu,
0356             "curl_easy_setopt expects a 'CURLU *' argument")
0357 CURLWARNING(Wcurl_easy_setopt_err_curl,
0358             "curl_easy_setopt expects a 'CURL *' argument")
0359 CURLWARNING(Wcurl_easy_setopt_err_FILE,
0360             "curl_easy_setopt expects a 'FILE *' argument")
0361 CURLWARNING(Wcurl_easy_setopt_err_postfields,
0362             "curl_easy_setopt expects a 'void *' or 'char *' argument")
0363 CURLWARNING(Wcurl_easy_setopt_err_curl_httpost,
0364             "curl_easy_setopt expects a 'struct curl_httppost *' "
0365             "argument")
0366 CURLWARNING(Wcurl_easy_setopt_err_curl_mimepost,
0367             "curl_easy_setopt expects a 'curl_mime *' "
0368             "argument")
0369 CURLWARNING(Wcurl_easy_setopt_err_curl_slist,
0370             "curl_easy_setopt expects a 'struct curl_slist *' argument")
0371 CURLWARNING(Wcurl_easy_setopt_err_CURLSH,
0372             "curl_easy_setopt expects a CURLSH* argument")
0373 CURLWARNING(Wcurl_easy_getinfo_err_string,
0374             "curl_easy_getinfo expects a pointer to 'char *'")
0375 CURLWARNING(Wcurl_easy_getinfo_err_long,
0376             "curl_easy_getinfo expects a pointer to long")
0377 CURLWARNING(Wcurl_easy_getinfo_err_double,
0378             "curl_easy_getinfo expects a pointer to double")
0379 CURLWARNING(Wcurl_easy_getinfo_err_curl_slist,
0380             "curl_easy_getinfo expects a pointer to 'struct curl_slist *'")
0381 CURLWARNING(Wcurl_easy_getinfo_err_curl_tlssessioninfo,
0382             "curl_easy_getinfo expects a pointer to "
0383             "'struct curl_tlssessioninfo *'")
0384 CURLWARNING(Wcurl_easy_getinfo_err_curl_certinfo,
0385             "curl_easy_getinfo expects a pointer to "
0386             "'struct curl_certinfo *'")
0387 CURLWARNING(Wcurl_easy_getinfo_err_curl_socket,
0388             "curl_easy_getinfo expects a pointer to curl_socket_t")
0389 CURLWARNING(Wcurl_easy_getinfo_err_curl_off_t,
0390             "curl_easy_getinfo expects a pointer to curl_off_t")
0391 
0392 /* groups of curl_easy_setops options that take the same type of argument */
0393 
0394 /* evaluates to true if option takes a long argument */
0395 #define curlcheck_long_option(option)                                   \
0396   (0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
0397 
0398 #define curlcheck_off_t_option(option)                                  \
0399   (((option) > CURLOPTTYPE_OFF_T) && ((option) < CURLOPTTYPE_BLOB))
0400 
0401 /* option takes a CURL * argument */
0402 #define curlcheck_curl_option(option)                                   \
0403   ((option) == CURLOPT_STREAM_DEPENDS ||                                \
0404    (option) == CURLOPT_STREAM_DEPENDS_E ||                              \
0405    0)
0406 
0407 /* evaluates to true if option takes a char* argument */
0408 #define curlcheck_string_option(option)                                 \
0409   ((option) == CURLOPT_ABSTRACT_UNIX_SOCKET ||                          \
0410    (option) == CURLOPT_ACCEPT_ENCODING ||                               \
0411    (option) == CURLOPT_ALTSVC ||                                        \
0412    (option) == CURLOPT_CAINFO ||                                        \
0413    (option) == CURLOPT_CAPATH ||                                        \
0414    (option) == CURLOPT_COOKIE ||                                        \
0415    (option) == CURLOPT_COOKIEFILE ||                                    \
0416    (option) == CURLOPT_COOKIEJAR ||                                     \
0417    (option) == CURLOPT_COOKIELIST ||                                    \
0418    (option) == CURLOPT_CRLFILE ||                                       \
0419    (option) == CURLOPT_CUSTOMREQUEST ||                                 \
0420    (option) == CURLOPT_DEFAULT_PROTOCOL ||                              \
0421    (option) == CURLOPT_DNS_INTERFACE ||                                 \
0422    (option) == CURLOPT_DNS_LOCAL_IP4 ||                                 \
0423    (option) == CURLOPT_DNS_LOCAL_IP6 ||                                 \
0424    (option) == CURLOPT_DNS_SERVERS ||                                   \
0425    (option) == CURLOPT_DOH_URL ||                                       \
0426    (option) == CURLOPT_ECH ||                                           \
0427    (option) == CURLOPT_EGDSOCKET ||                                     \
0428    (option) == CURLOPT_FTP_ACCOUNT ||                                   \
0429    (option) == CURLOPT_FTP_ALTERNATIVE_TO_USER ||                       \
0430    (option) == CURLOPT_FTPPORT ||                                       \
0431    (option) == CURLOPT_HAPROXY_CLIENT_IP ||                             \
0432    (option) == CURLOPT_HSTS ||                                          \
0433    (option) == CURLOPT_INTERFACE ||                                     \
0434    (option) == CURLOPT_ISSUERCERT ||                                    \
0435    (option) == CURLOPT_KEYPASSWD ||                                     \
0436    (option) == CURLOPT_KRBLEVEL ||                                      \
0437    (option) == CURLOPT_LOGIN_OPTIONS ||                                 \
0438    (option) == CURLOPT_MAIL_AUTH ||                                     \
0439    (option) == CURLOPT_MAIL_FROM ||                                     \
0440    (option) == CURLOPT_NETRC_FILE ||                                    \
0441    (option) == CURLOPT_NOPROXY ||                                       \
0442    (option) == CURLOPT_PASSWORD ||                                      \
0443    (option) == CURLOPT_PINNEDPUBLICKEY ||                               \
0444    (option) == CURLOPT_PRE_PROXY ||                                     \
0445    (option) == CURLOPT_PROTOCOLS_STR ||                                 \
0446    (option) == CURLOPT_PROXY ||                                         \
0447    (option) == CURLOPT_PROXY_CAINFO ||                                  \
0448    (option) == CURLOPT_PROXY_CAPATH ||                                  \
0449    (option) == CURLOPT_PROXY_CRLFILE ||                                 \
0450    (option) == CURLOPT_PROXY_ISSUERCERT ||                              \
0451    (option) == CURLOPT_PROXY_KEYPASSWD ||                               \
0452    (option) == CURLOPT_PROXY_PINNEDPUBLICKEY ||                         \
0453    (option) == CURLOPT_PROXY_SERVICE_NAME ||                            \
0454    (option) == CURLOPT_PROXY_SSL_CIPHER_LIST ||                         \
0455    (option) == CURLOPT_PROXY_SSLCERT ||                                 \
0456    (option) == CURLOPT_PROXY_SSLCERTTYPE ||                             \
0457    (option) == CURLOPT_PROXY_SSLKEY ||                                  \
0458    (option) == CURLOPT_PROXY_SSLKEYTYPE ||                              \
0459    (option) == CURLOPT_PROXY_TLS13_CIPHERS ||                           \
0460    (option) == CURLOPT_PROXY_TLSAUTH_PASSWORD ||                        \
0461    (option) == CURLOPT_PROXY_TLSAUTH_TYPE ||                            \
0462    (option) == CURLOPT_PROXY_TLSAUTH_USERNAME ||                        \
0463    (option) == CURLOPT_PROXYPASSWORD ||                                 \
0464    (option) == CURLOPT_PROXYUSERNAME ||                                 \
0465    (option) == CURLOPT_PROXYUSERPWD ||                                  \
0466    (option) == CURLOPT_RANDOM_FILE ||                                   \
0467    (option) == CURLOPT_RANGE ||                                         \
0468    (option) == CURLOPT_REDIR_PROTOCOLS_STR ||                           \
0469    (option) == CURLOPT_REFERER ||                                       \
0470    (option) == CURLOPT_REQUEST_TARGET ||                                \
0471    (option) == CURLOPT_RTSP_SESSION_ID ||                               \
0472    (option) == CURLOPT_RTSP_STREAM_URI ||                               \
0473    (option) == CURLOPT_RTSP_TRANSPORT ||                                \
0474    (option) == CURLOPT_SASL_AUTHZID ||                                  \
0475    (option) == CURLOPT_SERVICE_NAME ||                                  \
0476    (option) == CURLOPT_SOCKS5_GSSAPI_SERVICE ||                         \
0477    (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 ||                       \
0478    (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 ||                    \
0479    (option) == CURLOPT_SSH_KNOWNHOSTS ||                                \
0480    (option) == CURLOPT_SSH_PRIVATE_KEYFILE ||                           \
0481    (option) == CURLOPT_SSH_PUBLIC_KEYFILE ||                            \
0482    (option) == CURLOPT_SSLCERT ||                                       \
0483    (option) == CURLOPT_SSLCERTTYPE ||                                   \
0484    (option) == CURLOPT_SSLENGINE ||                                     \
0485    (option) == CURLOPT_SSLKEY ||                                        \
0486    (option) == CURLOPT_SSLKEYTYPE ||                                    \
0487    (option) == CURLOPT_SSL_CIPHER_LIST ||                               \
0488    (option) == CURLOPT_SSL_EC_CURVES ||                                 \
0489    (option) == CURLOPT_SSL_SIGNATURE_ALGORITHMS ||                      \
0490    (option) == CURLOPT_TLS13_CIPHERS ||                                 \
0491    (option) == CURLOPT_TLSAUTH_PASSWORD ||                              \
0492    (option) == CURLOPT_TLSAUTH_TYPE ||                                  \
0493    (option) == CURLOPT_TLSAUTH_USERNAME ||                              \
0494    (option) == CURLOPT_UNIX_SOCKET_PATH ||                              \
0495    (option) == CURLOPT_URL ||                                           \
0496    (option) == CURLOPT_USERAGENT ||                                     \
0497    (option) == CURLOPT_USERNAME ||                                      \
0498    (option) == CURLOPT_AWS_SIGV4 ||                                     \
0499    (option) == CURLOPT_USERPWD ||                                       \
0500    (option) == CURLOPT_XOAUTH2_BEARER ||                                \
0501    0)
0502 
0503 /* evaluates to true if option takes a curl_write_callback argument */
0504 #define curlcheck_write_cb_option(option)                               \
0505   ((option) == CURLOPT_HEADERFUNCTION ||                                \
0506    (option) == CURLOPT_WRITEFUNCTION)
0507 
0508 /* evaluates to true if option takes a curl_conv_callback argument */
0509 #define curlcheck_conv_cb_option(option)                                \
0510   ((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION ||                      \
0511    (option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION ||                    \
0512    (option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)
0513 
0514 /* evaluates to true if option takes a data argument to pass to a callback */
0515 #define curlcheck_cb_data_option(option)                                \
0516   ((option) == CURLOPT_CHUNK_DATA ||                                    \
0517    (option) == CURLOPT_CLOSESOCKETDATA ||                               \
0518    (option) == CURLOPT_DEBUGDATA ||                                     \
0519    (option) == CURLOPT_FNMATCH_DATA ||                                  \
0520    (option) == CURLOPT_HEADERDATA ||                                    \
0521    (option) == CURLOPT_HSTSREADDATA ||                                  \
0522    (option) == CURLOPT_HSTSWRITEDATA ||                                 \
0523    (option) == CURLOPT_INTERLEAVEDATA ||                                \
0524    (option) == CURLOPT_IOCTLDATA ||                                     \
0525    (option) == CURLOPT_OPENSOCKETDATA ||                                \
0526    (option) == CURLOPT_PREREQDATA ||                                    \
0527    (option) == CURLOPT_XFERINFODATA ||                                  \
0528    (option) == CURLOPT_READDATA ||                                      \
0529    (option) == CURLOPT_SEEKDATA ||                                      \
0530    (option) == CURLOPT_SOCKOPTDATA ||                                   \
0531    (option) == CURLOPT_SSH_KEYDATA ||                                   \
0532    (option) == CURLOPT_SSL_CTX_DATA ||                                  \
0533    (option) == CURLOPT_WRITEDATA ||                                     \
0534    (option) == CURLOPT_RESOLVER_START_DATA ||                           \
0535    (option) == CURLOPT_TRAILERDATA ||                                   \
0536    (option) == CURLOPT_SSH_HOSTKEYDATA ||                               \
0537    0)
0538 
0539 /* evaluates to true if option takes a POST data argument (void* or char*) */
0540 #define curlcheck_postfields_option(option)                             \
0541   ((option) == CURLOPT_POSTFIELDS ||                                    \
0542    (option) == CURLOPT_COPYPOSTFIELDS ||                                \
0543    0)
0544 
0545 /* evaluates to true if option takes a struct curl_slist * argument */
0546 #define curlcheck_slist_option(option)                                  \
0547   ((option) == CURLOPT_HTTP200ALIASES ||                                \
0548    (option) == CURLOPT_HTTPHEADER ||                                    \
0549    (option) == CURLOPT_MAIL_RCPT ||                                     \
0550    (option) == CURLOPT_POSTQUOTE ||                                     \
0551    (option) == CURLOPT_PREQUOTE ||                                      \
0552    (option) == CURLOPT_PROXYHEADER ||                                   \
0553    (option) == CURLOPT_QUOTE ||                                         \
0554    (option) == CURLOPT_RESOLVE ||                                       \
0555    (option) == CURLOPT_TELNETOPTIONS ||                                 \
0556    (option) == CURLOPT_CONNECT_TO ||                                    \
0557    0)
0558 
0559 /* groups of curl_easy_getinfo infos that take the same type of argument */
0560 
0561 /* evaluates to true if info expects a pointer to char * argument */
0562 #define curlcheck_string_info(info)                                     \
0563   (CURLINFO_STRING < (info) && (info) < CURLINFO_LONG &&                \
0564    (info) != CURLINFO_PRIVATE)
0565 
0566 /* evaluates to true if info expects a pointer to long argument */
0567 #define curlcheck_long_info(info)                                       \
0568   (CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)
0569 
0570 /* evaluates to true if info expects a pointer to double argument */
0571 #define curlcheck_double_info(info)                                     \
0572   (CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)
0573 
0574 /* true if info expects a pointer to struct curl_slist * argument */
0575 #define curlcheck_slist_info(info)                                      \
0576   (((info) == CURLINFO_SSL_ENGINES) ||                                  \
0577    ((info) == CURLINFO_COOKIELIST))
0578 
0579 /* true if info expects a pointer to struct curl_tlssessioninfo * argument */
0580 #define curlcheck_tlssessioninfo_info(info)                             \
0581   (((info) == CURLINFO_TLS_SSL_PTR) ||                                  \
0582    ((info) == CURLINFO_TLS_SESSION))
0583 
0584 /* true if info expects a pointer to struct curl_certinfo * argument */
0585 #define curlcheck_certinfo_info(info) ((info) == CURLINFO_CERTINFO)
0586 
0587 /* true if info expects a pointer to struct curl_socket_t argument */
0588 #define curlcheck_socket_info(info)                                     \
0589   (CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T)
0590 
0591 /* true if info expects a pointer to curl_off_t argument */
0592 #define curlcheck_off_t_info(info)                                      \
0593   (CURLINFO_OFF_T < (info))
0594 
0595 /*
0596  * typecheck helpers -- check whether given expression has requested type
0597  */
0598 
0599 /* For pointers, you can use the curlcheck_ptr/curlcheck_arr macros,
0600  * otherwise define a new macro. Search for __builtin_types_compatible_p
0601  * in the GCC manual.
0602  * NOTE: these macros MUST NOT EVALUATE their arguments! The argument is
0603  * the actual expression passed to the curl_easy_setopt macro. This
0604  * means that you can only apply the sizeof and __typeof__ operators, no
0605  * == or whatsoever.
0606  */
0607 
0608 /* XXX: should evaluate to true if expr is a pointer */
0609 #define curlcheck_any_ptr(expr)                                         \
0610   (sizeof(expr) == sizeof(void *))
0611 
0612 /* evaluates to true if expr is NULL */
0613 /* XXX: must not evaluate expr, so this check is not accurate */
0614 #define curlcheck_NULL(expr)                                            \
0615   (__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))
0616 
0617 /* evaluates to true if expr is type*, const type* or NULL */
0618 #define curlcheck_ptr(expr, type)                                       \
0619   (curlcheck_NULL(expr) ||                                              \
0620    __builtin_types_compatible_p(__typeof__(expr), type *) ||            \
0621    __builtin_types_compatible_p(__typeof__(expr), const type *))
0622 
0623 /* evaluates to true if expr is type**, const type** or NULL */
0624 #define curlcheck_ptrptr(expr, type)                                    \
0625   (curlcheck_NULL(expr) ||                                              \
0626    __builtin_types_compatible_p(__typeof__(expr), type **) ||           \
0627    __builtin_types_compatible_p(__typeof__(expr), type *[]) ||          \
0628    __builtin_types_compatible_p(__typeof__(expr), const type *[]) ||    \
0629    __builtin_types_compatible_p(__typeof__(expr), const type **))
0630 
0631 /* evaluates to true if expr is one of type[], type*, NULL or const type* */
0632 #define curlcheck_arr(expr, type)                                       \
0633   (curlcheck_ptr((expr), type) ||                                       \
0634    __builtin_types_compatible_p(__typeof__(expr), type []))
0635 
0636 /* evaluates to true if expr is a string */
0637 #define curlcheck_string(expr)                                          \
0638   (curlcheck_arr((expr), char) ||                                       \
0639    curlcheck_arr((expr), signed char) ||                                \
0640    curlcheck_arr((expr), unsigned char))
0641 
0642 /* evaluates to true if expr is a CURL * */
0643 #define curlcheck_curl(expr)                                            \
0644   (curlcheck_NULL(expr) ||                                              \
0645    __builtin_types_compatible_p(__typeof__(expr), CURL *))
0646 
0647 /* evaluates to true if expr is a long (no matter the signedness)
0648  * XXX: for now, int is also accepted (and therefore short and char, which
0649  * are promoted to int when passed to a variadic function) */
0650 #define curlcheck_long(expr)                                            \
0651   (                                                                     \
0652   ((sizeof(long) != sizeof(int)) &&                                     \
0653    (__builtin_types_compatible_p(__typeof__(expr), long) ||             \
0654     __builtin_types_compatible_p(__typeof__(expr), signed long) ||      \
0655     __builtin_types_compatible_p(__typeof__(expr), unsigned long)))     \
0656   ||                                                                    \
0657   ((sizeof(long) == sizeof(int)) &&                                     \
0658   (__builtin_types_compatible_p(__typeof__(expr), long) ||              \
0659    __builtin_types_compatible_p(__typeof__(expr), signed long) ||       \
0660    __builtin_types_compatible_p(__typeof__(expr), unsigned long) ||     \
0661    __builtin_types_compatible_p(__typeof__(expr), int) ||               \
0662    __builtin_types_compatible_p(__typeof__(expr), signed int) ||        \
0663    __builtin_types_compatible_p(__typeof__(expr), unsigned int) ||      \
0664    __builtin_types_compatible_p(__typeof__(expr), short) ||             \
0665    __builtin_types_compatible_p(__typeof__(expr), signed short) ||      \
0666    __builtin_types_compatible_p(__typeof__(expr), unsigned short) ||    \
0667    __builtin_types_compatible_p(__typeof__(expr), char) ||              \
0668    __builtin_types_compatible_p(__typeof__(expr), signed char) ||       \
0669    __builtin_types_compatible_p(__typeof__(expr), unsigned char)))      \
0670                                                                   )
0671 
0672 /* evaluates to true if expr is of type curl_off_t */
0673 #define curlcheck_off_t(expr)                                           \
0674   (__builtin_types_compatible_p(__typeof__(expr), curl_off_t))
0675 
0676 /* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
0677 /* XXX: also check size of an char[] array? */
0678 #define curlcheck_error_buffer(expr)                                    \
0679   (curlcheck_NULL(expr) ||                                              \
0680    __builtin_types_compatible_p(__typeof__(expr), char *) ||            \
0681    __builtin_types_compatible_p(__typeof__(expr), char[]))
0682 
0683 /* evaluates to true if expr is of type (const) void* or (const) FILE* */
0684 #if 0
0685 #define curlcheck_cb_data(expr)                                         \
0686   (curlcheck_ptr((expr), void) ||                                       \
0687    curlcheck_ptr((expr), FILE))
0688 #else /* be less strict */
0689 #define curlcheck_cb_data(expr)                                         \
0690   curlcheck_any_ptr(expr)
0691 #endif
0692 
0693 /* evaluates to true if expr is of type FILE* */
0694 #define curlcheck_FILE(expr)                                            \
0695   (curlcheck_NULL(expr) ||                                              \
0696    (__builtin_types_compatible_p(__typeof__(expr), FILE *)))
0697 
0698 /* evaluates to true if expr can be passed as POST data (void* or char*) */
0699 #define curlcheck_postfields(expr)                                      \
0700   (curlcheck_ptr((expr), void) ||                                       \
0701    curlcheck_arr((expr), char) ||                                       \
0702    curlcheck_arr((expr), unsigned char))
0703 
0704 /* helper: __builtin_types_compatible_p distinguishes between functions and
0705  * function pointers, hide it */
0706 #define curlcheck_cb_compatible(func, type)                             \
0707   (__builtin_types_compatible_p(__typeof__(func), type) ||              \
0708    __builtin_types_compatible_p(__typeof__(func) *, type))
0709 
0710 /* evaluates to true if expr is of type curl_resolver_start_callback */
0711 #define curlcheck_resolver_start_callback(expr)                         \
0712   (curlcheck_NULL(expr) ||                                              \
0713    curlcheck_cb_compatible((expr), curl_resolver_start_callback))
0714 
0715 /* evaluates to true if expr is of type curl_read_callback or "similar" */
0716 #define curlcheck_read_cb(expr)                                         \
0717   (curlcheck_NULL(expr) ||                                              \
0718    curlcheck_cb_compatible((expr), __typeof__(fread) *) ||              \
0719    curlcheck_cb_compatible((expr), curl_read_callback) ||               \
0720    curlcheck_cb_compatible((expr), Wcurl_read_callback1) ||             \
0721    curlcheck_cb_compatible((expr), Wcurl_read_callback2) ||             \
0722    curlcheck_cb_compatible((expr), Wcurl_read_callback3) ||             \
0723    curlcheck_cb_compatible((expr), Wcurl_read_callback4) ||             \
0724    curlcheck_cb_compatible((expr), Wcurl_read_callback5) ||             \
0725    curlcheck_cb_compatible((expr), Wcurl_read_callback6))
0726 typedef size_t (*Wcurl_read_callback1)(char *, size_t, size_t, void *);
0727 typedef size_t (*Wcurl_read_callback2)(char *, size_t, size_t, const void *);
0728 typedef size_t (*Wcurl_read_callback3)(char *, size_t, size_t, FILE *);
0729 typedef size_t (*Wcurl_read_callback4)(void *, size_t, size_t, void *);
0730 typedef size_t (*Wcurl_read_callback5)(void *, size_t, size_t, const void *);
0731 typedef size_t (*Wcurl_read_callback6)(void *, size_t, size_t, FILE *);
0732 
0733 /* evaluates to true if expr is of type curl_write_callback or "similar" */
0734 #define curlcheck_write_cb(expr)                                        \
0735   (curlcheck_read_cb(expr) ||                                           \
0736    curlcheck_cb_compatible((expr), __typeof__(fwrite) *) ||             \
0737    curlcheck_cb_compatible((expr), curl_write_callback) ||              \
0738    curlcheck_cb_compatible((expr), Wcurl_write_callback1) ||            \
0739    curlcheck_cb_compatible((expr), Wcurl_write_callback2) ||            \
0740    curlcheck_cb_compatible((expr), Wcurl_write_callback3) ||            \
0741    curlcheck_cb_compatible((expr), Wcurl_write_callback4) ||            \
0742    curlcheck_cb_compatible((expr), Wcurl_write_callback5) ||            \
0743    curlcheck_cb_compatible((expr), Wcurl_write_callback6))
0744 typedef size_t (*Wcurl_write_callback1)(const char *, size_t, size_t, void *);
0745 typedef size_t (*Wcurl_write_callback2)(const char *, size_t, size_t,
0746                                         const void *);
0747 typedef size_t (*Wcurl_write_callback3)(const char *, size_t, size_t, FILE *);
0748 typedef size_t (*Wcurl_write_callback4)(const void *, size_t, size_t, void *);
0749 typedef size_t (*Wcurl_write_callback5)(const void *, size_t, size_t,
0750                                         const void *);
0751 typedef size_t (*Wcurl_write_callback6)(const void *, size_t, size_t, FILE *);
0752 
0753 /* evaluates to true if expr is of type curl_ioctl_callback or "similar" */
0754 #define curlcheck_ioctl_cb(expr)                                        \
0755   (curlcheck_NULL(expr) ||                                              \
0756    curlcheck_cb_compatible((expr), curl_ioctl_callback) ||              \
0757    curlcheck_cb_compatible((expr), Wcurl_ioctl_callback1) ||            \
0758    curlcheck_cb_compatible((expr), Wcurl_ioctl_callback2) ||            \
0759    curlcheck_cb_compatible((expr), Wcurl_ioctl_callback3) ||            \
0760    curlcheck_cb_compatible((expr), Wcurl_ioctl_callback4))
0761 typedef curlioerr (*Wcurl_ioctl_callback1)(CURL *, int, void *);
0762 typedef curlioerr (*Wcurl_ioctl_callback2)(CURL *, int, const void *);
0763 typedef curlioerr (*Wcurl_ioctl_callback3)(CURL *, curliocmd, void *);
0764 typedef curlioerr (*Wcurl_ioctl_callback4)(CURL *, curliocmd, const void *);
0765 
0766 /* evaluates to true if expr is of type curl_sockopt_callback or "similar" */
0767 #define curlcheck_sockopt_cb(expr)                                      \
0768   (curlcheck_NULL(expr) ||                                              \
0769    curlcheck_cb_compatible((expr), curl_sockopt_callback) ||            \
0770    curlcheck_cb_compatible((expr), Wcurl_sockopt_callback1) ||          \
0771    curlcheck_cb_compatible((expr), Wcurl_sockopt_callback2))
0772 typedef int (*Wcurl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);
0773 typedef int (*Wcurl_sockopt_callback2)(const void *, curl_socket_t,
0774                                        curlsocktype);
0775 
0776 /* evaluates to true if expr is of type curl_opensocket_callback or
0777    "similar" */
0778 #define curlcheck_opensocket_cb(expr)                                   \
0779   (curlcheck_NULL(expr) ||                                              \
0780    curlcheck_cb_compatible((expr), curl_opensocket_callback) ||         \
0781    curlcheck_cb_compatible((expr), Wcurl_opensocket_callback1) ||       \
0782    curlcheck_cb_compatible((expr), Wcurl_opensocket_callback2) ||       \
0783    curlcheck_cb_compatible((expr), Wcurl_opensocket_callback3) ||       \
0784    curlcheck_cb_compatible((expr), Wcurl_opensocket_callback4))
0785 typedef curl_socket_t (*Wcurl_opensocket_callback1)
0786   (void *, curlsocktype, struct curl_sockaddr *);
0787 typedef curl_socket_t (*Wcurl_opensocket_callback2)
0788   (void *, curlsocktype, const struct curl_sockaddr *);
0789 typedef curl_socket_t (*Wcurl_opensocket_callback3)
0790   (const void *, curlsocktype, struct curl_sockaddr *);
0791 typedef curl_socket_t (*Wcurl_opensocket_callback4)
0792   (const void *, curlsocktype, const struct curl_sockaddr *);
0793 
0794 /* evaluates to true if expr is of type curl_progress_callback or "similar" */
0795 #define curlcheck_progress_cb(expr)                                     \
0796   (curlcheck_NULL(expr) ||                                              \
0797    curlcheck_cb_compatible((expr), curl_progress_callback) ||           \
0798    curlcheck_cb_compatible((expr), Wcurl_progress_callback1) ||         \
0799    curlcheck_cb_compatible((expr), Wcurl_progress_callback2))
0800 typedef int (*Wcurl_progress_callback1)(void *,
0801     double, double, double, double);
0802 typedef int (*Wcurl_progress_callback2)(const void *,
0803     double, double, double, double);
0804 
0805 /* evaluates to true if expr is of type curl_xferinfo_callback */
0806 #define curlcheck_xferinfo_cb(expr)                                     \
0807   (curlcheck_NULL(expr) ||                                              \
0808    curlcheck_cb_compatible((expr), curl_xferinfo_callback))
0809 
0810 /* evaluates to true if expr is of type curl_debug_callback or "similar" */
0811 #define curlcheck_debug_cb(expr)                                        \
0812   (curlcheck_NULL(expr) ||                                              \
0813    curlcheck_cb_compatible((expr), curl_debug_callback) ||              \
0814    curlcheck_cb_compatible((expr), Wcurl_debug_callback1) ||            \
0815    curlcheck_cb_compatible((expr), Wcurl_debug_callback2) ||            \
0816    curlcheck_cb_compatible((expr), Wcurl_debug_callback3) ||            \
0817    curlcheck_cb_compatible((expr), Wcurl_debug_callback4) ||            \
0818    curlcheck_cb_compatible((expr), Wcurl_debug_callback5) ||            \
0819    curlcheck_cb_compatible((expr), Wcurl_debug_callback6) ||            \
0820    curlcheck_cb_compatible((expr), Wcurl_debug_callback7) ||            \
0821    curlcheck_cb_compatible((expr), Wcurl_debug_callback8))
0822 typedef int (*Wcurl_debug_callback1)(CURL *,
0823     curl_infotype, char *, size_t, void *);
0824 typedef int (*Wcurl_debug_callback2)(CURL *,
0825     curl_infotype, char *, size_t, const void *);
0826 typedef int (*Wcurl_debug_callback3)(CURL *,
0827     curl_infotype, const char *, size_t, void *);
0828 typedef int (*Wcurl_debug_callback4)(CURL *,
0829     curl_infotype, const char *, size_t, const void *);
0830 typedef int (*Wcurl_debug_callback5)(CURL *,
0831     curl_infotype, unsigned char *, size_t, void *);
0832 typedef int (*Wcurl_debug_callback6)(CURL *,
0833     curl_infotype, unsigned char *, size_t, const void *);
0834 typedef int (*Wcurl_debug_callback7)(CURL *,
0835     curl_infotype, const unsigned char *, size_t, void *);
0836 typedef int (*Wcurl_debug_callback8)(CURL *,
0837     curl_infotype, const unsigned char *, size_t, const void *);
0838 
0839 /* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
0840 /* this is getting even messier... */
0841 #define curlcheck_ssl_ctx_cb(expr)                                      \
0842   (curlcheck_NULL(expr) ||                                              \
0843    curlcheck_cb_compatible((expr), curl_ssl_ctx_callback) ||            \
0844    curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback1) ||          \
0845    curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback2) ||          \
0846    curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback3) ||          \
0847    curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback4) ||          \
0848    curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback5) ||          \
0849    curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback6) ||          \
0850    curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback7) ||          \
0851    curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback8))
0852 typedef CURLcode (*Wcurl_ssl_ctx_callback1)(CURL *, void *, void *);
0853 typedef CURLcode (*Wcurl_ssl_ctx_callback2)(CURL *, void *, const void *);
0854 typedef CURLcode (*Wcurl_ssl_ctx_callback3)(CURL *, const void *, void *);
0855 typedef CURLcode (*Wcurl_ssl_ctx_callback4)(CURL *, const void *,
0856                                             const void *);
0857 #ifdef HEADER_SSL_H
0858 /* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX
0859  * this of course breaks if we are included before OpenSSL headers...
0860  */
0861 typedef CURLcode (*Wcurl_ssl_ctx_callback5)(CURL *, SSL_CTX *, void *);
0862 typedef CURLcode (*Wcurl_ssl_ctx_callback6)(CURL *, SSL_CTX *, const void *);
0863 typedef CURLcode (*Wcurl_ssl_ctx_callback7)(CURL *, const SSL_CTX *, void *);
0864 typedef CURLcode (*Wcurl_ssl_ctx_callback8)(CURL *, const SSL_CTX *,
0865                                             const void *);
0866 #else
0867 typedef Wcurl_ssl_ctx_callback1 Wcurl_ssl_ctx_callback5;
0868 typedef Wcurl_ssl_ctx_callback1 Wcurl_ssl_ctx_callback6;
0869 typedef Wcurl_ssl_ctx_callback1 Wcurl_ssl_ctx_callback7;
0870 typedef Wcurl_ssl_ctx_callback1 Wcurl_ssl_ctx_callback8;
0871 #endif
0872 
0873 /* evaluates to true if expr is of type curl_conv_callback or "similar" */
0874 #define curlcheck_conv_cb(expr)                                         \
0875   (curlcheck_NULL(expr) ||                                              \
0876    curlcheck_cb_compatible((expr), curl_conv_callback) ||               \
0877    curlcheck_cb_compatible((expr), Wcurl_conv_callback1) ||             \
0878    curlcheck_cb_compatible((expr), Wcurl_conv_callback2) ||             \
0879    curlcheck_cb_compatible((expr), Wcurl_conv_callback3) ||             \
0880    curlcheck_cb_compatible((expr), Wcurl_conv_callback4))
0881 typedef CURLcode (*Wcurl_conv_callback1)(char *, size_t length);
0882 typedef CURLcode (*Wcurl_conv_callback2)(const char *, size_t length);
0883 typedef CURLcode (*Wcurl_conv_callback3)(void *, size_t length);
0884 typedef CURLcode (*Wcurl_conv_callback4)(const void *, size_t length);
0885 
0886 /* evaluates to true if expr is of type curl_seek_callback or "similar" */
0887 #define curlcheck_seek_cb(expr)                                         \
0888   (curlcheck_NULL(expr) ||                                              \
0889    curlcheck_cb_compatible((expr), curl_seek_callback) ||               \
0890    curlcheck_cb_compatible((expr), Wcurl_seek_callback1) ||             \
0891    curlcheck_cb_compatible((expr), Wcurl_seek_callback2))
0892 typedef CURLcode (*Wcurl_seek_callback1)(void *, curl_off_t, int);
0893 typedef CURLcode (*Wcurl_seek_callback2)(const void *, curl_off_t, int);
0894 
0895 /* evaluates to true if expr is of type curl_chunk_bgn_callback */
0896 #define curlcheck_chunk_bgn_cb(expr)                                    \
0897   (curlcheck_NULL(expr) ||                                              \
0898    curlcheck_cb_compatible((expr), curl_chunk_bgn_callback) ||          \
0899    curlcheck_cb_compatible((expr), Wcurl_chunk_bgn_callback1) ||        \
0900    curlcheck_cb_compatible((expr), Wcurl_chunk_bgn_callback2))
0901 typedef long (*Wcurl_chunk_bgn_callback1)(struct curl_fileinfo *,
0902                                           void *, int);
0903 typedef long (*Wcurl_chunk_bgn_callback2)(void *, void *, int);
0904 
0905 /* evaluates to true if expr is of type curl_chunk_end_callback */
0906 #define curlcheck_chunk_end_cb(expr)                                    \
0907   (curlcheck_NULL(expr) ||                                              \
0908    curlcheck_cb_compatible((expr), curl_chunk_end_callback))
0909 
0910 /* evaluates to true if expr is of type curl_closesocket_callback */
0911 #define curlcheck_close_socket_cb(expr)                                 \
0912   (curlcheck_NULL(expr) ||                                              \
0913    curlcheck_cb_compatible((expr), curl_closesocket_callback))
0914 
0915 /* evaluates to true if expr is of type curl_fnmatch_callback */
0916 #define curlcheck_fnmatch_cb(expr)                                      \
0917   (curlcheck_NULL(expr) ||                                              \
0918    curlcheck_cb_compatible((expr), curl_fnmatch_callback))
0919 
0920 /* evaluates to true if expr is of type curl_hstsread_callback */
0921 #define curlcheck_hstsread_cb(expr)                                     \
0922   (curlcheck_NULL(expr) ||                                              \
0923    curlcheck_cb_compatible((expr), curl_hstsread_callback))
0924 
0925 /* evaluates to true if expr is of type curl_hstswrite_callback */
0926 #define curlcheck_hstswrite_cb(expr)                                    \
0927   (curlcheck_NULL(expr) ||                                              \
0928    curlcheck_cb_compatible((expr), curl_hstswrite_callback))
0929 
0930 /* evaluates to true if expr is of type curl_sshhostkeycallback */
0931 #define curlcheck_ssh_hostkey_cb(expr)                                  \
0932   (curlcheck_NULL(expr) ||                                              \
0933    curlcheck_cb_compatible((expr), curl_sshhostkeycallback))
0934 
0935 /* evaluates to true if expr is of type curl_sshkeycallback */
0936 #define curlcheck_ssh_key_cb(expr)                                      \
0937   (curlcheck_NULL(expr) ||                                              \
0938    curlcheck_cb_compatible((expr), curl_sshkeycallback))
0939 
0940 /* evaluates to true if expr is of type curl_interleave_callback */
0941 #define curlcheck_interleave_cb(expr)                                   \
0942   (curlcheck_NULL(expr) ||                                              \
0943    curlcheck_cb_compatible((expr), Wcurl_interleave_callback1) ||       \
0944    curlcheck_cb_compatible((expr), Wcurl_interleave_callback2))
0945 typedef size_t (*Wcurl_interleave_callback1)(void *p, size_t s,
0946                                              size_t n, void *u);
0947 typedef size_t (*Wcurl_interleave_callback2)(char *p, size_t s,
0948                                              size_t n, void *u);
0949 
0950 /* evaluates to true if expr is of type curl_prereq_callback */
0951 #define curlcheck_prereq_cb(expr)                                       \
0952   (curlcheck_NULL(expr) ||                                              \
0953    curlcheck_cb_compatible((expr), curl_prereq_callback))
0954 
0955 /* evaluates to true if expr is of type curl_trailer_callback */
0956 #define curlcheck_trailer_cb(expr)                                      \
0957   (curlcheck_NULL(expr) ||                                              \
0958    curlcheck_cb_compatible((expr), curl_trailer_callback))
0959 
0960 #endif /* CURLINC_TYPECHECK_GCC_H */