--- libaitcli/inc/aitcli.h 2010/06/04 12:46:27 1.2.2.2 +++ libaitcli/inc/aitcli.h 2010/06/04 13:51:21 1.2.2.3 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitcli.h,v 1.2.2.2 2010/06/04 12:46:27 misho Exp $ +* $Id: aitcli.h,v 1.2.2.3 2010/06/04 13:51:21 misho Exp $ * *************************************************************************/ #ifndef __AITCLI_H @@ -207,6 +207,72 @@ inline const char *cli_GetError(); /* CLI Functions */ + +/* + * cli_BindKey() Bind function to key + * @key = key structure + * @buffer = CLI buffer + * return: RETCODE_ERR error, RETCODE_OK ok, >0 bind at position +*/ +int cli_BindKey(bindkey_t * __restrict key, linebuffer_t * __restrict buffer); + +/* + * cli_addHistory() Add line to history + * @buffer = CLI buffer + * @str = Add text + * return: RETCODE_ERR error, RETCODE_OK ok +*/ +int cli_addHistory(linebuffer_t * __restrict buffer, const char * __restrict str); +/* + * cli_saveHistory() Save history to file + * @buffer = CLI buffer + * @histfile = History filename, if NULL will be use default name + * @lines = Maximum history lines to save + * return: RETCODE_ERR error, RETCODE_OK ok +*/ +int cli_saveHistory(linebuffer_t * __restrict buffer, const char *histfile, int lines); +/* + * cli_loadHistory() Load history from file + * @buffer = CLI buffer + * @histfile = History filename, if NULL will be use default name + * return: RETCODE_ERR error, RETCODE_OK ok +*/ +int cli_loadHistory(linebuffer_t * __restrict buffer, const char *histfile); +/* + * cli_resetHistory() Reset history search in CLI session + * @buffer = CLI buffer + * return: none +*/ +inline void cli_resetHistory(linebuffer_t * __restrict buffer); + +/* + * cli_freeLine() Clear entire line + * @buffer = CLI buffer + * return: RETCODE_ERR error, RETCODE_OK ok +*/ +inline int cli_freeLine(linebuffer_t * __restrict buffer); +/* + * cli_setPrompt() Set new prompt for CLI session + * @buffer = CLI buffer + * @prompt = new text for prompt or if NULL disable prompt + * return: none +*/ +inline void cli_setPrompt(linebuffer_t * __restrict buffer, const char *prompt); + +/* + * cliEnd() Clear data, Free resources and close CLI session + * @buffer = CLI buffer + * return: RETCODE_ERR error, RETCODE_OK ok +*/ +void cliEnd(linebuffer_t * __restrict buffer); +/* + * cliInit() Start CLI session, allocate memory for resources and bind keys + * @fin = Input device handle + * @fout = Output device handle + * @prompt = text for prompt, if NULL disable prompt + * return: NULL if error or !=NULL CLI buffer +*/ +linebuffer_t *cliInit(int fin, int fout, const char *prompt); /* * cliExec() Execute CLI main loop