--- libaitcli/src/aitcli.c 2025/12/17 23:30:11 1.20 +++ libaitcli/src/aitcli.c 2025/12/21 22:36:19 1.21.2.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitcli.c,v 1.20 2025/12/17 23:30:11 misho Exp $ +* $Id: aitcli.c,v 1.21.2.1 2025/12/21 22:36:19 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -558,7 +558,7 @@ cli_Printf(linebuffer_t * __restrict cli_buffer, char FILE *f; if (fmt) { - f = fdopen(cli_buffer->line_out, "a"); + f = fdopen(dup(cli_buffer->line_out), "a"); if (!f) { LOGERR; return; @@ -1300,6 +1300,31 @@ int cliResetLine(linebuffer_t * __restrict cli_buffer, struct termios * __restrict orig) { return tcsetattr(cli_buffer->line_in, TCSANOW, orig); +} + +/* + * cliEcho() - Switch echo on or off + * + * @cli_buffer = CLI buffer + * @on = On or off for echo on input handler + * return: -1 error or 0 ok +*/ +int +cliEcho(linebuffer_t * __restrict cli_buffer, int on) +{ + struct termios t; + + if (tcgetattr(cli_buffer->line_in, &t) == -1) { + cli_SetErr(errno, "tcgetattr(%d) - %s", cli_buffer->line_in, strerror(errno)); + return -1; + } + + if (on) + t.c_lflag |= (ECHO); + else + t.c_lflag &= ~(ECHO); + + return tcsetattr(cli_buffer->line_in, TCSANOW, &t); } /*