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