Revert "Update to 7.44.0"
[platform/upstream/curl.git] / src / tool_easysrc.c
index f672386..3db27bb 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2012, 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
@@ -19,9 +19,7 @@
  * KIND, either express or implied.
  *
  ***************************************************************************/
-#include "setup.h"
-
-#include <curl/curl.h>
+#include "tool_setup.h"
 
 #ifndef CURL_DISABLE_LIBCURL_OPTION
 
@@ -124,7 +122,7 @@ CURLcode easysrc_addf(struct curl_slist **plist, const char *fmt, ...)
   return ret;
 }
 
-#define CHKRET(v) do {CURLcode ret = (v); if(ret) return ret;} while(0)
+#define CHKRET(v) do {CURLcode ret = (v); if(ret) return ret;} WHILE_FALSE
 
 CURLcode easysrc_init(void)
 {
@@ -142,7 +140,7 @@ CURLcode easysrc_perform(void)
     const char *c;
     CHKRET(easysrc_add(&easysrc_code, ""));
     /* Preamble comment */
-    for(i=0; ((c = srchard[i]) != '\0'); i++)
+    for(i=0; ((c = srchard[i]) != NULL); i++)
       CHKRET(easysrc_add(&easysrc_code, c));
     /* Each unconverted option */
     for(ptr=easysrc_toohard; ptr; ptr = ptr->next)
@@ -156,18 +154,20 @@ CURLcode easysrc_perform(void)
 
   CHKRET(easysrc_add(&easysrc_code, ""));
   CHKRET(easysrc_add(&easysrc_code, "ret = curl_easy_perform(hnd);"));
+  CHKRET(easysrc_add(&easysrc_code, ""));
+
   return CURLE_OK;
 }
 
 CURLcode easysrc_cleanup(void)
 {
-  CHKRET(easysrc_add(&easysrc_code, ""));
   CHKRET(easysrc_add(&easysrc_code, "curl_easy_cleanup(hnd);"));
   CHKRET(easysrc_add(&easysrc_code, "hnd = NULL;"));
+
   return CURLE_OK;
 }
 
-void dumpeasysrc(struct Configurable *config)
+void dumpeasysrc(struct GlobalConfig *config)
 {
   struct curl_slist *ptr;
   char *o = config->libcurl;
@@ -176,18 +176,18 @@ void dumpeasysrc(struct Configurable *config)
     FILE *out;
     bool fopened = FALSE;
     if(strcmp(o, "-")) {
-      out = fopen(o, "wt");
+      out = fopen(o, "w");
       fopened = TRUE;
     }
     else
       out = stdout;
     if(!out)
-      warnf(config, "Failed to open %s to write libcurl code!\n", o);
+      warnf(config->current, "Failed to open %s to write libcurl code!\n", o);
     else {
       int i;
       const char *c;
 
-      for(i=0; ((c = srchead[i]) != '\0'); i++)
+      for(i=0; ((c = srchead[i]) != NULL); i++)
         fprintf(out, "%s\n", c);
 
       /* Declare variables used for complex setopt values */
@@ -215,7 +215,7 @@ void dumpeasysrc(struct Configurable *config)
       for(ptr=easysrc_clean; ptr; ptr = ptr->next)
         fprintf(out, "  %s\n", ptr->data);
 
-      for(i=0; ((c = srcend[i]) != '\0'); i++)
+      for(i=0; ((c = srcend[i]) != NULL); i++)
         fprintf(out, "%s\n", c);
 
       if(fopened)