source: asp3_tinet_ecnl_arm/trunk/curl-7.57.0/include/curl/typecheck-gcc.h@ 352

Last change on this file since 352 was 352, checked in by coas-nagasima, 6 years ago

arm向けASP3版ECNLを追加

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