mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
--libcurl: list the tricky options instead of using [REMARK]
I think the [REMARK] and commented function calls cluttered the code a bit too much and made the generated code ugly to read. Now we instead track the remarks one specially and just lists them at the end of the generated code more as additional information.
This commit is contained in:
parent
0417d34533
commit
bd36927f18
41
src/main.c
41
src/main.c
@ -4069,6 +4069,7 @@ output_expected(const char* url, const char* uploadfile)
|
||||
#define my_setopt_str(x,y,z) _my_setopt(x, TRUE, config, #y, y, z)
|
||||
|
||||
static struct curl_slist *easycode;
|
||||
static struct curl_slist *easycode_remarks;
|
||||
|
||||
static CURLcode _my_setopt(CURL *curl, bool str, struct Configurable *config,
|
||||
const char *name, CURLoption tag, ...);
|
||||
@ -4131,12 +4132,22 @@ static CURLcode _my_setopt(CURL *curl, bool str, struct Configurable *config,
|
||||
if(config->libcurl && !skip) {
|
||||
/* we only use this for real if --libcurl was used */
|
||||
|
||||
bufp = curlx_maprintf("%scurl_easy_setopt(hnd, %s, %s);%s",
|
||||
remark?"/* ":"", name, value,
|
||||
remark?" [REMARK] */":"");
|
||||
if(remark)
|
||||
bufp = curlx_maprintf("%s set to a %s", name, value);
|
||||
else
|
||||
bufp = curlx_maprintf("curl_easy_setopt(hnd, %s, %s);", name, value);
|
||||
|
||||
if (!bufp || !curl_slist_append(easycode, bufp))
|
||||
if (!bufp)
|
||||
ret = CURLE_OUT_OF_MEMORY;
|
||||
else {
|
||||
struct curl_slist *list =
|
||||
curl_slist_append(remark?easycode_remarks:easycode, bufp);
|
||||
|
||||
if(remark)
|
||||
easycode_remarks = list;
|
||||
else
|
||||
easycode = list;
|
||||
}
|
||||
if (bufp)
|
||||
curl_free(bufp);
|
||||
}
|
||||
@ -4147,8 +4158,7 @@ static CURLcode _my_setopt(CURL *curl, bool str, struct Configurable *config,
|
||||
|
||||
static const char * const srchead[]={
|
||||
"/********* Sample code generated by the curl command line tool **********",
|
||||
" * Lines with [REMARK] below might need to be modified to make this code ",
|
||||
" * usable. Add error code checking where appropriate.",
|
||||
" * Add error code checking where appropriate!",
|
||||
" * Compile this with a suitable header include path. Then link with ",
|
||||
" * libcurl.",
|
||||
" * If you use any *_LARGE options, make sure your compiler figure",
|
||||
@ -4167,7 +4177,7 @@ static const char * const srchead[]={
|
||||
|
||||
static void dumpeasycode(struct Configurable *config)
|
||||
{
|
||||
struct curl_slist *ptr = easycode;
|
||||
struct curl_slist *ptr;
|
||||
char *o = config->libcurl;
|
||||
|
||||
if(o) {
|
||||
@ -4197,10 +4207,27 @@ static void dumpeasycode(struct Configurable *config)
|
||||
fprintf(out, "%s\n", c);
|
||||
}
|
||||
|
||||
ptr = easycode;
|
||||
while(ptr) {
|
||||
fprintf(out, " %s\n", ptr->data);
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
ptr = easycode_remarks;
|
||||
if(ptr) {
|
||||
fprintf(out,
|
||||
"\n /* Here is a list of options the curl code"
|
||||
" used that cannot get generated\n"
|
||||
" as source easily. You may select to either"
|
||||
" not use them or implement\n them yourself.\n"
|
||||
"\n");
|
||||
while(ptr) {
|
||||
fprintf(out, " %s\n", ptr->data);
|
||||
ptr = ptr->next;
|
||||
}
|
||||
fprintf(out, "\n */\n");
|
||||
}
|
||||
|
||||
fprintf(out,
|
||||
" return (int)ret;\n"
|
||||
"}\n"
|
||||
|
Loading…
Reference in New Issue
Block a user