typecheck-gcc.h 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958
  1. #ifndef CURLINC_TYPECHECK_GCC_H
  2. #define CURLINC_TYPECHECK_GCC_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) Daniel Stenberg, <[email protected]>, 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. /* wraps curl_easy_setopt() with typechecking */
  27. /* To add a new kind of warning, add an
  28. * if(curlcheck_sometype_option(_curl_opt))
  29. * if(!curlcheck_sometype(value))
  30. * Wcurl_easy_setopt_err_sometype();
  31. * block and define curlcheck_sometype_option, curlcheck_sometype and
  32. * Wcurl_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 will
  39. * just need to extend the appropriate _curl_*_option macro
  40. */
  41. #define curl_easy_setopt(handle, option, value) \
  42. __extension__({ \
  43. if(__builtin_constant_p(option)) { \
  44. CURL_IGNORE_DEPRECATION( \
  45. if(curlcheck_long_option(option)) \
  46. if(!curlcheck_long(value)) \
  47. Wcurl_easy_setopt_err_long(); \
  48. if(curlcheck_off_t_option(option)) \
  49. if(!curlcheck_off_t(value)) \
  50. Wcurl_easy_setopt_err_curl_off_t(); \
  51. if(curlcheck_string_option(option)) \
  52. if(!curlcheck_string(value)) \
  53. Wcurl_easy_setopt_err_string(); \
  54. if((option) == CURLOPT_PRIVATE) { } \
  55. if(curlcheck_write_cb_option(option)) \
  56. if(!curlcheck_write_cb(value)) \
  57. Wcurl_easy_setopt_err_write_callback(); \
  58. if(curlcheck_curl_option(option)) \
  59. if(!curlcheck_curl(value)) \
  60. Wcurl_easy_setopt_err_curl(); \
  61. if((option) == CURLOPT_RESOLVER_START_FUNCTION) \
  62. if(!curlcheck_resolver_start_callback(value)) \
  63. Wcurl_easy_setopt_err_resolver_start_callback(); \
  64. if((option) == CURLOPT_READFUNCTION) \
  65. if(!curlcheck_read_cb(value)) \
  66. Wcurl_easy_setopt_err_read_cb(); \
  67. if((option) == CURLOPT_IOCTLFUNCTION) \
  68. if(!curlcheck_ioctl_cb(value)) \
  69. Wcurl_easy_setopt_err_ioctl_cb(); \
  70. if((option) == CURLOPT_SOCKOPTFUNCTION) \
  71. if(!curlcheck_sockopt_cb(value)) \
  72. Wcurl_easy_setopt_err_sockopt_cb(); \
  73. if((option) == CURLOPT_OPENSOCKETFUNCTION) \
  74. if(!curlcheck_opensocket_cb(value)) \
  75. Wcurl_easy_setopt_err_opensocket_cb(); \
  76. if((option) == CURLOPT_PROGRESSFUNCTION) \
  77. if(!curlcheck_progress_cb(value)) \
  78. Wcurl_easy_setopt_err_progress_cb(); \
  79. if((option) == CURLOPT_XFERINFOFUNCTION) \
  80. if(!curlcheck_xferinfo_cb(value)) \
  81. Wcurl_easy_setopt_err_xferinfo_cb(); \
  82. if((option) == CURLOPT_DEBUGFUNCTION) \
  83. if(!curlcheck_debug_cb(value)) \
  84. Wcurl_easy_setopt_err_debug_cb(); \
  85. if((option) == CURLOPT_SSL_CTX_FUNCTION) \
  86. if(!curlcheck_ssl_ctx_cb(value)) \
  87. Wcurl_easy_setopt_err_ssl_ctx_cb(); \
  88. if(curlcheck_conv_cb_option(option)) \
  89. if(!curlcheck_conv_cb(value)) \
  90. Wcurl_easy_setopt_err_conv_cb(); \
  91. if((option) == CURLOPT_SEEKFUNCTION) \
  92. if(!curlcheck_seek_cb(value)) \
  93. Wcurl_easy_setopt_err_seek_cb(); \
  94. if((option) == CURLOPT_CHUNK_BGN_FUNCTION) \
  95. if(!curlcheck_chunk_bgn_cb(value)) \
  96. Wcurl_easy_setopt_err_chunk_bgn_cb(); \
  97. if((option) == CURLOPT_CHUNK_END_FUNCTION) \
  98. if(!curlcheck_chunk_end_cb(value)) \
  99. Wcurl_easy_setopt_err_chunk_end_cb(); \
  100. if((option) == CURLOPT_CLOSESOCKETFUNCTION) \
  101. if(!curlcheck_close_socket_cb(value)) \
  102. Wcurl_easy_setopt_err_close_socket_cb(); \
  103. if((option) == CURLOPT_FNMATCH_FUNCTION) \
  104. if(!curlcheck_fnmatch_cb(value)) \
  105. Wcurl_easy_setopt_err_fnmatch_cb(); \
  106. if((option) == CURLOPT_HSTSREADFUNCTION) \
  107. if(!curlcheck_hstsread_cb(value)) \
  108. Wcurl_easy_setopt_err_hstsread_cb(); \
  109. if((option) == CURLOPT_HSTSWRITEFUNCTION) \
  110. if(!curlcheck_hstswrite_cb(value)) \
  111. Wcurl_easy_setopt_err_hstswrite_cb(); \
  112. if((option) == CURLOPT_SSH_HOSTKEYFUNCTION) \
  113. if(!curlcheck_ssh_hostkey_cb(value)) \
  114. Wcurl_easy_setopt_err_ssh_hostkey_cb(); \
  115. if((option) == CURLOPT_SSH_KEYFUNCTION) \
  116. if(!curlcheck_ssh_key_cb(value)) \
  117. Wcurl_easy_setopt_err_ssh_key_cb(); \
  118. if((option) == CURLOPT_INTERLEAVEFUNCTION) \
  119. if(!curlcheck_interleave_cb(value)) \
  120. Wcurl_easy_setopt_err_interleave_cb(); \
  121. if((option) == CURLOPT_PREREQFUNCTION) \
  122. if(!curlcheck_prereq_cb(value)) \
  123. Wcurl_easy_setopt_err_prereq_cb(); \
  124. if((option) == CURLOPT_TRAILERFUNCTION) \
  125. if(!curlcheck_trailer_cb(value)) \
  126. Wcurl_easy_setopt_err_trailer_cb(); \
  127. if(curlcheck_cb_data_option(option)) \
  128. if(!curlcheck_cb_data(value)) \
  129. Wcurl_easy_setopt_err_cb_data(); \
  130. if((option) == CURLOPT_ERRORBUFFER) \
  131. if(!curlcheck_error_buffer(value)) \
  132. Wcurl_easy_setopt_err_error_buffer(); \
  133. if((option) == CURLOPT_CURLU) \
  134. if(!curlcheck_ptr((value), CURLU)) \
  135. Wcurl_easy_setopt_err_curlu(); \
  136. if((option) == CURLOPT_STDERR) \
  137. if(!curlcheck_FILE(value)) \
  138. Wcurl_easy_setopt_err_FILE(); \
  139. if(curlcheck_postfields_option(option)) \
  140. if(!curlcheck_postfields(value)) \
  141. Wcurl_easy_setopt_err_postfields(); \
  142. if((option) == CURLOPT_HTTPPOST) \
  143. if(!curlcheck_arr((value), struct curl_httppost)) \
  144. Wcurl_easy_setopt_err_curl_httpost(); \
  145. if((option) == CURLOPT_MIMEPOST) \
  146. if(!curlcheck_ptr((value), curl_mime)) \
  147. Wcurl_easy_setopt_err_curl_mimepost(); \
  148. if(curlcheck_slist_option(option)) \
  149. if(!curlcheck_arr((value), struct curl_slist)) \
  150. Wcurl_easy_setopt_err_curl_slist(); \
  151. if((option) == CURLOPT_SHARE) \
  152. if(!curlcheck_ptr((value), CURLSH)) \
  153. Wcurl_easy_setopt_err_CURLSH(); \
  154. ) \
  155. } \
  156. curl_easy_setopt(handle, option, value); \
  157. })
  158. /* wraps curl_easy_getinfo() with typechecking */
  159. #define curl_easy_getinfo(handle, info, arg) \
  160. __extension__({ \
  161. if(__builtin_constant_p(info)) { \
  162. CURL_IGNORE_DEPRECATION( \
  163. if(curlcheck_string_info(info)) \
  164. if(!curlcheck_arr((arg), char *)) \
  165. Wcurl_easy_getinfo_err_string(); \
  166. if(curlcheck_long_info(info)) \
  167. if(!curlcheck_arr((arg), long)) \
  168. Wcurl_easy_getinfo_err_long(); \
  169. if(curlcheck_double_info(info)) \
  170. if(!curlcheck_arr((arg), double)) \
  171. Wcurl_easy_getinfo_err_double(); \
  172. if(curlcheck_slist_info(info)) \
  173. if(!curlcheck_arr((arg), struct curl_slist *)) \
  174. Wcurl_easy_getinfo_err_curl_slist(); \
  175. if(curlcheck_tlssessioninfo_info(info)) \
  176. if(!curlcheck_arr((arg), struct curl_tlssessioninfo *)) \
  177. Wcurl_easy_getinfo_err_curl_tlssessioninfo(); \
  178. if(curlcheck_certinfo_info(info)) \
  179. if(!curlcheck_arr((arg), struct curl_certinfo *)) \
  180. Wcurl_easy_getinfo_err_curl_certinfo(); \
  181. if(curlcheck_socket_info(info)) \
  182. if(!curlcheck_arr((arg), curl_socket_t)) \
  183. Wcurl_easy_getinfo_err_curl_socket(); \
  184. if(curlcheck_off_t_info(info)) \
  185. if(!curlcheck_arr((arg), curl_off_t)) \
  186. Wcurl_easy_getinfo_err_curl_off_t(); \
  187. ) \
  188. } \
  189. curl_easy_getinfo(handle, info, arg); \
  190. })
  191. #define curl_multi_setopt(handle, option, value) \
  192. __extension__({ \
  193. if(__builtin_constant_p(option)) { \
  194. if(curlcheck_long_option(option)) \
  195. if(!curlcheck_long(value)) \
  196. Wcurl_multi_setopt_err_long(); \
  197. if(curlcheck_off_t_option(option)) \
  198. if(!curlcheck_off_t(value)) \
  199. Wcurl_multi_setopt_err_curl_off_t(); \
  200. if(curlcheck_multicb_data_option(option)) \
  201. if(!curlcheck_cb_data(value)) \
  202. Wcurl_multi_setopt_err_cb_data(); \
  203. if(curlcheck_charpp_option(option)) \
  204. if(!curlcheck_ptrptr(value, char)) \
  205. Wcurl_multi_setopt_err_charpp(); \
  206. if((option) == CURLMOPT_NOTIFYFUNCTION) \
  207. if(!curlcheck_multinotify_cb(value)) \
  208. Wcurl_multi_setopt_err_notifycb(); \
  209. if((option) == CURLMOPT_PUSHFUNCTION) \
  210. if(!curlcheck_multipush_cb(value)) \
  211. Wcurl_multi_setopt_err_pushcb(); \
  212. if((option) == CURLMOPT_SOCKETFUNCTION) \
  213. if(!curlcheck_multisocket_cb(value)) \
  214. Wcurl_multi_setopt_err_socketcb(); \
  215. if((option) == CURLMOPT_TIMERFUNCTION) \
  216. if(!curlcheck_multitimer_cb(value)) \
  217. Wcurl_multi_setopt_err_timercb(); \
  218. } \
  219. curl_multi_setopt(handle, option, value); \
  220. })
  221. /* evaluates to true if the option takes a data argument to pass to a
  222. callback */
  223. #define curlcheck_multicb_data_option(option) \
  224. ((option) == CURLMOPT_NOTIFYDATA || \
  225. (option) == CURLMOPT_PUSHDATA || \
  226. (option) == CURLMOPT_SOCKETDATA || \
  227. (option) == CURLMOPT_TIMERDATA || \
  228. 0)
  229. /* evaluates to true if the option takes a char ** argument */
  230. #define curlcheck_charpp_option(option) \
  231. ((option) == CURLMOPT_PIPELINING_SERVER_BL || \
  232. (option) == CURLMOPT_PIPELINING_SITE_BL || \
  233. 0)
  234. /* evaluates to true if expr is of type curl_multi_timer_callback */
  235. #define curlcheck_multitimer_cb(expr) \
  236. (curlcheck_NULL(expr) || \
  237. curlcheck_cb_compatible((expr), curl_multi_timer_callback))
  238. /* evaluates to true if expr is of type curl_socket_callback */
  239. #define curlcheck_multisocket_cb(expr) \
  240. (curlcheck_NULL(expr) || \
  241. curlcheck_cb_compatible((expr), curl_socket_callback))
  242. /* evaluates to true if expr is of type curl_push_callback */
  243. #define curlcheck_multipush_cb(expr) \
  244. (curlcheck_NULL(expr) || \
  245. curlcheck_cb_compatible((expr), curl_push_callback))
  246. /* evaluates to true if expr is of type curl_push_callback */
  247. #define curlcheck_multinotify_cb(expr) \
  248. (curlcheck_NULL(expr) || \
  249. curlcheck_cb_compatible((expr), curl_notify_callback))
  250. /*
  251. * For now, just make sure that the functions are called with three arguments
  252. */
  253. #define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
  254. /* the actual warnings, triggered by calling the Wcurl_easy_setopt_err*
  255. * functions */
  256. /* To define a new warning, use _CURL_WARNING(identifier, "message") */
  257. #define CURLWARNING(id, message) \
  258. static void __attribute__((__warning__(message))) \
  259. __attribute__((__unused__)) __attribute__((__noinline__)) \
  260. id(void) { __asm__(""); }
  261. CURLWARNING(Wcurl_multi_setopt_err_long,
  262. "curl_multi_setopt expects a long argument")
  263. CURLWARNING(Wcurl_multi_setopt_err_curl_off_t,
  264. "curl_multi_setopt expects a curl_off_t argument")
  265. CURLWARNING(Wcurl_multi_setopt_err_cb_data,
  266. "curl_multi_setopt expects a 'void *' argument")
  267. CURLWARNING(Wcurl_multi_setopt_err_charpp,
  268. "curl_multi_setopt expects a 'char **' argument")
  269. CURLWARNING(Wcurl_multi_setopt_err_pushcb,
  270. "curl_multi_setopt expects a curl_push_callback argument")
  271. CURLWARNING(Wcurl_multi_setopt_err_notifycb,
  272. "curl_multi_setopt expects a curl_notify_callback argument")
  273. CURLWARNING(Wcurl_multi_setopt_err_socketcb,
  274. "curl_multi_setopt expects a curl_socket_callback argument")
  275. CURLWARNING(Wcurl_multi_setopt_err_timercb,
  276. "curl_multi_setopt expects a curl_multi_timer_callback argument")
  277. CURLWARNING(Wcurl_easy_setopt_err_long,
  278. "curl_easy_setopt expects a long argument")
  279. CURLWARNING(Wcurl_easy_setopt_err_curl_off_t,
  280. "curl_easy_setopt expects a curl_off_t argument")
  281. CURLWARNING(Wcurl_easy_setopt_err_string,
  282. "curl_easy_setopt expects a "
  283. "string ('char *' or char[]) argument")
  284. CURLWARNING(Wcurl_easy_setopt_err_write_callback,
  285. "curl_easy_setopt expects a curl_write_callback argument")
  286. CURLWARNING(Wcurl_easy_setopt_err_resolver_start_callback,
  287. "curl_easy_setopt expects a "
  288. "curl_resolver_start_callback argument")
  289. CURLWARNING(Wcurl_easy_setopt_err_read_cb,
  290. "curl_easy_setopt expects a curl_read_callback argument")
  291. CURLWARNING(Wcurl_easy_setopt_err_ioctl_cb,
  292. "curl_easy_setopt expects a curl_ioctl_callback argument")
  293. CURLWARNING(Wcurl_easy_setopt_err_sockopt_cb,
  294. "curl_easy_setopt expects a curl_sockopt_callback argument")
  295. CURLWARNING(Wcurl_easy_setopt_err_opensocket_cb,
  296. "curl_easy_setopt expects a "
  297. "curl_opensocket_callback argument")
  298. CURLWARNING(Wcurl_easy_setopt_err_progress_cb,
  299. "curl_easy_setopt expects a curl_progress_callback argument")
  300. CURLWARNING(Wcurl_easy_setopt_err_xferinfo_cb,
  301. "curl_easy_setopt expects a curl_xferinfo_callback argument")
  302. CURLWARNING(Wcurl_easy_setopt_err_debug_cb,
  303. "curl_easy_setopt expects a curl_debug_callback argument")
  304. CURLWARNING(Wcurl_easy_setopt_err_ssl_ctx_cb,
  305. "curl_easy_setopt expects a curl_ssl_ctx_callback argument")
  306. CURLWARNING(Wcurl_easy_setopt_err_conv_cb,
  307. "curl_easy_setopt expects a curl_conv_callback argument")
  308. CURLWARNING(Wcurl_easy_setopt_err_seek_cb,
  309. "curl_easy_setopt expects a curl_seek_callback argument")
  310. CURLWARNING(Wcurl_easy_setopt_err_cb_data,
  311. "curl_easy_setopt expects a "
  312. "private data pointer as argument")
  313. CURLWARNING(Wcurl_easy_setopt_err_chunk_bgn_cb,
  314. "curl_easy_setopt expects a curl_chunk_bgn_callback argument")
  315. CURLWARNING(Wcurl_easy_setopt_err_chunk_end_cb,
  316. "curl_easy_setopt expects a curl_chunk_end_callback argument")
  317. CURLWARNING(Wcurl_easy_setopt_err_close_socket_cb,
  318. "curl_easy_setopt expects a curl_closesocket_callback argument")
  319. CURLWARNING(Wcurl_easy_setopt_err_fnmatch_cb,
  320. "curl_easy_setopt expects a curl_fnmatch_callback argument")
  321. CURLWARNING(Wcurl_easy_setopt_err_hstsread_cb,
  322. "curl_easy_setopt expects a curl_hstsread_callback argument")
  323. CURLWARNING(Wcurl_easy_setopt_err_hstswrite_cb,
  324. "curl_easy_setopt expects a curl_hstswrite_callback argument")
  325. CURLWARNING(Wcurl_easy_setopt_err_ssh_key_cb,
  326. "curl_easy_setopt expects a curl_sshkeycallback argument")
  327. CURLWARNING(Wcurl_easy_setopt_err_ssh_hostkey_cb,
  328. "curl_easy_setopt expects a curl_sshhostkeycallback argument")
  329. CURLWARNING(Wcurl_easy_setopt_err_interleave_cb,
  330. "curl_easy_setopt expects a curl_interleave_callback argument")
  331. CURLWARNING(Wcurl_easy_setopt_err_prereq_cb,
  332. "curl_easy_setopt expects a curl_prereq_callback argument")
  333. CURLWARNING(Wcurl_easy_setopt_err_trailer_cb,
  334. "curl_easy_setopt expects a curl_trailerfunc_ok argument")
  335. CURLWARNING(Wcurl_easy_setopt_err_error_buffer,
  336. "curl_easy_setopt expects a "
  337. "char buffer of CURL_ERROR_SIZE as argument")
  338. CURLWARNING(Wcurl_easy_setopt_err_curlu,
  339. "curl_easy_setopt expects a 'CURLU *' argument")
  340. CURLWARNING(Wcurl_easy_setopt_err_curl,
  341. "curl_easy_setopt expects a 'CURL *' argument")
  342. CURLWARNING(Wcurl_easy_setopt_err_FILE,
  343. "curl_easy_setopt expects a 'FILE *' argument")
  344. CURLWARNING(Wcurl_easy_setopt_err_postfields,
  345. "curl_easy_setopt expects a 'void *' or 'char *' argument")
  346. CURLWARNING(Wcurl_easy_setopt_err_curl_httpost,
  347. "curl_easy_setopt expects a 'struct curl_httppost *' "
  348. "argument")
  349. CURLWARNING(Wcurl_easy_setopt_err_curl_mimepost,
  350. "curl_easy_setopt expects a 'curl_mime *' "
  351. "argument")
  352. CURLWARNING(Wcurl_easy_setopt_err_curl_slist,
  353. "curl_easy_setopt expects a 'struct curl_slist *' argument")
  354. CURLWARNING(Wcurl_easy_setopt_err_CURLSH,
  355. "curl_easy_setopt expects a CURLSH* argument")
  356. CURLWARNING(Wcurl_easy_getinfo_err_string,
  357. "curl_easy_getinfo expects a pointer to 'char *'")
  358. CURLWARNING(Wcurl_easy_getinfo_err_long,
  359. "curl_easy_getinfo expects a pointer to long")
  360. CURLWARNING(Wcurl_easy_getinfo_err_double,
  361. "curl_easy_getinfo expects a pointer to double")
  362. CURLWARNING(Wcurl_easy_getinfo_err_curl_slist,
  363. "curl_easy_getinfo expects a pointer to 'struct curl_slist *'")
  364. CURLWARNING(Wcurl_easy_getinfo_err_curl_tlssessioninfo,
  365. "curl_easy_getinfo expects a pointer to "
  366. "'struct curl_tlssessioninfo *'")
  367. CURLWARNING(Wcurl_easy_getinfo_err_curl_certinfo,
  368. "curl_easy_getinfo expects a pointer to "
  369. "'struct curl_certinfo *'")
  370. CURLWARNING(Wcurl_easy_getinfo_err_curl_socket,
  371. "curl_easy_getinfo expects a pointer to curl_socket_t")
  372. CURLWARNING(Wcurl_easy_getinfo_err_curl_off_t,
  373. "curl_easy_getinfo expects a pointer to curl_off_t")
  374. /* groups of curl_easy_setops options that take the same type of argument */
  375. /* evaluates to true if option takes a long argument */
  376. #define curlcheck_long_option(option) \
  377. (0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
  378. #define curlcheck_off_t_option(option) \
  379. (((option) > CURLOPTTYPE_OFF_T) && ((option) < CURLOPTTYPE_BLOB))
  380. /* option takes a CURL * argument */
  381. #define curlcheck_curl_option(option) \
  382. ((option) == CURLOPT_STREAM_DEPENDS || \
  383. (option) == CURLOPT_STREAM_DEPENDS_E || \
  384. 0)
  385. /* evaluates to true if option takes a char* argument */
  386. #define curlcheck_string_option(option) \
  387. ((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \
  388. (option) == CURLOPT_ACCEPT_ENCODING || \
  389. (option) == CURLOPT_ALTSVC || \
  390. (option) == CURLOPT_CAINFO || \
  391. (option) == CURLOPT_CAPATH || \
  392. (option) == CURLOPT_COOKIE || \
  393. (option) == CURLOPT_COOKIEFILE || \
  394. (option) == CURLOPT_COOKIEJAR || \
  395. (option) == CURLOPT_COOKIELIST || \
  396. (option) == CURLOPT_CRLFILE || \
  397. (option) == CURLOPT_CUSTOMREQUEST || \
  398. (option) == CURLOPT_DEFAULT_PROTOCOL || \
  399. (option) == CURLOPT_DNS_INTERFACE || \
  400. (option) == CURLOPT_DNS_LOCAL_IP4 || \
  401. (option) == CURLOPT_DNS_LOCAL_IP6 || \
  402. (option) == CURLOPT_DNS_SERVERS || \
  403. (option) == CURLOPT_DOH_URL || \
  404. (option) == CURLOPT_ECH || \
  405. (option) == CURLOPT_EGDSOCKET || \
  406. (option) == CURLOPT_FTP_ACCOUNT || \
  407. (option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \
  408. (option) == CURLOPT_FTPPORT || \
  409. (option) == CURLOPT_HAPROXY_CLIENT_IP || \
  410. (option) == CURLOPT_HSTS || \
  411. (option) == CURLOPT_INTERFACE || \
  412. (option) == CURLOPT_ISSUERCERT || \
  413. (option) == CURLOPT_KEYPASSWD || \
  414. (option) == CURLOPT_KRBLEVEL || \
  415. (option) == CURLOPT_LOGIN_OPTIONS || \
  416. (option) == CURLOPT_MAIL_AUTH || \
  417. (option) == CURLOPT_MAIL_FROM || \
  418. (option) == CURLOPT_NETRC_FILE || \
  419. (option) == CURLOPT_NOPROXY || \
  420. (option) == CURLOPT_PASSWORD || \
  421. (option) == CURLOPT_PINNEDPUBLICKEY || \
  422. (option) == CURLOPT_PRE_PROXY || \
  423. (option) == CURLOPT_PROTOCOLS_STR || \
  424. (option) == CURLOPT_PROXY || \
  425. (option) == CURLOPT_PROXY_CAINFO || \
  426. (option) == CURLOPT_PROXY_CAPATH || \
  427. (option) == CURLOPT_PROXY_CRLFILE || \
  428. (option) == CURLOPT_PROXY_ISSUERCERT || \
  429. (option) == CURLOPT_PROXY_KEYPASSWD || \
  430. (option) == CURLOPT_PROXY_PINNEDPUBLICKEY || \
  431. (option) == CURLOPT_PROXY_SERVICE_NAME || \
  432. (option) == CURLOPT_PROXY_SSL_CIPHER_LIST || \
  433. (option) == CURLOPT_PROXY_SSLCERT || \
  434. (option) == CURLOPT_PROXY_SSLCERTTYPE || \
  435. (option) == CURLOPT_PROXY_SSLKEY || \
  436. (option) == CURLOPT_PROXY_SSLKEYTYPE || \
  437. (option) == CURLOPT_PROXY_TLS13_CIPHERS || \
  438. (option) == CURLOPT_PROXY_TLSAUTH_PASSWORD || \
  439. (option) == CURLOPT_PROXY_TLSAUTH_TYPE || \
  440. (option) == CURLOPT_PROXY_TLSAUTH_USERNAME || \
  441. (option) == CURLOPT_PROXYPASSWORD || \
  442. (option) == CURLOPT_PROXYUSERNAME || \
  443. (option) == CURLOPT_PROXYUSERPWD || \
  444. (option) == CURLOPT_RANDOM_FILE || \
  445. (option) == CURLOPT_RANGE || \
  446. (option) == CURLOPT_REDIR_PROTOCOLS_STR || \
  447. (option) == CURLOPT_REFERER || \
  448. (option) == CURLOPT_REQUEST_TARGET || \
  449. (option) == CURLOPT_RTSP_SESSION_ID || \
  450. (option) == CURLOPT_RTSP_STREAM_URI || \
  451. (option) == CURLOPT_RTSP_TRANSPORT || \
  452. (option) == CURLOPT_SASL_AUTHZID || \
  453. (option) == CURLOPT_SERVICE_NAME || \
  454. (option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \
  455. (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \
  456. (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 || \
  457. (option) == CURLOPT_SSH_KNOWNHOSTS || \
  458. (option) == CURLOPT_SSH_PRIVATE_KEYFILE || \
  459. (option) == CURLOPT_SSH_PUBLIC_KEYFILE || \
  460. (option) == CURLOPT_SSLCERT || \
  461. (option) == CURLOPT_SSLCERTTYPE || \
  462. (option) == CURLOPT_SSLENGINE || \
  463. (option) == CURLOPT_SSLKEY || \
  464. (option) == CURLOPT_SSLKEYTYPE || \
  465. (option) == CURLOPT_SSL_CIPHER_LIST || \
  466. (option) == CURLOPT_SSL_EC_CURVES || \
  467. (option) == CURLOPT_SSL_SIGNATURE_ALGORITHMS || \
  468. (option) == CURLOPT_TLS13_CIPHERS || \
  469. (option) == CURLOPT_TLSAUTH_PASSWORD || \
  470. (option) == CURLOPT_TLSAUTH_TYPE || \
  471. (option) == CURLOPT_TLSAUTH_USERNAME || \
  472. (option) == CURLOPT_UNIX_SOCKET_PATH || \
  473. (option) == CURLOPT_URL || \
  474. (option) == CURLOPT_USERAGENT || \
  475. (option) == CURLOPT_USERNAME || \
  476. (option) == CURLOPT_AWS_SIGV4 || \
  477. (option) == CURLOPT_USERPWD || \
  478. (option) == CURLOPT_XOAUTH2_BEARER || \
  479. 0)
  480. /* evaluates to true if option takes a curl_write_callback argument */
  481. #define curlcheck_write_cb_option(option) \
  482. ((option) == CURLOPT_HEADERFUNCTION || \
  483. (option) == CURLOPT_WRITEFUNCTION)
  484. /* evaluates to true if option takes a curl_conv_callback argument */
  485. #define curlcheck_conv_cb_option(option) \
  486. ((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \
  487. (option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \
  488. (option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)
  489. /* evaluates to true if option takes a data argument to pass to a callback */
  490. #define curlcheck_cb_data_option(option) \
  491. ((option) == CURLOPT_CHUNK_DATA || \
  492. (option) == CURLOPT_CLOSESOCKETDATA || \
  493. (option) == CURLOPT_DEBUGDATA || \
  494. (option) == CURLOPT_FNMATCH_DATA || \
  495. (option) == CURLOPT_HEADERDATA || \
  496. (option) == CURLOPT_HSTSREADDATA || \
  497. (option) == CURLOPT_HSTSWRITEDATA || \
  498. (option) == CURLOPT_INTERLEAVEDATA || \
  499. (option) == CURLOPT_IOCTLDATA || \
  500. (option) == CURLOPT_OPENSOCKETDATA || \
  501. (option) == CURLOPT_PREREQDATA || \
  502. (option) == CURLOPT_XFERINFODATA || \
  503. (option) == CURLOPT_READDATA || \
  504. (option) == CURLOPT_SEEKDATA || \
  505. (option) == CURLOPT_SOCKOPTDATA || \
  506. (option) == CURLOPT_SSH_KEYDATA || \
  507. (option) == CURLOPT_SSL_CTX_DATA || \
  508. (option) == CURLOPT_WRITEDATA || \
  509. (option) == CURLOPT_RESOLVER_START_DATA || \
  510. (option) == CURLOPT_TRAILERDATA || \
  511. (option) == CURLOPT_SSH_HOSTKEYDATA || \
  512. 0)
  513. /* evaluates to true if option takes a POST data argument (void* or char*) */
  514. #define curlcheck_postfields_option(option) \
  515. ((option) == CURLOPT_POSTFIELDS || \
  516. (option) == CURLOPT_COPYPOSTFIELDS || \
  517. 0)
  518. /* evaluates to true if option takes a struct curl_slist * argument */
  519. #define curlcheck_slist_option(option) \
  520. ((option) == CURLOPT_HTTP200ALIASES || \
  521. (option) == CURLOPT_HTTPHEADER || \
  522. (option) == CURLOPT_MAIL_RCPT || \
  523. (option) == CURLOPT_POSTQUOTE || \
  524. (option) == CURLOPT_PREQUOTE || \
  525. (option) == CURLOPT_PROXYHEADER || \
  526. (option) == CURLOPT_QUOTE || \
  527. (option) == CURLOPT_RESOLVE || \
  528. (option) == CURLOPT_TELNETOPTIONS || \
  529. (option) == CURLOPT_CONNECT_TO || \
  530. 0)
  531. /* groups of curl_easy_getinfo infos that take the same type of argument */
  532. /* evaluates to true if info expects a pointer to char * argument */
  533. #define curlcheck_string_info(info) \
  534. (CURLINFO_STRING < (info) && (info) < CURLINFO_LONG && \
  535. (info) != CURLINFO_PRIVATE)
  536. /* evaluates to true if info expects a pointer to long argument */
  537. #define curlcheck_long_info(info) \
  538. (CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)
  539. /* evaluates to true if info expects a pointer to double argument */
  540. #define curlcheck_double_info(info) \
  541. (CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)
  542. /* true if info expects a pointer to struct curl_slist * argument */
  543. #define curlcheck_slist_info(info) \
  544. (((info) == CURLINFO_SSL_ENGINES) || ((info) == CURLINFO_COOKIELIST))
  545. /* true if info expects a pointer to struct curl_tlssessioninfo * argument */
  546. #define curlcheck_tlssessioninfo_info(info) \
  547. (((info) == CURLINFO_TLS_SSL_PTR) || ((info) == CURLINFO_TLS_SESSION))
  548. /* true if info expects a pointer to struct curl_certinfo * argument */
  549. #define curlcheck_certinfo_info(info) ((info) == CURLINFO_CERTINFO)
  550. /* true if info expects a pointer to struct curl_socket_t argument */
  551. #define curlcheck_socket_info(info) \
  552. (CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T)
  553. /* true if info expects a pointer to curl_off_t argument */
  554. #define curlcheck_off_t_info(info) \
  555. (CURLINFO_OFF_T < (info))
  556. /* typecheck helpers -- check whether given expression has requested type */
  557. /* For pointers, you can use the curlcheck_ptr/curlcheck_arr macros,
  558. * otherwise define a new macro. Search for __builtin_types_compatible_p
  559. * in the GCC manual.
  560. * NOTE: these macros MUST NOT EVALUATE their arguments! The argument is
  561. * the actual expression passed to the curl_easy_setopt macro. This
  562. * means that you can only apply the sizeof and __typeof__ operators, no
  563. * == or whatsoever.
  564. */
  565. /* XXX: should evaluate to true if expr is a pointer */
  566. #define curlcheck_any_ptr(expr) \
  567. (sizeof(expr) == sizeof(void *))
  568. /* evaluates to true if expr is NULL */
  569. /* XXX: must not evaluate expr, so this check is not accurate */
  570. #define curlcheck_NULL(expr) \
  571. (__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))
  572. /* evaluates to true if expr is type*, const type* or NULL */
  573. #define curlcheck_ptr(expr, type) \
  574. (curlcheck_NULL(expr) || \
  575. __builtin_types_compatible_p(__typeof__(expr), type *) || \
  576. __builtin_types_compatible_p(__typeof__(expr), const type *))
  577. /* evaluates to true if expr is type**, const type** or NULL */
  578. #define curlcheck_ptrptr(expr, type) \
  579. (curlcheck_NULL(expr) || \
  580. __builtin_types_compatible_p(__typeof__(expr), type **) || \
  581. __builtin_types_compatible_p(__typeof__(expr), type *[]) || \
  582. __builtin_types_compatible_p(__typeof__(expr), const type *[]) || \
  583. __builtin_types_compatible_p(__typeof__(expr), const type **))
  584. /* evaluates to true if expr is one of type[], type*, NULL or const type* */
  585. #define curlcheck_arr(expr, type) \
  586. (curlcheck_ptr((expr), type) || \
  587. __builtin_types_compatible_p(__typeof__(expr), type []))
  588. /* evaluates to true if expr is a string */
  589. #define curlcheck_string(expr) \
  590. (curlcheck_arr((expr), char) || \
  591. curlcheck_arr((expr), signed char) || \
  592. curlcheck_arr((expr), unsigned char))
  593. /* evaluates to true if expr is a CURL * */
  594. #define curlcheck_curl(expr) \
  595. (curlcheck_NULL(expr) || \
  596. __builtin_types_compatible_p(__typeof__(expr), CURL *))
  597. /* evaluates to true if expr is a long (no matter the signedness)
  598. * XXX: for now, int is also accepted (and therefore short and char, which
  599. * are promoted to int when passed to a variadic function) */
  600. #define curlcheck_long(expr) \
  601. ( \
  602. ((sizeof(long) != sizeof(int)) && \
  603. (__builtin_types_compatible_p(__typeof__(expr), long) || \
  604. __builtin_types_compatible_p(__typeof__(expr), signed long) || \
  605. __builtin_types_compatible_p(__typeof__(expr), unsigned long))) \
  606. || \
  607. ((sizeof(long) == sizeof(int)) && \
  608. (__builtin_types_compatible_p(__typeof__(expr), long) || \
  609. __builtin_types_compatible_p(__typeof__(expr), signed long) || \
  610. __builtin_types_compatible_p(__typeof__(expr), unsigned long) || \
  611. __builtin_types_compatible_p(__typeof__(expr), int) || \
  612. __builtin_types_compatible_p(__typeof__(expr), signed int) || \
  613. __builtin_types_compatible_p(__typeof__(expr), unsigned int) || \
  614. __builtin_types_compatible_p(__typeof__(expr), short) || \
  615. __builtin_types_compatible_p(__typeof__(expr), signed short) || \
  616. __builtin_types_compatible_p(__typeof__(expr), unsigned short) || \
  617. __builtin_types_compatible_p(__typeof__(expr), char) || \
  618. __builtin_types_compatible_p(__typeof__(expr), signed char) || \
  619. __builtin_types_compatible_p(__typeof__(expr), unsigned char))) \
  620. )
  621. /* evaluates to true if expr is of type curl_off_t */
  622. #define curlcheck_off_t(expr) \
  623. (__builtin_types_compatible_p(__typeof__(expr), curl_off_t))
  624. /* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
  625. /* XXX: also check size of an char[] array? */
  626. #define curlcheck_error_buffer(expr) \
  627. (curlcheck_NULL(expr) || \
  628. __builtin_types_compatible_p(__typeof__(expr), char *) || \
  629. __builtin_types_compatible_p(__typeof__(expr), char[]))
  630. /* evaluates to true if expr is of type (const) void* or (const) FILE* */
  631. #if 0
  632. #define curlcheck_cb_data(expr) \
  633. (curlcheck_ptr((expr), void) || \
  634. curlcheck_ptr((expr), FILE))
  635. #else /* be less strict */
  636. #define curlcheck_cb_data(expr) \
  637. curlcheck_any_ptr(expr)
  638. #endif
  639. /* evaluates to true if expr is of type FILE* */
  640. #define curlcheck_FILE(expr) \
  641. (curlcheck_NULL(expr) || \
  642. (__builtin_types_compatible_p(__typeof__(expr), FILE *)))
  643. /* evaluates to true if expr can be passed as POST data (void* or char*) */
  644. #define curlcheck_postfields(expr) \
  645. (curlcheck_ptr((expr), void) || \
  646. curlcheck_arr((expr), char) || \
  647. curlcheck_arr((expr), unsigned char))
  648. /* helper: __builtin_types_compatible_p distinguishes between functions and
  649. * function pointers, hide it */
  650. #define curlcheck_cb_compatible(func, type) \
  651. (__builtin_types_compatible_p(__typeof__(func), type) || \
  652. __builtin_types_compatible_p(__typeof__(func) *, type))
  653. /* evaluates to true if expr is of type curl_resolver_start_callback */
  654. #define curlcheck_resolver_start_callback(expr) \
  655. (curlcheck_NULL(expr) || \
  656. curlcheck_cb_compatible((expr), curl_resolver_start_callback))
  657. /* evaluates to true if expr is of type curl_read_callback or "similar" */
  658. #define curlcheck_read_cb(expr) \
  659. (curlcheck_NULL(expr) || \
  660. curlcheck_cb_compatible((expr), __typeof__(fread) *) || \
  661. curlcheck_cb_compatible((expr), curl_read_callback) || \
  662. curlcheck_cb_compatible((expr), Wcurl_read_callback1) || \
  663. curlcheck_cb_compatible((expr), Wcurl_read_callback2) || \
  664. curlcheck_cb_compatible((expr), Wcurl_read_callback3) || \
  665. curlcheck_cb_compatible((expr), Wcurl_read_callback4) || \
  666. curlcheck_cb_compatible((expr), Wcurl_read_callback5) || \
  667. curlcheck_cb_compatible((expr), Wcurl_read_callback6))
  668. typedef size_t (*Wcurl_read_callback1)(char *, size_t, size_t, void *);
  669. typedef size_t (*Wcurl_read_callback2)(char *, size_t, size_t, const void *);
  670. typedef size_t (*Wcurl_read_callback3)(char *, size_t, size_t, FILE *);
  671. typedef size_t (*Wcurl_read_callback4)(void *, size_t, size_t, void *);
  672. typedef size_t (*Wcurl_read_callback5)(void *, size_t, size_t, const void *);
  673. typedef size_t (*Wcurl_read_callback6)(void *, size_t, size_t, FILE *);
  674. /* evaluates to true if expr is of type curl_write_callback or "similar" */
  675. #define curlcheck_write_cb(expr) \
  676. (curlcheck_read_cb(expr) || \
  677. curlcheck_cb_compatible((expr), __typeof__(fwrite) *) || \
  678. curlcheck_cb_compatible((expr), curl_write_callback) || \
  679. curlcheck_cb_compatible((expr), Wcurl_write_callback1) || \
  680. curlcheck_cb_compatible((expr), Wcurl_write_callback2) || \
  681. curlcheck_cb_compatible((expr), Wcurl_write_callback3) || \
  682. curlcheck_cb_compatible((expr), Wcurl_write_callback4) || \
  683. curlcheck_cb_compatible((expr), Wcurl_write_callback5) || \
  684. curlcheck_cb_compatible((expr), Wcurl_write_callback6))
  685. typedef size_t (*Wcurl_write_callback1)(const char *, size_t, size_t, void *);
  686. typedef size_t (*Wcurl_write_callback2)(const char *, size_t, size_t,
  687. const void *);
  688. typedef size_t (*Wcurl_write_callback3)(const char *, size_t, size_t, FILE *);
  689. typedef size_t (*Wcurl_write_callback4)(const void *, size_t, size_t, void *);
  690. typedef size_t (*Wcurl_write_callback5)(const void *, size_t, size_t,
  691. const void *);
  692. typedef size_t (*Wcurl_write_callback6)(const void *, size_t, size_t, FILE *);
  693. /* evaluates to true if expr is of type curl_ioctl_callback or "similar" */
  694. #define curlcheck_ioctl_cb(expr) \
  695. (curlcheck_NULL(expr) || \
  696. curlcheck_cb_compatible((expr), curl_ioctl_callback) || \
  697. curlcheck_cb_compatible((expr), Wcurl_ioctl_callback1) || \
  698. curlcheck_cb_compatible((expr), Wcurl_ioctl_callback2) || \
  699. curlcheck_cb_compatible((expr), Wcurl_ioctl_callback3) || \
  700. curlcheck_cb_compatible((expr), Wcurl_ioctl_callback4))
  701. typedef curlioerr (*Wcurl_ioctl_callback1)(CURL *, int, void *);
  702. typedef curlioerr (*Wcurl_ioctl_callback2)(CURL *, int, const void *);
  703. typedef curlioerr (*Wcurl_ioctl_callback3)(CURL *, curliocmd, void *);
  704. typedef curlioerr (*Wcurl_ioctl_callback4)(CURL *, curliocmd, const void *);
  705. /* evaluates to true if expr is of type curl_sockopt_callback or "similar" */
  706. #define curlcheck_sockopt_cb(expr) \
  707. (curlcheck_NULL(expr) || \
  708. curlcheck_cb_compatible((expr), curl_sockopt_callback) || \
  709. curlcheck_cb_compatible((expr), Wcurl_sockopt_callback1) || \
  710. curlcheck_cb_compatible((expr), Wcurl_sockopt_callback2))
  711. typedef int (*Wcurl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);
  712. typedef int (*Wcurl_sockopt_callback2)(const void *, curl_socket_t,
  713. curlsocktype);
  714. /* evaluates to true if expr is of type curl_opensocket_callback or
  715. "similar" */
  716. #define curlcheck_opensocket_cb(expr) \
  717. (curlcheck_NULL(expr) || \
  718. curlcheck_cb_compatible((expr), curl_opensocket_callback) || \
  719. curlcheck_cb_compatible((expr), Wcurl_opensocket_callback1) || \
  720. curlcheck_cb_compatible((expr), Wcurl_opensocket_callback2) || \
  721. curlcheck_cb_compatible((expr), Wcurl_opensocket_callback3) || \
  722. curlcheck_cb_compatible((expr), Wcurl_opensocket_callback4))
  723. typedef curl_socket_t (*Wcurl_opensocket_callback1)
  724. (void *, curlsocktype, struct curl_sockaddr *);
  725. typedef curl_socket_t (*Wcurl_opensocket_callback2)
  726. (void *, curlsocktype, const struct curl_sockaddr *);
  727. typedef curl_socket_t (*Wcurl_opensocket_callback3)
  728. (const void *, curlsocktype, struct curl_sockaddr *);
  729. typedef curl_socket_t (*Wcurl_opensocket_callback4)
  730. (const void *, curlsocktype, const struct curl_sockaddr *);
  731. /* evaluates to true if expr is of type curl_progress_callback or "similar" */
  732. #define curlcheck_progress_cb(expr) \
  733. (curlcheck_NULL(expr) || \
  734. curlcheck_cb_compatible((expr), curl_progress_callback) || \
  735. curlcheck_cb_compatible((expr), Wcurl_progress_callback1) || \
  736. curlcheck_cb_compatible((expr), Wcurl_progress_callback2))
  737. typedef int (*Wcurl_progress_callback1)(void *,
  738. double, double, double, double);
  739. typedef int (*Wcurl_progress_callback2)(const void *,
  740. double, double, double, double);
  741. /* evaluates to true if expr is of type curl_xferinfo_callback */
  742. #define curlcheck_xferinfo_cb(expr) \
  743. (curlcheck_NULL(expr) || \
  744. curlcheck_cb_compatible((expr), curl_xferinfo_callback))
  745. /* evaluates to true if expr is of type curl_debug_callback or "similar" */
  746. #define curlcheck_debug_cb(expr) \
  747. (curlcheck_NULL(expr) || \
  748. curlcheck_cb_compatible((expr), curl_debug_callback) || \
  749. curlcheck_cb_compatible((expr), Wcurl_debug_callback1) || \
  750. curlcheck_cb_compatible((expr), Wcurl_debug_callback2) || \
  751. curlcheck_cb_compatible((expr), Wcurl_debug_callback3) || \
  752. curlcheck_cb_compatible((expr), Wcurl_debug_callback4) || \
  753. curlcheck_cb_compatible((expr), Wcurl_debug_callback5) || \
  754. curlcheck_cb_compatible((expr), Wcurl_debug_callback6) || \
  755. curlcheck_cb_compatible((expr), Wcurl_debug_callback7) || \
  756. curlcheck_cb_compatible((expr), Wcurl_debug_callback8))
  757. typedef int (*Wcurl_debug_callback1) (CURL *,
  758. curl_infotype, char *, size_t, void *);
  759. typedef int (*Wcurl_debug_callback2) (CURL *,
  760. curl_infotype, char *, size_t, const void *);
  761. typedef int (*Wcurl_debug_callback3) (CURL *,
  762. curl_infotype, const char *, size_t, void *);
  763. typedef int (*Wcurl_debug_callback4) (CURL *,
  764. curl_infotype, const char *, size_t, const void *);
  765. typedef int (*Wcurl_debug_callback5) (CURL *,
  766. curl_infotype, unsigned char *, size_t, void *);
  767. typedef int (*Wcurl_debug_callback6) (CURL *,
  768. curl_infotype, unsigned char *, size_t, const void *);
  769. typedef int (*Wcurl_debug_callback7) (CURL *,
  770. curl_infotype, const unsigned char *, size_t, void *);
  771. typedef int (*Wcurl_debug_callback8) (CURL *,
  772. curl_infotype, const unsigned char *, size_t, const void *);
  773. /* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
  774. /* this is getting even messier... */
  775. #define curlcheck_ssl_ctx_cb(expr) \
  776. (curlcheck_NULL(expr) || \
  777. curlcheck_cb_compatible((expr), curl_ssl_ctx_callback) || \
  778. curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback1) || \
  779. curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback2) || \
  780. curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback3) || \
  781. curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback4) || \
  782. curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback5) || \
  783. curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback6) || \
  784. curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback7) || \
  785. curlcheck_cb_compatible((expr), Wcurl_ssl_ctx_callback8))
  786. typedef CURLcode (*Wcurl_ssl_ctx_callback1)(CURL *, void *, void *);
  787. typedef CURLcode (*Wcurl_ssl_ctx_callback2)(CURL *, void *, const void *);
  788. typedef CURLcode (*Wcurl_ssl_ctx_callback3)(CURL *, const void *, void *);
  789. typedef CURLcode (*Wcurl_ssl_ctx_callback4)(CURL *, const void *,
  790. const void *);
  791. #ifdef HEADER_SSL_H
  792. /* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX
  793. * this will of course break if we are included before OpenSSL headers...
  794. */
  795. typedef CURLcode (*Wcurl_ssl_ctx_callback5)(CURL *, SSL_CTX *, void *);
  796. typedef CURLcode (*Wcurl_ssl_ctx_callback6)(CURL *, SSL_CTX *, const void *);
  797. typedef CURLcode (*Wcurl_ssl_ctx_callback7)(CURL *, const SSL_CTX *, void *);
  798. typedef CURLcode (*Wcurl_ssl_ctx_callback8)(CURL *, const SSL_CTX *,
  799. const void *);
  800. #else
  801. typedef Wcurl_ssl_ctx_callback1 Wcurl_ssl_ctx_callback5;
  802. typedef Wcurl_ssl_ctx_callback1 Wcurl_ssl_ctx_callback6;
  803. typedef Wcurl_ssl_ctx_callback1 Wcurl_ssl_ctx_callback7;
  804. typedef Wcurl_ssl_ctx_callback1 Wcurl_ssl_ctx_callback8;
  805. #endif
  806. /* evaluates to true if expr is of type curl_conv_callback or "similar" */
  807. #define curlcheck_conv_cb(expr) \
  808. (curlcheck_NULL(expr) || \
  809. curlcheck_cb_compatible((expr), curl_conv_callback) || \
  810. curlcheck_cb_compatible((expr), Wcurl_conv_callback1) || \
  811. curlcheck_cb_compatible((expr), Wcurl_conv_callback2) || \
  812. curlcheck_cb_compatible((expr), Wcurl_conv_callback3) || \
  813. curlcheck_cb_compatible((expr), Wcurl_conv_callback4))
  814. typedef CURLcode (*Wcurl_conv_callback1)(char *, size_t length);
  815. typedef CURLcode (*Wcurl_conv_callback2)(const char *, size_t length);
  816. typedef CURLcode (*Wcurl_conv_callback3)(void *, size_t length);
  817. typedef CURLcode (*Wcurl_conv_callback4)(const void *, size_t length);
  818. /* evaluates to true if expr is of type curl_seek_callback or "similar" */
  819. #define curlcheck_seek_cb(expr) \
  820. (curlcheck_NULL(expr) || \
  821. curlcheck_cb_compatible((expr), curl_seek_callback) || \
  822. curlcheck_cb_compatible((expr), Wcurl_seek_callback1) || \
  823. curlcheck_cb_compatible((expr), Wcurl_seek_callback2))
  824. typedef CURLcode (*Wcurl_seek_callback1)(void *, curl_off_t, int);
  825. typedef CURLcode (*Wcurl_seek_callback2)(const void *, curl_off_t, int);
  826. /* evaluates to true if expr is of type curl_chunk_bgn_callback */
  827. #define curlcheck_chunk_bgn_cb(expr) \
  828. (curlcheck_NULL(expr) || \
  829. curlcheck_cb_compatible((expr), curl_chunk_bgn_callback) || \
  830. curlcheck_cb_compatible((expr), Wcurl_chunk_bgn_callback1) || \
  831. curlcheck_cb_compatible((expr), Wcurl_chunk_bgn_callback2))
  832. typedef long (*Wcurl_chunk_bgn_callback1)(struct curl_fileinfo *,
  833. void *, int);
  834. typedef long (*Wcurl_chunk_bgn_callback2)(void *, void *, int);
  835. /* evaluates to true if expr is of type curl_chunk_end_callback */
  836. #define curlcheck_chunk_end_cb(expr) \
  837. (curlcheck_NULL(expr) || \
  838. curlcheck_cb_compatible((expr), curl_chunk_end_callback))
  839. /* evaluates to true if expr is of type curl_closesocket_callback */
  840. #define curlcheck_close_socket_cb(expr) \
  841. (curlcheck_NULL(expr) || \
  842. curlcheck_cb_compatible((expr), curl_closesocket_callback))
  843. /* evaluates to true if expr is of type curl_fnmatch_callback */
  844. #define curlcheck_fnmatch_cb(expr) \
  845. (curlcheck_NULL(expr) || \
  846. curlcheck_cb_compatible((expr), curl_fnmatch_callback))
  847. /* evaluates to true if expr is of type curl_hstsread_callback */
  848. #define curlcheck_hstsread_cb(expr) \
  849. (curlcheck_NULL(expr) || \
  850. curlcheck_cb_compatible((expr), curl_hstsread_callback))
  851. /* evaluates to true if expr is of type curl_hstswrite_callback */
  852. #define curlcheck_hstswrite_cb(expr) \
  853. (curlcheck_NULL(expr) || \
  854. curlcheck_cb_compatible((expr), curl_hstswrite_callback))
  855. /* evaluates to true if expr is of type curl_sshhostkeycallback */
  856. #define curlcheck_ssh_hostkey_cb(expr) \
  857. (curlcheck_NULL(expr) || \
  858. curlcheck_cb_compatible((expr), curl_sshhostkeycallback))
  859. /* evaluates to true if expr is of type curl_sshkeycallback */
  860. #define curlcheck_ssh_key_cb(expr) \
  861. (curlcheck_NULL(expr) || \
  862. curlcheck_cb_compatible((expr), curl_sshkeycallback))
  863. /* evaluates to true if expr is of type curl_interleave_callback */
  864. #define curlcheck_interleave_cb(expr) \
  865. (curlcheck_NULL(expr) || \
  866. curlcheck_cb_compatible((expr), Wcurl_interleave_callback1) || \
  867. curlcheck_cb_compatible((expr), Wcurl_interleave_callback2))
  868. typedef size_t (*Wcurl_interleave_callback1)(void *p, size_t s,
  869. size_t n, void *u);
  870. typedef size_t (*Wcurl_interleave_callback2)(char *p, size_t s,
  871. size_t n, void *u);
  872. /* evaluates to true if expr is of type curl_prereq_callback */
  873. #define curlcheck_prereq_cb(expr) \
  874. (curlcheck_NULL(expr) || \
  875. curlcheck_cb_compatible((expr), curl_prereq_callback))
  876. /* evaluates to true if expr is of type curl_trailer_callback */
  877. #define curlcheck_trailer_cb(expr) \
  878. (curlcheck_NULL(expr) || \
  879. curlcheck_cb_compatible((expr), curl_trailer_callback))
  880. #endif /* CURLINC_TYPECHECK_GCC_H */