# define memory_tracking_init() Curl_nop_stmt
#endif
+/*
+ * This is the main global constructor for the app. Call this before
+ * _any_ libcurl usage. If this fails, *NO* libcurl functions may be
+ * used, or havoc may be the result.
+ */
+static CURLcode main_init(void)
+{
+#if defined(__DJGPP__) || defined(__GO32__)
+ /* stop stat() wasting time */
+ _djstat_flags |= _STAT_INODE | _STAT_EXEC_MAGIC | _STAT_DIRSIZE;
+#endif
+
+ return curl_global_init(CURL_GLOBAL_DEFAULT);
+}
+
+/*
+ * This is the main global destructor for the app. Call this after
+ * _all_ libcurl usage is done.
+ */
+static void main_free(void)
+{
+ curl_global_cleanup();
+ convert_cleanup();
+ metalink_cleanup();
+}
+
/*
** curl tool main function.
*/
/* Initialise the config */
init_config(config);
- /* Start our curl operation */
- res = operate(config, argc, argv);
+ /* Initialize the curl library - do not call any libcurl functions before
+ this point */
+ if(!main_init()) {
+ /* Start our curl operation */
+ res = operate(config, argc, argv);
+
+ /* Perform the main cleanup */
+ main_free();
+ }
+ else {
+ helpf(config->errors, "error initializing curl library\n");
+ res = CURLE_FAILED_INIT;
+ }
#ifdef __SYMBIAN32__
if(config->showerror)
heads.stream = stdout;
heads.config = config;
- /*
- ** Initialize curl library - do not call any libcurl functions before
- ** this point.
- */
- if(main_init() != CURLE_OK) {
- helpf(config->errors, "error initializing curl library\n");
- return CURLE_FAILED_INIT;
- }
-
/* Get libcurl info right away */
if(get_libcurl_info() != CURLE_OK) {
helpf(config->errors, "error retrieving curl library information\n");
- main_free();
return CURLE_FAILED_INIT;
}
curl = curl_easy_init();
if(!curl) {
helpf(config->errors, "error initializing curl easy handle\n");
- main_free();
return CURLE_FAILED_INIT;
}
config->easy = curl;
/* Release metalink related resources here */
clean_metalink(config);
- main_free(); /* cleanup */
-
return res;
}
return CURLE_OK;
}
-/*
- * This is the main global constructor for the app. Call this before
- * _any_ libcurl usage. If this fails, *NO* libcurl functions may be
- * used, or havoc may be the result.
- */
-CURLcode main_init(void)
-{
-#if defined(__DJGPP__) || defined(__GO32__)
- /* stop stat() wasting time */
- _djstat_flags |= _STAT_INODE | _STAT_EXEC_MAGIC | _STAT_DIRSIZE;
-#endif
-
- return curl_global_init(CURL_GLOBAL_DEFAULT);
-}
-
-/*
- * This is the main global destructor for the app. Call this after
- * _all_ libcurl usage is done.
- */
-void main_free(void)
-{
- curl_global_cleanup();
- convert_cleanup();
- metalink_cleanup();
-}
-
CURLcode get_url_file_name(char **filename, const char *url);
-CURLcode main_init(void);
-
-void main_free(void);
-
#endif /* HEADER_CURL_TOOL_OPERHLP_H */