/[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.8 by sysadm, Mon Mar 21 17:08:21 2005 UTC Revision 1.10 by sysadm, Tue Mar 22 13:36:13 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 60  igetch () Line 63  igetch ()
63    static char buf[256];    static char buf[256];
64    unsigned char c, tmp[256];    unsigned char c, tmp[256];
65    int out = KEY_NULL, loop = 1, in_esc = 0, in_ascii = 0, in_control = 0, i =    int out = KEY_NULL, loop = 1, in_esc = 0, in_ascii = 0, in_control = 0, i =
66      0, j;      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 191  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        {
230          ch = igetch ();
231        }
232      while ((ch == KEY_TIMEOUT) && (time (0) - t_begin < sec));
233    
234      return ch;
235    }
236    
237    int
238  ikbhit ()  ikbhit ()
239  {  {
240    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