Diff for /libaitcli/src/aitcli.c between versions 1.11.2.1 and 1.11.2.2

version 1.11.2.1, 2013/11/22 14:25:37 version 1.11.2.2, 2013/11/22 14:46:01
Line 1267  cliInitLine(linebuffer_t * __restrict cli_buffer) Line 1267  cliInitLine(linebuffer_t * __restrict cli_buffer)
  *   *
  * @cli_buffer = CLI buffer   * @cli_buffer = CLI buffer
  * @timeout = Session timeout (-1 infinit)   * @timeout = Session timeout (-1 infinit)
  * @cmd_name = If timeout reached, we should call with this cmd_name (default name is "exit")  
  * return: NULL if error or !=NULL readed line, must be e_free after use!   * return: NULL if error or !=NULL readed line, must be e_free after use!
 */  */
 char *  char *
cliReadLine(linebuffer_t * __restrict cli_buffer, int timeout, const char *cmd_name)cliReadLine(linebuffer_t * __restrict cli_buffer, int timeout)
 {  {
         int code, readLen, ret;          int code, readLen, ret;
         register int i;          register int i;
Line 1292  cliReadLine(linebuffer_t * __restrict cli_buffer, int  Line 1291  cliReadLine(linebuffer_t * __restrict cli_buffer, int 
         while (42) {          while (42) {
                 if ((ret = poll(&fds, 1, timeout)) < 1) {                  if ((ret = poll(&fds, 1, timeout)) < 1) {
                         if (!ret) {                          if (!ret) {
                                if (str)                                cli_buffer->line_kill = 1;
                                 if (str) {
                                         e_free(str);                                          e_free(str);
                                str = e_strdup(cmd_name ? cmd_name : "exit");                                        str = NULL;
                                 }
                         } else                          } else
                                 LOGERR;                                  LOGERR;
                         return str;                          return str;
Line 1352  recheck: Line 1353  recheck:
  * @csHistFile = History file name   * @csHistFile = History file name
  * @sock = client socket   * @sock = client socket
  * @timeout = Session timeout (-1 infinit)   * @timeout = Session timeout (-1 infinit)
  * @cmd_name = If timeout reached, we should call with this cmd_name (default name is "exit")  
  * return: RETCODE_ERR error, RETCODE_OK ok   * return: RETCODE_ERR error, RETCODE_OK ok
 */  */
 int  int
 cliNetLoop(linebuffer_t * __restrict cli_buffer, const char *csHistFile,   cliNetLoop(linebuffer_t * __restrict cli_buffer, const char *csHistFile, 
                int sock, int timeout, const char *cmd_name)                int sock, int timeout)
 {  {
         u_char buf[BUFSIZ];          u_char buf[BUFSIZ];
         int pid, stat, pty, r, s, alen, flg, attrlen = 0, ret = 0;          int pid, stat, pty, r, s, alen, flg, attrlen = 0, ret = 0;
Line 1376  cliNetLoop(linebuffer_t * __restrict cli_buffer, const Line 1376  cliNetLoop(linebuffer_t * __restrict cli_buffer, const
                         } else                          } else
                                 close(sock);                                  close(sock);
   
                        ret = cliLoop(cli_buffer, csHistFile, timeout, cmd_name) < 0 ? 1 : 0;                        ret = cliLoop(cli_buffer, csHistFile, timeout) < 0 ? 1 : 0;
                         cliEnd(cli_buffer);                          cliEnd(cli_buffer);
   
                         _exit(ret);                          _exit(ret);
Line 1470  cliNetLoop(linebuffer_t * __restrict cli_buffer, const Line 1470  cliNetLoop(linebuffer_t * __restrict cli_buffer, const
  * @cli_buffer = CLI buffer   * @cli_buffer = CLI buffer
  * @csHistFile = History file name   * @csHistFile = History file name
  * @timeout = Session timeout (-1 infinit)   * @timeout = Session timeout (-1 infinit)
  * @cmd_name = If timeout reached, we should call with this cmd_name (default name is "exit")  
  * return: RETCODE_ERR error, RETCODE_OK ok   * return: RETCODE_ERR error, RETCODE_OK ok
 */  */
 int  int
cliLoop(linebuffer_t * __restrict cli_buffer, const char *csHistFile, cliLoop(linebuffer_t * __restrict cli_buffer, const char *csHistFile, int timeout)
                int timeout, const char *cmd_name) 
 {  {
         char *line, *s, *t, **app, *items[MAX_PROMPT_ITEMS];          char *line, *s, *t, **app, *items[MAX_PROMPT_ITEMS];
         register int i;          register int i;
Line 1489  cliLoop(linebuffer_t * __restrict cli_buffer, const ch Line 1487  cliLoop(linebuffer_t * __restrict cli_buffer, const ch
                 return RETCODE_ERR;                  return RETCODE_ERR;
   
         do {          do {
                line = cliReadLine(cli_buffer, timeout, cmd_name);                line = cliReadLine(cli_buffer, timeout);
                 if (!line) {                  if (!line) {
                         printfNL(cli_buffer, 0);                          printfNL(cli_buffer, 0);
                         break;                          break;

Removed from v.1.11.2.1  
changed lines
  Added in v.1.11.2.2


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