diff --git a/CMDList/CMDList.c b/CMDList/CMDList.c new file mode 100644 index 0000000..7944b78 --- /dev/null +++ b/CMDList/CMDList.c @@ -0,0 +1,41 @@ +#include "CMDList.h" + + +// initilises a CMDList_t with all null pointers +CMDList_t* CMDList_init() +{ + CMDList_t *list = malloc(sizeof(CMDList_t)); + memset(list, 0, sizeof(CMDList_t)); + return list; +} + +// free up the full tree from memory +int CMDList_deinit(CMDList_t *list) +{ + void* chars[26] = list; + + for (int i = 0; i < 26; i++) + { + if (chars[i] != null) + { + CMDList_deinit(chars[i]); + } + } + + free(list); + return 0; +} + +// add a command in the command tree +int CMDList_add(CMDList_t *list, void* cmd) +{ + char* read_p = cmd; + + while ((*read_p != 0) && (read_p != ' ') && (read_p - cmd < 500)) + { + + } +} + +// search command in the tree +int CMDList_get(CMDList_t *list, char* cmd); diff --git a/CMDList/CMDList.h b/CMDList/CMDList.h new file mode 100644 index 0000000..9732524 --- /dev/null +++ b/CMDList/CMDList.h @@ -0,0 +1,46 @@ +#ifndef CMDLIST_h +#define CMDLIST_h + +typedef struct CMDList_s { + void* a; + void* b; + void* c; + void* d; + void* e; + void* f; + void* g; + void* h; + void* i; + void* j; + void* k; + void* l; + void* m; + void* n; + void* o; + void* p; + void* q; + void* r; + void* s; + void* t; + void* u; + void* v; + void* w; + void* x; + void* y; + void* z; + CMD_t cmd; +} CMDList_t; + +// initilises a CMDList_t with all null pointers +extern CMDList_t* CMDList_init(); + +// free up the full tree from memory +extern int CMDList_deinit(CMDList_t *list); + +// add a command in the command tree +extern int CMDList_add(CMDList_t *list, void* cmd); + +// search command in the tree +extern int CMDList_get(CMDList_t *list, char* cmd); + +#endif \ No newline at end of file