--- libaitcli/src/aitcli.c 2016/08/18 09:27:37 1.15 +++ libaitcli/src/aitcli.c 2019/02/04 21:22:31 1.16 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitcli.c,v 1.15 2016/08/18 09:27:37 misho Exp $ +* $Id: aitcli.c,v 1.16 2019/02/04 21:22:31 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 - 2016 +Copyright 2004 - 2019 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -978,6 +978,7 @@ cliInit(int fin, int fout, const char *prompt) linebuffer_t *cli_buffer; bindkey_t *keys; register int i; + char szPrompt[STRSIZ] = {[0 ... STRSIZ - 1] = 0}; /* init buffer */ cli_buffer = e_malloc(sizeof(linebuffer_t)); @@ -994,7 +995,9 @@ cliInit(int fin, int fout, const char *prompt) SLIST_INIT(&cli_buffer->line_cmds); if (prompt) { - cli_buffer->line_prompt = e_strdup(prompt); + strlcpy(cli_buffer->line_porigin, prompt, sizeof cli_buffer->line_porigin); + snprintf(szPrompt, sizeof szPrompt, "%s{%d}> ", cli_buffer->line_porigin, cli_buffer->line_level); + cli_buffer->line_prompt = e_strdup(szPrompt); if (!cli_buffer->line_prompt) { LOGERR; e_free(cli_buffer);