blob: d42f80fe31c085601b6caaf6db1d4e6d40c157e5 [file] [log] [blame]
xf.li6c8fc1e2023-08-12 00:11:09 -07001/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) 1998 - 2022, 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 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "test.h"
25
26#include "testutil.h"
27#include "warnless.h"
28#include "memdebug.h"
29
30#define print_err(name, exp) \
31 fprintf(stderr, "Type mismatch for CURLOPT_%s (expected %s)\n", name, exp);
32
33int test(char *URL)
34{
35/* Only test if GCC typechecking is available */
36 int error = 0;
37#ifdef CURLINC_TYPECHECK_GCC_H
38 const struct curl_easyoption *o;
39 for(o = curl_easy_option_next(NULL);
40 o;
41 o = curl_easy_option_next(o)) {
42 /* Test for mismatch OR missing typecheck macros */
43 if(curlcheck_long_option(o->id) !=
44 (o->type == CURLOT_LONG || o->type == CURLOT_VALUES)) {
45 print_err(o->name, "CURLOT_LONG or CURLOT_VALUES");
46 error++;
47 }
48 if(curlcheck_off_t_option(o->id) != (o->type == CURLOT_OFF_T)) {
49 print_err(o->name, "CURLOT_OFF_T");
50 error++;
51 }
52 if(curlcheck_string_option(o->id) != (o->type == CURLOT_STRING)) {
53 print_err(o->name, "CURLOT_STRING");
54 error++;
55 }
56 if(curlcheck_slist_option(o->id) != (o->type == CURLOT_SLIST)) {
57 print_err(o->name, "CURLOT_SLIST");
58 error++;
59 }
60 if(curlcheck_cb_data_option(o->id) != (o->type == CURLOT_CBPTR)) {
61 print_err(o->name, "CURLOT_CBPTR");
62 error++;
63 }
64 /* From here: only test that the type matches if macro is known */
65 if(curlcheck_write_cb_option(o->id) && (o->type != CURLOT_FUNCTION)) {
66 print_err(o->name, "CURLOT_FUNCTION");
67 error++;
68 }
69 if(curlcheck_conv_cb_option(o->id) && (o->type != CURLOT_FUNCTION)) {
70 print_err(o->name, "CURLOT_FUNCTION");
71 error++;
72 }
73 if(curlcheck_postfields_option(o->id) && (o->type != CURLOT_OBJECT)) {
74 print_err(o->name, "CURLOT_OBJECT");
75 error++;
76 }
77 /* Todo: no gcc typecheck for CURLOPTTYPE_BLOB types? */
78 }
79#endif
80 (void)URL;
81 return error;
82}