Merge commit '69c6f63251949b949fb9b0e144256ecc27a31ff4' into Dennis_buffer
This commit is contained in:
commit
d69605b3a6
17
CLI/CLI.h
Normal file
17
CLI/CLI.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef CLI_h
|
||||||
|
#define CLI_h
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "../CMDList.h"
|
||||||
|
|
||||||
|
typedef CLI_lineOutFn(char* line) CLI_lineoutFn_t;
|
||||||
|
|
||||||
|
// initilize and register the lineout print function
|
||||||
|
bool init(CLI_lineoutFn_t* lineOut, CMDList_t* cmdList);
|
||||||
|
|
||||||
|
// to recive a single caracter
|
||||||
|
bool CLI_charIn(char c);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -30,10 +30,30 @@ int CMDList_deinit(CMDList_t *list)
|
|||||||
int CMDList_add(CMDList_t *list, void* cmd)
|
int CMDList_add(CMDList_t *list, void* cmd)
|
||||||
{
|
{
|
||||||
char* read_p = 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user