Newer
Older
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;
}
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
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;
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
1105
1106
1107
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
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("");
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
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
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) {
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
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;
}
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
*/
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"))
return PARAM_ENGINES_REQUESTED;
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
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;
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
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
}
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) {
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, global))
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);
break;
case 'M': /* M for manual, huge help */
if(toggle) { /* --no-manual shows no manual... */
#ifdef USE_MANUAL
return PARAM_MANUAL_REQUESTED;
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
#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 {
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
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
/* 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);
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
}
{
/* 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 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. */
global->showerror = (!toggle)?TRUE:FALSE; /* toggle off */
break;
case 'S':
/* show errors */
global->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;
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':
if(toggle) /* --no-version yields no output! */
return PARAM_VERSION_INFO_REQUESTED;
break;
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
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;
1751
1752
1753
1754
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
1797
1798
1799
1800
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 GlobalConfig *config, int argc,
argv_item_t argv[])
{
int i;
bool stillflags;
char *orig_opt;
ParameterError result = PARAM_OK;
struct OperationConfig *operation = config->first;
for(i = 1, stillflags = TRUE; i < argc && !result; i++) {
orig_opt = argv[i];
if(curlx_strequal(":", argv[i]) &&
(operation->url_list && operation->url_list->url)) {
/* Allocate the next config */
operation->next = malloc(sizeof(struct OperationConfig));
if(operation->next) {
/* Initialise the newly created config */
config_init(operation->next);
/* Copy the easy handle */
operation->next->easy = config->easy;
/* Update the last operation pointer */
config->last = operation->next;
/* Move onto the new config */
operation->next->prev = operation;
operation = operation->next;
/* Reset the flag indicator */
stillflags = TRUE;
}
else
result = PARAM_NO_MEM;
}
else if(stillflags && ('-' == argv[i][0])) {
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, operation);
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, operation);
}
}
if(result && result != PARAM_HELP_REQUESTED &&
result != PARAM_MANUAL_REQUESTED &&
result != PARAM_VERSION_INFO_REQUESTED &&
result != PARAM_ENGINES_REQUESTED) {
const char *reason = param2text(result);
if(!curlx_strequal(":", orig_opt))
helpf(operation->errors, "option %s: %s\n", orig_opt, reason);
helpf(operation->errors, "%s\n", reason);
}
return result;
}