diff --git a/CLI/CLI.c b/CLI/CLI.c index 62d5f74..f7a674e 100644 --- a/CLI/CLI.c +++ b/CLI/CLI.c @@ -9,6 +9,7 @@ CLI_charOutFn CLI_charOut; CMDList_t* CMDList; FIFOBuffChar_t* FIFO; +int i; // initilize and register the lineout print function bool CLI_init(CLI_charOutFn lineOut, CMDList_t* cmdList) @@ -41,7 +42,7 @@ char* fifoToString(FIFOBuffChar_t* fifo) char* out = malloc(fifo->size + 1); char* write_p = out; - for (int i = fifo->size; i > 0; i--) + for (i = fifo->size; i > 0; i--) { FIFOBuffChar_get(fifo, write_p); write_p++; @@ -74,7 +75,7 @@ int tryExecute(FIFOBuffChar_t* fifo) { char err[100]; sprintf(&err[0], "command not found: %s\n> ", line); - for (int i=0; err[i] != 0; i++) + for (i=0; err[i] != 0; i++) { char c[2] = {err[i], 0}; (*CLI_charOut)(&c[0]); @@ -139,7 +140,7 @@ bool CLI_charIn(char c) case 27: // escape (start for arrow keys) sprintf(&str[0], "\ninvlid char: ESC - (%i)\n", c); - for (int i=0; str[i] != 0; i++) + for (i=0; str[i] != 0; i++) { char ch[2] = {str[i], 0}; (*CLI_charOut)(&ch[0]); @@ -148,7 +149,7 @@ bool CLI_charIn(char c) default: sprintf(&str[0], "\ninvlid char: '%c' - (%i)\n", c, c); - for (int i=0; str[i] != 0; i++) + for (i=0; str[i] != 0; i++) { char ch[2] = {str[i], 0}; (*CLI_charOut)(&ch[0]); diff --git a/CMDList/CMDList.c b/CMDList/CMDList.c index ff9cca1..8c64ef0 100644 --- a/CMDList/CMDList.c +++ b/CMDList/CMDList.c @@ -5,6 +5,7 @@ #include #include +int i; // initilises a CMDList_t with all NULL pointers CMDList_t* CMDList_init() { @@ -21,7 +22,7 @@ int CMDList_deinit(CMDList_t *list) // printf("deinit %p\n", (void*)list); // printf("deinit e %p\n", list->e); - for (int i = 0; i < 26; i++) + for (i = 0; i < 26; i++) { if (*(list_p + i) != NULL) { @@ -31,20 +32,20 @@ int CMDList_deinit(CMDList_t *list) } //TODO: fix "free(): invalid pointer" - // free(list); + free(list); return 0; } // add a command in the command tree -int CMDList_add(CMDList_t *list, CMD_t* cmd) +int CMDList_add(CMDList_t *list, CMD_t* cmd, char* cmdName) { int returnCode = 0; - char* read_p = cmd->cmd; + char* read_p = cmdName; CMDList_t** list_p = (CMDList_t**)list; if (read_p == NULL) - { // cmd is missing a string for the commnad name - returnCode = -1; + { + read_p = cmd->cmd; } while (returnCode == 0) diff --git a/CMDList/CMDList.h b/CMDList/CMDList.h index df580c8..e6d3bff 100644 --- a/CMDList/CMDList.h +++ b/CMDList/CMDList.h @@ -46,7 +46,7 @@ extern CMDList_t* CMDList_init(); extern int CMDList_deinit(CMDList_t *list); // add a command in the command tree -extern int CMDList_add(CMDList_t *list, CMD_t* cmd); +extern int CMDList_add(CMDList_t *list, CMD_t* cmd, char* cmdName); // search command in the tree extern CMD_t* CMDList_get(CMDList_t *list, char* cmd); diff --git a/FIFOBuff/FIFOBuffChar.c b/FIFOBuff/FIFOBuffChar.c index 6801ad6..fe1fc0c 100644 --- a/FIFOBuff/FIFOBuffChar.c +++ b/FIFOBuff/FIFOBuffChar.c @@ -1,4 +1,4 @@ -#include "FIFOBuffChar.h" +#include "C:\Users\denbo\git\ems31_2023-2024_groep_09_ccs\ ems31_2023-2024_groep_09_submodules_2\FIFOBuff\FIFOBuffChar.h" #include #include