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