Merge commit 'f8068d72b5d5d741615052c3ca7d9a50b45e211f' into Dennis_buffer
This commit is contained in:
commit
1d9fcb3362
41
CMDList/CMDList.c
Normal file
41
CMDList/CMDList.c
Normal file
@ -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);
|
||||||
46
CMDList/CMDList.h
Normal file
46
CMDList/CMDList.h
Normal file
@ -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
|
||||||
Loading…
x
Reference in New Issue
Block a user