aboutsummaryrefslogtreecommitdiff
path: root/src/tool_operate.c
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2014-02-02 15:28:25 +0000
committerSteve Holme <steve_holme@hotmail.com>2014-02-04 20:14:39 +0000
commitdde308108501ba1e7ebf817b5e5eaa61fa1031b6 (patch)
tree5eddf4391820a975509cb107f2052ff5c2de3d4d /src/tool_operate.c
parent2dc7ad23fde91d6dfde172c8c673428ea0c07028 (diff)
tool_operate: Introduced operate_init() function
Diffstat (limited to 'src/tool_operate.c')
-rw-r--r--src/tool_operate.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c
index da76f55f4..a4e8069c8 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -184,6 +184,17 @@ static curl_off_t VmsSpecialSize(const char * name,
}
#endif /* __VMS */
+static CURLcode operate_init(struct Configurable *config)
+{
+ /* Get a curl handle to use for all forthcoming curl transfers */
+ config->easy = curl_easy_init();
+ if(!config->easy) {
+ helpf(config->errors, "error initializing curl easy handle\n");
+ return CURLE_FAILED_INIT;
+ }
+
+ return CURLE_OK;
+}
static int operate_do(struct Configurable *config, int argc, argv_item_t argv[])
{
@@ -196,7 +207,7 @@ static int operate_do(struct Configurable *config, int argc, argv_item_t argv[])
metalinkfile *mlfile_last = NULL;
- CURL *curl = NULL;
+ CURL *curl = config->easy;
char *httpgetfields = NULL;
int res = 0;
@@ -212,14 +223,6 @@ static int operate_do(struct Configurable *config, int argc, argv_item_t argv[])
heads.stream = stdout;
heads.config = config;
- /* Get a curl handle to use for all forthcoming curl transfers */
- curl = curl_easy_init();
- if(!curl) {
- helpf(config->errors, "error initializing curl easy handle\n");
- return CURLE_FAILED_INIT;
- }
- config->easy = curl;
-
/*
** Beyond this point no return'ing from this function allowed.
** Jump to label 'quit_curl' in order to abandon this function
@@ -1842,5 +1845,13 @@ static int operate_do(struct Configurable *config, int argc, argv_item_t argv[])
int operate(struct Configurable *config, int argc, argv_item_t argv[])
{
+ int result = 0;
+
+ /* Initialize the easy interface */
+ result = operate_init(config);
+ if(result)
+ return result;
+
+ /* Perform the main operation */
return operate_do(config, argc, argv);
}