read a key without blocking */
| 371 | |
| 372 | /* read a key without blocking */ |
| 373 | static int read_key(void) |
| 374 | { |
| 375 | #if HAVE_TERMIOS_H |
| 376 | int n = 1; |
| 377 | unsigned char ch; |
| 378 | #if !CONFIG_BEOS_NETSERVER |
| 379 | struct timeval tv; |
| 380 | fd_set rfds; |
| 381 | |
| 382 | FD_ZERO(&rfds); |
| 383 | FD_SET(0, &rfds); |
| 384 | tv.tv_sec = 0; |
| 385 | tv.tv_usec = 0; |
| 386 | n = select(1, &rfds, NULL, NULL, &tv); |
| 387 | #endif |
| 388 | if (n > 0) { |
| 389 | n = read(0, &ch, 1); |
| 390 | if (n == 1) |
| 391 | return ch; |
| 392 | |
| 393 | return n; |
| 394 | } |
| 395 | #elif HAVE_CONIO_H |
| 396 | if(kbhit()) |
| 397 | return(getch()); |
| 398 | #endif |
| 399 | return -1; |
| 400 | } |
| 401 | |
| 402 | static int decode_interrupt_cb(void) |
| 403 | { |
no outgoing calls
no test coverage detected