00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "tool_setup.h"
00023
00024 #include "tool_panykey.h"
00025 #include "tool_help.h"
00026 #include "tool_libinfo.h"
00027 #include "tool_version.h"
00028
00029 #include "memdebug.h"
00030
00031 #ifdef MSDOS
00032 # define USE_WATT32
00033 #endif
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 static const char *const helptext[] = {
00047 "Usage: curl [options...] <url>",
00048 "Options: (H) means HTTP/HTTPS only, (F) means FTP only",
00049 " --anyauth Pick \"any\" authentication method (H)",
00050 " -a, --append Append to target file when uploading (F/SFTP)",
00051 " --basic Use HTTP Basic Authentication (H)",
00052 " --cacert FILE CA certificate to verify peer against (SSL)",
00053 " --capath DIR CA directory to verify peer against (SSL)",
00054 " -E, --cert CERT[:PASSWD] Client certificate file and password (SSL)",
00055 " --cert-status Verify the status of the server certificate (SSL)",
00056 " --cert-type TYPE Certificate file type (DER/PEM/ENG) (SSL)",
00057 " --ciphers LIST SSL ciphers to use (SSL)",
00058 " --compressed Request compressed response (using deflate or gzip)",
00059 " -K, --config FILE Read config from FILE",
00060 " --connect-timeout SECONDS Maximum time allowed for connection",
00061 " --connect-to HOST1:PORT1:HOST2:PORT2 Connect to host (network level)",
00062 " -C, --continue-at OFFSET Resumed transfer OFFSET",
00063 " -b, --cookie STRING/FILE Read cookies from STRING/FILE (H)",
00064 " -c, --cookie-jar FILE Write cookies to FILE after operation (H)",
00065 " --create-dirs Create necessary local directory hierarchy",
00066 " --crlf Convert LF to CRLF in upload",
00067 " --crlfile FILE Get a CRL list in PEM format from the given file",
00068 " -d, --data DATA HTTP POST data (H)",
00069 " --data-raw DATA HTTP POST data, '@' allowed (H)",
00070 " --data-ascii DATA HTTP POST ASCII data (H)",
00071 " --data-binary DATA HTTP POST binary data (H)",
00072 " --data-urlencode DATA HTTP POST data url encoded (H)",
00073 " --delegation STRING GSS-API delegation permission",
00074 " --digest Use HTTP Digest Authentication (H)",
00075 " --disable-eprt Inhibit using EPRT or LPRT (F)",
00076 " --disable-epsv Inhibit using EPSV (F)",
00077 " --dns-servers DNS server addrs to use: 1.1.1.1;2.2.2.2",
00078 " --dns-interface Interface to use for DNS requests",
00079 " --dns-ipv4-addr IPv4 address to use for DNS requests, dot notation",
00080 " --dns-ipv6-addr IPv6 address to use for DNS requests, dot notation",
00081 " -D, --dump-header FILE Write the received headers to FILE",
00082 " --egd-file FILE EGD socket path for random data (SSL)",
00083 " --engine ENGINE Crypto engine (use \"--engine list\" for list) (SSL)",
00084 #ifdef USE_ENVIRONMENT
00085 " --environment Write results to environment variables (RISC OS)",
00086 #endif
00087 " --expect100-timeout SECONDS How long to wait for 100-continue (H)",
00088 " -f, --fail Fail silently (no output at all) on HTTP errors (H)",
00089 " --fail-early Fail on first transfer error, do not continue",
00090 " --false-start Enable TLS False Start.",
00091 " -F, --form CONTENT Specify HTTP multipart POST data (H)",
00092 " --form-string STRING Specify HTTP multipart POST data (H)",
00093 " --ftp-account DATA Account data string (F)",
00094 " --ftp-alternative-to-user COMMAND "
00095 "String to replace \"USER [name]\" (F)",
00096 " --ftp-create-dirs Create the remote dirs if not present (F)",
00097 " --ftp-method [MULTICWD/NOCWD/SINGLECWD] Control CWD usage (F)",
00098 " --ftp-pasv Use PASV/EPSV instead of PORT (F)",
00099 " -P, --ftp-port ADR Use PORT with given address instead of PASV (F)",
00100 " --ftp-skip-pasv-ip Skip the IP address for PASV (F)\n"
00101 " --ftp-pret Send PRET before PASV (for drftpd) (F)",
00102 " --ftp-ssl-ccc Send CCC after authenticating (F)",
00103 " --ftp-ssl-ccc-mode ACTIVE/PASSIVE Set CCC mode (F)",
00104 " --ftp-ssl-control Require SSL/TLS for FTP login, "
00105 "clear for transfer (F)",
00106 " -G, --get Send the -d data with a HTTP GET (H)",
00107 " -g, --globoff Disable URL sequences and ranges using {} and []",
00108 " -H, --header LINE Pass custom header LINE to server (H)",
00109 " -I, --head Show document info only",
00110 " -h, --help This help text",
00111 " --hostpubmd5 MD5 "
00112 "Hex-encoded MD5 string of the host public key. (SSH)",
00113 " -0, --http1.0 Use HTTP 1.0 (H)",
00114 " --http1.1 Use HTTP 1.1 (H)",
00115 " --http2 Use HTTP 2 (H)",
00116 " --http2-prior-knowledge Use HTTP 2 without HTTP/1.1 Upgrade (H)",
00117 " --ignore-content-length Ignore the HTTP Content-Length header",
00118 " -i, --include Include protocol headers in the output (H/F)",
00119 " -k, --insecure Allow connections to SSL sites without certs (H)",
00120 " --interface INTERFACE Use network INTERFACE (or address)",
00121 " -4, --ipv4 Resolve name to IPv4 address",
00122 " -6, --ipv6 Resolve name to IPv6 address",
00123 " -j, --junk-session-cookies Ignore session cookies read from file (H)",
00124 " --keepalive-time SECONDS Wait SECONDS between keepalive probes",
00125 " --key KEY Private key file name (SSL/SSH)",
00126 " --key-type TYPE Private key file type (DER/PEM/ENG) (SSL)",
00127 " --krb LEVEL Enable Kerberos with security LEVEL (F)",
00128 #ifndef CURL_DISABLE_LIBCURL_OPTION
00129 " --libcurl FILE Dump libcurl equivalent code of this command line",
00130 #endif
00131 " --limit-rate RATE Limit transfer speed to RATE",
00132 " -l, --list-only List only mode (F/POP3)",
00133 " --local-port RANGE Force use of RANGE for local port numbers",
00134 " -L, --location Follow redirects (H)",
00135 " --location-trusted "
00136 "Like '--location', and send auth to other hosts (H)",
00137 " --login-options OPTIONS Server login options (IMAP, POP3, SMTP)",
00138 " -M, --manual Display the full manual",
00139 " --mail-from FROM Mail from this address (SMTP)",
00140 " --mail-rcpt TO Mail to this/these addresses (SMTP)",
00141 " --mail-auth AUTH Originator address of the original email (SMTP)",
00142 " --max-filesize BYTES Maximum file size to download (H/F)",
00143 " --max-redirs NUM Maximum number of redirects allowed (H)",
00144 " -m, --max-time SECONDS Maximum time allowed for the transfer",
00145 " --metalink Process given URLs as metalink XML file",
00146 " --negotiate Use HTTP Negotiate (SPNEGO) authentication (H)",
00147 " -n, --netrc Must read .netrc for user name and password",
00148 " --netrc-optional Use either .netrc or URL; overrides -n",
00149 " --netrc-file FILE Specify FILE for netrc",
00150 " -:, --next "
00151 "Allows the following URL to use a separate set of options",
00152 " --no-alpn Disable the ALPN TLS extension (H)",
00153 " -N, --no-buffer Disable buffering of the output stream",
00154 " --no-keepalive Disable keepalive use on the connection",
00155 " --no-npn Disable the NPN TLS extension (H)",
00156 " --no-sessionid Disable SSL session-ID reusing (SSL)",
00157 " --noproxy List of hosts which do not use proxy",
00158 " --ntlm Use HTTP NTLM authentication (H)",
00159 " --ntlm-wb Use HTTP NTLM authentication with winbind (H)",
00160 " --oauth2-bearer TOKEN OAuth 2 Bearer Token (IMAP, POP3, SMTP)",
00161 " -o, --output FILE Write to FILE instead of stdout",
00162 " --pass PASS Pass phrase for the private key (SSL/SSH)",
00163 " --path-as-is Do not squash .. sequences in URL path",
00164 " --pinnedpubkey FILE/HASHES Public key to verify peer against (SSL)",
00165 " --post301 "
00166 "Do not switch to GET after following a 301 redirect (H)",
00167 " --post302 "
00168 "Do not switch to GET after following a 302 redirect (H)",
00169 " --post303 "
00170 "Do not switch to GET after following a 303 redirect (H)",
00171 " --preproxy [PROTOCOL://]HOST[:PORT] Proxy before HTTP(S) proxy",
00172 " -#, --progress-bar Display transfer progress as a progress bar",
00173 " --proto PROTOCOLS Enable/disable PROTOCOLS",
00174 " --proto-default PROTOCOL Use PROTOCOL for any URL missing a scheme",
00175 " --proto-redir PROTOCOLS Enable/disable PROTOCOLS on redirect",
00176 " -x, --proxy [PROTOCOL://]HOST[:PORT] Use proxy on given port",
00177 " --proxy-anyauth Pick \"any\" proxy authentication method (H)",
00178 " --proxy-basic Use Basic authentication on the proxy (H)",
00179 " --proxy-digest Use Digest authentication on the proxy (H)",
00180 " --proxy-cacert FILE "
00181 "CA certificate to verify peer against for proxy (SSL)",
00182 " --proxy-capath DIR "
00183 "CA directory to verify peer against for proxy (SSL)",
00184 " --proxy-cert CERT[:PASSWD] "
00185 "Client certificate file and password for proxy (SSL)",
00186 " --proxy-cert-type TYPE "
00187 "Certificate file type (DER/PEM/ENG) for proxy (SSL)",
00188 " --proxy-ciphers LIST SSL ciphers to use for proxy (SSL)",
00189 " --proxy-crlfile FILE "
00190 "Get a CRL list in PEM format from the given file for proxy",
00191 " --proxy-insecure "
00192 "Allow connections to SSL sites without certs for proxy (H)",
00193 " --proxy-key KEY Private key file name for proxy (SSL)",
00194 " --proxy-key-type TYPE "
00195 "Private key file type for proxy (DER/PEM/ENG) (SSL)",
00196 " --proxy-negotiate "
00197 "Use HTTP Negotiate (SPNEGO) authentication on the proxy (H)",
00198 " --proxy-ntlm Use NTLM authentication on the proxy (H)",
00199 " --proxy-header LINE Pass custom header LINE to proxy (H)",
00200 " --proxy-pass PASS Pass phrase for the private key for proxy (SSL)",
00201 " --proxy-ssl-allow-beast "
00202 "Allow security flaw to improve interop for proxy (SSL)",
00203 " --proxy-tlsv1 Use TLSv1 for proxy (SSL)",
00204 " --proxy-tlsuser USER TLS username for proxy",
00205 " --proxy-tlspassword STRING TLS password for proxy",
00206 " --proxy-tlsauthtype STRING "
00207 "TLS authentication type for proxy (default SRP)",
00208 " --proxy-service-name NAME SPNEGO proxy service name",
00209 " --service-name NAME SPNEGO service name",
00210 " -U, --proxy-user USER[:PASSWORD] Proxy user and password",
00211 " --proxy1.0 HOST[:PORT] Use HTTP/1.0 proxy on given port",
00212 " -p, --proxytunnel Operate through a HTTP proxy tunnel (using CONNECT)",
00213 " --pubkey KEY Public key file name (SSH)",
00214 " -Q, --quote CMD Send command(s) to server before transfer (F/SFTP)",
00215 " --random-file FILE File for reading random data from (SSL)",
00216 " -r, --range RANGE Retrieve only the bytes within RANGE",
00217 " --raw Do HTTP \"raw\"; no transfer decoding (H)",
00218 " -e, --referer Referer URL (H)",
00219 " -J, --remote-header-name Use the header-provided filename (H)",
00220 " -O, --remote-name Write output to a file named as the remote file",
00221 " --remote-name-all Use the remote file name for all URLs",
00222 " -R, --remote-time Set the remote file's time on the local output",
00223 " -X, --request COMMAND Specify request command to use",
00224 " --resolve HOST:PORT:ADDRESS Force resolve of HOST:PORT to ADDRESS",
00225 " --retry NUM "
00226 "Retry request NUM times if transient problems occur",
00227 " --retry-connrefused Retry on connection refused (use with --retry)",
00228 " --retry-delay SECONDS Wait SECONDS between retries",
00229 " --retry-max-time SECONDS Retry only within this period",
00230 " --sasl-ir Enable initial response in SASL authentication",
00231 " -S, --show-error "
00232 "Show error. With -s, make curl show errors when they occur",
00233 " -s, --silent Silent mode (don't output anything)",
00234 " --socks4 HOST[:PORT] SOCKS4 proxy on given host + port",
00235 " --socks4a HOST[:PORT] SOCKS4a proxy on given host + port",
00236 " --socks5 HOST[:PORT] SOCKS5 proxy on given host + port",
00237 " --socks5-hostname HOST[:PORT] "
00238 "SOCKS5 proxy, pass host name to proxy",
00239 " --socks5-gssapi-service NAME SOCKS5 proxy service name for GSS-API",
00240 " --socks5-gssapi-nec Compatibility with NEC SOCKS5 server",
00241 " -Y, --speed-limit RATE "
00242 "Stop transfers below RATE for 'speed-time' secs",
00243 " -y, --speed-time SECONDS "
00244 "Trigger 'speed-limit' abort after SECONDS (default: 30)",
00245 " --ssl Try SSL/TLS (FTP, IMAP, POP3, SMTP)",
00246 " --ssl-reqd Require SSL/TLS (FTP, IMAP, POP3, SMTP)",
00247 " -2, --sslv2 Use SSLv2 (SSL)",
00248 " -3, --sslv3 Use SSLv3 (SSL)",
00249 " --ssl-allow-beast Allow security flaw to improve interop (SSL)",
00250 " --ssl-no-revoke Disable cert revocation checks (WinSSL)",
00251 " --stderr FILE Where to redirect stderr (use \"-\" for stdout)",
00252 " --tcp-nodelay Use the TCP_NODELAY option",
00253 " --tcp-fastopen Use TCP Fast Open",
00254 " -t, --telnet-option OPT=VAL Set telnet option",
00255 " --tftp-blksize VALUE Set TFTP BLKSIZE option (must be >512)",
00256 " --tftp-no-options Do not send TFTP options requests",
00257 " -z, --time-cond TIME Transfer based on a time condition",
00258 " -1, --tlsv1 Use >= TLSv1 (SSL)",
00259 " --tlsv1.0 Use TLSv1.0 (SSL)",
00260 " --tlsv1.1 Use TLSv1.1 (SSL)",
00261 " --tlsv1.2 Use TLSv1.2 (SSL)",
00262 " --tlsv1.3 Use TLSv1.3 (SSL)",
00263 " --trace FILE Write a debug trace to FILE",
00264 " --trace-ascii FILE Like --trace, but without hex output",
00265 " --trace-time Add time stamps to trace/verbose output",
00266 " --tr-encoding Request compressed transfer encoding (H)",
00267 " -T, --upload-file FILE Transfer FILE to destination",
00268 " --url URL URL to work with",
00269 " -B, --use-ascii Use ASCII/text transfer",
00270 " -u, --user USER[:PASSWORD] Server user and password",
00271 " --tlsuser USER TLS username",
00272 " --tlspassword STRING TLS password",
00273 " --tlsauthtype STRING TLS authentication type (default: SRP)",
00274 " --unix-socket FILE Connect through this Unix domain socket",
00275 " -A, --user-agent STRING Send User-Agent STRING to server (H)",
00276 " -v, --verbose Make the operation more talkative",
00277 " -V, --version Show version number and quit",
00278 #ifdef USE_WATT32
00279 " --wdebug Turn on Watt-32 debugging",
00280 #endif
00281 " -w, --write-out FORMAT Use output FORMAT after completion",
00282 " --xattr Store metadata in extended file attributes",
00283 " -q, --disable Disable .curlrc (must be first parameter)",
00284 NULL
00285 };
00286
00287 #ifdef NETWARE
00288 # define PRINT_LINES_PAUSE 23
00289 #endif
00290
00291 #ifdef __SYMBIAN32__
00292 # define PRINT_LINES_PAUSE 16
00293 #endif
00294
00295 struct feat {
00296 const char *name;
00297 int bitmask;
00298 };
00299
00300 static const struct feat feats[] = {
00301 {"AsynchDNS", CURL_VERSION_ASYNCHDNS},
00302 {"Debug", CURL_VERSION_DEBUG},
00303 {"TrackMemory", CURL_VERSION_CURLDEBUG},
00304 {"IDN", CURL_VERSION_IDN},
00305 {"IPv6", CURL_VERSION_IPV6},
00306 {"Largefile", CURL_VERSION_LARGEFILE},
00307 {"SSPI", CURL_VERSION_SSPI},
00308 {"GSS-API", CURL_VERSION_GSSAPI},
00309 {"Kerberos", CURL_VERSION_KERBEROS5},
00310 {"SPNEGO", CURL_VERSION_SPNEGO},
00311 {"NTLM", CURL_VERSION_NTLM},
00312 {"NTLM_WB", CURL_VERSION_NTLM_WB},
00313 {"SSL", CURL_VERSION_SSL},
00314 {"libz", CURL_VERSION_LIBZ},
00315 {"CharConv", CURL_VERSION_CONV},
00316 {"TLS-SRP", CURL_VERSION_TLSAUTH_SRP},
00317 {"HTTP2", CURL_VERSION_HTTP2},
00318 {"UnixSockets", CURL_VERSION_UNIX_SOCKETS},
00319 {"HTTPS-proxy", CURL_VERSION_HTTPS_PROXY}
00320 };
00321
00322 void tool_help(void)
00323 {
00324 int i;
00325 for(i = 0; helptext[i]; i++) {
00326 puts(helptext[i]);
00327 #ifdef PRINT_LINES_PAUSE
00328 if(i && ((i % PRINT_LINES_PAUSE) == 0))
00329 tool_pressanykey();
00330 #endif
00331 }
00332 }
00333
00334 void tool_version_info(void)
00335 {
00336 const char *const *proto;
00337
00338 printf(CURL_ID "%s\n", curl_version());
00339 if(curlinfo->protocols) {
00340 printf("Protocols: ");
00341 for(proto = curlinfo->protocols; *proto; ++proto) {
00342 printf("%s ", *proto);
00343 }
00344 puts("");
00345 }
00346 if(curlinfo->features) {
00347 unsigned int i;
00348 printf("Features: ");
00349 for(i = 0; i < sizeof(feats)/sizeof(feats[0]); i++) {
00350 if(curlinfo->features & feats[i].bitmask)
00351 printf("%s ", feats[i].name);
00352 }
00353 #ifdef USE_METALINK
00354 printf("Metalink ");
00355 #endif
00356 #ifdef USE_LIBPSL
00357 printf("PSL ");
00358 #endif
00359 puts("");
00360 }
00361 }
00362
00363 void tool_list_engines(CURL *curl)
00364 {
00365 struct curl_slist *engines = NULL;
00366
00367
00368 curl_easy_getinfo(curl, CURLINFO_SSL_ENGINES, &engines);
00369
00370 puts("Build-time engines:");
00371 if(engines) {
00372 for(; engines; engines = engines->next)
00373 printf(" %s\n", engines->data);
00374 }
00375 else {
00376 puts(" <none>");
00377 }
00378
00379
00380 curl_slist_free_all(engines);
00381 }