Revert "Update to 7.40.1"
[platform/upstream/curl.git] / src / tool_cfgable.c
index e74ea43..2fdae07 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2014, 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
  * KIND, either express or implied.
  *
  ***************************************************************************/
-#include "setup.h"
-
-#include <curl/curl.h>
+#include "tool_setup.h"
 
 #include "tool_cfgable.h"
+#include "tool_main.h"
 
 #include "memdebug.h" /* keep this as LAST include */
 
-/* TODO: review handling of unhandled fields marked below */
+void config_init(struct OperationConfig* config)
+{
+  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 & ~(CURLPROTO_FILE|CURLPROTO_SCP); /* not FILE or SCP */
+  config->proto_redir_present = FALSE;
+}
 
-void free_config_fields(struct Configurable *config)
+static void free_config_fields(struct OperationConfig *config)
 {
   struct getout *urlnode;
 
-  if(config->easy) {
-    curl_easy_cleanup(config->easy);
-    config->easy = NULL;
-  }
-
   Curl_safefree(config->random_file);
   Curl_safefree(config->egd_file);
   Curl_safefree(config->useragent);
@@ -61,9 +68,16 @@ void free_config_fields(struct Configurable *config)
   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_slist_free_all(config->mail_rcpt);
+  Curl_safefree(config->mail_auth);
 
   Curl_safefree(config->netrc_file);
 
@@ -96,26 +110,23 @@ void free_config_fields(struct Configurable *config)
 
   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->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);
     config->httppost = NULL;
   }
-
-  /* config->last_post not handled */
+  config->last_post = NULL;
 
   curl_slist_free_all(config->telnet_options);
   curl_slist_free_all(config->resolve);
@@ -125,7 +136,19 @@ void free_config_fields(struct Configurable *config)
 
   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;
+  }
+}