/[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.16 by sysadm, Wed Apr 30 09:18:19 2025 UTC Revision 1.18 by sysadm, Sun May 4 14:54:55 2025 UTC
# Line 56  int iflush() Line 56  int iflush()
56          return retval;          return retval;
57  }  }
58    
59  int igetch()  int igetch(int clear_buf)
60  {  {
61            // static input buffer
62          static char buf[256];          static char buf[256];
63          unsigned char c, tmp[256];          static int len = 0;
64          int out = KEY_NULL, loop = 1, in_esc = 0, in_ascii = 0, in_control = 0, i = 0, j, result;          static int pos = 0;
65          static int len = 0, pos = 0;  
66          fd_set testfds;          unsigned char tmp[256];
67          struct timeval timeout;          int out = KEY_NULL;
68            int in_esc = 0;
69            int in_ascii = 0;
70            int in_control = 0;
71            int i = 0;
72    
73            if (clear_buf)
74            {
75                    pos = 0;
76                    len = 0;
77    
78                    return 0;
79            }
80    
81          // Stop on system exit          // Stop on system exit
82          if (SYS_exit)          if (SYS_exit)
# Line 71  int igetch() Line 84  int igetch()
84    
85          if (pos >= len)          if (pos >= len)
86          {          {
87                    fd_set testfds;
88                    struct timeval timeout;
89    
90                  pos = 0;                  pos = 0;
91                  len = 0;                  len = 0;
92    
# Line 80  int igetch() Line 96  int igetch()
96                  timeout.tv_sec = 1;                  timeout.tv_sec = 1;
97                  timeout.tv_usec = 0;                  timeout.tv_usec = 0;
98    
99                  result = SignalSafeSelect(FD_SETSIZE, &testfds, (fd_set *)NULL,                  int result = SignalSafeSelect(FD_SETSIZE, &testfds, (fd_set *)NULL,
100                                                                    (fd_set *)NULL, &timeout);                                                                    (fd_set *)NULL, &timeout);
101    
102                  if (result == 0)                  if (result == 0)
# Line 107  int igetch() Line 123  int igetch()
123    
124          while (pos < len)          while (pos < len)
125          {          {
126                  c = buf[pos++];                  unsigned char c = buf[pos++];
127    
128                  if (c == '\0')                  if (c == '\0')
129                  {                  {
# Line 227  int igetch_t(long int sec) Line 243  int igetch_t(long int sec)
243    
244          do          do
245          {          {
246                  ch = igetch();                  ch = igetch(0);
247          } while ((ch == KEY_TIMEOUT || ch == 0xa || ch == 0x0) && (time(0) - t_begin < sec));          } while ((ch == KEY_TIMEOUT || ch == 0xa) && (time(0) - t_begin < sec));
248    
249          return ch;          return ch;
250  }  }


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

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