Compare commits
9 Commits
e7ea706157
...
8ddf982e78
| Author | SHA1 | Date | |
|---|---|---|---|
| 8ddf982e78 | |||
| 9c30ea4ef1 | |||
| 62f45f7256 | |||
|
|
92eb70f4b5 | ||
|
|
cb7b573eed | ||
|
|
04eebfc3fc | ||
|
|
51c1c28756 | ||
|
|
cd72e519a1 | ||
| df2129a1bb |
@ -6,6 +6,7 @@
|
||||
#include <limits.h>
|
||||
|
||||
// #include <config.h>
|
||||
#define HISTORY
|
||||
|
||||
#include "../FIFOBuff/FIFOBuffChar.h"
|
||||
#ifdef HISTORY
|
||||
@ -68,7 +69,7 @@ bool CLI_deinit()
|
||||
|
||||
FIFOBuffChar_delete(FIFO);
|
||||
#ifdef HISTORY
|
||||
History_deinit(History);
|
||||
History_deinit(History, true);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
@ -95,9 +96,10 @@ void CLI_PrintHistory()
|
||||
{
|
||||
char** historyList;
|
||||
int ret = History_getFullHistory(History, &historyList);
|
||||
int i;
|
||||
if (ret >= 0)
|
||||
{
|
||||
for (int i=0; *(historyList + i) != NULL; i++)
|
||||
for (i=0; *(historyList + i) != NULL; i++)
|
||||
{
|
||||
printf("%03i: %s\n", i, *(historyList + i));
|
||||
}
|
||||
@ -262,6 +264,7 @@ bool CLI_charIn(char c)
|
||||
FIFOBuffChar_delete(fifo);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case 127: // backspace
|
||||
if (FIFOBuffChar_pop(FIFO))
|
||||
{ // pop something of the buffer
|
||||
|
||||
@ -17,7 +17,8 @@ CMDList_t* CMDList_init()
|
||||
// does not free up the commands
|
||||
int CMDList_deinit(CMDList_t *list)
|
||||
{
|
||||
CMDList_t** list_p = (CMDList_t**)list;
|
||||
CMDList_t** list_p;
|
||||
*list_p = list;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 26; i++)
|
||||
@ -28,7 +29,7 @@ int CMDList_deinit(CMDList_t *list)
|
||||
}
|
||||
}
|
||||
|
||||
free(*list_p);
|
||||
free(list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -44,7 +45,7 @@ int CMDList_add(CMDList_t *list, CMD_t* cmd, char* cmdName)
|
||||
read_p = cmd->cmd;
|
||||
}
|
||||
|
||||
while (returnCode == 0)
|
||||
while (returnCode >= 0)
|
||||
{
|
||||
char c = *read_p & (~0x20); // convert to uppercase
|
||||
if ((c >= 'A') && (c <= 'Z'))
|
||||
|
||||
@ -19,7 +19,7 @@ History_t* History_init()
|
||||
}
|
||||
|
||||
|
||||
int History_deinit(History_t* history)
|
||||
int History_deinit(History_t* history, bool freeLines)
|
||||
{
|
||||
// Check if the buffer there is something in the buffer
|
||||
if (history->FirstEl_p == NULL)
|
||||
@ -29,6 +29,10 @@ int History_deinit(History_t* history)
|
||||
while (el != NULL)
|
||||
{
|
||||
History_element_t* nextEl = el->nextEl_p;
|
||||
if (freeLines)
|
||||
{
|
||||
free(el->line);
|
||||
}
|
||||
free(el);
|
||||
el = nextEl;
|
||||
}
|
||||
@ -149,7 +153,8 @@ int History_getFullHistory(History_t* history, char*** list)
|
||||
*list = malloc(sizeof(char**) * (History_getSize(history) + 1));
|
||||
History_element_t* el = history->FirstEl_p;
|
||||
|
||||
for (int i = 0; (i < History_getSize(history)-1) && (retCode >= 0); i++)
|
||||
int i;
|
||||
for (i = 0; (i < History_getSize(history)-1) && (retCode >= 0); i++)
|
||||
{
|
||||
*((*list) + i) = el->line;
|
||||
if (el->nextEl_p == NULL)
|
||||
@ -178,7 +183,8 @@ int History_getCurrPos(History_t* history)
|
||||
if (history->CurrEl_p != NULL)
|
||||
{
|
||||
History_element_t* el = history->FirstEl_p;
|
||||
for (int i = 0; (el != history->CurrEl_p) && (retCode >= 0); i++)
|
||||
int i;
|
||||
for (i = 0; (el != history->CurrEl_p) && (retCode >= 0); i++)
|
||||
{
|
||||
if (el->nextEl_p == NULL)
|
||||
{
|
||||
|
||||
@ -22,7 +22,7 @@ typedef struct History_s {
|
||||
extern History_t* History_init();
|
||||
|
||||
// destroy a fifo buffer (free up its space)
|
||||
extern int History_deinit(History_t* history);
|
||||
extern int History_deinit(History_t* history, bool freeLines);
|
||||
|
||||
// put value i in buffer if there is still memory avaliable
|
||||
extern int History_put(History_t *history, char* line);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user