mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 09:21:50 -05:00
tool: Moved --stderr to the global config
This commit is contained in:
parent
1f07718123
commit
5513bbd5c3
@ -46,7 +46,7 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
|
|||||||
{
|
{
|
||||||
struct OperationConfig *operation = userdata;
|
struct OperationConfig *operation = userdata;
|
||||||
struct GlobalConfig *config = operation->global;
|
struct GlobalConfig *config = operation->global;
|
||||||
FILE *output = operation->errors;
|
FILE *output = config->errors;
|
||||||
const char *text;
|
const char *text;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct tm *now;
|
struct tm *now;
|
||||||
@ -77,7 +77,7 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
|
|||||||
config->trace_stream = stdout;
|
config->trace_stream = stdout;
|
||||||
else if(curlx_strequal("%", config->trace_dump))
|
else if(curlx_strequal("%", config->trace_dump))
|
||||||
/* Ok, this is somewhat hackish but we do it undocumented for now */
|
/* Ok, this is somewhat hackish but we do it undocumented for now */
|
||||||
config->trace_stream = operation->errors; /* aka stderr */
|
config->trace_stream = config->errors; /* aka stderr */
|
||||||
else {
|
else {
|
||||||
config->trace_stream = fopen(config->trace_dump, "w");
|
config->trace_stream = fopen(config->trace_dump, "w");
|
||||||
config->trace_fopened = TRUE;
|
config->trace_fopened = TRUE;
|
||||||
|
@ -146,5 +146,5 @@ void progressbarinit(struct ProgressData *bar,
|
|||||||
bar->width = scr_size[0] - 1;
|
bar->width = scr_size[0] - 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bar->out = config->errors;
|
bar->out = config->global->errors;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ void config_init(struct OperationConfig* config)
|
|||||||
{
|
{
|
||||||
memset(config, 0, sizeof(struct OperationConfig));
|
memset(config, 0, sizeof(struct OperationConfig));
|
||||||
|
|
||||||
config->errors = stderr; /* default errors to stderr */
|
|
||||||
config->postfieldsize = -1;
|
config->postfieldsize = -1;
|
||||||
config->use_httpget = FALSE;
|
config->use_httpget = FALSE;
|
||||||
config->create_dirs = FALSE;
|
config->create_dirs = FALSE;
|
||||||
@ -116,10 +115,6 @@ static void free_config_fields(struct OperationConfig *config)
|
|||||||
|
|
||||||
Curl_safefree(config->writeout);
|
Curl_safefree(config->writeout);
|
||||||
|
|
||||||
if(config->errors_fopened && config->errors)
|
|
||||||
fclose(config->errors);
|
|
||||||
config->errors = NULL;
|
|
||||||
|
|
||||||
curl_slist_free_all(config->quote);
|
curl_slist_free_all(config->quote);
|
||||||
curl_slist_free_all(config->postquote);
|
curl_slist_free_all(config->postquote);
|
||||||
curl_slist_free_all(config->prequote);
|
curl_slist_free_all(config->prequote);
|
||||||
|
@ -138,8 +138,6 @@ struct OperationConfig {
|
|||||||
bool proxyanyauth;
|
bool proxyanyauth;
|
||||||
char *writeout; /* %-styled format string to output */
|
char *writeout; /* %-styled format string to output */
|
||||||
bool writeenv; /* write results to environment, if available */
|
bool writeenv; /* write results to environment, if available */
|
||||||
FILE *errors; /* errors stream, defaults to stderr */
|
|
||||||
bool errors_fopened; /* whether errors stream isn't stderr */
|
|
||||||
struct curl_slist *quote;
|
struct curl_slist *quote;
|
||||||
struct curl_slist *postquote;
|
struct curl_slist *postquote;
|
||||||
struct curl_slist *prequote;
|
struct curl_slist *prequote;
|
||||||
@ -220,6 +218,8 @@ struct GlobalConfig {
|
|||||||
0 => -s is used to NOT show errors
|
0 => -s is used to NOT show errors
|
||||||
1 => -S has been used to show errors */
|
1 => -S has been used to show errors */
|
||||||
bool mute; /* don't show messages, --silent given */
|
bool mute; /* don't show messages, --silent given */
|
||||||
|
FILE *errors; /* Error stream, defaults to stderr */
|
||||||
|
bool errors_fopened; /* Whether error stream isn't stderr */
|
||||||
char *trace_dump; /* file to dump the network trace to */
|
char *trace_dump; /* file to dump the network trace to */
|
||||||
FILE *trace_stream;
|
FILE *trace_stream;
|
||||||
bool trace_fopened;
|
bool trace_fopened;
|
||||||
|
@ -163,7 +163,7 @@ int formparse(struct OperationConfig *config,
|
|||||||
/* Allocate the contents */
|
/* Allocate the contents */
|
||||||
contents = strdup(contp+1);
|
contents = strdup(contp+1);
|
||||||
if(!contents) {
|
if(!contents) {
|
||||||
fprintf(config->errors, "out of memory\n");
|
fprintf(config->global->errors, "out of memory\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
contp = contents;
|
contp = contents;
|
||||||
@ -277,7 +277,7 @@ int formparse(struct OperationConfig *config,
|
|||||||
}
|
}
|
||||||
forms = malloc((count+1)*sizeof(struct curl_forms));
|
forms = malloc((count+1)*sizeof(struct curl_forms));
|
||||||
if(!forms) {
|
if(!forms) {
|
||||||
fprintf(config->errors, "Error building form post!\n");
|
fprintf(config->global->errors, "Error building form post!\n");
|
||||||
Curl_safefree(contents);
|
Curl_safefree(contents);
|
||||||
FreeMultiInfo(&multi_start, &multi_current);
|
FreeMultiInfo(&multi_start, &multi_current);
|
||||||
return 4;
|
return 4;
|
||||||
|
@ -681,14 +681,14 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
if(!newfile)
|
if(!newfile)
|
||||||
warnf(config, "Failed to open %s!\n", nextarg);
|
warnf(config, "Failed to open %s!\n", nextarg);
|
||||||
else {
|
else {
|
||||||
if(config->errors_fopened)
|
if(global->errors_fopened)
|
||||||
fclose(config->errors);
|
fclose(global->errors);
|
||||||
config->errors = newfile;
|
global->errors = newfile;
|
||||||
config->errors_fopened = TRUE;
|
global->errors_fopened = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
config->errors = stdout;
|
global->errors = stdout;
|
||||||
break;
|
break;
|
||||||
case 'w': /* --interface */
|
case 'w': /* --interface */
|
||||||
/* interface */
|
/* interface */
|
||||||
@ -1875,9 +1875,9 @@ ParameterError parse_args(struct GlobalConfig *config, int argc,
|
|||||||
const char *reason = param2text(result);
|
const char *reason = param2text(result);
|
||||||
|
|
||||||
if(!curlx_strequal(":", orig_opt))
|
if(!curlx_strequal(":", orig_opt))
|
||||||
helpf(operation->errors, "option %s: %s\n", orig_opt, reason);
|
helpf(config->errors, "option %s: %s\n", orig_opt, reason);
|
||||||
else
|
else
|
||||||
helpf(operation->errors, "%s\n", reason);
|
helpf(config->errors, "%s\n", reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -132,6 +132,7 @@ static CURLcode main_init(struct GlobalConfig *config)
|
|||||||
|
|
||||||
/* Initialise the global config */
|
/* Initialise the global config */
|
||||||
config->showerror = -1; /* Will show errors */
|
config->showerror = -1; /* Will show errors */
|
||||||
|
config->errors = stderr; /* Default errors to stderr */
|
||||||
|
|
||||||
/* Allocate the initial operate config */
|
/* Allocate the initial operate config */
|
||||||
config->first = config->last = malloc(sizeof(struct OperationConfig));
|
config->first = config->last = malloc(sizeof(struct OperationConfig));
|
||||||
@ -179,6 +180,10 @@ static void free_config_fields(struct GlobalConfig *config)
|
|||||||
{
|
{
|
||||||
Curl_safefree(config->trace_dump);
|
Curl_safefree(config->trace_dump);
|
||||||
|
|
||||||
|
if(config->errors_fopened && config->errors)
|
||||||
|
fclose(config->errors);
|
||||||
|
config->errors = NULL;
|
||||||
|
|
||||||
if(config->trace_fopened && config->trace_stream)
|
if(config->trace_fopened && config->trace_stream)
|
||||||
fclose(config->trace_stream);
|
fclose(config->trace_stream);
|
||||||
config->trace_stream = NULL;
|
config->trace_stream = NULL;
|
||||||
|
@ -594,7 +594,7 @@ static int check_hash(const char *filename,
|
|||||||
return check_ok;
|
return check_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
int metalink_check_hash(struct OperationConfig *config,
|
int metalink_check_hash(struct GlobalConfig *config,
|
||||||
metalinkfile *mlfile,
|
metalinkfile *mlfile,
|
||||||
const char *filename)
|
const char *filename)
|
||||||
{
|
{
|
||||||
@ -602,8 +602,7 @@ int metalink_check_hash(struct OperationConfig *config,
|
|||||||
fprintf(config->errors, "Metalink: validating (%s)...\n", filename);
|
fprintf(config->errors, "Metalink: validating (%s)...\n", filename);
|
||||||
if(mlfile->checksum == NULL) {
|
if(mlfile->checksum == NULL) {
|
||||||
fprintf(config->errors,
|
fprintf(config->errors,
|
||||||
"Metalink: validating (%s) FAILED (digest missing)\n",
|
"Metalink: validating (%s) FAILED (digest missing)\n", filename);
|
||||||
filename);
|
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
rv = check_hash(filename, mlfile->checksum->digest_def,
|
rv = check_hash(filename, mlfile->checksum->digest_def,
|
||||||
@ -727,7 +726,7 @@ int parse_metalink(struct OperationConfig *config, struct OutStruct *outs,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(metalink->files == NULL) {
|
if(metalink->files == NULL) {
|
||||||
fprintf(config->errors, "Metalink: parsing (%s) WARNING "
|
fprintf(config->global->errors, "Metalink: parsing (%s) WARNING "
|
||||||
"(missing or invalid file name)\n",
|
"(missing or invalid file name)\n",
|
||||||
metalink_url);
|
metalink_url);
|
||||||
metalink_delete(metalink);
|
metalink_delete(metalink);
|
||||||
@ -737,7 +736,7 @@ int parse_metalink(struct OperationConfig *config, struct OutStruct *outs,
|
|||||||
struct getout *url;
|
struct getout *url;
|
||||||
/* Skip an entry which has no resource. */
|
/* Skip an entry which has no resource. */
|
||||||
if(!(*files)->resources) {
|
if(!(*files)->resources) {
|
||||||
fprintf(config->errors, "Metalink: parsing (%s) WARNING "
|
fprintf(config->global->errors, "Metalink: parsing (%s) WARNING "
|
||||||
"(missing or invalid resource)\n",
|
"(missing or invalid resource)\n",
|
||||||
metalink_url, (*files)->name);
|
metalink_url, (*files)->name);
|
||||||
continue;
|
continue;
|
||||||
@ -764,8 +763,8 @@ int parse_metalink(struct OperationConfig *config, struct OutStruct *outs,
|
|||||||
mlfile = new_metalinkfile(*files);
|
mlfile = new_metalinkfile(*files);
|
||||||
if(!mlfile->checksum) {
|
if(!mlfile->checksum) {
|
||||||
warnings = TRUE;
|
warnings = TRUE;
|
||||||
fprintf(config->errors, "Metalink: parsing (%s) WARNING "
|
fprintf(config->global->errors,
|
||||||
"(digest missing)\n",
|
"Metalink: parsing (%s) WARNING (digest missing)\n",
|
||||||
metalink_url);
|
metalink_url);
|
||||||
}
|
}
|
||||||
/* Set name as url */
|
/* Set name as url */
|
||||||
@ -809,7 +808,7 @@ size_t metalink_write_cb(void *buffer, size_t sz, size_t nmemb,
|
|||||||
if(rv == 0)
|
if(rv == 0)
|
||||||
return sz * nmemb;
|
return sz * nmemb;
|
||||||
else {
|
else {
|
||||||
fprintf(config->errors, "Metalink: parsing FAILED\n");
|
fprintf(config->global->errors, "Metalink: parsing FAILED\n");
|
||||||
return failure;
|
return failure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ int check_metalink_content_type(const char *content_type);
|
|||||||
* No checksum in Metalink supported, hash algorithm not available, or
|
* No checksum in Metalink supported, hash algorithm not available, or
|
||||||
* Metalink does not contain checksum.
|
* Metalink does not contain checksum.
|
||||||
*/
|
*/
|
||||||
int metalink_check_hash(struct OperationConfig *config,
|
int metalink_check_hash(struct GlobalConfig *config,
|
||||||
metalinkfile *mlfile,
|
metalinkfile *mlfile,
|
||||||
const char *filename);
|
const char *filename);
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ void warnf(struct OperationConfig *config, const char *fmt, ...)
|
|||||||
|
|
||||||
ptr = print_buffer;
|
ptr = print_buffer;
|
||||||
while(len > 0) {
|
while(len > 0) {
|
||||||
fputs(WARN_PREFIX, config->errors);
|
fputs(WARN_PREFIX, config->global->errors);
|
||||||
|
|
||||||
if(len > (int)WARN_TEXTWIDTH) {
|
if(len > (int)WARN_TEXTWIDTH) {
|
||||||
int cut = WARN_TEXTWIDTH-1;
|
int cut = WARN_TEXTWIDTH-1;
|
||||||
@ -65,13 +65,13 @@ void warnf(struct OperationConfig *config, const char *fmt, ...)
|
|||||||
max text width then! */
|
max text width then! */
|
||||||
cut = WARN_TEXTWIDTH-1;
|
cut = WARN_TEXTWIDTH-1;
|
||||||
|
|
||||||
(void)fwrite(ptr, cut + 1, 1, config->errors);
|
(void)fwrite(ptr, cut + 1, 1, config->global->errors);
|
||||||
fputs("\n", config->errors);
|
fputs("\n", config->global->errors);
|
||||||
ptr += cut+1; /* skip the space too */
|
ptr += cut+1; /* skip the space too */
|
||||||
len -= cut;
|
len -= cut;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fputs(ptr, config->errors);
|
fputs(ptr, config->global->errors);
|
||||||
len = 0;
|
len = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
|
|
||||||
/* Check we have a url */
|
/* Check we have a url */
|
||||||
if(!config->url_list || !config->url_list->url) {
|
if(!config->url_list || !config->url_list->url) {
|
||||||
helpf(config->errors, "no URL specified!\n");
|
helpf(global->errors, "no URL specified!\n");
|
||||||
res = CURLE_FAILED_INIT;
|
res = CURLE_FAILED_INIT;
|
||||||
goto quit_curl;
|
goto quit_curl;
|
||||||
}
|
}
|
||||||
@ -247,7 +247,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
config->cacert = strdup(env);
|
config->cacert = strdup(env);
|
||||||
if(!config->cacert) {
|
if(!config->cacert) {
|
||||||
curl_free(env);
|
curl_free(env);
|
||||||
helpf(config->errors, "out of memory\n");
|
helpf(global->errors, "out of memory\n");
|
||||||
res = CURLE_OUT_OF_MEMORY;
|
res = CURLE_OUT_OF_MEMORY;
|
||||||
goto quit_curl;
|
goto quit_curl;
|
||||||
}
|
}
|
||||||
@ -258,7 +258,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
config->capath = strdup(env);
|
config->capath = strdup(env);
|
||||||
if(!config->capath) {
|
if(!config->capath) {
|
||||||
curl_free(env);
|
curl_free(env);
|
||||||
helpf(config->errors, "out of memory\n");
|
helpf(global->errors, "out of memory\n");
|
||||||
res = CURLE_OUT_OF_MEMORY;
|
res = CURLE_OUT_OF_MEMORY;
|
||||||
goto quit_curl;
|
goto quit_curl;
|
||||||
}
|
}
|
||||||
@ -269,7 +269,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
config->cacert = strdup(env);
|
config->cacert = strdup(env);
|
||||||
if(!config->cacert) {
|
if(!config->cacert) {
|
||||||
curl_free(env);
|
curl_free(env);
|
||||||
helpf(config->errors, "out of memory\n");
|
helpf(global->errors, "out of memory\n");
|
||||||
res = CURLE_OUT_OF_MEMORY;
|
res = CURLE_OUT_OF_MEMORY;
|
||||||
goto quit_curl;
|
goto quit_curl;
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
httpgetfields = strdup(config->postfields);
|
httpgetfields = strdup(config->postfields);
|
||||||
Curl_safefree(config->postfields);
|
Curl_safefree(config->postfields);
|
||||||
if(!httpgetfields) {
|
if(!httpgetfields) {
|
||||||
helpf(config->errors, "out of memory\n");
|
helpf(global->errors, "out of memory\n");
|
||||||
res = CURLE_OUT_OF_MEMORY;
|
res = CURLE_OUT_OF_MEMORY;
|
||||||
goto quit_curl;
|
goto quit_curl;
|
||||||
}
|
}
|
||||||
@ -316,7 +316,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
#ifndef CURL_DISABLE_LIBCURL_OPTION
|
#ifndef CURL_DISABLE_LIBCURL_OPTION
|
||||||
res = easysrc_init();
|
res = easysrc_init();
|
||||||
if(res) {
|
if(res) {
|
||||||
helpf(config->errors, "out of memory\n");
|
helpf(global->errors, "out of memory\n");
|
||||||
goto quit_curl;
|
goto quit_curl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -399,7 +399,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
if(urlnode->outfile) {
|
if(urlnode->outfile) {
|
||||||
outfiles = strdup(urlnode->outfile);
|
outfiles = strdup(urlnode->outfile);
|
||||||
if(!outfiles) {
|
if(!outfiles) {
|
||||||
helpf(config->errors, "out of memory\n");
|
helpf(global->errors, "out of memory\n");
|
||||||
res = CURLE_OUT_OF_MEMORY;
|
res = CURLE_OUT_OF_MEMORY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -410,7 +410,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
if(!config->globoff && infiles) {
|
if(!config->globoff && infiles) {
|
||||||
/* Unless explicitly shut off */
|
/* Unless explicitly shut off */
|
||||||
res = glob_url(&inglob, infiles, &infilenum,
|
res = glob_url(&inglob, infiles, &infilenum,
|
||||||
global->showerror?config->errors:NULL);
|
global->showerror?global->errors:NULL);
|
||||||
if(res) {
|
if(res) {
|
||||||
Curl_safefree(outfiles);
|
Curl_safefree(outfiles);
|
||||||
break;
|
break;
|
||||||
@ -436,12 +436,12 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
if(inglob) {
|
if(inglob) {
|
||||||
res = glob_next_url(&uploadfile, inglob);
|
res = glob_next_url(&uploadfile, inglob);
|
||||||
if(res == CURLE_OUT_OF_MEMORY)
|
if(res == CURLE_OUT_OF_MEMORY)
|
||||||
helpf(config->errors, "out of memory\n");
|
helpf(global->errors, "out of memory\n");
|
||||||
}
|
}
|
||||||
else if(!up) {
|
else if(!up) {
|
||||||
uploadfile = strdup(infiles);
|
uploadfile = strdup(infiles);
|
||||||
if(!uploadfile) {
|
if(!uploadfile) {
|
||||||
helpf(config->errors, "out of memory\n");
|
helpf(global->errors, "out of memory\n");
|
||||||
res = CURLE_OUT_OF_MEMORY;
|
res = CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -461,7 +461,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
/* Unless explicitly shut off, we expand '{...}' and '[...]'
|
/* Unless explicitly shut off, we expand '{...}' and '[...]'
|
||||||
expressions and return total number of URLs in pattern set */
|
expressions and return total number of URLs in pattern set */
|
||||||
res = glob_url(&urls, urlnode->url, &urlnum,
|
res = glob_url(&urls, urlnode->url, &urlnum,
|
||||||
global->showerror?config->errors:NULL);
|
global->showerror?global->errors:NULL);
|
||||||
if(res) {
|
if(res) {
|
||||||
Curl_safefree(uploadfile);
|
Curl_safefree(uploadfile);
|
||||||
break;
|
break;
|
||||||
@ -555,7 +555,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
if(res)
|
if(res)
|
||||||
goto show_error;
|
goto show_error;
|
||||||
if((!outfile || !*outfile) && !config->content_disposition) {
|
if((!outfile || !*outfile) && !config->content_disposition) {
|
||||||
helpf(config->errors, "Remote file name has no length!\n");
|
helpf(global->errors, "Remote file name has no length!\n");
|
||||||
res = CURLE_WRITE_ERROR;
|
res = CURLE_WRITE_ERROR;
|
||||||
goto quit_urls;
|
goto quit_urls;
|
||||||
}
|
}
|
||||||
@ -585,7 +585,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
file output call */
|
file output call */
|
||||||
|
|
||||||
if(config->create_dirs || metalink) {
|
if(config->create_dirs || metalink) {
|
||||||
res = create_dir_hierarchy(outfile, config->errors);
|
res = create_dir_hierarchy(outfile, global->errors);
|
||||||
/* create_dir_hierarchy shows error upon CURLE_WRITE_ERROR */
|
/* create_dir_hierarchy shows error upon CURLE_WRITE_ERROR */
|
||||||
if(res == CURLE_WRITE_ERROR)
|
if(res == CURLE_WRITE_ERROR)
|
||||||
goto quit_urls;
|
goto quit_urls;
|
||||||
@ -624,7 +624,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
FILE *file = fopen(outfile, config->resume_from?"ab":"wb");
|
FILE *file = fopen(outfile, config->resume_from?"ab":"wb");
|
||||||
#endif
|
#endif
|
||||||
if(!file) {
|
if(!file) {
|
||||||
helpf(config->errors, "Can't open '%s'!\n", outfile);
|
helpf(global->errors, "Can't open '%s'!\n", outfile);
|
||||||
res = CURLE_WRITE_ERROR;
|
res = CURLE_WRITE_ERROR;
|
||||||
goto quit_urls;
|
goto quit_urls;
|
||||||
}
|
}
|
||||||
@ -686,7 +686,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
if((infd == -1) || fstat(infd, &fileinfo))
|
if((infd == -1) || fstat(infd, &fileinfo))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
helpf(config->errors, "Can't open '%s'!\n", uploadfile);
|
helpf(global->errors, "Can't open '%s'!\n", uploadfile);
|
||||||
if(infd != -1) {
|
if(infd != -1) {
|
||||||
close(infd);
|
close(infd);
|
||||||
infd = STDIN_FILENO;
|
infd = STDIN_FILENO;
|
||||||
@ -754,7 +754,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(urlnum > 1 && !global->mute) {
|
if(urlnum > 1 && !global->mute) {
|
||||||
fprintf(config->errors, "\n[%lu/%lu]: %s --> %s\n",
|
fprintf(global->errors, "\n[%lu/%lu]: %s --> %s\n",
|
||||||
li+1, urlnum, this_url, outfile ? outfile : "<stdout>");
|
li+1, urlnum, this_url, outfile ? outfile : "<stdout>");
|
||||||
if(separator)
|
if(separator)
|
||||||
printf("%s%s\n", CURLseparator, this_url);
|
printf("%s%s\n", CURLseparator, this_url);
|
||||||
@ -799,8 +799,8 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
this_url = urlbuffer; /* use our new URL instead! */
|
this_url = urlbuffer; /* use our new URL instead! */
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!config->errors)
|
if(!global->errors)
|
||||||
config->errors = stderr;
|
global->errors = stderr;
|
||||||
|
|
||||||
if((!outfile || !strcmp(outfile, "-")) && !config->use_ascii) {
|
if((!outfile || !strcmp(outfile, "-")) && !config->use_ascii) {
|
||||||
/* We get the output to stdout and we have not got the ASCII/text
|
/* We get the output to stdout and we have not got the ASCII/text
|
||||||
@ -1098,7 +1098,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
my_setopt_enum(curl, CURLOPT_TIMECONDITION, (long)config->timecond);
|
my_setopt_enum(curl, CURLOPT_TIMECONDITION, (long)config->timecond);
|
||||||
my_setopt(curl, CURLOPT_TIMEVALUE, (long)config->condtime);
|
my_setopt(curl, CURLOPT_TIMEVALUE, (long)config->condtime);
|
||||||
my_setopt_str(curl, CURLOPT_CUSTOMREQUEST, config->customrequest);
|
my_setopt_str(curl, CURLOPT_CUSTOMREQUEST, config->customrequest);
|
||||||
my_setopt(curl, CURLOPT_STDERR, config->errors);
|
my_setopt(curl, CURLOPT_STDERR, global->errors);
|
||||||
|
|
||||||
/* three new ones in libcurl 7.3: */
|
/* three new ones in libcurl 7.3: */
|
||||||
my_setopt_str(curl, CURLOPT_INTERFACE, config->iface);
|
my_setopt_str(curl, CURLOPT_INTERFACE, config->iface);
|
||||||
@ -1357,11 +1357,12 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
res = CURLE_OUT_OF_MEMORY;
|
res = CURLE_OUT_OF_MEMORY;
|
||||||
goto show_error;
|
goto show_error;
|
||||||
}
|
}
|
||||||
fprintf(config->errors, "Metalink: parsing (%s) metalink/XML...\n",
|
fprintf(config->global->errors,
|
||||||
this_url);
|
"Metalink: parsing (%s) metalink/XML...\n", this_url);
|
||||||
}
|
}
|
||||||
else if(metalink)
|
else if(metalink)
|
||||||
fprintf(config->errors, "Metalink: fetching (%s) from (%s)...\n",
|
fprintf(config->global->errors,
|
||||||
|
"Metalink: fetching (%s) from (%s)...\n",
|
||||||
mlfile->filename, this_url);
|
mlfile->filename, this_url);
|
||||||
#endif /* USE_METALINK */
|
#endif /* USE_METALINK */
|
||||||
|
|
||||||
@ -1461,7 +1462,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
/* We have written data to a output file, we truncate file
|
/* We have written data to a output file, we truncate file
|
||||||
*/
|
*/
|
||||||
if(!global->mute)
|
if(!global->mute)
|
||||||
fprintf(config->errors, "Throwing away %"
|
fprintf(global->errors, "Throwing away %"
|
||||||
CURL_FORMAT_CURL_OFF_T " bytes\n",
|
CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||||
outs.bytes);
|
outs.bytes);
|
||||||
fflush(outs.stream);
|
fflush(outs.stream);
|
||||||
@ -1471,7 +1472,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
/* when truncate fails, we can't just append as then we'll
|
/* when truncate fails, we can't just append as then we'll
|
||||||
create something strange, bail out */
|
create something strange, bail out */
|
||||||
if(!global->mute)
|
if(!global->mute)
|
||||||
fprintf(config->errors,
|
fprintf(global->errors,
|
||||||
"failed to truncate, exiting\n");
|
"failed to truncate, exiting\n");
|
||||||
res = CURLE_WRITE_ERROR;
|
res = CURLE_WRITE_ERROR;
|
||||||
goto quit_urls;
|
goto quit_urls;
|
||||||
@ -1507,7 +1508,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);
|
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);
|
||||||
if(response != 200 && response != 206) {
|
if(response != 200 && response != 206) {
|
||||||
metalink_next_res = 1;
|
metalink_next_res = 1;
|
||||||
fprintf(config->errors,
|
fprintf(global->errors,
|
||||||
"Metalink: fetching (%s) from (%s) FAILED "
|
"Metalink: fetching (%s) from (%s) FAILED "
|
||||||
"(HTTP status code %d)\n",
|
"(HTTP status code %d)\n",
|
||||||
mlfile->filename, this_url, response);
|
mlfile->filename, this_url, response);
|
||||||
@ -1516,7 +1517,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
metalink_next_res = 1;
|
metalink_next_res = 1;
|
||||||
fprintf(config->errors,
|
fprintf(global->errors,
|
||||||
"Metalink: fetching (%s) from (%s) FAILED (%s)\n",
|
"Metalink: fetching (%s) from (%s) FAILED (%s)\n",
|
||||||
mlfile->filename, this_url,
|
mlfile->filename, this_url,
|
||||||
(errorbuffer[0]) ?
|
(errorbuffer[0]) ?
|
||||||
@ -1524,7 +1525,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(metalink && !metalink_next_res)
|
if(metalink && !metalink_next_res)
|
||||||
fprintf(config->errors, "Metalink: fetching (%s) from (%s) OK\n",
|
fprintf(global->errors, "Metalink: fetching (%s) from (%s) OK\n",
|
||||||
mlfile->filename, this_url);
|
mlfile->filename, this_url);
|
||||||
|
|
||||||
/* In all ordinary cases, just break out of loop here */
|
/* In all ordinary cases, just break out of loop here */
|
||||||
@ -1562,10 +1563,10 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if(res && global->showerror) {
|
if(res && global->showerror) {
|
||||||
fprintf(config->errors, "curl: (%d) %s\n", res, (errorbuffer[0]) ?
|
fprintf(global->errors, "curl: (%d) %s\n", res, (errorbuffer[0]) ?
|
||||||
errorbuffer : curl_easy_strerror((CURLcode)res));
|
errorbuffer : curl_easy_strerror((CURLcode)res));
|
||||||
if(res == CURLE_SSL_CACERT)
|
if(res == CURLE_SSL_CACERT)
|
||||||
fprintf(config->errors, "%s%s",
|
fprintf(global->errors, "%s%s",
|
||||||
CURL_CA_CERT_ERRORMSG1, CURL_CA_CERT_ERRORMSG2);
|
CURL_CA_CERT_ERRORMSG1, CURL_CA_CERT_ERRORMSG2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1598,7 +1599,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
if(!res && rc) {
|
if(!res && rc) {
|
||||||
/* something went wrong in the writing process */
|
/* something went wrong in the writing process */
|
||||||
res = CURLE_WRITE_ERROR;
|
res = CURLE_WRITE_ERROR;
|
||||||
fprintf(config->errors, "(%d) Failed writing body\n", res);
|
fprintf(global->errors, "(%d) Failed writing body\n", res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!outs.s_isreg && outs.stream) {
|
else if(!outs.s_isreg && outs.stream) {
|
||||||
@ -1607,7 +1608,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
if(!res && rc) {
|
if(!res && rc) {
|
||||||
/* something went wrong in the writing process */
|
/* something went wrong in the writing process */
|
||||||
res = CURLE_WRITE_ERROR;
|
res = CURLE_WRITE_ERROR;
|
||||||
fprintf(config->errors, "(%d) Failed writing body\n", res);
|
fprintf(global->errors, "(%d) Failed writing body\n", res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1639,13 +1640,14 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
if(!metalink && config->use_metalink && res == CURLE_OK) {
|
if(!metalink && config->use_metalink && res == CURLE_OK) {
|
||||||
int rv = parse_metalink(config, &outs, this_url);
|
int rv = parse_metalink(config, &outs, this_url);
|
||||||
if(rv == 0)
|
if(rv == 0)
|
||||||
fprintf(config->errors, "Metalink: parsing (%s) OK\n", this_url);
|
fprintf(config->global->errors, "Metalink: parsing (%s) OK\n",
|
||||||
|
this_url);
|
||||||
else if(rv == -1)
|
else if(rv == -1)
|
||||||
fprintf(config->errors, "Metalink: parsing (%s) FAILED\n",
|
fprintf(config->global->errors, "Metalink: parsing (%s) FAILED\n",
|
||||||
this_url);
|
this_url);
|
||||||
}
|
}
|
||||||
else if(metalink && res == CURLE_OK && !metalink_next_res) {
|
else if(metalink && res == CURLE_OK && !metalink_next_res) {
|
||||||
int rv = metalink_check_hash(config, mlfile, outs.filename);
|
int rv = metalink_check_hash(global, mlfile, outs.filename);
|
||||||
if(rv == 0) {
|
if(rv == 0) {
|
||||||
metalink_next_res = 1;
|
metalink_next_res = 1;
|
||||||
}
|
}
|
||||||
@ -1795,7 +1797,7 @@ CURLcode operate(struct GlobalConfig *config, int argc, argv_item_t argv[])
|
|||||||
|
|
||||||
/* If we had no arguments then make sure a url was specified in .curlrc */
|
/* If we had no arguments then make sure a url was specified in .curlrc */
|
||||||
if((argc < 2) && (!config->first->url_list)) {
|
if((argc < 2) && (!config->first->url_list)) {
|
||||||
helpf(config->first->errors, NULL);
|
helpf(config->errors, NULL);
|
||||||
result = CURLE_FAILED_INIT;
|
result = CURLE_FAILED_INIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -504,7 +504,7 @@ CURLcode get_args(struct OperationConfig *config, const size_t i)
|
|||||||
if(!config->useragent) {
|
if(!config->useragent) {
|
||||||
config->useragent = my_useragent();
|
config->useragent = my_useragent();
|
||||||
if(!config->useragent) {
|
if(!config->useragent) {
|
||||||
helpf(config->errors, "out of memory\n");
|
helpf(config->global->errors, "out of memory\n");
|
||||||
result = CURLE_OUT_OF_MEMORY;
|
result = CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user