xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame^] | 1 | #ifndef HEADER_CURL_TOOL_CFGABLE_H |
| 2 | #define HEADER_CURL_TOOL_CFGABLE_H |
| 3 | /*************************************************************************** |
| 4 | * _ _ ____ _ |
| 5 | * Project ___| | | | _ \| | |
| 6 | * / __| | | | |_) | | |
| 7 | * | (__| |_| | _ <| |___ |
| 8 | * \___|\___/|_| \_\_____| |
| 9 | * |
| 10 | * Copyright (C) 1998 - 2022, 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 | #include "tool_sdecls.h" |
| 28 | #include "tool_urlglob.h" |
| 29 | #include "tool_formparse.h" |
| 30 | |
| 31 | struct GlobalConfig; |
| 32 | |
| 33 | struct State { |
| 34 | struct getout *urlnode; |
| 35 | struct URLGlob *inglob; |
| 36 | struct URLGlob *urls; |
| 37 | char *outfiles; |
| 38 | char *httpgetfields; |
| 39 | char *uploadfile; |
| 40 | unsigned long infilenum; /* number of files to upload */ |
| 41 | unsigned long up; /* upload file counter within a single upload glob */ |
| 42 | unsigned long urlnum; /* how many iterations this single URL has with ranges |
| 43 | etc */ |
| 44 | unsigned long li; |
| 45 | }; |
| 46 | |
| 47 | struct OperationConfig { |
| 48 | bool remote_time; |
| 49 | char *useragent; |
| 50 | struct curl_slist *cookies; /* cookies to serialize into a single line */ |
| 51 | char *cookiejar; /* write to this file */ |
| 52 | struct curl_slist *cookiefiles; /* file(s) to load cookies from */ |
| 53 | char *altsvc; /* alt-svc cache file name */ |
| 54 | char *hsts; /* HSTS cache file name */ |
| 55 | bool cookiesession; /* new session? */ |
| 56 | bool encoding; /* Accept-Encoding please */ |
| 57 | bool tr_encoding; /* Transfer-Encoding please */ |
| 58 | unsigned long authtype; /* auth bitmask */ |
| 59 | bool use_resume; |
| 60 | bool resume_from_current; |
| 61 | bool disable_epsv; |
| 62 | bool disable_eprt; |
| 63 | bool ftp_pret; |
| 64 | char *proto_str; |
| 65 | bool proto_present; |
| 66 | char *proto_redir_str; |
| 67 | bool proto_redir_present; |
| 68 | char *proto_default; |
| 69 | curl_off_t resume_from; |
| 70 | char *postfields; |
| 71 | curl_off_t postfieldsize; |
| 72 | char *referer; |
| 73 | double timeout; |
| 74 | double connecttimeout; |
| 75 | long maxredirs; |
| 76 | curl_off_t max_filesize; |
| 77 | char *output_dir; |
| 78 | char *headerfile; |
| 79 | char *ftpport; |
| 80 | char *iface; |
| 81 | long localport; |
| 82 | long localportrange; |
| 83 | unsigned short porttouse; |
| 84 | char *range; |
| 85 | long low_speed_limit; |
| 86 | long low_speed_time; |
| 87 | char *dns_servers; /* dot notation: 1.1.1.1;2.2.2.2 */ |
| 88 | char *dns_interface; /* interface name */ |
| 89 | char *dns_ipv4_addr; /* dot notation */ |
| 90 | char *dns_ipv6_addr; /* dot notation */ |
| 91 | char *userpwd; |
| 92 | char *login_options; |
| 93 | char *tls_username; |
| 94 | char *tls_password; |
| 95 | char *tls_authtype; |
| 96 | char *proxy_tls_username; |
| 97 | char *proxy_tls_password; |
| 98 | char *proxy_tls_authtype; |
| 99 | char *proxyuserpwd; |
| 100 | char *proxy; |
| 101 | int proxyver; /* set to CURLPROXY_HTTP* define */ |
| 102 | char *noproxy; |
| 103 | char *mail_from; |
| 104 | struct curl_slist *mail_rcpt; |
| 105 | char *mail_auth; |
| 106 | bool mail_rcpt_allowfails; /* --mail-rcpt-allowfails */ |
| 107 | char *sasl_authzid; /* Authorization identity (identity to use) */ |
| 108 | bool sasl_ir; /* Enable/disable SASL initial response */ |
| 109 | bool proxytunnel; |
| 110 | bool ftp_append; /* APPE on ftp */ |
| 111 | bool use_ascii; /* select ascii or text transfer */ |
| 112 | bool autoreferer; /* automatically set referer */ |
| 113 | bool failonerror; /* fail on (HTTP) errors */ |
| 114 | bool failwithbody; /* fail on (HTTP) errors but still store body */ |
| 115 | bool show_headers; /* show headers to data output */ |
| 116 | bool no_body; /* don't get the body */ |
| 117 | bool dirlistonly; /* only get the FTP dir list */ |
| 118 | bool followlocation; /* follow http redirects */ |
| 119 | bool unrestricted_auth; /* Continue to send authentication (user+password) |
| 120 | when following ocations, even when hostname |
| 121 | changed */ |
| 122 | bool netrc_opt; |
| 123 | bool netrc; |
| 124 | char *netrc_file; |
| 125 | struct getout *url_list; /* point to the first node */ |
| 126 | struct getout *url_last; /* point to the last/current node */ |
| 127 | struct getout *url_get; /* point to the node to fill in URL */ |
| 128 | struct getout *url_out; /* point to the node to fill in outfile */ |
| 129 | struct getout *url_ul; /* point to the node to fill in upload */ |
| 130 | char *doh_url; |
| 131 | char *cipher_list; |
| 132 | char *proxy_cipher_list; |
| 133 | char *cipher13_list; |
| 134 | char *proxy_cipher13_list; |
| 135 | char *cert; |
| 136 | char *proxy_cert; |
| 137 | char *cert_type; |
| 138 | char *proxy_cert_type; |
| 139 | char *cacert; |
| 140 | char *proxy_cacert; |
| 141 | char *capath; |
| 142 | char *proxy_capath; |
| 143 | char *crlfile; |
| 144 | char *proxy_crlfile; |
| 145 | char *pinnedpubkey; |
| 146 | char *proxy_pinnedpubkey; |
| 147 | char *key; |
| 148 | char *proxy_key; |
| 149 | char *key_type; |
| 150 | char *proxy_key_type; |
| 151 | char *key_passwd; |
| 152 | char *proxy_key_passwd; |
| 153 | char *pubkey; |
| 154 | char *hostpubmd5; |
| 155 | char *hostpubsha256; |
| 156 | char *engine; |
| 157 | char *etag_save_file; |
| 158 | char *etag_compare_file; |
| 159 | bool crlf; |
| 160 | char *customrequest; |
| 161 | char *ssl_ec_curves; |
| 162 | char *krblevel; |
| 163 | char *request_target; |
| 164 | long httpversion; |
| 165 | bool http09_allowed; |
| 166 | bool nobuffer; |
| 167 | bool readbusy; /* set when reading input returns EAGAIN */ |
| 168 | bool globoff; |
| 169 | bool use_httpget; |
| 170 | bool insecure_ok; /* set TRUE to allow insecure SSL connects */ |
| 171 | bool doh_insecure_ok; /* set TRUE to allow insecure SSL connects |
| 172 | for DoH */ |
| 173 | bool proxy_insecure_ok; /* set TRUE to allow insecure SSL connects |
| 174 | for proxy */ |
| 175 | bool terminal_binary_ok; |
| 176 | bool verifystatus; |
| 177 | bool doh_verifystatus; |
| 178 | bool create_dirs; |
| 179 | bool ftp_create_dirs; |
| 180 | bool ftp_skip_ip; |
| 181 | bool proxynegotiate; |
| 182 | bool proxyntlm; |
| 183 | bool proxydigest; |
| 184 | bool proxybasic; |
| 185 | bool proxyanyauth; |
| 186 | bool jsoned; /* added json content-type */ |
| 187 | char *writeout; /* %-styled format string to output */ |
| 188 | struct curl_slist *quote; |
| 189 | struct curl_slist *postquote; |
| 190 | struct curl_slist *prequote; |
| 191 | long ssl_version; |
| 192 | long ssl_version_max; |
| 193 | long proxy_ssl_version; |
| 194 | long ip_version; |
| 195 | long create_file_mode; /* CURLOPT_NEW_FILE_PERMS */ |
| 196 | curl_TimeCond timecond; |
| 197 | curl_off_t condtime; |
| 198 | struct curl_slist *headers; |
| 199 | struct curl_slist *proxyheaders; |
| 200 | struct tool_mime *mimeroot; |
| 201 | struct tool_mime *mimecurrent; |
| 202 | curl_mime *mimepost; |
| 203 | struct curl_slist *telnet_options; |
| 204 | struct curl_slist *resolve; |
| 205 | struct curl_slist *connect_to; |
| 206 | HttpReq httpreq; |
| 207 | |
| 208 | /* for bandwidth limiting features: */ |
| 209 | curl_off_t sendpersecond; /* send to peer */ |
| 210 | curl_off_t recvpersecond; /* receive from peer */ |
| 211 | |
| 212 | bool ftp_ssl; |
| 213 | bool ftp_ssl_reqd; |
| 214 | bool ftp_ssl_control; |
| 215 | bool ftp_ssl_ccc; |
| 216 | int ftp_ssl_ccc_mode; |
| 217 | char *preproxy; |
| 218 | int socks5_gssapi_nec; /* The NEC reference server does not protect the |
| 219 | encryption type exchange */ |
| 220 | unsigned long socks5_auth;/* auth bitmask for socks5 proxies */ |
| 221 | char *proxy_service_name; /* set authentication service name for HTTP and |
| 222 | SOCKS5 proxies */ |
| 223 | char *service_name; /* set authentication service name for DIGEST-MD5, |
| 224 | Kerberos 5 and SPNEGO */ |
| 225 | |
| 226 | bool tcp_nodelay; |
| 227 | bool tcp_fastopen; |
| 228 | long req_retry; /* number of retries */ |
| 229 | bool retry_all_errors; /* retry on any error */ |
| 230 | bool retry_connrefused; /* set connection refused as a transient error */ |
| 231 | long retry_delay; /* delay between retries (in seconds) */ |
| 232 | long retry_maxtime; /* maximum time to keep retrying */ |
| 233 | |
| 234 | char *ftp_account; /* for ACCT */ |
| 235 | char *ftp_alternative_to_user; /* send command if USER/PASS fails */ |
| 236 | int ftp_filemethod; |
| 237 | long mime_options; /* Mime option flags. */ |
| 238 | long tftp_blksize; /* TFTP BLKSIZE option */ |
| 239 | bool tftp_no_options; /* do not send TFTP options requests */ |
| 240 | bool ignorecl; /* --ignore-content-length */ |
| 241 | bool disable_sessionid; |
| 242 | |
| 243 | bool raw; |
| 244 | bool post301; |
| 245 | bool post302; |
| 246 | bool post303; |
| 247 | bool nokeepalive; /* for keepalive needs */ |
| 248 | long alivetime; |
| 249 | bool content_disposition; /* use Content-disposition filename */ |
| 250 | |
| 251 | int default_node_flags; /* default flags to search for each 'node', which |
| 252 | is basically each given URL to transfer */ |
| 253 | |
| 254 | bool xattr; /* store metadata in extended attributes */ |
| 255 | long gssapi_delegation; |
| 256 | bool ssl_allow_beast; /* allow this SSL vulnerability */ |
| 257 | bool proxy_ssl_allow_beast; /* allow this SSL vulnerability for proxy*/ |
| 258 | |
| 259 | bool ssl_no_revoke; /* disable SSL certificate revocation checks */ |
| 260 | /*bool proxy_ssl_no_revoke; */ |
| 261 | |
| 262 | bool ssl_revoke_best_effort; /* ignore SSL revocation offline/missing |
| 263 | revocation list errors */ |
| 264 | |
| 265 | bool native_ca_store; /* use the native os ca store */ |
| 266 | bool ssl_auto_client_cert; /* automatically locate and use a client |
| 267 | certificate for authentication (Schannel) */ |
| 268 | bool proxy_ssl_auto_client_cert; /* proxy version of ssl_auto_client_cert */ |
| 269 | char *oauth_bearer; /* OAuth 2.0 bearer token */ |
| 270 | bool noalpn; /* enable/disable TLS ALPN extension */ |
| 271 | char *unix_socket_path; /* path to Unix domain socket */ |
| 272 | bool abstract_unix_socket; /* path to an abstract Unix domain socket */ |
| 273 | bool falsestart; |
| 274 | bool path_as_is; |
| 275 | double expect100timeout; |
| 276 | bool suppress_connect_headers; /* suppress proxy CONNECT response headers |
| 277 | from user callbacks */ |
| 278 | bool synthetic_error; /* if TRUE, this is tool-internal error */ |
| 279 | bool ssh_compression; /* enable/disable SSH compression */ |
| 280 | long happy_eyeballs_timeout_ms; /* happy eyeballs timeout in milliseconds. |
| 281 | 0 is valid. default: CURL_HET_DEFAULT. */ |
| 282 | bool haproxy_protocol; /* whether to send HAProxy protocol v1 */ |
| 283 | bool disallow_username_in_url; /* disallow usernames in URLs */ |
| 284 | char *aws_sigv4; |
| 285 | enum { |
| 286 | CLOBBER_DEFAULT, /* Provides compatibility with previous versions of curl, |
| 287 | by using the default behavior for -o, -O, and -J. |
| 288 | If those options would have overwritten files, like |
| 289 | -o and -O would, then overwrite them. In the case of |
| 290 | -J, this will not overwrite any files. */ |
| 291 | CLOBBER_NEVER, /* If the file exists, always fail */ |
| 292 | CLOBBER_ALWAYS /* If the file exists, always overwrite it */ |
| 293 | } file_clobber_mode; |
| 294 | struct GlobalConfig *global; |
| 295 | struct OperationConfig *prev; |
| 296 | struct OperationConfig *next; /* Always last in the struct */ |
| 297 | struct State state; /* for create_transfer() */ |
| 298 | bool rm_partial; /* on error, remove partially written output |
| 299 | files */ |
| 300 | }; |
| 301 | |
| 302 | struct GlobalConfig { |
| 303 | int showerror; /* -1 == unset, default => show errors |
| 304 | 0 => -s is used to NOT show errors |
| 305 | 1 => -S has been used to show errors */ |
| 306 | bool mute; /* don't show messages, --silent given */ |
| 307 | bool noprogress; /* don't show progress bar --silent given */ |
| 308 | bool isatty; /* Updated internally if output is a tty */ |
| 309 | FILE *errors; /* Error stream, defaults to stderr */ |
| 310 | bool errors_fopened; /* Whether error stream isn't stderr */ |
| 311 | char *trace_dump; /* file to dump the network trace to */ |
| 312 | FILE *trace_stream; |
| 313 | bool trace_fopened; |
| 314 | trace tracetype; |
| 315 | bool tracetime; /* include timestamp? */ |
| 316 | int progressmode; /* CURL_PROGRESS_BAR / CURL_PROGRESS_STATS */ |
| 317 | char *libcurl; /* Output libcurl code to this file name */ |
| 318 | bool fail_early; /* exit on first transfer error */ |
| 319 | bool styled_output; /* enable fancy output style detection */ |
| 320 | long ms_per_transfer; /* start next transfer after (at least) this |
| 321 | many milliseconds */ |
| 322 | #ifdef CURLDEBUG |
| 323 | bool test_event_based; |
| 324 | #endif |
| 325 | bool parallel; |
| 326 | long parallel_max; |
| 327 | bool parallel_connect; |
| 328 | char *help_category; /* The help category, if set */ |
| 329 | struct OperationConfig *first; |
| 330 | struct OperationConfig *current; |
| 331 | struct OperationConfig *last; /* Always last in the struct */ |
| 332 | }; |
| 333 | |
| 334 | void config_init(struct OperationConfig *config); |
| 335 | void config_free(struct OperationConfig *config); |
| 336 | |
| 337 | #endif /* HEADER_CURL_TOOL_CFGABLE_H */ |