/src/curl/lib/easygetopt.c
Line | Count | Source |
1 | | /*************************************************************************** |
2 | | * _ _ ____ _ |
3 | | * Project ___| | | | _ \| | |
4 | | * / __| | | | |_) | | |
5 | | * | (__| |_| | _ <| |___ |
6 | | * \___|\___/|_| \_\_____| |
7 | | * |
8 | | * Copyright (C) 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 "curl_setup.h" |
25 | | |
26 | | #include "easyoptions.h" |
27 | | |
28 | | #ifndef CURL_DISABLE_GETOPTIONS |
29 | | |
30 | | /* Lookups easy options at runtime */ |
31 | | static const struct curl_easyoption *lookup(const char *name, CURLoption id) |
32 | 0 | { |
33 | 0 | DEBUGASSERT(name || id); |
34 | 0 | DEBUGASSERT(!Curl_easyopts_check()); |
35 | 0 | if(name || id) { |
36 | 0 | const struct curl_easyoption *o = &Curl_easyopts[0]; |
37 | 0 | do { |
38 | 0 | if(name) { |
39 | 0 | if(curl_strequal(o->name, name)) |
40 | 0 | return o; |
41 | 0 | } |
42 | 0 | else { |
43 | 0 | if((o->id == id) && !(o->flags & CURLOT_FLAG_ALIAS)) |
44 | | /* do not match alias options */ |
45 | 0 | return o; |
46 | 0 | } |
47 | 0 | o++; |
48 | 0 | } while(o->name); |
49 | 0 | } |
50 | 0 | return NULL; |
51 | 0 | } |
52 | | |
53 | | const struct curl_easyoption *curl_easy_option_by_name(const char *name) |
54 | 0 | { |
55 | | /* when name is used, the id argument is ignored */ |
56 | 0 | return lookup(name, CURLOPT_LASTENTRY); |
57 | 0 | } |
58 | | |
59 | | const struct curl_easyoption *curl_easy_option_by_id(CURLoption id) |
60 | 0 | { |
61 | 0 | return lookup(NULL, id); |
62 | 0 | } |
63 | | |
64 | | /* Iterates over available options */ |
65 | | const struct curl_easyoption *curl_easy_option_next( |
66 | | const struct curl_easyoption *prev) |
67 | 0 | { |
68 | 0 | if(prev && prev->name) { |
69 | 0 | prev++; |
70 | 0 | if(prev->name) |
71 | 0 | return prev; |
72 | 0 | } |
73 | 0 | else if(!prev) |
74 | 0 | return &Curl_easyopts[0]; |
75 | 0 | return NULL; |
76 | 0 | } |
77 | | |
78 | | #else |
79 | | const struct curl_easyoption *curl_easy_option_by_name(const char *name) |
80 | | { |
81 | | (void)name; |
82 | | return NULL; |
83 | | } |
84 | | |
85 | | const struct curl_easyoption *curl_easy_option_by_id(CURLoption id) |
86 | | { |
87 | | (void)id; |
88 | | return NULL; |
89 | | } |
90 | | |
91 | | const struct curl_easyoption *curl_easy_option_next( |
92 | | const struct curl_easyoption *prev) |
93 | | { |
94 | | (void)prev; |
95 | | return NULL; |
96 | | } |
97 | | #endif |