Diff for /libaitcli/src/aitcli.c between versions 1.17 and 1.18

version 1.17, 2020/09/01 23:19:55 version 1.18, 2022/10/17 22:04:24
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 - 2020Copyright 2004 - 2022
         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 978  cliInit(int fin, int fout, const char *prompt) Line 978  cliInit(int fin, int fout, const char *prompt)
         linebuffer_t *cli_buffer;          linebuffer_t *cli_buffer;
         bindkey_t *keys;          bindkey_t *keys;
         register int i;          register int i;
        char szPrompt[STRSIZ] = {[0 ... STRSIZ - 1] = 0};        char szPrompt[STRSIZ + 16] = {[0 ... STRSIZ + 15] = 0};
   
         /* init buffer */          /* init buffer */
         cli_buffer = e_malloc(sizeof(linebuffer_t));          cli_buffer = e_malloc(sizeof(linebuffer_t));
Line 1246  cliInit(int fin, int fout, const char *prompt) Line 1246  cliInit(int fin, int fout, const char *prompt)
 }  }
   
 /*  /*
 * cliInitLine() - Init CLI input line terminal * cliSetLine() - Set CLI input line terminal
  *   *
  * @cli_buffer = CLI buffer   * @cli_buffer = CLI buffer
 * return: none * @old = Old terminal settings
  * return: -1 error or 0 ok
 */  */
 int  int
cliInitLine(linebuffer_t * __restrict cli_buffer)cliSetLine(linebuffer_t * __restrict cli_buffer, struct termios * __restrict old)
 {  {
         struct termios t;          struct termios t;
   
         memset(&t, 0, sizeof t);          memset(&t, 0, sizeof t);
         tcgetattr(cli_buffer->line_in, &t);          tcgetattr(cli_buffer->line_in, &t);
           if (old)
                   memcpy(old, &t, sizeof(struct termios));
         t.c_lflag &= ~(ICANON | ISIG | IEXTEN | ECHO |           t.c_lflag &= ~(ICANON | ISIG | IEXTEN | ECHO | 
                         ECHOCTL | ECHOE | ECHOK | ECHOKE | ECHONL | ECHOPRT);                          ECHOCTL | ECHOE | ECHOK | ECHOKE | ECHONL | ECHOPRT);
         t.c_iflag |= IGNBRK;          t.c_iflag |= IGNBRK;
Line 1267  cliInitLine(linebuffer_t * __restrict cli_buffer) Line 1270  cliInitLine(linebuffer_t * __restrict cli_buffer)
 }  }
   
 /*  /*
    * cliResetLine() - Reset CLI input line terminal
    *
    * @cli_buffer = CLI buffer
    * @old = Original terminal settings
    * return: -1 error or 0 ok
   */
   int
   cliResetLine(linebuffer_t * __restrict cli_buffer, struct termios * __restrict orig)
   {
           return tcsetattr(cli_buffer->line_in, TCSANOW, orig);
   }
   
   /*
  * cliReadLine() - Read line from opened CLI session   * cliReadLine() - Read line from opened CLI session
  *   *
  * @cli_buffer = CLI buffer   * @cli_buffer = CLI buffer
Line 1538  cliLoop(linebuffer_t * __restrict cli_buffer, const ch Line 1554  cliLoop(linebuffer_t * __restrict cli_buffer, const ch
 {  {
         char *line;          char *line;
         int ret = RETCODE_OK;          int ret = RETCODE_OK;
           struct termios t;
   
         /* --- main body of CLI --- */          /* --- main body of CLI --- */
        cliInitLine(cli_buffer);        cliSetLine(cli_buffer, &t);
   
         if (cli_loadHistory(cli_buffer, csHistFile) == RETCODE_ERR)          if (cli_loadHistory(cli_buffer, csHistFile) == RETCODE_ERR)
                 return RETCODE_ERR;                  return RETCODE_ERR;
Line 1561  cliLoop(linebuffer_t * __restrict cli_buffer, const ch Line 1578  cliLoop(linebuffer_t * __restrict cli_buffer, const ch
         } while (cli_buffer->line_kill || ret < 1);          } while (cli_buffer->line_kill || ret < 1);
   
         cli_saveHistory(cli_buffer, csHistFile, HISTORY_LINES);          cli_saveHistory(cli_buffer, csHistFile, HISTORY_LINES);
   
           /* --- restore tty --- */
           cliResetLine(cli_buffer, &t);
   
         return ret;          return ret;
 }  }

Removed from v.1.17  
changed lines
  Added in v.1.18


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>