--- libaitcli/src/aitcli.c 2025/12/17 23:40:35 1.20.2.1 +++ 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.2.1 2025/12/17 23:40:35 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 @@ -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); } /*