* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
*/
size_t failure = (size && nmemb) ? 0 : 1;
- if(!heads->config)
+ if(!per->config)
return failure;
#ifdef DEBUGBUILD
if(size * nmemb > (size_t)CURL_MAX_HTTP_HEADER) {
- warnf(heads->config->global, "Header data exceeds single call write "
+ warnf(per->config->global, "Header data exceeds single call write "
"limit!\n");
return failure;
}
* Write header data when curl option --dump-header (-D) is given.
*/
- if(heads->config->headerfile && heads->stream) {
+ if(per->config->headerfile && heads->stream) {
size_t rc = fwrite(ptr, size, nmemb, heads->stream);
if(rc != cb)
return rc;
* Write etag to file when --etag-save option is given.
* etag string that we want is enveloped in double quotes
*/
- if(etag_save->config->etag_save_file && etag_save->stream) {
+ if(per->config->etag_save_file && etag_save->stream) {
/* match only header that start with etag (case insensitive) */
if(curl_strnequal(str, "etag:", 5)) {
char *etag_h = NULL;
*/
if(!first) {
- warnf(
- etag_save->config->global,
- "\nReceived header etag is missing double quote/s\n");
+ warnf(per->config->global,
+ "\nReceived header etag is missing double quote/s\n");
return 1;
}
else {
last = memchr(first, '\"', cb);
if(!last) {
- warnf(
- etag_save->config->global,
- "\nReceived header etag is missing double quote/s\n");
+ warnf(per->config->global,
+ "\nReceived header etag is missing double quote/s\n");
return 1;
}
/* rename the initial file name to the new file name */
rc = rename(outs->filename, filename);
if(rc != 0) {
- warnf(outs->config->global, "Failed to rename %s -> %s: %s\n",
+ warnf(per->config->global, "Failed to rename %s -> %s: %s\n",
outs->filename, filename, strerror(errno));
}
if(outs->alloc_filename)
outs->filename = filename;
outs->alloc_filename = TRUE;
hdrcbdata->honor_cd_filename = FALSE; /* done now! */
- if(!tool_create_output_file(outs))
+ if(!tool_create_output_file(outs, per->config))
return failure;
}
break;
}
- if(!outs->stream && !tool_create_output_file(outs))
+ if(!outs->stream && !tool_create_output_file(outs, per->config))
return failure;
}
/* bold headers only for selected protocols */
char *value = NULL;
- if(!outs->stream && !tool_create_output_file(outs))
+ if(!outs->stream && !tool_create_output_file(outs, per->config))
return failure;
if(hdrcbdata->global->isatty && hdrcbdata->global->styled_output)
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
struct timeval now = tvnow();
struct per_transfer *per = clientp;
- struct OutStruct *outs = &per->outs;
- struct OperationConfig *config = outs->config;
+ struct OperationConfig *config = per->config;
struct ProgressData *bar = &per->progressbar;
curl_off_t total;
curl_off_t point;
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
curl_off_t ultotal, curl_off_t ulnow)
{
struct per_transfer *per = clientp;
- struct OutStruct *outs = &per->outs;
- struct OperationConfig *config = outs->config;
+ struct OperationConfig *config = per->config;
(void)dltotal; /* unused */
(void)dlnow; /* unused */
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
#include "memdebug.h" /* keep this as LAST include */
/* create a local file for writing, return TRUE on success */
-bool tool_create_output_file(struct OutStruct *outs)
+bool tool_create_output_file(struct OutStruct *outs,
+ struct OperationConfig *config)
{
- struct GlobalConfig *global = outs->config->global;
+ struct GlobalConfig *global;
FILE *file;
-
+ DEBUGASSERT(outs);
+ DEBUGASSERT(config);
+ global = config->global;
if(!outs->filename || !*outs->filename) {
warnf(global, "Remote filename has no length!\n");
return FALSE;
size_t rc;
struct per_transfer *per = userdata;
struct OutStruct *outs = &per->outs;
- struct OperationConfig *config = outs->config;
+ struct OperationConfig *config = per->config;
size_t bytes = sz * nmemb;
bool is_tty = config->global->isatty;
#ifdef WIN32
}
#endif
- if(!outs->stream && !tool_create_output_file(outs))
+ if(!outs->stream && !tool_create_output_file(outs, per->config))
return failure;
if(is_tty && (outs->bytes < 2000) && !config->terminal_binary_ok) {
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata);
/* create a local file for writing, return TRUE on success */
-bool tool_create_output_file(struct OutStruct *outs);
+bool tool_create_output_file(struct OutStruct *outs,
+ struct OperationConfig *config);
#endif /* HEADER_CURL_TOOL_CB_WRT_H */
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
{
struct per_transfer *per = userdata;
struct OutStruct *outs = &per->outs;
- struct OperationConfig *config = outs->config;
+ struct OperationConfig *config = per->config;
int rv;
/*
/* do not create (or even overwrite) the file in case we get no
data because of unmet condition */
curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &cond_unmet);
- if(!cond_unmet && !tool_create_output_file(outs))
+ if(!cond_unmet && !tool_create_output_file(outs, config))
result = CURLE_WRITE_ERROR;
}
/* default headers output stream is stdout */
heads = &per->heads;
heads->stream = stdout;
- heads->config = config;
/* Single header file for all URLs */
if(config->headerfile) {
}
}
+ hdrcbdata = &per->hdrcbdata;
+
+ outs = &per->outs;
+ input = &per->input;
+
+ per->outfile = NULL;
+ per->infdopen = FALSE;
+ per->infd = STDIN_FILENO;
+
+ /* default output stream is stdout */
+ outs->stream = stdout;
+
/* --etag-save */
etag_save = &per->etag_save;
etag_save->stream = stdout;
- etag_save->config = config;
+
if(config->etag_save_file) {
/* open file for output: */
if(strcmp(config->etag_save_file, "-")) {
}
}
- hdrcbdata = &per->hdrcbdata;
-
- outs = &per->outs;
- input = &per->input;
-
- per->outfile = NULL;
- per->infdopen = FALSE;
- per->infd = STDIN_FILENO;
-
- /* default output stream is stdout */
- outs->stream = stdout;
- outs->config = config;
-
if(metalink) {
/* For Metalink download, use name in Metalink file as
filename. */
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
curl_off_t ulnow)
{
struct per_transfer *per = clientp;
- struct OutStruct *outs = &per->outs;
- struct OperationConfig *config = outs->config;
+ struct OperationConfig *config = per->config;
per->dltotal = dltotal;
per->dlnow = dlnow;
per->ultotal = ultotal;
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
bool s_isreg;
bool fopened;
FILE *stream;
- struct OperationConfig *config;
curl_off_t bytes;
curl_off_t init;
#ifdef USE_METALINK