Remove custom option checker and use the one of the shellmatta instead

This commit is contained in:
Mario Hüttel 2021-04-10 14:10:17 +02:00
parent 54416a6350
commit 9f1a791be2

View File

@ -53,28 +53,6 @@ static shellmatta_instance_t shell;
static char shell_buffer[512]; static char shell_buffer[512];
static char IN_SECTION(.ccm.bss) history_buffer[512]; static char IN_SECTION(.ccm.bss) history_buffer[512];
static bool check_opt(const char *args, uint32_t len, const char *opt_to_check)
{
(void)len;
char str[128];
const char *ptr;
static const char * const tokens = "\t ";
strncpy(str, args, sizeof(str));
str[sizeof(str) - 1] = 0;
/* Tokenize the string */
ptr = strtok(str, tokens);
while (ptr) {
if (strcmp(ptr, opt_to_check) == 0)
return true;
ptr = strtok(NULL, tokens);
}
return false;
}
static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle, static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
const char *arguments, const char *arguments,
uint32_t length) uint32_t length)
@ -345,14 +323,36 @@ static shellmatta_retCode_t shell_cmd_read_flags(const shellmatta_handle_t handl
uint32_t i; uint32_t i;
char name[64]; char name[64];
bool flag; bool flag;
bool tryack; bool tryack = false;
int status; int status;
enum safety_flag flag_enum; enum safety_flag flag_enum;
struct analog_monitor_info amon_info; struct analog_monitor_info amon_info;
struct timing_monitor_info timing_info; struct timing_monitor_info timing_info;
char *argument;
uint32_t len;
char option;
shellmatta_retCode_t opt_ret;
static const shellmatta_opt_long_t options[] = {
{"ack", 'a', SHELLMATTA_OPT_ARG_NONE},
{NULL, '\0', SHELLMATTA_OPT_ARG_NONE}
};
do {
opt_ret = shellmatta_opt_long(handle, options, &option, &argument, &len);
if (opt_ret != SHELLMATTA_OK) {
break;
}
switch (option) {
case 'a':
tryack = true;
break;
default:
break;
}
} while(1);
/* Check for the --ack option */
tryack = check_opt(arguments, length, "--ack");
shellmatta_printf(handle, "Error Flags\r\n" shellmatta_printf(handle, "Error Flags\r\n"
"-----------\r\n"); "-----------\r\n");