--- libaitcli/inc/aitcli.h 2010/04/18 20:42:23 1.1.1.1.2.1 +++ libaitcli/inc/aitcli.h 2010/04/24 10:02:33 1.1.1.1.2.7 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitcli.h,v 1.1.1.1.2.1 2010/04/18 20:42:23 misho Exp $ +* $Id: aitcli.h,v 1.1.1.1.2.7 2010/04/24 10:02:33 misho Exp $ * *************************************************************************/ #ifndef __AITCLI_H @@ -32,17 +32,33 @@ inline const char *cli_GetError(); * cli_Printf() Printf CLI features * @out = Output stream * @csFormat = Printf format string - * return: none + * return: -1 error, != -1 printed chars */ inline int cli_Printf(FILE *out, const char *csFormat, ...); /* + * cliInit() Initialize Readline + * @csProg = program name + * return: none +*/ +inline void cliInit(const char *csProg); +/* + * cliNetInit() Initialize Readline if CLI bind to socket + * @csProg = program name + * @pty = Master pty + * @term = stdin termios + * return: none +*/ +void cliNetInit(const char *csProg, int pty, struct termios *term); +/* * cliTTY() Initialize I/O TTY CLI features + * @term = terminal name * @inp = input handle * @out = output handle - * return: none + * @win = window size + * return: -1 error, != -1 ok */ -inline void cliTTY(FILE *inp, FILE *out); +inline int cliTTY(const char *term, FILE *inp, FILE *out, struct winsize *win); /* * cliComp() Initialize completion CLI features * @cmdComplete = Completion function @@ -53,11 +69,34 @@ inline void cliComp(cli_Completion_t *cmdComplete, cli /* * cliExec() Execute CLI main loop * @cmdList = Commands list - * @out = Output handle * @csPrompt = Prompt text * return: -1 error, 0 = exit w/^+D, 1 done. */ -int cliExec(cliCommands_t *cmdList, FILE *out, const char *csPrompt); +int cliExec(cliCommands_t *cmdList, const char *csPrompt); +/* + * cliNetExec() Execute net CLI main loop + * @cmdList = Commands list + * @csPrompt = Prompt text + * @sock = client socket + * @term = stdin termios + * @win = window size of tty + * return: -1 error, 0 = exit w/^+D, 1 done. +*/ +int cliNetExec(cliCommands_t *cmdList, const char *csPrompt, int sock, struct termios *term, struct winsize *win); + +/* + * cli_ReadHistory() Read CLI History from file + * @csFile = history file name, if NULL default history name is ".aitcli.history" + * return: -1 error; != -1 readed ok +*/ +inline int cli_ReadHistory(const char *csFile); +/* + * cli_WriteHistory() Write CLI History to file + * @csFile = history file name, if NULL default history name is ".aitcli.history" + * @lineNum = save number of history entry lines, if -1 all lines saved without limit + * return: -1 error; != -1 readed ok +*/ +inline int cli_WriteHistory(const char *csFile, int lineNum); /*