From 64a72b70ef2ade72593a3f6291959e0b0c01cbe6 Mon Sep 17 00:00:00 2001 From: FReenen Date: Fri, 12 Apr 2024 18:32:39 +0200 Subject: [PATCH 1/2] CMDList: separate command name from comand object for alias --- CMDList/CMDList.c | 8 ++++---- CMDList/CMDList.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMDList/CMDList.c b/CMDList/CMDList.c index ff9cca1..19c8639 100644 --- a/CMDList/CMDList.c +++ b/CMDList/CMDList.c @@ -36,15 +36,15 @@ int CMDList_deinit(CMDList_t *list) } // 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); From 2495ac6ee6b1270f128d75bc88d50b0ec3cb73c3 Mon Sep 17 00:00:00 2001 From: Dennis Boekholtz <1017359@hr.nl> Date: Sat, 13 Apr 2024 23:16:24 +0200 Subject: [PATCH 2/2] Veranderingen om CCS blij te maken --- CLI/CLI.c | 9 +++++---- CMDList/CMDList.c | 5 +++-- FIFOBuff/FIFOBuffChar.c | 4 +++- 3 files changed, 11 insertions(+), 7 deletions(-) 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 19c8639..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,7 +32,7 @@ int CMDList_deinit(CMDList_t *list) } //TODO: fix "free(): invalid pointer" - // free(list); + free(list); return 0; } diff --git a/FIFOBuff/FIFOBuffChar.c b/FIFOBuff/FIFOBuffChar.c index 6f41aef..ddbe3d4 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 @@ -141,6 +141,7 @@ bool FIFOBuffChar_pop(FIFOBuffChar_t *fifo) default: // buffer is at least 2 element big // find the second last element + { FIFOBuffChar_element_t* secondLastEl = fifo->FirstEl_p; while ( secondLastEl->nextElement != fifo->LastEl_p @@ -158,6 +159,7 @@ bool FIFOBuffChar_pop(FIFOBuffChar_t *fifo) fifo->size--; ok = true; break; + } } return ok;