mirror of
https://github.com/curl/curl.git
synced 2026-05-30 11:37:28 +03:00
tool_getparam: refactored, simplified
- add dedicated option functions for bools/none/strings
- simplify clearing (some) arguments, use '*' instead of ' '
- scripts/top-complexity: remove getparameter from whitelist
- handle --help separately
- getstr and getstrn do not allow a NULL input
- improve the ;auto check, it needs to be trailing
- add toggle bit helper function
- unify an error message for bad --no- use
- introduce generic handling of deprecated options: ARG_DEPR
- handle --no- prefix on more booleans:
--cert-status
--doh-cert-status
--false-start
--mptcp
--ssl-no-revoke
--ssl-revoke-best-effort
--tcp-fastopen
Closes #17448
This commit is contained in:
parent
6eea7219a5
commit
698491f444
6 changed files with 1208 additions and 1233 deletions
|
|
@ -75,7 +75,7 @@ my @output=`$cmd`;
|
||||||
|
|
||||||
# these functions can have these scores, but not higher
|
# these functions can have these scores, but not higher
|
||||||
my %whitelist = (
|
my %whitelist = (
|
||||||
'getparameter' => 142
|
|
||||||
);
|
);
|
||||||
|
|
||||||
# functions with complexity above this level causes the function to return error
|
# functions with complexity above this level causes the function to return error
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ struct OperationConfig {
|
||||||
long retry_delay; /* delay between retries (in seconds) */
|
long retry_delay; /* delay between retries (in seconds) */
|
||||||
long retry_maxtime; /* maximum time to keep retrying */
|
long retry_maxtime; /* maximum time to keep retrying */
|
||||||
|
|
||||||
long mime_options; /* Mime option flags. */
|
unsigned long mime_options; /* Mime option flags. */
|
||||||
long tftp_blksize; /* TFTP BLKSIZE option */
|
long tftp_blksize; /* TFTP BLKSIZE option */
|
||||||
long alivetime; /* keepalive-time */
|
long alivetime; /* keepalive-time */
|
||||||
long alivecnt; /* keepalive-cnt */
|
long alivecnt; /* keepalive-cnt */
|
||||||
|
|
|
||||||
2427
src/tool_getparam.c
2427
src/tool_getparam.c
File diff suppressed because it is too large
Load diff
|
|
@ -317,6 +317,8 @@ typedef enum {
|
||||||
#define ARG_TYPEMASK 0x03
|
#define ARG_TYPEMASK 0x03
|
||||||
#define ARGTYPE(x) ((x) & ARG_TYPEMASK)
|
#define ARGTYPE(x) ((x) & ARG_TYPEMASK)
|
||||||
|
|
||||||
|
#define ARG_DEPR 0x10 /* deprecated option */
|
||||||
|
#define ARG_CLEAR 0x20 /* clear cmdline argument */
|
||||||
#define ARG_TLS 0x40 /* requires TLS support */
|
#define ARG_TLS 0x40 /* requires TLS support */
|
||||||
#define ARG_NO 0x80 /* set if the option is documented as --no-* */
|
#define ARG_NO 0x80 /* set if the option is documented as --no-* */
|
||||||
|
|
||||||
|
|
@ -347,7 +349,6 @@ typedef enum {
|
||||||
PARAM_NEXT_OPERATION,
|
PARAM_NEXT_OPERATION,
|
||||||
PARAM_NO_PREFIX,
|
PARAM_NO_PREFIX,
|
||||||
PARAM_NUMBER_TOO_LARGE,
|
PARAM_NUMBER_TOO_LARGE,
|
||||||
PARAM_NO_NOT_BOOLEAN,
|
|
||||||
PARAM_CONTDISP_RESUME_FROM, /* --continue-at and --remote-header-name */
|
PARAM_CONTDISP_RESUME_FROM, /* --continue-at and --remote-header-name */
|
||||||
PARAM_READ_ERROR,
|
PARAM_READ_ERROR,
|
||||||
PARAM_EXPAND_ERROR, /* --expand problem */
|
PARAM_EXPAND_ERROR, /* --expand problem */
|
||||||
|
|
@ -363,8 +364,6 @@ const struct LongShort *findlongopt(const char *opt);
|
||||||
const struct LongShort *findshortopt(char letter);
|
const struct LongShort *findshortopt(char letter);
|
||||||
|
|
||||||
ParameterError getparameter(const char *flag, const char *nextarg,
|
ParameterError getparameter(const char *flag, const char *nextarg,
|
||||||
argv_item_t cleararg1,
|
|
||||||
argv_item_t cleararg2,
|
|
||||||
bool *usedarg,
|
bool *usedarg,
|
||||||
struct GlobalConfig *global,
|
struct GlobalConfig *global,
|
||||||
struct OperationConfig *operation);
|
struct OperationConfig *operation);
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,6 @@ const char *param2text(ParameterError error)
|
||||||
return "the given option cannot be reversed with a --no- prefix";
|
return "the given option cannot be reversed with a --no- prefix";
|
||||||
case PARAM_NUMBER_TOO_LARGE:
|
case PARAM_NUMBER_TOO_LARGE:
|
||||||
return "too large number";
|
return "too large number";
|
||||||
case PARAM_NO_NOT_BOOLEAN:
|
|
||||||
return "used '--no-' for option that is not a boolean";
|
|
||||||
case PARAM_CONTDISP_RESUME_FROM:
|
case PARAM_CONTDISP_RESUME_FROM:
|
||||||
return "--continue-at and --remote-header-name cannot be combined";
|
return "--continue-at and --remote-header-name cannot be combined";
|
||||||
case PARAM_READ_ERROR:
|
case PARAM_READ_ERROR:
|
||||||
|
|
|
||||||
|
|
@ -172,8 +172,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
|
||||||
#ifdef DEBUG_CONFIG
|
#ifdef DEBUG_CONFIG
|
||||||
fprintf(tool_stderr, "PARAM: \"%s\"\n",(param ? param : "(null)"));
|
fprintf(tool_stderr, "PARAM: \"%s\"\n",(param ? param : "(null)"));
|
||||||
#endif
|
#endif
|
||||||
res = getparameter(option, param, NULL, NULL,
|
res = getparameter(option, param, &usedarg, global, operation);
|
||||||
&usedarg, global, operation);
|
|
||||||
operation = global->last;
|
operation = global->last;
|
||||||
|
|
||||||
if(!res && param && *param && !usedarg)
|
if(!res && param && *param && !usedarg)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue