quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

tool_cfgable.h (14503B)


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