diff --git a/CLI/CLI.h b/CLI/CLI.h new file mode 100644 index 0000000..a3b65a8 --- /dev/null +++ b/CLI/CLI.h @@ -0,0 +1,17 @@ +#ifndef CLI_h +#define CLI_h + +#include + +#include "../CMDList.h" + +typedef CLI_lineOutFn(char* line) CLI_lineoutFn_t; + +// initilize and register the lineout print function +bool init(CLI_lineoutFn_t* lineOut, CMDList_t* cmdList); + +// to recive a single caracter +bool CLI_charIn(char c); + + +#endif \ No newline at end of file diff --git a/CMDList/CMDList.c b/CMDList/CMDList.c index 7944b78..251323e 100644 --- a/CMDList/CMDList.c +++ b/CMDList/CMDList.c @@ -30,10 +30,30 @@ int CMDList_deinit(CMDList_t *list) int CMDList_add(CMDList_t *list, void* cmd) { char* read_p = cmd; + CMDList_t* list_p = list; - while ((*read_p != 0) && (read_p != ' ') && (read_p - cmd < 500)) + while ( + (read_p != null) + && (*read_p != ' ') // space ends the command + && (*read_p != '\n') // end of line + && (*read_p != '\r') // end of line + && (*read_p != 0) // end of string + && (read_p - cmd < 500) + ) { - + char c = *read_p & (~0x20); // to uppercase + if ((*read_p >= 'A') && (*read_p <= 'Z')) + { + read_p += (read_p - 'A') * sizeof(CMDList_t*); + if (*((CMDList_t**)read_p) == null) + { + read_p = malloc(sizeof(CMDList_t)); + } + else + { + read_p = *((CMDList_t**)read_p) + } + } } }