first attampt at CMDList_add

This commit is contained in:
2024-04-05 19:35:38 +02:00
parent 78c332095a
commit 6c69de3722

View File

@@ -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)
}
}
}
}