diff --git a/tools/n2n-portfwd.c b/tools/n2n-portfwd.c index da19769..b06e6e4 100644 --- a/tools/n2n-portfwd.c +++ b/tools/n2n-portfwd.c @@ -26,6 +26,7 @@ #define SOCKET_TIMEOUT 2 #define INFO_INTERVAL 5 +// REVISIT: may become obsolete #ifdef WIN32 #define STDIN_FILENO _fileno(stdin) #endif @@ -156,10 +157,12 @@ int get_port_from_json (uint16_t *port, json_object_t *json, char *key, int tag, // ------------------------------------------------------------------------------------------------------- +// PLATFORM-DEPENDANT CODE +#if !defined(WIN32) // taken from https://web.archive.org/web/20170407122137/http://cc.byexamples.com/2007/04/08/non-blocking-user-input-in-loop-without-ncurses/ -int kbhit () { +int _kbhit () { struct timeval tv; fd_set fds; @@ -172,6 +175,7 @@ int kbhit () { return FD_ISSET(STDIN_FILENO, &fds); } +#endif // ------------------------------------------------------------------------------------------------------- @@ -311,7 +315,7 @@ reset_main_loop: // read answer packet by packet which are only accepted if a corresponding request was sent before // of which we know about by having set the related tag, tag_info // a valid sock address indicates that we have seen a valid answer to the info request - while(keep_running && !kbhit()) { + while(keep_running && !_kbhit()) { // current time now = time(NULL);