aboutsummaryrefslogtreecommitdiff
path: root/src/tool_operate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tool_operate.c')
-rw-r--r--src/tool_operate.c69
1 files changed, 21 insertions, 48 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 783d86cce..faecd8f46 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -187,24 +187,8 @@ static curl_off_t VmsSpecialSize(const char * name,
}
#endif /* __VMS */
-static CURLcode operate_init(struct OperationConfig *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;
- }
-
- /* Setup proper locale from environment */
-#ifdef HAVE_SETLOCALE
- setlocale(LC_ALL, "");
-#endif
-
- return CURLE_OK;
-}
-
-static CURLcode operate_do(struct OperationConfig *config)
+static CURLcode operate_do(struct GlobalConfig *global,
+ struct OperationConfig *config)
{
char errorbuffer[CURL_ERROR_SIZE];
struct ProgressData progressbar;
@@ -425,7 +409,7 @@ static CURLcode operate_do(struct OperationConfig *config)
if(!config->globoff && infiles) {
/* Unless explicitly shut off */
res = glob_url(&inglob, infiles, &infilenum,
- config->showerror?config->errors:NULL);
+ global->showerror?config->errors:NULL);
if(res) {
Curl_safefree(outfiles);
break;
@@ -476,7 +460,7 @@ static CURLcode operate_do(struct OperationConfig *config)
/* Unless explicitly shut off, we expand '{...}' and '[...]'
expressions and return total number of URLs in pattern set */
res = glob_url(&urls, urlnode->url, &urlnum,
- config->showerror?config->errors:NULL);
+ global->showerror?config->errors:NULL);
if(res) {
Curl_safefree(uploadfile);
break;
@@ -1571,12 +1555,12 @@ static CURLcode operate_do(struct OperationConfig *config)
#ifdef __VMS
if(is_vms_shell()) {
/* VMS DCL shell behavior */
- if(!config->showerror)
+ if(!global->showerror)
vms_show = VMSSTS_HIDE;
}
else
#endif
- if(res && config->showerror) {
+ if(res && global->showerror) {
fprintf(config->errors, "curl: (%d) %s\n", res, (errorbuffer[0]) ?
errorbuffer : curl_easy_strerror((CURLcode)res));
if(res == CURLE_SSL_CACERT)
@@ -1789,36 +1773,28 @@ static CURLcode operate_do(struct OperationConfig *config)
dumpeasysrc(config);
#endif
- return (CURLcode)res;
-}
-
-static void operate_free(struct OperationConfig *config)
-{
- if(config->easy) {
- curl_easy_cleanup(config->easy);
- config->easy = NULL;
- }
-
/* Release metalink related resources here */
clean_metalink(config);
+
+ return (CURLcode)res;
}
-CURLcode operate(struct OperationConfig *config, int argc, argv_item_t argv[])
+CURLcode operate(struct GlobalConfig *config, int argc, argv_item_t argv[])
{
CURLcode result = CURLE_OK;
- /* Initialize the easy interface */
- result = operate_init(config);
- if(result)
- return result;
+ /* Setup proper locale from environment */
+#ifdef HAVE_SETLOCALE
+ setlocale(LC_ALL, "");
+#endif
/* Parse .curlrc if necessary */
if((argc == 1) || (!curlx_strequal(argv[1], "-q"))) {
parseconfig(NULL, config); /* ignore possible failure */
/* If we had no arguments then make sure a url was specified in .curlrc */
- if((argc < 2) && (!config->url_list)) {
- helpf(config->errors, NULL);
+ if((argc < 2) && (!config->first->url_list)) {
+ helpf(config->first->errors, NULL);
result = CURLE_FAILED_INIT;
}
}
@@ -1847,7 +1823,7 @@ CURLcode operate(struct OperationConfig *config, int argc, argv_item_t argv[])
/* Perform the main operations */
else {
size_t count = 0;
- struct OperationConfig *operation = config;
+ struct OperationConfig *operation = config->first;
/* Get the required aguments for each operation */
while(!result && operation) {
@@ -1856,20 +1832,17 @@ CURLcode operate(struct OperationConfig *config, int argc, argv_item_t argv[])
operation = operation->next;
}
- /* Reset the operation pointer */
- operation = config;
+ /* Set the current operation pointer */
+ config->current = config->first;
/* Perform each operation */
- while(!result && operation) {
- result = operate_do(operation);
+ while(!result && config->current) {
+ result = operate_do(config, config->current);
- operation = operation->next;
+ config->current = config->current->next;
}
}
}
- /* Perform the cleanup */
- operate_free(config);
-
return result;
}