1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
22 #include "tool_setup.h"
24 #include "tool_panykey.h"
25 #include "tool_help.h"
26 #include "tool_libinfo.h"
27 #include "tool_version.h"
29 #include "memdebug.h" /* keep this as LAST include */
36 * The help output is generated with the following command
37 ---------------------------------------------------------
39 cd $srcroot/docs/cmdline-opts
48 static const struct helptxt helptext[] = {
49 {" --abstract-unix-socket <path>",
50 "Connect via abstract Unix domain socket"},
52 "Pick any authentication method"},
54 "Append to target file when uploading"},
56 "Use HTTP Basic Authentication"},
58 "CA certificate to verify peer against"},
60 "CA directory to verify peer against"},
61 {"-E, --cert <certificate[:password]>",
62 "Client certificate file and password"},
64 "Verify the status of the server certificate"},
65 {" --cert-type <type>",
66 "Certificate file type (DER/PEM/ENG)"},
67 {" --ciphers <list of ciphers>",
68 "SSL ciphers to use"},
70 "Request compressed response"},
72 "Enable SSH compression"},
73 {"-K, --config <file>",
74 "Read config from a file"},
75 {" --connect-timeout <seconds>",
76 "Maximum time allowed for connection"},
77 {" --connect-to <HOST1:PORT1:HOST2:PORT2>",
79 {"-C, --continue-at <offset>",
80 "Resumed transfer offset"},
81 {"-b, --cookie <data>",
82 "Send cookies from string/file"},
83 {"-c, --cookie-jar <filename>",
84 "Write cookies to <filename> after operation"},
86 "Create necessary local directory hierarchy"},
88 "Convert LF to CRLF in upload"},
90 "Get a CRL list in PEM format from the given file"},
93 {" --data-ascii <data>",
94 "HTTP POST ASCII data"},
95 {" --data-binary <data>",
96 "HTTP POST binary data"},
97 {" --data-raw <data>",
98 "HTTP POST data, '@' allowed"},
99 {" --data-urlencode <data>",
100 "HTTP POST data url encoded"},
101 {" --delegation <LEVEL>",
102 "GSS-API delegation permission"},
104 "Use HTTP Digest Authentication"},
108 "Inhibit using EPRT or LPRT"},
110 "Inhibit using EPSV"},
111 {" --dns-interface <interface>",
112 "Interface to use for DNS requests"},
113 {" --dns-ipv4-addr <address>",
114 "IPv4 address to use for DNS requests"},
115 {" --dns-ipv6-addr <address>",
116 "IPv6 address to use for DNS requests"},
117 {" --dns-servers <addresses>",
118 "DNS server addrs to use"},
119 {"-D, --dump-header <filename>",
120 "Write the received headers to <filename>"},
121 {" --egd-file <file>",
122 "EGD socket path for random data"},
124 "Crypto engine to use"},
125 {" --expect100-timeout <seconds>",
126 "How long to wait for 100-continue"},
128 "Fail silently (no output at all) on HTTP errors"},
130 "Fail on first transfer error, do not continue"},
132 "Enable TLS False Start"},
133 {"-F, --form <name=content>",
134 "Specify multipart MIME data"},
135 {" --form-string <name=string>",
136 "Specify multipart MIME data"},
137 {" --ftp-account <data>",
138 "Account data string"},
139 {" --ftp-alternative-to-user <command>",
140 "String to replace USER [name]"},
141 {" --ftp-create-dirs",
142 "Create the remote dirs if not present"},
143 {" --ftp-method <method>",
144 "Control CWD usage"},
146 "Use PASV/EPSV instead of PORT"},
147 {"-P, --ftp-port <address>",
148 "Use PORT instead of PASV"},
150 "Send PRET before PASV"},
151 {" --ftp-skip-pasv-ip",
152 "Skip the IP address for PASV"},
154 "Send CCC after authenticating"},
155 {" --ftp-ssl-ccc-mode <active/passive>",
157 {" --ftp-ssl-control",
158 "Require SSL/TLS for FTP login, clear for transfer"},
160 "Put the post data in the URL and use GET"},
162 "Disable URL sequences and ranges using {} and []"},
164 "Show document info only"},
165 {"-H, --header <header/@file>",
166 "Pass custom header(s) to server"},
169 {" --hostpubmd5 <md5>",
170 "Acceptable MD5 hash of the host public key"},
177 {" --http2-prior-knowledge",
178 "Use HTTP 2 without HTTP/1.1 Upgrade"},
179 {" --ignore-content-length",
180 "Ignore the size of the remote resource"},
182 "Include protocol response headers in the output"},
184 "Allow insecure server connections when using SSL"},
185 {" --interface <name>",
186 "Use network INTERFACE (or address)"},
188 "Resolve names to IPv4 addresses"},
190 "Resolve names to IPv6 addresses"},
191 {"-j, --junk-session-cookies",
192 "Ignore session cookies read from file"},
193 {" --keepalive-time <seconds>",
194 "Interval time for keepalive probes"},
196 "Private key file name"},
197 {" --key-type <type>",
198 "Private key file type (DER/PEM/ENG)"},
200 "Enable Kerberos with security <level>"},
201 {" --libcurl <file>",
202 "Dump libcurl equivalent code of this command line"},
203 {" --limit-rate <speed>",
204 "Limit transfer speed to RATE"},
207 {" --local-port <num/range>",
208 "Force use of RANGE for local port numbers"},
211 {" --location-trusted",
212 "Like --location, and send auth to other hosts"},
213 {" --login-options <options>",
214 "Server login options"},
215 {" --mail-auth <address>",
216 "Originator address of the original email"},
217 {" --mail-from <address>",
218 "Mail from this address"},
219 {" --mail-rcpt <address>",
220 "Mail from this address"},
222 "Display the full manual"},
223 {" --max-filesize <bytes>",
224 "Maximum file size to download"},
225 {" --max-redirs <num>",
226 "Maximum number of redirects allowed"},
227 {"-m, --max-time <time>",
228 "Maximum time allowed for the transfer"},
230 "Process given URLs as metalink XML file"},
232 "Use HTTP Negotiate (SPNEGO) authentication"},
234 "Must read .netrc for user name and password"},
235 {" --netrc-file <filename>",
236 "Specify FILE for netrc"},
237 {" --netrc-optional",
238 "Use either .netrc or URL"},
240 "Make next URL use its separate set of options"},
242 "Disable the ALPN TLS extension"},
244 "Disable buffering of the output stream"},
246 "Disable TCP keepalive on the connection"},
248 "Disable the NPN TLS extension"},
250 "Disable SSL session-ID reusing"},
251 {" --noproxy <no-proxy-list>",
252 "List of hosts which do not use proxy"},
254 "Use HTTP NTLM authentication"},
256 "Use HTTP NTLM authentication with winbind"},
257 {" --oauth2-bearer <token>",
258 "OAuth 2 Bearer Token"},
259 {"-o, --output <file>",
260 "Write to file instead of stdout"},
262 "Pass phrase for the private key"},
264 "Do not squash .. sequences in URL path"},
265 {" --pinnedpubkey <hashes>",
266 "FILE/HASHES Public key to verify peer against"},
268 "Do not switch to GET after following a 301"},
270 "Do not switch to GET after following a 302"},
272 "Do not switch to GET after following a 303"},
273 {" --preproxy [protocol://]host[:port]",
274 "Use this proxy first"},
275 {"-#, --progress-bar",
276 "Display transfer progress as a bar"},
277 {" --proto <protocols>",
278 "Enable/disable PROTOCOLS"},
279 {" --proto-default <protocol>",
280 "Use PROTOCOL for any URL missing a scheme"},
281 {" --proto-redir <protocols>",
282 "Enable/disable PROTOCOLS on redirect"},
283 {"-x, --proxy [protocol://]host[:port]",
286 "Pick any proxy authentication method"},
288 "Use Basic authentication on the proxy"},
289 {" --proxy-cacert <file>",
290 "CA certificate to verify peer against for proxy"},
291 {" --proxy-capath <dir>",
292 "CA directory to verify peer against for proxy"},
293 {" --proxy-cert <cert[:passwd]>",
294 "Set client certificate for proxy"},
295 {" --proxy-cert-type <type>",
296 "Client certificate type for HTTS proxy"},
297 {" --proxy-ciphers <list>",
298 "SSL ciphers to use for proxy"},
299 {" --proxy-crlfile <file>",
300 "Set a CRL list for proxy"},
302 "Use Digest authentication on the proxy"},
303 {" --proxy-header <header/@file>",
304 "Pass custom header(s) to proxy"},
305 {" --proxy-insecure",
306 "Do HTTPS proxy connections without verifying the proxy"},
307 {" --proxy-key <key>",
308 "Private key for HTTPS proxy"},
309 {" --proxy-key-type <type>",
310 "Private key file type for proxy"},
311 {" --proxy-negotiate",
312 "Use HTTP Negotiate (SPNEGO) authentication on the proxy"},
314 "Use NTLM authentication on the proxy"},
315 {" --proxy-pass <phrase>",
316 "Pass phrase for the private key for HTTPS proxy"},
317 {" --proxy-service-name <name>",
318 "SPNEGO proxy service name"},
319 {" --proxy-ssl-allow-beast",
320 "Allow security flaw for interop for HTTPS proxy"},
321 {" --proxy-tlsauthtype <type>",
322 "TLS authentication type for HTTPS proxy"},
323 {" --proxy-tlspassword <string>",
324 "TLS password for HTTPS proxy"},
325 {" --proxy-tlsuser <name>",
326 "TLS username for HTTPS proxy"},
328 "Use TLSv1 for HTTPS proxy"},
329 {"-U, --proxy-user <user:password>",
330 "Proxy user and password"},
331 {" --proxy1.0 <host[:port]>",
332 "Use HTTP/1.0 proxy on given port"},
333 {"-p, --proxytunnel",
334 "Operate through a HTTP proxy tunnel (using CONNECT)"},
336 "SSH Public key file name"},
338 "Send command(s) to server before transfer"},
339 {" --random-file <file>",
340 "File for reading random data from"},
341 {"-r, --range <range>",
342 "Retrieve only the bytes within RANGE"},
344 "Do HTTP \"raw\"; no transfer decoding"},
345 {"-e, --referer <URL>",
347 {"-J, --remote-header-name",
348 "Use the header-provided filename"},
349 {"-O, --remote-name",
350 "Write output to a file named as the remote file"},
351 {" --remote-name-all",
352 "Use the remote file name for all URLs"},
353 {"-R, --remote-time",
354 "Set the remote file's time on the local output"},
355 {"-X, --request <command>",
356 "Specify request command to use"},
357 {" --request-target",
358 "Specify the target for this request"},
359 {" --resolve <host:port:address>",
360 "Resolve the host+port to this address"},
362 "Retry request if transient problems occur"},
363 {" --retry-connrefused",
364 "Retry on connection refused (use with --retry)"},
365 {" --retry-delay <seconds>",
366 "Wait time between retries"},
367 {" --retry-max-time <seconds>",
368 "Retry only within this period"},
370 "Enable initial response in SASL authentication"},
371 {" --service-name <name>",
372 "SPNEGO service name"},
374 "Show error even when -s is used"},
377 {" --socks4 <host[:port]>",
378 "SOCKS4 proxy on given host + port"},
379 {" --socks4a <host[:port]>",
380 "SOCKS4a proxy on given host + port"},
381 {" --socks5 <host[:port]>",
382 "SOCKS5 proxy on given host + port"},
384 "Enable username/password auth for SOCKS5 proxies"},
386 "Enable GSS-API auth for SOCKS5 proxies"},
387 {" --socks5-gssapi-nec",
388 "Compatibility with NEC SOCKS5 server"},
389 {" --socks5-gssapi-service <name>",
390 "SOCKS5 proxy service name for GSS-API"},
391 {" --socks5-hostname <host[:port]>",
392 "SOCKS5 proxy, pass host name to proxy"},
393 {"-Y, --speed-limit <speed>",
394 "Stop transfers slower than this"},
395 {"-y, --speed-time <seconds>",
396 "Trigger 'speed-limit' abort after this time"},
399 {" --ssl-allow-beast",
400 "Allow security flaw to improve interop"},
402 "Disable cert revocation checks (WinSSL)"},
410 "Where to redirect stderr"},
411 {" --suppress-connect-headers",
412 "Suppress proxy CONNECT response headers"},
414 "Use TCP Fast Open"},
416 "Use the TCP_NODELAY option"},
417 {"-t, --telnet-option <opt=val>",
418 "Set telnet option"},
419 {" --tftp-blksize <value>",
420 "Set TFTP BLKSIZE option"},
421 {" --tftp-no-options",
422 "Do not send any TFTP options"},
423 {"-z, --time-cond <time>",
424 "Transfer based on a time condition"},
425 {" --tls-max <VERSION>",
426 "Use TLSv1.0 or greater"},
427 {" --tlsauthtype <type>",
428 "TLS authentication type"},
431 {" --tlsuser <name>",
434 "Use TLSv1.0 or greater"},
444 "Request compressed transfer encoding"},
446 "Write a debug trace to FILE"},
447 {" --trace-ascii <file>",
448 "Like --trace, but without hex output"},
450 "Add time stamps to trace/verbose output"},
451 {" --unix-socket <path>",
452 "Connect through this Unix domain socket"},
453 {"-T, --upload-file <file>",
454 "Transfer local FILE to destination"},
458 "Use ASCII/text transfer"},
459 {"-u, --user <user:password>",
460 "Server user and password"},
461 {"-A, --user-agent <name>",
462 "Send User-Agent <name> to server"},
464 "Make the operation more talkative"},
466 "Show version number and quit"},
467 {"-w, --write-out <format>",
468 "Use output FORMAT after completion"},
470 "Store metadata in extended file attributes"},
475 # define PRINT_LINES_PAUSE 23
479 # define PRINT_LINES_PAUSE 16
487 static const struct feat feats[] = {
488 {"AsynchDNS", CURL_VERSION_ASYNCHDNS},
489 {"Debug", CURL_VERSION_DEBUG},
490 {"TrackMemory", CURL_VERSION_CURLDEBUG},
491 {"IDN", CURL_VERSION_IDN},
492 {"IPv6", CURL_VERSION_IPV6},
493 {"Largefile", CURL_VERSION_LARGEFILE},
494 {"SSPI", CURL_VERSION_SSPI},
495 {"GSS-API", CURL_VERSION_GSSAPI},
496 {"Kerberos", CURL_VERSION_KERBEROS5},
497 {"SPNEGO", CURL_VERSION_SPNEGO},
498 {"NTLM", CURL_VERSION_NTLM},
499 {"NTLM_WB", CURL_VERSION_NTLM_WB},
500 {"SSL", CURL_VERSION_SSL},
501 {"libz", CURL_VERSION_LIBZ},
502 {"CharConv", CURL_VERSION_CONV},
503 {"TLS-SRP", CURL_VERSION_TLSAUTH_SRP},
504 {"HTTP2", CURL_VERSION_HTTP2},
505 {"UnixSockets", CURL_VERSION_UNIX_SOCKETS},
506 {"HTTPS-proxy", CURL_VERSION_HTTPS_PROXY},
507 {"MultiSSL", CURL_VERSION_MULTI_SSL}
513 puts("Usage: curl [options...] <url>");
514 for(i = 0; helptext[i].opt; i++) {
515 printf(" %-19s %s\n", helptext[i].opt, helptext[i].desc);
516 #ifdef PRINT_LINES_PAUSE
517 if(i && ((i % PRINT_LINES_PAUSE) == 0))
523 void tool_version_info(void)
525 const char *const *proto;
527 printf(CURL_ID "%s\n", curl_version());
528 #ifdef CURL_PATCHSTAMP
529 printf("Release-Date: %s, security patched: %s\n",
530 LIBCURL_TIMESTAMP, CURL_PATCHSTAMP);
532 printf("Release-Date: %s\n", LIBCURL_TIMESTAMP);
534 if(curlinfo->protocols) {
535 printf("Protocols: ");
536 for(proto = curlinfo->protocols; *proto; ++proto) {
537 printf("%s ", *proto);
539 puts(""); /* newline */
541 if(curlinfo->features) {
543 printf("Features: ");
544 for(i = 0; i < sizeof(feats)/sizeof(feats[0]); i++) {
545 if(curlinfo->features & feats[i].bitmask)
546 printf("%s ", feats[i].name);
554 puts(""); /* newline */
558 void tool_list_engines(CURL *curl)
560 struct curl_slist *engines = NULL;
562 /* Get the list of engines */
563 curl_easy_getinfo(curl, CURLINFO_SSL_ENGINES, &engines);
565 puts("Build-time engines:");
567 for(; engines; engines = engines->next)
568 printf(" %s\n", engines->data);
574 /* Cleanup the list of engines */
575 curl_slist_free_all(engines);