unsigned char *data, size_t size,
void *userdata)
{
- struct OperationConfig *config = userdata;
- FILE *output = config->errors;
+ struct OperationConfig *operation = userdata;
+ struct GlobalConfig *config = operation->global;
+ FILE *output = operation->errors;
const char *text;
struct timeval tv;
struct tm *now;
config->trace_stream = stdout;
else if(curlx_strequal("%", config->trace_dump))
/* Ok, this is somewhat hackish but we do it undocumented for now */
- config->trace_stream = config->errors; /* aka stderr */
+ config->trace_stream = operation->errors; /* aka stderr */
else {
config->trace_stream = fopen(config->trace_dump, "w");
config->trace_fopened = TRUE;
output = config->trace_stream;
if(!output) {
- warnf(config, "Failed to create/open output");
+ warnf(operation, "Failed to create/open output");
return 0;
}
to stderr or stdout, we don't display the alert about the data not
being shown as the data _is_ shown then just not via this
function */
- if(!config->isatty ||
+ if(!operation->isatty ||
((output != stderr) && (output != stdout))) {
if(!newl)
fprintf(output, "%s%s ", timebuf, s_infotype[type]);
Curl_safefree(config->customrequest);
Curl_safefree(config->krblevel);
- Curl_safefree(config->trace_dump);
Curl_safefree(config->xoauth2_bearer);
- if(config->trace_fopened && config->trace_stream)
- fclose(config->trace_stream);
- config->trace_stream = NULL;
-
Curl_safefree(config->writeout);
if(config->errors_fopened && config->errors)
bool crlf;
char *customrequest;
char *krblevel;
- char *trace_dump; /* file to dump the network trace to, or NULL */
- FILE *trace_stream;
- bool trace_fopened;
- trace tracetype;
- bool tracetime; /* include timestamp? */
long httpversion;
int progressmode; /* CURL_PROGRESS_BAR or CURL_PROGRESS_STATS */
bool nobuffer;
0 => -s is used to NOT show errors
1 => -S has been used to show errors */
bool mute; /* don't show messages, --silent given */
+ char *trace_dump; /* file to dump the network trace to */
+ FILE *trace_stream;
+ bool trace_fopened;
+ trace tracetype;
+ bool tracetime; /* include timestamp? */
struct OperationConfig *first;
struct OperationConfig *current;
GetStr(&config->dns_servers, nextarg);
break;
case 'g': /* --trace */
- GetStr(&config->trace_dump, nextarg);
- if(config->tracetype && (config->tracetype != TRACE_BIN))
+ GetStr(&global->trace_dump, nextarg);
+ if(global->tracetype && (global->tracetype != TRACE_BIN))
warnf(config, "--trace overrides an earlier trace/verbose option\n");
- config->tracetype = TRACE_BIN;
+ global->tracetype = TRACE_BIN;
break;
case 'G': /* --npn */
config->nonpn = (!toggle)?TRUE:FALSE;
break;
case 'h': /* --trace-ascii */
- GetStr(&config->trace_dump, nextarg);
- if(config->tracetype && (config->tracetype != TRACE_ASCII))
+ GetStr(&global->trace_dump, nextarg);
+ if(global->tracetype && (global->tracetype != TRACE_ASCII))
warnf(config,
"--trace-ascii overrides an earlier trace/verbose option\n");
- config->tracetype = TRACE_ASCII;
+ global->tracetype = TRACE_ASCII;
break;
case 'H': /* --alpn */
config->noalpn = (!toggle)?TRUE:FALSE;
config->proxyanyauth = toggle;
break;
case 'o': /* --trace-time */
- config->tracetime = toggle;
+ global->tracetime = toggle;
break;
case 'p': /* --ignore-content-length */
config->ignorecl = toggle;
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)
+ Curl_safefree(global->trace_dump);
+ global->trace_dump = strdup("%");
+ if(!global->trace_dump)
return PARAM_NO_MEM;
- if(config->tracetype && (config->tracetype != TRACE_PLAIN))
+ if(global->tracetype && (global->tracetype != TRACE_PLAIN))
warnf(config,
"-v, --verbose overrides an earlier trace/verbose option\n");
- config->tracetype = TRACE_PLAIN;
+ global->tracetype = TRACE_PLAIN;
}
else
/* verbose is disabled here */
- config->tracetype = TRACE_NONE;
+ global->tracetype = TRACE_NONE;
break;
case 'V':
if(toggle) /* --no-version yields no output! */
return result;
}
+static void free_config_fields(struct GlobalConfig *config)
+{
+ Curl_safefree(config->trace_dump);
+
+ if(config->trace_fopened && config->trace_stream)
+ fclose(config->trace_stream);
+ config->trace_stream = NULL;
+}
+
/*
* This is the main global destructor for the app. Call this after
* _all_ libcurl usage is done.
curl_global_cleanup();
convert_cleanup();
metalink_cleanup();
+ free_config_fields(config);
/* Free the config structures */
config_free(config->last);
/* disable it */
my_setopt(curl, CURLOPT_FTP_USE_EPRT, 0L);
- if(config->tracetype != TRACE_NONE) {
+ if(global->tracetype != TRACE_NONE) {
my_setopt(curl, CURLOPT_DEBUGFUNCTION, tool_debug_cb);
my_setopt(curl, CURLOPT_DEBUGDATA, config);
my_setopt(curl, CURLOPT_VERBOSE, 1L);