Compare commits
3 Commits
f08c8e5788
...
multie-cli
| Author | SHA1 | Date | |
|---|---|---|---|
|
42aec53edb
|
|||
|
8f71535dfd
|
|||
|
8261e605bc
|
13
CLI/CLI.c
13
CLI/CLI.c
@@ -128,7 +128,11 @@ void historyPrevius(CLI_t* cli)
|
||||
// write line
|
||||
if ((ret >= 0) && (line != NULL))
|
||||
{
|
||||
CLI_stringOut(cli, line);
|
||||
int i;
|
||||
for (i=0; *(line + i) != '\0'; i++)
|
||||
{
|
||||
CLI_charIn(cli, *(line + i));
|
||||
}
|
||||
}
|
||||
}
|
||||
void historyNext(CLI_t* cli)
|
||||
@@ -148,7 +152,10 @@ void historyNext(CLI_t* cli)
|
||||
if ((ret >= 0) && (line != NULL))
|
||||
{
|
||||
int i;
|
||||
CLI_stringOut(cli, line);
|
||||
for (i=0; *(line + i) != '\0'; i++)
|
||||
{
|
||||
CLI_charIn(cli, *(line + i));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -173,7 +180,7 @@ int tryExecute(CLI_t* cli, FIFOBuffChar_t* fifo)
|
||||
#ifdef HISTORY
|
||||
History_put(cli->History, line);
|
||||
#endif
|
||||
int ret = (*(cmd->fn))(line);
|
||||
int ret = (*(cmd->fn))(line, cli);
|
||||
|
||||
if (ret != INT_MIN)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <config.h>
|
||||
#define HISTORY
|
||||
|
||||
#include "../CMDList/CMDList.h"
|
||||
#include "../FIFOBuff/FIFOBuffChar.h"
|
||||
@@ -39,6 +38,8 @@ extern void CLI_PrintHistory(CLI_t* cli);
|
||||
|
||||
// to recive a single caracter
|
||||
bool CLI_charIn(CLI_t* cli, char c);
|
||||
void CLI_charOut_save(CLI_t* cli, char ch);
|
||||
void CLI_stringOut(CLI_t* cli, char* str);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
typedef struct CMD_t {
|
||||
char* cmd;
|
||||
int (*fn)(char* line);
|
||||
int (*fn)(char* line, void* cli);
|
||||
} CMD_t;
|
||||
|
||||
typedef struct CMDList_s {
|
||||
|
||||
@@ -123,7 +123,7 @@ int History_getPrev(History_t* history, char** line)
|
||||
*line = NULL;
|
||||
retCode = -1;
|
||||
}
|
||||
return 0;
|
||||
return retCode;
|
||||
}
|
||||
|
||||
int History_getNext(History_t* history, char** line)
|
||||
@@ -144,7 +144,7 @@ int History_getNext(History_t* history, char** line)
|
||||
*line = NULL;
|
||||
retCode = -1;
|
||||
}
|
||||
return 0;
|
||||
return retCode;
|
||||
}
|
||||
|
||||
int History_getFullHistory(History_t* history, char*** list)
|
||||
|
||||
Reference in New Issue
Block a user