mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 18:48:13 -07:00
cliparser CLIGetOptionList
This commit is contained in:
parent
afb06ec72c
commit
afbd80b906
2 changed files with 72 additions and 0 deletions
|
@ -51,6 +51,8 @@
|
|||
|
||||
#define CLIGetStrWithReturn(ctx, paramnum, data, datalen) if (CLIParamStrToBuf(arg_get_str((ctx), (paramnum)), (data), (*datalen), (datalen))) {CLIParserFree((ctx)); return PM3_ESOFT;}
|
||||
|
||||
#define CLIGetOptionListWithReturn(ctx, paramnum, option_array, option_array_len, value) if (CLIGetOptionList(arg_get_str((ctx), (paramnum)), (option_array), (option_array_len), (value))) {CLIParserFree((ctx)); return PM3_ESOFT;}
|
||||
|
||||
typedef struct {
|
||||
void **argtable;
|
||||
size_t argtableLen;
|
||||
|
@ -59,6 +61,14 @@ typedef struct {
|
|||
const char *programHelp;
|
||||
char buf[1024 + 60];
|
||||
} CLIParserContext;
|
||||
|
||||
#define CLI_MAX_OPTLIST_LEN 50
|
||||
// option list needs to have NULL at the last record int the field `text`
|
||||
typedef struct {
|
||||
int code;
|
||||
const char *text;
|
||||
} CLIParserOption;
|
||||
|
||||
int CLIParserInit(CLIParserContext **ctx, const char *vprogramName, const char *vprogramHint, const char *vprogramHelp);
|
||||
void CLIParserPrintHelp(CLIParserContext *ctx);
|
||||
int CLIParserParseString(CLIParserContext *ctx, const char *str, void *vargtable[], size_t vargtableLen, bool allowEmptyExec);
|
||||
|
@ -69,6 +79,10 @@ int CLIParamHexToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int
|
|||
int CLIParamStrToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int *datalen);
|
||||
int CLIParamBinToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int *datalen);
|
||||
|
||||
// names in the CLIParserOption array must be in the lowercase format
|
||||
int CLIGetOptionList(struct arg_str *argstr, const CLIParserOption *option_array, int *value);
|
||||
const char *CLIGetOptionListStr(const CLIParserOption *option_array, int value);
|
||||
|
||||
uint64_t arg_get_u64_hexstr_def(CLIParserContext *ctx, uint8_t paramnum, uint64_t def);
|
||||
int arg_get_u64_hexstr_def_nlen(CLIParserContext *ctx, uint8_t paramnum, uint64_t def, uint64_t *out, uint8_t nlen, bool optional);
|
||||
int arg_get_u32_hexstr_def(CLIParserContext *ctx, uint8_t paramnum, uint32_t def, uint32_t *out);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue