1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2013, 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 http://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"
26 #define ENABLE_CURLX_PRINTF
27 /* use our own printf() functions */
31 # include "tool_hugehelp.h"
34 #include "tool_binmode.h"
35 #include "tool_cfgable.h"
36 #include "tool_cb_prg.h"
37 #include "tool_formparse.h"
38 #include "tool_getparam.h"
39 #include "tool_help.h"
40 #include "tool_helpers.h"
41 #include "tool_libinfo.h"
42 #include "tool_metalink.h"
43 #include "tool_msgs.h"
44 #include "tool_paramhlp.h"
45 #include "tool_parsecfg.h"
46 #include "tool_version.h"
48 #include "memdebug.h" /* keep this as LAST include */
54 #define GetStr(str,val) do { \
60 *(str) = strdup((val)); \
62 return PARAM_NO_MEM; \
67 const char *letter; /* short name option */
68 const char *lname; /* long name option */
69 bool extraparam; /* whether it takes an additional argument */
72 static const struct LongShort aliases[]= {
73 /* all these ones, starting with "*" or "$" as a short-option have *no*
74 short option to mention. */
76 {"*4", "dns-ipv4-addr", TRUE},
77 {"*6", "dns-ipv6-addr", TRUE},
78 {"*a", "random-file", TRUE},
79 {"*b", "egd-file", TRUE},
80 {"*B", "bearer", TRUE},
81 {"*c", "connect-timeout", TRUE},
82 {"*d", "ciphers", TRUE},
83 {"*D", "dns-interface", TRUE},
84 {"*e", "disable-epsv", FALSE},
85 {"*E", "epsv", FALSE},
86 /* 'epsv' made like this to make --no-epsv and --epsv to work
87 although --disable-epsv is the documented option */
88 #ifdef USE_ENVIRONMENT
89 {"*f", "environment", FALSE},
91 {"*F", "dns-servers", TRUE},
92 {"*g", "trace", TRUE},
93 {"*h", "trace-ascii", TRUE},
94 {"*i", "limit-rate", TRUE},
95 {"*j", "compressed", FALSE},
96 {"*J", "tr-encoding", FALSE},
97 {"*k", "digest", FALSE},
98 {"*l", "negotiate", FALSE},
99 {"*m", "ntlm", FALSE},
100 {"*M", "ntlm-wb", FALSE},
101 {"*n", "basic", FALSE},
102 {"*o", "anyauth", FALSE},
104 {"*p", "wdebug", FALSE},
106 {"*q", "ftp-create-dirs", FALSE},
107 {"*r", "create-dirs", FALSE},
108 {"*s", "max-redirs", TRUE},
109 {"*t", "proxy-ntlm", FALSE},
110 {"*u", "crlf", FALSE},
111 {"*v", "stderr", TRUE},
112 {"*w", "interface", TRUE},
113 {"*x", "krb" , TRUE},
114 {"*x", "krb4" , TRUE},
115 /* 'krb4' is the previous name */
116 {"*y", "max-filesize", TRUE},
117 {"*z", "disable-eprt", FALSE},
118 {"*Z", "eprt", FALSE},
119 /* 'eprt' made like this to make --no-eprt and --eprt to work
120 although --disable-eprt is the documented option */
121 {"$a", "ftp-ssl", FALSE},
122 /* 'ftp-ssl' deprecated name since 7.20.0 */
123 {"$a", "ssl", FALSE},
124 /* 'ssl' new option name in 7.20.0, previously this was ftp-ssl */
125 {"$b", "ftp-pasv", FALSE},
126 {"$c", "socks5", TRUE},
127 {"$c", "socks", TRUE},
128 /* 'socks' is how the option once was documented but we prefer
129 the --socks5 version for explicit version */
130 {"$d", "tcp-nodelay", FALSE},
131 {"$e", "proxy-digest", FALSE},
132 {"$f", "proxy-basic", FALSE},
133 {"$g", "retry", TRUE},
134 {"$h", "retry-delay", TRUE},
135 {"$i", "retry-max-time", TRUE},
136 {"$k", "proxy-negotiate", FALSE},
137 {"$m", "ftp-account", TRUE},
138 {"$n", "proxy-anyauth", FALSE},
139 {"$o", "trace-time", FALSE},
140 {"$p", "ignore-content-length", FALSE},
141 {"$q", "ftp-skip-pasv-ip", FALSE},
142 {"$r", "ftp-method", TRUE},
143 {"$s", "local-port", TRUE},
144 {"$t", "socks4", TRUE},
145 {"$T", "socks4a", TRUE},
146 {"$u", "ftp-alternative-to-user", TRUE},
147 {"$v", "ftp-ssl-reqd", FALSE},
148 /* 'ftp-ssl-reqd' deprecated name since 7.20.0 */
149 {"$v", "ssl-reqd", FALSE},
150 /* 'ssl-reqd' new in 7.20.0, previously this was ftp-ssl-reqd */
151 {"$w", "sessionid", FALSE},
152 /* ¡sessionid' listed as --no-sessionid in the help */
153 {"$x", "ftp-ssl-control", FALSE},
154 {"$y", "ftp-ssl-ccc", FALSE},
155 {"$j", "ftp-ssl-ccc-mode", TRUE},
156 {"$z", "libcurl", TRUE},
157 {"$#", "raw", FALSE},
158 {"$0", "post301", FALSE},
159 {"$1", "keepalive", FALSE},
160 /* 'keepalive' listed as --no-keepalive in the help */
161 {"$2", "socks5-hostname", TRUE},
162 {"$3", "keepalive-time", TRUE},
163 {"$4", "post302", FALSE},
164 {"$5", "noproxy", TRUE},
165 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
166 {"$6", "socks5-gssapi-service", TRUE},
167 {"$7", "socks5-gssapi-nec", FALSE},
169 {"$8", "proxy1.0", TRUE},
170 {"$9", "tftp-blksize", TRUE},
171 {"$A", "mail-from", TRUE},
172 {"$B", "mail-rcpt", TRUE},
173 {"$C", "ftp-pret", FALSE},
174 {"$D", "proto", TRUE},
175 {"$E", "proto-redir", TRUE},
176 {"$F", "resolve", TRUE},
177 {"$G", "delegation", TRUE},
178 {"$H", "mail-auth", TRUE},
179 {"$I", "post303", FALSE},
180 {"$J", "metalink", FALSE},
181 {"$K", "sasl-ir", FALSE},
182 {"$L", "test-event", FALSE},
183 {"0", "http1.0", FALSE},
184 {"01", "http1.1", FALSE},
185 {"02", "http2.0", FALSE},
186 {"1", "tlsv1", FALSE},
187 {"2", "sslv2", FALSE},
188 {"3", "sslv3", FALSE},
189 {"4", "ipv4", FALSE},
190 {"6", "ipv6", FALSE},
191 {"a", "append", FALSE},
192 {"A", "user-agent", TRUE},
193 {"b", "cookie", TRUE},
194 {"B", "use-ascii", FALSE},
195 {"c", "cookie-jar", TRUE},
196 {"C", "continue-at", TRUE},
198 {"da", "data-ascii", TRUE},
199 {"db", "data-binary", TRUE},
200 {"de", "data-urlencode", TRUE},
201 {"D", "dump-header", TRUE},
202 {"e", "referer", TRUE},
204 {"Ea", "cacert", TRUE},
205 {"Eb", "cert-type", TRUE},
207 {"Ed", "key-type", TRUE},
208 {"Ee", "pass", TRUE},
209 {"Ef", "engine", TRUE},
210 {"Eg", "capath ", TRUE},
211 {"Eh", "pubkey", TRUE},
212 {"Ei", "hostpubmd5", TRUE},
213 {"Ej", "crlfile", TRUE},
214 {"Ek", "tlsuser", TRUE},
215 {"El", "tlspassword", TRUE},
216 {"Em", "tlsauthtype", TRUE},
217 {"En", "ssl-allow-beast", FALSE},
218 {"f", "fail", FALSE},
220 {"Fs", "form-string", TRUE},
221 {"g", "globoff", FALSE},
223 {"h", "help", FALSE},
224 {"H", "header", TRUE},
225 {"i", "include", FALSE},
226 {"I", "head", FALSE},
227 {"j", "junk-session-cookies", FALSE},
228 {"J", "remote-header-name", FALSE},
229 {"k", "insecure", FALSE},
230 {"K", "config", TRUE},
231 {"l", "list-only", FALSE},
232 {"L", "location", FALSE},
233 {"Lt", "location-trusted", FALSE},
234 {"m", "max-time", TRUE},
235 {"M", "manual", FALSE},
236 {"n", "netrc", FALSE},
237 {"no", "netrc-optional", FALSE},
238 {"ne", "netrc-file", TRUE},
239 {"N", "buffer", FALSE},
240 /* 'buffer' listed as --no-buffer in the help */
241 {"o", "output", TRUE},
242 {"O", "remote-name", FALSE},
243 {"Oa", "remote-name-all", FALSE},
244 {"p", "proxytunnel", FALSE},
245 {"P", "ftpport", TRUE},
246 /* 'ftpport' old version */
247 {"P", "ftp-port", TRUE},
248 {"q", "disable", FALSE},
249 {"Q", "quote", TRUE},
250 {"r", "range", TRUE},
251 {"R", "remote-time", FALSE},
252 {"s", "silent", FALSE},
253 {"S", "show-error", FALSE},
254 {"t", "telnet-options", TRUE},
255 /* 'telnet-options' documented as telnet-option */
256 {"T", "upload-file", TRUE},
258 {"U", "proxy-user", TRUE},
259 {"v", "verbose", FALSE},
260 {"V", "version", FALSE},
261 {"w", "write-out", TRUE},
262 {"x", "proxy", TRUE},
263 {"X", "request", TRUE},
264 {"X", "http-request", TRUE},
265 /* 'http-request' OBSOLETE VERSION */
266 {"Y", "speed-limit", TRUE},
267 {"y", "speed-time", TRUE},
268 {"z", "time-cond", TRUE},
269 {"#", "progress-bar", FALSE},
270 {"~", "xattr", FALSE},
278 static const struct feat feats[] = {
279 {"AsynchDNS", CURL_VERSION_ASYNCHDNS},
280 {"Debug", CURL_VERSION_DEBUG},
281 {"TrackMemory", CURL_VERSION_CURLDEBUG},
282 {"GSS-Negotiate", CURL_VERSION_GSSNEGOTIATE},
283 {"IDN", CURL_VERSION_IDN},
284 {"IPv6", CURL_VERSION_IPV6},
285 {"Largefile", CURL_VERSION_LARGEFILE},
286 {"NTLM", CURL_VERSION_NTLM},
287 {"NTLM_WB", CURL_VERSION_NTLM_WB},
288 {"SPNEGO", CURL_VERSION_SPNEGO},
289 {"SSL", CURL_VERSION_SSL},
290 {"SSPI", CURL_VERSION_SSPI},
291 {"krb4", CURL_VERSION_KERBEROS4},
292 {"libz", CURL_VERSION_LIBZ},
293 {"CharConv", CURL_VERSION_CONV},
294 {"TLS-SRP", CURL_VERSION_TLSAUTH_SRP},
295 {"HTTP2", CURL_VERSION_HTTP2}
298 /* Split the argument of -E to 'certname' and 'passphrase' separated by colon.
299 * We allow ':' and '\' to be escaped by '\' so that we can use certificate
300 * nicknames containing ':'. See <https://sourceforge.net/p/curl/bugs/1196/>
305 void parse_cert_parameter(const char *cert_parameter,
309 size_t param_length = strlen(cert_parameter);
311 const char *param_place = NULL;
312 char *certname_place = NULL;
316 /* most trivial assumption: cert_parameter is empty */
317 if(param_length == 0)
320 /* next less trivial: cert_parameter contains no colon nor backslash; this
321 * means no passphrase was given and no characters escaped */
322 if(!strpbrk(cert_parameter, ":\\")) {
323 *certname = strdup(cert_parameter);
326 /* deal with escaped chars; find unescaped colon if it exists */
327 certname_place = malloc(param_length + 1);
331 *certname = certname_place;
332 param_place = cert_parameter;
333 while(*param_place) {
334 span = strcspn(param_place, ":\\");
335 strncpy(certname_place, param_place, span);
337 certname_place += span;
338 /* we just ate all the non-special chars. now we're on either a special
339 * char or the end of the string. */
340 switch(*param_place) {
345 switch(*param_place) {
347 *certname_place++ = '\\';
350 *certname_place++ = '\\';
354 *certname_place++ = ':';
358 *certname_place++ = '\\';
359 *certname_place++ = *param_place;
365 /* Since we live in a world of weirdness and confusion, the win32
366 dudes can use : when using drive letters and thus c:\file:password
367 needs to work. In order not to break compatibility, we still use : as
368 separator, but we try to detect when it is used for a file name! On
372 (param_place == &cert_parameter[1]) &&
373 (cert_parameter[2] == '\\' || cert_parameter[2] == '/') &&
374 (ISALPHA(cert_parameter[0])) ) {
375 /* colon in the second column, followed by a backslash, and the
376 first character is an alphabetic letter:
378 this is a drive letter colon */
379 *certname_place++ = ':';
384 /* escaped colons and Windows drive letter colons were handled
385 * above; if we're still here, this is a separating colon */
387 if(strlen(param_place) > 0) {
388 *passphrase = strdup(param_place);
394 *certname_place = '\0';
397 ParameterError getparameter(char *flag, /* f or -long-flag */
398 char *nextarg, /* NULL if unset */
399 bool *usedarg, /* set to TRUE if the arg
401 struct Configurable *config)
404 char subletter = '\0'; /* subletters can only occur on long options */
406 const char *parse = NULL;
410 bool longopt = FALSE;
411 bool singleopt = FALSE; /* when true means '-o foo' used '-ofoo' */
413 bool toggle = TRUE; /* how to switch boolean options, on or off. Controlled
414 by using --OPTION or --no-OPTION */
417 if(('-' != flag[0]) ||
418 (('-' == flag[0]) && ('-' == flag[1]))) {
419 /* this should be a long name */
420 char *word = ('-' == flag[0]) ? flag+2 : flag;
421 size_t fnam = strlen(word);
424 if(!strncmp(word, "no-", 3)) {
425 /* disable this option but ignore the "no-" part when looking for it */
430 for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) {
431 if(curlx_strnequal(aliases[j].lname, word, fnam)) {
434 if(curlx_raw_equal(aliases[j].lname, word)) {
435 parse = aliases[j].letter;
437 numhits = 1; /* a single unique hit */
440 parse = aliases[j].letter;
445 /* this is at least the second match! */
446 return PARAM_OPTION_AMBIGUOUS;
449 return PARAM_OPTION_UNKNOWN;
453 flag++; /* prefixed with one dash, pass it */
459 /* we can loop here if we have multiple single-letters */
463 letter = (char)*parse;
472 subletter = parse[1];
474 *usedarg = FALSE; /* default is that we don't use the arg */
477 for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) {
478 if(letter == aliases[j].letter[0]) {
484 return PARAM_OPTION_UNKNOWN;
488 if(aliases[hit].extraparam) {
489 /* this option requires an extra parameter */
490 if(!longopt && parse[1]) {
491 nextarg = (char *)&parse[1]; /* this is the actual extra parameter */
492 singleopt = TRUE; /* don't loop anymore after this */
495 return PARAM_REQUIRES_PARAMETER;
497 *usedarg = TRUE; /* mark it as used */
501 case '*': /* options without a short option */
503 case '4': /* --dns-ipv4-addr */
504 /* addr in dot notation */
505 GetStr(&config->dns_ipv4_addr, nextarg);
507 case '6': /* --dns-ipv6-addr */
508 /* addr in dot notation */
509 GetStr(&config->dns_ipv6_addr, nextarg);
511 case 'a': /* random-file */
512 GetStr(&config->random_file, nextarg);
514 case 'b': /* egd-file */
515 GetStr(&config->egd_file, nextarg);
517 case 'B': /* XOAUTH2 Bearer */
518 GetStr(&config->xoauth2_bearer, nextarg);
520 case 'c': /* connect-timeout */
521 err = str2udouble(&config->connecttimeout, nextarg);
525 case 'd': /* ciphers */
526 GetStr(&config->cipher_list, nextarg);
528 case 'D': /* --dns-interface */
530 GetStr(&config->dns_interface, nextarg);
532 case 'e': /* --disable-epsv */
533 config->disable_epsv = toggle;
535 case 'E': /* --epsv */
536 config->disable_epsv = (!toggle)?TRUE:FALSE;
538 #ifdef USE_ENVIRONMENT
540 config->writeenv = toggle;
543 case 'F': /* --dns-servers */
544 /* IP addrs of DNS servers */
545 GetStr(&config->dns_servers, nextarg);
547 case 'g': /* --trace */
548 GetStr(&config->trace_dump, nextarg);
549 if(config->tracetype && (config->tracetype != TRACE_BIN))
550 warnf(config, "--trace overrides an earlier trace/verbose option\n");
551 config->tracetype = TRACE_BIN;
553 case 'h': /* --trace-ascii */
554 GetStr(&config->trace_dump, nextarg);
555 if(config->tracetype && (config->tracetype != TRACE_ASCII))
557 "--trace-ascii overrides an earlier trace/verbose option\n");
558 config->tracetype = TRACE_ASCII;
560 case 'i': /* --limit-rate */
562 /* We support G, M, K too */
564 curl_off_t value = curlx_strtoofft(nextarg, &unit, 0);
568 else if(strlen(unit) > 1)
569 unit = (char *)"w"; /* unsupported */
574 value *= 1024*1024*1024;
586 /* for plain bytes, leave as-is */
589 warnf(config, "unsupported rate unit. Use G, M, K or B!\n");
590 return PARAM_BAD_USE;
592 config->recvpersecond = value;
593 config->sendpersecond = value;
597 case 'j': /* --compressed */
598 if(toggle && !(curlinfo->features & CURL_VERSION_LIBZ))
599 return PARAM_LIBCURL_DOESNT_SUPPORT;
600 config->encoding = toggle;
603 case 'J': /* --tr-encoding */
604 config->tr_encoding = toggle;
607 case 'k': /* --digest */
609 config->authtype |= CURLAUTH_DIGEST;
611 config->authtype &= ~CURLAUTH_DIGEST;
614 case 'l': /* --negotiate */
616 if(curlinfo->features & CURL_VERSION_GSSNEGOTIATE)
617 config->authtype |= CURLAUTH_GSSNEGOTIATE;
619 return PARAM_LIBCURL_DOESNT_SUPPORT;
622 config->authtype &= ~CURLAUTH_GSSNEGOTIATE;
625 case 'm': /* --ntlm */
627 if(curlinfo->features & CURL_VERSION_NTLM)
628 config->authtype |= CURLAUTH_NTLM;
630 return PARAM_LIBCURL_DOESNT_SUPPORT;
633 config->authtype &= ~CURLAUTH_NTLM;
636 case 'M': /* --ntlm-wb */
638 if(curlinfo->features & CURL_VERSION_NTLM_WB)
639 config->authtype |= CURLAUTH_NTLM_WB;
641 return PARAM_LIBCURL_DOESNT_SUPPORT;
644 config->authtype &= ~CURLAUTH_NTLM_WB;
647 case 'n': /* --basic for completeness */
649 config->authtype |= CURLAUTH_BASIC;
651 config->authtype &= ~CURLAUTH_BASIC;
654 case 'o': /* --anyauth, let libcurl pick it */
656 config->authtype = CURLAUTH_ANY;
657 /* --no-anyauth simply doesn't touch it */
661 case 'p': /* --wdebug */
665 case 'q': /* --ftp-create-dirs */
666 config->ftp_create_dirs = toggle;
669 case 'r': /* --create-dirs */
670 config->create_dirs = toggle;
673 case 's': /* --max-redirs */
674 /* specified max no of redirects (http(s)), this accepts -1 as a
676 err = str2num(&config->maxredirs, nextarg);
679 if(config->maxredirs < -1)
680 return PARAM_BAD_NUMERIC;
683 case 't': /* --proxy-ntlm */
684 if(curlinfo->features & CURL_VERSION_NTLM)
685 config->proxyntlm = toggle;
687 return PARAM_LIBCURL_DOESNT_SUPPORT;
690 case 'u': /* --crlf */
691 /* LF -> CRLF conversion? */
692 config->crlf = toggle;
695 case 'v': /* --stderr */
696 if(strcmp(nextarg, "-")) {
697 FILE *newfile = fopen(nextarg, "wt");
699 warnf(config, "Failed to open %s!\n", nextarg);
701 if(config->errors_fopened)
702 fclose(config->errors);
703 config->errors = newfile;
704 config->errors_fopened = TRUE;
708 config->errors = stdout;
710 case 'w': /* --interface */
712 GetStr(&config->iface, nextarg);
714 case 'x': /* --krb */
715 /* kerberos level string */
716 if(curlinfo->features & (CURL_VERSION_KERBEROS4 |
717 CURL_VERSION_GSSNEGOTIATE))
718 GetStr(&config->krblevel, nextarg);
720 return PARAM_LIBCURL_DOESNT_SUPPORT;
722 case 'y': /* --max-filesize */
723 err = str2offset(&config->max_filesize, nextarg);
727 case 'z': /* --disable-eprt */
728 config->disable_eprt = toggle;
730 case 'Z': /* --eprt */
731 config->disable_eprt = (!toggle)?TRUE:FALSE;
734 default: /* the URL! */
737 if(config->url_get || ((config->url_get = config->url_list) != NULL)) {
738 /* there's a node here, if it already is filled-in continue to find
740 while(config->url_get && (config->url_get->flags & GETOUT_URL))
741 config->url_get = config->url_get->next;
744 /* now there might or might not be an available node to fill in! */
748 url = config->url_get;
750 /* there was no free node, create one! */
751 url = new_getout(config);
756 /* fill in the URL */
757 GetStr(&url->url, nextarg);
758 url->flags |= GETOUT_URL;
763 case '$': /* more options without a short option */
765 case 'a': /* --ftp-ssl */
766 if(toggle && !(curlinfo->features & CURL_VERSION_SSL))
767 return PARAM_LIBCURL_DOESNT_SUPPORT;
768 config->ftp_ssl = toggle;
770 case 'b': /* --ftp-pasv */
771 Curl_safefree(config->ftpport);
773 case 'c': /* --socks5 specifies a socks5 proxy to use, and resolves
774 the name locally and passes on the resolved address */
775 GetStr(&config->socksproxy, nextarg);
776 config->socksver = CURLPROXY_SOCKS5;
778 case 't': /* --socks4 specifies a socks4 proxy to use */
779 GetStr(&config->socksproxy, nextarg);
780 config->socksver = CURLPROXY_SOCKS4;
782 case 'T': /* --socks4a specifies a socks4a proxy to use */
783 GetStr(&config->socksproxy, nextarg);
784 config->socksver = CURLPROXY_SOCKS4A;
786 case '2': /* --socks5-hostname specifies a socks5 proxy and enables name
787 resolving with the proxy */
788 GetStr(&config->socksproxy, nextarg);
789 config->socksver = CURLPROXY_SOCKS5_HOSTNAME;
791 case 'd': /* --tcp-nodelay option */
792 config->tcp_nodelay = toggle;
794 case 'e': /* --proxy-digest */
795 config->proxydigest = toggle;
797 case 'f': /* --proxy-basic */
798 config->proxybasic = toggle;
800 case 'g': /* --retry */
801 err = str2unum(&config->req_retry, nextarg);
805 case 'h': /* --retry-delay */
806 err = str2unum(&config->retry_delay, nextarg);
810 case 'i': /* --retry-max-time */
811 err = str2unum(&config->retry_maxtime, nextarg);
816 case 'k': /* --proxy-negotiate */
817 if(curlinfo->features & CURL_VERSION_GSSNEGOTIATE)
818 config->proxynegotiate = toggle;
820 return PARAM_LIBCURL_DOESNT_SUPPORT;
822 case 'm': /* --ftp-account */
823 GetStr(&config->ftp_account, nextarg);
825 case 'n': /* --proxy-anyauth */
826 config->proxyanyauth = toggle;
828 case 'o': /* --trace-time */
829 config->tracetime = toggle;
831 case 'p': /* --ignore-content-length */
832 config->ignorecl = toggle;
834 case 'q': /* --ftp-skip-pasv-ip */
835 config->ftp_skip_ip = toggle;
837 case 'r': /* --ftp-method (undocumented at this point) */
838 config->ftp_filemethod = ftpfilemethod(config, nextarg);
840 case 's': /* --local-port */
841 rc = sscanf(nextarg, "%d - %d",
843 &config->localportrange);
845 return PARAM_BAD_USE;
847 config->localportrange = 1; /* default number of ports to try */
849 config->localportrange -= config->localport;
850 if(config->localportrange < 1) {
851 warnf(config, "bad range input\n");
852 return PARAM_BAD_USE;
856 case 'u': /* --ftp-alternative-to-user */
857 GetStr(&config->ftp_alternative_to_user, nextarg);
859 case 'v': /* --ftp-ssl-reqd */
860 if(toggle && !(curlinfo->features & CURL_VERSION_SSL))
861 return PARAM_LIBCURL_DOESNT_SUPPORT;
862 config->ftp_ssl_reqd = toggle;
864 case 'w': /* --no-sessionid */
865 config->disable_sessionid = (!toggle)?TRUE:FALSE;
867 case 'x': /* --ftp-ssl-control */
868 if(toggle && !(curlinfo->features & CURL_VERSION_SSL))
869 return PARAM_LIBCURL_DOESNT_SUPPORT;
870 config->ftp_ssl_control = toggle;
872 case 'y': /* --ftp-ssl-ccc */
873 config->ftp_ssl_ccc = toggle;
874 if(!config->ftp_ssl_ccc_mode)
875 config->ftp_ssl_ccc_mode = CURLFTPSSL_CCC_PASSIVE;
877 case 'j': /* --ftp-ssl-ccc-mode */
878 config->ftp_ssl_ccc = TRUE;
879 config->ftp_ssl_ccc_mode = ftpcccmethod(config, nextarg);
881 case 'z': /* --libcurl */
882 #ifdef CURL_DISABLE_LIBCURL_OPTION
884 "--libcurl option was disabled at build-time!\n");
885 return PARAM_OPTION_UNKNOWN;
887 GetStr(&config->libcurl, nextarg);
890 case '#': /* --raw */
891 config->raw = toggle;
893 case '0': /* --post301 */
894 config->post301 = toggle;
896 case '1': /* --no-keepalive */
897 config->nokeepalive = (!toggle)?TRUE:FALSE;
899 case '3': /* --keepalive-time */
900 err = str2unum(&config->alivetime, nextarg);
904 case '4': /* --post302 */
905 config->post302 = toggle;
907 case 'I': /* --post303 */
908 config->post303 = toggle;
910 case '5': /* --noproxy */
911 /* This specifies the noproxy list */
912 GetStr(&config->noproxy, nextarg);
914 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
915 case '6': /* --socks5-gssapi-service */
916 GetStr(&config->socks5_gssapi_service, nextarg);
918 case '7': /* --socks5-gssapi-nec*/
919 config->socks5_gssapi_nec = toggle;
922 case '8': /* --proxy1.0 */
924 GetStr(&config->proxy, nextarg);
925 config->proxyver = CURLPROXY_HTTP_1_0;
927 case '9': /* --tftp-blksize */
928 err = str2unum(&config->tftp_blksize, nextarg);
932 case 'A': /* --mail-from */
933 GetStr(&config->mail_from, nextarg);
935 case 'B': /* --mail-rcpt */
936 /* append receiver to a list */
937 err = add2list(&config->mail_rcpt, nextarg);
941 case 'C': /* --ftp-pret */
942 config->ftp_pret = toggle;
944 case 'D': /* --proto */
945 config->proto_present = TRUE;
946 if(proto2num(config, &config->proto, nextarg))
947 return PARAM_BAD_USE;
949 case 'E': /* --proto-redir */
950 config->proto_redir_present = TRUE;
951 if(proto2num(config, &config->proto_redir, nextarg))
952 return PARAM_BAD_USE;
954 case 'F': /* --resolve */
955 err = add2list(&config->resolve, nextarg);
959 case 'G': /* --delegation LEVEL */
960 config->gssapi_delegation = delegation(config, nextarg);
962 case 'H': /* --mail-auth */
963 GetStr(&config->mail_auth, nextarg);
965 case 'J': /* --metalink */
968 int mlmaj, mlmin, mlpatch;
969 metalink_get_version(&mlmaj, &mlmin, &mlpatch);
970 if((mlmaj*10000)+(mlmin*100)+mlpatch < CURL_REQ_LIBMETALINK_VERS) {
972 "--metalink option cannot be used because the version of "
973 "the linked libmetalink library is too old. "
974 "Required: %d.%d.%d, found %d.%d.%d\n",
975 CURL_REQ_LIBMETALINK_MAJOR,
976 CURL_REQ_LIBMETALINK_MINOR,
977 CURL_REQ_LIBMETALINK_PATCH,
978 mlmaj, mlmin, mlpatch);
979 return PARAM_BAD_USE;
982 config->use_metalink = toggle;
984 warnf(config, "--metalink option is ignored because the binary is "
985 "built without the Metalink support.\n");
989 case 'K': /* --sasl-ir */
990 config->sasl_ir = toggle;
992 case 'L': /* --test-event */
994 config->test_event_based = toggle;
996 warnf(config, "--test-event is ignored unless a debug build!\n");
1001 case '#': /* --progress-bar */
1003 config->progressmode = CURL_PROGRESS_BAR;
1005 config->progressmode = CURL_PROGRESS_STATS;
1007 case '~': /* --xattr */
1008 config->xattr = toggle;
1010 case '0': /* --http* options */
1013 /* HTTP version 1.0 */
1014 config->httpversion = CURL_HTTP_VERSION_1_0;
1017 /* HTTP version 1.1 */
1018 config->httpversion = CURL_HTTP_VERSION_1_1;
1021 /* HTTP version 2.0 */
1022 config->httpversion = CURL_HTTP_VERSION_2_0;
1028 config->ssl_version = CURL_SSLVERSION_TLSv1;
1032 config->ssl_version = CURL_SSLVERSION_SSLv2;
1036 config->ssl_version = CURL_SSLVERSION_SSLv3;
1040 config->ip_version = 4;
1044 config->ip_version = 6;
1047 /* This makes the FTP sessions use APPE instead of STOR */
1048 config->ftp_append = toggle;
1051 /* This specifies the User-Agent name */
1052 GetStr(&config->useragent, nextarg);
1054 case 'b': /* cookie string coming up: */
1055 if(nextarg[0] == '@') {
1058 else if(strchr(nextarg, '=')) {
1059 /* A cookie string must have a =-letter */
1060 GetStr(&config->cookie, nextarg);
1063 /* We have a cookie file to read from! */
1064 GetStr(&config->cookiefile, nextarg);
1067 /* use ASCII/text when transferring */
1068 config->use_ascii = toggle;
1071 /* get the file name to dump all cookies in */
1072 GetStr(&config->cookiejar, nextarg);
1075 /* This makes us continue an ftp transfer at given position */
1076 if(!curlx_strequal(nextarg, "-")) {
1077 err = str2offset(&config->resume_from, nextarg);
1080 config->resume_from_current = FALSE;
1083 config->resume_from_current = TRUE;
1084 config->resume_from = 0;
1086 config->use_resume=TRUE;
1089 /* postfield data */
1091 char *postdata = NULL;
1095 if(subletter == 'e') { /* --data-urlencode*/
1096 /* [name]=[content], we encode the content part only
1097 * [name]@[file name]
1099 * Case 2: we first load the file using that name and then encode
1102 const char *p = strchr(nextarg, '=');
1106 /* there was no '=' letter, check for a '@' instead */
1107 p = strchr(nextarg, '@');
1109 nlen = p - nextarg; /* length of the name part */
1110 is_file = *p++; /* pass the separator */
1113 /* neither @ nor =, so no name and it isn't a file */
1117 if('@' == is_file) {
1118 /* a '@' letter, it means that a file name or - (stdin) follows */
1120 if(curlx_strequal("-", p)) {
1125 file = fopen(p, "rb");
1128 "Couldn't read data from file \"%s\", this makes "
1129 "an empty POST.\n", nextarg);
1132 err = file2memory(&postdata, &size, file);
1134 if(file && (file != stdin))
1140 GetStr(&postdata, p);
1142 size = strlen(postdata);
1146 /* no data from the file, point to a zero byte string to make this
1147 get sent as a POST anyway */
1148 postdata = strdup("");
1150 return PARAM_NO_MEM;
1154 char *enc = curl_easy_escape(config->easy, postdata, (int)size);
1155 Curl_safefree(postdata); /* no matter if it worked or not */
1157 /* now make a string with the name from above and append the
1159 size_t outlen = nlen + strlen(enc) + 2;
1160 char *n = malloc(outlen);
1163 return PARAM_NO_MEM;
1165 if(nlen > 0) { /* only append '=' if we have a name */
1166 snprintf(n, outlen, "%.*s=%s", nlen, nextarg, enc);
1171 size = outlen-2; /* since no '=' was inserted */
1177 return PARAM_NO_MEM;
1180 else if('@' == *nextarg) {
1181 /* the data begins with a '@' letter, it means that a file name
1182 or - (stdin) follows */
1183 nextarg++; /* pass the @ */
1185 if(curlx_strequal("-", nextarg)) {
1187 if(subletter == 'b') /* forced data-binary */
1191 file = fopen(nextarg, "rb");
1193 warnf(config, "Couldn't read data from file \"%s\", this makes "
1194 "an empty POST.\n", nextarg);
1197 if(subletter == 'b')
1199 err = file2memory(&postdata, &size, file);
1201 err = file2string(&postdata, file);
1203 size = strlen(postdata);
1206 if(file && (file != stdin))
1212 /* no data from the file, point to a zero byte string to make this
1213 get sent as a POST anyway */
1214 postdata = strdup("");
1216 return PARAM_NO_MEM;
1220 GetStr(&postdata, nextarg);
1222 size = strlen(postdata);
1225 #ifdef CURL_DOES_CONVERSIONS
1226 if(subletter != 'b') {
1227 /* NOT forced binary, convert to ASCII */
1228 if(convert_to_network(postdata, strlen(postdata))) {
1229 Curl_safefree(postdata);
1230 return PARAM_NO_MEM;
1235 if(config->postfields) {
1236 /* we already have a string, we append this one with a separating
1238 char *oldpost = config->postfields;
1239 curl_off_t oldlen = config->postfieldsize;
1240 curl_off_t newlen = oldlen + size + 2;
1241 config->postfields = malloc((size_t)newlen);
1242 if(!config->postfields) {
1243 Curl_safefree(oldpost);
1244 Curl_safefree(postdata);
1245 return PARAM_NO_MEM;
1247 memcpy(config->postfields, oldpost, (size_t)oldlen);
1248 /* use byte value 0x26 for '&' to accommodate non-ASCII platforms */
1249 config->postfields[oldlen] = '\x26';
1250 memcpy(&config->postfields[oldlen+1], postdata, size);
1251 config->postfields[oldlen+1+size] = '\0';
1252 Curl_safefree(oldpost);
1253 Curl_safefree(postdata);
1254 config->postfieldsize += size+1;
1257 config->postfields = postdata;
1258 config->postfieldsize = size;
1262 We can't set the request type here, as this data might be used in
1263 a simple GET if -G is used. Already or soon.
1265 if(SetHTTPrequest(HTTPREQ_SIMPLEPOST, &config->httpreq)) {
1266 Curl_safefree(postdata);
1267 return PARAM_BAD_USE;
1272 /* dump-header to given file name */
1273 GetStr(&config->headerfile, nextarg);
1277 char *ptr = strstr(nextarg, ";auto");
1279 /* Automatic referer requested, this may be combined with a
1281 config->autoreferer = TRUE;
1282 *ptr = 0; /* zero terminate here */
1285 config->autoreferer = FALSE;
1286 GetStr(&config->referer, nextarg);
1291 case 'a': /* CA info PEM file */
1292 /* CA info PEM file */
1293 GetStr(&config->cacert, nextarg);
1295 case 'b': /* cert file type */
1296 GetStr(&config->cert_type, nextarg);
1298 case 'c': /* private key file */
1299 GetStr(&config->key, nextarg);
1301 case 'd': /* private key file type */
1302 GetStr(&config->key_type, nextarg);
1304 case 'e': /* private key passphrase */
1305 GetStr(&config->key_passwd, nextarg);
1308 case 'f': /* crypto engine */
1309 GetStr(&config->engine, nextarg);
1310 if(config->engine && curlx_raw_equal(config->engine,"list"))
1311 config->list_engines = TRUE;
1313 case 'g': /* CA info PEM file */
1314 /* CA cert directory */
1315 GetStr(&config->capath, nextarg);
1317 case 'h': /* --pubkey public key file */
1318 GetStr(&config->pubkey, nextarg);
1320 case 'i': /* --hostpubmd5 md5 of the host public key */
1321 GetStr(&config->hostpubmd5, nextarg);
1322 if(!config->hostpubmd5 || strlen(config->hostpubmd5) != 32)
1323 return PARAM_BAD_USE;
1325 case 'j': /* CRL info PEM file */
1327 GetStr(&config->crlfile, nextarg);
1329 case 'k': /* TLS username */
1330 if(curlinfo->features & CURL_VERSION_TLSAUTH_SRP)
1331 GetStr(&config->tls_username, nextarg);
1333 return PARAM_LIBCURL_DOESNT_SUPPORT;
1335 case 'l': /* TLS password */
1336 if(curlinfo->features & CURL_VERSION_TLSAUTH_SRP)
1337 GetStr(&config->tls_password, nextarg);
1339 return PARAM_LIBCURL_DOESNT_SUPPORT;
1341 case 'm': /* TLS authentication type */
1342 if(curlinfo->features & CURL_VERSION_TLSAUTH_SRP) {
1343 GetStr(&config->tls_authtype, nextarg);
1344 if(!strequal(config->tls_authtype, "SRP"))
1345 return PARAM_LIBCURL_DOESNT_SUPPORT; /* only support TLS-SRP */
1348 return PARAM_LIBCURL_DOESNT_SUPPORT;
1350 case 'n': /* no empty SSL fragments */
1351 if(curlinfo->features & CURL_VERSION_SSL)
1352 config->ssl_allow_beast = toggle;
1354 default: /* certificate file */
1356 char *certname, *passphrase;
1357 parse_cert_parameter(nextarg, &certname, &passphrase);
1358 Curl_safefree(config->cert);
1359 config->cert = certname;
1361 Curl_safefree(config->key_passwd);
1362 config->key_passwd = passphrase;
1369 /* fail hard on errors */
1370 config->failonerror = toggle;
1373 /* "form data" simulation, this is a little advanced so lets do our best
1374 to sort this out slowly and carefully */
1375 if(formparse(config,
1379 (subletter=='s')?TRUE:FALSE)) /* 's' means literal string */
1380 return PARAM_BAD_USE;
1381 if(SetHTTPrequest(config, HTTPREQ_POST, &config->httpreq))
1382 return PARAM_BAD_USE;
1385 case 'g': /* g disables URLglobbing */
1386 config->globoff = toggle;
1389 case 'G': /* HTTP GET */
1390 config->use_httpget = TRUE;
1393 case 'h': /* h for help */
1396 return PARAM_HELP_REQUESTED;
1398 /* we now actually support --no-help too! */
1401 /* A custom header to append to a list */
1402 err = add2list(&config->headers, nextarg);
1407 config->include_headers = toggle; /* include the headers as well in the
1408 general output stream */
1411 config->cookiesession = toggle;
1415 * no_body will imply include_headers later on
1417 config->no_body = toggle;
1418 if(SetHTTPrequest(config,
1419 (config->no_body)?HTTPREQ_HEAD:HTTPREQ_GET,
1421 return PARAM_BAD_USE;
1423 case 'J': /* --remote-header-name */
1424 if(config->include_headers) {
1426 "--include and --remote-header-name cannot be combined.\n");
1427 return PARAM_BAD_USE;
1429 config->content_disposition = toggle;
1431 case 'k': /* allow insecure SSL connects */
1432 config->insecure_ok = toggle;
1434 case 'K': /* parse config file */
1435 if(parseconfig(nextarg, config))
1436 warnf(config, "error trying read config from the '%s' file\n",
1440 config->dirlistonly = toggle; /* only list the names of the FTP dir */
1443 config->followlocation = toggle; /* Follow Location: HTTP headers */
1444 switch (subletter) {
1446 /* Continue to send authentication (user+password) when following
1447 * locations, even when hostname changed */
1448 config->unrestricted_auth = toggle;
1453 /* specified max time */
1454 err = str2udouble(&config->timeout, nextarg);
1458 case 'M': /* M for manual, huge help */
1459 if(toggle) { /* --no-manual shows no manual... */
1462 return PARAM_HELP_REQUESTED;
1465 "built-in manual was disabled at build-time!\n");
1466 return PARAM_OPTION_UNKNOWN;
1472 case 'o': /* CA info PEM file */
1473 /* use .netrc or URL */
1474 config->netrc_opt = toggle;
1476 case 'e': /* netrc-file */
1477 GetStr(&config->netrc_file, nextarg);
1480 /* pick info from .netrc, if this is used for http, curl will
1481 automatically enfore user+password with the request */
1482 config->netrc = toggle;
1487 /* disable the output I/O buffering. note that the option is called
1488 --buffer but is mostly used in the negative form: --no-buffer */
1490 config->nobuffer = (!toggle)?TRUE:FALSE;
1492 config->nobuffer = toggle;
1494 case 'O': /* --remote-name */
1495 if(subletter == 'a') { /* --remote-name-all */
1496 config->default_node_flags = toggle?GETOUT_USEREMOTE:0;
1500 case 'o': /* --output */
1504 if(config->url_out || ((config->url_out = config->url_list) != NULL)) {
1505 /* there's a node here, if it already is filled-in continue to find
1507 while(config->url_out && (config->url_out->flags & GETOUT_OUTFILE))
1508 config->url_out = config->url_out->next;
1511 /* now there might or might not be an available node to fill in! */
1515 url = config->url_out;
1517 /* there was no free node, create one! */
1518 url = new_getout(config);
1521 return PARAM_NO_MEM;
1523 /* fill in the outfile */
1525 GetStr(&url->outfile, nextarg);
1526 url->flags &= ~GETOUT_USEREMOTE; /* switch off */
1529 url->outfile = NULL; /* leave it */
1531 url->flags |= GETOUT_USEREMOTE; /* switch on */
1533 url->flags &= ~GETOUT_USEREMOTE; /* switch off */
1535 url->flags |= GETOUT_OUTFILE;
1540 /* This makes the FTP sessions use PORT instead of PASV */
1541 /* use <eth0> or <192.168.10.10> style addresses. Anything except
1542 this will make us try to get the "default" address.
1543 NOTE: this is a changed behaviour since the released 4.1!
1545 GetStr(&config->ftpport, nextarg);
1548 /* proxy tunnel for non-http protocols */
1549 config->proxytunnel = toggle;
1552 case 'q': /* if used first, already taken care of, we do it like
1553 this so we don't cause an error! */
1556 /* QUOTE command to send to FTP server */
1557 switch(nextarg[0]) {
1559 /* prefixed with a dash makes it a POST TRANSFER one */
1561 err = add2list(&config->postquote, nextarg);
1564 /* prefixed with a plus makes it a just-before-transfer one */
1566 err = add2list(&config->prequote, nextarg);
1569 err = add2list(&config->quote, nextarg);
1576 /* Specifying a range WITHOUT A DASH will create an illegal HTTP range
1577 (and won't actually be range by definition). The man page previously
1578 claimed that to be a good way, why this code is added to work-around
1580 if(ISDIGIT(*nextarg) && !strchr(nextarg, '-')) {
1584 "A specified range MUST include at least one dash (-). "
1585 "Appending one for you!\n");
1586 off = curlx_strtoofft(nextarg, NULL, 10);
1587 snprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-", off);
1588 Curl_safefree(config->range);
1589 config->range = strdup(buffer);
1591 return PARAM_NO_MEM;
1594 /* byte range requested */
1596 tmp_range = nextarg;
1597 while(*tmp_range != '\0') {
1598 if(!ISDIGIT(*tmp_range) && *tmp_range != '-' && *tmp_range != ',') {
1599 warnf(config,"Invalid character is found in given range. "
1600 "A specified range MUST have only digits in "
1601 "\'start\'-\'stop\'. The server's response to this "
1602 "request is uncertain.\n");
1607 /* byte range requested */
1608 GetStr(&config->range, nextarg);
1612 /* use remote file's time */
1613 config->remote_time = toggle;
1616 /* don't show progress meter, don't show errors : */
1618 config->mute = config->noprogress = TRUE;
1620 config->mute = config->noprogress = FALSE;
1621 if(config->showerror < 0)
1622 /* if still on the default value, set showerror to the reverse of
1623 toggle. This is to allow -S and -s to be used in an independent
1624 order but still have the same effect. */
1625 config->showerror = (!toggle)?TRUE:FALSE; /* toggle off */
1629 config->showerror = toggle?1:0; /* toggle on if used with -s */
1632 /* Telnet options */
1633 err = add2list(&config->telnet_options, nextarg);
1638 /* we are uploading */
1641 if(config->url_out || ((config->url_out = config->url_list) != NULL)) {
1642 /* there's a node here, if it already is filled-in continue to find
1644 while(config->url_out && (config->url_out->flags & GETOUT_UPLOAD))
1645 config->url_out = config->url_out->next;
1648 /* now there might or might not be an available node to fill in! */
1652 url = config->url_out;
1654 /* there was no free node, create one! */
1655 url = new_getout(config);
1658 return PARAM_NO_MEM;
1660 url->flags |= GETOUT_UPLOAD; /* mark -T used */
1662 url->flags |= GETOUT_NOUPLOAD;
1664 /* "-" equals stdin, but keep the string around for now */
1665 GetStr(&url->infile, nextarg);
1671 /* user:password;options */
1672 GetStr(&config->userpwd, nextarg);
1676 /* Proxy user:password */
1677 GetStr(&config->proxyuserpwd, nextarg);
1682 /* the '%' thing here will cause the trace get sent to stderr */
1683 Curl_safefree(config->trace_dump);
1684 config->trace_dump = strdup("%");
1685 if(!config->trace_dump)
1686 return PARAM_NO_MEM;
1687 if(config->tracetype && (config->tracetype != TRACE_PLAIN))
1689 "-v, --verbose overrides an earlier trace/verbose option\n");
1690 config->tracetype = TRACE_PLAIN;
1693 /* verbose is disabled here */
1694 config->tracetype = TRACE_NONE;
1698 const char *const *proto;
1701 /* --no-version yields no output! */
1704 printf(CURL_ID "%s\n", curl_version());
1705 if(curlinfo->protocols) {
1706 printf("Protocols: ");
1707 for(proto = curlinfo->protocols; *proto; ++proto) {
1708 printf("%s ", *proto);
1710 puts(""); /* newline */
1712 if(curlinfo->features) {
1714 printf("Features: ");
1715 for(i = 0; i < sizeof(feats)/sizeof(feats[0]); i++) {
1716 if(curlinfo->features & feats[i].bitmask)
1717 printf("%s ", feats[i].name);
1720 printf("Metalink ");
1722 puts(""); /* newline */
1725 return PARAM_HELP_REQUESTED;
1727 /* get the output string */
1728 if('@' == *nextarg) {
1729 /* the data begins with a '@' letter, it means that a file name
1730 or - (stdin) follows */
1733 nextarg++; /* pass the @ */
1734 if(curlx_strequal("-", nextarg)) {
1740 file = fopen(nextarg, "r");
1742 err = file2string(&config->writeout, file);
1743 if(file && (file != stdin))
1747 if(!config->writeout)
1748 warnf(config, "Failed to read %s", fname);
1751 GetStr(&config->writeout, nextarg);
1755 GetStr(&config->proxy, nextarg);
1756 config->proxyver = CURLPROXY_HTTP;
1759 /* set custom request */
1760 GetStr(&config->customrequest, nextarg);
1763 /* low speed time */
1764 err = str2unum(&config->low_speed_time, nextarg);
1767 if(!config->low_speed_limit)
1768 config->low_speed_limit = 1;
1771 /* low speed limit */
1772 err = str2unum(&config->low_speed_limit, nextarg);
1775 if(!config->low_speed_time)
1776 config->low_speed_time = 30;
1778 case 'z': /* time condition coming up */
1783 /* If-Modified-Since: (section 14.28 in RFC2068) */
1784 config->timecond = CURL_TIMECOND_IFMODSINCE;
1787 /* If-Unmodified-Since: (section 14.24 in RFC2068) */
1788 config->timecond = CURL_TIMECOND_IFUNMODSINCE;
1792 /* Last-Modified: (section 14.29 in RFC2068) */
1793 config->timecond = CURL_TIMECOND_LASTMOD;
1798 config->condtime=curl_getdate(nextarg, &now);
1799 if(-1 == (int)config->condtime) {
1800 /* now let's see if it is a file name to get the time from instead! */
1801 struct_stat statbuf;
1802 if(-1 == stat(nextarg, &statbuf)) {
1803 /* failed, remove time condition */
1804 config->timecond = CURL_TIMECOND_NONE;
1806 "Illegal date format for -z, --timecond (and not "
1807 "a file name). Disabling time condition. "
1808 "See curl_getdate(3) for valid date syntax.\n");
1811 /* pull the time out from the file */
1812 config->condtime = statbuf.st_mtime;
1816 default: /* unknown flag */
1817 return PARAM_OPTION_UNKNOWN;
1821 } while(!longopt && !singleopt && *++parse && !*usedarg);