typecheck-gcc.h
Go to the documentation of this file.
00001 #ifndef __CURL_TYPECHECK_GCC_H
00002 #define __CURL_TYPECHECK_GCC_H
00003 /***************************************************************************
00004  *                                  _   _ ____  _
00005  *  Project                     ___| | | |  _ \| |
00006  *                             / __| | | | |_) | |
00007  *                            | (__| |_| |  _ <| |___
00008  *                             \___|\___/|_| \_\_____|
00009  *
00010  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
00011  *
00012  * This software is licensed as described in the file COPYING, which
00013  * you should have received as part of this distribution. The terms
00014  * are also available at https://curl.haxx.se/docs/copyright.html.
00015  *
00016  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00017  * copies of the Software, and permit persons to whom the Software is
00018  * furnished to do so, under the terms of the COPYING file.
00019  *
00020  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00021  * KIND, either express or implied.
00022  *
00023  ***************************************************************************/
00024 
00025 /* wraps curl_easy_setopt() with typechecking */
00026 
00027 /* To add a new kind of warning, add an
00028  *   if(_curl_is_sometype_option(_curl_opt))
00029  *     if(!_curl_is_sometype(value))
00030  *       _curl_easy_setopt_err_sometype();
00031  * block and define _curl_is_sometype_option, _curl_is_sometype and
00032  * _curl_easy_setopt_err_sometype below
00033  *
00034  * NOTE: We use two nested 'if' statements here instead of the && operator, in
00035  *       order to work around gcc bug #32061.  It affects only gcc 4.3.x/4.4.x
00036  *       when compiling with -Wlogical-op.
00037  *
00038  * To add an option that uses the same type as an existing option, you'll just
00039  * need to extend the appropriate _curl_*_option macro
00040  */
00041 #define curl_easy_setopt(handle, option, value)                               \
00042 __extension__ ({                                                              \
00043   __typeof__(option) _curl_opt = option;                                     \
00044   if(__builtin_constant_p(_curl_opt)) {                                       \
00045     if(_curl_is_long_option(_curl_opt))                                       \
00046       if(!_curl_is_long(value))                                               \
00047         _curl_easy_setopt_err_long();                                         \
00048     if(_curl_is_off_t_option(_curl_opt))                                      \
00049       if(!_curl_is_off_t(value))                                              \
00050         _curl_easy_setopt_err_curl_off_t();                                   \
00051     if(_curl_is_string_option(_curl_opt))                                     \
00052       if(!_curl_is_string(value))                                             \
00053         _curl_easy_setopt_err_string();                                       \
00054     if(_curl_is_write_cb_option(_curl_opt))                                   \
00055       if(!_curl_is_write_cb(value))                                           \
00056         _curl_easy_setopt_err_write_callback();                               \
00057     if((_curl_opt) == CURLOPT_READFUNCTION)                                   \
00058       if(!_curl_is_read_cb(value))                                            \
00059         _curl_easy_setopt_err_read_cb();                                      \
00060     if((_curl_opt) == CURLOPT_IOCTLFUNCTION)                                  \
00061       if(!_curl_is_ioctl_cb(value))                                           \
00062         _curl_easy_setopt_err_ioctl_cb();                                     \
00063     if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION)                                \
00064       if(!_curl_is_sockopt_cb(value))                                         \
00065         _curl_easy_setopt_err_sockopt_cb();                                   \
00066     if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION)                             \
00067       if(!_curl_is_opensocket_cb(value))                                      \
00068         _curl_easy_setopt_err_opensocket_cb();                                \
00069     if((_curl_opt) == CURLOPT_PROGRESSFUNCTION)                               \
00070       if(!_curl_is_progress_cb(value))                                        \
00071         _curl_easy_setopt_err_progress_cb();                                  \
00072     if((_curl_opt) == CURLOPT_DEBUGFUNCTION)                                  \
00073       if(!_curl_is_debug_cb(value))                                           \
00074         _curl_easy_setopt_err_debug_cb();                                     \
00075     if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION)                               \
00076       if(!_curl_is_ssl_ctx_cb(value))                                         \
00077         _curl_easy_setopt_err_ssl_ctx_cb();                                   \
00078     if(_curl_is_conv_cb_option(_curl_opt))                                    \
00079       if(!_curl_is_conv_cb(value))                                            \
00080         _curl_easy_setopt_err_conv_cb();                                      \
00081     if((_curl_opt) == CURLOPT_SEEKFUNCTION)                                   \
00082       if(!_curl_is_seek_cb(value))                                            \
00083         _curl_easy_setopt_err_seek_cb();                                      \
00084     if(_curl_is_cb_data_option(_curl_opt))                                    \
00085       if(!_curl_is_cb_data(value))                                            \
00086         _curl_easy_setopt_err_cb_data();                                      \
00087     if((_curl_opt) == CURLOPT_ERRORBUFFER)                                    \
00088       if(!_curl_is_error_buffer(value))                                       \
00089         _curl_easy_setopt_err_error_buffer();                                 \
00090     if((_curl_opt) == CURLOPT_STDERR)                                         \
00091       if(!_curl_is_FILE(value))                                               \
00092         _curl_easy_setopt_err_FILE();                                         \
00093     if(_curl_is_postfields_option(_curl_opt))                                 \
00094       if(!_curl_is_postfields(value))                                         \
00095         _curl_easy_setopt_err_postfields();                                   \
00096     if((_curl_opt) == CURLOPT_HTTPPOST)                                       \
00097       if(!_curl_is_arr((value), struct curl_httppost))                        \
00098         _curl_easy_setopt_err_curl_httpost();                                 \
00099     if(_curl_is_slist_option(_curl_opt))                                      \
00100       if(!_curl_is_arr((value), struct curl_slist))                           \
00101         _curl_easy_setopt_err_curl_slist();                                   \
00102     if((_curl_opt) == CURLOPT_SHARE)                                          \
00103       if(!_curl_is_ptr((value), CURLSH))                                      \
00104         _curl_easy_setopt_err_CURLSH();                                       \
00105   }                                                                           \
00106   curl_easy_setopt(handle, _curl_opt, value);                                 \
00107 })
00108 
00109 /* wraps curl_easy_getinfo() with typechecking */
00110 /* FIXME: don't allow const pointers */
00111 #define curl_easy_getinfo(handle, info, arg)                                  \
00112 __extension__ ({                                                              \
00113   __typeof__(info) _curl_info = info;                                        \
00114   if(__builtin_constant_p(_curl_info)) {                                      \
00115     if(_curl_is_string_info(_curl_info))                                      \
00116       if(!_curl_is_arr((arg), char *))                                        \
00117         _curl_easy_getinfo_err_string();                                      \
00118     if(_curl_is_long_info(_curl_info))                                        \
00119       if(!_curl_is_arr((arg), long))                                          \
00120         _curl_easy_getinfo_err_long();                                        \
00121     if(_curl_is_double_info(_curl_info))                                      \
00122       if(!_curl_is_arr((arg), double))                                        \
00123         _curl_easy_getinfo_err_double();                                      \
00124     if(_curl_is_slist_info(_curl_info))                                       \
00125       if(!_curl_is_arr((arg), struct curl_slist *))                           \
00126         _curl_easy_getinfo_err_curl_slist();                                  \
00127   }                                                                           \
00128   curl_easy_getinfo(handle, _curl_info, arg);                                 \
00129 })
00130 
00131 /* TODO: typechecking for curl_share_setopt() and curl_multi_setopt(),
00132  * for now just make sure that the functions are called with three
00133  * arguments
00134  */
00135 #define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
00136 #define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)
00137 
00138 
00139 /* the actual warnings, triggered by calling the _curl_easy_setopt_err*
00140  * functions */
00141 
00142 /* To define a new warning, use _CURL_WARNING(identifier, "message") */
00143 #define _CURL_WARNING(id, message)                                            \
00144   static void __attribute__((__warning__(message)))                           \
00145   __attribute__((__unused__)) __attribute__((__noinline__))                   \
00146   id(void) { __asm__(""); }
00147 
00148 _CURL_WARNING(_curl_easy_setopt_err_long,
00149   "curl_easy_setopt expects a long argument for this option")
00150 _CURL_WARNING(_curl_easy_setopt_err_curl_off_t,
00151   "curl_easy_setopt expects a curl_off_t argument for this option")
00152 _CURL_WARNING(_curl_easy_setopt_err_string,
00153               "curl_easy_setopt expects a "
00154               "string ('char *' or char[]) argument for this option"
00155   )
00156 _CURL_WARNING(_curl_easy_setopt_err_write_callback,
00157   "curl_easy_setopt expects a curl_write_callback argument for this option")
00158 _CURL_WARNING(_curl_easy_setopt_err_read_cb,
00159   "curl_easy_setopt expects a curl_read_callback argument for this option")
00160 _CURL_WARNING(_curl_easy_setopt_err_ioctl_cb,
00161   "curl_easy_setopt expects a curl_ioctl_callback argument for this option")
00162 _CURL_WARNING(_curl_easy_setopt_err_sockopt_cb,
00163   "curl_easy_setopt expects a curl_sockopt_callback argument for this option")
00164 _CURL_WARNING(_curl_easy_setopt_err_opensocket_cb,
00165               "curl_easy_setopt expects a "
00166               "curl_opensocket_callback argument for this option"
00167   )
00168 _CURL_WARNING(_curl_easy_setopt_err_progress_cb,
00169   "curl_easy_setopt expects a curl_progress_callback argument for this option")
00170 _CURL_WARNING(_curl_easy_setopt_err_debug_cb,
00171   "curl_easy_setopt expects a curl_debug_callback argument for this option")
00172 _CURL_WARNING(_curl_easy_setopt_err_ssl_ctx_cb,
00173   "curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option")
00174 _CURL_WARNING(_curl_easy_setopt_err_conv_cb,
00175   "curl_easy_setopt expects a curl_conv_callback argument for this option")
00176 _CURL_WARNING(_curl_easy_setopt_err_seek_cb,
00177   "curl_easy_setopt expects a curl_seek_callback argument for this option")
00178 _CURL_WARNING(_curl_easy_setopt_err_cb_data,
00179               "curl_easy_setopt expects a "
00180               "private data pointer as argument for this option")
00181 _CURL_WARNING(_curl_easy_setopt_err_error_buffer,
00182               "curl_easy_setopt expects a "
00183               "char buffer of CURL_ERROR_SIZE as argument for this option")
00184 _CURL_WARNING(_curl_easy_setopt_err_FILE,
00185   "curl_easy_setopt expects a 'FILE *' argument for this option")
00186 _CURL_WARNING(_curl_easy_setopt_err_postfields,
00187   "curl_easy_setopt expects a 'void *' or 'char *' argument for this option")
00188 _CURL_WARNING(_curl_easy_setopt_err_curl_httpost,
00189               "curl_easy_setopt expects a 'struct curl_httppost *' "
00190               "argument for this option")
00191 _CURL_WARNING(_curl_easy_setopt_err_curl_slist,
00192   "curl_easy_setopt expects a 'struct curl_slist *' argument for this option")
00193 _CURL_WARNING(_curl_easy_setopt_err_CURLSH,
00194   "curl_easy_setopt expects a CURLSH* argument for this option")
00195 
00196 _CURL_WARNING(_curl_easy_getinfo_err_string,
00197   "curl_easy_getinfo expects a pointer to 'char *' for this info")
00198 _CURL_WARNING(_curl_easy_getinfo_err_long,
00199   "curl_easy_getinfo expects a pointer to long for this info")
00200 _CURL_WARNING(_curl_easy_getinfo_err_double,
00201   "curl_easy_getinfo expects a pointer to double for this info")
00202 _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
00203   "curl_easy_getinfo expects a pointer to 'struct curl_slist *' for this info")
00204 
00205 /* groups of curl_easy_setops options that take the same type of argument */
00206 
00207 /* To add a new option to one of the groups, just add
00208  *   (option) == CURLOPT_SOMETHING
00209  * to the or-expression. If the option takes a long or curl_off_t, you don't
00210  * have to do anything
00211  */
00212 
00213 /* evaluates to true if option takes a long argument */
00214 #define _curl_is_long_option(option)                                          \
00215   (0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
00216 
00217 #define _curl_is_off_t_option(option)                                         \
00218   ((option) > CURLOPTTYPE_OFF_T)
00219 
00220 /* evaluates to true if option takes a char* argument */
00221 #define _curl_is_string_option(option)                                        \
00222   ((option) == CURLOPT_ACCEPT_ENCODING ||                                     \
00223    (option) == CURLOPT_CAINFO ||                                              \
00224    (option) == CURLOPT_CAPATH ||                                              \
00225    (option) == CURLOPT_COOKIE ||                                              \
00226    (option) == CURLOPT_COOKIEFILE ||                                          \
00227    (option) == CURLOPT_COOKIEJAR ||                                           \
00228    (option) == CURLOPT_COOKIELIST ||                                          \
00229    (option) == CURLOPT_CRLFILE ||                                             \
00230    (option) == CURLOPT_CUSTOMREQUEST ||                                       \
00231    (option) == CURLOPT_DEFAULT_PROTOCOL ||                                    \
00232    (option) == CURLOPT_DNS_INTERFACE ||                                       \
00233    (option) == CURLOPT_DNS_LOCAL_IP4 ||                                       \
00234    (option) == CURLOPT_DNS_LOCAL_IP6 ||                                       \
00235    (option) == CURLOPT_DNS_SERVERS ||                                         \
00236    (option) == CURLOPT_EGDSOCKET ||                                           \
00237    (option) == CURLOPT_FTPPORT ||                                             \
00238    (option) == CURLOPT_FTP_ACCOUNT ||                                         \
00239    (option) == CURLOPT_FTP_ALTERNATIVE_TO_USER ||                             \
00240    (option) == CURLOPT_INTERFACE ||                                           \
00241    (option) == CURLOPT_ISSUERCERT ||                                          \
00242    (option) == CURLOPT_KEYPASSWD ||                                           \
00243    (option) == CURLOPT_KRBLEVEL ||                                            \
00244    (option) == CURLOPT_LOGIN_OPTIONS ||                                       \
00245    (option) == CURLOPT_MAIL_AUTH ||                                           \
00246    (option) == CURLOPT_MAIL_FROM ||                                           \
00247    (option) == CURLOPT_NETRC_FILE ||                                          \
00248    (option) == CURLOPT_NOPROXY ||                                             \
00249    (option) == CURLOPT_PASSWORD ||                                            \
00250    (option) == CURLOPT_PINNEDPUBLICKEY ||                                     \
00251    (option) == CURLOPT_PROXY ||                                               \
00252    (option) == CURLOPT_PROXYPASSWORD ||                                       \
00253    (option) == CURLOPT_PROXYUSERNAME ||                                       \
00254    (option) == CURLOPT_PROXYUSERPWD ||                                        \
00255    (option) == CURLOPT_PROXY_SERVICE_NAME ||                                  \
00256    (option) == CURLOPT_RANDOM_FILE ||                                         \
00257    (option) == CURLOPT_RANGE ||                                               \
00258    (option) == CURLOPT_REFERER ||                                             \
00259    (option) == CURLOPT_RTSP_SESSION_ID ||                                     \
00260    (option) == CURLOPT_RTSP_STREAM_URI ||                                     \
00261    (option) == CURLOPT_RTSP_TRANSPORT ||                                      \
00262    (option) == CURLOPT_SERVICE_NAME ||                                        \
00263    (option) == CURLOPT_SOCKS5_GSSAPI_SERVICE ||                               \
00264    (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 ||                             \
00265    (option) == CURLOPT_SSH_KNOWNHOSTS ||                                      \
00266    (option) == CURLOPT_SSH_PRIVATE_KEYFILE ||                                 \
00267    (option) == CURLOPT_SSH_PUBLIC_KEYFILE ||                                  \
00268    (option) == CURLOPT_SSLCERT ||                                             \
00269    (option) == CURLOPT_SSLCERTTYPE ||                                         \
00270    (option) == CURLOPT_SSLENGINE ||                                           \
00271    (option) == CURLOPT_SSLKEY ||                                              \
00272    (option) == CURLOPT_SSLKEYTYPE ||                                          \
00273    (option) == CURLOPT_SSL_CIPHER_LIST ||                                     \
00274    (option) == CURLOPT_TLSAUTH_PASSWORD ||                                    \
00275    (option) == CURLOPT_TLSAUTH_TYPE ||                                        \
00276    (option) == CURLOPT_TLSAUTH_USERNAME ||                                    \
00277    (option) == CURLOPT_UNIX_SOCKET_PATH ||                                    \
00278    (option) == CURLOPT_URL ||                                                 \
00279    (option) == CURLOPT_USERAGENT ||                                           \
00280    (option) == CURLOPT_USERNAME ||                                            \
00281    (option) == CURLOPT_USERPWD ||                                             \
00282    (option) == CURLOPT_XOAUTH2_BEARER ||                                      \
00283    0)
00284 
00285 /* evaluates to true if option takes a curl_write_callback argument */
00286 #define _curl_is_write_cb_option(option)                                      \
00287   ((option) == CURLOPT_HEADERFUNCTION ||                                      \
00288    (option) == CURLOPT_WRITEFUNCTION)
00289 
00290 /* evaluates to true if option takes a curl_conv_callback argument */
00291 #define _curl_is_conv_cb_option(option)                                       \
00292   ((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION ||                            \
00293    (option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION ||                          \
00294    (option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)
00295 
00296 /* evaluates to true if option takes a data argument to pass to a callback */
00297 #define _curl_is_cb_data_option(option)                                       \
00298   ((option) == CURLOPT_CHUNK_DATA ||                                          \
00299    (option) == CURLOPT_CLOSESOCKETDATA ||                                     \
00300    (option) == CURLOPT_DEBUGDATA ||                                           \
00301    (option) == CURLOPT_FNMATCH_DATA ||                                        \
00302    (option) == CURLOPT_HEADERDATA ||                                          \
00303    (option) == CURLOPT_INTERLEAVEDATA ||                                      \
00304    (option) == CURLOPT_IOCTLDATA ||                                           \
00305    (option) == CURLOPT_OPENSOCKETDATA ||                                      \
00306    (option) == CURLOPT_PRIVATE ||                                             \
00307    (option) == CURLOPT_PROGRESSDATA ||                                        \
00308    (option) == CURLOPT_READDATA ||                                            \
00309    (option) == CURLOPT_SEEKDATA ||                                            \
00310    (option) == CURLOPT_SOCKOPTDATA ||                                         \
00311    (option) == CURLOPT_SSH_KEYDATA ||                                         \
00312    (option) == CURLOPT_SSL_CTX_DATA ||                                        \
00313    (option) == CURLOPT_WRITEDATA ||                                           \
00314    0)
00315 
00316 /* evaluates to true if option takes a POST data argument (void* or char*) */
00317 #define _curl_is_postfields_option(option)                                    \
00318   ((option) == CURLOPT_POSTFIELDS ||                                          \
00319    (option) == CURLOPT_COPYPOSTFIELDS ||                                      \
00320    0)
00321 
00322 /* evaluates to true if option takes a struct curl_slist * argument */
00323 #define _curl_is_slist_option(option)                                         \
00324   ((option) == CURLOPT_HTTP200ALIASES ||                                      \
00325    (option) == CURLOPT_HTTPHEADER ||                                          \
00326    (option) == CURLOPT_MAIL_RCPT ||                                           \
00327    (option) == CURLOPT_POSTQUOTE ||                                           \
00328    (option) == CURLOPT_PREQUOTE ||                                            \
00329    (option) == CURLOPT_PROXYHEADER ||                                         \
00330    (option) == CURLOPT_QUOTE ||                                               \
00331    (option) == CURLOPT_RESOLVE ||                                             \
00332    (option) == CURLOPT_TELNETOPTIONS ||                                       \
00333    0)
00334 
00335 /* groups of curl_easy_getinfo infos that take the same type of argument */
00336 
00337 /* evaluates to true if info expects a pointer to char * argument */
00338 #define _curl_is_string_info(info)                                            \
00339   (CURLINFO_STRING < (info) && (info) < CURLINFO_LONG)
00340 
00341 /* evaluates to true if info expects a pointer to long argument */
00342 #define _curl_is_long_info(info)                                              \
00343   (CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)
00344 
00345 /* evaluates to true if info expects a pointer to double argument */
00346 #define _curl_is_double_info(info)                                            \
00347   (CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)
00348 
00349 /* true if info expects a pointer to struct curl_slist * argument */
00350 #define _curl_is_slist_info(info)                                             \
00351   (CURLINFO_SLIST < (info))
00352 
00353 
00354 /* typecheck helpers -- check whether given expression has requested type*/
00355 
00356 /* For pointers, you can use the _curl_is_ptr/_curl_is_arr macros,
00357  * otherwise define a new macro. Search for __builtin_types_compatible_p
00358  * in the GCC manual.
00359  * NOTE: these macros MUST NOT EVALUATE their arguments! The argument is
00360  * the actual expression passed to the curl_easy_setopt macro. This
00361  * means that you can only apply the sizeof and __typeof__ operators, no
00362  * == or whatsoever.
00363  */
00364 
00365 /* XXX: should evaluate to true iff expr is a pointer */
00366 #define _curl_is_any_ptr(expr)                                                \
00367   (sizeof(expr) == sizeof(void *))
00368 
00369 /* evaluates to true if expr is NULL */
00370 /* XXX: must not evaluate expr, so this check is not accurate */
00371 #define _curl_is_NULL(expr)                                                   \
00372   (__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))
00373 
00374 /* evaluates to true if expr is type*, const type* or NULL */
00375 #define _curl_is_ptr(expr, type)                                              \
00376   (_curl_is_NULL(expr) ||                                                     \
00377    __builtin_types_compatible_p(__typeof__(expr), type *) ||                  \
00378    __builtin_types_compatible_p(__typeof__(expr), const type *))
00379 
00380 /* evaluates to true if expr is one of type[], type*, NULL or const type* */
00381 #define _curl_is_arr(expr, type)                                              \
00382   (_curl_is_ptr((expr), type) ||                                              \
00383    __builtin_types_compatible_p(__typeof__(expr), type []))
00384 
00385 /* evaluates to true if expr is a string */
00386 #define _curl_is_string(expr)                                                 \
00387   (_curl_is_arr((expr), char) ||                                              \
00388    _curl_is_arr((expr), signed char) ||                                       \
00389    _curl_is_arr((expr), unsigned char))
00390 
00391 /* evaluates to true if expr is a long (no matter the signedness)
00392  * XXX: for now, int is also accepted (and therefore short and char, which
00393  * are promoted to int when passed to a variadic function) */
00394 #define _curl_is_long(expr)                                                   \
00395   (__builtin_types_compatible_p(__typeof__(expr), long) ||                    \
00396    __builtin_types_compatible_p(__typeof__(expr), signed long) ||             \
00397    __builtin_types_compatible_p(__typeof__(expr), unsigned long) ||           \
00398    __builtin_types_compatible_p(__typeof__(expr), int) ||                     \
00399    __builtin_types_compatible_p(__typeof__(expr), signed int) ||              \
00400    __builtin_types_compatible_p(__typeof__(expr), unsigned int) ||            \
00401    __builtin_types_compatible_p(__typeof__(expr), short) ||                   \
00402    __builtin_types_compatible_p(__typeof__(expr), signed short) ||            \
00403    __builtin_types_compatible_p(__typeof__(expr), unsigned short) ||          \
00404    __builtin_types_compatible_p(__typeof__(expr), char) ||                    \
00405    __builtin_types_compatible_p(__typeof__(expr), signed char) ||             \
00406    __builtin_types_compatible_p(__typeof__(expr), unsigned char))
00407 
00408 /* evaluates to true if expr is of type curl_off_t */
00409 #define _curl_is_off_t(expr)                                                  \
00410   (__builtin_types_compatible_p(__typeof__(expr), curl_off_t))
00411 
00412 /* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
00413 /* XXX: also check size of an char[] array? */
00414 #define _curl_is_error_buffer(expr)                                           \
00415   (_curl_is_NULL(expr) ||                                                     \
00416    __builtin_types_compatible_p(__typeof__(expr), char *) ||                  \
00417    __builtin_types_compatible_p(__typeof__(expr), char[]))
00418 
00419 /* evaluates to true if expr is of type (const) void* or (const) FILE* */
00420 #if 0
00421 #define _curl_is_cb_data(expr)                                                \
00422   (_curl_is_ptr((expr), void) ||                                              \
00423    _curl_is_ptr((expr), FILE))
00424 #else /* be less strict */
00425 #define _curl_is_cb_data(expr)                                                \
00426   _curl_is_any_ptr(expr)
00427 #endif
00428 
00429 /* evaluates to true if expr is of type FILE* */
00430 #define _curl_is_FILE(expr)                                                   \
00431   (__builtin_types_compatible_p(__typeof__(expr), FILE *))
00432 
00433 /* evaluates to true if expr can be passed as POST data (void* or char*) */
00434 #define _curl_is_postfields(expr)                                             \
00435   (_curl_is_ptr((expr), void) ||                                              \
00436    _curl_is_arr((expr), char))
00437 
00438 /* FIXME: the whole callback checking is messy...
00439  * The idea is to tolerate char vs. void and const vs. not const
00440  * pointers in arguments at least
00441  */
00442 /* helper: __builtin_types_compatible_p distinguishes between functions and
00443  * function pointers, hide it */
00444 #define _curl_callback_compatible(func, type)                                 \
00445   (__builtin_types_compatible_p(__typeof__(func), type) ||                    \
00446    __builtin_types_compatible_p(__typeof__(func), type*))
00447 
00448 /* evaluates to true if expr is of type curl_read_callback or "similar" */
00449 #define _curl_is_read_cb(expr)                                          \
00450   (_curl_is_NULL(expr) ||                                                     \
00451    __builtin_types_compatible_p(__typeof__(expr), __typeof__(fread)) ||       \
00452    __builtin_types_compatible_p(__typeof__(expr), curl_read_callback) ||      \
00453    _curl_callback_compatible((expr), _curl_read_callback1) ||                 \
00454    _curl_callback_compatible((expr), _curl_read_callback2) ||                 \
00455    _curl_callback_compatible((expr), _curl_read_callback3) ||                 \
00456    _curl_callback_compatible((expr), _curl_read_callback4) ||                 \
00457    _curl_callback_compatible((expr), _curl_read_callback5) ||                 \
00458    _curl_callback_compatible((expr), _curl_read_callback6))
00459 typedef size_t (_curl_read_callback1)(char *, size_t, size_t, void *);
00460 typedef size_t (_curl_read_callback2)(char *, size_t, size_t, const void *);
00461 typedef size_t (_curl_read_callback3)(char *, size_t, size_t, FILE *);
00462 typedef size_t (_curl_read_callback4)(void *, size_t, size_t, void *);
00463 typedef size_t (_curl_read_callback5)(void *, size_t, size_t, const void *);
00464 typedef size_t (_curl_read_callback6)(void *, size_t, size_t, FILE *);
00465 
00466 /* evaluates to true if expr is of type curl_write_callback or "similar" */
00467 #define _curl_is_write_cb(expr)                                               \
00468   (_curl_is_read_cb(expr) ||                                            \
00469    __builtin_types_compatible_p(__typeof__(expr), __typeof__(fwrite)) ||      \
00470    __builtin_types_compatible_p(__typeof__(expr), curl_write_callback) ||     \
00471    _curl_callback_compatible((expr), _curl_write_callback1) ||                \
00472    _curl_callback_compatible((expr), _curl_write_callback2) ||                \
00473    _curl_callback_compatible((expr), _curl_write_callback3) ||                \
00474    _curl_callback_compatible((expr), _curl_write_callback4) ||                \
00475    _curl_callback_compatible((expr), _curl_write_callback5) ||                \
00476    _curl_callback_compatible((expr), _curl_write_callback6))
00477 typedef size_t (_curl_write_callback1)(const char *, size_t, size_t, void *);
00478 typedef size_t (_curl_write_callback2)(const char *, size_t, size_t,
00479                                        const void *);
00480 typedef size_t (_curl_write_callback3)(const char *, size_t, size_t, FILE *);
00481 typedef size_t (_curl_write_callback4)(const void *, size_t, size_t, void *);
00482 typedef size_t (_curl_write_callback5)(const void *, size_t, size_t,
00483                                        const void *);
00484 typedef size_t (_curl_write_callback6)(const void *, size_t, size_t, FILE *);
00485 
00486 /* evaluates to true if expr is of type curl_ioctl_callback or "similar" */
00487 #define _curl_is_ioctl_cb(expr)                                         \
00488   (_curl_is_NULL(expr) ||                                                     \
00489    __builtin_types_compatible_p(__typeof__(expr), curl_ioctl_callback) ||     \
00490    _curl_callback_compatible((expr), _curl_ioctl_callback1) ||                \
00491    _curl_callback_compatible((expr), _curl_ioctl_callback2) ||                \
00492    _curl_callback_compatible((expr), _curl_ioctl_callback3) ||                \
00493    _curl_callback_compatible((expr), _curl_ioctl_callback4))
00494 typedef curlioerr (_curl_ioctl_callback1)(CURL *, int, void *);
00495 typedef curlioerr (_curl_ioctl_callback2)(CURL *, int, const void *);
00496 typedef curlioerr (_curl_ioctl_callback3)(CURL *, curliocmd, void *);
00497 typedef curlioerr (_curl_ioctl_callback4)(CURL *, curliocmd, const void *);
00498 
00499 /* evaluates to true if expr is of type curl_sockopt_callback or "similar" */
00500 #define _curl_is_sockopt_cb(expr)                                       \
00501   (_curl_is_NULL(expr) ||                                                     \
00502    __builtin_types_compatible_p(__typeof__(expr), curl_sockopt_callback) ||   \
00503    _curl_callback_compatible((expr), _curl_sockopt_callback1) ||              \
00504    _curl_callback_compatible((expr), _curl_sockopt_callback2))
00505 typedef int (_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);
00506 typedef int (_curl_sockopt_callback2)(const void *, curl_socket_t,
00507                                       curlsocktype);
00508 
00509 /* evaluates to true if expr is of type curl_opensocket_callback or
00510    "similar" */
00511 #define _curl_is_opensocket_cb(expr)                                    \
00512   (_curl_is_NULL(expr) ||                                                     \
00513    __builtin_types_compatible_p(__typeof__(expr), curl_opensocket_callback) ||\
00514    _curl_callback_compatible((expr), _curl_opensocket_callback1) ||           \
00515    _curl_callback_compatible((expr), _curl_opensocket_callback2) ||           \
00516    _curl_callback_compatible((expr), _curl_opensocket_callback3) ||           \
00517    _curl_callback_compatible((expr), _curl_opensocket_callback4))
00518 typedef curl_socket_t (_curl_opensocket_callback1)
00519   (void *, curlsocktype, struct curl_sockaddr *);
00520 typedef curl_socket_t (_curl_opensocket_callback2)
00521   (void *, curlsocktype, const struct curl_sockaddr *);
00522 typedef curl_socket_t (_curl_opensocket_callback3)
00523   (const void *, curlsocktype, struct curl_sockaddr *);
00524 typedef curl_socket_t (_curl_opensocket_callback4)
00525   (const void *, curlsocktype, const struct curl_sockaddr *);
00526 
00527 /* evaluates to true if expr is of type curl_progress_callback or "similar" */
00528 #define _curl_is_progress_cb(expr)                                      \
00529   (_curl_is_NULL(expr) ||                                                     \
00530    __builtin_types_compatible_p(__typeof__(expr), curl_progress_callback) ||  \
00531    _curl_callback_compatible((expr), _curl_progress_callback1) ||             \
00532    _curl_callback_compatible((expr), _curl_progress_callback2))
00533 typedef int (_curl_progress_callback1)(void *,
00534     double, double, double, double);
00535 typedef int (_curl_progress_callback2)(const void *,
00536     double, double, double, double);
00537 
00538 /* evaluates to true if expr is of type curl_debug_callback or "similar" */
00539 #define _curl_is_debug_cb(expr)                                         \
00540   (_curl_is_NULL(expr) ||                                                     \
00541    __builtin_types_compatible_p(__typeof__(expr), curl_debug_callback) ||     \
00542    _curl_callback_compatible((expr), _curl_debug_callback1) ||                \
00543    _curl_callback_compatible((expr), _curl_debug_callback2) ||                \
00544    _curl_callback_compatible((expr), _curl_debug_callback3) ||                \
00545    _curl_callback_compatible((expr), _curl_debug_callback4) ||                \
00546    _curl_callback_compatible((expr), _curl_debug_callback5) ||                \
00547    _curl_callback_compatible((expr), _curl_debug_callback6) ||                \
00548    _curl_callback_compatible((expr), _curl_debug_callback7) ||                \
00549    _curl_callback_compatible((expr), _curl_debug_callback8))
00550 typedef int (_curl_debug_callback1) (CURL *,
00551     curl_infotype, char *, size_t, void *);
00552 typedef int (_curl_debug_callback2) (CURL *,
00553     curl_infotype, char *, size_t, const void *);
00554 typedef int (_curl_debug_callback3) (CURL *,
00555     curl_infotype, const char *, size_t, void *);
00556 typedef int (_curl_debug_callback4) (CURL *,
00557     curl_infotype, const char *, size_t, const void *);
00558 typedef int (_curl_debug_callback5) (CURL *,
00559     curl_infotype, unsigned char *, size_t, void *);
00560 typedef int (_curl_debug_callback6) (CURL *,
00561     curl_infotype, unsigned char *, size_t, const void *);
00562 typedef int (_curl_debug_callback7) (CURL *,
00563     curl_infotype, const unsigned char *, size_t, void *);
00564 typedef int (_curl_debug_callback8) (CURL *,
00565     curl_infotype, const unsigned char *, size_t, const void *);
00566 
00567 /* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
00568 /* this is getting even messier... */
00569 #define _curl_is_ssl_ctx_cb(expr)                                       \
00570   (_curl_is_NULL(expr) ||                                                     \
00571    __builtin_types_compatible_p(__typeof__(expr), curl_ssl_ctx_callback) ||   \
00572    _curl_callback_compatible((expr), _curl_ssl_ctx_callback1) ||              \
00573    _curl_callback_compatible((expr), _curl_ssl_ctx_callback2) ||              \
00574    _curl_callback_compatible((expr), _curl_ssl_ctx_callback3) ||              \
00575    _curl_callback_compatible((expr), _curl_ssl_ctx_callback4) ||              \
00576    _curl_callback_compatible((expr), _curl_ssl_ctx_callback5) ||              \
00577    _curl_callback_compatible((expr), _curl_ssl_ctx_callback6) ||              \
00578    _curl_callback_compatible((expr), _curl_ssl_ctx_callback7) ||              \
00579    _curl_callback_compatible((expr), _curl_ssl_ctx_callback8))
00580 typedef CURLcode (_curl_ssl_ctx_callback1)(CURL *, void *, void *);
00581 typedef CURLcode (_curl_ssl_ctx_callback2)(CURL *, void *, const void *);
00582 typedef CURLcode (_curl_ssl_ctx_callback3)(CURL *, const void *, void *);
00583 typedef CURLcode (_curl_ssl_ctx_callback4)(CURL *, const void *, const void *);
00584 #ifdef HEADER_SSL_H
00585 /* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX
00586  * this will of course break if we're included before OpenSSL headers...
00587  */
00588 typedef CURLcode (_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *);
00589 typedef CURLcode (_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *);
00590 typedef CURLcode (_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *);
00591 typedef CURLcode (_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX,
00592                                            const void *);
00593 #else
00594 typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5;
00595 typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6;
00596 typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7;
00597 typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8;
00598 #endif
00599 
00600 /* evaluates to true if expr is of type curl_conv_callback or "similar" */
00601 #define _curl_is_conv_cb(expr)                                          \
00602   (_curl_is_NULL(expr) ||                                                     \
00603    __builtin_types_compatible_p(__typeof__(expr), curl_conv_callback) ||      \
00604    _curl_callback_compatible((expr), _curl_conv_callback1) ||                 \
00605    _curl_callback_compatible((expr), _curl_conv_callback2) ||                 \
00606    _curl_callback_compatible((expr), _curl_conv_callback3) ||                 \
00607    _curl_callback_compatible((expr), _curl_conv_callback4))
00608 typedef CURLcode (*_curl_conv_callback1)(char *, size_t length);
00609 typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length);
00610 typedef CURLcode (*_curl_conv_callback3)(void *, size_t length);
00611 typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length);
00612 
00613 /* evaluates to true if expr is of type curl_seek_callback or "similar" */
00614 #define _curl_is_seek_cb(expr)                                          \
00615   (_curl_is_NULL(expr) ||                                                     \
00616    __builtin_types_compatible_p(__typeof__(expr), curl_seek_callback) ||      \
00617    _curl_callback_compatible((expr), _curl_seek_callback1) ||                 \
00618    _curl_callback_compatible((expr), _curl_seek_callback2))
00619 typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int);
00620 typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int);
00621 
00622 
00623 #endif /* __CURL_TYPECHECK_GCC_H */


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:07