|
version 1.19.4.1, 2024/03/19 10:11:13
|
version 1.21.2.1, 2025/12/21 22:36:19
|
|
Line 12 terms:
|
Line 12 terms:
|
| All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
| Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
| |
|
| Copyright 2004 - 2022 | Copyright 2004 - 2025 |
| by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
| |
|
| Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
|
Line 186 bufEOL(int idx, void * __restrict cli_buffer)
|
Line 186 bufEOL(int idx, void * __restrict cli_buffer)
|
| static int |
static int |
| bufEOF(int idx, void * __restrict cli_buffer) |
bufEOF(int idx, void * __restrict cli_buffer) |
| { |
{ |
| |
int ret; |
| |
|
| /* |
/* |
| if (!cli_buffer || idx < 0 || idx > MAX_BINDKEY) |
if (!cli_buffer || idx < 0 || idx > MAX_BINDKEY) |
| return RETCODE_ERR; |
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 |
static int |
|
Line 425 bufComp(int idx, void * __restrict cli_buffer)
|
Line 431 bufComp(int idx, void * __restrict cli_buffer)
|
| str_Trim(s); |
str_Trim(s); |
| } |
} |
| |
|
| i = j = 0; | j = 0; |
| c = NULL; |
c = NULL; |
| memset(szLine, 0, STRSIZ); |
memset(szLine, 0, STRSIZ); |
| if (*s) { |
if (*s) { |
|
Line 520 static int
|
Line 526 static int
|
| bufEndNode(int idx, void * __restrict cli_buffer) |
bufEndNode(int idx, void * __restrict cli_buffer) |
| { |
{ |
| linebuffer_t *buf = cli_buffer; |
linebuffer_t *buf = cli_buffer; |
| |
char szPrompt[STRSIZ + 16] = {[0 ... STRSIZ + 15] = 0}; |
| |
|
| if (!cli_buffer || idx < 0 || idx > MAX_BINDKEY) |
if (!cli_buffer || idx < 0 || idx > MAX_BINDKEY) |
| return RETCODE_ERR; |
return RETCODE_ERR; |
|
Line 527 bufEndNode(int idx, void * __restrict cli_buffer)
|
Line 534 bufEndNode(int idx, void * __restrict cli_buffer)
|
| if (buf->line_level > 0) { |
if (buf->line_level > 0) { |
| printfNL(cli_buffer, 0); |
printfNL(cli_buffer, 0); |
| buf->line_level--; |
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); |
cli_Printf(buf, "Enter to config level %d\n", buf->line_level); |
| } |
} |
| |
|
|
Line 549 cli_Printf(linebuffer_t * __restrict cli_buffer, char
|
Line 558 cli_Printf(linebuffer_t * __restrict cli_buffer, char
|
| FILE *f; |
FILE *f; |
| |
|
| if (fmt) { |
if (fmt) { |
| f = fdopen(cli_buffer->line_out, "a"); | f = fdopen(dup(cli_buffer->line_out), "a"); |
| if (!f) { |
if (!f) { |
| LOGERR; |
LOGERR; |
| return; |
return; |
|
Line 558 cli_Printf(linebuffer_t * __restrict cli_buffer, char
|
Line 567 cli_Printf(linebuffer_t * __restrict cli_buffer, char
|
| va_start(lst, fmt); |
va_start(lst, fmt); |
| vfprintf(f, fmt, lst); |
vfprintf(f, fmt, lst); |
| va_end(lst); |
va_end(lst); |
| |
|
| |
fclose(f); |
| } else |
} else |
| cli_SetErr(EINVAL, "Invalid input parameters ..."); |
cli_SetErr(EINVAL, "Invalid input parameters ..."); |
| } |
} |
|
Line 1289 int
|
Line 1300 int
|
| cliResetLine(linebuffer_t * __restrict cli_buffer, struct termios * __restrict orig) |
cliResetLine(linebuffer_t * __restrict cli_buffer, struct termios * __restrict orig) |
| { |
{ |
| return tcsetattr(cli_buffer->line_in, TCSANOW, 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); |
| } |
} |
| |
|
| /* |
/* |