| 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) |
| 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 |
|
|
| 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) |
| 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 |
{ |
{ |
| 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 |
} |
} |