33 if (!line || 0==strlen(line)) {
37 if (NULL==command_list || 0==command_list_length) {
42 char* dup = calloc(strlen(line)+1,
sizeof(
char));
43 strncpy(dup, line, strlen(line)+1);
44 const char* delimiter =
" ";
45 char* word = strtok(dup, delimiter);
51 bool command_found =
false;
52 for (
size_t i=0; i<command_list_length; i++) {
54 if ((1==strlen(word) && command.
shortcut==word[0]) || 0==strcmp(word, command.
name)) {
60 const char* original_argument = line+strlen(word)+1;
61 word = strtok(NULL, delimiter);
74 if (delimiter[0]==original_argument[strlen(word)]) {
75 word[strlen(word)] = delimiter[0];
87 for (
size_t i=0; i<command_list_length; i++) {
100 return command_found;
105 for (
size_t i=0; i<command_list_length; i++) {
char * argument_description
human readable description of the argument it can accept
enum menu_argument_t argument
what kind of argument it accepts
char * name
complete name of the command (space-free)
char shortcut
short command code (0 if not available)
size_t printf(const char *format,...)
print format string on user output
void(* command_handler)(void *argument)
function to be called to handle this command
printing utilities to replace the large printf from the standard library (API)
char * command_description
human readable description of the command purpose