--- libaitcli/src/aitcli.c 2022/12/05 22:23:38 1.19 +++ libaitcli/src/aitcli.c 2025/12/17 23:30:11 1.20 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitcli.c,v 1.19 2022/12/05 22:23:38 misho Exp $ +* $Id: aitcli.c,v 1.20 2025/12/17 23:30:11 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004 - 2022 +Copyright 2004 - 2025 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -186,12 +186,18 @@ bufEOL(int idx, void * __restrict cli_buffer) static int bufEOF(int idx, void * __restrict cli_buffer) { + int ret; + /* if (!cli_buffer || idx < 0 || idx > MAX_BINDKEY) return RETCODE_ERR; */ - return RETCODE_EOF; + printfNL(cli_buffer, 0); + ret = cli_Cmd_End(cli_buffer, idx, NULL); + printfCR(cli_buffer, (ret != RETCODE_EOF)); + + return ret; } static int @@ -425,7 +431,7 @@ bufComp(int idx, void * __restrict cli_buffer) str_Trim(s); } - i = j = 0; + j = 0; c = NULL; memset(szLine, 0, STRSIZ); if (*s) { @@ -520,6 +526,7 @@ static int bufEndNode(int idx, void * __restrict cli_buffer) { linebuffer_t *buf = cli_buffer; + char szPrompt[STRSIZ + 16] = {[0 ... STRSIZ + 15] = 0}; if (!cli_buffer || idx < 0 || idx > MAX_BINDKEY) return RETCODE_ERR; @@ -527,6 +534,8 @@ bufEndNode(int idx, void * __restrict cli_buffer) if (buf->line_level > 0) { printfNL(cli_buffer, 0); buf->line_level--; + snprintf(szPrompt, sizeof szPrompt, "%s{%d}> ", buf->line_porigin, buf->line_level); + cli_setPrompt(buf, szPrompt); cli_Printf(buf, "Enter to config level %d\n", buf->line_level); } @@ -558,6 +567,8 @@ cli_Printf(linebuffer_t * __restrict cli_buffer, char va_start(lst, fmt); vfprintf(f, fmt, lst); va_end(lst); + + fclose(f); } else cli_SetErr(EINVAL, "Invalid input parameters ..."); } @@ -1499,7 +1510,6 @@ int cliRun(linebuffer_t * __restrict cli_buffer, char *psInput, int prompt) { char *line, *s, *t, **app, *items[MAX_PROMPT_ITEMS]; - register int i; int ret = RETCODE_OK; struct tagCommand *cmd; @@ -1521,14 +1531,11 @@ cliRun(linebuffer_t * __restrict cli_buffer, char *psI (*app = strsep(&s, " \t")); *app ? app++ : app); // exec_cmd ... - i = 0; SLIST_FOREACH(cmd, &cli_buffer->line_cmds, cmd_next) { if (!(cmd->cmd_level & (1 << cli_buffer->line_level))) continue; if (*items[0] && !strncmp(cmd->cmd_name, items[0], strlen(items[0]))) break; - else - i++; } if (!cmd) {