Install curl-7.21.1.tar.bz2
[msysgit.git] / mingw / include / curl / typecheck-gcc.h
blob62883f567f5e31fda4d74897dc2ae0655aed07fd
1 #ifndef __CURL_TYPECHECK_GCC_H
2 #define __CURL_TYPECHECK_GCC_H
3 /***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
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 http://curl.haxx.se/docs/copyright.html.
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.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ***************************************************************************/
25 /* wraps curl_easy_setopt() with typechecking */
27 /* To add a new kind of warning, add an
28 * if(_curl_is_sometype_option(_curl_opt) && ! _curl_is_sometype(value))
29 * _curl_easy_setopt_err_sometype();
30 * block and define _curl_is_sometype_option, _curl_is_sometype and
31 * _curl_easy_setopt_err_sometype below
33 * To add an option that uses the same type as an existing option, you'll just
34 * need to extend the appropriate _curl_*_option macro
36 #define curl_easy_setopt(handle, option, value) \
37 __extension__ ({ \
38 __typeof__ (option) _curl_opt = option; \
39 if (__builtin_constant_p(_curl_opt)) { \
40 if (_curl_is_long_option(_curl_opt) && !_curl_is_long(value)) \
41 _curl_easy_setopt_err_long(); \
42 if (_curl_is_off_t_option(_curl_opt) && !_curl_is_off_t(value)) \
43 _curl_easy_setopt_err_curl_off_t(); \
44 if (_curl_is_string_option(_curl_opt) && !_curl_is_string(value)) \
45 _curl_easy_setopt_err_string(); \
46 if (_curl_is_write_cb_option(_curl_opt) && !_curl_is_write_cb(value)) \
47 _curl_easy_setopt_err_write_callback(); \
48 if ((_curl_opt) == CURLOPT_READFUNCTION && !_curl_is_read_cb(value)) \
49 _curl_easy_setopt_err_read_cb(); \
50 if ((_curl_opt) == CURLOPT_IOCTLFUNCTION && !_curl_is_ioctl_cb(value)) \
51 _curl_easy_setopt_err_ioctl_cb(); \
52 if ((_curl_opt) == CURLOPT_SOCKOPTFUNCTION && !_curl_is_sockopt_cb(value))\
53 _curl_easy_setopt_err_sockopt_cb(); \
54 if ((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION && \
55 !_curl_is_opensocket_cb(value)) \
56 _curl_easy_setopt_err_opensocket_cb(); \
57 if ((_curl_opt) == CURLOPT_PROGRESSFUNCTION && \
58 !_curl_is_progress_cb(value)) \
59 _curl_easy_setopt_err_progress_cb(); \
60 if ((_curl_opt) == CURLOPT_DEBUGFUNCTION && !_curl_is_debug_cb(value)) \
61 _curl_easy_setopt_err_debug_cb(); \
62 if ((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION && \
63 !_curl_is_ssl_ctx_cb(value)) \
64 _curl_easy_setopt_err_ssl_ctx_cb(); \
65 if (_curl_is_conv_cb_option(_curl_opt) && !_curl_is_conv_cb(value)) \
66 _curl_easy_setopt_err_conv_cb(); \
67 if ((_curl_opt) == CURLOPT_SEEKFUNCTION && !_curl_is_seek_cb(value)) \
68 _curl_easy_setopt_err_seek_cb(); \
69 if (_curl_is_cb_data_option(_curl_opt) && !_curl_is_cb_data(value)) \
70 _curl_easy_setopt_err_cb_data(); \
71 if ((_curl_opt) == CURLOPT_ERRORBUFFER && !_curl_is_error_buffer(value)) \
72 _curl_easy_setopt_err_error_buffer(); \
73 if ((_curl_opt) == CURLOPT_STDERR && !_curl_is_FILE(value)) \
74 _curl_easy_setopt_err_FILE(); \
75 if (_curl_is_postfields_option(_curl_opt) && !_curl_is_postfields(value)) \
76 _curl_easy_setopt_err_postfields(); \
77 if ((_curl_opt) == CURLOPT_HTTPPOST && \
78 !_curl_is_arr((value), struct curl_httppost)) \
79 _curl_easy_setopt_err_curl_httpost(); \
80 if (_curl_is_slist_option(_curl_opt) && \
81 !_curl_is_arr((value), struct curl_slist)) \
82 _curl_easy_setopt_err_curl_slist(); \
83 if ((_curl_opt) == CURLOPT_SHARE && !_curl_is_ptr((value), CURLSH)) \
84 _curl_easy_setopt_err_CURLSH(); \
85 } \
86 curl_easy_setopt(handle, _curl_opt, value); \
89 /* wraps curl_easy_getinfo() with typechecking */
90 /* FIXME: don't allow const pointers */
91 #define curl_easy_getinfo(handle, info, arg) \
92 __extension__ ({ \
93 __typeof__ (info) _curl_info = info; \
94 if (__builtin_constant_p(_curl_info)) { \
95 if (_curl_is_string_info(_curl_info) && !_curl_is_arr((arg), char *)) \
96 _curl_easy_getinfo_err_string(); \
97 if (_curl_is_long_info(_curl_info) && !_curl_is_arr((arg), long)) \
98 _curl_easy_getinfo_err_long(); \
99 if (_curl_is_double_info(_curl_info) && !_curl_is_arr((arg), double)) \
100 _curl_easy_getinfo_err_double(); \
101 if (_curl_is_slist_info(_curl_info) && \
102 !_curl_is_arr((arg), struct curl_slist *)) \
103 _curl_easy_getinfo_err_curl_slist(); \
105 curl_easy_getinfo(handle, _curl_info, arg); \
108 /* TODO: typechecking for curl_share_setopt() and curl_multi_setopt(),
109 * for now just make sure that the functions are called with three
110 * arguments
112 #define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
113 #define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)
116 /* the actual warnings, triggered by calling the _curl_easy_setopt_err*
117 * functions */
119 /* To define a new warning, use _CURL_WARNING(identifier, "message") */
120 #define _CURL_WARNING(id, message) \
121 static void __attribute__((warning(message))) __attribute__((unused)) \
122 __attribute__((noinline)) id(void) { __asm__(""); }
124 _CURL_WARNING(_curl_easy_setopt_err_long,
125 "curl_easy_setopt expects a long argument for this option")
126 _CURL_WARNING(_curl_easy_setopt_err_curl_off_t,
127 "curl_easy_setopt expects a curl_off_t argument for this option")
128 _CURL_WARNING(_curl_easy_setopt_err_string,
129 "curl_easy_setopt expects a string (char* or char[]) argument for this option"
131 _CURL_WARNING(_curl_easy_setopt_err_write_callback,
132 "curl_easy_setopt expects a curl_write_callback argument for this option")
133 _CURL_WARNING(_curl_easy_setopt_err_read_cb,
134 "curl_easy_setopt expects a curl_read_callback argument for this option")
135 _CURL_WARNING(_curl_easy_setopt_err_ioctl_cb,
136 "curl_easy_setopt expects a curl_ioctl_callback argument for this option")
137 _CURL_WARNING(_curl_easy_setopt_err_sockopt_cb,
138 "curl_easy_setopt expects a curl_sockopt_callback argument for this option")
139 _CURL_WARNING(_curl_easy_setopt_err_opensocket_cb,
140 "curl_easy_setopt expects a curl_opensocket_callback argument for this option"
142 _CURL_WARNING(_curl_easy_setopt_err_progress_cb,
143 "curl_easy_setopt expects a curl_progress_callback argument for this option")
144 _CURL_WARNING(_curl_easy_setopt_err_debug_cb,
145 "curl_easy_setopt expects a curl_debug_callback argument for this option")
146 _CURL_WARNING(_curl_easy_setopt_err_ssl_ctx_cb,
147 "curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option")
148 _CURL_WARNING(_curl_easy_setopt_err_conv_cb,
149 "curl_easy_setopt expects a curl_conv_callback argument for this option")
150 _CURL_WARNING(_curl_easy_setopt_err_seek_cb,
151 "curl_easy_setopt expects a curl_seek_callback argument for this option")
152 _CURL_WARNING(_curl_easy_setopt_err_cb_data,
153 "curl_easy_setopt expects a private data pointer as argument for this option")
154 _CURL_WARNING(_curl_easy_setopt_err_error_buffer,
155 "curl_easy_setopt expects a char buffer of CURL_ERROR_SIZE as argument for this option")
156 _CURL_WARNING(_curl_easy_setopt_err_FILE,
157 "curl_easy_setopt expects a FILE* argument for this option")
158 _CURL_WARNING(_curl_easy_setopt_err_postfields,
159 "curl_easy_setopt expects a void* or char* argument for this option")
160 _CURL_WARNING(_curl_easy_setopt_err_curl_httpost,
161 "curl_easy_setopt expects a struct curl_httppost* argument for this option")
162 _CURL_WARNING(_curl_easy_setopt_err_curl_slist,
163 "curl_easy_setopt expects a struct curl_slist* argument for this option")
164 _CURL_WARNING(_curl_easy_setopt_err_CURLSH,
165 "curl_easy_setopt expects a CURLSH* argument for this option")
167 _CURL_WARNING(_curl_easy_getinfo_err_string,
168 "curl_easy_getinfo expects a pointer to char * for this info")
169 _CURL_WARNING(_curl_easy_getinfo_err_long,
170 "curl_easy_getinfo expects a pointer to long for this info")
171 _CURL_WARNING(_curl_easy_getinfo_err_double,
172 "curl_easy_getinfo expects a pointer to double for this info")
173 _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
174 "curl_easy_getinfo expects a pointer to struct curl_slist * for this info")
176 /* groups of curl_easy_setops options that take the same type of argument */
178 /* To add a new option to one of the groups, just add
179 * (option) == CURLOPT_SOMETHING
180 * to the or-expression. If the option takes a long or curl_off_t, you don't
181 * have to do anything
184 /* evaluates to true if option takes a long argument */
185 #define _curl_is_long_option(option) \
186 (0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
188 #define _curl_is_off_t_option(option) \
189 ((option) > CURLOPTTYPE_OFF_T)
191 /* evaluates to true if option takes a char* argument */
192 #define _curl_is_string_option(option) \
193 ((option) == CURLOPT_URL || \
194 (option) == CURLOPT_PROXY || \
195 (option) == CURLOPT_INTERFACE || \
196 (option) == CURLOPT_NETRC_FILE || \
197 (option) == CURLOPT_USERPWD || \
198 (option) == CURLOPT_USERNAME || \
199 (option) == CURLOPT_PASSWORD || \
200 (option) == CURLOPT_PROXYUSERPWD || \
201 (option) == CURLOPT_PROXYUSERNAME || \
202 (option) == CURLOPT_PROXYPASSWORD || \
203 (option) == CURLOPT_NOPROXY || \
204 (option) == CURLOPT_ENCODING || \
205 (option) == CURLOPT_REFERER || \
206 (option) == CURLOPT_USERAGENT || \
207 (option) == CURLOPT_COOKIE || \
208 (option) == CURLOPT_COOKIEFILE || \
209 (option) == CURLOPT_COOKIEJAR || \
210 (option) == CURLOPT_COOKIELIST || \
211 (option) == CURLOPT_FTPPORT || \
212 (option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \
213 (option) == CURLOPT_FTP_ACCOUNT || \
214 (option) == CURLOPT_RANGE || \
215 (option) == CURLOPT_CUSTOMREQUEST || \
216 (option) == CURLOPT_SSLCERT || \
217 (option) == CURLOPT_SSLCERTTYPE || \
218 (option) == CURLOPT_SSLKEY || \
219 (option) == CURLOPT_SSLKEYTYPE || \
220 (option) == CURLOPT_KEYPASSWD || \
221 (option) == CURLOPT_SSLENGINE || \
222 (option) == CURLOPT_CAINFO || \
223 (option) == CURLOPT_CAPATH || \
224 (option) == CURLOPT_RANDOM_FILE || \
225 (option) == CURLOPT_EGDSOCKET || \
226 (option) == CURLOPT_SSL_CIPHER_LIST || \
227 (option) == CURLOPT_KRBLEVEL || \
228 (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \
229 (option) == CURLOPT_SSH_PUBLIC_KEYFILE || \
230 (option) == CURLOPT_SSH_PRIVATE_KEYFILE || \
231 (option) == CURLOPT_CRLFILE || \
232 (option) == CURLOPT_ISSUERCERT || \
233 (option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \
234 (option) == CURLOPT_SSH_KNOWNHOSTS || \
235 (option) == CURLOPT_MAIL_FROM || \
236 (option) == CURLOPT_RTSP_SESSION_ID || \
237 (option) == CURLOPT_RTSP_STREAM_URI || \
238 (option) == CURLOPT_RTSP_TRANSPORT || \
241 /* evaluates to true if option takes a curl_write_callback argument */
242 #define _curl_is_write_cb_option(option) \
243 ((option) == CURLOPT_HEADERFUNCTION || \
244 (option) == CURLOPT_WRITEFUNCTION)
246 /* evaluates to true if option takes a curl_conv_callback argument */
247 #define _curl_is_conv_cb_option(option) \
248 ((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \
249 (option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \
250 (option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)
252 /* evaluates to true if option takes a data argument to pass to a callback */
253 #define _curl_is_cb_data_option(option) \
254 ((option) == CURLOPT_WRITEDATA || \
255 (option) == CURLOPT_READDATA || \
256 (option) == CURLOPT_IOCTLDATA || \
257 (option) == CURLOPT_SOCKOPTDATA || \
258 (option) == CURLOPT_OPENSOCKETDATA || \
259 (option) == CURLOPT_PROGRESSDATA || \
260 (option) == CURLOPT_WRITEHEADER || \
261 (option) == CURLOPT_DEBUGDATA || \
262 (option) == CURLOPT_SSL_CTX_DATA || \
263 (option) == CURLOPT_SEEKDATA || \
264 (option) == CURLOPT_PRIVATE || \
265 (option) == CURLOPT_SSH_KEYDATA || \
266 (option) == CURLOPT_INTERLEAVEDATA || \
267 (option) == CURLOPT_CHUNK_DATA || \
268 (option) == CURLOPT_FNMATCH_DATA || \
271 /* evaluates to true if option takes a POST data argument (void* or char*) */
272 #define _curl_is_postfields_option(option) \
273 ((option) == CURLOPT_POSTFIELDS || \
274 (option) == CURLOPT_COPYPOSTFIELDS || \
277 /* evaluates to true if option takes a struct curl_slist * argument */
278 #define _curl_is_slist_option(option) \
279 ((option) == CURLOPT_HTTPHEADER || \
280 (option) == CURLOPT_HTTP200ALIASES || \
281 (option) == CURLOPT_QUOTE || \
282 (option) == CURLOPT_POSTQUOTE || \
283 (option) == CURLOPT_PREQUOTE || \
284 (option) == CURLOPT_TELNETOPTIONS || \
285 (option) == CURLOPT_MAIL_RCPT || \
288 /* groups of curl_easy_getinfo infos that take the same type of argument */
290 /* evaluates to true if info expects a pointer to char * argument */
291 #define _curl_is_string_info(info) \
292 (CURLINFO_STRING < (info) && (info) < CURLINFO_LONG)
294 /* evaluates to true if info expects a pointer to long argument */
295 #define _curl_is_long_info(info) \
296 (CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)
298 /* evaluates to true if info expects a pointer to double argument */
299 #define _curl_is_double_info(info) \
300 (CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)
302 /* true if info expects a pointer to struct curl_slist * argument */
303 #define _curl_is_slist_info(info) \
304 (CURLINFO_SLIST < (info))
307 /* typecheck helpers -- check whether given expression has requested type*/
309 /* For pointers, you can use the _curl_is_ptr/_curl_is_arr macros,
310 * otherwise define a new macro. Search for __builtin_types_compatible_p
311 * in the GCC manual.
312 * NOTE: these macros MUST NOT EVALUATE their arguments! The argument is
313 * the actual expression passed to the curl_easy_setopt macro. This
314 * means that you can only apply the sizeof and __typeof__ operators, no
315 * == or whatsoever.
318 /* XXX: should evaluate to true iff expr is a pointer */
319 #define _curl_is_any_ptr(expr) \
320 (sizeof(expr) == sizeof(void*))
322 /* evaluates to true if expr is NULL */
323 /* XXX: must not evaluate expr, so this check is not accurate */
324 #define _curl_is_NULL(expr) \
325 (__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))
327 /* evaluates to true if expr is type*, const type* or NULL */
328 #define _curl_is_ptr(expr, type) \
329 (_curl_is_NULL(expr) || \
330 __builtin_types_compatible_p(__typeof__(expr), type *) || \
331 __builtin_types_compatible_p(__typeof__(expr), const type *))
333 /* evaluates to true if expr is one of type[], type*, NULL or const type* */
334 #define _curl_is_arr(expr, type) \
335 (_curl_is_ptr((expr), type) || \
336 __builtin_types_compatible_p(__typeof__(expr), type []))
338 /* evaluates to true if expr is a string */
339 #define _curl_is_string(expr) \
340 (_curl_is_arr((expr), char) || \
341 _curl_is_arr((expr), signed char) || \
342 _curl_is_arr((expr), unsigned char))
344 /* evaluates to true if expr is a long (no matter the signedness)
345 * XXX: for now, int is also accepted (and therefore short and char, which
346 * are promoted to int when passed to a variadic function) */
347 #define _curl_is_long(expr) \
348 (__builtin_types_compatible_p(__typeof__(expr), long) || \
349 __builtin_types_compatible_p(__typeof__(expr), signed long) || \
350 __builtin_types_compatible_p(__typeof__(expr), unsigned long) || \
351 __builtin_types_compatible_p(__typeof__(expr), int) || \
352 __builtin_types_compatible_p(__typeof__(expr), signed int) || \
353 __builtin_types_compatible_p(__typeof__(expr), unsigned int) || \
354 __builtin_types_compatible_p(__typeof__(expr), short) || \
355 __builtin_types_compatible_p(__typeof__(expr), signed short) || \
356 __builtin_types_compatible_p(__typeof__(expr), unsigned short) || \
357 __builtin_types_compatible_p(__typeof__(expr), char) || \
358 __builtin_types_compatible_p(__typeof__(expr), signed char) || \
359 __builtin_types_compatible_p(__typeof__(expr), unsigned char))
361 /* evaluates to true if expr is of type curl_off_t */
362 #define _curl_is_off_t(expr) \
363 (__builtin_types_compatible_p(__typeof__(expr), curl_off_t))
365 /* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
366 /* XXX: also check size of an char[] array? */
367 #define _curl_is_error_buffer(expr) \
368 (__builtin_types_compatible_p(__typeof__(expr), char *) || \
369 __builtin_types_compatible_p(__typeof__(expr), char[]))
371 /* evaluates to true if expr is of type (const) void* or (const) FILE* */
372 #if 0
373 #define _curl_is_cb_data(expr) \
374 (_curl_is_ptr((expr), void) || \
375 _curl_is_ptr((expr), FILE))
376 #else /* be less strict */
377 #define _curl_is_cb_data(expr) \
378 _curl_is_any_ptr(expr)
379 #endif
381 /* evaluates to true if expr is of type FILE* */
382 #define _curl_is_FILE(expr) \
383 (__builtin_types_compatible_p(__typeof__(expr), FILE *))
385 /* evaluates to true if expr can be passed as POST data (void* or char*) */
386 #define _curl_is_postfields(expr) \
387 (_curl_is_ptr((expr), void) || \
388 _curl_is_arr((expr), char))
390 /* FIXME: the whole callback checking is messy...
391 * The idea is to tolerate char vs. void and const vs. not const
392 * pointers in arguments at least
394 /* helper: __builtin_types_compatible_p distinguishes between functions and
395 * function pointers, hide it */
396 #define _curl_callback_compatible(func, type) \
397 (__builtin_types_compatible_p(__typeof__(func), type) || \
398 __builtin_types_compatible_p(__typeof__(func), type*))
400 /* evaluates to true if expr is of type curl_read_callback or "similar" */
401 #define _curl_is_read_cb(expr) \
402 (_curl_is_NULL(expr) || \
403 __builtin_types_compatible_p(__typeof__(expr), __typeof__(fread)) || \
404 __builtin_types_compatible_p(__typeof__(expr), curl_read_callback) || \
405 _curl_callback_compatible((expr), _curl_read_callback1) || \
406 _curl_callback_compatible((expr), _curl_read_callback2) || \
407 _curl_callback_compatible((expr), _curl_read_callback3) || \
408 _curl_callback_compatible((expr), _curl_read_callback4) || \
409 _curl_callback_compatible((expr), _curl_read_callback5) || \
410 _curl_callback_compatible((expr), _curl_read_callback6))
411 typedef size_t (_curl_read_callback1)(char *, size_t, size_t, void*);
412 typedef size_t (_curl_read_callback2)(char *, size_t, size_t, const void*);
413 typedef size_t (_curl_read_callback3)(char *, size_t, size_t, FILE*);
414 typedef size_t (_curl_read_callback4)(void *, size_t, size_t, void*);
415 typedef size_t (_curl_read_callback5)(void *, size_t, size_t, const void*);
416 typedef size_t (_curl_read_callback6)(void *, size_t, size_t, FILE*);
418 /* evaluates to true if expr is of type curl_write_callback or "similar" */
419 #define _curl_is_write_cb(expr) \
420 (_curl_is_read_cb(expr) || \
421 __builtin_types_compatible_p(__typeof__(expr), __typeof__(fwrite)) || \
422 __builtin_types_compatible_p(__typeof__(expr), curl_write_callback) || \
423 _curl_callback_compatible((expr), _curl_write_callback1) || \
424 _curl_callback_compatible((expr), _curl_write_callback2) || \
425 _curl_callback_compatible((expr), _curl_write_callback3) || \
426 _curl_callback_compatible((expr), _curl_write_callback4) || \
427 _curl_callback_compatible((expr), _curl_write_callback5) || \
428 _curl_callback_compatible((expr), _curl_write_callback6))
429 typedef size_t (_curl_write_callback1)(const char *, size_t, size_t, void*);
430 typedef size_t (_curl_write_callback2)(const char *, size_t, size_t,
431 const void*);
432 typedef size_t (_curl_write_callback3)(const char *, size_t, size_t, FILE*);
433 typedef size_t (_curl_write_callback4)(const void *, size_t, size_t, void*);
434 typedef size_t (_curl_write_callback5)(const void *, size_t, size_t,
435 const void*);
436 typedef size_t (_curl_write_callback6)(const void *, size_t, size_t, FILE*);
438 /* evaluates to true if expr is of type curl_ioctl_callback or "similar" */
439 #define _curl_is_ioctl_cb(expr) \
440 (_curl_is_NULL(expr) || \
441 __builtin_types_compatible_p(__typeof__(expr), curl_ioctl_callback) || \
442 _curl_callback_compatible((expr), _curl_ioctl_callback1) || \
443 _curl_callback_compatible((expr), _curl_ioctl_callback2) || \
444 _curl_callback_compatible((expr), _curl_ioctl_callback3) || \
445 _curl_callback_compatible((expr), _curl_ioctl_callback4))
446 typedef curlioerr (_curl_ioctl_callback1)(CURL *, int, void*);
447 typedef curlioerr (_curl_ioctl_callback2)(CURL *, int, const void*);
448 typedef curlioerr (_curl_ioctl_callback3)(CURL *, curliocmd, void*);
449 typedef curlioerr (_curl_ioctl_callback4)(CURL *, curliocmd, const void*);
451 /* evaluates to true if expr is of type curl_sockopt_callback or "similar" */
452 #define _curl_is_sockopt_cb(expr) \
453 (_curl_is_NULL(expr) || \
454 __builtin_types_compatible_p(__typeof__(expr), curl_sockopt_callback) || \
455 _curl_callback_compatible((expr), _curl_sockopt_callback1) || \
456 _curl_callback_compatible((expr), _curl_sockopt_callback2))
457 typedef int (_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);
458 typedef int (_curl_sockopt_callback2)(const void *, curl_socket_t,
459 curlsocktype);
461 /* evaluates to true if expr is of type curl_opensocket_callback or "similar" */
462 #define _curl_is_opensocket_cb(expr) \
463 (_curl_is_NULL(expr) || \
464 __builtin_types_compatible_p(__typeof__(expr), curl_opensocket_callback) ||\
465 _curl_callback_compatible((expr), _curl_opensocket_callback1) || \
466 _curl_callback_compatible((expr), _curl_opensocket_callback2) || \
467 _curl_callback_compatible((expr), _curl_opensocket_callback3) || \
468 _curl_callback_compatible((expr), _curl_opensocket_callback4))
469 typedef curl_socket_t (_curl_opensocket_callback1)
470 (void *, curlsocktype, struct curl_sockaddr *);
471 typedef curl_socket_t (_curl_opensocket_callback2)
472 (void *, curlsocktype, const struct curl_sockaddr *);
473 typedef curl_socket_t (_curl_opensocket_callback3)
474 (const void *, curlsocktype, struct curl_sockaddr *);
475 typedef curl_socket_t (_curl_opensocket_callback4)
476 (const void *, curlsocktype, const struct curl_sockaddr *);
478 /* evaluates to true if expr is of type curl_progress_callback or "similar" */
479 #define _curl_is_progress_cb(expr) \
480 (_curl_is_NULL(expr) || \
481 __builtin_types_compatible_p(__typeof__(expr), curl_progress_callback) || \
482 _curl_callback_compatible((expr), _curl_progress_callback1) || \
483 _curl_callback_compatible((expr), _curl_progress_callback2))
484 typedef int (_curl_progress_callback1)(void *,
485 double, double, double, double);
486 typedef int (_curl_progress_callback2)(const void *,
487 double, double, double, double);
489 /* evaluates to true if expr is of type curl_debug_callback or "similar" */
490 #define _curl_is_debug_cb(expr) \
491 (_curl_is_NULL(expr) || \
492 __builtin_types_compatible_p(__typeof__(expr), curl_debug_callback) || \
493 _curl_callback_compatible((expr), _curl_debug_callback1) || \
494 _curl_callback_compatible((expr), _curl_debug_callback2) || \
495 _curl_callback_compatible((expr), _curl_debug_callback3) || \
496 _curl_callback_compatible((expr), _curl_debug_callback4))
497 typedef int (_curl_debug_callback1) (CURL *,
498 curl_infotype, char *, size_t, void *);
499 typedef int (_curl_debug_callback2) (CURL *,
500 curl_infotype, char *, size_t, const void *);
501 typedef int (_curl_debug_callback3) (CURL *,
502 curl_infotype, const char *, size_t, void *);
503 typedef int (_curl_debug_callback4) (CURL *,
504 curl_infotype, const char *, size_t, const void *);
506 /* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
507 /* this is getting even messier... */
508 #define _curl_is_ssl_ctx_cb(expr) \
509 (_curl_is_NULL(expr) || \
510 __builtin_types_compatible_p(__typeof__(expr), curl_ssl_ctx_callback) || \
511 _curl_callback_compatible((expr), _curl_ssl_ctx_callback1) || \
512 _curl_callback_compatible((expr), _curl_ssl_ctx_callback2) || \
513 _curl_callback_compatible((expr), _curl_ssl_ctx_callback3) || \
514 _curl_callback_compatible((expr), _curl_ssl_ctx_callback4) || \
515 _curl_callback_compatible((expr), _curl_ssl_ctx_callback5) || \
516 _curl_callback_compatible((expr), _curl_ssl_ctx_callback6) || \
517 _curl_callback_compatible((expr), _curl_ssl_ctx_callback7) || \
518 _curl_callback_compatible((expr), _curl_ssl_ctx_callback8))
519 typedef CURLcode (_curl_ssl_ctx_callback1)(CURL *, void *, void *);
520 typedef CURLcode (_curl_ssl_ctx_callback2)(CURL *, void *, const void *);
521 typedef CURLcode (_curl_ssl_ctx_callback3)(CURL *, const void *, void *);
522 typedef CURLcode (_curl_ssl_ctx_callback4)(CURL *, const void *, const void *);
523 #ifdef HEADER_SSL_H
524 /* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX
525 * this will of course break if we're included before OpenSSL headers...
527 typedef CURLcode (_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *);
528 typedef CURLcode (_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *);
529 typedef CURLcode (_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *);
530 typedef CURLcode (_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX, const void *);
531 #else
532 typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5;
533 typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6;
534 typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7;
535 typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8;
536 #endif
538 /* evaluates to true if expr is of type curl_conv_callback or "similar" */
539 #define _curl_is_conv_cb(expr) \
540 (_curl_is_NULL(expr) || \
541 __builtin_types_compatible_p(__typeof__(expr), curl_conv_callback) || \
542 _curl_callback_compatible((expr), _curl_conv_callback1) || \
543 _curl_callback_compatible((expr), _curl_conv_callback2) || \
544 _curl_callback_compatible((expr), _curl_conv_callback3) || \
545 _curl_callback_compatible((expr), _curl_conv_callback4))
546 typedef CURLcode (*_curl_conv_callback1)(char *, size_t length);
547 typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length);
548 typedef CURLcode (*_curl_conv_callback3)(void *, size_t length);
549 typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length);
551 /* evaluates to true if expr is of type curl_seek_callback or "similar" */
552 #define _curl_is_seek_cb(expr) \
553 (_curl_is_NULL(expr) || \
554 __builtin_types_compatible_p(__typeof__(expr), curl_seek_callback) || \
555 _curl_callback_compatible((expr), _curl_seek_callback1) || \
556 _curl_callback_compatible((expr), _curl_seek_callback2))
557 typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int);
558 typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int);
561 #endif /* __CURL_TYPECHECK_GCC_H */