curl: add my_setopt_long() and _offt()

Two new dedicated functions for setting long and curl_off_t options with
curl_easy_setopt(). These make it easier to make sure we pass on the
right option (types) so that the --libcurl code also gets right.

Corrected a few errors.

Closes #16669
This commit is contained in:
Daniel Stenberg 2025-03-11 10:34:47 +01:00
parent 763fa529df
commit dc12ecd5db
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 197 additions and 195 deletions

View file

@ -97,6 +97,12 @@ CURLcode tool_setopt_mimepost(CURL *curl, struct GlobalConfig *config,
CURLcode tool_setopt_slist(CURL *curl, struct GlobalConfig *config,
const char *name, CURLoption tag,
struct curl_slist *list);
CURLcode tool_setopt_long(CURL *curl, struct GlobalConfig *global,
const char *name, CURLoption tag,
long lval);
CURLcode tool_setopt_offt(CURL *curl, struct GlobalConfig *global,
const char *name, CURLoption tag,
curl_off_t lval);
CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *global,
struct OperationConfig *config,
const char *name, CURLoption tag, ...);
@ -104,6 +110,12 @@ CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *global,
#define my_setopt(x,y,z) \
SETOPT_CHECK(tool_setopt(x, FALSE, global, config, #y, y, z), y)
#define my_setopt_long(x,y,z) \
SETOPT_CHECK(tool_setopt_long(x, global, #y, y, z), y)
#define my_setopt_offt(x,y,z) \
SETOPT_CHECK(tool_setopt_offt(x, global, #y, y, z), y)
#define my_setopt_str(x,y,z) \
SETOPT_CHECK(tool_setopt(x, TRUE, global, config, #y, y, z), y)
@ -133,7 +145,13 @@ CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *global,
#define my_setopt(x,y,z) \
SETOPT_CHECK(curl_easy_setopt(x, y, z), y)
#define my_setopt_str(x,y,z) \
#define my_setopt_long(x,y,z) \
SETOPT_CHECK(curl_easy_setopt(x, y, (long)(z)), y)
#define my_setopt_offt(x,y,z) \
SETOPT_CHECK(curl_easy_setopt(x, y, (curl_off_t)(z)), y)
#define my_setopt_str(x,y,z) \
SETOPT_CHECK(curl_easy_setopt(x, y, z), y)
#define my_setopt_enum(x,y,z) \