Newer
Older
case 'K': /* --sasl-ir */
config->sasl_ir = toggle;
case 'L': /* --test-event */
#ifdef CURLDEBUG
config->test_event_based = toggle;
#else
warnf(config, "--test-event is ignored unless a debug build!\n");
#endif
break;
}
break;
case '#': /* --progress-bar */
if(toggle)
config->progressmode = CURL_PROGRESS_BAR;
else
config->progressmode = CURL_PROGRESS_STATS;
break;
case '~': /* --xattr */
config->xattr = toggle;
break;
case '0': /* --http* options */
switch(subletter) {
/* HTTP version 1.0 */
config->httpversion = CURL_HTTP_VERSION_1_0;
break;
case '1':
/* HTTP version 1.1 */
config->httpversion = CURL_HTTP_VERSION_1_1;
break;
case '2':
/* HTTP version 2.0 */
config->httpversion = CURL_HTTP_VERSION_2_0;
break;
}
case '1': /* --tlsv1* options */
switch(subletter) {
case '\0':
/* TLS version 1.x */
config->ssl_version = CURL_SSLVERSION_TLSv1;
break;
case '0':
/* TLS version 1.0 */
config->ssl_version = CURL_SSLVERSION_TLSv1_0;
break;
case '1':
/* TLS version 1.1 */
config->ssl_version = CURL_SSLVERSION_TLSv1_1;
break;
case '2':
/* TLS version 1.2 */
config->ssl_version = CURL_SSLVERSION_TLSv1_2;
break;
}
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
break;
case '2':
/* SSL version 2 */
config->ssl_version = CURL_SSLVERSION_SSLv2;
break;
case '3':
/* SSL version 3 */
config->ssl_version = CURL_SSLVERSION_SSLv3;
break;
case '4':
/* IPv4 */
config->ip_version = 4;
break;
case '6':
/* IPv6 */
config->ip_version = 6;
break;
case 'a':
/* This makes the FTP sessions use APPE instead of STOR */
config->ftp_append = toggle;
break;
case 'A':
/* This specifies the User-Agent name */
GetStr(&config->useragent, nextarg);
break;
case 'b': /* cookie string coming up: */
if(nextarg[0] == '@') {
nextarg++;
}
else if(strchr(nextarg, '=')) {
/* A cookie string must have a =-letter */
GetStr(&config->cookie, nextarg);
break;
}
/* We have a cookie file to read from! */
GetStr(&config->cookiefile, nextarg);
break;
case 'B':
/* use ASCII/text when transferring */
config->use_ascii = toggle;
break;
case 'c':
/* get the file name to dump all cookies in */
GetStr(&config->cookiejar, nextarg);
break;
case 'C':
/* This makes us continue an ftp transfer at given position */
if(!curlx_strequal(nextarg, "-")) {
err = str2offset(&config->resume_from, nextarg);
if(err)
return err;
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
config->resume_from_current = FALSE;
}
else {
config->resume_from_current = TRUE;
config->resume_from = 0;
}
config->use_resume=TRUE;
break;
case 'd':
/* postfield data */
{
char *postdata = NULL;
FILE *file;
size_t size = 0;
if(subletter == 'e') { /* --data-urlencode*/
/* [name]=[content], we encode the content part only
* [name]@[file name]
*
* Case 2: we first load the file using that name and then encode
* the content.
*/
const char *p = strchr(nextarg, '=');
size_t nlen;
char is_file;
if(!p)
/* there was no '=' letter, check for a '@' instead */
p = strchr(nextarg, '@');
if(p) {
nlen = p - nextarg; /* length of the name part */
is_file = *p++; /* pass the separator */
}
else {
/* neither @ nor =, so no name and it isn't a file */
nlen = is_file = 0;
p = nextarg;
}
if('@' == is_file) {
/* a '@' letter, it means that a file name or - (stdin) follows */
if(curlx_strequal("-", p)) {
file = stdin;
set_binmode(stdin);
}
else {
file = fopen(p, "rb");
if(!file)
warnf(config,
"Couldn't read data from file \"%s\", this makes "
"an empty POST.\n", nextarg);
}
err = file2memory(&postdata, &size, file);
if(file && (file != stdin))
fclose(file);
if(err)
return err;
}
else {
GetStr(&postdata, p);
}
if(!postdata) {
/* no data from the file, point to a zero byte string to make this
get sent as a POST anyway */
postdata = strdup("");
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
size = 0;
}
else {
char *enc = curl_easy_escape(config->easy, postdata, (int)size);
Curl_safefree(postdata); /* no matter if it worked or not */
if(enc) {
/* now make a string with the name from above and append the
encoded string */
size_t outlen = nlen + strlen(enc) + 2;
char *n = malloc(outlen);
if(!n) {
curl_free(enc);
return PARAM_NO_MEM;
}
if(nlen > 0) { /* only append '=' if we have a name */
snprintf(n, outlen, "%.*s=%s", nlen, nextarg, enc);
size = outlen-1;
}
else {
strcpy(n, enc);
size = outlen-2; /* since no '=' was inserted */
}
curl_free(enc);
postdata = n;
}
else
return PARAM_NO_MEM;
}
}
else if('@' == *nextarg) {
/* the data begins with a '@' letter, it means that a file name
or - (stdin) follows */
nextarg++; /* pass the @ */
if(curlx_strequal("-", nextarg)) {
file = stdin;
if(subletter == 'b') /* forced data-binary */
set_binmode(stdin);
}
else {
file = fopen(nextarg, "rb");
if(!file)
warnf(config, "Couldn't read data from file \"%s\", this makes "
"an empty POST.\n", nextarg);
}
if(subletter == 'b')
/* forced binary */
err = file2memory(&postdata, &size, file);
else {
err = file2string(&postdata, file);
if(postdata)
size = strlen(postdata);
}
if(file && (file != stdin))
fclose(file);
if(err)
return err;
if(!postdata) {
/* no data from the file, point to a zero byte string to make this
get sent as a POST anyway */
postdata = strdup("");
if(!postdata)
return PARAM_NO_MEM;
}
}
else {
GetStr(&postdata, nextarg);
}
#ifdef CURL_DOES_CONVERSIONS
if(subletter != 'b') {
/* NOT forced binary, convert to ASCII */
if(convert_to_network(postdata, strlen(postdata))) {
Curl_safefree(postdata);
return PARAM_NO_MEM;
}
}
#endif
if(config->postfields) {
/* we already have a string, we append this one with a separating
&-letter */
char *oldpost = config->postfields;
curl_off_t oldlen = config->postfieldsize;
curl_off_t newlen = oldlen + size + 2;
config->postfields = malloc((size_t)newlen);
if(!config->postfields) {
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
Curl_safefree(postdata);
return PARAM_NO_MEM;
}
memcpy(config->postfields, oldpost, (size_t)oldlen);
/* use byte value 0x26 for '&' to accommodate non-ASCII platforms */
config->postfields[oldlen] = '\x26';
memcpy(&config->postfields[oldlen+1], postdata, size);
config->postfields[oldlen+1+size] = '\0';
Curl_safefree(oldpost);
Curl_safefree(postdata);
config->postfieldsize += size+1;
}
else {
config->postfields = postdata;
config->postfieldsize = size;
}
}
/*
We can't set the request type here, as this data might be used in
a simple GET if -G is used. Already or soon.
if(SetHTTPrequest(HTTPREQ_SIMPLEPOST, &config->httpreq)) {
Curl_safefree(postdata);
return PARAM_BAD_USE;
}
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
*/
break;
case 'D':
/* dump-header to given file name */
GetStr(&config->headerfile, nextarg);
break;
case 'e':
{
char *ptr = strstr(nextarg, ";auto");
if(ptr) {
/* Automatic referer requested, this may be combined with a
set initial one */
config->autoreferer = TRUE;
*ptr = 0; /* zero terminate here */
}
else
config->autoreferer = FALSE;
GetStr(&config->referer, nextarg);
}
break;
case 'E':
switch(subletter) {
case 'a': /* CA info PEM file */
/* CA info PEM file */
GetStr(&config->cacert, nextarg);
break;
case 'b': /* cert file type */
GetStr(&config->cert_type, nextarg);
break;
case 'c': /* private key file */
GetStr(&config->key, nextarg);
break;
case 'd': /* private key file type */
GetStr(&config->key_type, nextarg);
break;
case 'e': /* private key passphrase */
GetStr(&config->key_passwd, nextarg);
cleanarg(nextarg);
break;
case 'f': /* crypto engine */
GetStr(&config->engine, nextarg);
if(config->engine && curlx_raw_equal(config->engine,"list"))
config->list_engines = TRUE;
break;
case 'g': /* CA info PEM file */
/* CA cert directory */
GetStr(&config->capath, nextarg);
break;
case 'h': /* --pubkey public key file */
GetStr(&config->pubkey, nextarg);
break;
case 'i': /* --hostpubmd5 md5 of the host public key */
GetStr(&config->hostpubmd5, nextarg);
if(!config->hostpubmd5 || strlen(config->hostpubmd5) != 32)
return PARAM_BAD_USE;
break;
case 'j': /* CRL info PEM file */
/* CRL file */
GetStr(&config->crlfile, nextarg);
break;
case 'k': /* TLS username */
if(curlinfo->features & CURL_VERSION_TLSAUTH_SRP)
GetStr(&config->tls_username, nextarg);
else
return PARAM_LIBCURL_DOESNT_SUPPORT;
break;
case 'l': /* TLS password */
if(curlinfo->features & CURL_VERSION_TLSAUTH_SRP)
GetStr(&config->tls_password, nextarg);
else
return PARAM_LIBCURL_DOESNT_SUPPORT;
break;
case 'm': /* TLS authentication type */
if(curlinfo->features & CURL_VERSION_TLSAUTH_SRP) {
GetStr(&config->tls_authtype, nextarg);
if(!strequal(config->tls_authtype, "SRP"))
return PARAM_LIBCURL_DOESNT_SUPPORT; /* only support TLS-SRP */
}
else
return PARAM_LIBCURL_DOESNT_SUPPORT;
break;
case 'n': /* no empty SSL fragments, --ssl-allow-beast */
if(curlinfo->features & CURL_VERSION_SSL)
config->ssl_allow_beast = toggle;
break;
case 'o': /* --login-options */
GetStr(&config->login_options, nextarg);
break;
default: /* certificate file */
{
char *certname, *passphrase;
parse_cert_parameter(nextarg, &certname, &passphrase);
Curl_safefree(config->cert);
config->cert = certname;
Curl_safefree(config->key_passwd);
config->key_passwd = passphrase;
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
}
cleanarg(nextarg);
}
}
break;
case 'f':
/* fail hard on errors */
config->failonerror = toggle;
break;
case 'F':
/* "form data" simulation, this is a little advanced so lets do our best
to sort this out slowly and carefully */
if(formparse(config,
nextarg,
&config->httppost,
&config->last_post,
(subletter=='s')?TRUE:FALSE)) /* 's' means literal string */
return PARAM_BAD_USE;
if(SetHTTPrequest(config, HTTPREQ_POST, &config->httpreq))
return PARAM_BAD_USE;
break;
case 'g': /* g disables URLglobbing */
config->globoff = toggle;
break;
case 'G': /* HTTP GET */
config->use_httpget = TRUE;
break;
case 'h': /* h for help */
if(toggle) {
tool_help();
return PARAM_HELP_REQUESTED;
}
/* we now actually support --no-help too! */
break;
case 'H':
/* A custom header to append to a list */
err = add2list(&config->headers, nextarg);
if(err)
return err;
break;
case 'i':
config->include_headers = toggle; /* include the headers as well in the
general output stream */
break;
case 'j':
config->cookiesession = toggle;
break;
case 'I':
/*
* no_body will imply include_headers later on
*/
config->no_body = toggle;
if(SetHTTPrequest(config,
(config->no_body)?HTTPREQ_HEAD:HTTPREQ_GET,
&config->httpreq))
return PARAM_BAD_USE;
break;
case 'J': /* --remote-header-name */
if(config->include_headers) {
warnf(config,
"--include and --remote-header-name cannot be combined.\n");
return PARAM_BAD_USE;
}
config->content_disposition = toggle;
break;
case 'k': /* allow insecure SSL connects */
config->insecure_ok = toggle;
break;
case 'K': /* parse config file */
if(parseconfig(nextarg, config))
warnf(config, "error trying read config from the '%s' file\n",
nextarg);
break;
case 'l':
config->dirlistonly = toggle; /* only list the names of the FTP dir */
break;
case 'L':
config->followlocation = toggle; /* Follow Location: HTTP headers */
switch (subletter) {
case 't':
/* Continue to send authentication (user+password) when following
* locations, even when hostname changed */
config->unrestricted_auth = toggle;
break;
}
break;
case 'm':
/* specified max time */
err = str2udouble(&config->timeout, nextarg);
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
break;
case 'M': /* M for manual, huge help */
if(toggle) { /* --no-manual shows no manual... */
#ifdef USE_MANUAL
hugehelp();
return PARAM_HELP_REQUESTED;
#else
warnf(config,
"built-in manual was disabled at build-time!\n");
return PARAM_OPTION_UNKNOWN;
#endif
}
break;
case 'n':
switch(subletter) {
case 'o': /* CA info PEM file */
/* use .netrc or URL */
config->netrc_opt = toggle;
break;
case 'e': /* netrc-file */
GetStr(&config->netrc_file, nextarg);
break;
default:
/* pick info from .netrc, if this is used for http, curl will
automatically enfore user+password with the request */
config->netrc = toggle;
break;
}
break;
case 'N':
/* disable the output I/O buffering. note that the option is called
--buffer but is mostly used in the negative form: --no-buffer */
if(longopt)
config->nobuffer = (!toggle)?TRUE:FALSE;
else
config->nobuffer = toggle;
break;
case 'O': /* --remote-name */
if(subletter == 'a') { /* --remote-name-all */
config->default_node_flags = toggle?GETOUT_USEREMOTE:0;
break;
}
/* fall-through! */
case 'o': /* --output */
/* output file */
{
struct getout *url;
if(config->url_out || ((config->url_out = config->url_list) != NULL)) {
/* there's a node here, if it already is filled-in continue to find
an "empty" node */
while(config->url_out && (config->url_out->flags & GETOUT_OUTFILE))
config->url_out = config->url_out->next;
}
/* now there might or might not be an available node to fill in! */
if(config->url_out)
/* existing node */
url = config->url_out;
else
/* there was no free node, create one! */
url = new_getout(config);
if(!url)
return PARAM_NO_MEM;
else {
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
/* fill in the outfile */
if('o' == letter) {
GetStr(&url->outfile, nextarg);
url->flags &= ~GETOUT_USEREMOTE; /* switch off */
}
else {
url->outfile = NULL; /* leave it */
if(toggle)
url->flags |= GETOUT_USEREMOTE; /* switch on */
else
url->flags &= ~GETOUT_USEREMOTE; /* switch off */
}
url->flags |= GETOUT_OUTFILE;
}
}
break;
case 'P':
/* This makes the FTP sessions use PORT instead of PASV */
/* use <eth0> or <192.168.10.10> style addresses. Anything except
this will make us try to get the "default" address.
NOTE: this is a changed behaviour since the released 4.1!
*/
GetStr(&config->ftpport, nextarg);
break;
case 'p':
/* proxy tunnel for non-http protocols */
config->proxytunnel = toggle;
break;
case 'q': /* if used first, already taken care of, we do it like
this so we don't cause an error! */
break;
case 'Q':
/* QUOTE command to send to FTP server */
switch(nextarg[0]) {
case '-':
/* prefixed with a dash makes it a POST TRANSFER one */
nextarg++;
err = add2list(&config->postquote, nextarg);
break;
case '+':
/* prefixed with a plus makes it a just-before-transfer one */
nextarg++;
err = add2list(&config->prequote, nextarg);
break;
default:
err = add2list(&config->quote, nextarg);
break;
}
if(err)
return err;
break;
case 'r':
/* Specifying a range WITHOUT A DASH will create an illegal HTTP range
(and won't actually be range by definition). The man page previously
claimed that to be a good way, why this code is added to work-around
it. */
if(ISDIGIT(*nextarg) && !strchr(nextarg, '-')) {
char buffer[32];
curl_off_t off;
warnf(config,
"A specified range MUST include at least one dash (-). "
"Appending one for you!\n");
off = curlx_strtoofft(nextarg, NULL, 10);
snprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-", off);
Curl_safefree(config->range);
config->range = strdup(buffer);
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
}
{
/* byte range requested */
char *tmp_range;
tmp_range = nextarg;
while(*tmp_range != '\0') {
if(!ISDIGIT(*tmp_range) && *tmp_range != '-' && *tmp_range != ',') {
warnf(config,"Invalid character is found in given range. "
"A specified range MUST have only digits in "
"\'start\'-\'stop\'. The server's response to this "
"request is uncertain.\n");
break;
}
tmp_range++;
}
/* byte range requested */
GetStr(&config->range, nextarg);
}
break;
case 'R':
/* use remote file's time */
config->remote_time = toggle;
break;
case 's':
/* don't show progress meter, don't show errors : */
if(toggle)
config->mute = config->noprogress = TRUE;
else
config->mute = config->noprogress = FALSE;
if(config->showerror < 0)
/* if still on the default value, set showerror to the reverse of
toggle. This is to allow -S and -s to be used in an independent
order but still have the same effect. */
config->showerror = (!toggle)?TRUE:FALSE; /* toggle off */
break;
case 'S':
/* show errors */
config->showerror = toggle?1:0; /* toggle on if used with -s */
break;
case 't':
/* Telnet options */
err = add2list(&config->telnet_options, nextarg);
if(err)
return err;
break;
case 'T':
/* we are uploading */
{
struct getout *url;
if(config->url_out || ((config->url_out = config->url_list) != NULL)) {
/* there's a node here, if it already is filled-in continue to find
an "empty" node */
while(config->url_out && (config->url_out->flags & GETOUT_UPLOAD))
config->url_out = config->url_out->next;
}
/* now there might or might not be an available node to fill in! */
if(config->url_out)
/* existing node */
url = config->url_out;
else
/* there was no free node, create one! */
url = new_getout(config);
if(!url)
return PARAM_NO_MEM;
else {
url->flags |= GETOUT_UPLOAD; /* mark -T used */
if(!*nextarg)
url->flags |= GETOUT_NOUPLOAD;
else {
/* "-" equals stdin, but keep the string around for now */
GetStr(&url->infile, nextarg);
}
}
}
break;
case 'u':
/* user:password */
GetStr(&config->userpwd, nextarg);
cleanarg(nextarg);
break;
case 'U':
/* Proxy user:password */
GetStr(&config->proxyuserpwd, nextarg);
cleanarg(nextarg);
break;
case 'v':
if(toggle) {
/* the '%' thing here will cause the trace get sent to stderr */
Curl_safefree(config->trace_dump);
config->trace_dump = strdup("%");
if(!config->trace_dump)
return PARAM_NO_MEM;
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
if(config->tracetype && (config->tracetype != TRACE_PLAIN))
warnf(config,
"-v, --verbose overrides an earlier trace/verbose option\n");
config->tracetype = TRACE_PLAIN;
}
else
/* verbose is disabled here */
config->tracetype = TRACE_NONE;
break;
case 'V':
{
const char *const *proto;
if(!toggle)
/* --no-version yields no output! */
break;
printf(CURL_ID "%s\n", curl_version());
if(curlinfo->protocols) {
printf("Protocols: ");
for(proto = curlinfo->protocols; *proto; ++proto) {
printf("%s ", *proto);
}
puts(""); /* newline */
}
if(curlinfo->features) {
unsigned int i;
printf("Features: ");
for(i = 0; i < sizeof(feats)/sizeof(feats[0]); i++) {
if(curlinfo->features & feats[i].bitmask)
printf("%s ", feats[i].name);
}
printf("Metalink ");
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
puts(""); /* newline */
}
}
return PARAM_HELP_REQUESTED;
case 'w':
/* get the output string */
if('@' == *nextarg) {
/* the data begins with a '@' letter, it means that a file name
or - (stdin) follows */
FILE *file;
const char *fname;
nextarg++; /* pass the @ */
if(curlx_strequal("-", nextarg)) {
fname = "<stdin>";
file = stdin;
}
else {
fname = nextarg;
file = fopen(nextarg, "r");
}
err = file2string(&config->writeout, file);
if(file && (file != stdin))
fclose(file);
if(err)
return err;
if(!config->writeout)
warnf(config, "Failed to read %s", fname);
}
else
GetStr(&config->writeout, nextarg);
break;
case 'x':
/* proxy */
GetStr(&config->proxy, nextarg);
config->proxyver = CURLPROXY_HTTP;
break;
case 'X':
/* set custom request */
GetStr(&config->customrequest, nextarg);
break;
case 'y':
/* low speed time */
err = str2unum(&config->low_speed_time, nextarg);
if(err)
return err;
if(!config->low_speed_limit)
config->low_speed_limit = 1;
break;
case 'Y':
/* low speed limit */
err = str2unum(&config->low_speed_limit, nextarg);
if(err)
return err;
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
if(!config->low_speed_time)
config->low_speed_time = 30;
break;
case 'z': /* time condition coming up */
switch(*nextarg) {
case '+':
nextarg++;
default:
/* If-Modified-Since: (section 14.28 in RFC2068) */
config->timecond = CURL_TIMECOND_IFMODSINCE;
break;
case '-':
/* If-Unmodified-Since: (section 14.24 in RFC2068) */
config->timecond = CURL_TIMECOND_IFUNMODSINCE;
nextarg++;
break;
case '=':
/* Last-Modified: (section 14.29 in RFC2068) */
config->timecond = CURL_TIMECOND_LASTMOD;
nextarg++;
break;
}
now = time(NULL);
config->condtime=curl_getdate(nextarg, &now);
if(-1 == (int)config->condtime) {
/* now let's see if it is a file name to get the time from instead! */
struct_stat statbuf;
if(-1 == stat(nextarg, &statbuf)) {
/* failed, remove time condition */
config->timecond = CURL_TIMECOND_NONE;
warnf(config,
"Illegal date format for -z, --timecond (and not "
"a file name). Disabling time condition. "
"See curl_getdate(3) for valid date syntax.\n");
}
else {
/* pull the time out from the file */
config->condtime = statbuf.st_mtime;
}
}
break;
default: /* unknown flag */
return PARAM_OPTION_UNKNOWN;
}
hit = -1;
} while(!longopt && !singleopt && *++parse && !*usedarg);
return PARAM_OK;
}
ParameterError parse_args(struct Configurable *config, int argc,
argv_item_t argv[])
{
int i;
bool stillflags;
char *orig_opt;
ParameterError result = PARAM_OK;
for(i = 1, stillflags = TRUE; i < argc && !result; i++) {
orig_opt = argv[i];
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
if(curlx_strequal(":", argv[i]) &&
((config->url_list && config->url_list->url) || config->list_engines)) {
/* Allocate the next config */
config->next = malloc(sizeof(struct Configurable));
if(config->next) {
/* Initialise the newly created config */
config_init(config->next);
/* Copy the easy handle */
config->next->easy = config->easy;
/* Move onto the new config */
config->next->prev = config;
config = config->next;
/* Reset the flag indicator */
stillflags = TRUE;
}
else
result = PARAM_NO_MEM;
}
else if(stillflags && ('-' == argv[i][0])) {
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
char *nextarg;
bool passarg;
char *flag = argv[i];
if(curlx_strequal("--", argv[i]))
/* This indicates the end of the flags and thus enables the
following (URL) argument to start with -. */
stillflags = FALSE;
else {
nextarg = (i < (argc - 1)) ? argv[i + 1] : NULL;
result = getparameter(flag, nextarg, &passarg, config);
if(!result && passarg)
i++; /* we're supposed to skip this */
}
}
else {
bool used;
/* Just add the URL please */
result = getparameter((char *)"--url", argv[i], &used, config);
}
}
if(result && result != PARAM_HELP_REQUESTED) {
const char *reason = param2text(result);
if(!curlx_strequal(":", orig_opt))
helpf(config->errors, "option %s: %s\n", orig_opt, reason);
else
helpf(config->errors, "%s\n", reason);
}
return result;
}