/[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.7 by sysadm, Mon Mar 21 05:43:43 2005 UTC Revision 1.11 by sysadm, Sat May 7 09:28:12 2005 UTC
# Line 17  Line 17 
17    
18  #include "io.h"  #include "io.h"
19  #include "common.h"  #include "common.h"
20    #include "tcplib.h"
21  #include <stdio.h>  #include <stdio.h>
22  #include <stdarg.h>  #include <stdarg.h>
23    #include <time.h>
24    #include <fcntl.h>
25    #include <unistd.h>
26  #include <sys/ioctl.h>  #include <sys/ioctl.h>
27    
28  int  int
# Line 59  igetch () Line 63  igetch ()
63  {  {
64    static char buf[256];    static char buf[256];
65    unsigned char c, tmp[256];    unsigned char c, tmp[256];
66    int out = KEY_NULL, loop = 1, in_esc = 0, in_ascii = 0, in_control = 0, i = 0, j;    int out = KEY_NULL, loop = 1, in_esc = 0, in_ascii = 0, in_control = 0, i =
67        0, j, result;
68    static int len = 0, pos = 0;    static int len = 0, pos = 0;
69      fd_set testfds;
70      struct timeval timeout;
71    
72    if (pos >= len)    if (pos >= len)
73      {      {
74        pos = 0;        pos = 0;
75          len = 0;
76    
77        //len = s_receive (socket_client, buf, 255, "");        FD_ZERO (&testfds);
78        len = read (0, buf, 255);        FD_SET (0, &testfds);
79    
80          timeout.tv_sec = 1;
81          timeout.tv_usec = 0;
82    
83          result = SignalSafeSelect (FD_SETSIZE, &testfds, (fd_set *) NULL,
84                           (fd_set *) NULL, &timeout);
85    
86          if (result == 0)
87            {
88              return KEY_TIMEOUT;
89            }
90          if (result < 0)
91            {
92              log_error ("select() error!\n");
93              return KEY_NULL;
94            }
95          if (result > 0)
96            {
97              if (FD_ISSET (0, &testfds))
98                {
99                  len = read (0, buf, 255);
100                }
101            }
102    
103        //For debug        //For debug
104        //for (j = 0; j < len; j++)        //for (j = 0; j < len; j++)
# Line 171  igetch () Line 202  igetch ()
202                    out = KEY_PGUP;                    out = KEY_PGUP;
203                    break;                    break;
204                  case 54:                  case 54:
205                    out = KEY_PGDOWN;                    out = KEY_PGDN;
206                    break;                    break;
207                  }                  }
208                break;                break;
# Line 190  igetch () Line 221  igetch ()
221  }  }
222    
223  int  int
224    igetch_t (long int sec)
225    {
226      int ch;
227      time_t t_begin = time (0);
228    
229      do
230        {
231          ch = igetch ();
232        }
233      while ((ch == KEY_TIMEOUT) && (time (0) - t_begin < sec));
234    
235      return ch;
236    }
237    
238    int
239  ikbhit ()  ikbhit ()
240  {  {
241    int len;    int len;


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

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