1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-13 13:05:03 -05:00

Kevin P Roth's idea of supporting multiple -d options was turned into reality

This commit is contained in:
Daniel Stenberg 2000-10-26 07:06:52 +00:00
parent 949eaf8ad4
commit 68c231e1b0

View File

@ -686,6 +686,9 @@ static int getparameter(char *flag, /* f or -long-flag */
break; break;
case 'd': case 'd':
/* postfield data */ /* postfield data */
{
char *postdata=NULL;
if('@' == *nextarg) { if('@' == *nextarg) {
/* the data begins with a '@' letter, it means that a file name /* the data begins with a '@' letter, it means that a file name
or - (stdin) follows */ or - (stdin) follows */
@ -700,14 +703,26 @@ static int getparameter(char *flag, /* f or -long-flag */
file = fopen(nextarg, "r"); file = fopen(nextarg, "r");
if(subletter == 'b') /* forced binary */ if(subletter == 'b') /* forced binary */
config->postfields = file2memory(file, &config->postfieldsize); postdata = file2memory(file, &config->postfieldsize);
else else
config->postfields = file2string(file); postdata = file2string(file);
if(file && (file != stdin)) if(file && (file != stdin))
fclose(stdin); fclose(stdin);
} }
else { else {
GetStr(&config->postfields, nextarg); GetStr(&postdata, nextarg);
}
if(config->postfields && *config->postfields) {
/* we already have a string, we append this one
with a separating &-letter */
char *oldpost=config->postfields;
config->postfields=maprintf("%s&%s", oldpost, postdata);
free(oldpost);
free(postdata);
}
else
config->postfields=postdata;
} }
if(config->postfields) if(config->postfields)
config->conf |= CONF_POST; config->conf |= CONF_POST;