1 /* 2 * Copyright (c) 2012 Tim Ruehsen 3 * Copyright (c) 2015-2021 Free Software Foundation, Inc. 4 * 5 * This file is part of Wget. 6 * 7 * 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 * 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 <https://www.gnu.org/licenses/>. 19 * 20 * 21 * Header file for option routines 22 * 23 * Changelog 24 * 12.06.2012 Tim Ruehsen created 25 * 26 */ 27 28 #ifndef SRC_WGET_OPTIONS_H 29 #define SRC_WGET_OPTIONS_H 30 31 #include <stdarg.h> 32 #include <unistd.h> // needed for EXIT_SUCCESS 33 34 #ifdef WITH_LIBHSTS 35 #include <libhsts.h> 36 #endif 37 38 #include <wget.h> 39 40 #define INCLUDED_DIRECTORY_PREFIX '+' 41 #define EXCLUDED_DIRECTORY_PREFIX '-' 42 43 //types for --https-enforce 44 typedef enum { 45 HTTPS_ENFORCE_NONE, 46 HTTPS_ENFORCE_SOFT, 47 HTTPS_ENFORCE_HARD 48 } https_enforce_mode; 49 50 typedef enum { 51 GPG_VERIFY_DISABLED, 52 GPG_VERIFY_SIG_FAIL, 53 WGET_GPG_VERIFY_SIG_NO_FAIL 54 } gpg_verify_mode; 55 56 typedef enum { 57 DOWNLOAD_ATTR_NO, 58 DOWNLOAD_ATTR_STRIPPATH, 59 DOWNLOAD_ATTR_USEPATH, 60 } download_attr_mode; 61 62 typedef struct { 63 const char 64 *filename; 65 FILE 66 *fp; 67 wget_stats_format 68 format; 69 } stats_args; 70 71 struct config { 72 wget_iri 73 *base; 74 const char 75 *post_file, 76 *post_data, 77 *body_file, 78 *body_data, 79 *http_username, 80 *http_password, 81 *http_proxy_username, 82 *http_proxy_password, 83 *input_encoding, // encoding of files given with --input-file (or -i) (if not specified in the document itself) 84 *local_encoding, // encoding of the environment and file system 85 *remote_encoding, // encoding of remote files (if not specified in Content-Type HTTP header or in document itself) 86 *bind_address, 87 *bind_interface, 88 *input_file, 89 *base_url, 90 *default_page, 91 *referer, 92 *directory_prefix, 93 *http_proxy, 94 *https_proxy, 95 *no_proxy, 96 *cookie_suffixes, 97 *load_cookies, 98 *save_cookies, 99 *logfile, 100 *logfile_append, 101 *user_agent, 102 *output_document, 103 *ca_cert, 104 *ca_directory, 105 *cert_file, 106 *crl_file, 107 *egd_file, 108 *private_key, 109 *random_file, 110 *secure_protocol, // auto, SSLv2, SSLv3, TLSv1 111 *accept_regex, 112 *reject_regex, 113 *gnupg_homedir, 114 *stats_all, 115 *system_config, 116 *user_config, 117 *hsts_file, 118 *hsts_preload_file, 119 *hpkp_file, 120 *tls_session_file, 121 *ocsp_server, 122 *ocsp_file, 123 *netrc_file, 124 *use_askpass_bin, 125 *hostname, 126 *dns_cache_preload, 127 *method; 128 wget_vector 129 *compression, 130 *domains, 131 *exclude_directories, 132 *exclude_domains, 133 *accept_patterns, 134 *reject_patterns, 135 #ifdef WITH_GPGME 136 *sig_ext, 137 #endif 138 *follow_tags, 139 *ignore_tags, 140 *default_challenges, 141 *headers, 142 *mime_types, 143 *retry_on_http_error, 144 *save_content_on; 145 wget_content_encoding 146 compression_methods[wget_content_encoding_max + 1]; // the last one for counting 147 wget_hsts_db 148 *hsts_db; // in-memory HSTS database 149 #ifdef WITH_LIBHSTS 150 hsts_t 151 *hsts_preload_data; // in-memory HSTS preloaded data 152 #endif 153 wget_hpkp_db 154 *hpkp_db; // in-memory HPKP database 155 wget_tls_session_db 156 *tls_session_db; // in-memory TLS session database 157 wget_ocsp_db 158 *ocsp_db; // in-memory fingerprint OCSP database 159 wget_netrc_db 160 *netrc_db; // in-memory .netrc database 161 wget_cookie_db 162 *cookie_db; 163 stats_args 164 *stats_dns_args, 165 *stats_ocsp_args, 166 *stats_server_args, 167 *stats_site_args, 168 *stats_tls_args; 169 char 170 *password, 171 *username; 172 size_t 173 chunk_size; 174 long long 175 quota, 176 limit_rate, // bytes 177 start_pos; // bytes 178 int 179 http2_request_window, 180 backups, 181 tries, 182 wait, 183 waitretry, 184 restrict_file_names, 185 level, 186 preferred_family, 187 cut_directories, 188 connect_timeout, // ms 189 dns_timeout, // ms 190 read_timeout, // ms 191 max_redirect, 192 max_threads; 193 uint16_t 194 default_http_port, 195 default_https_port; 196 wget_report_speed 197 report_speed; 198 https_enforce_mode 199 https_enforce; 200 gpg_verify_mode 201 verify_sig; 202 char 203 cert_type, // SSL_X509_FMT_PEM or SSL_X509_FMT_DER (=ASN1) 204 private_key_type, // SSL_X509_FMT_PEM or SSL_X509_FMT_DER (=ASN1) 205 progress, 206 regex_type, 207 download_attr; 208 bool 209 tls_resume, // if TLS session resumption is enabled or not 210 content_on_error, 211 fsync_policy, 212 netrc, 213 http2, 214 http2_only, 215 ocsp_stapling, 216 ocsp, 217 mirror, 218 backup_converted, 219 convert_file_only, 220 convert_links, 221 ignore_case, 222 ignore_length, 223 hsts, // if HSTS (HTTP Strict Transport Security) is enabled or not 224 hsts_preload, // if loading of a HSTS Preload file is enabled of not 225 hpkp, // HTTP Public Key Pinning (HPKP) 226 random_wait, 227 trust_server_names, 228 robots, 229 parent, 230 https_only, 231 content_disposition, 232 page_requisites, 233 force_rss, 234 force_atom, 235 force_sitemap, 236 force_css, 237 force_html, 238 force_metalink, 239 adjust_extension, 240 save_headers, 241 clobber, 242 cache, 243 inet4_only, 244 inet6_only, 245 delete_after, 246 strict_comments, 247 protocol_directories, 248 host_directories, 249 force_directories, 250 directories, 251 timestamping, 252 use_server_timestamps, 253 continue_download, 254 server_response, 255 keep_alive, 256 keep_extension, 257 keep_session_cookies, 258 cookies, 259 spider, 260 dns_caching, 261 check_certificate, 262 check_hostname, 263 span_hosts, 264 verbose, 265 quiet, 266 debug, 267 hyperlink, 268 metalink, 269 cut_url_get_vars, 270 cut_file_get_vars, 271 proxy, 272 xattr, 273 force_progress, 274 local_db, 275 dont_write, // fuzzers and unit/fuzz tests set this to 1, so they won't write any files 276 filter_urls, 277 askpass, 278 verify_save_failed, 279 retry_connrefused, 280 unlink, 281 background, 282 if_modified_since, 283 auth_no_challenge, 284 no_compression, 285 ocsp_date, 286 ocsp_nonce, 287 recursive, 288 tls_false_start, 289 tcp_fastopen; 290 }; 291 292 extern struct config 293 config; 294 295 typedef enum { 296 EXIT_STATUS_NO_ERROR = EXIT_SUCCESS, 297 EXIT_STATUS_GENERIC = 1, 298 EXIT_STATUS_PARSE_INIT = 2, 299 EXIT_STATUS_IO = 3, 300 EXIT_STATUS_NETWORK = 4, 301 EXIT_STATUS_TLS = 5, 302 EXIT_STATUS_AUTH = 6, 303 EXIT_STATUS_PROTOCOL = 7, 304 EXIT_STATUS_REMOTE = 8, 305 EXIT_STATUS_GPG_ERROR = 9 306 } exit_status_e; 307 308 // Needed for fuzzers that are compiled by C++ 309 #ifdef __cplusplus 310 extern "C" { 311 #endif 312 313 int init(int argc, const char **argv) WGET_GCC_NONNULL_ALL; 314 int selftest_options(void); 315 void deinit(void); 316 void set_exit_status(exit_status_e status); 317 exit_status_e get_exit_status(void); 318 319 #ifdef __cplusplus 320 } 321 #endif 322 323 #endif /* SRC_WGET_OPTIONS_H */ 324