* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2015, 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 "tool_setup.h"
-#include <curl/curl.h>
-
#include "tool_cfgable.h"
+#include "tool_main.h"
#include "memdebug.h" /* keep this as LAST include */
-void free_config_fields(struct Configurable *config)
+void config_init(struct OperationConfig* config)
{
- struct getout *urlnode;
+ memset(config, 0, sizeof(struct OperationConfig));
+
+ config->postfieldsize = -1;
+ config->use_httpget = FALSE;
+ config->create_dirs = FALSE;
+ config->maxredirs = DEFAULT_MAXREDIRS;
+ config->proto = CURLPROTO_ALL; /* FIXME: better to read from library */
+ config->proto_present = FALSE;
+ config->proto_redir = CURLPROTO_ALL & /* All except FILE, SCP and SMB */
+ ~(CURLPROTO_FILE | CURLPROTO_SCP | CURLPROTO_SMB |
+ CURLPROTO_SMBS);
+ config->proto_redir_present = FALSE;
+}
- if(config->easy) {
- curl_easy_cleanup(config->easy);
- config->easy = NULL;
- }
+static void free_config_fields(struct OperationConfig *config)
+{
+ struct getout *urlnode;
Curl_safefree(config->random_file);
Curl_safefree(config->egd_file);
Curl_safefree(config->proxyuserpwd);
Curl_safefree(config->proxy);
+ Curl_safefree(config->dns_ipv6_addr);
+ Curl_safefree(config->dns_ipv4_addr);
+ Curl_safefree(config->dns_interface);
+ Curl_safefree(config->dns_servers);
+
Curl_safefree(config->noproxy);
Curl_safefree(config->mail_from);
Curl_safefree(config->cacert);
Curl_safefree(config->capath);
Curl_safefree(config->crlfile);
+ Curl_safefree(config->pinnedpubkey);
Curl_safefree(config->key);
Curl_safefree(config->key_type);
Curl_safefree(config->key_passwd);
Curl_safefree(config->customrequest);
Curl_safefree(config->krblevel);
- Curl_safefree(config->trace_dump);
- config->trace_stream = NULL; /* closed elsewhere when appropriate */
+ Curl_safefree(config->xoauth2_bearer);
+ Curl_safefree(config->unix_socket_path);
Curl_safefree(config->writeout);
- config->errors = NULL; /* closed elsewhere when appropriate */
-
curl_slist_free_all(config->quote);
curl_slist_free_all(config->postquote);
curl_slist_free_all(config->prequote);
curl_slist_free_all(config->headers);
+ curl_slist_free_all(config->proxyheaders);
if(config->httppost) {
curl_formfree(config->httppost);
Curl_safefree(config->ftp_account);
Curl_safefree(config->ftp_alternative_to_user);
-
- Curl_safefree(config->libcurl);
}
+void config_free(struct OperationConfig *config)
+{
+ struct OperationConfig *last = config;
+
+ /* Free each of the structures in reverse order */
+ while(last) {
+ struct OperationConfig *prev = last->prev;
+
+ free_config_fields(last);
+ free(last);
+
+ last = prev;
+ }
+}