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