tool_operate: move config2setopts to separate file, split into subs

To decrease size and complexity. Complexity taken down from 190 to 80.

Bonus:

- remove leftover HTTP/0.9 warning never triggered since hyper was dropped
- remove the ftp-skip-ip option unless FTP is used
- only set HTTP options if HTTP(S) is used
- remove use of the pointless SETOPT_CHECK macro

Side-effect:

- The order of the options in --libcurl is modified

Closes #17352
This commit is contained in:
Daniel Stenberg 2025-05-15 09:49:47 +02:00
parent 9c8cbbda5b
commit f97d372703
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
16 changed files with 1225 additions and 1101 deletions

View file

@ -54,6 +54,7 @@ CURLX_HFILES = \
../lib/curlx/warnless.h
CURL_CFILES = \
config2setopts.c \
slist_wc.c \
terminal.c \
tool_bname.c \
@ -99,6 +100,7 @@ CURL_CFILES = \
var.c
CURL_HFILES = \
config2setopts.h \
slist_wc.h \
terminal.h \
tool_binmode.h \

1137
src/config2setopts.c Normal file

File diff suppressed because it is too large Load diff

33
src/config2setopts.h Normal file
View file

@ -0,0 +1,33 @@
#ifndef HEADER_CURL_CONFIG2SETOPTS_H
#define HEADER_CURL_CONFIG2SETOPTS_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
* SPDX-License-Identifier: curl
*
***************************************************************************/
CURLcode config2setopts(struct GlobalConfig *global,
struct OperationConfig *config,
struct per_transfer *per,
CURL *curl,
CURLSH *share);
#endif /* HEADER_CURL_CONFIG2SETOPTS_H */

File diff suppressed because it is too large Load diff

View file

@ -31,10 +31,6 @@
* Macros used in operate()
*/
#define SETOPT_CHECK(v,opt) do { \
result = (v); \
} while(0)
#ifndef CURL_DISABLE_LIBCURL_OPTION
/* Associate symbolic names with option values */
@ -108,70 +104,62 @@ CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *global,
const char *name, CURLoption tag, ...);
#define my_setopt(x,y,z) \
SETOPT_CHECK(tool_setopt(x, FALSE, global, config, #y, y, z), y)
tool_setopt(x, FALSE, global, config, #y, y, z)
#define my_setopt_long(x,y,z) \
SETOPT_CHECK(tool_setopt_long(x, global, #y, y, z), y)
tool_setopt_long(x, global, #y, y, z)
#define my_setopt_offt(x,y,z) \
SETOPT_CHECK(tool_setopt_offt(x, global, #y, y, z), y)
tool_setopt_offt(x, global, #y, y, z)
#define my_setopt_str(x,y,z) \
SETOPT_CHECK(tool_setopt(x, TRUE, global, config, #y, y, z), y)
tool_setopt(x, TRUE, global, config, #y, y, z)
#define my_setopt_enum(x,y,z) \
SETOPT_CHECK(tool_setopt_enum(x, global, #y, y, setopt_nv_ ## y, z), y)
tool_setopt_enum(x, global, #y, y, setopt_nv_ ## y, z)
#define my_setopt_SSLVERSION(x,y,z) \
SETOPT_CHECK(tool_setopt_SSLVERSION(x, global, #y, y, z), y)
tool_setopt_SSLVERSION(x, global, #y, y, z)
#define my_setopt_bitmask(x,y,z) \
SETOPT_CHECK(tool_setopt_bitmask(x, global, #y, y, setopt_nv_ ## y, z), y)
tool_setopt_bitmask(x, global, #y, y, setopt_nv_ ## y, z)
#define my_setopt_mimepost(x,y,z) \
SETOPT_CHECK(tool_setopt_mimepost(x, global, #y, y, z), y)
tool_setopt_mimepost(x, global, #y, y, z)
#define my_setopt_slist(x,y,z) \
SETOPT_CHECK(tool_setopt_slist(x, global, #y, y, z), y)
#define res_setopt(x,y,z) tool_setopt(x, FALSE, global, config, #y, y, z)
#define res_setopt_str(x,y,z) tool_setopt(x, TRUE, global, config, #y, y, z)
tool_setopt_slist(x, global, #y, y, z)
#else /* CURL_DISABLE_LIBCURL_OPTION */
/* No --libcurl, so pass options directly to library */
#define my_setopt(x,y,z) \
SETOPT_CHECK(curl_easy_setopt(x, y, z), y)
curl_easy_setopt(x, y, z)
#define my_setopt_long(x,y,z) \
SETOPT_CHECK(curl_easy_setopt(x, y, (long)(z)), y)
curl_easy_setopt(x, y, (long)(z))
#define my_setopt_offt(x,y,z) \
SETOPT_CHECK(curl_easy_setopt(x, y, (curl_off_t)(z)), y)
curl_easy_setopt(x, y, (curl_off_t)(z))
#define my_setopt_str(x,y,z) \
SETOPT_CHECK(curl_easy_setopt(x, y, z), y)
curl_easy_setopt(x, y, z)
#define my_setopt_enum(x,y,z) \
SETOPT_CHECK(curl_easy_setopt(x, y, z), y)
curl_easy_setopt(x, y, z)
#define my_setopt_SSLVERSION(x,y,z) \
SETOPT_CHECK(curl_easy_setopt(x, y, z), y)
curl_easy_setopt(x, y, z)
#define my_setopt_bitmask(x,y,z) \
SETOPT_CHECK(curl_easy_setopt(x, y, z), y)
curl_easy_setopt(x, y, (long)z)
#define my_setopt_mimepost(x,y,z) \
SETOPT_CHECK(curl_easy_setopt(x, y, z), y)
curl_easy_setopt(x, y, z)
#define my_setopt_slist(x,y,z) \
SETOPT_CHECK(curl_easy_setopt(x, y, z), y)
#define res_setopt(x,y,z) curl_easy_setopt(x,y,z)
#define res_setopt_str(x,y,z) curl_easy_setopt(x,y,z)
curl_easy_setopt(x, y, z)
#endif /* CURL_DISABLE_LIBCURL_OPTION */