From 6c69de372226b748770b4cfd80991238cc74a01a Mon Sep 17 00:00:00 2001 From: FReenen Date: Fri, 5 Apr 2024 19:35:38 +0200 Subject: [PATCH] first attampt at CMDList_add --- CMDList/CMDList.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) 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) + } + } } }