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", "oauth2-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 {"10", "tlsv1.0", FALSE},
188 {"11", "tlsv1.1", FALSE},
189 {"12", "tlsv1.2", FALSE},
190 {"2", "sslv2", FALSE},
191 {"3", "sslv3", FALSE},
192 {"4", "ipv4", FALSE},
193 {"6", "ipv6", FALSE},
194 {"a", "append", FALSE},
195 {"A", "user-agent", TRUE},
196 {"b", "cookie", TRUE},
197 {"B", "use-ascii", FALSE},
198 {"c", "cookie-jar", TRUE},
199 {"C", "continue-at", TRUE},
201 {"da", "data-ascii", TRUE},
202 {"db", "data-binary", TRUE},
203 {"de", "data-urlencode", TRUE},
204 {"D", "dump-header", TRUE},
205 {"e", "referer", TRUE},
207 {"Ea", "cacert", TRUE},
208 {"Eb", "cert-type", TRUE},
210 {"Ed", "key-type", TRUE},
211 {"Ee", "pass", TRUE},
212 {"Ef", "engine", TRUE},
213 {"Eg", "capath ", TRUE},
214 {"Eh", "pubkey", TRUE},
215 {"Ei", "hostpubmd5", TRUE},
216 {"Ej", "crlfile", TRUE},
217 {"Ek", "tlsuser", TRUE},
218 {"El", "tlspassword", TRUE},
219 {"Em", "tlsauthtype", TRUE},
220 {"En", "ssl-allow-beast", FALSE},
221 {"Eo", "login-options", TRUE},
222 {"f", "fail", FALSE},
224 {"Fs", "form-string", TRUE},
225 {"g", "globoff", FALSE},
227 {"h", "help", FALSE},
228 {"H", "header", TRUE},
229 {"i", "include", FALSE},
230 {"I", "head", FALSE},
231 {"j", "junk-session-cookies", FALSE},
232 {"J", "remote-header-name", FALSE},
233 {"k", "insecure", FALSE},
234 {"K", "config", TRUE},
235 {"l", "list-only", FALSE},
236 {"L", "location", FALSE},
237 {"Lt", "location-trusted", FALSE},
238 {"m", "max-time", TRUE},
239 {"M", "manual", FALSE},
240 {"n", "netrc", FALSE},
241 {"no", "netrc-optional", FALSE},
242 {"ne", "netrc-file", TRUE},
243 {"N", "buffer", FALSE},
244 /* 'buffer' listed as --no-buffer in the help */
245 {"o", "output", TRUE},
246 {"O", "remote-name", FALSE},
247 {"Oa", "remote-name-all", FALSE},
248 {"p", "proxytunnel", FALSE},
249 {"P", "ftpport", TRUE},
250 /* 'ftpport' old version */
251 {"P", "ftp-port", TRUE},
252 {"q", "disable", FALSE},
253 {"Q", "quote", TRUE},
254 {"r", "range", TRUE},
255 {"R", "remote-time", FALSE},
256 {"s", "silent", FALSE},
257 {"S", "show-error", FALSE},
258 {"t", "telnet-options", TRUE},
259 /* 'telnet-options' documented as telnet-option */
260 {"T", "upload-file", TRUE},
262 {"U", "proxy-user", TRUE},
263 {"v", "verbose", FALSE},
264 {"V", "version", FALSE},
265 {"w", "write-out", TRUE},
266 {"x", "proxy", TRUE},
267 {"X", "request", TRUE},
268 {"X", "http-request", TRUE},
269 /* 'http-request' OBSOLETE VERSION */
270 {"Y", "speed-limit", TRUE},
271 {"y", "speed-time", TRUE},
272 {"z", "time-cond", TRUE},
273 {"#", "progress-bar", FALSE},
274 {"~", "xattr", FALSE},
282 static const struct feat feats[] = {
283 {"AsynchDNS", CURL_VERSION_ASYNCHDNS},
284 {"Debug", CURL_VERSION_DEBUG},
285 {"TrackMemory", CURL_VERSION_CURLDEBUG},
286 {"GSS-Negotiate", CURL_VERSION_GSSNEGOTIATE},
287 {"IDN", CURL_VERSION_IDN},
288 {"IPv6", CURL_VERSION_IPV6},
289 {"Largefile", CURL_VERSION_LARGEFILE},
290 {"NTLM", CURL_VERSION_NTLM},
291 {"NTLM_WB", CURL_VERSION_NTLM_WB},
292 {"SPNEGO", CURL_VERSION_SPNEGO},
293 {"SSL", CURL_VERSION_SSL},
294 {"SSPI", CURL_VERSION_SSPI},
295 {"krb4", CURL_VERSION_KERBEROS4},
296 {"libz", CURL_VERSION_LIBZ},
297 {"CharConv", CURL_VERSION_CONV},
298 {"TLS-SRP", CURL_VERSION_TLSAUTH_SRP},
299 {"HTTP2", CURL_VERSION_HTTP2}
302 /* Split the argument of -E to 'certname' and 'passphrase' separated by colon.
303 * We allow ':' and '\' to be escaped by '\' so that we can use certificate
304 * nicknames containing ':'. See <https://sourceforge.net/p/curl/bugs/1196/>
309 void parse_cert_parameter(const char *cert_parameter,
313 size_t param_length = strlen(cert_parameter);
315 const char *param_place = NULL;
316 char *certname_place = NULL;
320 /* most trivial assumption: cert_parameter is empty */
321 if(param_length == 0)
324 /* next less trivial: cert_parameter contains no colon nor backslash; this
325 * means no passphrase was given and no characters escaped */
326 if(!strpbrk(cert_parameter, ":\\")) {
327 *certname = strdup(cert_parameter);
330 /* deal with escaped chars; find unescaped colon if it exists */
331 certname_place = malloc(param_length + 1);
335 *certname = certname_place;
336 param_place = cert_parameter;
337 while(*param_place) {
338 span = strcspn(param_place, ":\\");
339 strncpy(certname_place, param_place, span);
341 certname_place += span;
342 /* we just ate all the non-special chars. now we're on either a special
343 * char or the end of the string. */
344 switch(*param_place) {
349 switch(*param_place) {
351 *certname_place++ = '\\';
354 *certname_place++ = '\\';
358 *certname_place++ = ':';
362 *certname_place++ = '\\';
363 *certname_place++ = *param_place;
369 /* Since we live in a world of weirdness and confusion, the win32
370 dudes can use : when using drive letters and thus c:\file:password
371 needs to work. In order not to break compatibility, we still use : as
372 separator, but we try to detect when it is used for a file name! On
376 (param_place == &cert_parameter[1]) &&
377 (cert_parameter[2] == '\\' || cert_parameter[2] == '/') &&
378 (ISALPHA(cert_parameter[0])) ) {
379 /* colon in the second column, followed by a backslash, and the
380 first character is an alphabetic letter:
382 this is a drive letter colon */
383 *certname_place++ = ':';
388 /* escaped colons and Windows drive letter colons were handled
389 * above; if we're still here, this is a separating colon */
391 if(strlen(param_place) > 0) {
392 *passphrase = strdup(param_place);
398 *certname_place = '\0';
401 ParameterError getparameter(char *flag, /* f or -long-flag */
402 char *nextarg, /* NULL if unset */
403 bool *usedarg, /* set to TRUE if the arg
405 struct Configurable *config)
408 char subletter = '\0'; /* subletters can only occur on long options */
410 const char *parse = NULL;
414 bool longopt = FALSE;
415 bool singleopt = FALSE; /* when true means '-o foo' used '-ofoo' */
417 bool toggle = TRUE; /* how to switch boolean options, on or off. Controlled
418 by using --OPTION or --no-OPTION */
421 if(('-' != flag[0]) ||
422 (('-' == flag[0]) && ('-' == flag[1]))) {
423 /* this should be a long name */
424 char *word = ('-' == flag[0]) ? flag+2 : flag;
425 size_t fnam = strlen(word);
428 if(!strncmp(word, "no-", 3)) {
429 /* disable this option but ignore the "no-" part when looking for it */
434 for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) {
435 if(curlx_strnequal(aliases[j].lname, word, fnam)) {
438 if(curlx_raw_equal(aliases[j].lname, word)) {
439 parse = aliases[j].letter;
441 numhits = 1; /* a single unique hit */
444 parse = aliases[j].letter;
449 /* this is at least the second match! */
450 return PARAM_OPTION_AMBIGUOUS;
453 return PARAM_OPTION_UNKNOWN;
457 flag++; /* prefixed with one dash, pass it */
463 /* we can loop here if we have multiple single-letters */
467 letter = (char)*parse;
476 subletter = parse[1];
478 *usedarg = FALSE; /* default is that we don't use the arg */
481 for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) {
482 if(letter == aliases[j].letter[0]) {
488 return PARAM_OPTION_UNKNOWN;
492 if(aliases[hit].extraparam) {
493 /* this option requires an extra parameter */
494 if(!longopt && parse[1]) {
495 nextarg = (char *)&parse[1]; /* this is the actual extra parameter */
496 singleopt = TRUE; /* don't loop anymore after this */
499 return PARAM_REQUIRES_PARAMETER;
501 *usedarg = TRUE; /* mark it as used */
505 case '*': /* options without a short option */
507 case '4': /* --dns-ipv4-addr */
508 /* addr in dot notation */
509 GetStr(&config->dns_ipv4_addr, nextarg);
511 case '6': /* --dns-ipv6-addr */
512 /* addr in dot notation */
513 GetStr(&config->dns_ipv6_addr, nextarg);
515 case 'a': /* random-file */
516 GetStr(&config->random_file, nextarg);
518 case 'b': /* egd-file */
519 GetStr(&config->egd_file, nextarg);
521 case 'B': /* XOAUTH2 Bearer */
522 GetStr(&config->xoauth2_bearer, nextarg);
524 case 'c': /* connect-timeout */
525 err = str2udouble(&config->connecttimeout, nextarg);
529 case 'd': /* ciphers */
530 GetStr(&config->cipher_list, nextarg);
532 case 'D': /* --dns-interface */
534 GetStr(&config->dns_interface, nextarg);
536 case 'e': /* --disable-epsv */
537 config->disable_epsv = toggle;
539 case 'E': /* --epsv */
540 config->disable_epsv = (!toggle)?TRUE:FALSE;
542 #ifdef USE_ENVIRONMENT
544 config->writeenv = toggle;
547 case 'F': /* --dns-servers */
548 /* IP addrs of DNS servers */
549 GetStr(&config->dns_servers, nextarg);
551 case 'g': /* --trace */
552 GetStr(&config->trace_dump, nextarg);
553 if(config->tracetype && (config->tracetype != TRACE_BIN))
554 warnf(config, "--trace overrides an earlier trace/verbose option\n");
555 config->tracetype = TRACE_BIN;
557 case 'h': /* --trace-ascii */
558 GetStr(&config->trace_dump, nextarg);
559 if(config->tracetype && (config->tracetype != TRACE_ASCII))
561 "--trace-ascii overrides an earlier trace/verbose option\n");
562 config->tracetype = TRACE_ASCII;
564 case 'i': /* --limit-rate */
566 /* We support G, M, K too */
568 curl_off_t value = curlx_strtoofft(nextarg, &unit, 0);
572 else if(strlen(unit) > 1)
573 unit = (char *)"w"; /* unsupported */
578 value *= 1024*1024*1024;
590 /* for plain bytes, leave as-is */
593 warnf(config, "unsupported rate unit. Use G, M, K or B!\n");
594 return PARAM_BAD_USE;
596 config->recvpersecond = value;
597 config->sendpersecond = value;
601 case 'j': /* --compressed */
602 if(toggle && !(curlinfo->features & CURL_VERSION_LIBZ))
603 return PARAM_LIBCURL_DOESNT_SUPPORT;
604 config->encoding = toggle;
607 case 'J': /* --tr-encoding */
608 config->tr_encoding = toggle;
611 case 'k': /* --digest */
613 config->authtype |= CURLAUTH_DIGEST;
615 config->authtype &= ~CURLAUTH_DIGEST;
618 case 'l': /* --negotiate */
620 if(curlinfo->features & CURL_VERSION_GSSNEGOTIATE)
621 config->authtype |= CURLAUTH_GSSNEGOTIATE;
623 return PARAM_LIBCURL_DOESNT_SUPPORT;
626 config->authtype &= ~CURLAUTH_GSSNEGOTIATE;
629 case 'm': /* --ntlm */
631 if(curlinfo->features & CURL_VERSION_NTLM)
632 config->authtype |= CURLAUTH_NTLM;
634 return PARAM_LIBCURL_DOESNT_SUPPORT;
637 config->authtype &= ~CURLAUTH_NTLM;
640 case 'M': /* --ntlm-wb */
642 if(curlinfo->features & CURL_VERSION_NTLM_WB)
643 config->authtype |= CURLAUTH_NTLM_WB;
645 return PARAM_LIBCURL_DOESNT_SUPPORT;
648 config->authtype &= ~CURLAUTH_NTLM_WB;
651 case 'n': /* --basic for completeness */
653 config->authtype |= CURLAUTH_BASIC;
655 config->authtype &= ~CURLAUTH_BASIC;
658 case 'o': /* --anyauth, let libcurl pick it */
660 config->authtype = CURLAUTH_ANY;
661 /* --no-anyauth simply doesn't touch it */
665 case 'p': /* --wdebug */
669 case 'q': /* --ftp-create-dirs */
670 config->ftp_create_dirs = toggle;
673 case 'r': /* --create-dirs */
674 config->create_dirs = toggle;
677 case 's': /* --max-redirs */
678 /* specified max no of redirects (http(s)), this accepts -1 as a
680 err = str2num(&config->maxredirs, nextarg);
683 if(config->maxredirs < -1)
684 return PARAM_BAD_NUMERIC;
687 case 't': /* --proxy-ntlm */
688 if(curlinfo->features & CURL_VERSION_NTLM)
689 config->proxyntlm = toggle;
691 return PARAM_LIBCURL_DOESNT_SUPPORT;
694 case 'u': /* --crlf */
695 /* LF -> CRLF conversion? */
696 config->crlf = toggle;
699 case 'v': /* --stderr */
700 if(strcmp(nextarg, "-")) {
701 FILE *newfile = fopen(nextarg, "wt");
703 warnf(config, "Failed to open %s!\n", nextarg);
705 if(config->errors_fopened)
706 fclose(config->errors);
707 config->errors = newfile;
708 config->errors_fopened = TRUE;
712 config->errors = stdout;
714 case 'w': /* --interface */
716 GetStr(&config->iface, nextarg);
718 case 'x': /* --krb */
719 /* kerberos level string */
720 if(curlinfo->features & (CURL_VERSION_KERBEROS4 |
721 CURL_VERSION_GSSNEGOTIATE))
722 GetStr(&config->krblevel, nextarg);
724 return PARAM_LIBCURL_DOESNT_SUPPORT;
726 case 'y': /* --max-filesize */
727 err = str2offset(&config->max_filesize, nextarg);
731 case 'z': /* --disable-eprt */
732 config->disable_eprt = toggle;
734 case 'Z': /* --eprt */
735 config->disable_eprt = (!toggle)?TRUE:FALSE;
738 default: /* the URL! */
741 if(config->url_get || ((config->url_get = config->url_list) != NULL)) {
742 /* there's a node here, if it already is filled-in continue to find
744 while(config->url_get && (config->url_get->flags & GETOUT_URL))
745 config->url_get = config->url_get->next;
748 /* now there might or might not be an available node to fill in! */
752 url = config->url_get;
754 /* there was no free node, create one! */
755 url = new_getout(config);
760 /* fill in the URL */
761 GetStr(&url->url, nextarg);
762 url->flags |= GETOUT_URL;
767 case '$': /* more options without a short option */
769 case 'a': /* --ftp-ssl */
770 if(toggle && !(curlinfo->features & CURL_VERSION_SSL))
771 return PARAM_LIBCURL_DOESNT_SUPPORT;
772 config->ftp_ssl = toggle;
774 case 'b': /* --ftp-pasv */
775 Curl_safefree(config->ftpport);
777 case 'c': /* --socks5 specifies a socks5 proxy to use, and resolves
778 the name locally and passes on the resolved address */
779 GetStr(&config->socksproxy, nextarg);
780 config->socksver = CURLPROXY_SOCKS5;
782 case 't': /* --socks4 specifies a socks4 proxy to use */
783 GetStr(&config->socksproxy, nextarg);
784 config->socksver = CURLPROXY_SOCKS4;
786 case 'T': /* --socks4a specifies a socks4a proxy to use */
787 GetStr(&config->socksproxy, nextarg);
788 config->socksver = CURLPROXY_SOCKS4A;
790 case '2': /* --socks5-hostname specifies a socks5 proxy and enables name
791 resolving with the proxy */
792 GetStr(&config->socksproxy, nextarg);
793 config->socksver = CURLPROXY_SOCKS5_HOSTNAME;
795 case 'd': /* --tcp-nodelay option */
796 config->tcp_nodelay = toggle;
798 case 'e': /* --proxy-digest */
799 config->proxydigest = toggle;
801 case 'f': /* --proxy-basic */
802 config->proxybasic = toggle;
804 case 'g': /* --retry */
805 err = str2unum(&config->req_retry, nextarg);
809 case 'h': /* --retry-delay */
810 err = str2unum(&config->retry_delay, nextarg);
814 case 'i': /* --retry-max-time */
815 err = str2unum(&config->retry_maxtime, nextarg);
820 case 'k': /* --proxy-negotiate */
821 if(curlinfo->features & CURL_VERSION_GSSNEGOTIATE)
822 config->proxynegotiate = toggle;
824 return PARAM_LIBCURL_DOESNT_SUPPORT;
826 case 'm': /* --ftp-account */
827 GetStr(&config->ftp_account, nextarg);
829 case 'n': /* --proxy-anyauth */
830 config->proxyanyauth = toggle;
832 case 'o': /* --trace-time */
833 config->tracetime = toggle;
835 case 'p': /* --ignore-content-length */
836 config->ignorecl = toggle;
838 case 'q': /* --ftp-skip-pasv-ip */
839 config->ftp_skip_ip = toggle;
841 case 'r': /* --ftp-method (undocumented at this point) */
842 config->ftp_filemethod = ftpfilemethod(config, nextarg);
844 case 's': /* --local-port */
845 rc = sscanf(nextarg, "%d - %d",
847 &config->localportrange);
849 return PARAM_BAD_USE;
851 config->localportrange = 1; /* default number of ports to try */
853 config->localportrange -= config->localport;
854 if(config->localportrange < 1) {
855 warnf(config, "bad range input\n");
856 return PARAM_BAD_USE;
860 case 'u': /* --ftp-alternative-to-user */
861 GetStr(&config->ftp_alternative_to_user, nextarg);
863 case 'v': /* --ftp-ssl-reqd */
864 if(toggle && !(curlinfo->features & CURL_VERSION_SSL))
865 return PARAM_LIBCURL_DOESNT_SUPPORT;
866 config->ftp_ssl_reqd = toggle;
868 case 'w': /* --no-sessionid */
869 config->disable_sessionid = (!toggle)?TRUE:FALSE;
871 case 'x': /* --ftp-ssl-control */
872 if(toggle && !(curlinfo->features & CURL_VERSION_SSL))
873 return PARAM_LIBCURL_DOESNT_SUPPORT;
874 config->ftp_ssl_control = toggle;
876 case 'y': /* --ftp-ssl-ccc */
877 config->ftp_ssl_ccc = toggle;
878 if(!config->ftp_ssl_ccc_mode)
879 config->ftp_ssl_ccc_mode = CURLFTPSSL_CCC_PASSIVE;
881 case 'j': /* --ftp-ssl-ccc-mode */
882 config->ftp_ssl_ccc = TRUE;
883 config->ftp_ssl_ccc_mode = ftpcccmethod(config, nextarg);
885 case 'z': /* --libcurl */
886 #ifdef CURL_DISABLE_LIBCURL_OPTION
888 "--libcurl option was disabled at build-time!\n");
889 return PARAM_OPTION_UNKNOWN;
891 GetStr(&config->libcurl, nextarg);
894 case '#': /* --raw */
895 config->raw = toggle;
897 case '0': /* --post301 */
898 config->post301 = toggle;
900 case '1': /* --no-keepalive */
901 config->nokeepalive = (!toggle)?TRUE:FALSE;
903 case '3': /* --keepalive-time */
904 err = str2unum(&config->alivetime, nextarg);
908 case '4': /* --post302 */
909 config->post302 = toggle;
911 case 'I': /* --post303 */
912 config->post303 = toggle;
914 case '5': /* --noproxy */
915 /* This specifies the noproxy list */
916 GetStr(&config->noproxy, nextarg);
918 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
919 case '6': /* --socks5-gssapi-service */
920 GetStr(&config->socks5_gssapi_service, nextarg);
922 case '7': /* --socks5-gssapi-nec*/
923 config->socks5_gssapi_nec = toggle;
926 case '8': /* --proxy1.0 */
928 GetStr(&config->proxy, nextarg);
929 config->proxyver = CURLPROXY_HTTP_1_0;
931 case '9': /* --tftp-blksize */
932 err = str2unum(&config->tftp_blksize, nextarg);
936 case 'A': /* --mail-from */
937 GetStr(&config->mail_from, nextarg);
939 case 'B': /* --mail-rcpt */
940 /* append receiver to a list */
941 err = add2list(&config->mail_rcpt, nextarg);
945 case 'C': /* --ftp-pret */
946 config->ftp_pret = toggle;
948 case 'D': /* --proto */
949 config->proto_present = TRUE;
950 if(proto2num(config, &config->proto, nextarg))
951 return PARAM_BAD_USE;
953 case 'E': /* --proto-redir */
954 config->proto_redir_present = TRUE;
955 if(proto2num(config, &config->proto_redir, nextarg))
956 return PARAM_BAD_USE;
958 case 'F': /* --resolve */
959 err = add2list(&config->resolve, nextarg);
963 case 'G': /* --delegation LEVEL */
964 config->gssapi_delegation = delegation(config, nextarg);
966 case 'H': /* --mail-auth */
967 GetStr(&config->mail_auth, nextarg);
969 case 'J': /* --metalink */
972 int mlmaj, mlmin, mlpatch;
973 metalink_get_version(&mlmaj, &mlmin, &mlpatch);
974 if((mlmaj*10000)+(mlmin*100)+mlpatch < CURL_REQ_LIBMETALINK_VERS) {
976 "--metalink option cannot be used because the version of "
977 "the linked libmetalink library is too old. "
978 "Required: %d.%d.%d, found %d.%d.%d\n",
979 CURL_REQ_LIBMETALINK_MAJOR,
980 CURL_REQ_LIBMETALINK_MINOR,
981 CURL_REQ_LIBMETALINK_PATCH,
982 mlmaj, mlmin, mlpatch);
983 return PARAM_BAD_USE;
986 config->use_metalink = toggle;
988 warnf(config, "--metalink option is ignored because the binary is "
989 "built without the Metalink support.\n");
993 case 'K': /* --sasl-ir */
994 config->sasl_ir = toggle;
996 case 'L': /* --test-event */
998 config->test_event_based = toggle;
1000 warnf(config, "--test-event is ignored unless a debug build!\n");
1005 case '#': /* --progress-bar */
1007 config->progressmode = CURL_PROGRESS_BAR;
1009 config->progressmode = CURL_PROGRESS_STATS;
1011 case '~': /* --xattr */
1012 config->xattr = toggle;
1014 case '0': /* --http* options */
1017 /* HTTP version 1.0 */
1018 config->httpversion = CURL_HTTP_VERSION_1_0;
1021 /* HTTP version 1.1 */
1022 config->httpversion = CURL_HTTP_VERSION_1_1;
1025 /* HTTP version 2.0 */
1026 config->httpversion = CURL_HTTP_VERSION_2_0;
1030 case '1': /* --tlsv1* options */
1033 /* TLS version 1.x */
1034 config->ssl_version = CURL_SSLVERSION_TLSv1;
1037 /* TLS version 1.0 */
1038 config->ssl_version = CURL_SSLVERSION_TLSv1_0;
1041 /* TLS version 1.1 */
1042 config->ssl_version = CURL_SSLVERSION_TLSv1_1;
1045 /* TLS version 1.2 */
1046 config->ssl_version = CURL_SSLVERSION_TLSv1_2;
1052 config->ssl_version = CURL_SSLVERSION_SSLv2;
1056 config->ssl_version = CURL_SSLVERSION_SSLv3;
1060 config->ip_version = 4;
1064 config->ip_version = 6;
1067 /* This makes the FTP sessions use APPE instead of STOR */
1068 config->ftp_append = toggle;
1071 /* This specifies the User-Agent name */
1072 GetStr(&config->useragent, nextarg);
1074 case 'b': /* cookie string coming up: */
1075 if(nextarg[0] == '@') {
1078 else if(strchr(nextarg, '=')) {
1079 /* A cookie string must have a =-letter */
1080 GetStr(&config->cookie, nextarg);
1083 /* We have a cookie file to read from! */
1084 GetStr(&config->cookiefile, nextarg);
1087 /* use ASCII/text when transferring */
1088 config->use_ascii = toggle;
1091 /* get the file name to dump all cookies in */
1092 GetStr(&config->cookiejar, nextarg);
1095 /* This makes us continue an ftp transfer at given position */
1096 if(!curlx_strequal(nextarg, "-")) {
1097 err = str2offset(&config->resume_from, nextarg);
1100 config->resume_from_current = FALSE;
1103 config->resume_from_current = TRUE;
1104 config->resume_from = 0;
1106 config->use_resume=TRUE;
1109 /* postfield data */
1111 char *postdata = NULL;
1115 if(subletter == 'e') { /* --data-urlencode*/
1116 /* [name]=[content], we encode the content part only
1117 * [name]@[file name]
1119 * Case 2: we first load the file using that name and then encode
1122 const char *p = strchr(nextarg, '=');
1126 /* there was no '=' letter, check for a '@' instead */
1127 p = strchr(nextarg, '@');
1129 nlen = p - nextarg; /* length of the name part */
1130 is_file = *p++; /* pass the separator */
1133 /* neither @ nor =, so no name and it isn't a file */
1137 if('@' == is_file) {
1138 /* a '@' letter, it means that a file name or - (stdin) follows */
1140 if(curlx_strequal("-", p)) {
1145 file = fopen(p, "rb");
1148 "Couldn't read data from file \"%s\", this makes "
1149 "an empty POST.\n", nextarg);
1152 err = file2memory(&postdata, &size, file);
1154 if(file && (file != stdin))
1160 GetStr(&postdata, p);
1162 size = strlen(postdata);
1166 /* no data from the file, point to a zero byte string to make this
1167 get sent as a POST anyway */
1168 postdata = strdup("");
1170 return PARAM_NO_MEM;
1174 char *enc = curl_easy_escape(config->easy, postdata, (int)size);
1175 Curl_safefree(postdata); /* no matter if it worked or not */
1177 /* now make a string with the name from above and append the
1179 size_t outlen = nlen + strlen(enc) + 2;
1180 char *n = malloc(outlen);
1183 return PARAM_NO_MEM;
1185 if(nlen > 0) { /* only append '=' if we have a name */
1186 snprintf(n, outlen, "%.*s=%s", nlen, nextarg, enc);
1191 size = outlen-2; /* since no '=' was inserted */
1197 return PARAM_NO_MEM;
1200 else if('@' == *nextarg) {
1201 /* the data begins with a '@' letter, it means that a file name
1202 or - (stdin) follows */
1203 nextarg++; /* pass the @ */
1205 if(curlx_strequal("-", nextarg)) {
1207 if(subletter == 'b') /* forced data-binary */
1211 file = fopen(nextarg, "rb");
1213 warnf(config, "Couldn't read data from file \"%s\", this makes "
1214 "an empty POST.\n", nextarg);
1217 if(subletter == 'b')
1219 err = file2memory(&postdata, &size, file);
1221 err = file2string(&postdata, file);
1223 size = strlen(postdata);
1226 if(file && (file != stdin))
1232 /* no data from the file, point to a zero byte string to make this
1233 get sent as a POST anyway */
1234 postdata = strdup("");
1236 return PARAM_NO_MEM;
1240 GetStr(&postdata, nextarg);
1242 size = strlen(postdata);
1245 #ifdef CURL_DOES_CONVERSIONS
1246 if(subletter != 'b') {
1247 /* NOT forced binary, convert to ASCII */
1248 if(convert_to_network(postdata, strlen(postdata))) {
1249 Curl_safefree(postdata);
1250 return PARAM_NO_MEM;
1255 if(config->postfields) {
1256 /* we already have a string, we append this one with a separating
1258 char *oldpost = config->postfields;
1259 curl_off_t oldlen = config->postfieldsize;
1260 curl_off_t newlen = oldlen + size + 2;
1261 config->postfields = malloc((size_t)newlen);
1262 if(!config->postfields) {
1263 Curl_safefree(oldpost);
1264 Curl_safefree(postdata);
1265 return PARAM_NO_MEM;
1267 memcpy(config->postfields, oldpost, (size_t)oldlen);
1268 /* use byte value 0x26 for '&' to accommodate non-ASCII platforms */
1269 config->postfields[oldlen] = '\x26';
1270 memcpy(&config->postfields[oldlen+1], postdata, size);
1271 config->postfields[oldlen+1+size] = '\0';
1272 Curl_safefree(oldpost);
1273 Curl_safefree(postdata);
1274 config->postfieldsize += size+1;
1277 config->postfields = postdata;
1278 config->postfieldsize = size;
1282 We can't set the request type here, as this data might be used in
1283 a simple GET if -G is used. Already or soon.
1285 if(SetHTTPrequest(HTTPREQ_SIMPLEPOST, &config->httpreq)) {
1286 Curl_safefree(postdata);
1287 return PARAM_BAD_USE;
1292 /* dump-header to given file name */
1293 GetStr(&config->headerfile, nextarg);
1297 char *ptr = strstr(nextarg, ";auto");
1299 /* Automatic referer requested, this may be combined with a
1301 config->autoreferer = TRUE;
1302 *ptr = 0; /* zero terminate here */
1305 config->autoreferer = FALSE;
1306 GetStr(&config->referer, nextarg);
1311 case 'a': /* CA info PEM file */
1312 /* CA info PEM file */
1313 GetStr(&config->cacert, nextarg);
1315 case 'b': /* cert file type */
1316 GetStr(&config->cert_type, nextarg);
1318 case 'c': /* private key file */
1319 GetStr(&config->key, nextarg);
1321 case 'd': /* private key file type */
1322 GetStr(&config->key_type, nextarg);
1324 case 'e': /* private key passphrase */
1325 GetStr(&config->key_passwd, nextarg);
1328 case 'f': /* crypto engine */
1329 GetStr(&config->engine, nextarg);
1330 if(config->engine && curlx_raw_equal(config->engine,"list"))
1331 config->list_engines = TRUE;
1333 case 'g': /* CA info PEM file */
1334 /* CA cert directory */
1335 GetStr(&config->capath, nextarg);
1337 case 'h': /* --pubkey public key file */
1338 GetStr(&config->pubkey, nextarg);
1340 case 'i': /* --hostpubmd5 md5 of the host public key */
1341 GetStr(&config->hostpubmd5, nextarg);
1342 if(!config->hostpubmd5 || strlen(config->hostpubmd5) != 32)
1343 return PARAM_BAD_USE;
1345 case 'j': /* CRL info PEM file */
1347 GetStr(&config->crlfile, nextarg);
1349 case 'k': /* TLS username */
1350 if(curlinfo->features & CURL_VERSION_TLSAUTH_SRP)
1351 GetStr(&config->tls_username, nextarg);
1353 return PARAM_LIBCURL_DOESNT_SUPPORT;
1355 case 'l': /* TLS password */
1356 if(curlinfo->features & CURL_VERSION_TLSAUTH_SRP)
1357 GetStr(&config->tls_password, nextarg);
1359 return PARAM_LIBCURL_DOESNT_SUPPORT;
1361 case 'm': /* TLS authentication type */
1362 if(curlinfo->features & CURL_VERSION_TLSAUTH_SRP) {
1363 GetStr(&config->tls_authtype, nextarg);
1364 if(!strequal(config->tls_authtype, "SRP"))
1365 return PARAM_LIBCURL_DOESNT_SUPPORT; /* only support TLS-SRP */
1368 return PARAM_LIBCURL_DOESNT_SUPPORT;
1370 case 'n': /* no empty SSL fragments, --ssl-allow-beast */
1371 if(curlinfo->features & CURL_VERSION_SSL)
1372 config->ssl_allow_beast = toggle;
1375 case 'o': /* --login-options */
1376 GetStr(&config->login_options, nextarg);
1379 default: /* certificate file */
1381 char *certname, *passphrase;
1382 parse_cert_parameter(nextarg, &certname, &passphrase);
1383 Curl_safefree(config->cert);
1384 config->cert = certname;
1386 Curl_safefree(config->key_passwd);
1387 config->key_passwd = passphrase;
1394 /* fail hard on errors */
1395 config->failonerror = toggle;
1398 /* "form data" simulation, this is a little advanced so lets do our best
1399 to sort this out slowly and carefully */
1400 if(formparse(config,
1404 (subletter=='s')?TRUE:FALSE)) /* 's' means literal string */
1405 return PARAM_BAD_USE;
1406 if(SetHTTPrequest(config, HTTPREQ_POST, &config->httpreq))
1407 return PARAM_BAD_USE;
1410 case 'g': /* g disables URLglobbing */
1411 config->globoff = toggle;
1414 case 'G': /* HTTP GET */
1415 config->use_httpget = TRUE;
1418 case 'h': /* h for help */
1421 return PARAM_HELP_REQUESTED;
1423 /* we now actually support --no-help too! */
1426 /* A custom header to append to a list */
1427 err = add2list(&config->headers, nextarg);
1432 config->include_headers = toggle; /* include the headers as well in the
1433 general output stream */
1436 config->cookiesession = toggle;
1440 * no_body will imply include_headers later on
1442 config->no_body = toggle;
1443 if(SetHTTPrequest(config,
1444 (config->no_body)?HTTPREQ_HEAD:HTTPREQ_GET,
1446 return PARAM_BAD_USE;
1448 case 'J': /* --remote-header-name */
1449 if(config->include_headers) {
1451 "--include and --remote-header-name cannot be combined.\n");
1452 return PARAM_BAD_USE;
1454 config->content_disposition = toggle;
1456 case 'k': /* allow insecure SSL connects */
1457 config->insecure_ok = toggle;
1459 case 'K': /* parse config file */
1460 if(parseconfig(nextarg, config))
1461 warnf(config, "error trying read config from the '%s' file\n",
1465 config->dirlistonly = toggle; /* only list the names of the FTP dir */
1468 config->followlocation = toggle; /* Follow Location: HTTP headers */
1469 switch (subletter) {
1471 /* Continue to send authentication (user+password) when following
1472 * locations, even when hostname changed */
1473 config->unrestricted_auth = toggle;
1478 /* specified max time */
1479 err = str2udouble(&config->timeout, nextarg);
1483 case 'M': /* M for manual, huge help */
1484 if(toggle) { /* --no-manual shows no manual... */
1487 return PARAM_HELP_REQUESTED;
1490 "built-in manual was disabled at build-time!\n");
1491 return PARAM_OPTION_UNKNOWN;
1497 case 'o': /* CA info PEM file */
1498 /* use .netrc or URL */
1499 config->netrc_opt = toggle;
1501 case 'e': /* netrc-file */
1502 GetStr(&config->netrc_file, nextarg);
1505 /* pick info from .netrc, if this is used for http, curl will
1506 automatically enfore user+password with the request */
1507 config->netrc = toggle;
1512 /* disable the output I/O buffering. note that the option is called
1513 --buffer but is mostly used in the negative form: --no-buffer */
1515 config->nobuffer = (!toggle)?TRUE:FALSE;
1517 config->nobuffer = toggle;
1519 case 'O': /* --remote-name */
1520 if(subletter == 'a') { /* --remote-name-all */
1521 config->default_node_flags = toggle?GETOUT_USEREMOTE:0;
1525 case 'o': /* --output */
1529 if(config->url_out || ((config->url_out = config->url_list) != NULL)) {
1530 /* there's a node here, if it already is filled-in continue to find
1532 while(config->url_out && (config->url_out->flags & GETOUT_OUTFILE))
1533 config->url_out = config->url_out->next;
1536 /* now there might or might not be an available node to fill in! */
1540 url = config->url_out;
1542 /* there was no free node, create one! */
1543 url = new_getout(config);
1546 return PARAM_NO_MEM;
1548 /* fill in the outfile */
1550 GetStr(&url->outfile, nextarg);
1551 url->flags &= ~GETOUT_USEREMOTE; /* switch off */
1554 url->outfile = NULL; /* leave it */
1556 url->flags |= GETOUT_USEREMOTE; /* switch on */
1558 url->flags &= ~GETOUT_USEREMOTE; /* switch off */
1560 url->flags |= GETOUT_OUTFILE;
1565 /* This makes the FTP sessions use PORT instead of PASV */
1566 /* use <eth0> or <192.168.10.10> style addresses. Anything except
1567 this will make us try to get the "default" address.
1568 NOTE: this is a changed behaviour since the released 4.1!
1570 GetStr(&config->ftpport, nextarg);
1573 /* proxy tunnel for non-http protocols */
1574 config->proxytunnel = toggle;
1577 case 'q': /* if used first, already taken care of, we do it like
1578 this so we don't cause an error! */
1581 /* QUOTE command to send to FTP server */
1582 switch(nextarg[0]) {
1584 /* prefixed with a dash makes it a POST TRANSFER one */
1586 err = add2list(&config->postquote, nextarg);
1589 /* prefixed with a plus makes it a just-before-transfer one */
1591 err = add2list(&config->prequote, nextarg);
1594 err = add2list(&config->quote, nextarg);
1601 /* Specifying a range WITHOUT A DASH will create an illegal HTTP range
1602 (and won't actually be range by definition). The man page previously
1603 claimed that to be a good way, why this code is added to work-around
1605 if(ISDIGIT(*nextarg) && !strchr(nextarg, '-')) {
1609 "A specified range MUST include at least one dash (-). "
1610 "Appending one for you!\n");
1611 off = curlx_strtoofft(nextarg, NULL, 10);
1612 snprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-", off);
1613 Curl_safefree(config->range);
1614 config->range = strdup(buffer);
1616 return PARAM_NO_MEM;
1619 /* byte range requested */
1621 tmp_range = nextarg;
1622 while(*tmp_range != '\0') {
1623 if(!ISDIGIT(*tmp_range) && *tmp_range != '-' && *tmp_range != ',') {
1624 warnf(config,"Invalid character is found in given range. "
1625 "A specified range MUST have only digits in "
1626 "\'start\'-\'stop\'. The server's response to this "
1627 "request is uncertain.\n");
1632 /* byte range requested */
1633 GetStr(&config->range, nextarg);
1637 /* use remote file's time */
1638 config->remote_time = toggle;
1641 /* don't show progress meter, don't show errors : */
1643 config->mute = config->noprogress = TRUE;
1645 config->mute = config->noprogress = FALSE;
1646 if(config->showerror < 0)
1647 /* if still on the default value, set showerror to the reverse of
1648 toggle. This is to allow -S and -s to be used in an independent
1649 order but still have the same effect. */
1650 config->showerror = (!toggle)?TRUE:FALSE; /* toggle off */
1654 config->showerror = toggle?1:0; /* toggle on if used with -s */
1657 /* Telnet options */
1658 err = add2list(&config->telnet_options, nextarg);
1663 /* we are uploading */
1666 if(config->url_out || ((config->url_out = config->url_list) != NULL)) {
1667 /* there's a node here, if it already is filled-in continue to find
1669 while(config->url_out && (config->url_out->flags & GETOUT_UPLOAD))
1670 config->url_out = config->url_out->next;
1673 /* now there might or might not be an available node to fill in! */
1677 url = config->url_out;
1679 /* there was no free node, create one! */
1680 url = new_getout(config);
1683 return PARAM_NO_MEM;
1685 url->flags |= GETOUT_UPLOAD; /* mark -T used */
1687 url->flags |= GETOUT_NOUPLOAD;
1689 /* "-" equals stdin, but keep the string around for now */
1690 GetStr(&url->infile, nextarg);
1697 GetStr(&config->userpwd, nextarg);
1701 /* Proxy user:password */
1702 GetStr(&config->proxyuserpwd, nextarg);
1707 /* the '%' thing here will cause the trace get sent to stderr */
1708 Curl_safefree(config->trace_dump);
1709 config->trace_dump = strdup("%");
1710 if(!config->trace_dump)
1711 return PARAM_NO_MEM;
1712 if(config->tracetype && (config->tracetype != TRACE_PLAIN))
1714 "-v, --verbose overrides an earlier trace/verbose option\n");
1715 config->tracetype = TRACE_PLAIN;
1718 /* verbose is disabled here */
1719 config->tracetype = TRACE_NONE;
1723 const char *const *proto;
1726 /* --no-version yields no output! */
1729 printf(CURL_ID "%s\n", curl_version());
1730 if(curlinfo->protocols) {
1731 printf("Protocols: ");
1732 for(proto = curlinfo->protocols; *proto; ++proto) {
1733 printf("%s ", *proto);
1735 puts(""); /* newline */
1737 if(curlinfo->features) {
1739 printf("Features: ");
1740 for(i = 0; i < sizeof(feats)/sizeof(feats[0]); i++) {
1741 if(curlinfo->features & feats[i].bitmask)
1742 printf("%s ", feats[i].name);
1745 printf("Metalink ");
1747 puts(""); /* newline */
1750 return PARAM_HELP_REQUESTED;
1752 /* get the output string */
1753 if('@' == *nextarg) {
1754 /* the data begins with a '@' letter, it means that a file name
1755 or - (stdin) follows */
1758 nextarg++; /* pass the @ */
1759 if(curlx_strequal("-", nextarg)) {
1765 file = fopen(nextarg, "r");
1767 err = file2string(&config->writeout, file);
1768 if(file && (file != stdin))
1772 if(!config->writeout)
1773 warnf(config, "Failed to read %s", fname);
1776 GetStr(&config->writeout, nextarg);
1780 GetStr(&config->proxy, nextarg);
1781 config->proxyver = CURLPROXY_HTTP;
1784 /* set custom request */
1785 GetStr(&config->customrequest, nextarg);
1788 /* low speed time */
1789 err = str2unum(&config->low_speed_time, nextarg);
1792 if(!config->low_speed_limit)
1793 config->low_speed_limit = 1;
1796 /* low speed limit */
1797 err = str2unum(&config->low_speed_limit, nextarg);
1800 if(!config->low_speed_time)
1801 config->low_speed_time = 30;
1803 case 'z': /* time condition coming up */
1808 /* If-Modified-Since: (section 14.28 in RFC2068) */
1809 config->timecond = CURL_TIMECOND_IFMODSINCE;
1812 /* If-Unmodified-Since: (section 14.24 in RFC2068) */
1813 config->timecond = CURL_TIMECOND_IFUNMODSINCE;
1817 /* Last-Modified: (section 14.29 in RFC2068) */
1818 config->timecond = CURL_TIMECOND_LASTMOD;
1823 config->condtime=curl_getdate(nextarg, &now);
1824 if(-1 == (int)config->condtime) {
1825 /* now let's see if it is a file name to get the time from instead! */
1826 struct_stat statbuf;
1827 if(-1 == stat(nextarg, &statbuf)) {
1828 /* failed, remove time condition */
1829 config->timecond = CURL_TIMECOND_NONE;
1831 "Illegal date format for -z, --timecond (and not "
1832 "a file name). Disabling time condition. "
1833 "See curl_getdate(3) for valid date syntax.\n");
1836 /* pull the time out from the file */
1837 config->condtime = statbuf.st_mtime;
1841 default: /* unknown flag */
1842 return PARAM_OPTION_UNKNOWN;
1846 } while(!longopt && !singleopt && *++parse && !*usedarg);