Commit b449b943 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

moved the libcurl init call

parent a6cb9b08
Loading
Loading
Loading
Loading
+111 −114
Original line number Diff line number Diff line
@@ -1440,12 +1440,10 @@ operate(struct Configurable *config, int argc, char *argv[])
  curl_memdebug("memdump");
#endif

  main_init(); /* inits winsock crap for windows */

  config->showerror=TRUE;
  config->conf=CONF_DEFAULT;
#if 0
  config->crlf=FALSE;
  config->quote=NULL;
#endif

  if(argc>1 &&
     (!strnequal("--", argv[1], 2) && (argv[1][0] == '-')) &&
@@ -1454,9 +1452,6 @@ operate(struct Configurable *config, int argc, char *argv[])
     * The first flag, that is not a verbose name, but a shortname
     * and it includes the 'q' flag!
     */
#if 0
    fprintf(stderr, "I TURNED OFF THE CRAP\n");
#endif
    ;
  }
  else {
@@ -1536,6 +1531,15 @@ operate(struct Configurable *config, int argc, char *argv[])
  else
    allocuseragent = TRUE;

  /*
   * Get a curl handle to use for all forthcoming curl transfers.  Cleanup
   * when all transfers are done. This is supported with libcurl 7.7 and
   * should not be attempted on previous versions.
   */
  curl = curl_easy_init();
  if(!curl)
    return CURLE_FAILED_INIT;

  urlnode = config->url_list;

  /* loop through the list of given URLs */
@@ -1721,10 +1725,6 @@ operate(struct Configurable *config, int argc, char *argv[])
#endif


      main_init();

      curl = curl_easy_init();
      if(curl) {
      curl_easy_setopt(curl, CURLOPT_FILE, (FILE *)&outs); /* where to store */
      /* what call to write: */
      curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
@@ -1826,16 +1826,8 @@ operate(struct Configurable *config, int argc, char *argv[])
        ourWriteOut(curl, config->writeout);
      }
        
        /* always cleanup */
        curl_easy_cleanup(curl);
        
      if((res!=CURLE_OK) && config->showerror)
        fprintf(config->errors, "curl: (%d) %s\n", res, errorbuffer);
      }
      else
        fprintf(config->errors, "curl: failed to init libcurl!\n");

      main_free();

      if((config->errors != stderr) &&
         (config->errors != stdout))
@@ -1883,6 +1875,11 @@ operate(struct Configurable *config, int argc, char *argv[])
  if(allocuseragent)
    free(config->useragent);

  /* cleanup the curl handle! */
  curl_easy_cleanup(curl);

  main_free(); /* cleanup the winsock stuff for windows */

  return res;
}