Newer
Older
if(err)
return err;
break;
case 'r':
/* byte range requested */
GetStr(&config->range, nextarg);
break;
case 'R':
/* use remote file's time */
config->remote_time ^= TRUE;
break;
case 's':
/* don't show progress meter, don't show errors : */
config->conf |= (CONF_MUTE|CONF_NOPROGRESS);
config->showerror ^= TRUE; /* toggle off */
break;
case 'S':
/* show errors */
config->showerror ^= TRUE; /* toggle on if used with -s */
break;
case 't':
err = add2list(&config->telnet_options, nextarg);
if(err)
return err;
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
{
struct getout *url;
if(config->url_out || (config->url_out=config->url_list)) {
/* 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) {
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);
checkpasswd("host", &config->userpwd);
break;
case 'U':
/* Proxy user:password */
GetStr(&config->proxyuserpwd, nextarg);
cleanarg(nextarg);
checkpasswd("proxy", &config->proxyuserpwd);
break;
case 'v':
config->conf ^= CONF_VERBOSE; /* talk a lot */
break;
case 'V':
{
const char * const *proto;
if (curlinfo->protocols) {
printf("Protocols: ");
for (proto=curlinfo->protocols; *proto; ++proto) {
printf("%s ", *proto);
}
puts(""); /* newline */
}
if(curlinfo->features) {
unsigned int i;
struct feat {
const char *name;
int bitmask;
};
{"AsynchDNS", CURL_VERSION_ASYNCHDNS},
{"Debug", CURL_VERSION_DEBUG},
{"GSS-Negotiate", CURL_VERSION_GSSNEGOTIATE},
{"IDN", CURL_VERSION_IDN},
{"Largefile", CURL_VERSION_LARGEFILE},
{"SPNEGO", CURL_VERSION_SPNEGO},
{"SSL", CURL_VERSION_SSL},
{"krb4", CURL_VERSION_KERBEROS4},
{"libz", CURL_VERSION_LIBZ}
};
printf("Features: ");
for(i=0; i<sizeof(feats)/sizeof(feats[0]); i++) {
if(curlinfo->features & feats[i].bitmask)
printf("%s ", feats[i].name);
}
puts(""); /* newline */
}
}
return PARAM_HELP_REQUESTED;
Daniel Stenberg
committed
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;
nextarg++; /* pass the @ */
Daniel Stenberg
committed
if(curlx_strequal("-", nextarg))
file = fopen(nextarg, "r");
config->writeout = file2string(file);
if(file && (file != stdin))
fclose(file);
GetStr(&config->writeout, nextarg);
Daniel Stenberg
committed
break;
/* set custom request */
GetStr(&config->customrequest, nextarg);
break;
if(str2num(&config->low_speed_time, nextarg))
return PARAM_BAD_NUMERIC;
config->low_speed_limit = 1;
if(str2num(&config->low_speed_limit, nextarg))
return PARAM_BAD_NUMERIC;
config->low_speed_time=30;
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) */
nextarg++;
break;
}
now=time(NULL);
config->condtime=curl_getdate(nextarg, &now);
/* now let's see if it is a file name to get the time from instead! */
if(-1 == stat(nextarg, &statbuf)) {
/* failed, remove time condition */
}
else {
/* pull the time out from the file */
config->condtime = statbuf.st_mtime;
}
}
break;
return PARAM_OPTION_UNKNOWN;
} while(!longopt && !singleopt && *++parse && !*usedarg);
return PARAM_OK;
static void parseconfig(const char *filename,
struct Configurable *config)
char filebuffer[512];
char *home;
if(!filename || !*filename) {
/* NULL or no file name attempts to load .curlrc from the homedir! */
#define CURLRC DOT_CHAR "curlrc"
filename = CURLRC; /* sensible default */
home = homedir(); /* portable homedir finder */
if(home) {
if(strlen(home)<(sizeof(filebuffer)-strlen(CURLRC))) {
snprintf(filebuffer, sizeof(filebuffer),
"%s%s%s", home, DIR_CHAR, CURLRC);
filename = filebuffer;
}
free(home); /* we've used it, now free it */
}
# else /* AmigaOS */
/* On AmigaOS all the config files are into env:
*/
filename = "ENV:" CURLRC;
#endif
}
if(strcmp(filename,"-"))
file = fopen(filename, "r");
else
file = stdin;
Daniel Stenberg
committed
if(file) {
Daniel Stenberg
committed
char *line;
char *aline;
char *option;
char *param;
int lineno=0;
bool alloced_param;
#define isseparator(x) (((x)=='=') || ((x) == ':'))
while (NULL != (aline = my_get_line(file))) {
lineno++;
line = aline;
alloced_param=FALSE;
Daniel Stenberg
committed
/* lines with # in the fist column is a comment! */
Daniel Stenberg
committed
while(*line && isspace((int)*line))
line++;
switch(*line) {
case '#':
case '/':
case '\r':
case '\n':
case '*':
case '\0':
Daniel Stenberg
committed
continue;
}
/* the option keywords starts here */
option = line;
while(*line && !isspace((int)*line) && !isseparator(*line))
line++;
/* ... and has ended here */
Daniel Stenberg
committed
if(*line)
*line++=0; /* zero terminate, we have a local copy of the data */
#ifdef DEBUG_CONFIG
fprintf(stderr, "GOT: %s\n", option);
#endif
/* pass spaces and separator(s) */
Daniel Stenberg
committed
while(*line && (isspace((int)*line) || isseparator(*line)))
line++;
/* the parameter starts here (unless quoted) */
if(*line == '\"') {
char *ptr;
/* quoted parameter, do the qoute dance */
line++;
param=strdup(line); /* parameter */
alloced_param=TRUE;
ptr=param;
while(*line && (*line != '\"')) {
if(*line == '\\') {
line++;
/* default is to output the letter after the backslah */
switch(out = *line) {
case '\0':
continue; /* this'll break out of the loop */
case 't':
out='\t';
break;
case 'n':
out='\n';
break;
case 'r':
out='\r';
break;
case 'v':
out='\v';
break;
}
*ptr++=out;
line++;
}
else
*ptr++=*line++;
}
*ptr=0; /* always zero terminate */
else {
param=line; /* parameter starts here */
while(*line && !isspace((int)*line))
line++;
*line=0; /* zero terminate */
if (param && !*param) {
/* do this so getparameter can check for required parameters.
Otherwise it always thinks there's a parameter. */
if (alloced_param)
free(param);
param = NULL;
}
#ifdef DEBUG_CONFIG
fprintf(stderr, "PARAM: \"%s\"\n",(param ? param : "(null)"));
#endif
res = getparameter(option, param, &usedarg, config);
Daniel Stenberg
committed
if (param && *param && !usedarg)
/* we passed in a parameter that wasn't used! */
res = PARAM_GOT_EXTRA_PARAMETER;
Daniel Stenberg
committed
if(res != PARAM_OK) {
/* the help request isn't really an error */
if(!strcmp(filename, "-")) {
}
if(PARAM_HELP_REQUESTED != res) {
const char *reason = param2text(res);
fprintf(stderr, "%s:%d: warning: '%s' %s\n",
filename, lineno, option, reason);
Daniel Stenberg
committed
}
Daniel Stenberg
committed
}
if(alloced_param)
{
free(param);
}
free(aline);
}
if(file != stdin)
fclose(file);
}
}
#ifdef HAVE_POLL_FINE
#else
/* systems without poll() need other solutions */
#ifdef WIN32
/* Windows offers a millisecond sleep */
Sleep(ms);
#elif defined(__MSDOS__)
delay(ms);
#else
/* Other systems must use select() for this */
struct timeval timeout;
Daniel Stenberg
committed
timeout.tv_sec = ms/1000;
ms = ms%1000;
timeout.tv_usec = ms * 1000;
select(0, NULL, NULL, NULL, &timeout);
#endif
#endif
struct OutStruct {
char *filename;
FILE *stream;
struct Configurable *config;
Daniel Stenberg
committed
curl_off_t bytes; /* amount written so far */
curl_off_t init; /* original size (non-zero when appending) */
Daniel Stenberg
committed
static int my_fwrite(void *buffer, size_t sz, size_t nmemb, void *stream)
Daniel Stenberg
committed
int rc;
curl_off_t size = (curl_off_t)(sz * nmemb); /* typecast to prevent
warnings when converting from
unsigned to signed */
if(out && !out->stream) {
/* open file for writing */
out->stream=fopen(out->filename, "wb");
if(!out->stream)
return -1; /* failure */
}
if(config->recvpersecond) {
/*
* We know when we received data the previous time. We know how much data
* we get now. Make sure that this is not faster than we are told to run.
* If we're faster, sleep a while *before* doing the fwrite() here.
*/
Daniel Stenberg
committed
struct timeval now;
long timediff;
long sleep_time;
Daniel Stenberg
committed
static curl_off_t addit = 0;
Daniel Stenberg
committed
now = curlx_tvnow();
timediff = curlx_tvdiff(now, config->lastrecvtime); /* milliseconds */
Daniel Stenberg
committed
if((config->recvpersecond > CURL_MAX_WRITE_SIZE) && (timediff < 100) ) {
/* If we allow a rather speedy transfer, add this amount for later
* checking. Also, do not modify the lastrecvtime as we will use a
* longer scope due to this addition. We wait for at least 100 ms to
* pass to get better values to do better math for the sleep. */
addit += size;
}
else {
size += addit; /* add up the possibly added bonus rounds from the
zero timediff calls */
addit = 0; /* clear the addition pool */
if( size*1000 > config->recvpersecond*timediff) {
/* figure out how many milliseconds to rest */
Daniel Stenberg
committed
sleep_time = (long)(size*1000/config->recvpersecond - timediff);
Daniel Stenberg
committed
/*
* Make sure we don't sleep for so long that we trigger the speed
* limit. This won't limit the bandwidth quite the way we've been
* asked to, but at least the transfer has a chance.
*/
if (config->low_speed_time > 0)
sleep_time = MIN(sleep_time,(config->low_speed_time * 1000) / 2);
Daniel Stenberg
committed
if(sleep_time > 0) {
go_sleep(sleep_time);
now = curlx_tvnow();
}
}
config->lastrecvtime = now;
Daniel Stenberg
committed
rc = fwrite(buffer, sz, nmemb, out->stream);
Daniel Stenberg
committed
if((int)(sz * nmemb) == rc) {
/* we added this amount of data to the output */
out->bytes += (sz * nmemb);
}
Daniel Stenberg
committed
if(config->nobuffer)
/* disable output buffering */
fflush(out->stream);
Daniel Stenberg
committed
return rc;
struct InStruct {
FILE *stream;
struct Configurable *config;
};
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
static curlioerr my_ioctl(CURL *handle, curliocmd cmd, void *userp)
{
struct InStruct *in=(struct InStruct *)userp;
(void)handle; /* not used in here */
switch(cmd) {
case CURLIOCMD_RESTARTREAD:
/* mr libcurl kindly asks as to rewind the read data stream to start */
if(-1 == fseek(in->stream, 0, SEEK_SET))
/* couldn't rewind, the reason is in errno but errno is just not
portable enough and we don't actually care that much why we failed. */
return CURLIOE_FAILRESTART;
break;
default: /* ignore unknown commands */
return CURLIOE_UNKNOWNCMD;
}
return CURLIOE_OK;
}
Daniel Stenberg
committed
static int my_fread(void *buffer, size_t sz, size_t nmemb, void *userp)
struct InStruct *in=(struct InStruct *)userp;
struct Configurable *config = in->config;
curl_off_t size = (curl_off_t)(sz * nmemb); /* typecast to prevent warnings
when converting from
unsigned to signed */
if(config->sendpersecond) {
/*
* We know when we sent data the previous time. We know how much data
* we sent. Make sure that this was not faster than we are told to run.
* If we're faster, sleep a while *before* doing the fread() here.
* Also, make no larger fread() than should be sent this second!
*/
Daniel Stenberg
committed
struct timeval now;
long timediff;
long sleep_time;
Daniel Stenberg
committed
static curl_off_t addit = 0;
now = curlx_tvnow();
timediff = curlx_tvdiff(now, config->lastsendtime); /* milliseconds */
Daniel Stenberg
committed
if((config->sendpersecond > CURL_MAX_WRITE_SIZE) &&
(timediff < 100)) {
/*
* We allow very fast transfers, then allow at least 100 ms between
* each sleeping mile-stone to create more accurate long-term rates.
*/
addit += size;
}
else {
/* If 'addit' is non-zero, it contains the total amount of bytes
uploaded during the last 'timediff' milliseconds. If it is zero,
we use the stored previous size. */
curl_off_t xfered = addit?addit:(curl_off_t)config->lastsendsize;
Daniel Stenberg
committed
addit = 0; /* clear it for the next round */
if( xfered*1000 > config->sendpersecond*timediff) {
/* figure out how many milliseconds to rest */
Daniel Stenberg
committed
sleep_time = (long)(xfered*1000/config->sendpersecond - timediff);
Daniel Stenberg
committed
if(sleep_time > 0) {
go_sleep (sleep_time);
now = curlx_tvnow();
}
}
config->lastsendtime = now;
Daniel Stenberg
committed
if(size > config->sendpersecond) {
/* lower the size to actually read */
Daniel Stenberg
committed
nmemb = (size_t)config->sendpersecond;
Daniel Stenberg
committed
sz = 1;
}
Daniel Stenberg
committed
config->lastsendsize = sz*nmemb;
}
rc = fread(buffer, sz, nmemb, in->stream);
#if 0
fprintf(stderr, "CALLBACK returning %d bytes data\n", (int)rc);
#endif
return rc;
struct ProgressData {
Daniel Stenberg
committed
int calls;
int width;
FILE *out; /* where to write everything to */
};
static int myprogress (void *clientp,
double dltotal,
double dlnow,
double ultotal,
double ulnow)
{
/* The original progress-bar source code was written for curl by Lars Aas,
and this new edition inherits some of his concepts. */
char line[256];
char outline[256];
char format[40];
double frac;
double percent;
int barwidth;
int num;
int i;
struct ProgressData *bar = (struct ProgressData *)clientp;
curl_off_t total = (curl_off_t)dltotal + (curl_off_t)ultotal +
bar->initial_size; /* expected transfer size */
curl_off_t point = (curl_off_t)dlnow + (curl_off_t)ulnow +
bar->initial_size; /* we've come this far */
Daniel Stenberg
committed
bar->calls++; /* simply count invokes */
curl_off_t prevblock = bar->prev / 1024;
curl_off_t thisblock = point / 1024;
while ( thisblock > prevblock ) {
fprintf( bar->out, "#" );
prevblock++;
}
}
else {
percent = frac * 100.0f;
barwidth = bar->width - 7;
num = (int) (((double)barwidth) * frac);
i = 0;
for ( i = 0; i < num; i++ ) {
line[i] = '#';
}
line[i] = '\0';
snprintf( format, sizeof(format), "%%-%ds %%5.1f%%%%", barwidth );
snprintf( outline, sizeof(outline), format, line, percent );
fprintf( bar->out, "\r%s", outline );
}
fflush(bar->out);
bar->prev = point;
return 0;
}
static
void progressbarinit(struct ProgressData *bar,
struct Configurable *config)
{
#ifdef __EMX__
/* 20000318 mgs */
int scr_size [2];
#endif
char *colp;
memset(bar, 0, sizeof(struct ProgressData));
/* pass this through to progress function so
* it can display progress towards total file
* not just the part that's left. (21-may-03, dbyron) */
if (config->use_resume)
bar->initial_size = config->resume_from;
/* TODO: get terminal width through ansi escapes or something similar.
try to update width when xterm is resized... - 19990617 larsa */
#ifndef __EMX__
/* 20000318 mgs
* OS/2 users most likely won't have this env var set, and besides that
* we're using our own way to determine screen width */
Daniel Stenberg
committed
colp = curlx_getenv("COLUMNS");
if (colp != NULL) {
bar->width = atoi(colp);
}
else
bar->width = 79;
#else
/* 20000318 mgs
* We use this emx library call to get the screen width, and subtract
* one from what we got in order to avoid a problem with the cursor
* advancing to the next line if we print a string that is as long as
* the screen is wide. */
_scrsize(scr_size);
bar->width = scr_size[0] - 1;
#endif
bar->out = config->errors;
}
Daniel Stenberg
committed
static
void dump(const char *text,
FILE *stream, unsigned char *ptr, size_t size,
bool nohex)
Daniel Stenberg
committed
{
size_t i;
size_t c;
unsigned int width=0x10;
if(nohex)
/* without the hex output, we can fit more on screen */
width = 0x40;
Daniel Stenberg
committed
fprintf(stream, "%s, %zd bytes (0x%zx)\n", text, size, size);
Daniel Stenberg
committed
Daniel Stenberg
committed
fprintf(stream, "%04zx: ", i);
Daniel Stenberg
committed
if(!nohex) {
/* hex not disabled, show it */
for(c = 0; c < width; c++)
if(i+c < size)
fprintf(stream, "%02x ", ptr[i+c]);
else
fputs(" ", stream);
}
for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */
if (nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) {
i+=(c+2-width);
break;
}
Daniel Stenberg
committed
fprintf(stream, "%c",
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
/* check again for 0D0A, to avoid an extra \n if it's at width */
if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) {
i+=(c+3-width);
break;
}
}
Daniel Stenberg
committed
fputc('\n', stream); /* newline */
}
Daniel Stenberg
committed
}
static
int my_trace(CURL *handle, curl_infotype type,
unsigned char *data, size_t size,
void *userp)
{
struct Configurable *config = (struct Configurable *)userp;
FILE *output=config->errors;
Daniel Stenberg
committed
(void)handle; /* prevent compiler warning */
if(!config->trace_stream) {
Daniel Stenberg
committed
/* open for append */
Daniel Stenberg
committed
if(curlx_strequal("-", config->trace_dump))
config->trace_stream = stdout;
else {
config->trace_stream = fopen(config->trace_dump, "w");
config->trace_fopened = TRUE;
}
}
Daniel Stenberg
committed
if(config->trace_stream)
output = config->trace_stream;
switch (type) {
case CURLINFO_TEXT:
fprintf(output, "== Info: %s", data);
default: /* in case a new one is introduced to shock us */
return 0;
Daniel Stenberg
committed
case CURLINFO_HEADER_OUT:
Daniel Stenberg
committed
break;
case CURLINFO_DATA_OUT:
text = "=> Send data";
Daniel Stenberg
committed
break;
case CURLINFO_HEADER_IN:
Daniel Stenberg
committed
break;
case CURLINFO_DATA_IN:
Daniel Stenberg
committed
break;
Daniel Stenberg
committed
case CURLINFO_SSL_DATA_IN:
text = "<= Recv SSL data";
break;
case CURLINFO_SSL_DATA_OUT:
text = "<= Send SSL data";
break;
Daniel Stenberg
committed
}
dump(text, output, data, size, config->trace_ascii);
Daniel Stenberg
committed
return 0;
}
static void free_config_fields(struct Configurable *config)
{
if(config->random_file)
free(config->random_file);
if(config->egd_file)
free(config->egd_file);
if(config->trace_dump)
free(config->trace_dump);
if(config->cipher_list)
free(config->cipher_list);
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
if(config->userpwd)
free(config->userpwd);
if(config->postfields)
free(config->postfields);
if(config->proxy)
free(config->proxy);
if(config->proxyuserpwd)
free(config->proxyuserpwd);
if(config->cookie)
free(config->cookie);
if(config->cookiefile)
free(config->cookiefile);
if(config->krb4level)
free(config->krb4level);
if(config->headerfile)
free(config->headerfile);
if(config->ftpport)
free(config->ftpport);
if(config->range)
free(config->range);
if(config->customrequest)
free(config->customrequest);
if(config->writeout)
free(config->writeout);
if(config->httppost)
curl_formfree(config->httppost);
if(config->cacert)
free(config->cacert);
if(config->capath)
free(config->capath);
if(config->cookiejar)
free(config->cookiejar);
if(config->tp_url)
free(config->tp_url);
if(config->tp_user)
free(config->tp_user);
Daniel Stenberg
committed
if(config->ftp_account)
free(config->ftp_account);
curl_slist_free_all(config->quote); /* checks for config->quote == NULL */
Daniel Stenberg
committed
curl_slist_free_all(config->prequote);
curl_slist_free_all(config->postquote);
curl_slist_free_all(config->tp_quote);
curl_slist_free_all(config->tp_prequote);
curl_slist_free_all(config->tp_postquote);
Daniel Stenberg
committed
curl_slist_free_all(config->headers);
}
Daniel Stenberg
committed
#if defined(WIN32) && !defined(__CYGWIN32__)
/* Function to find CACert bundle on a Win32 platform using SearchPath.
* (SearchPath is defined in windows.h, which is #included into libcurl)
* (Use the ASCII version instead of the unicode one!)
* The order of the directories it searches is:
* 1. application's directory
* 2. current working directory
* 3. Windows System directory (e.g. C:\windows\system32)
* 4. Windows Directory (e.g. C:\windows)
* 5. all directories along %PATH%
*/
static void FindWin32CACert(struct Configurable *config,
Daniel Stenberg
committed
const char *bundle_file)
{
/* only check for cert file if "we" support SSL */
if(curlinfo->features & CURL_VERSION_SSL) {
Daniel Stenberg
committed
DWORD buflen;
char *ptr = NULL;
char *retval = (char *) malloc(sizeof (TCHAR) * (MAX_PATH + 1));
if (!retval)
return;
retval[0] = '\0';
buflen = SearchPathA(NULL, bundle_file, NULL, MAX_PATH+2, retval, &ptr);
if (buflen > 0) {
GetStr(&config->cacert, retval);
}
free(retval);
}
}
#endif
Daniel Stenberg
committed
#define RETRY_SLEEP_DEFAULT 1000 /* ms */
#define RETRY_SLEEP_MAX 600000 /* ms == 10 minutes */
operate(struct Configurable *config, int argc, char *argv[])
char errorbuffer[CURL_ERROR_SIZE];
char useragent[128]; /* buah, we don't want a larger default user agent */
struct ProgressData progressbar;
struct getout *urlnode;
struct getout *nextnode;
Daniel Stenberg
committed
struct OutStruct heads;
Daniel Stenberg
committed
URLGlob *urls=NULL;
URLGlob *inglob=NULL;
int infilenum;
char *infiles; /* might a glob pattern */
char *uploadfile=NULL; /* a single file, never a glob */
FILE *infd = stdin;
bool infdfopen;
FILE *headerfilep = NULL;
char *urlbuffer=NULL;
curl_off_t uploadfilesize; /* -1 means unknown */
Daniel Stenberg
committed
char *httpgetfields=NULL;
int res = 0;
int up; /* upload file counter within a single upload glob */
Daniel Stenberg
committed
config->retry_delay*1000:RETRY_SLEEP_DEFAULT; /* ms */
long retry_numretries;
long retry_sleep = retry_sleep_default;
Daniel Stenberg
committed
long response;
Daniel Stenberg
committed
char *env;
/* this sends all memory debug messages to a logfile named memdump */
Daniel Stenberg
committed
env = curlx_getenv("CURL_MEMDEBUG");
if(env) {
/* use the value as file name */
char *s = strdup(env);
curl_memdebug(s);
free(s);
/* this weird strdup() and stuff here is to make the curl_free() get
called before the memdebug() as otherwise the memdebug tracing will
with tracing a free() without an alloc! */
}
Daniel Stenberg
committed
env = curlx_getenv("CURL_MEMLIMIT");
if(env) {
curl_memlimit(atoi(env));
curl_free(env);
}
memset(&outs,0,sizeof(outs));
/* we get libcurl info right away */
curlinfo = curl_version_info(CURLVERSION_NOW);
errorbuffer[0]=0; /* prevent junk from being output */
/* setup proper locale from environment */
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
#endif
/* inits */
if (main_init() != CURLE_OK) {
helpf("error initializing curl library\n");
return CURLE_FAILED_INIT;
}
Daniel Stenberg
committed
config->postfieldsize = -1;
config->showerror=TRUE;
config->conf=CONF_DEFAULT;
Daniel Stenberg
committed
config->use_httpget=FALSE;
config->create_dirs=FALSE;
Daniel Stenberg
committed
config->lastrecvtime = curlx_tvnow();
config->lastsendtime = curlx_tvnow();
Daniel Stenberg
committed
(!curlx_strnequal("--", argv[1], 2) && (argv[1][0] == '-')) &&
strchr(argv[1], 'q')) {
/*
* The first flag, that is not a verbose name, but a shortname
* and it includes the 'q' flag!
*/
;
}
else {
}
/* Parse options */
for (i = 1; i < argc; i++) {
if(stillflags &&
('-' == argv[i][0])) {
char *nextarg;
bool passarg;
char *origopt=argv[i];