1 /* struct options.
2    Copyright (C) 1996-2011, 2015, 2018-2021 Free Software Foundation,
3    Inc.
4 
5 This file is part of GNU Wget.
6 
7 GNU Wget is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11 
12 GNU Wget is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Wget.  If not, see <http://www.gnu.org/licenses/>.
19 
20 Additional permission under GNU GPL version 3 section 7
21 
22 If you modify this program, or any covered work, by linking or
23 combining it with the OpenSSL project's OpenSSL library (or a
24 modified version of that library), containing parts covered by the
25 terms of the OpenSSL or SSLeay licenses, the Free Software Foundation
26 grants you additional permission to convey the resulting work.
27 Corresponding Source for a non-source form of such a combination
28 shall include the source code for the parts of OpenSSL used as well
29 as that of the covered work.  */
30 
31 enum CHECK_CERT_MODES
32 {
33   CHECK_CERT_OFF,
34   CHECK_CERT_ON,
35   CHECK_CERT_QUIET
36 };
37 
38 struct options
39 {
40   int verbose;                  /* Are we verbose?  (First set to -1,
41                                    hence not boolean.) */
42   bool quiet;                   /* Are we quiet? */
43   int ntry;                     /* Number of tries per URL */
44   bool retry_connrefused;       /* Treat CONNREFUSED as non-fatal. */
45   bool retry_on_host_error;     /* Treat host errors as non-fatal. */
46   char *retry_on_http_error;    /* Treat given HTTP errors as non-fatal. */
47   bool background;              /* Whether we should work in background. */
48   bool ignore_length;           /* Do we heed content-length at all?  */
49   bool recursive;               /* Are we recursive? */
50   bool spanhost;                /* Do we span across hosts in
51                                    recursion? */
52   int  max_redirect;            /* Maximum number of times we'll allow
53                                    a page to redirect. */
54   bool relative_only;           /* Follow only relative links. */
55   bool no_parent;               /* Restrict access to the parent
56                                    directory.  */
57   int reclevel;                 /* Maximum level of recursion */
58   bool dirstruct;               /* Do we build the directory structure
59                                    as we go along? */
60   bool no_dirstruct;            /* Do we hate dirstruct? */
61   int cut_dirs;                 /* Number of directory components to cut. */
62   bool add_hostdir;             /* Do we add hostname directory? */
63   bool protocol_directories;    /* Whether to prepend "http"/"ftp" to dirs. */
64   bool noclobber;               /* Disables clobbering of existing data. */
65   bool unlink_requested;        /* remove file before clobbering */
66   char *dir_prefix;             /* The top of directory tree */
67   char *lfilename;              /* Log filename */
68   char *input_filename;         /* Input filename */
69 #ifdef HAVE_METALINK
70   char *input_metalink;         /* Input metalink file */
71   int metalink_index;           /* Metalink application/metalink4+xml metaurl ordinal number. */
72   bool metalink_over_http;      /* Use Metalink if present in HTTP response */
73   char *preferred_location;     /* Preferred location for Metalink resources */
74 #endif
75   char *choose_config;          /* Specified config file */
76   bool noconfig;                /* Ignore all config files? */
77   bool force_html;              /* Is the input file an HTML file? */
78 
79   char *default_page;           /* Alternative default page (index file) */
80 
81   bool spider;                  /* Is Wget in spider mode? */
82 
83   char **accepts;               /* List of patterns to accept. */
84   char **rejects;               /* List of patterns to reject. */
85   const char **excludes;        /* List of excluded FTP directories. */
86   const char **includes;        /* List of FTP directories to
87                                    follow. */
88   bool ignore_case;             /* Whether to ignore case when
89                                    matching dirs and files */
90 
91   char *acceptregex_s;          /* Patterns to accept (a regex string). */
92   char *rejectregex_s;          /* Patterns to reject (a regex string). */
93   void *acceptregex;            /* Patterns to accept (a regex struct). */
94   void *rejectregex;            /* Patterns to reject (a regex struct). */
95   enum {
96 #if defined HAVE_LIBPCRE || HAVE_LIBPCRE2
97     regex_type_pcre,
98 #endif
99     regex_type_posix
100   } regex_type;                 /* The regex library. */
101   void *(*regex_compile_fun)(const char *);             /* Function to compile a regex. */
102   bool (*regex_match_fun)(const void *, const char *);  /* Function to match a string to a regex. */
103 
104 #ifdef HAVE_LIBCARES
105   char *bind_dns_address;
106   char *dns_servers;
107 #endif
108 
109   char **domains;               /* See host.c */
110   char **exclude_domains;
111   bool dns_cache;               /* whether we cache DNS lookups. */
112 
113   char **follow_tags;           /* List of HTML tags to recursively follow. */
114   char **ignore_tags;           /* List of HTML tags to ignore if recursing. */
115 
116   bool follow_ftp;              /* Are FTP URL-s followed in recursive
117                                    retrieving? */
118   bool retr_symlinks;           /* Whether we retrieve symlinks in
119                                    FTP. */
120   char *output_document;        /* The output file to which the
121                                    documents will be printed.  */
122   char *warc_filename;          /* WARC output filename */
123   char *warc_tempdir;           /* WARC temp dir */
124   char *warc_cdx_dedup_filename;/* CDX file to be used for deduplication. */
125   wgint warc_maxsize;           /* WARC max archive size */
126   bool warc_compression_enabled;/* For GZIP compression. */
127   bool warc_digests_enabled;    /* For SHA1 digests. */
128   bool warc_cdx_enabled;        /* Create CDX files? */
129   bool warc_keep_log;           /* Store the log file in a WARC record. */
130   char **warc_user_headers;     /* User-defined WARC header(s). */
131 
132   bool enable_xattr;            /* Store metadata in POSIX extended attributes. */
133 
134   char *user;                   /* Generic username */
135   char *passwd;                 /* Generic password */
136   bool ask_passwd;              /* Ask for password? */
137   char *use_askpass;           /* value to use for use-askpass if WGET_ASKPASS is not set */
138 
139   bool always_rest;             /* Always use REST. */
140   wgint start_pos;              /* Start position of a download. */
141   char *ftp_user;               /* FTP username */
142   char *ftp_passwd;             /* FTP password */
143   bool netrc;                   /* Whether to read .netrc. */
144   bool ftp_glob;                /* FTP globbing */
145   bool ftp_pasv;                /* Passive FTP. */
146 
147   char *http_user;              /* HTTP username. */
148   char *http_passwd;            /* HTTP password. */
149   char **user_headers;          /* User-defined header(s). */
150   bool http_keep_alive;         /* whether we use keep-alive */
151 
152   bool use_proxy;               /* Do we use proxy? */
153   bool allow_cache;             /* Do we allow server-side caching? */
154   char *http_proxy, *ftp_proxy, *https_proxy;
155   char **no_proxy;
156   char *base_href;
157   char *progress_type;          /* progress indicator type. */
158   int  show_progress;           /* Show only the progress bar */
159   bool noscroll;                /* Don't scroll the filename in the progressbar */
160   char *proxy_user; /*oli*/
161   char *proxy_passwd;
162 
163   double read_timeout;          /* The read/write timeout. */
164   double dns_timeout;           /* The DNS timeout. */
165   double connect_timeout;       /* The connect timeout. */
166 
167   bool random_wait;             /* vary from 0 .. wait secs by random()? */
168   double wait;                  /* The wait period between retrievals. */
169   double waitretry;             /* The wait period between retries. - HEH */
170   bool use_robots;              /* Do we heed robots.txt? */
171 
172   wgint limit_rate;             /* Limit the download rate to this
173                                    many bps. */
174   wgint quota;                  /* Maximum file size to download and
175                                    store. */
176 
177   bool server_response;         /* Do we print server response? */
178   bool save_headers;            /* Do we save headers together with
179                                    file? */
180   bool content_on_error;        /* Do we output the content when the HTTP
181                                    status code indicates a server error */
182 
183   bool debug;                   /* Debugging on/off */
184 
185 #ifdef USE_WATT32
186   bool wdebug;                  /* Watt-32 tcp/ip debugging on/off */
187 #endif
188 
189   bool timestamping;            /* Whether to use time-stamping. */
190   bool if_modified_since;       /* Whether to use conditional get requests.  */
191 
192   bool backup_converted;        /* Do we save pre-converted files as *.orig? */
193   int backups;                  /* Are numeric backups made? */
194 
195   char *useragent;              /* User-Agent string, which can be set
196                                    to something other than Wget. */
197   char *referer;                /* Naughty Referer, which can be
198                                    set to something other than
199                                    NULL. */
200   bool convert_links;           /* Will the links be converted
201                                    locally? */
202   bool convert_file_only;       /* Convert only the file portion of the URI (i.e. basename).
203                                    Leave everything else untouched. */
204 
205   bool remove_listing;          /* Do we remove .listing files
206                                    generated by FTP? */
207   bool htmlify;                 /* Do we HTML-ify the OS-dependent
208                                    listings? */
209 
210   char *dot_style;
211   wgint dot_bytes;              /* How many bytes in a printing
212                                    dot. */
213   int dots_in_line;             /* How many dots in one line. */
214   int dot_spacing;              /* How many dots between spacings. */
215 
216   bool delete_after;            /* Whether the files will be deleted
217                                    after download. */
218 
219   bool adjust_extension;        /* Use ".html" extension on all text/html? */
220 
221   bool page_requisites;         /* Whether we need to download all files
222                                    necessary to display a page properly. */
223   char *bind_address;           /* What local IP address to bind to. */
224 
225 #ifdef HAVE_SSL
226   enum {
227     secure_protocol_auto,
228     secure_protocol_sslv2,
229     secure_protocol_sslv3,
230     secure_protocol_tlsv1,
231     secure_protocol_tlsv1_1,
232     secure_protocol_tlsv1_2,
233     secure_protocol_tlsv1_3,
234     secure_protocol_pfs
235   } secure_protocol;            /* type of secure protocol to use. */
236   int check_cert;               /* whether to validate the server's cert */
237   char *cert_file;              /* external client certificate to use. */
238   char *private_key;            /* private key file (if not internal). */
239   enum keyfile_type {
240     keyfile_pem,
241     keyfile_asn1
242   } cert_type;                  /* type of client certificate file */
243   enum keyfile_type
244     private_key_type;           /* type of private key file */
245 
246   char *ca_directory;           /* CA directory (hash files) */
247   char *ca_cert;                /* CA certificate file to use */
248   char *crl_file;               /* file with CRLs */
249 
250   char *pinnedpubkey;           /* Public key (PEM/DER) file, or any number
251                                    of base64 encoded sha256 hashes preceded by
252                                    \'sha256//\' and separated by \';\', to verify
253                                    peer against */
254 
255   char *random_file;            /* file with random data to seed the PRNG */
256   char *egd_file;               /* file name of the egd daemon socket */
257   bool https_only;              /* whether to follow HTTPS only */
258   bool ftps_resume_ssl;
259   bool ftps_fallback_to_ftp;
260   bool ftps_implicit;
261   bool ftps_clear_data_connection;
262 
263   char *tls_ciphers_string;
264 #endif /* HAVE_SSL */
265 
266   bool cookies;                 /* whether cookies are used. */
267   char *cookies_input;          /* file we're loading the cookies from. */
268   char *cookies_output;         /* file we're saving the cookies to. */
269   bool keep_badhash;            /* Keep files with checksum mismatch. */
270   bool keep_session_cookies;    /* whether session cookies should be
271                                    saved and loaded. */
272 
273   char *post_data;              /* POST query string */
274   char *post_file_name;         /* File to post */
275   char *method;                 /* HTTP Method to use in Header */
276   char *body_data;              /* HTTP Method Data String */
277   char *body_file;              /* HTTP Method File */
278 
279   enum {
280     restrict_unix,
281     restrict_vms,
282     restrict_windows
283   } restrict_files_os;          /* file name restriction ruleset. */
284   bool restrict_files_ctrl;     /* non-zero if control chars in URLs
285                                    are restricted from appearing in
286                                    generated file names. */
287   bool restrict_files_nonascii; /* non-zero if bytes with values greater
288                                    than 127 are restricted. */
289   enum {
290     restrict_no_case_restriction,
291     restrict_lowercase,
292     restrict_uppercase
293   } restrict_files_case;        /* file name case restriction. */
294 
295   bool strict_comments;         /* whether strict SGML comments are
296                                    enforced.  */
297 
298   bool preserve_perm;           /* whether remote permissions are used
299                                    or that what is set by umask. */
300 
301 #ifdef ENABLE_IPV6
302   bool ipv4_only;               /* IPv4 connections have been requested. */
303   bool ipv6_only;               /* IPv4 connections have been requested. */
304 #endif
305   enum {
306     prefer_ipv4,
307     prefer_ipv6,
308     prefer_none
309   } prefer_family;              /* preferred address family when more
310                                    than one type is available */
311 
312   bool content_disposition;     /* Honor HTTP Content-Disposition header. */
313   bool auth_without_challenge;  /* Issue Basic authentication creds without
314                                    waiting for a challenge. */
315 
316   bool enable_iri;
317   char *encoding_remote;
318   const char *locale;
319 
320   bool trustservernames;
321 #ifdef __VMS
322   int ftp_stmlf;                /* Force Stream_LF format for binary FTP. */
323 #endif /* def __VMS */
324 
325   bool useservertimestamps;     /* Update downloaded files' timestamps to
326                                    match those on server? */
327 
328   bool show_all_dns_entries;    /* Show all the DNS entries when resolving a
329                                    name. */
330   bool report_bps;              /*Output bandwidth in bits format*/
331 
332 #ifdef HAVE_LIBZ
333   enum compression_options {
334     compression_auto,
335     compression_gzip,
336     compression_none
337   } compression;                /* type of HTTP compression to use */
338 #endif
339 
340   char *rejected_log;           /* The file to log rejected URLS to. */
341 
342 #ifdef HAVE_HSTS
343   bool hsts;
344   char *hsts_file;
345 #endif
346 
347   const char *homedir;          /* the homedir of the running process */
348   const char *wgetrcfile;       /* the wgetrc file to be loaded */
349 };
350 
351 extern struct options opt;
352