tool_setopt.h (6206B)
1 #ifndef HEADER_CURL_TOOL_SETOPT_H 2 #define HEADER_CURL_TOOL_SETOPT_H 3 /*************************************************************************** 4 * _ _ ____ _ 5 * Project ___| | | | _ \| | 6 * / __| | | | |_) | | 7 * | (__| |_| | _ <| |___ 8 * \___|\___/|_| \_\_____| 9 * 10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, 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 #include "tool_setup.h" 27 28 #include "tool_formparse.h" 29 30 /* 31 * Macros used in operate() 32 */ 33 34 #ifndef CURL_DISABLE_LIBCURL_OPTION 35 36 /* Associate symbolic names with option values */ 37 struct NameValue { 38 const char *name; 39 long value; 40 }; 41 42 struct NameValueUnsigned { 43 const char *name; 44 unsigned long value; 45 }; 46 47 extern const struct NameValue setopt_nv_CURLPROXY[]; 48 extern const struct NameValue setopt_nv_CURL_SOCKS_PROXY[]; 49 extern const struct NameValue setopt_nv_CURL_HTTP_VERSION[]; 50 extern const struct NameValue setopt_nv_CURL_SSLVERSION[]; 51 extern const struct NameValue setopt_nv_CURL_SSLVERSION_MAX[]; 52 extern const struct NameValue setopt_nv_CURL_TIMECOND[]; 53 extern const struct NameValue setopt_nv_CURLFTPSSL_CCC[]; 54 extern const struct NameValue setopt_nv_CURLUSESSL[]; 55 extern const struct NameValueUnsigned setopt_nv_CURLSSLOPT[]; 56 extern const struct NameValue setopt_nv_CURL_NETRC[]; 57 extern const struct NameValueUnsigned setopt_nv_CURLAUTH[]; 58 extern const struct NameValueUnsigned setopt_nv_CURLHSTS[]; 59 60 /* Map options to NameValue sets */ 61 #define setopt_nv_CURLOPT_HSTS_CTRL setopt_nv_CURLHSTS 62 #define setopt_nv_CURLOPT_HTTP_VERSION setopt_nv_CURL_HTTP_VERSION 63 #define setopt_nv_CURLOPT_HTTPAUTH setopt_nv_CURLAUTH 64 #define setopt_nv_CURLOPT_SSLVERSION setopt_nv_CURL_SSLVERSION 65 #define setopt_nv_CURLOPT_PROXY_SSLVERSION setopt_nv_CURL_SSLVERSION 66 #define setopt_nv_CURLOPT_TIMECONDITION setopt_nv_CURL_TIMECOND 67 #define setopt_nv_CURLOPT_FTP_SSL_CCC setopt_nv_CURLFTPSSL_CCC 68 #define setopt_nv_CURLOPT_USE_SSL setopt_nv_CURLUSESSL 69 #define setopt_nv_CURLOPT_SSL_OPTIONS setopt_nv_CURLSSLOPT 70 #define setopt_nv_CURLOPT_PROXY_SSL_OPTIONS setopt_nv_CURLSSLOPT 71 #define setopt_nv_CURLOPT_NETRC setopt_nv_CURL_NETRC 72 #define setopt_nv_CURLOPT_PROXYTYPE setopt_nv_CURLPROXY 73 #define setopt_nv_CURLOPT_PROXYAUTH setopt_nv_CURLAUTH 74 #define setopt_nv_CURLOPT_SOCKS5_AUTH setopt_nv_CURLAUTH 75 76 /* Intercept setopt calls for --libcurl */ 77 78 CURLcode tool_setopt_enum(CURL *curl, struct OperationConfig *config, 79 const char *name, CURLoption tag, 80 const struct NameValue *nv, long lval); 81 CURLcode tool_setopt_SSLVERSION(CURL *curl, struct OperationConfig *config, 82 const char *name, CURLoption tag, 83 long lval); 84 CURLcode tool_setopt_flags(CURL *curl, struct OperationConfig *config, 85 const char *name, CURLoption tag, 86 const struct NameValue *nv, long lval); 87 CURLcode tool_setopt_bitmask(CURL *curl, struct OperationConfig *config, 88 const char *name, CURLoption tag, 89 const struct NameValueUnsigned *nv, long lval); 90 CURLcode tool_setopt_mimepost(CURL *curl, struct OperationConfig *config, 91 const char *name, CURLoption tag, 92 curl_mime *mimepost); 93 CURLcode tool_setopt_slist(CURL *curl, struct OperationConfig *config, 94 const char *name, CURLoption tag, 95 struct curl_slist *list); 96 CURLcode tool_setopt_long(CURL *curl, struct OperationConfig *config, 97 const char *name, CURLoption tag, 98 long lval); 99 CURLcode tool_setopt_offt(CURL *curl, struct OperationConfig *config, 100 const char *name, CURLoption tag, 101 curl_off_t lval); 102 CURLcode tool_setopt(CURL *curl, bool str, 103 struct OperationConfig *config, 104 const char *name, CURLoption tag, ...); 105 106 #define my_setopt(x,y,z) \ 107 tool_setopt(x, FALSE, config, #y, y, z) 108 109 #define my_setopt_long(x,y,z) \ 110 tool_setopt_long(x, config, #y, y, z) 111 112 #define my_setopt_offt(x,y,z) \ 113 tool_setopt_offt(x, config, #y, y, z) 114 115 #define my_setopt_str(x,y,z) \ 116 tool_setopt(x, TRUE, config, #y, y, z) 117 118 #define my_setopt_enum(x,y,z) \ 119 tool_setopt_enum(x, config, #y, y, setopt_nv_ ## y, z) 120 121 #define my_setopt_SSLVERSION(x,y,z) \ 122 tool_setopt_SSLVERSION(x, config, #y, y, z) 123 124 #define my_setopt_bitmask(x,y,z) \ 125 tool_setopt_bitmask(x, config, #y, y, setopt_nv_ ## y, z) 126 127 #define my_setopt_mimepost(x,y,z) \ 128 tool_setopt_mimepost(x, config, #y, y, z) 129 130 #define my_setopt_slist(x,y,z) \ 131 tool_setopt_slist(x, config, #y, y, z) 132 133 #else /* CURL_DISABLE_LIBCURL_OPTION */ 134 135 /* No --libcurl, so pass options directly to library */ 136 137 #define my_setopt(x,y,z) \ 138 curl_easy_setopt(x, y, z) 139 140 #define my_setopt_long(x,y,z) \ 141 curl_easy_setopt(x, y, (long)(z)) 142 143 #define my_setopt_offt(x,y,z) \ 144 curl_easy_setopt(x, y, (curl_off_t)(z)) 145 146 #define my_setopt_str(x,y,z) \ 147 curl_easy_setopt(x, y, z) 148 149 #define my_setopt_enum(x,y,z) \ 150 curl_easy_setopt(x, y, z) 151 152 #define my_setopt_SSLVERSION(x,y,z) \ 153 curl_easy_setopt(x, y, z) 154 155 #define my_setopt_bitmask(x,y,z) \ 156 curl_easy_setopt(x, y, (long)z) 157 158 #define my_setopt_mimepost(x,y,z) \ 159 curl_easy_setopt(x, y, z) 160 161 #define my_setopt_slist(x,y,z) \ 162 curl_easy_setopt(x, y, z) 163 164 #endif /* CURL_DISABLE_LIBCURL_OPTION */ 165 166 #endif /* HEADER_CURL_TOOL_SETOPT_H */