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