ReactOS 0.4.16-dev-1946-g52006dd
typecheck-gcc.h
Go to the documentation of this file.
1#ifndef CURLINC_TYPECHECK_GCC_H
2#define CURLINC_TYPECHECK_GCC_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26
27/* wraps curl_easy_setopt() with typechecking */
28
29/* To add a new kind of warning, add an
30 * if(curlcheck_sometype_option(_curl_opt))
31 * if(!curlcheck_sometype(value))
32 * _curl_easy_setopt_err_sometype();
33 * block and define curlcheck_sometype_option, curlcheck_sometype and
34 * _curl_easy_setopt_err_sometype below
35 *
36 * NOTE: We use two nested 'if' statements here instead of the && operator, in
37 * order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x
38 * when compiling with -Wlogical-op.
39 *
40 * To add an option that uses the same type as an existing option, you'll just
41 * need to extend the appropriate _curl_*_option macro
42 */
43#define curl_easy_setopt(handle, option, value) \
44 __extension__({ \
45 __typeof__(option) _curl_opt = option; \
46 if(__builtin_constant_p(_curl_opt)) { \
47 if(curlcheck_long_option(_curl_opt)) \
48 if(!curlcheck_long(value)) \
49 _curl_easy_setopt_err_long(); \
50 if(curlcheck_off_t_option(_curl_opt)) \
51 if(!curlcheck_off_t(value)) \
52 _curl_easy_setopt_err_curl_off_t(); \
53 if(curlcheck_string_option(_curl_opt)) \
54 if(!curlcheck_string(value)) \
55 _curl_easy_setopt_err_string(); \
56 if(curlcheck_write_cb_option(_curl_opt)) \
57 if(!curlcheck_write_cb(value)) \
58 _curl_easy_setopt_err_write_callback(); \
59 if((_curl_opt) == CURLOPT_RESOLVER_START_FUNCTION) \
60 if(!curlcheck_resolver_start_callback(value)) \
61 _curl_easy_setopt_err_resolver_start_callback(); \
62 if((_curl_opt) == CURLOPT_READFUNCTION) \
63 if(!curlcheck_read_cb(value)) \
64 _curl_easy_setopt_err_read_cb(); \
65 if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \
66 if(!curlcheck_ioctl_cb(value)) \
67 _curl_easy_setopt_err_ioctl_cb(); \
68 if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \
69 if(!curlcheck_sockopt_cb(value)) \
70 _curl_easy_setopt_err_sockopt_cb(); \
71 if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \
72 if(!curlcheck_opensocket_cb(value)) \
73 _curl_easy_setopt_err_opensocket_cb(); \
74 if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \
75 if(!curlcheck_progress_cb(value)) \
76 _curl_easy_setopt_err_progress_cb(); \
77 if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \
78 if(!curlcheck_debug_cb(value)) \
79 _curl_easy_setopt_err_debug_cb(); \
80 if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \
81 if(!curlcheck_ssl_ctx_cb(value)) \
82 _curl_easy_setopt_err_ssl_ctx_cb(); \
83 if(curlcheck_conv_cb_option(_curl_opt)) \
84 if(!curlcheck_conv_cb(value)) \
85 _curl_easy_setopt_err_conv_cb(); \
86 if((_curl_opt) == CURLOPT_SEEKFUNCTION) \
87 if(!curlcheck_seek_cb(value)) \
88 _curl_easy_setopt_err_seek_cb(); \
89 if(curlcheck_cb_data_option(_curl_opt)) \
90 if(!curlcheck_cb_data(value)) \
91 _curl_easy_setopt_err_cb_data(); \
92 if((_curl_opt) == CURLOPT_ERRORBUFFER) \
93 if(!curlcheck_error_buffer(value)) \
94 _curl_easy_setopt_err_error_buffer(); \
95 if((_curl_opt) == CURLOPT_STDERR) \
96 if(!curlcheck_FILE(value)) \
97 _curl_easy_setopt_err_FILE(); \
98 if(curlcheck_postfields_option(_curl_opt)) \
99 if(!curlcheck_postfields(value)) \
100 _curl_easy_setopt_err_postfields(); \
101 if((_curl_opt) == CURLOPT_HTTPPOST) \
102 if(!curlcheck_arr((value), struct curl_httppost)) \
103 _curl_easy_setopt_err_curl_httpost(); \
104 if((_curl_opt) == CURLOPT_MIMEPOST) \
105 if(!curlcheck_ptr((value), curl_mime)) \
106 _curl_easy_setopt_err_curl_mimepost(); \
107 if(curlcheck_slist_option(_curl_opt)) \
108 if(!curlcheck_arr((value), struct curl_slist)) \
109 _curl_easy_setopt_err_curl_slist(); \
110 if((_curl_opt) == CURLOPT_SHARE) \
111 if(!curlcheck_ptr((value), CURLSH)) \
112 _curl_easy_setopt_err_CURLSH(); \
113 } \
114 curl_easy_setopt(handle, _curl_opt, value); \
115 })
116
117/* wraps curl_easy_getinfo() with typechecking */
118#define curl_easy_getinfo(handle, info, arg) \
119 __extension__({ \
120 __typeof__(info) _curl_info = info; \
121 if(__builtin_constant_p(_curl_info)) { \
122 if(curlcheck_string_info(_curl_info)) \
123 if(!curlcheck_arr((arg), char *)) \
124 _curl_easy_getinfo_err_string(); \
125 if(curlcheck_long_info(_curl_info)) \
126 if(!curlcheck_arr((arg), long)) \
127 _curl_easy_getinfo_err_long(); \
128 if(curlcheck_double_info(_curl_info)) \
129 if(!curlcheck_arr((arg), double)) \
130 _curl_easy_getinfo_err_double(); \
131 if(curlcheck_slist_info(_curl_info)) \
132 if(!curlcheck_arr((arg), struct curl_slist *)) \
133 _curl_easy_getinfo_err_curl_slist(); \
134 if(curlcheck_tlssessioninfo_info(_curl_info)) \
135 if(!curlcheck_arr((arg), struct curl_tlssessioninfo *)) \
136 _curl_easy_getinfo_err_curl_tlssesssioninfo(); \
137 if(curlcheck_certinfo_info(_curl_info)) \
138 if(!curlcheck_arr((arg), struct curl_certinfo *)) \
139 _curl_easy_getinfo_err_curl_certinfo(); \
140 if(curlcheck_socket_info(_curl_info)) \
141 if(!curlcheck_arr((arg), curl_socket_t)) \
142 _curl_easy_getinfo_err_curl_socket(); \
143 if(curlcheck_off_t_info(_curl_info)) \
144 if(!curlcheck_arr((arg), curl_off_t)) \
145 _curl_easy_getinfo_err_curl_off_t(); \
146 } \
147 curl_easy_getinfo(handle, _curl_info, arg); \
148 })
149
150/*
151 * For now, just make sure that the functions are called with three arguments
152 */
153#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
154#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)
155
156
157/* the actual warnings, triggered by calling the _curl_easy_setopt_err*
158 * functions */
159
160/* To define a new warning, use _CURL_WARNING(identifier, "message") */
161#define CURLWARNING(id, message) \
162 static void __attribute__((__warning__(message))) \
163 __attribute__((__unused__)) __attribute__((__noinline__)) \
164 id(void) { __asm__(""); }
165
166CURLWARNING(_curl_easy_setopt_err_long,
167 "curl_easy_setopt expects a long argument for this option")
168CURLWARNING(_curl_easy_setopt_err_curl_off_t,
169 "curl_easy_setopt expects a curl_off_t argument for this option")
170CURLWARNING(_curl_easy_setopt_err_string,
171 "curl_easy_setopt expects a "
172 "string ('char *' or char[]) argument for this option"
173 )
174CURLWARNING(_curl_easy_setopt_err_write_callback,
175 "curl_easy_setopt expects a curl_write_callback argument for this option")
176CURLWARNING(_curl_easy_setopt_err_resolver_start_callback,
177 "curl_easy_setopt expects a "
179 )
180CURLWARNING(_curl_easy_setopt_err_read_cb,
181 "curl_easy_setopt expects a curl_read_callback argument for this option")
182CURLWARNING(_curl_easy_setopt_err_ioctl_cb,
183 "curl_easy_setopt expects a curl_ioctl_callback argument for this option")
184CURLWARNING(_curl_easy_setopt_err_sockopt_cb,
185 "curl_easy_setopt expects a curl_sockopt_callback argument for this option")
186CURLWARNING(_curl_easy_setopt_err_opensocket_cb,
187 "curl_easy_setopt expects a "
188 "curl_opensocket_callback argument for this option"
189 )
190CURLWARNING(_curl_easy_setopt_err_progress_cb,
191 "curl_easy_setopt expects a curl_progress_callback argument for this option")
192CURLWARNING(_curl_easy_setopt_err_debug_cb,
193 "curl_easy_setopt expects a curl_debug_callback argument for this option")
194CURLWARNING(_curl_easy_setopt_err_ssl_ctx_cb,
195 "curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option")
196CURLWARNING(_curl_easy_setopt_err_conv_cb,
197 "curl_easy_setopt expects a curl_conv_callback argument for this option")
198CURLWARNING(_curl_easy_setopt_err_seek_cb,
199 "curl_easy_setopt expects a curl_seek_callback argument for this option")
200CURLWARNING(_curl_easy_setopt_err_cb_data,
201 "curl_easy_setopt expects a "
202 "private data pointer as argument for this option")
203CURLWARNING(_curl_easy_setopt_err_error_buffer,
204 "curl_easy_setopt expects a "
205 "char buffer of CURL_ERROR_SIZE as argument for this option")
206CURLWARNING(_curl_easy_setopt_err_FILE,
207 "curl_easy_setopt expects a 'FILE *' argument for this option")
208CURLWARNING(_curl_easy_setopt_err_postfields,
209 "curl_easy_setopt expects a 'void *' or 'char *' argument for this option")
210CURLWARNING(_curl_easy_setopt_err_curl_httpost,
212 "argument for this option")
213CURLWARNING(_curl_easy_setopt_err_curl_mimepost,
214 "curl_easy_setopt expects a 'curl_mime *' "
215 "argument for this option")
216CURLWARNING(_curl_easy_setopt_err_curl_slist,
217 "curl_easy_setopt expects a 'struct curl_slist *' argument for this option")
218CURLWARNING(_curl_easy_setopt_err_CURLSH,
219 "curl_easy_setopt expects a CURLSH* argument for this option")
220
221CURLWARNING(_curl_easy_getinfo_err_string,
222 "curl_easy_getinfo expects a pointer to 'char *' for this info")
223CURLWARNING(_curl_easy_getinfo_err_long,
224 "curl_easy_getinfo expects a pointer to long for this info")
225CURLWARNING(_curl_easy_getinfo_err_double,
226 "curl_easy_getinfo expects a pointer to double for this info")
227CURLWARNING(_curl_easy_getinfo_err_curl_slist,
228 "curl_easy_getinfo expects a pointer to 'struct curl_slist *' for this info")
229CURLWARNING(_curl_easy_getinfo_err_curl_tlssesssioninfo,
230 "curl_easy_getinfo expects a pointer to "
232CURLWARNING(_curl_easy_getinfo_err_curl_certinfo,
233 "curl_easy_getinfo expects a pointer to "
234 "'struct curl_certinfo *' for this info")
235CURLWARNING(_curl_easy_getinfo_err_curl_socket,
237CURLWARNING(_curl_easy_getinfo_err_curl_off_t,
238 "curl_easy_getinfo expects a pointer to curl_off_t for this info")
239
240/* groups of curl_easy_setops options that take the same type of argument */
241
242/* To add a new option to one of the groups, just add
243 * (option) == CURLOPT_SOMETHING
244 * to the or-expression. If the option takes a long or curl_off_t, you don't
245 * have to do anything
246 */
247
248/* evaluates to true if option takes a long argument */
249#define curlcheck_long_option(option) \
250 (0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
251
252#define curlcheck_off_t_option(option) \
253 (((option) > CURLOPTTYPE_OFF_T) && ((option) < CURLOPTTYPE_BLOB))
254
255/* evaluates to true if option takes a char* argument */
256#define curlcheck_string_option(option) \
257 ((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \
258 (option) == CURLOPT_ACCEPT_ENCODING || \
259 (option) == CURLOPT_ALTSVC || \
260 (option) == CURLOPT_CAINFO || \
261 (option) == CURLOPT_CAPATH || \
262 (option) == CURLOPT_COOKIE || \
263 (option) == CURLOPT_COOKIEFILE || \
264 (option) == CURLOPT_COOKIEJAR || \
265 (option) == CURLOPT_COOKIELIST || \
266 (option) == CURLOPT_CRLFILE || \
267 (option) == CURLOPT_CUSTOMREQUEST || \
268 (option) == CURLOPT_DEFAULT_PROTOCOL || \
269 (option) == CURLOPT_DNS_INTERFACE || \
270 (option) == CURLOPT_DNS_LOCAL_IP4 || \
271 (option) == CURLOPT_DNS_LOCAL_IP6 || \
272 (option) == CURLOPT_DNS_SERVERS || \
273 (option) == CURLOPT_DOH_URL || \
274 (option) == CURLOPT_EGDSOCKET || \
275 (option) == CURLOPT_FTPPORT || \
276 (option) == CURLOPT_FTP_ACCOUNT || \
277 (option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \
278 (option) == CURLOPT_HSTS || \
279 (option) == CURLOPT_INTERFACE || \
280 (option) == CURLOPT_ISSUERCERT || \
281 (option) == CURLOPT_KEYPASSWD || \
282 (option) == CURLOPT_KRBLEVEL || \
283 (option) == CURLOPT_LOGIN_OPTIONS || \
284 (option) == CURLOPT_MAIL_AUTH || \
285 (option) == CURLOPT_MAIL_FROM || \
286 (option) == CURLOPT_NETRC_FILE || \
287 (option) == CURLOPT_NOPROXY || \
288 (option) == CURLOPT_PASSWORD || \
289 (option) == CURLOPT_PINNEDPUBLICKEY || \
290 (option) == CURLOPT_PRE_PROXY || \
291 (option) == CURLOPT_PROXY || \
292 (option) == CURLOPT_PROXYPASSWORD || \
293 (option) == CURLOPT_PROXYUSERNAME || \
294 (option) == CURLOPT_PROXYUSERPWD || \
295 (option) == CURLOPT_PROXY_CAINFO || \
296 (option) == CURLOPT_PROXY_CAPATH || \
297 (option) == CURLOPT_PROXY_CRLFILE || \
298 (option) == CURLOPT_PROXY_ISSUERCERT || \
299 (option) == CURLOPT_PROXY_KEYPASSWD || \
300 (option) == CURLOPT_PROXY_PINNEDPUBLICKEY || \
301 (option) == CURLOPT_PROXY_SERVICE_NAME || \
302 (option) == CURLOPT_PROXY_SSLCERT || \
303 (option) == CURLOPT_PROXY_SSLCERTTYPE || \
304 (option) == CURLOPT_PROXY_SSLKEY || \
305 (option) == CURLOPT_PROXY_SSLKEYTYPE || \
306 (option) == CURLOPT_PROXY_SSL_CIPHER_LIST || \
307 (option) == CURLOPT_PROXY_TLS13_CIPHERS || \
308 (option) == CURLOPT_PROXY_TLSAUTH_PASSWORD || \
309 (option) == CURLOPT_PROXY_TLSAUTH_TYPE || \
310 (option) == CURLOPT_PROXY_TLSAUTH_USERNAME || \
311 (option) == CURLOPT_RANDOM_FILE || \
312 (option) == CURLOPT_RANGE || \
313 (option) == CURLOPT_REFERER || \
314 (option) == CURLOPT_REQUEST_TARGET || \
315 (option) == CURLOPT_RTSP_SESSION_ID || \
316 (option) == CURLOPT_RTSP_STREAM_URI || \
317 (option) == CURLOPT_RTSP_TRANSPORT || \
318 (option) == CURLOPT_SASL_AUTHZID || \
319 (option) == CURLOPT_SERVICE_NAME || \
320 (option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \
321 (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \
322 (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 || \
323 (option) == CURLOPT_SSH_KNOWNHOSTS || \
324 (option) == CURLOPT_SSH_PRIVATE_KEYFILE || \
325 (option) == CURLOPT_SSH_PUBLIC_KEYFILE || \
326 (option) == CURLOPT_SSLCERT || \
327 (option) == CURLOPT_SSLCERTTYPE || \
328 (option) == CURLOPT_SSLENGINE || \
329 (option) == CURLOPT_SSLKEY || \
330 (option) == CURLOPT_SSLKEYTYPE || \
331 (option) == CURLOPT_SSL_CIPHER_LIST || \
332 (option) == CURLOPT_TLS13_CIPHERS || \
333 (option) == CURLOPT_TLSAUTH_PASSWORD || \
334 (option) == CURLOPT_TLSAUTH_TYPE || \
335 (option) == CURLOPT_TLSAUTH_USERNAME || \
336 (option) == CURLOPT_UNIX_SOCKET_PATH || \
337 (option) == CURLOPT_URL || \
338 (option) == CURLOPT_USERAGENT || \
339 (option) == CURLOPT_USERNAME || \
340 (option) == CURLOPT_AWS_SIGV4 || \
341 (option) == CURLOPT_USERPWD || \
342 (option) == CURLOPT_XOAUTH2_BEARER || \
343 (option) == CURLOPT_SSL_EC_CURVES || \
344 0)
345
346/* evaluates to true if option takes a curl_write_callback argument */
347#define curlcheck_write_cb_option(option) \
348 ((option) == CURLOPT_HEADERFUNCTION || \
349 (option) == CURLOPT_WRITEFUNCTION)
350
351/* evaluates to true if option takes a curl_conv_callback argument */
352#define curlcheck_conv_cb_option(option) \
353 ((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \
354 (option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \
355 (option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)
356
357/* evaluates to true if option takes a data argument to pass to a callback */
358#define curlcheck_cb_data_option(option) \
359 ((option) == CURLOPT_CHUNK_DATA || \
360 (option) == CURLOPT_CLOSESOCKETDATA || \
361 (option) == CURLOPT_DEBUGDATA || \
362 (option) == CURLOPT_FNMATCH_DATA || \
363 (option) == CURLOPT_HEADERDATA || \
364 (option) == CURLOPT_HSTSREADDATA || \
365 (option) == CURLOPT_HSTSWRITEDATA || \
366 (option) == CURLOPT_INTERLEAVEDATA || \
367 (option) == CURLOPT_IOCTLDATA || \
368 (option) == CURLOPT_OPENSOCKETDATA || \
369 (option) == CURLOPT_PREREQDATA || \
370 (option) == CURLOPT_PROGRESSDATA || \
371 (option) == CURLOPT_READDATA || \
372 (option) == CURLOPT_SEEKDATA || \
373 (option) == CURLOPT_SOCKOPTDATA || \
374 (option) == CURLOPT_SSH_KEYDATA || \
375 (option) == CURLOPT_SSL_CTX_DATA || \
376 (option) == CURLOPT_WRITEDATA || \
377 (option) == CURLOPT_RESOLVER_START_DATA || \
378 (option) == CURLOPT_TRAILERDATA || \
379 (option) == CURLOPT_SSH_HOSTKEYDATA || \
380 0)
381
382/* evaluates to true if option takes a POST data argument (void* or char*) */
383#define curlcheck_postfields_option(option) \
384 ((option) == CURLOPT_POSTFIELDS || \
385 (option) == CURLOPT_COPYPOSTFIELDS || \
386 0)
387
388/* evaluates to true if option takes a struct curl_slist * argument */
389#define curlcheck_slist_option(option) \
390 ((option) == CURLOPT_HTTP200ALIASES || \
391 (option) == CURLOPT_HTTPHEADER || \
392 (option) == CURLOPT_MAIL_RCPT || \
393 (option) == CURLOPT_POSTQUOTE || \
394 (option) == CURLOPT_PREQUOTE || \
395 (option) == CURLOPT_PROXYHEADER || \
396 (option) == CURLOPT_QUOTE || \
397 (option) == CURLOPT_RESOLVE || \
398 (option) == CURLOPT_TELNETOPTIONS || \
399 (option) == CURLOPT_CONNECT_TO || \
400 0)
401
402/* groups of curl_easy_getinfo infos that take the same type of argument */
403
404/* evaluates to true if info expects a pointer to char * argument */
405#define curlcheck_string_info(info) \
406 (CURLINFO_STRING < (info) && (info) < CURLINFO_LONG && \
407 (info) != CURLINFO_PRIVATE)
408
409/* evaluates to true if info expects a pointer to long argument */
410#define curlcheck_long_info(info) \
411 (CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)
412
413/* evaluates to true if info expects a pointer to double argument */
414#define curlcheck_double_info(info) \
415 (CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)
416
417/* true if info expects a pointer to struct curl_slist * argument */
418#define curlcheck_slist_info(info) \
419 (((info) == CURLINFO_SSL_ENGINES) || ((info) == CURLINFO_COOKIELIST))
420
421/* true if info expects a pointer to struct curl_tlssessioninfo * argument */
422#define curlcheck_tlssessioninfo_info(info) \
423 (((info) == CURLINFO_TLS_SSL_PTR) || ((info) == CURLINFO_TLS_SESSION))
424
425/* true if info expects a pointer to struct curl_certinfo * argument */
426#define curlcheck_certinfo_info(info) ((info) == CURLINFO_CERTINFO)
427
428/* true if info expects a pointer to struct curl_socket_t argument */
429#define curlcheck_socket_info(info) \
430 (CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T)
431
432/* true if info expects a pointer to curl_off_t argument */
433#define curlcheck_off_t_info(info) \
434 (CURLINFO_OFF_T < (info))
435
436
437/* typecheck helpers -- check whether given expression has requested type*/
438
439/* For pointers, you can use the curlcheck_ptr/curlcheck_arr macros,
440 * otherwise define a new macro. Search for __builtin_types_compatible_p
441 * in the GCC manual.
442 * NOTE: these macros MUST NOT EVALUATE their arguments! The argument is
443 * the actual expression passed to the curl_easy_setopt macro. This
444 * means that you can only apply the sizeof and __typeof__ operators, no
445 * == or whatsoever.
446 */
447
448/* XXX: should evaluate to true if expr is a pointer */
449#define curlcheck_any_ptr(expr) \
450 (sizeof(expr) == sizeof(void *))
451
452/* evaluates to true if expr is NULL */
453/* XXX: must not evaluate expr, so this check is not accurate */
454#define curlcheck_NULL(expr) \
455 (__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))
456
457/* evaluates to true if expr is type*, const type* or NULL */
458#define curlcheck_ptr(expr, type) \
459 (curlcheck_NULL(expr) || \
460 __builtin_types_compatible_p(__typeof__(expr), type *) || \
461 __builtin_types_compatible_p(__typeof__(expr), const type *))
462
463/* evaluates to true if expr is one of type[], type*, NULL or const type* */
464#define curlcheck_arr(expr, type) \
465 (curlcheck_ptr((expr), type) || \
466 __builtin_types_compatible_p(__typeof__(expr), type []))
467
468/* evaluates to true if expr is a string */
469#define curlcheck_string(expr) \
470 (curlcheck_arr((expr), char) || \
471 curlcheck_arr((expr), signed char) || \
472 curlcheck_arr((expr), unsigned char))
473
474/* evaluates to true if expr is a long (no matter the signedness)
475 * XXX: for now, int is also accepted (and therefore short and char, which
476 * are promoted to int when passed to a variadic function) */
477#define curlcheck_long(expr) \
478 (__builtin_types_compatible_p(__typeof__(expr), long) || \
479 __builtin_types_compatible_p(__typeof__(expr), signed long) || \
480 __builtin_types_compatible_p(__typeof__(expr), unsigned long) || \
481 __builtin_types_compatible_p(__typeof__(expr), int) || \
482 __builtin_types_compatible_p(__typeof__(expr), signed int) || \
483 __builtin_types_compatible_p(__typeof__(expr), unsigned int) || \
484 __builtin_types_compatible_p(__typeof__(expr), short) || \
485 __builtin_types_compatible_p(__typeof__(expr), signed short) || \
486 __builtin_types_compatible_p(__typeof__(expr), unsigned short) || \
487 __builtin_types_compatible_p(__typeof__(expr), char) || \
488 __builtin_types_compatible_p(__typeof__(expr), signed char) || \
489 __builtin_types_compatible_p(__typeof__(expr), unsigned char))
490
491/* evaluates to true if expr is of type curl_off_t */
492#define curlcheck_off_t(expr) \
493 (__builtin_types_compatible_p(__typeof__(expr), curl_off_t))
494
495/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
496/* XXX: also check size of an char[] array? */
497#define curlcheck_error_buffer(expr) \
498 (curlcheck_NULL(expr) || \
499 __builtin_types_compatible_p(__typeof__(expr), char *) || \
500 __builtin_types_compatible_p(__typeof__(expr), char[]))
501
502/* evaluates to true if expr is of type (const) void* or (const) FILE* */
503#if 0
504#define curlcheck_cb_data(expr) \
505 (curlcheck_ptr((expr), void) || \
506 curlcheck_ptr((expr), FILE))
507#else /* be less strict */
508#define curlcheck_cb_data(expr) \
509 curlcheck_any_ptr(expr)
510#endif
511
512/* evaluates to true if expr is of type FILE* */
513#define curlcheck_FILE(expr) \
514 (curlcheck_NULL(expr) || \
515 (__builtin_types_compatible_p(__typeof__(expr), FILE *)))
516
517/* evaluates to true if expr can be passed as POST data (void* or char*) */
518#define curlcheck_postfields(expr) \
519 (curlcheck_ptr((expr), void) || \
520 curlcheck_arr((expr), char) || \
521 curlcheck_arr((expr), unsigned char))
522
523/* helper: __builtin_types_compatible_p distinguishes between functions and
524 * function pointers, hide it */
525#define curlcheck_cb_compatible(func, type) \
526 (__builtin_types_compatible_p(__typeof__(func), type) || \
527 __builtin_types_compatible_p(__typeof__(func) *, type))
528
529/* evaluates to true if expr is of type curl_resolver_start_callback */
530#define curlcheck_resolver_start_callback(expr) \
531 (curlcheck_NULL(expr) || \
532 curlcheck_cb_compatible((expr), curl_resolver_start_callback))
533
534/* evaluates to true if expr is of type curl_read_callback or "similar" */
535#define curlcheck_read_cb(expr) \
536 (curlcheck_NULL(expr) || \
537 curlcheck_cb_compatible((expr), __typeof__(fread) *) || \
538 curlcheck_cb_compatible((expr), curl_read_callback) || \
539 curlcheck_cb_compatible((expr), _curl_read_callback1) || \
540 curlcheck_cb_compatible((expr), _curl_read_callback2) || \
541 curlcheck_cb_compatible((expr), _curl_read_callback3) || \
542 curlcheck_cb_compatible((expr), _curl_read_callback4) || \
543 curlcheck_cb_compatible((expr), _curl_read_callback5) || \
544 curlcheck_cb_compatible((expr), _curl_read_callback6))
545typedef size_t (*_curl_read_callback1)(char *, size_t, size_t, void *);
546typedef size_t (*_curl_read_callback2)(char *, size_t, size_t, const void *);
548typedef size_t (*_curl_read_callback4)(void *, size_t, size_t, void *);
549typedef size_t (*_curl_read_callback5)(void *, size_t, size_t, const void *);
551
552/* evaluates to true if expr is of type curl_write_callback or "similar" */
553#define curlcheck_write_cb(expr) \
554 (curlcheck_read_cb(expr) || \
555 curlcheck_cb_compatible((expr), __typeof__(fwrite) *) || \
556 curlcheck_cb_compatible((expr), curl_write_callback) || \
557 curlcheck_cb_compatible((expr), _curl_write_callback1) || \
558 curlcheck_cb_compatible((expr), _curl_write_callback2) || \
559 curlcheck_cb_compatible((expr), _curl_write_callback3) || \
560 curlcheck_cb_compatible((expr), _curl_write_callback4) || \
561 curlcheck_cb_compatible((expr), _curl_write_callback5) || \
562 curlcheck_cb_compatible((expr), _curl_write_callback6))
563typedef size_t (*_curl_write_callback1)(const char *, size_t, size_t, void *);
564typedef size_t (*_curl_write_callback2)(const char *, size_t, size_t,
565 const void *);
566typedef size_t (*_curl_write_callback3)(const char *, size_t, size_t, FILE *);
567typedef size_t (*_curl_write_callback4)(const void *, size_t, size_t, void *);
568typedef size_t (*_curl_write_callback5)(const void *, size_t, size_t,
569 const void *);
570typedef size_t (*_curl_write_callback6)(const void *, size_t, size_t, FILE *);
571
572/* evaluates to true if expr is of type curl_ioctl_callback or "similar" */
573#define curlcheck_ioctl_cb(expr) \
574 (curlcheck_NULL(expr) || \
575 curlcheck_cb_compatible((expr), curl_ioctl_callback) || \
576 curlcheck_cb_compatible((expr), _curl_ioctl_callback1) || \
577 curlcheck_cb_compatible((expr), _curl_ioctl_callback2) || \
578 curlcheck_cb_compatible((expr), _curl_ioctl_callback3) || \
579 curlcheck_cb_compatible((expr), _curl_ioctl_callback4))
581typedef curlioerr (*_curl_ioctl_callback2)(CURL *, int, const void *);
583typedef curlioerr (*_curl_ioctl_callback4)(CURL *, curliocmd, const void *);
584
585/* evaluates to true if expr is of type curl_sockopt_callback or "similar" */
586#define curlcheck_sockopt_cb(expr) \
587 (curlcheck_NULL(expr) || \
588 curlcheck_cb_compatible((expr), curl_sockopt_callback) || \
589 curlcheck_cb_compatible((expr), _curl_sockopt_callback1) || \
590 curlcheck_cb_compatible((expr), _curl_sockopt_callback2))
594
595/* evaluates to true if expr is of type curl_opensocket_callback or
596 "similar" */
597#define curlcheck_opensocket_cb(expr) \
598 (curlcheck_NULL(expr) || \
599 curlcheck_cb_compatible((expr), curl_opensocket_callback) || \
600 curlcheck_cb_compatible((expr), _curl_opensocket_callback1) || \
601 curlcheck_cb_compatible((expr), _curl_opensocket_callback2) || \
602 curlcheck_cb_compatible((expr), _curl_opensocket_callback3) || \
603 curlcheck_cb_compatible((expr), _curl_opensocket_callback4))
605 (void *, curlsocktype, struct curl_sockaddr *);
607 (void *, curlsocktype, const struct curl_sockaddr *);
609 (const void *, curlsocktype, struct curl_sockaddr *);
611 (const void *, curlsocktype, const struct curl_sockaddr *);
612
613/* evaluates to true if expr is of type curl_progress_callback or "similar" */
614#define curlcheck_progress_cb(expr) \
615 (curlcheck_NULL(expr) || \
616 curlcheck_cb_compatible((expr), curl_progress_callback) || \
617 curlcheck_cb_compatible((expr), _curl_progress_callback1) || \
618 curlcheck_cb_compatible((expr), _curl_progress_callback2))
621typedef int (*_curl_progress_callback2)(const void *,
623
624/* evaluates to true if expr is of type curl_debug_callback or "similar" */
625#define curlcheck_debug_cb(expr) \
626 (curlcheck_NULL(expr) || \
627 curlcheck_cb_compatible((expr), curl_debug_callback) || \
628 curlcheck_cb_compatible((expr), _curl_debug_callback1) || \
629 curlcheck_cb_compatible((expr), _curl_debug_callback2) || \
630 curlcheck_cb_compatible((expr), _curl_debug_callback3) || \
631 curlcheck_cb_compatible((expr), _curl_debug_callback4) || \
632 curlcheck_cb_compatible((expr), _curl_debug_callback5) || \
633 curlcheck_cb_compatible((expr), _curl_debug_callback6) || \
634 curlcheck_cb_compatible((expr), _curl_debug_callback7) || \
635 curlcheck_cb_compatible((expr), _curl_debug_callback8))
637 curl_infotype, char *, size_t, void *);
639 curl_infotype, char *, size_t, const void *);
641 curl_infotype, const char *, size_t, void *);
643 curl_infotype, const char *, size_t, const void *);
645 curl_infotype, unsigned char *, size_t, void *);
647 curl_infotype, unsigned char *, size_t, const void *);
649 curl_infotype, const unsigned char *, size_t, void *);
651 curl_infotype, const unsigned char *, size_t, const void *);
652
653/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
654/* this is getting even messier... */
655#define curlcheck_ssl_ctx_cb(expr) \
656 (curlcheck_NULL(expr) || \
657 curlcheck_cb_compatible((expr), curl_ssl_ctx_callback) || \
658 curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback1) || \
659 curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback2) || \
660 curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback3) || \
661 curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback4) || \
662 curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback5) || \
663 curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback6) || \
664 curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback7) || \
665 curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback8))
666typedef CURLcode (*_curl_ssl_ctx_callback1)(CURL *, void *, void *);
667typedef CURLcode (*_curl_ssl_ctx_callback2)(CURL *, void *, const void *);
668typedef CURLcode (*_curl_ssl_ctx_callback3)(CURL *, const void *, void *);
669typedef CURLcode (*_curl_ssl_ctx_callback4)(CURL *, const void *,
670 const void *);
671#ifdef HEADER_SSL_H
672/* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX
673 * this will of course break if we're included before OpenSSL headers...
674 */
675typedef CURLcode (*_curl_ssl_ctx_callback5)(CURL *, SSL_CTX *, void *);
676typedef CURLcode (*_curl_ssl_ctx_callback6)(CURL *, SSL_CTX *, const void *);
677typedef CURLcode (*_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX *, void *);
678typedef CURLcode (*_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX *,
679 const void *);
680#else
685#endif
686
687/* evaluates to true if expr is of type curl_conv_callback or "similar" */
688#define curlcheck_conv_cb(expr) \
689 (curlcheck_NULL(expr) || \
690 curlcheck_cb_compatible((expr), curl_conv_callback) || \
691 curlcheck_cb_compatible((expr), _curl_conv_callback1) || \
692 curlcheck_cb_compatible((expr), _curl_conv_callback2) || \
693 curlcheck_cb_compatible((expr), _curl_conv_callback3) || \
694 curlcheck_cb_compatible((expr), _curl_conv_callback4))
695typedef CURLcode (*_curl_conv_callback1)(char *, size_t length);
696typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length);
697typedef CURLcode (*_curl_conv_callback3)(void *, size_t length);
698typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length);
699
700/* evaluates to true if expr is of type curl_seek_callback or "similar" */
701#define curlcheck_seek_cb(expr) \
702 (curlcheck_NULL(expr) || \
703 curlcheck_cb_compatible((expr), curl_seek_callback) || \
704 curlcheck_cb_compatible((expr), _curl_seek_callback1) || \
705 curlcheck_cb_compatible((expr), _curl_seek_callback2))
707typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int);
708
709
710#endif /* CURLINC_TYPECHECK_GCC_H */
curl_socket_t(* curl_opensocket_callback)(void *clientp, curlsocktype purpose, struct curl_sockaddr *address)
Definition: curl.h:410
curliocmd
Definition: curl.h:424
int(* curl_sockopt_callback)(void *clientp, curl_socket_t curlfd, curlsocktype purpose)
Definition: curl.h:395
size_t(* curl_read_callback)(char *buffer, size_t size, size_t nitems, void *instream)
Definition: curl.h:375
int(* curl_seek_callback)(void *instream, curl_off_t offset, int origin)
Definition: curl.h:357
curl_infotype
Definition: curl.h:451
#define CURL_ERROR_SIZE
Definition: curl.h:815
int(* curl_resolver_start_callback)(void *resolver_state, void *reserved, void *userdata)
Definition: curl.h:264
CURLcode(* curl_conv_callback)(char *buffer, size_t length)
Definition: curl.h:742
size_t(* curl_write_callback)(char *buffer, size_t size, size_t nitems, void *outstream)
Definition: curl.h:258
struct curl_mime curl_mime
Definition: curl.h:2299
int(* curl_debug_callback)(CURL *handle, curl_infotype type, char *data, size_t size, void *userptr)
Definition: curl.h:463
int curl_socket_t
Definition: curl.h:133
curlioerr(* curl_ioctl_callback)(CURL *handle, int cmd, void *clientp)
Definition: curl.h:430
curlsocktype
Definition: curl.h:383
curlioerr
Definition: curl.h:417
CURLcode
Definition: curl.h:490
int(* curl_progress_callback)(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
Definition: curl.h:217
CURLcode(* curl_ssl_ctx_callback)(CURL *curl, void *ssl_ctx, void *userptr)
Definition: curl.h:744
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
__kernel_size_t size_t
Definition: linux.h:237
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint buffer
Definition: glext.h:5915
GLsizei const GLvoid * pointer
Definition: glext.h:5848
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define for
Definition: utility.h:88
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:91
Definition: getopt.h:109
CURL_TYPEOF_CURL_OFF_T curl_off_t
Definition: system.h:439
curlioerr(* _curl_ioctl_callback4)(CURL *, curliocmd, const void *)
CURLcode(* _curl_conv_callback2)(const char *, size_t length)
curl_socket_t(* _curl_opensocket_callback3)(const void *, curlsocktype, struct curl_sockaddr *)
int(* _curl_debug_callback7)(CURL *, curl_infotype, const unsigned char *, size_t, void *)
size_t(* _curl_read_callback6)(void *, size_t, size_t, FILE *)
int(* _curl_debug_callback2)(CURL *, curl_infotype, char *, size_t, const void *)
size_t(* _curl_write_callback6)(const void *, size_t, size_t, FILE *)
size_t(* _curl_write_callback4)(const void *, size_t, size_t, void *)
size_t(* _curl_write_callback5)(const void *, size_t, size_t, const void *)
int(* _curl_debug_callback3)(CURL *, curl_infotype, const char *, size_t, void *)
CURLcode(* _curl_ssl_ctx_callback3)(CURL *, const void *, void *)
curlioerr(* _curl_ioctl_callback3)(CURL *, curliocmd, void *)
size_t(* _curl_read_callback2)(char *, size_t, size_t, const void *)
size_t(* _curl_write_callback1)(const char *, size_t, size_t, void *)
_curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6
curl_socket_t(* _curl_opensocket_callback2)(void *, curlsocktype, const struct curl_sockaddr *)
CURLcode(* _curl_seek_callback2)(const void *, curl_off_t, int)
CURLcode(* _curl_ssl_ctx_callback1)(CURL *, void *, void *)
int(* _curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype)
int(* _curl_debug_callback4)(CURL *, curl_infotype, const char *, size_t, const void *)
curl_socket_t(* _curl_opensocket_callback1)(void *, curlsocktype, struct curl_sockaddr *)
size_t(* _curl_read_callback3)(char *, size_t, size_t, FILE *)
CURLcode(* _curl_conv_callback3)(void *, size_t length)
size_t(* _curl_write_callback3)(const char *, size_t, size_t, FILE *)
int(* _curl_debug_callback6)(CURL *, curl_infotype, unsigned char *, size_t, const void *)
int(* _curl_debug_callback1)(CURL *, curl_infotype, char *, size_t, void *)
int(* _curl_progress_callback2)(const void *, double, double, double, double)
#define curl_easy_getinfo(handle, info, arg)
int(* _curl_debug_callback8)(CURL *, curl_infotype, const unsigned char *, size_t, const void *)
curlioerr(* _curl_ioctl_callback2)(CURL *, int, const void *)
size_t(* _curl_read_callback5)(void *, size_t, size_t, const void *)
size_t(* _curl_read_callback1)(char *, size_t, size_t, void *)
size_t(* _curl_read_callback4)(void *, size_t, size_t, void *)
_curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5
CURLcode(* _curl_ssl_ctx_callback2)(CURL *, void *, const void *)
CURLcode(* _curl_conv_callback4)(const void *, size_t length)
CURLcode(* _curl_ssl_ctx_callback4)(CURL *, const void *, const void *)
size_t(* _curl_write_callback2)(const char *, size_t, size_t, const void *)
int(* _curl_sockopt_callback2)(const void *, curl_socket_t, curlsocktype)
int(* _curl_progress_callback1)(void *, double, double, double, double)
#define CURLWARNING(id, message)
CURLcode(* _curl_seek_callback1)(void *, curl_off_t, int)
curl_socket_t(* _curl_opensocket_callback4)(const void *, curlsocktype, const struct curl_sockaddr *)
CURLcode(* _curl_conv_callback1)(char *, size_t length)
_curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7
curlioerr(* _curl_ioctl_callback1)(CURL *, int, void *)
_curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8
#define curl_easy_setopt(handle, option, value)
Definition: typecheck-gcc.h:43
int(* _curl_debug_callback5)(CURL *, curl_infotype, unsigned char *, size_t, void *)