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