lib1912.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. *
  10. * This software is licensed as described in the file COPYING, which
  11. * you should have received as part of this distribution. The terms
  12. * are also available at https://curl.se/docs/copyright.html.
  13. *
  14. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. * copies of the Software, and permit persons to whom the Software is
  16. * furnished to do so, under the terms of the COPYING file.
  17. *
  18. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. * KIND, either express or implied.
  20. *
  21. ***************************************************************************/
  22. #include "test.h"
  23. #include "testutil.h"
  24. #include "warnless.h"
  25. #include "memdebug.h"
  26. #define print_err(name, exp) \
  27. fprintf(stderr, "Type mismatch for CURLOPT_%s (expected %s)\n", name, exp);
  28. int test(char *URL)
  29. {
  30. /* Only test if GCC typechecking is available */
  31. int error = 0;
  32. #ifdef CURLINC_TYPECHECK_GCC_H
  33. const struct curl_easyoption *o;
  34. for(o = curl_easy_option_next(NULL);
  35. o;
  36. o = curl_easy_option_next(o)) {
  37. /* Test for mismatch OR missing typecheck macros */
  38. if(curlcheck_long_option(o->id) !=
  39. (o->type == CURLOT_LONG || o->type == CURLOT_VALUES)) {
  40. print_err(o->name, "CURLOT_LONG or CURLOT_VALUES");
  41. error++;
  42. }
  43. if(curlcheck_off_t_option(o->id) != (o->type == CURLOT_OFF_T)) {
  44. print_err(o->name, "CURLOT_OFF_T");
  45. error++;
  46. }
  47. if(curlcheck_string_option(o->id) != (o->type == CURLOT_STRING)) {
  48. print_err(o->name, "CURLOT_STRING");
  49. error++;
  50. }
  51. if(curlcheck_slist_option(o->id) != (o->type == CURLOT_SLIST)) {
  52. print_err(o->name, "CURLOT_SLIST");
  53. error++;
  54. }
  55. if(curlcheck_cb_data_option(o->id) != (o->type == CURLOT_CBPTR)) {
  56. print_err(o->name, "CURLOT_CBPTR");
  57. error++;
  58. }
  59. /* From here: only test that the type matches if macro is known */
  60. if(curlcheck_write_cb_option(o->id) && (o->type != CURLOT_FUNCTION)) {
  61. print_err(o->name, "CURLOT_FUNCTION");
  62. error++;
  63. }
  64. if(curlcheck_conv_cb_option(o->id) && (o->type != CURLOT_FUNCTION)) {
  65. print_err(o->name, "CURLOT_FUNCTION");
  66. error++;
  67. }
  68. if(curlcheck_postfields_option(o->id) && (o->type != CURLOT_OBJECT)) {
  69. print_err(o->name, "CURLOT_OBJECT");
  70. error++;
  71. }
  72. /* Todo: no gcc typecheck for CURLOPTTYPE_BLOB types? */
  73. }
  74. #endif
  75. (void)URL;
  76. return error;
  77. }