1 /*************************************************************************** 2 * _ _ ____ _ 3 * Project ___| | | | _ \| | 4 * / __| | | | |_) | | 5 * | (__| |_| | _ <| |___ 6 * \___|\___/|_| \_\_____| 7 * 8 * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel (at) haxx.se>, et al. 9 * 10 * This software is licensed as described in the file COPYING, which 11 * you should have received as part of this distribution. The terms 12 * are also available at http://curl.haxx.se/docs/copyright.html. 13 * 14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell 15 * copies of the Software, and permit persons to whom the Software is 16 * furnished to do so, under the terms of the COPYING file. 17 * 18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 19 * KIND, either express or implied. 20 * 21 ***************************************************************************/ 22 #include "tool_setup.h" 23 24 #include "tool_panykey.h" 25 #include "tool_help.h" 26 #include "tool_libinfo.h" 27 #include "tool_version.h" 28 29 #include "memdebug.h" /* keep this as LAST include */ 30 31 #ifdef MSDOS 32 # define USE_WATT32 33 #endif 34 35 /* 36 * A few of these source lines are >80 columns wide, but that's only because 37 * breaking the strings narrower makes this chunk look even worse! 38 * 39 * Starting with 7.18.0, this list of command line options is sorted based 40 * on the long option name. It is not done automatically, although a command 41 * line like the following can help out: 42 * 43 * curl --help | cut -c5- | grep "^-" | sort 44 */ 45 46 static const char *const helptext[] = { 47 "Usage: curl [options...] <url>", 48 "Options: (H) means HTTP/HTTPS only, (F) means FTP only", 49 " --anyauth Pick \"any\" authentication method (H)", 50 " -a, --append Append to target file when uploading (F/SFTP)", 51 " --basic Use HTTP Basic Authentication (H)", 52 " --cacert FILE CA certificate to verify peer against (SSL)", 53 " --capath DIR CA directory to verify peer against (SSL)", 54 " -E, --cert CERT[:PASSWD] Client certificate file and password (SSL)", 55 " --cert-status Verify the status of the server certificate (SSL)", 56 " --cert-type TYPE Certificate file type (DER/PEM/ENG) (SSL)", 57 " --ciphers LIST SSL ciphers to use (SSL)", 58 " --compressed Request compressed response (using deflate or gzip)", 59 " -K, --config FILE Read config from FILE", 60 " --connect-timeout SECONDS Maximum time allowed for connection", 61 " -C, --continue-at OFFSET Resumed transfer OFFSET", 62 " -b, --cookie STRING/FILE Read cookies from STRING/FILE (H)", 63 " -c, --cookie-jar FILE Write cookies to FILE after operation (H)", 64 " --create-dirs Create necessary local directory hierarchy", 65 " --crlf Convert LF to CRLF in upload", 66 " --crlfile FILE Get a CRL list in PEM format from the given file", 67 " -d, --data DATA HTTP POST data (H)", 68 " --data-raw DATA HTTP POST data, '@' allowed (H)", 69 " --data-ascii DATA HTTP POST ASCII data (H)", 70 " --data-binary DATA HTTP POST binary data (H)", 71 " --data-urlencode DATA HTTP POST data url encoded (H)", 72 " --delegation STRING GSS-API delegation permission", 73 " --digest Use HTTP Digest Authentication (H)", 74 " --disable-eprt Inhibit using EPRT or LPRT (F)", 75 " --disable-epsv Inhibit using EPSV (F)", 76 " --dns-servers DNS server addrs to use: 1.1.1.1;2.2.2.2", 77 " --dns-interface Interface to use for DNS requests", 78 " --dns-ipv4-addr IPv4 address to use for DNS requests, dot notation", 79 " --dns-ipv6-addr IPv6 address to use for DNS requests, dot notation", 80 " -D, --dump-header FILE Write the headers to FILE", 81 " --egd-file FILE EGD socket path for random data (SSL)", 82 " --engine ENGINE Crypto engine (use \"--engine list\" for list) (SSL)", 83 #ifdef USE_ENVIRONMENT 84 " --environment Write results to environment variables (RISC OS)", 85 #endif 86 " -f, --fail Fail silently (no output at all) on HTTP errors (H)", 87 " --false-start Enable TLS False Start.", 88 " -F, --form CONTENT Specify HTTP multipart POST data (H)", 89 " --form-string STRING Specify HTTP multipart POST data (H)", 90 " --ftp-account DATA Account data string (F)", 91 " --ftp-alternative-to-user COMMAND " 92 "String to replace \"USER [name]\" (F)", 93 " --ftp-create-dirs Create the remote dirs if not present (F)", 94 " --ftp-method [MULTICWD/NOCWD/SINGLECWD] Control CWD usage (F)", 95 " --ftp-pasv Use PASV/EPSV instead of PORT (F)", 96 " -P, --ftp-port ADR Use PORT with given address instead of PASV (F)", 97 " --ftp-skip-pasv-ip Skip the IP address for PASV (F)\n" 98 " --ftp-pret Send PRET before PASV (for drftpd) (F)", 99 " --ftp-ssl-ccc Send CCC after authenticating (F)", 100 " --ftp-ssl-ccc-mode ACTIVE/PASSIVE Set CCC mode (F)", 101 " --ftp-ssl-control Require SSL/TLS for FTP login, " 102 "clear for transfer (F)", 103 " -G, --get Send the -d data with a HTTP GET (H)", 104 " -g, --globoff Disable URL sequences and ranges using {} and []", 105 " -H, --header LINE Pass custom header LINE to server (H)", 106 " -I, --head Show document info only", 107 " -h, --help This help text", 108 " --hostpubmd5 MD5 " 109 "Hex-encoded MD5 string of the host public key. (SSH)", 110 " -0, --http1.0 Use HTTP 1.0 (H)", 111 " --http1.1 Use HTTP 1.1 (H)", 112 " --http2 Use HTTP 2 (H)", 113 " --ignore-content-length Ignore the HTTP Content-Length header", 114 " -i, --include Include protocol headers in the output (H/F)", 115 " -k, --insecure Allow connections to SSL sites without certs (H)", 116 " --interface INTERFACE Use network INTERFACE (or address)", 117 " -4, --ipv4 Resolve name to IPv4 address", 118 " -6, --ipv6 Resolve name to IPv6 address", 119 " -j, --junk-session-cookies Ignore session cookies read from file (H)", 120 " --keepalive-time SECONDS Wait SECONDS between keepalive probes", 121 " --key KEY Private key file name (SSL/SSH)", 122 " --key-type TYPE Private key file type (DER/PEM/ENG) (SSL)", 123 " --krb LEVEL Enable Kerberos with security LEVEL (F)", 124 #ifndef CURL_DISABLE_LIBCURL_OPTION 125 " --libcurl FILE Dump libcurl equivalent code of this command line", 126 #endif 127 " --limit-rate RATE Limit transfer speed to RATE", 128 " -l, --list-only List only mode (F/POP3)", 129 " --local-port RANGE Force use of RANGE for local port numbers", 130 " -L, --location Follow redirects (H)", 131 " --location-trusted " 132 "Like '--location', and send auth to other hosts (H)", 133 " --login-options OPTIONS Server login options (IMAP, POP3, SMTP)", 134 " -M, --manual Display the full manual", 135 " --mail-from FROM Mail from this address (SMTP)", 136 " --mail-rcpt TO Mail to this/these addresses (SMTP)", 137 " --mail-auth AUTH Originator address of the original email (SMTP)", 138 " --max-filesize BYTES Maximum file size to download (H/F)", 139 " --max-redirs NUM Maximum number of redirects allowed (H)", 140 " -m, --max-time SECONDS Maximum time allowed for the transfer", 141 " --metalink Process given URLs as metalink XML file", 142 " --negotiate Use HTTP Negotiate (SPNEGO) authentication (H)", 143 " -n, --netrc Must read .netrc for user name and password", 144 " --netrc-optional Use either .netrc or URL; overrides -n", 145 " --netrc-file FILE Specify FILE for netrc", 146 " -:, --next " 147 "Allows the following URL to use a separate set of options", 148 " --no-alpn Disable the ALPN TLS extension (H)", 149 " -N, --no-buffer Disable buffering of the output stream", 150 " --no-keepalive Disable keepalive use on the connection", 151 " --no-npn Disable the NPN TLS extension (H)", 152 " --no-sessionid Disable SSL session-ID reusing (SSL)", 153 " --noproxy List of hosts which do not use proxy", 154 " --ntlm Use HTTP NTLM authentication (H)", 155 " --oauth2-bearer TOKEN OAuth 2 Bearer Token (IMAP, POP3, SMTP)", 156 " -o, --output FILE Write to FILE instead of stdout", 157 " --pass PASS Pass phrase for the private key (SSL/SSH)", 158 " --path-as-is Do not squash .. sequences in URL path", 159 " --pinnedpubkey FILE Public key (PEM/DER) to verify peer against " 160 "(OpenSSL/GnuTLS/NSS/wolfSSL/CyaSSL/GSKit only)", 161 " --post301 " 162 "Do not switch to GET after following a 301 redirect (H)", 163 " --post302 " 164 "Do not switch to GET after following a 302 redirect (H)", 165 " --post303 " 166 "Do not switch to GET after following a 303 redirect (H)", 167 " -#, --progress-bar Display transfer progress as a progress bar", 168 " --proto PROTOCOLS Enable/disable PROTOCOLS", 169 " --proto-redir PROTOCOLS Enable/disable PROTOCOLS on redirect", 170 " -x, --proxy [PROTOCOL://]HOST[:PORT] Use proxy on given port", 171 " --proxy-anyauth Pick \"any\" proxy authentication method (H)", 172 " --proxy-basic Use Basic authentication on the proxy (H)", 173 " --proxy-digest Use Digest authentication on the proxy (H)", 174 " --proxy-negotiate " 175 "Use HTTP Negotiate (SPNEGO) authentication on the proxy (H)", 176 " --proxy-ntlm Use NTLM authentication on the proxy (H)", 177 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) 178 " --proxy-service-name NAME SPNEGO proxy service name", 179 " --service-name NAME SPNEGO service name", 180 #endif 181 " -U, --proxy-user USER[:PASSWORD] Proxy user and password", 182 " --proxy1.0 HOST[:PORT] Use HTTP/1.0 proxy on given port", 183 " -p, --proxytunnel Operate through a HTTP proxy tunnel (using CONNECT)", 184 " --pubkey KEY Public key file name (SSH)", 185 " -Q, --quote CMD Send command(s) to server before transfer (F/SFTP)", 186 " --random-file FILE File for reading random data from (SSL)", 187 " -r, --range RANGE Retrieve only the bytes within RANGE", 188 " --raw Do HTTP \"raw\"; no transfer decoding (H)", 189 " -e, --referer Referer URL (H)", 190 " -J, --remote-header-name Use the header-provided filename (H)", 191 " -O, --remote-name Write output to a file named as the remote file", 192 " --remote-name-all Use the remote file name for all URLs", 193 " -R, --remote-time Set the remote file's time on the local output", 194 " -X, --request COMMAND Specify request command to use", 195 " --resolve HOST:PORT:ADDRESS Force resolve of HOST:PORT to ADDRESS", 196 " --retry NUM " 197 "Retry request NUM times if transient problems occur", 198 " --retry-delay SECONDS Wait SECONDS between retries", 199 " --retry-max-time SECONDS Retry only within this period", 200 " --sasl-ir Enable initial response in SASL authentication", 201 " -S, --show-error " 202 "Show error. With -s, make curl show errors when they occur", 203 " -s, --silent Silent mode (don't output anything)", 204 " --socks4 HOST[:PORT] SOCKS4 proxy on given host + port", 205 " --socks4a HOST[:PORT] SOCKS4a proxy on given host + port", 206 " --socks5 HOST[:PORT] SOCKS5 proxy on given host + port", 207 " --socks5-hostname HOST[:PORT] " 208 "SOCKS5 proxy, pass host name to proxy", 209 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) 210 " --socks5-gssapi-service NAME SOCKS5 proxy service name for GSS-API", 211 " --socks5-gssapi-nec Compatibility with NEC SOCKS5 server", 212 #endif 213 " -Y, --speed-limit RATE " 214 "Stop transfers below RATE for 'speed-time' secs", 215 " -y, --speed-time SECONDS " 216 "Trigger 'speed-limit' abort after SECONDS (default: 30)", 217 " --ssl Try SSL/TLS (FTP, IMAP, POP3, SMTP)", 218 " --ssl-reqd Require SSL/TLS (FTP, IMAP, POP3, SMTP)", 219 " -2, --sslv2 Use SSLv2 (SSL)", 220 " -3, --sslv3 Use SSLv3 (SSL)", 221 " --ssl-allow-beast Allow security flaw to improve interop (SSL)", 222 " --stderr FILE Where to redirect stderr (use \"-\" for stdout)", 223 " --tcp-nodelay Use the TCP_NODELAY option", 224 " -t, --telnet-option OPT=VAL Set telnet option", 225 " --tftp-blksize VALUE Set TFTP BLKSIZE option (must be >512)", 226 " -z, --time-cond TIME Transfer based on a time condition", 227 " -1, --tlsv1 Use => TLSv1 (SSL)", 228 " --tlsv1.0 Use TLSv1.0 (SSL)", 229 " --tlsv1.1 Use TLSv1.1 (SSL)", 230 " --tlsv1.2 Use TLSv1.2 (SSL)", 231 " --trace FILE Write a debug trace to FILE", 232 " --trace-ascii FILE Like --trace, but without hex output", 233 " --trace-time Add time stamps to trace/verbose output", 234 " --tr-encoding Request compressed transfer encoding (H)", 235 " -T, --upload-file FILE Transfer FILE to destination", 236 " --url URL URL to work with", 237 " -B, --use-ascii Use ASCII/text transfer", 238 " -u, --user USER[:PASSWORD] Server user and password", 239 " --tlsuser USER TLS username", 240 " --tlspassword STRING TLS password", 241 " --tlsauthtype STRING TLS authentication type (default: SRP)", 242 " --unix-socket FILE Connect through this Unix domain socket", 243 " -A, --user-agent STRING Send User-Agent STRING to server (H)", 244 " -v, --verbose Make the operation more talkative", 245 " -V, --version Show version number and quit", 246 #ifdef USE_WATT32 247 " --wdebug Turn on Watt-32 debugging", 248 #endif 249 " -w, --write-out FORMAT Use output FORMAT after completion", 250 " --xattr Store metadata in extended file attributes", 251 " -q Disable .curlrc (must be first parameter)", 252 NULL 253 }; 254 255 #ifdef NETWARE 256 # define PRINT_LINES_PAUSE 23 257 #endif 258 259 #ifdef __SYMBIAN32__ 260 # define PRINT_LINES_PAUSE 16 261 #endif 262 263 struct feat { 264 const char *name; 265 int bitmask; 266 }; 267 268 static const struct feat feats[] = { 269 {"AsynchDNS", CURL_VERSION_ASYNCHDNS}, 270 {"Debug", CURL_VERSION_DEBUG}, 271 {"TrackMemory", CURL_VERSION_CURLDEBUG}, 272 {"IDN", CURL_VERSION_IDN}, 273 {"IPv6", CURL_VERSION_IPV6}, 274 {"Largefile", CURL_VERSION_LARGEFILE}, 275 {"SSPI", CURL_VERSION_SSPI}, 276 {"GSS-API", CURL_VERSION_GSSAPI}, 277 {"Kerberos", CURL_VERSION_KERBEROS5}, 278 {"SPNEGO", CURL_VERSION_SPNEGO}, 279 {"NTLM", CURL_VERSION_NTLM}, 280 {"NTLM_WB", CURL_VERSION_NTLM_WB}, 281 {"SSL", CURL_VERSION_SSL}, 282 {"libz", CURL_VERSION_LIBZ}, 283 {"CharConv", CURL_VERSION_CONV}, 284 {"TLS-SRP", CURL_VERSION_TLSAUTH_SRP}, 285 {"HTTP2", CURL_VERSION_HTTP2}, 286 {"UnixSockets", CURL_VERSION_UNIX_SOCKETS}, 287 }; 288 289 void tool_help(void) 290 { 291 int i; 292 for(i = 0; helptext[i]; i++) { 293 puts(helptext[i]); 294 #ifdef PRINT_LINES_PAUSE 295 if(i && ((i % PRINT_LINES_PAUSE) == 0)) 296 tool_pressanykey(); 297 #endif 298 } 299 } 300 301 void tool_version_info(void) 302 { 303 const char *const *proto; 304 305 printf(CURL_ID "%s\n", curl_version()); 306 if(curlinfo->protocols) { 307 printf("Protocols: "); 308 for(proto = curlinfo->protocols; *proto; ++proto) { 309 printf("%s ", *proto); 310 } 311 puts(""); /* newline */ 312 } 313 if(curlinfo->features) { 314 unsigned int i; 315 printf("Features: "); 316 for(i = 0; i < sizeof(feats)/sizeof(feats[0]); i++) { 317 if(curlinfo->features & feats[i].bitmask) 318 printf("%s ", feats[i].name); 319 } 320 #ifdef USE_METALINK 321 printf("Metalink "); 322 #endif 323 puts(""); /* newline */ 324 } 325 } 326 327 void tool_list_engines(CURL *curl) 328 { 329 struct curl_slist *engines = NULL; 330 331 /* Get the list of engines */ 332 curl_easy_getinfo(curl, CURLINFO_SSL_ENGINES, &engines); 333 334 puts("Build-time engines:"); 335 if(engines) { 336 for(; engines; engines = engines->next) 337 printf(" %s\n", engines->data); 338 } 339 else { 340 puts(" <none>"); 341 } 342 343 /* Cleanup the list of engines */ 344 curl_slist_free_all(engines); 345 } 346