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 - 2020, 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_metalink.h"
27 #include "tool_urlglob.h"
28 #include "tool_formparse.h"
29 
30 typedef enum {
31   ERR_NONE,
32   ERR_BINARY_TERMINAL = 1, /* binary to terminal detected */
33   ERR_LAST
34 } curl_error;
35 
36 struct GlobalConfig;
37 
38 struct State {
39   struct getout *urlnode;
40   struct URLGlob *inglob;
41   struct URLGlob *urls;
42   char *outfiles;
43   char *httpgetfields;
44   char *uploadfile;
45   unsigned long infilenum; /* number of files to upload */
46   unsigned long up;  /* upload file counter within a single upload glob */
47   unsigned long urlnum; /* how many iterations this single URL has with ranges
48                            etc */
49   unsigned long li;
50 };
51 
52 struct OperationConfig {
53   bool remote_time;
54   char *random_file;
55   char *egd_file;
56   char *useragent;
57   char *cookie;             /* single line with specified cookies */
58   char *cookiejar;          /* write to this file */
59   char *cookiefile;         /* read from this file */
60   char *altsvc;             /* alt-svc cache file name */
61   char *hsts;               /* HSTS cache file name */
62   bool cookiesession;       /* new session? */
63   bool encoding;            /* Accept-Encoding please */
64   bool tr_encoding;         /* Transfer-Encoding please */
65   unsigned long authtype;   /* auth bitmask */
66   bool use_resume;
67   bool resume_from_current;
68   bool disable_epsv;
69   bool disable_eprt;
70   bool ftp_pret;
71   long proto;
72   bool proto_present;
73   long proto_redir;
74   bool proto_redir_present;
75   char *proto_default;
76   curl_off_t resume_from;
77   char *postfields;
78   curl_off_t postfieldsize;
79   char *referer;
80   double timeout;
81   double connecttimeout;
82   long maxredirs;
83   curl_off_t max_filesize;
84   char *output_dir;
85   char *headerfile;
86   char *ftpport;
87   char *iface;
88   long localport;
89   long localportrange;
90   unsigned short porttouse;
91   char *range;
92   long low_speed_limit;
93   long low_speed_time;
94   char *dns_servers;   /* dot notation: 1.1.1.1;2.2.2.2 */
95   char *dns_interface; /* interface name */
96   char *dns_ipv4_addr; /* dot notation */
97   char *dns_ipv6_addr; /* dot notation */
98   char *userpwd;
99   char *login_options;
100   char *tls_username;
101   char *tls_password;
102   char *tls_authtype;
103   char *proxy_tls_username;
104   char *proxy_tls_password;
105   char *proxy_tls_authtype;
106   char *proxyuserpwd;
107   char *proxy;
108   int proxyver;             /* set to CURLPROXY_HTTP* define */
109   char *noproxy;
110   char *mail_from;
111   struct curl_slist *mail_rcpt;
112   char *mail_auth;
113   bool mail_rcpt_allowfails; /* --mail-rcpt-allowfails */
114   char *sasl_authzid;       /* Authorisation identity (identity to use) */
115   bool sasl_ir;             /* Enable/disable SASL initial response */
116   bool proxytunnel;
117   bool ftp_append;          /* APPE on ftp */
118   bool use_ascii;           /* select ascii or text transfer */
119   bool autoreferer;         /* automatically set referer */
120   bool failonerror;         /* fail on (HTTP) errors */
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 *engine;
162   char *etag_save_file;
163   char *etag_compare_file;
164   bool crlf;
165   char *customrequest;
166   char *ssl_ec_curves;
167   char *krblevel;
168   char *request_target;
169   long httpversion;
170   bool http09_allowed;
171   bool nobuffer;
172   bool readbusy;            /* set when reading input returns EAGAIN */
173   bool globoff;
174   bool use_httpget;
175   bool insecure_ok;         /* set TRUE to allow insecure SSL connects */
176   bool proxy_insecure_ok;   /* set TRUE to allow insecure SSL connects
177                                for proxy */
178   bool terminal_binary_ok;
179   bool verifystatus;
180   bool create_dirs;
181   bool ftp_create_dirs;
182   bool ftp_skip_ip;
183   bool proxynegotiate;
184   bool proxyntlm;
185   bool proxydigest;
186   bool proxybasic;
187   bool proxyanyauth;
188   char *writeout;           /* %-styled format string to output */
189   struct curl_slist *quote;
190   struct curl_slist *postquote;
191   struct curl_slist *prequote;
192   long ssl_version;
193   long ssl_version_max;
194   long proxy_ssl_version;
195   long ip_version;
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 tftp_blksize;        /* TFTP BLKSIZE option */
238   bool tftp_no_options;     /* do not send TFTP options requests */
239   bool ignorecl;            /* --ignore-content-length */
240   bool disable_sessionid;
241 
242   bool raw;
243   bool post301;
244   bool post302;
245   bool post303;
246   bool nokeepalive;         /* for keepalive needs */
247   long alivetime;
248   bool content_disposition; /* use Content-disposition filename */
249 
250   int default_node_flags;   /* default flags to search for each 'node', which
251                                is basically each given URL to transfer */
252 
253   bool xattr;               /* store metadata in extended attributes */
254   long gssapi_delegation;
255   bool ssl_allow_beast;     /* allow this SSL vulnerability */
256   bool proxy_ssl_allow_beast; /* allow this SSL vulnerability for proxy*/
257 
258   bool ssl_no_revoke;       /* disable SSL certificate revocation checks */
259   /*bool proxy_ssl_no_revoke; */
260 
261   bool ssl_revoke_best_effort; /* ignore SSL revocation offline/missing
262                                   revocation list errors */
263 
264   bool native_ca_store;        /* use the native os ca store */
265 
266   bool use_metalink;        /* process given URLs as metalink XML file */
267   struct metalinkfile *metalinkfile_list; /* point to the first node */
268   struct metalinkfile *metalinkfile_last; /* point to the last/current node */
269   char *oauth_bearer;             /* OAuth 2.0 bearer token */
270   bool nonpn;                     /* enable/disable TLS NPN extension */
271   bool noalpn;                    /* enable/disable TLS ALPN extension */
272   char *unix_socket_path;         /* path to Unix domain socket */
273   bool abstract_unix_socket;      /* path to an abstract Unix domain socket */
274   bool falsestart;
275   bool path_as_is;
276   double expect100timeout;
277   bool suppress_connect_headers;  /* suppress proxy CONNECT response headers
278                                      from user callbacks */
279   curl_error synthetic_error;     /* if non-zero, it overrides any libcurl
280                                      error */
281   bool ssh_compression;           /* enable/disable SSH compression */
282   long happy_eyeballs_timeout_ms; /* happy eyeballs timeout in milliseconds.
283                                      0 is valid. default: CURL_HET_DEFAULT. */
284   bool haproxy_protocol;          /* whether to send HAProxy protocol v1 */
285   bool disallow_username_in_url;  /* disallow usernames in URLs */
286   struct GlobalConfig *global;
287   struct OperationConfig *prev;
288   struct OperationConfig *next;   /* Always last in the struct */
289   struct State state;             /* for create_transfer() */
290 };
291 
292 struct GlobalConfig {
293   int showerror;                  /* -1 == unset, default => show errors
294                                       0 => -s is used to NOT show errors
295                                       1 => -S has been used to show errors */
296   bool mute;                      /* don't show messages, --silent given */
297   bool noprogress;                /* don't show progress bar --silent given */
298   bool isatty;                    /* Updated internally if output is a tty */
299   FILE *errors;                   /* Error stream, defaults to stderr */
300   bool errors_fopened;            /* Whether error stream isn't stderr */
301   char *trace_dump;               /* file to dump the network trace to */
302   FILE *trace_stream;
303   bool trace_fopened;
304   trace tracetype;
305   bool tracetime;                 /* include timestamp? */
306   int progressmode;               /* CURL_PROGRESS_BAR / CURL_PROGRESS_STATS */
307   char *libcurl;                  /* Output libcurl code to this file name */
308   bool fail_early;                /* exit on first transfer error */
309   bool styled_output;             /* enable fancy output style detection */
310 #ifdef CURLDEBUG
311   bool test_event_based;
312 #endif
313   bool parallel;
314   long parallel_max;
315   bool parallel_connect;
316   char *help_category;            /* The help category, if set */
317   struct OperationConfig *first;
318   struct OperationConfig *current;
319   struct OperationConfig *last;   /* Always last in the struct */
320 };
321 
322 void config_init(struct OperationConfig *config);
323 void config_free(struct OperationConfig *config);
324 
325 #endif /* HEADER_CURL_TOOL_CFGABLE_H */
326