/[LeafOK_CVS]/lbbs/src/io.c
ViewVC logotype

Diff of /lbbs/src/io.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.40 by sysadm, Thu Jun 5 08:36:02 2025 UTC Revision 1.47 by sysadm, Sat Jun 21 02:15:18 2025 UTC
# Line 14  Line 14 
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
16    
17    #include "common.h"
18  #include "io.h"  #include "io.h"
19  #include "log.h"  #include "log.h"
 #include "common.h"  
20  #include <errno.h>  #include <errno.h>
21  #include <stdio.h>  #include <fcntl.h>
22  #include <stdarg.h>  #include <stdarg.h>
23    #include <stdio.h>
24  #include <string.h>  #include <string.h>
25  #include <time.h>  #include <time.h>
 #include <fcntl.h>  
26  #include <unistd.h>  #include <unistd.h>
 #include <sys/select.h>  
 #include <sys/ioctl.h>  
27  #include <sys/epoll.h>  #include <sys/epoll.h>
28    #include <sys/ioctl.h>
29    #include <sys/select.h>
30    #include <libssh/callbacks.h>
31  #include <libssh/libssh.h>  #include <libssh/libssh.h>
32  #include <libssh/server.h>  #include <libssh/server.h>
 #include <libssh/callbacks.h>  
33    
34  static char stdout_buf[BUFSIZ];  static char stdout_buf[BUFSIZ];
35  static int stdout_buf_len = 0;  static int stdout_buf_len = 0;
# Line 91  int outc(char c) Line 91  int outc(char c)
91          return ret;          return ret;
92  }  }
93    
94  int iflush()  int iflush(void)
95  {  {
96          int flags;          int flags;
97          struct epoll_event ev, events[MAX_EVENTS];          struct epoll_event ev, events[MAX_EVENTS];
# Line 176  int iflush() Line 176  int iflush()
176                                                  }                                                  }
177                                                  else                                                  else
178                                                  {                                                  {
179    #ifdef _DEBUG
180                                                          log_error("write(STDOUT) error (%d)\n", errno);                                                          log_error("write(STDOUT) error (%d)\n", errno);
181    #endif
182                                                          retry = 0;                                                          retry = 0;
183                                                          break;                                                          break;
184                                                  }                                                  }
# Line 333  int igetch(int timeout) Line 335  int igetch(int timeout)
335                                                  }                                                  }
336                                                  else                                                  else
337                                                  {                                                  {
338    #ifdef _DEBUG
339                                                          log_error("read(STDIN) error (%d)\n", errno);                                                          log_error("read(STDIN) error (%d)\n", errno);
340    #endif
341                                                          loop = 0;                                                          loop = 0;
342                                                          break;                                                          break;
343                                                  }                                                  }
# Line 353  int igetch(int timeout) Line 357  int igetch(int timeout)
357                  }                  }
358    
359                  // For debug                  // For debug
360                  // for (int j = pos; j < len; j++)  #ifdef _DEBUG
361                  // {                  for (int j = pos; j < len; j++)
362                  //      log_common("Debug: <--[%u]\n", (buf[j] + 256) % 256);                  {
363                  // }                          log_common("Debug: <--[%u]\n", (buf[j] + 256) % 256);
364                    }
365    #endif
366          }          }
367    
368          fcntl(STDIN_FILENO, F_SETFL, flags);          fcntl(STDIN_FILENO, F_SETFL, flags);
# Line 534  int igetch(int timeout) Line 540  int igetch(int timeout)
540                                  case 49:                                  case 49:
541                                          out = KEY_HOME;                                          out = KEY_HOME;
542                                          break;                                          break;
543                                    case 50:
544                                            out = KEY_INS;
545                                            break;
546                                  case 51:                                  case 51:
547                                          out = KEY_DEL;                                          out = KEY_DEL;
548                                          break;                                          break;
# Line 624  int igetch(int timeout) Line 633  int igetch(int timeout)
633                                  in_ascii = 0;                                  in_ascii = 0;
634                                  switch (tmp[4])                                  switch (tmp[4])
635                                  {                                  {
636                                    case 65:
637                                            out = KEY_CTRL_UP;
638                                            break;
639                                    case 66:
640                                            out = KEY_CTRL_DOWN;
641                                            break;
642                                    case 67:
643                                            out = KEY_CTRL_RIGHT;
644                                            break;
645                                    case 68:
646                                            out = KEY_CTRL_LEFT;
647                                            break;
648                                    case 70:
649                                            out = KEY_CTRL_END;
650                                            break;
651                                    case 72:
652                                            out = KEY_CTRL_HOME;
653                                            break;
654                                  case 80:                                  case 80:
655                                          out = KEY_CTRL_F1;                                          out = KEY_CTRL_F1;
656                                          break;                                          break;
# Line 790  int igetch(int timeout) Line 817  int igetch(int timeout)
817          }          }
818    
819          // for debug          // for debug
820          // if (out != KEY_TIMEOUT && out != KEY_NULL)  #ifdef _DEBUG
821          // {          if (out != KEY_TIMEOUT && out != KEY_NULL)
822          //      log_common("Debug: -->[0x %x]\n", out);          {
823          // }                  log_common("Debug: -->[0x %x]\n", out);
824            }
825    #endif
826    
827          return out;          return out;
828  }  }
# Line 801  int igetch(int timeout) Line 830  int igetch(int timeout)
830  int igetch_t(int sec)  int igetch_t(int sec)
831  {  {
832          int ch;          int ch;
833          time_t t_begin = time(0);          time_t t_begin = time(NULL);
834    
835          do          do
836          {          {
837                  ch = igetch(100);                  ch = igetch(100);
838          } while (!SYS_server_exit && ch == KEY_TIMEOUT && (time(0) - t_begin < sec));          } while (!SYS_server_exit && ch == KEY_TIMEOUT && (time(NULL) - t_begin < sec));
839    
840          return ch;          return ch;
841  }  }


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1