/[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.10 by sysadm, Tue Mar 22 13:36:13 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>  #include <time.h>
# Line 65  igetch () Line 66  igetch ()
66    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 =
67      0, j, result;      0, j, result;
68    static int len = 0, pos = 0;    static int len = 0, pos = 0;
69    fd_set inputs, testfds;    fd_set testfds;
70    struct timeval timeout;    struct timeval timeout;
71    
72    if (pos >= len)    if (pos >= len)
# Line 73  igetch () Line 74  igetch ()
74        pos = 0;        pos = 0;
75        len = 0;        len = 0;
76    
77        FD_ZERO (&inputs);        FD_ZERO (&testfds);
78        FD_SET (0, &inputs);        FD_SET (0, &testfds);
79    
       testfds = inputs;  
80        timeout.tv_sec = 1;        timeout.tv_sec = 1;
81        timeout.tv_usec = 0;        timeout.tv_usec = 0;
82    
83        result = select (FD_SETSIZE, &testfds, (fd_set *) NULL,        result = SignalSafeSelect (FD_SETSIZE, &testfds, (fd_set *) NULL,
84                         (fd_set *) NULL, &timeout);                         (fd_set *) NULL, &timeout);
85    
86        switch (result)        if (result == 0)
87            {
88              return KEY_TIMEOUT;
89            }
90          if (result < 0)
91          {          {
         case 0:  
           out = KEY_TIMEOUT;  
           break;  
         case -1:  
92            log_error ("select() error!\n");            log_error ("select() error!\n");
93            break;            return KEY_NULL;
94          default:          }
95          if (result > 0)
96            {
97            if (FD_ISSET (0, &testfds))            if (FD_ISSET (0, &testfds))
98              {              {
99                len = read (0, buf, 255);                len = read (0, buf, 255);
100              }              }
           break;  
101          }          }
102    
103        //For debug        //For debug


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

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