1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2018, 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 []"},
163 {" --happy-eyeballs-timeout-ms",
164 "How long to wait in milliseconds for IPv6 before trying IPv4"},
166 "Show document info only"},
167 {"-H, --header <header/@file>",
168 "Pass custom header(s) to server"},
171 {" --hostpubmd5 <md5>",
172 "Acceptable MD5 hash of the host public key"},
179 {" --http2-prior-knowledge",
180 "Use HTTP 2 without HTTP/1.1 Upgrade"},
181 {" --ignore-content-length",
182 "Ignore the size of the remote resource"},
184 "Include protocol response headers in the output"},
186 "Allow insecure server connections when using SSL"},
187 {" --interface <name>",
188 "Use network INTERFACE (or address)"},
190 "Resolve names to IPv4 addresses"},
192 "Resolve names to IPv6 addresses"},
193 {"-j, --junk-session-cookies",
194 "Ignore session cookies read from file"},
195 {" --keepalive-time <seconds>",
196 "Interval time for keepalive probes"},
198 "Private key file name"},
199 {" --key-type <type>",
200 "Private key file type (DER/PEM/ENG)"},
202 "Enable Kerberos with security <level>"},
203 {" --libcurl <file>",
204 "Dump libcurl equivalent code of this command line"},
205 {" --limit-rate <speed>",
206 "Limit transfer speed to RATE"},
209 {" --local-port <num/range>",
210 "Force use of RANGE for local port numbers"},
213 {" --location-trusted",
214 "Like --location, and send auth to other hosts"},
215 {" --login-options <options>",
216 "Server login options"},
217 {" --mail-auth <address>",
218 "Originator address of the original email"},
219 {" --mail-from <address>",
220 "Mail from this address"},
221 {" --mail-rcpt <address>",
222 "Mail to this address"},
224 "Display the full manual"},
225 {" --max-filesize <bytes>",
226 "Maximum file size to download"},
227 {" --max-redirs <num>",
228 "Maximum number of redirects allowed"},
229 {"-m, --max-time <time>",
230 "Maximum time allowed for the transfer"},
232 "Process given URLs as metalink XML file"},
234 "Use HTTP Negotiate (SPNEGO) authentication"},
236 "Must read .netrc for user name and password"},
237 {" --netrc-file <filename>",
238 "Specify FILE for netrc"},
239 {" --netrc-optional",
240 "Use either .netrc or URL"},
242 "Make next URL use its separate set of options"},
244 "Disable the ALPN TLS extension"},
246 "Disable buffering of the output stream"},
248 "Disable TCP keepalive on the connection"},
250 "Disable the NPN TLS extension"},
252 "Disable SSL session-ID reusing"},
253 {" --noproxy <no-proxy-list>",
254 "List of hosts which do not use proxy"},
256 "Use HTTP NTLM authentication"},
258 "Use HTTP NTLM authentication with winbind"},
259 {" --oauth2-bearer <token>",
260 "OAuth 2 Bearer Token"},
261 {"-o, --output <file>",
262 "Write to file instead of stdout"},
264 "Pass phrase for the private key"},
266 "Do not squash .. sequences in URL path"},
267 {" --pinnedpubkey <hashes>",
268 "FILE/HASHES Public key to verify peer against"},
270 "Do not switch to GET after following a 301"},
272 "Do not switch to GET after following a 302"},
274 "Do not switch to GET after following a 303"},
275 {" --preproxy [protocol://]host[:port]",
276 "Use this proxy first"},
277 {"-#, --progress-bar",
278 "Display transfer progress as a bar"},
279 {" --proto <protocols>",
280 "Enable/disable PROTOCOLS"},
281 {" --proto-default <protocol>",
282 "Use PROTOCOL for any URL missing a scheme"},
283 {" --proto-redir <protocols>",
284 "Enable/disable PROTOCOLS on redirect"},
285 {"-x, --proxy [protocol://]host[:port]",
288 "Pick any proxy authentication method"},
290 "Use Basic authentication on the proxy"},
291 {" --proxy-cacert <file>",
292 "CA certificate to verify peer against for proxy"},
293 {" --proxy-capath <dir>",
294 "CA directory to verify peer against for proxy"},
295 {" --proxy-cert <cert[:passwd]>",
296 "Set client certificate for proxy"},
297 {" --proxy-cert-type <type>",
298 "Client certificate type for HTTS proxy"},
299 {" --proxy-ciphers <list>",
300 "SSL ciphers to use for proxy"},
301 {" --proxy-crlfile <file>",
302 "Set a CRL list for proxy"},
304 "Use Digest authentication on the proxy"},
305 {" --proxy-header <header/@file>",
306 "Pass custom header(s) to proxy"},
307 {" --proxy-insecure",
308 "Do HTTPS proxy connections without verifying the proxy"},
309 {" --proxy-key <key>",
310 "Private key for HTTPS proxy"},
311 {" --proxy-key-type <type>",
312 "Private key file type for proxy"},
313 {" --proxy-negotiate",
314 "Use HTTP Negotiate (SPNEGO) authentication on the proxy"},
316 "Use NTLM authentication on the proxy"},
317 {" --proxy-pass <phrase>",
318 "Pass phrase for the private key for HTTPS proxy"},
319 {" --proxy-pinnedpubkey <hashes>",
320 "FILE/HASHES public key to verify proxy with"},
321 {" --proxy-service-name <name>",
322 "SPNEGO proxy service name"},
323 {" --proxy-ssl-allow-beast",
324 "Allow security flaw for interop for HTTPS proxy"},
325 {" --proxy-tlsauthtype <type>",
326 "TLS authentication type for HTTPS proxy"},
327 {" --proxy-tlspassword <string>",
328 "TLS password for HTTPS proxy"},
329 {" --proxy-tlsuser <name>",
330 "TLS username for HTTPS proxy"},
332 "Use TLSv1 for HTTPS proxy"},
333 {"-U, --proxy-user <user:password>",
334 "Proxy user and password"},
335 {" --proxy1.0 <host[:port]>",
336 "Use HTTP/1.0 proxy on given port"},
337 {"-p, --proxytunnel",
338 "Operate through a HTTP proxy tunnel (using CONNECT)"},
340 "SSH Public key file name"},
342 "Send command(s) to server before transfer"},
343 {" --random-file <file>",
344 "File for reading random data from"},
345 {"-r, --range <range>",
346 "Retrieve only the bytes within RANGE"},
348 "Do HTTP \"raw\"; no transfer decoding"},
349 {"-e, --referer <URL>",
351 {"-J, --remote-header-name",
352 "Use the header-provided filename"},
353 {"-O, --remote-name",
354 "Write output to a file named as the remote file"},
355 {" --remote-name-all",
356 "Use the remote file name for all URLs"},
357 {"-R, --remote-time",
358 "Set the remote file's time on the local output"},
359 {"-X, --request <command>",
360 "Specify request command to use"},
361 {" --request-target",
362 "Specify the target for this request"},
363 {" --resolve <host:port:address>",
364 "Resolve the host+port to this address"},
366 "Retry request if transient problems occur"},
367 {" --retry-connrefused",
368 "Retry on connection refused (use with --retry)"},
369 {" --retry-delay <seconds>",
370 "Wait time between retries"},
371 {" --retry-max-time <seconds>",
372 "Retry only within this period"},
374 "Enable initial response in SASL authentication"},
375 {" --service-name <name>",
376 "SPNEGO service name"},
378 "Show error even when -s is used"},
381 {" --socks4 <host[:port]>",
382 "SOCKS4 proxy on given host + port"},
383 {" --socks4a <host[:port]>",
384 "SOCKS4a proxy on given host + port"},
385 {" --socks5 <host[:port]>",
386 "SOCKS5 proxy on given host + port"},
388 "Enable username/password auth for SOCKS5 proxies"},
390 "Enable GSS-API auth for SOCKS5 proxies"},
391 {" --socks5-gssapi-nec",
392 "Compatibility with NEC SOCKS5 server"},
393 {" --socks5-gssapi-service <name>",
394 "SOCKS5 proxy service name for GSS-API"},
395 {" --socks5-hostname <host[:port]>",
396 "SOCKS5 proxy, pass host name to proxy"},
397 {"-Y, --speed-limit <speed>",
398 "Stop transfers slower than this"},
399 {"-y, --speed-time <seconds>",
400 "Trigger 'speed-limit' abort after this time"},
403 {" --ssl-allow-beast",
404 "Allow security flaw to improve interop"},
406 "Disable cert revocation checks (WinSSL)"},
414 "Where to redirect stderr"},
415 {" --suppress-connect-headers",
416 "Suppress proxy CONNECT response headers"},
418 "Use TCP Fast Open"},
420 "Use the TCP_NODELAY option"},
421 {"-t, --telnet-option <opt=val>",
422 "Set telnet option"},
423 {" --tftp-blksize <value>",
424 "Set TFTP BLKSIZE option"},
425 {" --tftp-no-options",
426 "Do not send any TFTP options"},
427 {"-z, --time-cond <time>",
428 "Transfer based on a time condition"},
429 {" --tls-max <VERSION>",
430 "Use TLSv1.0 or greater"},
431 {" --tlsauthtype <type>",
432 "TLS authentication type"},
435 {" --tlsuser <name>",
438 "Use TLSv1.0 or greater"},
448 "Request compressed transfer encoding"},
450 "Write a debug trace to FILE"},
451 {" --trace-ascii <file>",
452 "Like --trace, but without hex output"},
454 "Add time stamps to trace/verbose output"},
455 {" --unix-socket <path>",
456 "Connect through this Unix domain socket"},
457 {"-T, --upload-file <file>",
458 "Transfer local FILE to destination"},
462 "Use ASCII/text transfer"},
463 {"-u, --user <user:password>",
464 "Server user and password"},
465 {"-A, --user-agent <name>",
466 "Send User-Agent <name> to server"},
468 "Make the operation more talkative"},
470 "Show version number and quit"},
471 {"-w, --write-out <format>",
472 "Use output FORMAT after completion"},
474 "Store metadata in extended file attributes"},
479 # define PRINT_LINES_PAUSE 23
483 # define PRINT_LINES_PAUSE 16
491 static const struct feat feats[] = {
492 {"AsynchDNS", CURL_VERSION_ASYNCHDNS},
493 {"Debug", CURL_VERSION_DEBUG},
494 {"TrackMemory", CURL_VERSION_CURLDEBUG},
495 {"IDN", CURL_VERSION_IDN},
496 {"IPv6", CURL_VERSION_IPV6},
497 {"Largefile", CURL_VERSION_LARGEFILE},
498 {"SSPI", CURL_VERSION_SSPI},
499 {"GSS-API", CURL_VERSION_GSSAPI},
500 {"Kerberos", CURL_VERSION_KERBEROS5},
501 {"SPNEGO", CURL_VERSION_SPNEGO},
502 {"NTLM", CURL_VERSION_NTLM},
503 {"NTLM_WB", CURL_VERSION_NTLM_WB},
504 {"SSL", CURL_VERSION_SSL},
505 {"libz", CURL_VERSION_LIBZ},
506 {"brotli", CURL_VERSION_BROTLI},
507 {"CharConv", CURL_VERSION_CONV},
508 {"TLS-SRP", CURL_VERSION_TLSAUTH_SRP},
509 {"HTTP2", CURL_VERSION_HTTP2},
510 {"UnixSockets", CURL_VERSION_UNIX_SOCKETS},
511 {"HTTPS-proxy", CURL_VERSION_HTTPS_PROXY},
512 {"MultiSSL", CURL_VERSION_MULTI_SSL},
513 {"PSL", CURL_VERSION_PSL},
519 puts("Usage: curl [options...] <url>");
520 for(i = 0; helptext[i].opt; i++) {
521 printf(" %-19s %s\n", helptext[i].opt, helptext[i].desc);
522 #ifdef PRINT_LINES_PAUSE
523 if(i && ((i % PRINT_LINES_PAUSE) == 0))
529 void tool_version_info(void)
531 const char *const *proto;
533 printf(CURL_ID "%s\n", curl_version());
534 #ifdef CURL_PATCHSTAMP
535 printf("Release-Date: %s, security patched: %s\n",
536 LIBCURL_TIMESTAMP, CURL_PATCHSTAMP);
538 printf("Release-Date: %s\n", LIBCURL_TIMESTAMP);
540 if(curlinfo->protocols) {
541 printf("Protocols: ");
542 for(proto = curlinfo->protocols; *proto; ++proto) {
543 printf("%s ", *proto);
545 puts(""); /* newline */
547 if(curlinfo->features) {
549 printf("Features: ");
550 for(i = 0; i < sizeof(feats)/sizeof(feats[0]); i++) {
551 if(curlinfo->features & feats[i].bitmask)
552 printf("%s ", feats[i].name);
557 puts(""); /* newline */
561 void tool_list_engines(CURL *curl)
563 struct curl_slist *engines = NULL;
565 /* Get the list of engines */
566 curl_easy_getinfo(curl, CURLINFO_SSL_ENGINES, &engines);
568 puts("Build-time engines:");
570 for(; engines; engines = engines->next)
571 printf(" %s\n", engines->data);
577 /* Cleanup the list of engines */
578 curl_slist_free_all(engines);