tool_getparam.c
Go to the documentation of this file.
1 /***************************************************************************
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 "strcase.h"
25 
26 #define ENABLE_CURLX_PRINTF
27 /* use our own printf() functions */
28 #include "curlx.h"
29 
30 #include "tool_binmode.h"
31 #include "tool_cfgable.h"
32 #include "tool_cb_prg.h"
33 #include "tool_convert.h"
34 #include "tool_formparse.h"
35 #include "tool_getparam.h"
36 #include "tool_helpers.h"
37 #include "tool_libinfo.h"
38 #include "tool_metalink.h"
39 #include "tool_msgs.h"
40 #include "tool_paramhlp.h"
41 #include "tool_parsecfg.h"
42 
43 #include "memdebug.h" /* keep this as LAST include */
44 
45 #ifdef MSDOS
46 # define USE_WATT32
47 #endif
48 
49 #define GetStr(str,val) do { \
50  if(*(str)) { \
51  free(*(str)); \
52  *(str) = NULL; \
53  } \
54  if((val)) { \
55  *(str) = strdup((val)); \
56  if(!(*(str))) \
57  return PARAM_NO_MEM; \
58  } \
59 } WHILE_FALSE
60 
61 struct LongShort {
62  const char *letter; /* short name option */
63  const char *lname; /* long name option */
64  enum {
65  ARG_NONE, /* stand-alone but not a boolean */
66  ARG_BOOL, /* accepts a --no-[name] prefix */
67  ARG_STRING /* requires an argument */
68  } desc;
69 };
70 
71 static const struct LongShort aliases[]= {
72  /* 'letter' strings with more than one character have *no* short option to
73  mention. */
74  {"*@", "url", ARG_STRING},
75  {"*4", "dns-ipv4-addr", ARG_STRING},
76  {"*6", "dns-ipv6-addr", ARG_STRING},
77  {"*a", "random-file", ARG_STRING},
78  {"*b", "egd-file", ARG_STRING},
79  {"*B", "oauth2-bearer", ARG_STRING},
80  {"*c", "connect-timeout", ARG_STRING},
81  {"*d", "ciphers", ARG_STRING},
82  {"*D", "dns-interface", ARG_STRING},
83  {"*e", "disable-epsv", ARG_BOOL},
84  {"*E", "epsv", ARG_BOOL},
85  /* 'epsv' made like this to make --no-epsv and --epsv to work
86  although --disable-epsv is the documented option */
87  {"*F", "dns-servers", ARG_STRING},
88  {"*g", "trace", ARG_STRING},
89  {"*G", "npn", ARG_BOOL},
90  {"*h", "trace-ascii", ARG_STRING},
91  {"*H", "alpn", ARG_BOOL},
92  {"*i", "limit-rate", ARG_STRING},
93  {"*j", "compressed", ARG_BOOL},
94  {"*J", "tr-encoding", ARG_BOOL},
95  {"*k", "digest", ARG_BOOL},
96  {"*l", "negotiate", ARG_BOOL},
97  {"*m", "ntlm", ARG_BOOL},
98  {"*M", "ntlm-wb", ARG_BOOL},
99  {"*n", "basic", ARG_BOOL},
100  {"*o", "anyauth", ARG_BOOL},
101 #ifdef USE_WATT32
102  {"*p", "wdebug", ARG_BOOL},
103 #endif
104  {"*q", "ftp-create-dirs", ARG_BOOL},
105  {"*r", "create-dirs", ARG_BOOL},
106  {"*s", "max-redirs", ARG_STRING},
107  {"*t", "proxy-ntlm", ARG_BOOL},
108  {"*u", "crlf", ARG_BOOL},
109  {"*v", "stderr", ARG_STRING},
110  {"*w", "interface", ARG_STRING},
111  {"*x", "krb", ARG_STRING},
112  {"*x", "krb4", ARG_STRING},
113  /* 'krb4' is the previous name */
114  {"*y", "max-filesize", ARG_STRING},
115  {"*z", "disable-eprt", ARG_BOOL},
116  {"*Z", "eprt", ARG_BOOL},
117  /* 'eprt' made like this to make --no-eprt and --eprt to work
118  although --disable-eprt is the documented option */
119  {"*~", "xattr", ARG_BOOL},
120  {"$a", "ftp-ssl", ARG_BOOL},
121  /* 'ftp-ssl' deprecated name since 7.20.0 */
122  {"$a", "ssl", ARG_BOOL},
123  /* 'ssl' new option name in 7.20.0, previously this was ftp-ssl */
124  {"$b", "ftp-pasv", ARG_BOOL},
125  {"$c", "socks5", ARG_STRING},
126  {"$d", "tcp-nodelay", ARG_BOOL},
127  {"$e", "proxy-digest", ARG_BOOL},
128  {"$f", "proxy-basic", ARG_BOOL},
129  {"$g", "retry", ARG_STRING},
130  {"$V", "retry-connrefused", ARG_BOOL},
131  {"$h", "retry-delay", ARG_STRING},
132  {"$i", "retry-max-time", ARG_STRING},
133  {"$k", "proxy-negotiate", ARG_BOOL},
134  {"$m", "ftp-account", ARG_STRING},
135  {"$n", "proxy-anyauth", ARG_BOOL},
136  {"$o", "trace-time", ARG_BOOL},
137  {"$p", "ignore-content-length", ARG_BOOL},
138  {"$q", "ftp-skip-pasv-ip", ARG_BOOL},
139  {"$r", "ftp-method", ARG_STRING},
140  {"$s", "local-port", ARG_STRING},
141  {"$t", "socks4", ARG_STRING},
142  {"$T", "socks4a", ARG_STRING},
143  {"$u", "ftp-alternative-to-user", ARG_STRING},
144  {"$v", "ftp-ssl-reqd", ARG_BOOL},
145  /* 'ftp-ssl-reqd' deprecated name since 7.20.0 */
146  {"$v", "ssl-reqd", ARG_BOOL},
147  /* 'ssl-reqd' new in 7.20.0, previously this was ftp-ssl-reqd */
148  {"$w", "sessionid", ARG_BOOL},
149  /* 'sessionid' listed as --no-sessionid in the help */
150  {"$x", "ftp-ssl-control", ARG_BOOL},
151  {"$y", "ftp-ssl-ccc", ARG_BOOL},
152  {"$j", "ftp-ssl-ccc-mode", ARG_STRING},
153  {"$z", "libcurl", ARG_STRING},
154  {"$#", "raw", ARG_BOOL},
155  {"$0", "post301", ARG_BOOL},
156  {"$1", "keepalive", ARG_BOOL},
157  /* 'keepalive' listed as --no-keepalive in the help */
158  {"$2", "socks5-hostname", ARG_STRING},
159  {"$3", "keepalive-time", ARG_STRING},
160  {"$4", "post302", ARG_BOOL},
161  {"$5", "noproxy", ARG_STRING},
162  {"$7", "socks5-gssapi-nec", ARG_BOOL},
163  {"$8", "proxy1.0", ARG_STRING},
164  {"$9", "tftp-blksize", ARG_STRING},
165  {"$A", "mail-from", ARG_STRING},
166  {"$B", "mail-rcpt", ARG_STRING},
167  {"$C", "ftp-pret", ARG_BOOL},
168  {"$D", "proto", ARG_STRING},
169  {"$E", "proto-redir", ARG_STRING},
170  {"$F", "resolve", ARG_STRING},
171  {"$G", "delegation", ARG_STRING},
172  {"$H", "mail-auth", ARG_STRING},
173  {"$I", "post303", ARG_BOOL},
174  {"$J", "metalink", ARG_BOOL},
175  {"$K", "sasl-ir", ARG_BOOL},
176  {"$L", "test-event", ARG_BOOL},
177  {"$M", "unix-socket", ARG_STRING},
178  {"$N", "path-as-is", ARG_BOOL},
179  {"$O", "socks5-gssapi-service", ARG_STRING},
180  /* 'socks5-gssapi-service' merged with'proxy-service-name' and
181  deprecated since 7.49.0 */
182  {"$O", "proxy-service-name", ARG_STRING},
183  {"$P", "service-name", ARG_STRING},
184  {"$Q", "proto-default", ARG_STRING},
185  {"$R", "expect100-timeout", ARG_STRING},
186  {"$S", "tftp-no-options", ARG_BOOL},
187  {"$U", "connect-to", ARG_STRING},
188  {"$W", "abstract-unix-socket", ARG_STRING},
189  {"$X", "tls-max", ARG_STRING},
190  {"$Y", "suppress-connect-headers", ARG_BOOL},
191  {"$Z", "compressed-ssh", ARG_BOOL},
192  {"0", "http1.0", ARG_NONE},
193  {"01", "http1.1", ARG_NONE},
194  {"02", "http2", ARG_NONE},
195  {"03", "http2-prior-knowledge", ARG_NONE},
196  {"1", "tlsv1", ARG_NONE},
197  {"10", "tlsv1.0", ARG_NONE},
198  {"11", "tlsv1.1", ARG_NONE},
199  {"12", "tlsv1.2", ARG_NONE},
200  {"13", "tlsv1.3", ARG_NONE},
201  {"2", "sslv2", ARG_NONE},
202  {"3", "sslv3", ARG_NONE},
203  {"4", "ipv4", ARG_NONE},
204  {"6", "ipv6", ARG_NONE},
205  {"a", "append", ARG_BOOL},
206  {"A", "user-agent", ARG_STRING},
207  {"b", "cookie", ARG_STRING},
208  {"B", "use-ascii", ARG_BOOL},
209  {"c", "cookie-jar", ARG_STRING},
210  {"C", "continue-at", ARG_STRING},
211  {"d", "data", ARG_STRING},
212  {"dr", "data-raw", ARG_STRING},
213  {"da", "data-ascii", ARG_STRING},
214  {"db", "data-binary", ARG_STRING},
215  {"de", "data-urlencode", ARG_STRING},
216  {"D", "dump-header", ARG_STRING},
217  {"e", "referer", ARG_STRING},
218  {"E", "cert", ARG_STRING},
219  {"Ea", "cacert", ARG_STRING},
220  {"Eb", "cert-type", ARG_STRING},
221  {"Ec", "key", ARG_STRING},
222  {"Ed", "key-type", ARG_STRING},
223  {"Ee", "pass", ARG_STRING},
224  {"Ef", "engine", ARG_STRING},
225  {"Eg", "capath", ARG_STRING},
226  {"Eh", "pubkey", ARG_STRING},
227  {"Ei", "hostpubmd5", ARG_STRING},
228  {"Ej", "crlfile", ARG_STRING},
229  {"Ek", "tlsuser", ARG_STRING},
230  {"El", "tlspassword", ARG_STRING},
231  {"Em", "tlsauthtype", ARG_STRING},
232  {"En", "ssl-allow-beast", ARG_BOOL},
233  {"Eo", "login-options", ARG_STRING},
234  {"Ep", "pinnedpubkey", ARG_STRING},
235  {"Eq", "cert-status", ARG_BOOL},
236  {"Er", "false-start", ARG_BOOL},
237  {"Es", "ssl-no-revoke", ARG_BOOL},
238  {"Et", "tcp-fastopen", ARG_BOOL},
239  {"Eu", "proxy-tlsuser", ARG_STRING},
240  {"Ev", "proxy-tlspassword", ARG_STRING},
241  {"Ew", "proxy-tlsauthtype", ARG_STRING},
242  {"Ex", "proxy-cert", ARG_STRING},
243  {"Ey", "proxy-cert-type", ARG_STRING},
244  {"Ez", "proxy-key", ARG_STRING},
245  {"E0", "proxy-key-type", ARG_STRING},
246  {"E1", "proxy-pass", ARG_STRING},
247  {"E2", "proxy-ciphers", ARG_STRING},
248  {"E3", "proxy-crlfile", ARG_STRING},
249  {"E4", "proxy-ssl-allow-beast", ARG_BOOL},
250  {"E5", "login-options", ARG_STRING},
251  {"E6", "proxy-cacert", ARG_STRING},
252  {"E7", "proxy-capath", ARG_STRING},
253  {"E8", "proxy-insecure", ARG_BOOL},
254  {"E9", "proxy-tlsv1", ARG_NONE},
255  {"EA", "socks5-basic", ARG_BOOL},
256  {"EB", "socks5-gssapi", ARG_BOOL},
257  {"f", "fail", ARG_BOOL},
258  {"fa", "fail-early", ARG_BOOL},
259  {"F", "form", ARG_STRING},
260  {"Fs", "form-string", ARG_STRING},
261  {"g", "globoff", ARG_BOOL},
262  {"G", "get", ARG_NONE},
263  {"Ga", "request-target", ARG_STRING},
264  {"h", "help", ARG_BOOL},
265  {"H", "header", ARG_STRING},
266  {"Hp", "proxy-header", ARG_STRING},
267  {"i", "include", ARG_BOOL},
268  {"I", "head", ARG_BOOL},
269  {"j", "junk-session-cookies", ARG_BOOL},
270  {"J", "remote-header-name", ARG_BOOL},
271  {"k", "insecure", ARG_BOOL},
272  {"K", "config", ARG_STRING},
273  {"l", "list-only", ARG_BOOL},
274  {"L", "location", ARG_BOOL},
275  {"Lt", "location-trusted", ARG_BOOL},
276  {"m", "max-time", ARG_STRING},
277  {"M", "manual", ARG_BOOL},
278  {"n", "netrc", ARG_BOOL},
279  {"no", "netrc-optional", ARG_BOOL},
280  {"ne", "netrc-file", ARG_STRING},
281  {"N", "buffer", ARG_BOOL},
282  /* 'buffer' listed as --no-buffer in the help */
283  {"o", "output", ARG_STRING},
284  {"O", "remote-name", ARG_NONE},
285  {"Oa", "remote-name-all", ARG_BOOL},
286  {"p", "proxytunnel", ARG_BOOL},
287  {"P", "ftp-port", ARG_STRING},
288  {"q", "disable", ARG_BOOL},
289  {"Q", "quote", ARG_STRING},
290  {"r", "range", ARG_STRING},
291  {"R", "remote-time", ARG_BOOL},
292  {"s", "silent", ARG_BOOL},
293  {"S", "show-error", ARG_BOOL},
294  {"t", "telnet-option", ARG_STRING},
295  {"T", "upload-file", ARG_STRING},
296  {"u", "user", ARG_STRING},
297  {"U", "proxy-user", ARG_STRING},
298  {"v", "verbose", ARG_BOOL},
299  {"V", "version", ARG_BOOL},
300  {"w", "write-out", ARG_STRING},
301  {"x", "proxy", ARG_STRING},
302  {"xa", "preproxy", ARG_STRING},
303  {"X", "request", ARG_STRING},
304  {"Y", "speed-limit", ARG_STRING},
305  {"y", "speed-time", ARG_STRING},
306  {"z", "time-cond", ARG_STRING},
307  {"#", "progress-bar", ARG_BOOL},
308  {":", "next", ARG_NONE},
309 };
310 
311 /* Split the argument of -E to 'certname' and 'passphrase' separated by colon.
312  * We allow ':' and '\' to be escaped by '\' so that we can use certificate
313  * nicknames containing ':'. See <https://sourceforge.net/p/curl/bugs/1196/>
314  * for details. */
315 #ifndef UNITTESTS
316 static
317 #endif
318 void parse_cert_parameter(const char *cert_parameter,
319  char **certname,
320  char **passphrase)
321 {
322  size_t param_length = strlen(cert_parameter);
323  size_t span;
324  const char *param_place = NULL;
325  char *certname_place = NULL;
326  *certname = NULL;
327  *passphrase = NULL;
328 
329  /* most trivial assumption: cert_parameter is empty */
330  if(param_length == 0)
331  return;
332 
333  /* next less trivial: cert_parameter starts 'pkcs11:' and thus
334  * looks like a RFC7512 PKCS#11 URI which can be used as-is.
335  * Also if cert_parameter contains no colon nor backslash, this
336  * means no passphrase was given and no characters escaped */
337  if(!strncmp(cert_parameter, "pkcs11:", 7) ||
338  !strpbrk(cert_parameter, ":\\")) {
339  *certname = strdup(cert_parameter);
340  return;
341  }
342  /* deal with escaped chars; find unescaped colon if it exists */
343  certname_place = malloc(param_length + 1);
344  if(!certname_place)
345  return;
346 
347  *certname = certname_place;
348  param_place = cert_parameter;
349  while(*param_place) {
350  span = strcspn(param_place, ":\\");
351  strncpy(certname_place, param_place, span);
352  param_place += span;
353  certname_place += span;
354  /* we just ate all the non-special chars. now we're on either a special
355  * char or the end of the string. */
356  switch(*param_place) {
357  case '\0':
358  break;
359  case '\\':
360  param_place++;
361  switch(*param_place) {
362  case '\0':
363  *certname_place++ = '\\';
364  break;
365  case '\\':
366  *certname_place++ = '\\';
367  param_place++;
368  break;
369  case ':':
370  *certname_place++ = ':';
371  param_place++;
372  break;
373  default:
374  *certname_place++ = '\\';
375  *certname_place++ = *param_place;
376  param_place++;
377  break;
378  }
379  break;
380  case ':':
381  /* Since we live in a world of weirdness and confusion, the win32
382  dudes can use : when using drive letters and thus c:\file:password
383  needs to work. In order not to break compatibility, we still use : as
384  separator, but we try to detect when it is used for a file name! On
385  windows. */
386 #ifdef WIN32
387  if(param_place &&
388  (param_place == &cert_parameter[1]) &&
389  (cert_parameter[2] == '\\' || cert_parameter[2] == '/') &&
390  (ISALPHA(cert_parameter[0])) ) {
391  /* colon in the second column, followed by a backslash, and the
392  first character is an alphabetic letter:
393 
394  this is a drive letter colon */
395  *certname_place++ = ':';
396  param_place++;
397  break;
398  }
399 #endif
400  /* escaped colons and Windows drive letter colons were handled
401  * above; if we're still here, this is a separating colon */
402  param_place++;
403  if(strlen(param_place) > 0) {
404  *passphrase = strdup(param_place);
405  }
406  goto done;
407  }
408  }
409 done:
410  *certname_place = '\0';
411 }
412 
413 static void
414 GetFileAndPassword(char *nextarg, char **file, char **password)
415 {
416  char *certname, *passphrase;
417  parse_cert_parameter(nextarg, &certname, &passphrase);
418  Curl_safefree(*file);
419  *file = certname;
420  if(passphrase) {
421  Curl_safefree(*password);
422  *password = passphrase;
423  }
424  cleanarg(nextarg);
425 }
426 
427 ParameterError getparameter(const char *flag, /* f or -long-flag */
428  char *nextarg, /* NULL if unset */
429  bool *usedarg, /* set to TRUE if the arg
430  has been used */
431  struct GlobalConfig *global,
432  struct OperationConfig *config)
433 {
434  char letter;
435  char subletter = '\0'; /* subletters can only occur on long options */
436  int rc;
437  const char *parse = NULL;
438  unsigned int j;
439  time_t now;
440  int hit = -1;
441  bool longopt = FALSE;
442  bool singleopt = FALSE; /* when true means '-o foo' used '-ofoo' */
443  ParameterError err;
444  bool toggle = TRUE; /* how to switch boolean options, on or off. Controlled
445  by using --OPTION or --no-OPTION */
446 
447  *usedarg = FALSE; /* default is that we don't use the arg */
448 
449  if(('-' != flag[0]) ||
450  (('-' == flag[0]) && ('-' == flag[1]))) {
451  /* this should be a long name */
452  const char *word = ('-' == flag[0]) ? flag + 2 : flag;
453  size_t fnam = strlen(word);
454  int numhits = 0;
455 
456  if(!strncmp(word, "no-", 3)) {
457  /* disable this option but ignore the "no-" part when looking for it */
458  word += 3;
459  toggle = FALSE;
460  }
461 
462  for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) {
463  if(curl_strnequal(aliases[j].lname, word, fnam)) {
464  longopt = TRUE;
465  numhits++;
466  if(curl_strequal(aliases[j].lname, word)) {
467  parse = aliases[j].letter;
468  hit = j;
469  numhits = 1; /* a single unique hit */
470  break;
471  }
472  parse = aliases[j].letter;
473  hit = j;
474  }
475  }
476  if(numhits > 1) {
477  /* this is at least the second match! */
478  return PARAM_OPTION_AMBIGUOUS;
479  }
480  if(hit < 0) {
481  return PARAM_OPTION_UNKNOWN;
482  }
483  }
484  else {
485  flag++; /* prefixed with one dash, pass it */
486  hit = -1;
487  parse = flag;
488  }
489 
490  do {
491  /* we can loop here if we have multiple single-letters */
492 
493  if(!longopt) {
494  letter = (char)*parse;
495  subletter = '\0';
496  }
497  else {
498  letter = parse[0];
499  subletter = parse[1];
500  }
501 
502  if(hit < 0) {
503  for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) {
504  if(letter == aliases[j].letter[0]) {
505  hit = j;
506  break;
507  }
508  }
509  if(hit < 0) {
510  return PARAM_OPTION_UNKNOWN;
511  }
512  }
513 
514  if(aliases[hit].desc == ARG_STRING) {
515  /* this option requires an extra parameter */
516  if(!longopt && parse[1]) {
517  nextarg = (char *)&parse[1]; /* this is the actual extra parameter */
518  singleopt = TRUE; /* don't loop anymore after this */
519  }
520  else if(!nextarg)
522  else
523  *usedarg = TRUE; /* mark it as used */
524  }
525  else if((aliases[hit].desc == ARG_NONE) && !toggle)
526  return PARAM_NO_PREFIX;
527 
528  switch(letter) {
529  case '*': /* options without a short option */
530  switch(subletter) {
531  case '4': /* --dns-ipv4-addr */
532  /* addr in dot notation */
533  GetStr(&config->dns_ipv4_addr, nextarg);
534  break;
535  case '6': /* --dns-ipv6-addr */
536  /* addr in dot notation */
537  GetStr(&config->dns_ipv6_addr, nextarg);
538  break;
539  case 'a': /* random-file */
540  GetStr(&config->random_file, nextarg);
541  break;
542  case 'b': /* egd-file */
543  GetStr(&config->egd_file, nextarg);
544  break;
545  case 'B': /* OAuth 2.0 bearer token */
546  GetStr(&config->oauth_bearer, nextarg);
547  break;
548  case 'c': /* connect-timeout */
549  err = str2udouble(&config->connecttimeout, nextarg,
550  LONG_MAX/1000);
551  if(err)
552  return err;
553  break;
554  case 'd': /* ciphers */
555  GetStr(&config->cipher_list, nextarg);
556  break;
557  case 'D': /* --dns-interface */
558  /* interface name */
559  GetStr(&config->dns_interface, nextarg);
560  break;
561  case 'e': /* --disable-epsv */
562  config->disable_epsv = toggle;
563  break;
564  case 'E': /* --epsv */
565  config->disable_epsv = (!toggle)?TRUE:FALSE;
566  break;
567  case 'F': /* --dns-servers */
568  /* IP addrs of DNS servers */
569  GetStr(&config->dns_servers, nextarg);
570  break;
571  case 'g': /* --trace */
572  GetStr(&global->trace_dump, nextarg);
573  if(global->tracetype && (global->tracetype != TRACE_BIN))
574  warnf(global, "--trace overrides an earlier trace/verbose option\n");
575  global->tracetype = TRACE_BIN;
576  break;
577  case 'G': /* --npn */
578  config->nonpn = (!toggle)?TRUE:FALSE;
579  break;
580  case 'h': /* --trace-ascii */
581  GetStr(&global->trace_dump, nextarg);
582  if(global->tracetype && (global->tracetype != TRACE_ASCII))
583  warnf(global,
584  "--trace-ascii overrides an earlier trace/verbose option\n");
585  global->tracetype = TRACE_ASCII;
586  break;
587  case 'H': /* --alpn */
588  config->noalpn = (!toggle)?TRUE:FALSE;
589  break;
590  case 'i': /* --limit-rate */
591  {
592  /* We support G, M, K too */
593  char *unit;
595  if(curlx_strtoofft(nextarg, &unit, 0, &value)) {
596  warnf(global, "unsupported rate\n");
597  return PARAM_BAD_USE;
598  }
599 
600  if(!*unit)
601  unit = (char *)"b";
602  else if(strlen(unit) > 1)
603  unit = (char *)"w"; /* unsupported */
604 
605  switch(*unit) {
606  case 'G':
607  case 'g':
608  value *= 1024*1024*1024;
609  break;
610  case 'M':
611  case 'm':
612  value *= 1024*1024;
613  break;
614  case 'K':
615  case 'k':
616  value *= 1024;
617  break;
618  case 'b':
619  case 'B':
620  /* for plain bytes, leave as-is */
621  break;
622  default:
623  warnf(global, "unsupported rate unit. Use G, M, K or B!\n");
624  return PARAM_BAD_USE;
625  }
626  config->recvpersecond = value;
627  config->sendpersecond = value;
628  }
629  break;
630 
631  case 'j': /* --compressed */
632  if(toggle && !(curlinfo->features & CURL_VERSION_LIBZ))
634  config->encoding = toggle;
635  break;
636 
637  case 'J': /* --tr-encoding */
638  config->tr_encoding = toggle;
639  break;
640 
641  case 'k': /* --digest */
642  if(toggle)
643  config->authtype |= CURLAUTH_DIGEST;
644  else
645  config->authtype &= ~CURLAUTH_DIGEST;
646  break;
647 
648  case 'l': /* --negotiate */
649  if(toggle) {
651  config->authtype |= CURLAUTH_NEGOTIATE;
652  else
654  }
655  else
656  config->authtype &= ~CURLAUTH_NEGOTIATE;
657  break;
658 
659  case 'm': /* --ntlm */
660  if(toggle) {
662  config->authtype |= CURLAUTH_NTLM;
663  else
665  }
666  else
667  config->authtype &= ~CURLAUTH_NTLM;
668  break;
669 
670  case 'M': /* --ntlm-wb */
671  if(toggle) {
673  config->authtype |= CURLAUTH_NTLM_WB;
674  else
676  }
677  else
678  config->authtype &= ~CURLAUTH_NTLM_WB;
679  break;
680 
681  case 'n': /* --basic for completeness */
682  if(toggle)
683  config->authtype |= CURLAUTH_BASIC;
684  else
685  config->authtype &= ~CURLAUTH_BASIC;
686  break;
687 
688  case 'o': /* --anyauth, let libcurl pick it */
689  if(toggle)
690  config->authtype = CURLAUTH_ANY;
691  /* --no-anyauth simply doesn't touch it */
692  break;
693 
694 #ifdef USE_WATT32
695  case 'p': /* --wdebug */
696  dbug_init();
697  break;
698 #endif
699  case 'q': /* --ftp-create-dirs */
700  config->ftp_create_dirs = toggle;
701  break;
702 
703  case 'r': /* --create-dirs */
704  config->create_dirs = toggle;
705  break;
706 
707  case 's': /* --max-redirs */
708  /* specified max no of redirects (http(s)), this accepts -1 as a
709  special condition */
710  err = str2num(&config->maxredirs, nextarg);
711  if(err)
712  return err;
713  if(config->maxredirs < -1)
714  return PARAM_BAD_NUMERIC;
715  break;
716 
717  case 't': /* --proxy-ntlm */
719  config->proxyntlm = toggle;
720  else
722  break;
723 
724  case 'u': /* --crlf */
725  /* LF -> CRLF conversion? */
726  config->crlf = toggle;
727  break;
728 
729  case 'v': /* --stderr */
730  if(strcmp(nextarg, "-")) {
731  FILE *newfile = fopen(nextarg, FOPEN_WRITETEXT);
732  if(!newfile)
733  warnf(global, "Failed to open %s!\n", nextarg);
734  else {
735  if(global->errors_fopened)
736  fclose(global->errors);
737  global->errors = newfile;
738  global->errors_fopened = TRUE;
739  }
740  }
741  else
742  global->errors = stdout;
743  break;
744  case 'w': /* --interface */
745  /* interface */
746  GetStr(&config->iface, nextarg);
747  break;
748  case 'x': /* --krb */
749  /* kerberos level string */
751  GetStr(&config->krblevel, nextarg);
752  else
754  break;
755  case 'y': /* --max-filesize */
756  err = str2offset(&config->max_filesize, nextarg);
757  if(err)
758  return err;
759  break;
760  case 'z': /* --disable-eprt */
761  config->disable_eprt = toggle;
762  break;
763  case 'Z': /* --eprt */
764  config->disable_eprt = (!toggle)?TRUE:FALSE;
765  break;
766  case '~': /* --xattr */
767  config->xattr = toggle;
768  break;
769  case '@': /* the URL! */
770  {
771  struct getout *url;
772 
773  if(!config->url_get)
774  config->url_get = config->url_list;
775 
776  if(config->url_get) {
777  /* there's a node here, if it already is filled-in continue to find
778  an "empty" node */
779  while(config->url_get && (config->url_get->flags & GETOUT_URL))
780  config->url_get = config->url_get->next;
781  }
782 
783  /* now there might or might not be an available node to fill in! */
784 
785  if(config->url_get)
786  /* existing node */
787  url = config->url_get;
788  else
789  /* there was no free node, create one! */
790  url = new_getout(config);
791 
792  if(!url)
793  return PARAM_NO_MEM;
794 
795  /* fill in the URL */
796  GetStr(&url->url, nextarg);
797  url->flags |= GETOUT_URL;
798  }
799  }
800  break;
801  case '$': /* more options without a short option */
802  switch(subletter) {
803  case 'a': /* --ssl */
804  if(toggle && !(curlinfo->features & CURL_VERSION_SSL))
806  config->ftp_ssl = toggle;
807  break;
808  case 'b': /* --ftp-pasv */
809  Curl_safefree(config->ftpport);
810  break;
811  case 'c': /* --socks5 specifies a socks5 proxy to use, and resolves
812  the name locally and passes on the resolved address */
813  GetStr(&config->proxy, nextarg);
814  config->proxyver = CURLPROXY_SOCKS5;
815  break;
816  case 't': /* --socks4 specifies a socks4 proxy to use */
817  GetStr(&config->proxy, nextarg);
818  config->proxyver = CURLPROXY_SOCKS4;
819  break;
820  case 'T': /* --socks4a specifies a socks4a proxy to use */
821  GetStr(&config->proxy, nextarg);
822  config->proxyver = CURLPROXY_SOCKS4A;
823  break;
824  case '2': /* --socks5-hostname specifies a socks5 proxy and enables name
825  resolving with the proxy */
826  GetStr(&config->proxy, nextarg);
828  break;
829  case 'd': /* --tcp-nodelay option */
830  config->tcp_nodelay = toggle;
831  break;
832  case 'e': /* --proxy-digest */
833  config->proxydigest = toggle;
834  break;
835  case 'f': /* --proxy-basic */
836  config->proxybasic = toggle;
837  break;
838  case 'g': /* --retry */
839  err = str2unum(&config->req_retry, nextarg);
840  if(err)
841  return err;
842  break;
843  case 'V': /* --retry-connrefused */
844  config->retry_connrefused = toggle;
845  break;
846  case 'h': /* --retry-delay */
847  err = str2unum(&config->retry_delay, nextarg);
848  if(err)
849  return err;
850  break;
851  case 'i': /* --retry-max-time */
852  err = str2unum(&config->retry_maxtime, nextarg);
853  if(err)
854  return err;
855  break;
856 
857  case 'k': /* --proxy-negotiate */
859  config->proxynegotiate = toggle;
860  else
862  break;
863 
864  case 'm': /* --ftp-account */
865  GetStr(&config->ftp_account, nextarg);
866  break;
867  case 'n': /* --proxy-anyauth */
868  config->proxyanyauth = toggle;
869  break;
870  case 'o': /* --trace-time */
871  global->tracetime = toggle;
872  break;
873  case 'p': /* --ignore-content-length */
874  config->ignorecl = toggle;
875  break;
876  case 'q': /* --ftp-skip-pasv-ip */
877  config->ftp_skip_ip = toggle;
878  break;
879  case 'r': /* --ftp-method (undocumented at this point) */
880  config->ftp_filemethod = ftpfilemethod(config, nextarg);
881  break;
882  case 's': /* --local-port */
883  rc = sscanf(nextarg, "%d - %d",
884  &config->localport,
885  &config->localportrange);
886  if(!rc)
887  return PARAM_BAD_USE;
888  if(rc == 1)
889  config->localportrange = 1; /* default number of ports to try */
890  else {
891  config->localportrange -= config->localport;
892  if(config->localportrange < 1) {
893  warnf(global, "bad range input\n");
894  return PARAM_BAD_USE;
895  }
896  }
897  break;
898  case 'u': /* --ftp-alternative-to-user */
899  GetStr(&config->ftp_alternative_to_user, nextarg);
900  break;
901  case 'v': /* --ssl-reqd */
902  if(toggle && !(curlinfo->features & CURL_VERSION_SSL))
904  config->ftp_ssl_reqd = toggle;
905  break;
906  case 'w': /* --no-sessionid */
907  config->disable_sessionid = (!toggle)?TRUE:FALSE;
908  break;
909  case 'x': /* --ftp-ssl-control */
910  if(toggle && !(curlinfo->features & CURL_VERSION_SSL))
912  config->ftp_ssl_control = toggle;
913  break;
914  case 'y': /* --ftp-ssl-ccc */
915  config->ftp_ssl_ccc = toggle;
916  if(!config->ftp_ssl_ccc_mode)
918  break;
919  case 'j': /* --ftp-ssl-ccc-mode */
920  config->ftp_ssl_ccc = TRUE;
921  config->ftp_ssl_ccc_mode = ftpcccmethod(config, nextarg);
922  break;
923  case 'z': /* --libcurl */
924 #ifdef CURL_DISABLE_LIBCURL_OPTION
925  warnf(global,
926  "--libcurl option was disabled at build-time!\n");
927  return PARAM_OPTION_UNKNOWN;
928 #else
929  GetStr(&global->libcurl, nextarg);
930  break;
931 #endif
932  case '#': /* --raw */
933  config->raw = toggle;
934  break;
935  case '0': /* --post301 */
936  config->post301 = toggle;
937  break;
938  case '1': /* --no-keepalive */
939  config->nokeepalive = (!toggle)?TRUE:FALSE;
940  break;
941  case '3': /* --keepalive-time */
942  err = str2unum(&config->alivetime, nextarg);
943  if(err)
944  return err;
945  break;
946  case '4': /* --post302 */
947  config->post302 = toggle;
948  break;
949  case 'I': /* --post303 */
950  config->post303 = toggle;
951  break;
952  case '5': /* --noproxy */
953  /* This specifies the noproxy list */
954  GetStr(&config->noproxy, nextarg);
955  break;
956  case '7': /* --socks5-gssapi-nec*/
957  config->socks5_gssapi_nec = toggle;
958  break;
959  case '8': /* --proxy1.0 */
960  /* http 1.0 proxy */
961  GetStr(&config->proxy, nextarg);
962  config->proxyver = CURLPROXY_HTTP_1_0;
963  break;
964  case '9': /* --tftp-blksize */
965  err = str2unum(&config->tftp_blksize, nextarg);
966  if(err)
967  return err;
968  break;
969  case 'A': /* --mail-from */
970  GetStr(&config->mail_from, nextarg);
971  break;
972  case 'B': /* --mail-rcpt */
973  /* append receiver to a list */
974  err = add2list(&config->mail_rcpt, nextarg);
975  if(err)
976  return err;
977  break;
978  case 'C': /* --ftp-pret */
979  config->ftp_pret = toggle;
980  break;
981  case 'D': /* --proto */
982  config->proto_present = TRUE;
983  if(proto2num(config, &config->proto, nextarg))
984  return PARAM_BAD_USE;
985  break;
986  case 'E': /* --proto-redir */
987  config->proto_redir_present = TRUE;
988  if(proto2num(config, &config->proto_redir, nextarg))
989  return PARAM_BAD_USE;
990  break;
991  case 'F': /* --resolve */
992  err = add2list(&config->resolve, nextarg);
993  if(err)
994  return err;
995  break;
996  case 'G': /* --delegation LEVEL */
997  config->gssapi_delegation = delegation(config, nextarg);
998  break;
999  case 'H': /* --mail-auth */
1000  GetStr(&config->mail_auth, nextarg);
1001  break;
1002  case 'J': /* --metalink */
1003  {
1004 #ifdef USE_METALINK
1005  int mlmaj, mlmin, mlpatch;
1006  metalink_get_version(&mlmaj, &mlmin, &mlpatch);
1007  if((mlmaj*10000)+(mlmin*100) + mlpatch < CURL_REQ_LIBMETALINK_VERS) {
1008  warnf(global,
1009  "--metalink option cannot be used because the version of "
1010  "the linked libmetalink library is too old. "
1011  "Required: %d.%d.%d, found %d.%d.%d\n",
1012  CURL_REQ_LIBMETALINK_MAJOR,
1013  CURL_REQ_LIBMETALINK_MINOR,
1014  CURL_REQ_LIBMETALINK_PATCH,
1015  mlmaj, mlmin, mlpatch);
1016  return PARAM_BAD_USE;
1017  }
1018  else
1019  config->use_metalink = toggle;
1020 #else
1021  warnf(global, "--metalink option is ignored because the binary is "
1022  "built without the Metalink support.\n");
1023 #endif
1024  break;
1025  }
1026  case 'K': /* --sasl-ir */
1027  config->sasl_ir = toggle;
1028  break;
1029  case 'L': /* --test-event */
1030 #ifdef CURLDEBUG
1031  config->test_event_based = toggle;
1032 #else
1033  warnf(global, "--test-event is ignored unless a debug build!\n");
1034 #endif
1035  break;
1036  case 'M': /* --unix-socket */
1037  config->abstract_unix_socket = FALSE;
1038  GetStr(&config->unix_socket_path, nextarg);
1039  break;
1040  case 'N': /* --path-as-is */
1041  config->path_as_is = toggle;
1042  break;
1043  case 'O': /* --proxy-service-name */
1044  GetStr(&config->proxy_service_name, nextarg);
1045  break;
1046  case 'P': /* --service-name */
1047  GetStr(&config->service_name, nextarg);
1048  break;
1049  case 'Q': /* --proto-default */
1050  GetStr(&config->proto_default, nextarg);
1051  err = check_protocol(config->proto_default);
1052  if(err)
1053  return err;
1054  break;
1055  case 'R': /* --expect100-timeout */
1056  err = str2udouble(&config->expect100timeout, nextarg, LONG_MAX/1000);
1057  if(err)
1058  return err;
1059  break;
1060  case 'S': /* --tftp-no-options */
1061  config->tftp_no_options = toggle;
1062  break;
1063  case 'U': /* --connect-to */
1064  err = add2list(&config->connect_to, nextarg);
1065  if(err)
1066  return err;
1067  break;
1068  case 'W': /* --abstract-unix-socket */
1069  config->abstract_unix_socket = TRUE;
1070  GetStr(&config->unix_socket_path, nextarg);
1071  break;
1072  case 'X': /* --tls-max */
1073  err = str2tls_max(&config->ssl_version_max, nextarg);
1074  if(err)
1075  return err;
1076  break;
1077  case 'Y': /* --suppress-connect-headers */
1078  config->suppress_connect_headers = toggle;
1079  break;
1080  case 'Z': /* --compressed-ssh */
1081  config->ssh_compression = toggle;
1082  break;
1083  }
1084  break;
1085  case '#': /* --progress-bar */
1086  if(toggle)
1087  global->progressmode = CURL_PROGRESS_BAR;
1088  else
1090  break;
1091  case ':': /* --next */
1092  return PARAM_NEXT_OPERATION;
1093  case '0': /* --http* options */
1094  switch(subletter) {
1095  case '\0':
1096  /* HTTP version 1.0 */
1098  break;
1099  case '1':
1100  /* HTTP version 1.1 */
1102  break;
1103  case '2':
1104  /* HTTP version 2.0 */
1106  break;
1107  case '3':
1108  /* HTTP version 2.0 over clean TCP*/
1110  break;
1111  }
1112  break;
1113  case '1': /* --tlsv1* options */
1114  switch(subletter) {
1115  case '\0':
1116  /* TLS version 1.x */
1118  break;
1119  case '0':
1120  /* TLS version 1.0 */
1122  break;
1123  case '1':
1124  /* TLS version 1.1 */
1126  break;
1127  case '2':
1128  /* TLS version 1.2 */
1130  break;
1131  case '3':
1132  /* TLS version 1.3 */
1134  break;
1135  }
1136  break;
1137  case '2':
1138  /* SSL version 2 */
1140  break;
1141  case '3':
1142  /* SSL version 3 */
1144  break;
1145  case '4':
1146  /* IPv4 */
1147  config->ip_version = 4;
1148  break;
1149  case '6':
1150  /* IPv6 */
1151  config->ip_version = 6;
1152  break;
1153  case 'a':
1154  /* This makes the FTP sessions use APPE instead of STOR */
1155  config->ftp_append = toggle;
1156  break;
1157  case 'A':
1158  /* This specifies the User-Agent name */
1159  GetStr(&config->useragent, nextarg);
1160  break;
1161  case 'b': /* cookie string coming up: */
1162  if(nextarg[0] == '@') {
1163  nextarg++;
1164  }
1165  else if(strchr(nextarg, '=')) {
1166  /* A cookie string must have a =-letter */
1167  GetStr(&config->cookie, nextarg);
1168  break;
1169  }
1170  /* We have a cookie file to read from! */
1171  GetStr(&config->cookiefile, nextarg);
1172  break;
1173  case 'B':
1174  /* use ASCII/text when transferring */
1175  config->use_ascii = toggle;
1176  break;
1177  case 'c':
1178  /* get the file name to dump all cookies in */
1179  GetStr(&config->cookiejar, nextarg);
1180  break;
1181  case 'C':
1182  /* This makes us continue an ftp transfer at given position */
1183  if(strcmp(nextarg, "-")) {
1184  err = str2offset(&config->resume_from, nextarg);
1185  if(err)
1186  return err;
1187  config->resume_from_current = FALSE;
1188  }
1189  else {
1190  config->resume_from_current = TRUE;
1191  config->resume_from = 0;
1192  }
1193  config->use_resume = TRUE;
1194  break;
1195  case 'd':
1196  /* postfield data */
1197  {
1198  char *postdata = NULL;
1199  FILE *file;
1200  size_t size = 0;
1201  bool raw_mode = (subletter == 'r');
1202 
1203  if(subletter == 'e') { /* --data-urlencode*/
1204  /* [name]=[content], we encode the content part only
1205  * [name]@[file name]
1206  *
1207  * Case 2: we first load the file using that name and then encode
1208  * the content.
1209  */
1210  const char *p = strchr(nextarg, '=');
1211  size_t nlen;
1212  char is_file;
1213  if(!p)
1214  /* there was no '=' letter, check for a '@' instead */
1215  p = strchr(nextarg, '@');
1216  if(p) {
1217  nlen = p - nextarg; /* length of the name part */
1218  is_file = *p++; /* pass the separator */
1219  }
1220  else {
1221  /* neither @ nor =, so no name and it isn't a file */
1222  nlen = is_file = 0;
1223  p = nextarg;
1224  }
1225  if('@' == is_file) {
1226  /* a '@' letter, it means that a file name or - (stdin) follows */
1227  if(!strcmp("-", p)) {
1228  file = stdin;
1229  set_binmode(stdin);
1230  }
1231  else {
1232  file = fopen(p, "rb");
1233  if(!file)
1234  warnf(global,
1235  "Couldn't read data from file \"%s\", this makes "
1236  "an empty POST.\n", nextarg);
1237  }
1238 
1239  err = file2memory(&postdata, &size, file);
1240 
1241  if(file && (file != stdin))
1242  fclose(file);
1243  if(err)
1244  return err;
1245  }
1246  else {
1247  GetStr(&postdata, p);
1248  if(postdata)
1249  size = strlen(postdata);
1250  }
1251 
1252  if(!postdata) {
1253  /* no data from the file, point to a zero byte string to make this
1254  get sent as a POST anyway */
1255  postdata = strdup("");
1256  if(!postdata)
1257  return PARAM_NO_MEM;
1258  size = 0;
1259  }
1260  else {
1261  char *enc = curl_easy_escape(config->easy, postdata, (int)size);
1262  Curl_safefree(postdata); /* no matter if it worked or not */
1263  if(enc) {
1264  /* now make a string with the name from above and append the
1265  encoded string */
1266  size_t outlen = nlen + strlen(enc) + 2;
1267  char *n = malloc(outlen);
1268  if(!n) {
1269  curl_free(enc);
1270  return PARAM_NO_MEM;
1271  }
1272  if(nlen > 0) { /* only append '=' if we have a name */
1273  snprintf(n, outlen, "%.*s=%s", nlen, nextarg, enc);
1274  size = outlen-1;
1275  }
1276  else {
1277  strcpy(n, enc);
1278  size = outlen-2; /* since no '=' was inserted */
1279  }
1280  curl_free(enc);
1281  postdata = n;
1282  }
1283  else
1284  return PARAM_NO_MEM;
1285  }
1286  }
1287  else if('@' == *nextarg && !raw_mode) {
1288  /* the data begins with a '@' letter, it means that a file name
1289  or - (stdin) follows */
1290  nextarg++; /* pass the @ */
1291 
1292  if(!strcmp("-", nextarg)) {
1293  file = stdin;
1294  if(subletter == 'b') /* forced data-binary */
1295  set_binmode(stdin);
1296  }
1297  else {
1298  file = fopen(nextarg, "rb");
1299  if(!file)
1300  warnf(global, "Couldn't read data from file \"%s\", this makes "
1301  "an empty POST.\n", nextarg);
1302  }
1303 
1304  if(subletter == 'b')
1305  /* forced binary */
1306  err = file2memory(&postdata, &size, file);
1307  else {
1308  err = file2string(&postdata, file);
1309  if(postdata)
1310  size = strlen(postdata);
1311  }
1312 
1313  if(file && (file != stdin))
1314  fclose(file);
1315  if(err)
1316  return err;
1317 
1318  if(!postdata) {
1319  /* no data from the file, point to a zero byte string to make this
1320  get sent as a POST anyway */
1321  postdata = strdup("");
1322  if(!postdata)
1323  return PARAM_NO_MEM;
1324  }
1325  }
1326  else {
1327  GetStr(&postdata, nextarg);
1328  if(postdata)
1329  size = strlen(postdata);
1330  }
1331 
1332 #ifdef CURL_DOES_CONVERSIONS
1333  if(subletter != 'b') {
1334  /* NOT forced binary, convert to ASCII */
1335  if(convert_to_network(postdata, strlen(postdata))) {
1336  Curl_safefree(postdata);
1337  return PARAM_NO_MEM;
1338  }
1339  }
1340 #endif
1341 
1342  if(config->postfields) {
1343  /* we already have a string, we append this one with a separating
1344  &-letter */
1345  char *oldpost = config->postfields;
1346  curl_off_t oldlen = config->postfieldsize;
1347  curl_off_t newlen = oldlen + curlx_uztoso(size) + 2;
1348  config->postfields = malloc((size_t)newlen);
1349  if(!config->postfields) {
1350  Curl_safefree(oldpost);
1351  Curl_safefree(postdata);
1352  return PARAM_NO_MEM;
1353  }
1354  memcpy(config->postfields, oldpost, (size_t)oldlen);
1355  /* use byte value 0x26 for '&' to accommodate non-ASCII platforms */
1356  config->postfields[oldlen] = '\x26';
1357  memcpy(&config->postfields[oldlen + 1], postdata, size);
1358  config->postfields[oldlen + 1 + size] = '\0';
1359  Curl_safefree(oldpost);
1360  Curl_safefree(postdata);
1361  config->postfieldsize += size + 1;
1362  }
1363  else {
1364  config->postfields = postdata;
1365  config->postfieldsize = curlx_uztoso(size);
1366  }
1367  }
1368  /*
1369  We can't set the request type here, as this data might be used in
1370  a simple GET if -G is used. Already or soon.
1371 
1372  if(SetHTTPrequest(HTTPREQ_SIMPLEPOST, &config->httpreq)) {
1373  Curl_safefree(postdata);
1374  return PARAM_BAD_USE;
1375  }
1376  */
1377  break;
1378  case 'D':
1379  /* dump-header to given file name */
1380  GetStr(&config->headerfile, nextarg);
1381  break;
1382  case 'e':
1383  {
1384  char *ptr = strstr(nextarg, ";auto");
1385  if(ptr) {
1386  /* Automatic referer requested, this may be combined with a
1387  set initial one */
1388  config->autoreferer = TRUE;
1389  *ptr = 0; /* zero terminate here */
1390  }
1391  else
1392  config->autoreferer = FALSE;
1393  GetStr(&config->referer, nextarg);
1394  }
1395  break;
1396  case 'E':
1397  switch(subletter) {
1398  case '\0': /* certificate file */
1399  GetFileAndPassword(nextarg, &config->cert, &config->key_passwd);
1400  break;
1401  case 'a': /* CA info PEM file */
1402  /* CA info PEM file */
1403  GetStr(&config->cacert, nextarg);
1404  break;
1405  case 'b': /* cert file type */
1406  GetStr(&config->cert_type, nextarg);
1407  break;
1408  case 'c': /* private key file */
1409  GetStr(&config->key, nextarg);
1410  break;
1411  case 'd': /* private key file type */
1412  GetStr(&config->key_type, nextarg);
1413  break;
1414  case 'e': /* private key passphrase */
1415  GetStr(&config->key_passwd, nextarg);
1416  cleanarg(nextarg);
1417  break;
1418  case 'f': /* crypto engine */
1419  GetStr(&config->engine, nextarg);
1420  if(config->engine && curl_strequal(config->engine, "list"))
1421  return PARAM_ENGINES_REQUESTED;
1422  break;
1423  case 'g': /* CA info PEM file */
1424  /* CA cert directory */
1425  GetStr(&config->capath, nextarg);
1426  break;
1427  case 'h': /* --pubkey public key file */
1428  GetStr(&config->pubkey, nextarg);
1429  break;
1430  case 'i': /* --hostpubmd5 md5 of the host public key */
1431  GetStr(&config->hostpubmd5, nextarg);
1432  if(!config->hostpubmd5 || strlen(config->hostpubmd5) != 32)
1433  return PARAM_BAD_USE;
1434  break;
1435  case 'j': /* CRL info PEM file */
1436  /* CRL file */
1437  GetStr(&config->crlfile, nextarg);
1438  break;
1439  case 'k': /* TLS username */
1441  GetStr(&config->tls_username, nextarg);
1442  else
1444  break;
1445  case 'l': /* TLS password */
1447  GetStr(&config->tls_password, nextarg);
1448  else
1450  break;
1451  case 'm': /* TLS authentication type */
1453  GetStr(&config->tls_authtype, nextarg);
1454  if(!curl_strequal(config->tls_authtype, "SRP"))
1455  return PARAM_LIBCURL_DOESNT_SUPPORT; /* only support TLS-SRP */
1456  }
1457  else
1459  break;
1460  case 'n': /* no empty SSL fragments, --ssl-allow-beast */
1462  config->ssl_allow_beast = toggle;
1463  break;
1464 
1465  case 'o': /* --login-options */
1466  GetStr(&config->login_options, nextarg);
1467  break;
1468 
1469  case 'p': /* Pinned public key DER file */
1470  /* Pinned public key DER file */
1471  GetStr(&config->pinnedpubkey, nextarg);
1472  break;
1473 
1474  case 'q': /* --cert-status */
1475  config->verifystatus = TRUE;
1476  break;
1477 
1478  case 'r': /* --false-start */
1479  config->falsestart = TRUE;
1480  break;
1481 
1482  case 's': /* --ssl-no-revoke */
1484  config->ssl_no_revoke = TRUE;
1485  break;
1486 
1487  case 't': /* --tcp-fastopen */
1488  config->tcp_fastopen = TRUE;
1489  break;
1490 
1491  case 'u': /* TLS username for proxy */
1493  GetStr(&config->proxy_tls_username, nextarg);
1494  else
1496  break;
1497 
1498  case 'v': /* TLS password for proxy */
1500  GetStr(&config->proxy_tls_password, nextarg);
1501  else
1503  break;
1504 
1505  case 'w': /* TLS authentication type for proxy */
1507  GetStr(&config->proxy_tls_authtype, nextarg);
1508  if(!curl_strequal(config->proxy_tls_authtype, "SRP"))
1509  return PARAM_LIBCURL_DOESNT_SUPPORT; /* only support TLS-SRP */
1510  }
1511  else
1513  break;
1514 
1515  case 'x': /* certificate file for proxy */
1516  GetFileAndPassword(nextarg, &config->proxy_cert,
1517  &config->proxy_key_passwd);
1518  break;
1519 
1520  case 'y': /* cert file type for proxy */
1521  GetStr(&config->proxy_cert_type, nextarg);
1522  break;
1523 
1524  case 'z': /* private key file for proxy */
1525  GetStr(&config->proxy_key, nextarg);
1526  break;
1527 
1528  case '0': /* private key file type for proxy */
1529  GetStr(&config->proxy_key_type, nextarg);
1530  break;
1531 
1532  case '1': /* private key passphrase for proxy */
1533  GetStr(&config->proxy_key_passwd, nextarg);
1534  cleanarg(nextarg);
1535  break;
1536 
1537  case '2': /* ciphers for proxy */
1538  GetStr(&config->proxy_cipher_list, nextarg);
1539  break;
1540 
1541  case '3': /* CRL info PEM file for proxy */
1542  /* CRL file */
1543  GetStr(&config->proxy_crlfile, nextarg);
1544  break;
1545 
1546  case '4': /* no empty SSL fragments for proxy */
1548  config->proxy_ssl_allow_beast = toggle;
1549  break;
1550 
1551  case '5': /* --login-options */
1552  GetStr(&config->login_options, nextarg);
1553  break;
1554 
1555  case '6': /* CA info PEM file for proxy */
1556  /* CA info PEM file */
1557  GetStr(&config->proxy_cacert, nextarg);
1558  break;
1559 
1560  case '7': /* CA info PEM file for proxy */
1561  /* CA cert directory */
1562  GetStr(&config->proxy_capath, nextarg);
1563  break;
1564 
1565  case '8': /* allow insecure SSL connects for proxy */
1566  config->proxy_insecure_ok = toggle;
1567  break;
1568 
1569  case '9': /* --proxy-tlsv1 */
1570  /* TLS version 1 for proxy */
1572  break;
1573 
1574  case 'A':
1575  /* --socks5-basic */
1576  if(toggle)
1577  config->socks5_auth |= CURLAUTH_BASIC;
1578  else
1579  config->socks5_auth &= ~CURLAUTH_BASIC;
1580  break;
1581 
1582  case 'B':
1583  /* --socks5-gssapi */
1584  if(toggle)
1585  config->socks5_auth |= CURLAUTH_GSSAPI;
1586  else
1587  config->socks5_auth &= ~CURLAUTH_GSSAPI;
1588  break;
1589 
1590  default: /* unknown flag */
1591  return PARAM_OPTION_UNKNOWN;
1592  }
1593  break;
1594  case 'f':
1595  switch(subletter) {
1596  case 'a': /* --fail-early */
1597  global->fail_early = toggle;
1598  break;
1599  default:
1600  /* fail hard on errors */
1601  config->failonerror = toggle;
1602  }
1603  break;
1604  case 'F':
1605  /* "form data" simulation, this is a little advanced so lets do our best
1606  to sort this out slowly and carefully */
1607  if(formparse(config,
1608  nextarg,
1609  &config->mimepost,
1610  &config->mimecurrent,
1611  (subletter == 's')?TRUE:FALSE)) /* 's' is literal string */
1612  return PARAM_BAD_USE;
1613  if(SetHTTPrequest(config, HTTPREQ_MIMEPOST, &config->httpreq))
1614  return PARAM_BAD_USE;
1615  break;
1616 
1617  case 'g': /* g disables URLglobbing */
1618  config->globoff = toggle;
1619  break;
1620 
1621  case 'G': /* HTTP GET */
1622  if(subletter == 'a') { /* --request-target */
1623  GetStr(&config->request_target, nextarg);
1624  }
1625  else
1626  config->use_httpget = TRUE;
1627  break;
1628 
1629  case 'h': /* h for help */
1630  if(toggle) {
1631  return PARAM_HELP_REQUESTED;
1632  }
1633  /* we now actually support --no-help too! */
1634  break;
1635  case 'H':
1636  /* A custom header to append to a list */
1637  if(nextarg[0] == '@') {
1638  /* read many headers from a file or stdin */
1639  char *string;
1640  size_t len;
1641  bool use_stdin = !strcmp(&nextarg[1], "-");
1642  FILE *file = use_stdin?stdin:fopen(&nextarg[1], FOPEN_READTEXT);
1643  if(!file)
1644  warnf(global, "Failed to open %s!\n", &nextarg[1]);
1645  else {
1646  err = file2memory(&string, &len, file);
1647  if(!err) {
1648  /* Allow strtok() here since this isn't used threaded */
1649  /* !checksrc! disable BANNEDFUNC 2 */
1650  char *h = strtok(string, "\r\n");
1651  while(h) {
1652  if(subletter == 'p') /* --proxy-header */
1653  err = add2list(&config->proxyheaders, h);
1654  else
1655  err = add2list(&config->headers, h);
1656  if(err)
1657  break;
1658  h = strtok(NULL, "\r\n");
1659  }
1660  free(string);
1661  }
1662  if(!use_stdin)
1663  fclose(file);
1664  if(err)
1665  return err;
1666  }
1667  }
1668  else {
1669  if(subletter == 'p') /* --proxy-header */
1670  err = add2list(&config->proxyheaders, nextarg);
1671  else
1672  err = add2list(&config->headers, nextarg);
1673  if(err)
1674  return err;
1675  }
1676  break;
1677  case 'i':
1678  config->include_headers = toggle; /* include the headers as well in the
1679  general output stream */
1680  break;
1681  case 'j':
1682  config->cookiesession = toggle;
1683  break;
1684  case 'I':
1685  /*
1686  * no_body will imply include_headers later on
1687  */
1688  config->no_body = toggle;
1689  if(SetHTTPrequest(config,
1690  (config->no_body)?HTTPREQ_HEAD:HTTPREQ_GET,
1691  &config->httpreq))
1692  return PARAM_BAD_USE;
1693  break;
1694  case 'J': /* --remote-header-name */
1695  if(config->include_headers) {
1696  warnf(global,
1697  "--include and --remote-header-name cannot be combined.\n");
1698  return PARAM_BAD_USE;
1699  }
1700  config->content_disposition = toggle;
1701  break;
1702  case 'k': /* allow insecure SSL connects */
1703  config->insecure_ok = toggle;
1704  break;
1705  case 'K': /* parse config file */
1706  if(parseconfig(nextarg, global))
1707  warnf(global, "error trying read config from the '%s' file\n",
1708  nextarg);
1709  break;
1710  case 'l':
1711  config->dirlistonly = toggle; /* only list the names of the FTP dir */
1712  break;
1713  case 'L':
1714  config->followlocation = toggle; /* Follow Location: HTTP headers */
1715  switch(subletter) {
1716  case 't':
1717  /* Continue to send authentication (user+password) when following
1718  * locations, even when hostname changed */
1719  config->unrestricted_auth = toggle;
1720  break;
1721  }
1722  break;
1723  case 'm':
1724  /* specified max time */
1725  err = str2udouble(&config->timeout, nextarg, LONG_MAX/1000);
1726  if(err)
1727  return err;
1728  break;
1729  case 'M': /* M for manual, huge help */
1730  if(toggle) { /* --no-manual shows no manual... */
1731 #ifdef USE_MANUAL
1732  return PARAM_MANUAL_REQUESTED;
1733 #else
1734  warnf(global,
1735  "built-in manual was disabled at build-time!\n");
1736  return PARAM_OPTION_UNKNOWN;
1737 #endif
1738  }
1739  break;
1740  case 'n':
1741  switch(subletter) {
1742  case 'o': /* CA info PEM file */
1743  /* use .netrc or URL */
1744  config->netrc_opt = toggle;
1745  break;
1746  case 'e': /* netrc-file */
1747  GetStr(&config->netrc_file, nextarg);
1748  break;
1749  default:
1750  /* pick info from .netrc, if this is used for http, curl will
1751  automatically enfore user+password with the request */
1752  config->netrc = toggle;
1753  break;
1754  }
1755  break;
1756  case 'N':
1757  /* disable the output I/O buffering. note that the option is called
1758  --buffer but is mostly used in the negative form: --no-buffer */
1759  if(longopt)
1760  config->nobuffer = (!toggle)?TRUE:FALSE;
1761  else
1762  config->nobuffer = toggle;
1763  break;
1764  case 'O': /* --remote-name */
1765  if(subletter == 'a') { /* --remote-name-all */
1766  config->default_node_flags = toggle?GETOUT_USEREMOTE:0;
1767  break;
1768  }
1769  /* fall-through! */
1770  case 'o': /* --output */
1771  /* output file */
1772  {
1773  struct getout *url;
1774  if(!config->url_out)
1775  config->url_out = config->url_list;
1776  if(config->url_out) {
1777  /* there's a node here, if it already is filled-in continue to find
1778  an "empty" node */
1779  while(config->url_out && (config->url_out->flags & GETOUT_OUTFILE))
1780  config->url_out = config->url_out->next;
1781  }
1782 
1783  /* now there might or might not be an available node to fill in! */
1784 
1785  if(config->url_out)
1786  /* existing node */
1787  url = config->url_out;
1788  else
1789  /* there was no free node, create one! */
1790  url = new_getout(config);
1791 
1792  if(!url)
1793  return PARAM_NO_MEM;
1794 
1795  /* fill in the outfile */
1796  if('o' == letter) {
1797  GetStr(&url->outfile, nextarg);
1798  url->flags &= ~GETOUT_USEREMOTE; /* switch off */
1799  }
1800  else {
1801  url->outfile = NULL; /* leave it */
1802  if(toggle)
1803  url->flags |= GETOUT_USEREMOTE; /* switch on */
1804  else
1805  url->flags &= ~GETOUT_USEREMOTE; /* switch off */
1806  }
1807  url->flags |= GETOUT_OUTFILE;
1808  }
1809  break;
1810  case 'P':
1811  /* This makes the FTP sessions use PORT instead of PASV */
1812  /* use <eth0> or <192.168.10.10> style addresses. Anything except
1813  this will make us try to get the "default" address.
1814  NOTE: this is a changed behaviour since the released 4.1!
1815  */
1816  GetStr(&config->ftpport, nextarg);
1817  break;
1818  case 'p':
1819  /* proxy tunnel for non-http protocols */
1820  config->proxytunnel = toggle;
1821  break;
1822 
1823  case 'q': /* if used first, already taken care of, we do it like
1824  this so we don't cause an error! */
1825  break;
1826  case 'Q':
1827  /* QUOTE command to send to FTP server */
1828  switch(nextarg[0]) {
1829  case '-':
1830  /* prefixed with a dash makes it a POST TRANSFER one */
1831  nextarg++;
1832  err = add2list(&config->postquote, nextarg);
1833  break;
1834  case '+':
1835  /* prefixed with a plus makes it a just-before-transfer one */
1836  nextarg++;
1837  err = add2list(&config->prequote, nextarg);
1838  break;
1839  default:
1840  err = add2list(&config->quote, nextarg);
1841  break;
1842  }
1843  if(err)
1844  return err;
1845  break;
1846  case 'r':
1847  /* Specifying a range WITHOUT A DASH will create an illegal HTTP range
1848  (and won't actually be range by definition). The man page previously
1849  claimed that to be a good way, why this code is added to work-around
1850  it. */
1851  if(ISDIGIT(*nextarg) && !strchr(nextarg, '-')) {
1852  char buffer[32];
1853  curl_off_t off;
1854  if(curlx_strtoofft(nextarg, NULL, 10, &off)) {
1855  warnf(global, "unsupported range point\n");
1856  return PARAM_BAD_USE;
1857  }
1858  warnf(global,
1859  "A specified range MUST include at least one dash (-). "
1860  "Appending one for you!\n");
1861  snprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-", off);
1862  Curl_safefree(config->range);
1863  config->range = strdup(buffer);
1864  if(!config->range)
1865  return PARAM_NO_MEM;
1866  }
1867  {
1868  /* byte range requested */
1869  char *tmp_range;
1870  tmp_range = nextarg;
1871  while(*tmp_range != '\0') {
1872  if(!ISDIGIT(*tmp_range) && *tmp_range != '-' && *tmp_range != ',') {
1873  warnf(global, "Invalid character is found in given range. "
1874  "A specified range MUST have only digits in "
1875  "\'start\'-\'stop\'. The server's response to this "
1876  "request is uncertain.\n");
1877  break;
1878  }
1879  tmp_range++;
1880  }
1881  /* byte range requested */
1882  GetStr(&config->range, nextarg);
1883  }
1884  break;
1885  case 'R':
1886  /* use remote file's time */
1887  config->remote_time = toggle;
1888  break;
1889  case 's':
1890  /* don't show progress meter, don't show errors : */
1891  if(toggle)
1892  global->mute = global->noprogress = TRUE;
1893  else
1894  global->mute = global->noprogress = FALSE;
1895  if(global->showerror < 0)
1896  /* if still on the default value, set showerror to the reverse of
1897  toggle. This is to allow -S and -s to be used in an independent
1898  order but still have the same effect. */
1899  global->showerror = (!toggle)?TRUE:FALSE; /* toggle off */
1900  break;
1901  case 'S':
1902  /* show errors */
1903  global->showerror = toggle?1:0; /* toggle on if used with -s */
1904  break;
1905  case 't':
1906  /* Telnet options */
1907  err = add2list(&config->telnet_options, nextarg);
1908  if(err)
1909  return err;
1910  break;
1911  case 'T':
1912  /* we are uploading */
1913  {
1914  struct getout *url;
1915  if(!config->url_out)
1916  config->url_out = config->url_list;
1917  if(config->url_out) {
1918  /* there's a node here, if it already is filled-in continue to find
1919  an "empty" node */
1920  while(config->url_out && (config->url_out->flags & GETOUT_UPLOAD))
1921  config->url_out = config->url_out->next;
1922  }
1923 
1924  /* now there might or might not be an available node to fill in! */
1925 
1926  if(config->url_out)
1927  /* existing node */
1928  url = config->url_out;
1929  else
1930  /* there was no free node, create one! */
1931  url = new_getout(config);
1932 
1933  if(!url)
1934  return PARAM_NO_MEM;
1935 
1936  url->flags |= GETOUT_UPLOAD; /* mark -T used */
1937  if(!*nextarg)
1938  url->flags |= GETOUT_NOUPLOAD;
1939  else {
1940  /* "-" equals stdin, but keep the string around for now */
1941  GetStr(&url->infile, nextarg);
1942  }
1943  }
1944  break;
1945  case 'u':
1946  /* user:password */
1947  GetStr(&config->userpwd, nextarg);
1948  cleanarg(nextarg);
1949  break;
1950  case 'U':
1951  /* Proxy user:password */
1952  GetStr(&config->proxyuserpwd, nextarg);
1953  cleanarg(nextarg);
1954  break;
1955  case 'v':
1956  if(toggle) {
1957  /* the '%' thing here will cause the trace get sent to stderr */
1958  Curl_safefree(global->trace_dump);
1959  global->trace_dump = strdup("%");
1960  if(!global->trace_dump)
1961  return PARAM_NO_MEM;
1962  if(global->tracetype && (global->tracetype != TRACE_PLAIN))
1963  warnf(global,
1964  "-v, --verbose overrides an earlier trace/verbose option\n");
1965  global->tracetype = TRACE_PLAIN;
1966  }
1967  else
1968  /* verbose is disabled here */
1969  global->tracetype = TRACE_NONE;
1970  break;
1971  case 'V':
1972  if(toggle) /* --no-version yields no output! */
1974  break;
1975 
1976  case 'w':
1977  /* get the output string */
1978  if('@' == *nextarg) {
1979  /* the data begins with a '@' letter, it means that a file name
1980  or - (stdin) follows */
1981  FILE *file;
1982  const char *fname;
1983  nextarg++; /* pass the @ */
1984  if(!strcmp("-", nextarg)) {
1985  fname = "<stdin>";
1986  file = stdin;
1987  }
1988  else {
1989  fname = nextarg;
1990  file = fopen(nextarg, FOPEN_READTEXT);
1991  }
1992  err = file2string(&config->writeout, file);
1993  if(file && (file != stdin))
1994  fclose(file);
1995  if(err)
1996  return err;
1997  if(!config->writeout)
1998  warnf(global, "Failed to read %s", fname);
1999  }
2000  else
2001  GetStr(&config->writeout, nextarg);
2002  break;
2003  case 'x':
2004  switch(subletter) {
2005  case 'a': /* --preproxy */
2006  GetStr(&config->preproxy, nextarg);
2007  break;
2008  default:
2009  /* --proxy */
2010  GetStr(&config->proxy, nextarg);
2011  config->proxyver = CURLPROXY_HTTP;
2012  break;
2013  }
2014  break;
2015  case 'X':
2016  /* set custom request */
2017  GetStr(&config->customrequest, nextarg);
2018  break;
2019  case 'y':
2020  /* low speed time */
2021  err = str2unum(&config->low_speed_time, nextarg);
2022  if(err)
2023  return err;
2024  if(!config->low_speed_limit)
2025  config->low_speed_limit = 1;
2026  break;
2027  case 'Y':
2028  /* low speed limit */
2029  err = str2unum(&config->low_speed_limit, nextarg);
2030  if(err)
2031  return err;
2032  if(!config->low_speed_time)
2033  config->low_speed_time = 30;
2034  break;
2035  case 'z': /* time condition coming up */
2036  switch(*nextarg) {
2037  case '+':
2038  nextarg++;
2039  /* FALLTHROUGH */
2040  default:
2041  /* If-Modified-Since: (section 14.28 in RFC2068) */
2043  break;
2044  case '-':
2045  /* If-Unmodified-Since: (section 14.24 in RFC2068) */
2047  nextarg++;
2048  break;
2049  case '=':
2050  /* Last-Modified: (section 14.29 in RFC2068) */
2051  config->timecond = CURL_TIMECOND_LASTMOD;
2052  nextarg++;
2053  break;
2054  }
2055  now = time(NULL);
2056  config->condtime = curl_getdate(nextarg, &now);
2057  if(-1 == (int)config->condtime) {
2058  /* now let's see if it is a file name to get the time from instead! */
2059  struct_stat statbuf;
2060  if(-1 == stat(nextarg, &statbuf)) {
2061  /* failed, remove time condition */
2062  config->timecond = CURL_TIMECOND_NONE;
2063  warnf(global,
2064  "Illegal date format for -z, --time-cond (and not "
2065  "a file name). Disabling time condition. "
2066  "See curl_getdate(3) for valid date syntax.\n");
2067  }
2068  else {
2069  /* pull the time out from the file */
2070  config->condtime = statbuf.st_mtime;
2071  }
2072  }
2073  break;
2074  default: /* unknown flag */
2075  return PARAM_OPTION_UNKNOWN;
2076  }
2077  hit = -1;
2078 
2079  } while(!longopt && !singleopt && *++parse && !*usedarg);
2080 
2081  return PARAM_OK;
2082 }
2083 
2085  argv_item_t argv[])
2086 {
2087  int i;
2088  bool stillflags;
2089  char *orig_opt = NULL;
2091  struct OperationConfig *operation = config->first;
2092 
2093  for(i = 1, stillflags = TRUE; i < argc && !result; i++) {
2094  orig_opt = argv[i];
2095 
2096  if(stillflags && ('-' == argv[i][0])) {
2097  char *nextarg;
2098  bool passarg;
2099  char *flag = argv[i];
2100 
2101  if(!strcmp("--", argv[i]))
2102  /* This indicates the end of the flags and thus enables the
2103  following (URL) argument to start with -. */
2104  stillflags = FALSE;
2105  else {
2106  nextarg = (i < (argc - 1)) ? argv[i + 1] : NULL;
2107 
2108  result = getparameter(flag, nextarg, &passarg, config, operation);
2109  if(result == PARAM_NEXT_OPERATION) {
2110  /* Reset result as PARAM_NEXT_OPERATION is only used here and not
2111  returned from this function */
2112  result = PARAM_OK;
2113 
2114  if(operation->url_list && operation->url_list->url) {
2115  /* Allocate the next config */
2116  operation->next = malloc(sizeof(struct OperationConfig));
2117  if(operation->next) {
2118  /* Initialise the newly created config */
2119  config_init(operation->next);
2120 
2121  /* Copy the easy handle */
2122  operation->next->easy = config->easy;
2123 
2124  /* Set the global config pointer */
2125  operation->next->global = config;
2126 
2127  /* Update the last operation pointer */
2128  config->last = operation->next;
2129 
2130  /* Move onto the new config */
2131  operation->next->prev = operation;
2132  operation = operation->next;
2133  }
2134  else
2135  result = PARAM_NO_MEM;
2136  }
2137  }
2138  else if(!result && passarg)
2139  i++; /* we're supposed to skip this */
2140  }
2141  }
2142  else {
2143  bool used;
2144 
2145  /* Just add the URL please */
2146  result = getparameter((char *)"--url", argv[i], &used, config,
2147  operation);
2148  }
2149  }
2150 
2151  if(result && result != PARAM_HELP_REQUESTED &&
2152  result != PARAM_MANUAL_REQUESTED &&
2153  result != PARAM_VERSION_INFO_REQUESTED &&
2154  result != PARAM_ENGINES_REQUESTED) {
2155  const char *reason = param2text(result);
2156 
2157  if(orig_opt && strcmp(":", orig_opt))
2158  helpf(config->errors, "option %s: %s\n", orig_opt, reason);
2159  else
2160  helpf(config->errors, "%s\n", reason);
2161  }
2162 
2163  return result;
2164 }
#define free(ptr)
Definition: curl_memory.h:130
curl_off_t max_filesize
Definition: tool_cfgable.h:68
struct getout * next
Definition: tool_sdecls.h:104
#define GETOUT_USEREMOTE
Definition: tool_sdecls.h:113
#define ISALPHA(x)
curl_off_t postfieldsize
Definition: tool_cfgable.h:63
struct curl_slist * quote
Definition: tool_cfgable.h:162
static void GetFileAndPassword(char *nextarg, char **file, char **password)
int check_protocol(const char *str)
Check if the given string is a protocol supported by libcurl.
double expect100timeout
Definition: tool_cfgable.h:245
CURL_EXTERN void curl_free(void *p)
Definition: escape.c:239
static void parse_cert_parameter(const char *cert_parameter, char **certname, char **passphrase)
struct OperationConfig * prev
Definition: tool_cfgable.h:252
Definition: ws_ssl.c:25
#define CURLAUTH_BASIC
Definition: curl.h:697
#define CURL_VERSION_SSL
Definition: curl.h:2636
char * proxyuserpwd
Definition: tool_cfgable.h:90
#define GetStr(str, val)
Definition: tool_getparam.c:49
ParameterError parse_args(struct GlobalConfig *config, int argc, argv_item_t argv[])
enum LongShort::@37 desc
curl_version_info_data * curlinfo
Definition: tool_libinfo.c:36
CURL_EXTERN char * curl_easy_escape(CURL *handle, const char *string, int length)
#define CURL_VERSION_LIBZ
Definition: curl.h:2637
void cleanarg(char *str)
struct curl_slist * telnet_options
Definition: tool_cfgable.h:175
int stat(const char *path, struct stat *buffer)
unsigned long authtype
Definition: tool_cfgable.h:50
char * dns_ipv6_addr
Definition: tool_cfgable.h:81
char * certname
Definition: unit1394.c:77
char * proxy_service_name
Definition: tool_cfgable.h:193
struct curl_slist * headers
Definition: tool_cfgable.h:171
::std::string string
Definition: gtest-port.h:1129
#define strdup(ptr)
Definition: curl_memory.h:122
UNITTEST_START char * ptr
Definition: unit1330.c:38
struct OperationConfig * last
Definition: tool_cfgable.h:276
struct curl_slist * prequote
Definition: tool_cfgable.h:164
#define CURL_VERSION_TLSAUTH_SRP
Definition: curl.h:2650
ParameterError file2memory(char **bufp, size_t *size, FILE *file)
Definition: tool_paramhlp.c:90
char * customrequest
Definition: tool_cfgable.h:140
struct curltime now
Definition: unit1399.c:83
char * infile
Definition: tool_sdecls.h:107
const char * letter
Definition: tool_getparam.c:62
struct curl_slist * connect_to
Definition: tool_cfgable.h:177
static char * password
Definition: unit1304.c:27
struct GlobalConfig * global
Definition: tool_cfgable.h:251
#define GETOUT_NOUPLOAD
Definition: tool_sdecls.h:115
long proto2num(struct OperationConfig *config, long *val, const char *str)
#define malloc(size)
Definition: curl_memory.h:124
ParameterError file2string(char **bufp, FILE *file)
Definition: tool_paramhlp.c:59
ParameterError str2udouble(double *valp, const char *str, long max)
#define CURLAUTH_GSSAPI
Definition: curl.h:703
void helpf(FILE *errors, const char *fmt,...)
Definition: tool_msgs.c:106
int SetHTTPrequest(struct OperationConfig *config, HttpReq req, HttpReq *store)
Definition: tool_helpers.c:74
UNITTEST_START int result
Definition: unit1304.c:49
const char ** p
Definition: unit1394.c:76
int j
char buffer[]
Definition: unit1308.c:48
char * dns_servers
Definition: tool_cfgable.h:78
static const struct LongShort aliases[]
Definition: tool_getparam.c:71
char * unix_socket_path
Definition: tool_cfgable.h:241
unsigned int i
Definition: unit1303.c:79
#define CURL_VERSION_NTLM
Definition: curl.h:2638
char * ftp_alternative_to_user
Definition: tool_cfgable.h:206
#define FOPEN_READTEXT
Definition: curl_setup.h:732
size_t len
Definition: curl_sasl.c:55
struct curl_slist * resolve
Definition: tool_cfgable.h:176
memcpy(filename, filename1, strlen(filename1))
#define CURLAUTH_NEGOTIATE
Definition: curl.h:699
#define FOPEN_WRITETEXT
Definition: curl_setup.h:733
curl_off_t curlx_uztoso(size_t uznum)
Definition: warnless.c:181
ParameterError str2offset(curl_off_t *val, const char *str)
Parses the given string looking for an offset (which may be a larger-than-integer value)...
struct getout * url_get
Definition: tool_cfgable.h:115
#define GETOUT_URL
Definition: tool_sdecls.h:112
int ftpfilemethod(struct OperationConfig *config, const char *str)
char * proxy_tls_password
Definition: tool_cfgable.h:88
#define FALSE
UNITTEST_START int rc
Definition: unit1301.c:31
bool abstract_unix_socket
Definition: tool_cfgable.h:242
struct getout * url_out
Definition: tool_cfgable.h:116
char * proxy_crlfile
Definition: tool_cfgable.h:128
#define ISDIGIT(x)
CURLofft curlx_strtoofft(const char *str, char **endp, int base, curl_off_t *num)
Definition: strtoofft.c:215
ParameterError
Definition: tool_getparam.h:26
#define GETOUT_UPLOAD
Definition: tool_sdecls.h:114
char * dns_interface
Definition: tool_cfgable.h:79
curl_mime * mimecurrent
Definition: tool_cfgable.h:174
char * outfile
Definition: tool_sdecls.h:106
#define CURL_VERSION_NTLM_WB
Definition: curl.h:2651
ParameterError str2num(long *val, const char *str)
CURL_TYPEOF_CURL_OFF_T curl_off_t
Definition: system.h:420
char * libcurl
Definition: tool_cfgable.h:272
bool content_disposition
Definition: tool_cfgable.h:219
#define argv_item_t
#define CURLAUTH_NTLM
Definition: curl.h:704
struct OperationConfig * next
Definition: tool_cfgable.h:253
char * login_options
Definition: tool_cfgable.h:83
#define set_binmode(x)
Definition: tool_binmode.h:32
curl_mime * mimepost
Definition: tool_cfgable.h:173
CURL_EXTERN int curl_strequal(const char *s1, const char *s2)
Definition: strcase.c:170
bool proto_redir_present
Definition: tool_cfgable.h:59
bool proxy_ssl_allow_beast
Definition: tool_cfgable.h:227
struct curl_slist * postquote
Definition: tool_cfgable.h:163
#define Curl_safefree(ptr)
Definition: memdebug.h:170
char * tls_authtype
Definition: tool_cfgable.h:86
char * proxy_tls_authtype
Definition: tool_cfgable.h:89
struct getout * url_list
Definition: tool_cfgable.h:113
int flags
Definition: tool_sdecls.h:108
char * proxy_cert_type
Definition: tool_cfgable.h:122
int parseconfig(const char *filename, struct GlobalConfig *global)
Definition: tool_parsecfg.c:47
const char * param2text(int res)
Definition: tool_helpers.c:41
struct getout * new_getout(struct OperationConfig *config)
Definition: tool_paramhlp.c:40
ParameterError str2tls_max(long *val, const char *str)
curl_off_t recvpersecond
Definition: tool_cfgable.h:182
char * url
Definition: tool_sdecls.h:105
struct curl_slist * proxyheaders
Definition: tool_cfgable.h:172
int ftpcccmethod(struct OperationConfig *config, const char *str)
char * dns_ipv4_addr
Definition: tool_cfgable.h:80
curl_TimeCond timecond
Definition: tool_cfgable.h:169
CURL_EXTERN time_t curl_getdate(const char *p, const time_t *unused)
Definition: parsedate.c:548
#define GETOUT_OUTFILE
Definition: tool_sdecls.h:111
unsigned long socks5_auth
Definition: tool_cfgable.h:192
char * proxy_key_type
Definition: tool_cfgable.h:133
ParameterError add2list(struct curl_slist **list, const char *ptr)
char * passphrase
Definition: unit1394.c:77
char * trace_dump
Definition: tool_cfgable.h:266
const char * lname
Definition: tool_getparam.c:63
UNITTEST_START int * value
Definition: unit1602.c:51
curl_off_t resume_from
Definition: tool_cfgable.h:61
char * tls_username
Definition: tool_cfgable.h:84
#define CURLAUTH_DIGEST
Definition: curl.h:698
curl_off_t sendpersecond
Definition: tool_cfgable.h:181
int formparse(struct OperationConfig *config, const char *input, curl_mime **mimepost, curl_mime **mimecurrent, bool literal_value)
size_t size
Definition: unit1302.c:52
#define snprintf
Definition: curl_printf.h:42
#define TRUE
char * proto_default
Definition: tool_cfgable.h:60
char * request_target
Definition: tool_cfgable.h:142
bool resume_from_current
Definition: tool_cfgable.h:52
bool errors_fopened
Definition: tool_cfgable.h:265
#define CURL_PROGRESS_STATS
Definition: tool_cb_prg.h:26
void warnf(struct GlobalConfig *config, const char *fmt,...)
Definition: tool_msgs.c:95
#define CURLAUTH_ANY
Definition: curl.h:708
char * proxy_cipher_list
Definition: tool_cfgable.h:118
#define CURLAUTH_NTLM_WB
Definition: curl.h:706
char * proxy_key_passwd
Definition: tool_cfgable.h:135
void config_init(struct OperationConfig *config)
Definition: tool_cfgable.c:29
char * tls_password
Definition: tool_cfgable.h:85
bool suppress_connect_headers
Definition: tool_cfgable.h:246
#define CURL_PROGRESS_BAR
Definition: tool_cb_prg.h:27
CURL_EXTERN int curl_strnequal(const char *s1, const char *s2, size_t n)
Definition: strcase.c:174
ParameterError getparameter(const char *flag, char *nextarg, bool *usedarg, struct GlobalConfig *global, struct OperationConfig *config)
long delegation(struct OperationConfig *config, char *str)
ParameterError str2unum(long *val, const char *str)
#define CURL_VERSION_KERBEROS4
Definition: curl.h:2634
struct OperationConfig * first
Definition: tool_cfgable.h:274
#define struct_stat
Definition: curl_setup.h:385
char * random_file
Definition: tool_cfgable.h:41
double connecttimeout
Definition: tool_cfgable.h:66
#define CURL_VERSION_SPNEGO
Definition: curl.h:2643
char * proxy_tls_username
Definition: tool_cfgable.h:87
struct curl_slist * mail_rcpt
Definition: tool_cfgable.h:95
#define CURL_FORMAT_CURL_OFF_T
Definition: system.h:373


rc_tagdetect_client
Author(s): Monika Florek-Jasinska , Raphael Schaller
autogenerated on Sat Feb 13 2021 03:42:16