| 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 |
| 62 |
{ |
{ |
| 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 = 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++) |
| 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; |
| 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; |