mirror of https://github.com/moparisthebest/curl
tool: Fixed libcurl source output for multiple operations
Correctly output libcurl source code that includes multiply operations as specified by --next. Note that each operation evaluates to a single curl_easy_perform() in source code form. Also note that the output could be optimised a little so global config options are only output once rather than per operation as is presently the case.
This commit is contained in:
parent
46b1d0a047
commit
68920b6c11
|
@ -154,14 +154,16 @@ CURLcode easysrc_perform(void)
|
||||||
|
|
||||||
CHKRET(easysrc_add(&easysrc_code, ""));
|
CHKRET(easysrc_add(&easysrc_code, ""));
|
||||||
CHKRET(easysrc_add(&easysrc_code, "ret = curl_easy_perform(hnd);"));
|
CHKRET(easysrc_add(&easysrc_code, "ret = curl_easy_perform(hnd);"));
|
||||||
|
CHKRET(easysrc_add(&easysrc_code, ""));
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
CURLcode easysrc_cleanup(void)
|
CURLcode easysrc_cleanup(void)
|
||||||
{
|
{
|
||||||
CHKRET(easysrc_add(&easysrc_code, ""));
|
|
||||||
CHKRET(easysrc_add(&easysrc_code, "curl_easy_cleanup(hnd);"));
|
CHKRET(easysrc_add(&easysrc_code, "curl_easy_cleanup(hnd);"));
|
||||||
CHKRET(easysrc_add(&easysrc_code, "hnd = NULL;"));
|
CHKRET(easysrc_add(&easysrc_code, "hnd = NULL;"));
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -313,14 +313,6 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CURL_DISABLE_LIBCURL_OPTION
|
|
||||||
res = easysrc_init();
|
|
||||||
if(res) {
|
|
||||||
helpf(global->errors, "out of memory\n");
|
|
||||||
goto quit_curl;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Single header file for all URLs */
|
/* Single header file for all URLs */
|
||||||
if(config->headerfile) {
|
if(config->headerfile) {
|
||||||
/* open file for output: */
|
/* open file for output: */
|
||||||
|
@ -1760,26 +1752,15 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
||||||
/* Free list of given URLs */
|
/* Free list of given URLs */
|
||||||
clean_getout(config);
|
clean_getout(config);
|
||||||
|
|
||||||
#ifndef CURL_DISABLE_LIBCURL_OPTION
|
|
||||||
easysrc_cleanup();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
hdrcbdata.heads = NULL;
|
hdrcbdata.heads = NULL;
|
||||||
|
|
||||||
/* Close function-local opened file descriptors */
|
/* Close function-local opened file descriptors */
|
||||||
|
|
||||||
if(heads.fopened && heads.stream)
|
if(heads.fopened && heads.stream)
|
||||||
fclose(heads.stream);
|
fclose(heads.stream);
|
||||||
|
|
||||||
if(heads.alloc_filename)
|
if(heads.alloc_filename)
|
||||||
Curl_safefree(heads.filename);
|
Curl_safefree(heads.filename);
|
||||||
|
|
||||||
#ifndef CURL_DISABLE_LIBCURL_OPTION
|
|
||||||
/* Dump the libcurl code if previously enabled.
|
|
||||||
NOTE: that this function relies on config->errors amongst other things
|
|
||||||
so not everything can be closed and cleaned before this is called */
|
|
||||||
dumpeasysrc(global);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Release metalink related resources here */
|
/* Release metalink related resources here */
|
||||||
clean_metalink(config);
|
clean_metalink(config);
|
||||||
|
|
||||||
|
@ -1827,29 +1808,50 @@ CURLcode operate(struct GlobalConfig *config, int argc, argv_item_t argv[])
|
||||||
else
|
else
|
||||||
result = CURLE_FAILED_INIT;
|
result = CURLE_FAILED_INIT;
|
||||||
}
|
}
|
||||||
/* Perform the main operations */
|
|
||||||
else {
|
else {
|
||||||
size_t count = 0;
|
#ifndef CURL_DISABLE_LIBCURL_OPTION
|
||||||
struct OperationConfig *operation = config->first;
|
/* Initialise the libcurl source output */
|
||||||
|
result = easysrc_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Get the required aguments for each operation */
|
/* Perform the main operations */
|
||||||
while(!result && operation) {
|
if(!result) {
|
||||||
result = get_args(operation, count++);
|
size_t count = 0;
|
||||||
|
struct OperationConfig *operation = config->first;
|
||||||
|
|
||||||
operation = operation->next;
|
/* Get the required aguments for each operation */
|
||||||
}
|
while(!result && operation) {
|
||||||
|
result = get_args(operation, count++);
|
||||||
/* Set the current operation pointer */
|
|
||||||
config->current = config->first;
|
operation = operation->next;
|
||||||
|
}
|
||||||
/* Perform each operation */
|
|
||||||
while(!result && config->current) {
|
/* Set the current operation pointer */
|
||||||
result = operate_do(config, config->current);
|
config->current = config->first;
|
||||||
|
|
||||||
config->current = config->current->next;
|
/* Perform each operation */
|
||||||
|
while(!result && config->current) {
|
||||||
|
result = operate_do(config, config->current);
|
||||||
|
|
||||||
|
config->current = config->current->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef CURL_DISABLE_LIBCURL_OPTION
|
||||||
|
/* Cleanup the libcurl source output */
|
||||||
|
easysrc_cleanup();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
helpf(config->errors, "out of memory\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef CURL_DISABLE_LIBCURL_OPTION
|
||||||
|
/* Dump the libcurl code if previously enabled.
|
||||||
|
NOTE: that this function relies on config->errors amongst other things
|
||||||
|
so not everything can be closed and cleaned before this is called */
|
||||||
|
dumpeasysrc(config);
|
||||||
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue