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