blob: 46aae4527189594ce6e9522d0300acc48988f61d [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) 1998 - 2017, 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 * The help output is generated with the following command
37 ---------------------------------------------------------
38
39 cd $srcroot/docs/cmdline-opts
40 ./gen.pl listhelp
41 */
42
43struct helptxt {
44 const char *opt;
45 const char *desc;
46};
47
48static const struct helptxt helptext[] = {
49 {" --abstract-unix-socket <path>",
50 "Connect via abstract Unix domain socket"},
51 {" --anyauth",
52 "Pick any authentication method"},
53 {"-a, --append",
54 "Append to target file when uploading"},
55 {" --basic",
56 "Use HTTP Basic Authentication"},
57 {" --cacert <CA certificate>",
58 "CA certificate to verify peer against"},
59 {" --capath <dir>",
60 "CA directory to verify peer against"},
61 {"-E, --cert <certificate[:password]>",
62 "Client certificate file and password"},
63 {" --cert-status",
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"},
69 {" --compressed",
70 "Request compressed response"},
71 {"-K, --config <file>",
72 "Read config from a file"},
73 {" --connect-timeout <seconds>",
74 "Maximum time allowed for connection"},
75 {" --connect-to <HOST1:PORT1:HOST2:PORT2>",
76 "Connect to host"},
77 {"-C, --continue-at <offset>",
78 "Resumed transfer offset"},
79 {"-b, --cookie <data>",
80 "Send cookies from string/file"},
81 {"-c, --cookie-jar <filename>",
82 "Write cookies to <filename> after operation"},
83 {" --create-dirs",
84 "Create necessary local directory hierarchy"},
85 {" --crlf",
86 "Convert LF to CRLF in upload"},
87 {" --crlfile <file>",
88 "Get a CRL list in PEM format from the given file"},
89 {"-d, --data <data>",
90 "HTTP POST data"},
91 {" --data-ascii <data>",
92 "HTTP POST ASCII data"},
93 {" --data-binary <data>",
94 "HTTP POST binary data"},
95 {" --data-raw <data>",
96 "HTTP POST data, '@' allowed"},
97 {" --data-urlencode <data>",
98 "HTTP POST data url encoded"},
99 {" --delegation <LEVEL>",
100 "GSS-API delegation permission"},
101 {" --digest",
102 "Use HTTP Digest Authentication"},
103 {"-q, --disable",
104 "Disable .curlrc"},
105 {" --disable-eprt",
106 "Inhibit using EPRT or LPRT"},
107 {" --disable-epsv",
108 "Inhibit using EPSV"},
109 {" --dns-interface <interface>",
110 "Interface to use for DNS requests"},
111 {" --dns-ipv4-addr <address>",
112 "IPv4 address to use for DNS requests"},
113 {" --dns-ipv6-addr <address>",
114 "IPv6 address to use for DNS requests"},
115 {" --dns-servers <addresses>",
116 "DNS server addrs to use"},
117 {"-D, --dump-header <filename>",
118 "Write the received headers to <filename>"},
119 {" --egd-file <file>",
120 "EGD socket path for random data"},
121 {" --engine <name>",
122 "Crypto engine to use"},
123 {" --expect100-timeout <seconds>",
124 "How long to wait for 100-continue"},
125 {"-f, --fail",
126 "Fail silently (no output at all) on HTTP errors"},
127 {" --fail-early",
128 "Fail on first transfer error, do not continue"},
129 {" --false-start",
130 "Enable TLS False Start"},
131 {"-F, --form <name=content>",
132 "Specify HTTP multipart POST data"},
133 {" --form-string <name=string>",
134 "Specify HTTP multipart POST data"},
135 {" --ftp-account <data>",
136 "Account data string"},
137 {" --ftp-alternative-to-user <command>",
138 "String to replace USER [name]"},
139 {" --ftp-create-dirs",
140 "Create the remote dirs if not present"},
141 {" --ftp-method <method>",
142 "Control CWD usage"},
143 {" --ftp-pasv",
144 "Use PASV/EPSV instead of PORT"},
145 {"-P, --ftp-port <address>",
146 "Use PORT instead of PASV"},
147 {" --ftp-pret",
148 "Send PRET before PASV"},
149 {" --ftp-skip-pasv-ip",
150 "Skip the IP address for PASV"},
151 {" --ftp-ssl-ccc",
152 "Send CCC after authenticating"},
153 {" --ftp-ssl-ccc-mode <active/passive>",
154 "Set CCC mode"},
155 {" --ftp-ssl-control",
156 "Require SSL/TLS for FTP login, clear for transfer"},
157 {"-G, --get",
158 "Put the post data in the URL and use GET"},
159 {"-g, --globoff",
160 "Disable URL sequences and ranges using {} and []"},
161 {"-I, --head",
162 "Show document info only"},
163 {"-H, --header <header>",
164 "Pass custom header LINE to server"},
165 {"-h, --help",
166 "This help text"},
167 {" --hostpubmd5 <md5>",
168 "Acceptable MD5 hash of the host public key"},
169 {"-0, --http1.0",
170 "Use HTTP 1.0"},
171 {" --http1.1",
172 "Use HTTP 1.1"},
173 {" --http2",
174 "Use HTTP 2"},
175 {" --http2-prior-knowledge",
176 "Use HTTP 2 without HTTP/1.1 Upgrade"},
177 {" --ignore-content-length",
178 "Ignore the size of the remote resource"},
179 {"-i, --include",
180 "Include protocol headers in the output"},
181 {"-k, --insecure",
182 "Allow insecure server connections when using SSL"},
183 {" --interface <name>",
184 "Use network INTERFACE (or address)"},
185 {"-4, --ipv4",
186 "Resolve names to IPv4 addresses"},
187 {"-6, --ipv6",
188 "Resolve names to IPv6 addresses"},
189 {"-j, --junk-session-cookies",
190 "Ignore session cookies read from file"},
191 {" --keepalive-time <seconds>",
192 "Interval time for keepalive probes"},
193 {" --key <key>",
194 "Private key file name"},
195 {" --key-type <type>",
196 "Private key file type (DER/PEM/ENG)"},
197 {" --krb <level>",
198 "Enable Kerberos with security <level>"},
199 {" --libcurl <file>",
200 "Dump libcurl equivalent code of this command line"},
201 {" --limit-rate <speed>",
202 "Limit transfer speed to RATE"},
203 {"-l, --list-only",
204 "List only mode"},
205 {" --local-port <num/range>",
206 "Force use of RANGE for local port numbers"},
207 {"-L, --location",
208 "Follow redirects"},
209 {" --location-trusted",
210 "Like --location, and send auth to other hosts"},
211 {" --login-options <options>",
212 "Server login options"},
213 {" --mail-auth <address>",
214 "Originator address of the original email"},
215 {" --mail-from <address>",
216 "Mail from this address"},
217 {" --mail-rcpt <address>",
218 "Mail from this address"},
219 {"-M, --manual",
220 "Display the full manual"},
221 {" --max-filesize <bytes>",
222 "Maximum file size to download"},
223 {" --max-redirs <num>",
224 "Maximum number of redirects allowed"},
225 {"-m, --max-time <time>",
226 "Maximum time allowed for the transfer"},
227 {" --metalink",
228 "Process given URLs as metalink XML file"},
229 {" --negotiate",
230 "Use HTTP Negotiate (SPNEGO) authentication"},
231 {"-n, --netrc",
232 "Must read .netrc for user name and password"},
233 {" --netrc-file <filename>",
234 "Specify FILE for netrc"},
235 {" --netrc-optional",
236 "Use either .netrc or URL"},
237 {"-:, --next",
238 "Make next URL use its separate set of options"},
239 {" --no-alpn",
240 "Disable the ALPN TLS extension"},
241 {"-N, --no-buffer",
242 "Disable buffering of the output stream"},
243 {" --no-keepalive",
244 "Disable TCP keepalive on the connection"},
245 {" --no-npn",
246 "Disable the NPN TLS extension"},
247 {" --no-sessionid",
248 "Disable SSL session-ID reusing"},
249 {" --noproxy <no-proxy-list>",
250 "List of hosts which do not use proxy"},
251 {" --ntlm",
252 "Use HTTP NTLM authentication"},
253 {" --ntlm-wb",
254 "Use HTTP NTLM authentication with winbind"},
255 {" --oauth2-bearer",
256 "OAuth 2 Bearer Token"},
257 {"-o, --output <file>",
258 "Write to file instead of stdout"},
259 {" --pass <phrase>",
260 "Pass phrase for the private key"},
261 {" --path-as-is",
262 "Do not squash .. sequences in URL path"},
263 {" --pinnedpubkey <hashes>",
264 "FILE/HASHES Public key to verify peer against"},
265 {" --post301",
266 "Do not switch to GET after following a 301"},
267 {" --post302",
268 "Do not switch to GET after following a 302"},
269 {" --post303",
270 "Do not switch to GET after following a 303"},
271 {" --preproxy [protocol://]host[:port]",
272 "Use this proxy first"},
273 {"-#, --progress-bar",
274 "Display transfer progress as a bar"},
275 {" --proto <protocols>",
276 "Enable/disable PROTOCOLS"},
277 {" --proto-default <protocol>",
278 "Use PROTOCOL for any URL missing a scheme"},
279 {" --proto-redir <protocols>",
280 "Enable/disable PROTOCOLS on redirect"},
281 {"-x, --proxy [protocol://]host[:port]",
282 "Use this proxy"},
283 {" --proxy-anyauth",
284 "Pick any proxy authentication method"},
285 {" --proxy-basic",
286 "Use Basic authentication on the proxy"},
287 {" --proxy-cacert <file>",
288 "CA certificate to verify peer against for proxy"},
289 {" --proxy-capath <dir>",
290 "CA directory to verify peer against for proxy"},
291 {" --proxy-cert <cert[:passwd]>",
292 "Set client certificate for proxy"},
293 {" --proxy-cert-type <type>",
294 "Client certificate type for HTTS proxy"},
295 {" --proxy-ciphers <list>",
296 "SSL ciphers to use for proxy"},
297 {" --proxy-crlfile <file>",
298 "Set a CRL list for proxy"},
299 {" --proxy-digest",
300 "Use Digest authentication on the proxy"},
301 {" --proxy-header <header>",
302 "Pass custom header LINE to proxy"},
303 {" --proxy-insecure",
304 "Do HTTPS proxy connections without verifying the proxy"},
305 {" --proxy-key <key>",
306 "Private key for HTTPS proxy"},
307 {" --proxy-key-type <type>",
308 "Private key file type for proxy"},
309 {" --proxy-negotiate",
310 "Use HTTP Negotiate (SPNEGO) authentication on the proxy"},
311 {" --proxy-ntlm",
312 "Use NTLM authentication on the proxy"},
313 {" --proxy-pass <phrase>",
314 "Pass phrase for the private key for HTTPS proxy"},
315 {" --proxy-service-name <name>",
316 "SPNEGO proxy service name"},
317 {" --proxy-ssl-allow-beast",
318 "Allow security flaw for interop for HTTPS proxy"},
319 {" --proxy-tlsauthtype <type>",
320 "TLS authentication type for HTTPS proxy"},
321 {" --proxy-tlspassword <string>",
322 "TLS password for HTTPS proxy"},
323 {" --proxy-tlsuser <name>",
324 "TLS username for HTTPS proxy"},
325 {" --proxy-tlsv1",
326 "Use TLSv1 for HTTPS proxy"},
327 {"-U, --proxy-user <user:password>",
328 "Proxy user and password"},
329 {" --proxy1.0 <host[:port]>",
330 "Use HTTP/1.0 proxy on given port"},
331 {"-p, --proxytunnel",
332 "Operate through a HTTP proxy tunnel (using CONNECT)"},
333 {" --pubkey <key>",
334 "SSH Public key file name"},
335 {"-Q, --quote",
336 "Send command(s) to server before transfer"},
337 {" --random-file <file>",
338 "File for reading random data from"},
339 {"-r, --range <range>",
340 "Retrieve only the bytes within RANGE"},
341 {" --raw",
342 "Do HTTP \"raw\"; no transfer decoding"},
343 {"-e, --referer <URL>",
344 "Referrer URL"},
345 {"-J, --remote-header-name",
346 "Use the header-provided filename"},
347 {"-O, --remote-name",
348 "Write output to a file named as the remote file"},
349 {" --remote-name-all",
350 "Use the remote file name for all URLs"},
351 {"-R, --remote-time",
352 "Set the remote file's time on the local output"},
353 {"-X, --request <command>",
354 "Specify request command to use"},
355 {" --resolve <host:port:address>",
356 "Resolve the host+port to this address"},
357 {" --retry <num>",
358 "Retry request if transient problems occur"},
359 {" --retry-connrefused",
360 "Retry on connection refused (use with --retry)"},
361 {" --retry-delay <seconds>",
362 "Wait time between retries"},
363 {" --retry-max-time <seconds>",
364 "Retry only within this period"},
365 {" --sasl-ir",
366 "Enable initial response in SASL authentication"},
367 {" --service-name <name>",
368 "SPNEGO service name"},
369 {"-S, --show-error",
370 "Show error even when -s is used"},
371 {"-s, --silent",
372 "Silent mode"},
373 {" --socks4 <host[:port]>",
374 "SOCKS4 proxy on given host + port"},
375 {" --socks4a <host[:port]>",
376 "SOCKS4a proxy on given host + port"},
377 {" --socks5 <host[:port]>",
378 "SOCKS5 proxy on given host + port"},
379 {" --socks5-gssapi-nec",
380 "Compatibility with NEC SOCKS5 server"},
381 {" --socks5-gssapi-service <name>",
382 "SOCKS5 proxy service name for GSS-API"},
383 {" --socks5-hostname <host[:port]>",
384 "SOCKS5 proxy, pass host name to proxy"},
385 {"-Y, --speed-limit <speed>",
386 "Stop transfers slower than this"},
387 {"-y, --speed-time <seconds>",
388 "Trigger 'speed-limit' abort after this time"},
389 {" --ssl",
390 "Try SSL/TLS"},
391 {" --ssl-allow-beast",
392 "Allow security flaw to improve interop"},
393 {" --ssl-no-revoke",
394 "Disable cert revocation checks (WinSSL)"},
395 {" --ssl-reqd",
396 "Require SSL/TLS"},
397 {"-2, --sslv2",
398 "Use SSLv2"},
399 {"-3, --sslv3",
400 "Use SSLv3"},
401 {" --stderr",
402 "Where to redirect stderr"},
403 {" --suppress-connect-headers",
404 "Suppress proxy CONNECT response headers"},
405 {" --tcp-fastopen",
406 "Use TCP Fast Open"},
407 {" --tcp-nodelay",
408 "Use the TCP_NODELAY option"},
409 {"-t, --telnet-option <opt=val>",
410 "Set telnet option"},
411 {" --tftp-blksize <value>",
412 "Set TFTP BLKSIZE option"},
413 {" --tftp-no-options",
414 "Do not send any TFTP options"},
415 {"-z, --time-cond <time>",
416 "Transfer based on a time condition"},
417 {" --tls-max <VERSION>",
418 "Use TLSv1.0 or greater"},
419 {" --tlsauthtype <type>",
420 "TLS authentication type"},
421 {" --tlspassword",
422 "TLS password"},
423 {" --tlsuser <name>",
424 "TLS user name"},
425 {"-1, --tlsv1",
426 "Use TLSv1.0 or greater"},
427 {" --tlsv1.0",
428 "Use TLSv1.0"},
429 {" --tlsv1.1",
430 "Use TLSv1.1"},
431 {" --tlsv1.2",
432 "Use TLSv1.2"},
433 {" --tlsv1.3",
434 "Use TLSv1.3"},
435 {" --tr-encoding",
436 "Request compressed transfer encoding"},
437 {" --trace <file>",
438 "Write a debug trace to FILE"},
439 {" --trace-ascii <file>",
440 "Like --trace, but without hex output"},
441 {" --trace-time",
442 "Add time stamps to trace/verbose output"},
443 {" --unix-socket <path>",
444 "Connect through this Unix domain socket"},
445 {"-T, --upload-file <file>",
446 "Transfer local FILE to destination"},
447 {" --url <url>",
448 "URL to work with"},
449 {"-B, --use-ascii",
450 "Use ASCII/text transfer"},
451 {"-u, --user <user:password>",
452 "Server user and password"},
453 {"-A, --user-agent <name>",
454 "Send User-Agent <name> to server"},
455 {"-v, --verbose",
456 "Make the operation more talkative"},
457 {"-V, --version",
458 "Show version number and quit"},
459 {"-w, --write-out <format>",
460 "Use output FORMAT after completion"},
461 {" --xattr",
462 "Store metadata in extended file attributes"},
463 { NULL, NULL }
464};
465
466#ifdef NETWARE
467# define PRINT_LINES_PAUSE 23
468#endif
469
470#ifdef __SYMBIAN32__
471# define PRINT_LINES_PAUSE 16
472#endif
473
474struct feat {
475 const char *name;
476 int bitmask;
477};
478
479static const struct feat feats[] = {
480 {"AsynchDNS", CURL_VERSION_ASYNCHDNS},
481 {"Debug", CURL_VERSION_DEBUG},
482 {"TrackMemory", CURL_VERSION_CURLDEBUG},
483 {"IDN", CURL_VERSION_IDN},
484 {"IPv6", CURL_VERSION_IPV6},
485 {"Largefile", CURL_VERSION_LARGEFILE},
486 {"SSPI", CURL_VERSION_SSPI},
487 {"GSS-API", CURL_VERSION_GSSAPI},
488 {"Kerberos", CURL_VERSION_KERBEROS5},
489 {"SPNEGO", CURL_VERSION_SPNEGO},
490 {"NTLM", CURL_VERSION_NTLM},
491 {"NTLM_WB", CURL_VERSION_NTLM_WB},
492 {"SSL", CURL_VERSION_SSL},
493 {"libz", CURL_VERSION_LIBZ},
494 {"CharConv", CURL_VERSION_CONV},
495 {"TLS-SRP", CURL_VERSION_TLSAUTH_SRP},
496 {"HTTP2", CURL_VERSION_HTTP2},
497 {"UnixSockets", CURL_VERSION_UNIX_SOCKETS},
498 {"HTTPS-proxy", CURL_VERSION_HTTPS_PROXY}
499};
500
501void tool_help(void)
502{
503 int i;
504 puts("Usage: curl [options...] <url>");
505 for(i = 0; helptext[i].opt; i++) {
506 printf(" %-19s %s\n", helptext[i].opt, helptext[i].desc);
507#ifdef PRINT_LINES_PAUSE
508 if(i && ((i % PRINT_LINES_PAUSE) == 0))
509 tool_pressanykey();
510#endif
511 }
512}
513
514void tool_version_info(void)
515{
516 const char *const *proto;
517
518 printf(CURL_ID "%s\n", curl_version());
519#ifdef CURL_PATCHSTAMP
520 printf("Release-Date: %s, security patched: %s\n",
521 LIBCURL_TIMESTAMP, CURL_PATCHSTAMP);
522#else
523 printf("Release-Date: %s\n", LIBCURL_TIMESTAMP);
524#endif
525 if(curlinfo->protocols) {
526 printf("Protocols: ");
527 for(proto = curlinfo->protocols; *proto; ++proto) {
528 printf("%s ", *proto);
529 }
530 puts(""); /* newline */
531 }
532 if(curlinfo->features) {
533 unsigned int i;
534 printf("Features: ");
535 for(i = 0; i < sizeof(feats)/sizeof(feats[0]); i++) {
536 if(curlinfo->features & feats[i].bitmask)
537 printf("%s ", feats[i].name);
538 }
539#ifdef USE_METALINK
540 printf("Metalink ");
541#endif
542#ifdef USE_LIBPSL
543 printf("PSL ");
544#endif
545 puts(""); /* newline */
546 }
547}
548
549void tool_list_engines(CURL *curl)
550{
551 struct curl_slist *engines = NULL;
552
553 /* Get the list of engines */
554 curl_easy_getinfo(curl, CURLINFO_SSL_ENGINES, &engines);
555
556 puts("Build-time engines:");
557 if(engines) {
558 for(; engines; engines = engines->next)
559 printf(" %s\n", engines->data);
560 }
561 else {
562 puts(" <none>");
563 }
564
565 /* Cleanup the list of engines */
566 curl_slist_free_all(engines);
567}