Browse Source

added to portfwd tool - Windows keyboard fix (#1035)

* added to portfwd tool - Windows keyboard fix

* is it just a hick-up
pull/1036/head
Logan oos Even 2 years ago
committed by GitHub
parent
commit
ba8855fa71
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      tools/n2n-portfwd.c

8
tools/n2n-portfwd.c

@ -26,6 +26,7 @@
#define SOCKET_TIMEOUT 2 #define SOCKET_TIMEOUT 2
#define INFO_INTERVAL 5 #define INFO_INTERVAL 5
// REVISIT: may become obsolete
#ifdef WIN32 #ifdef WIN32
#define STDIN_FILENO _fileno(stdin) #define STDIN_FILENO _fileno(stdin)
#endif #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/ // 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; struct timeval tv;
fd_set fds; fd_set fds;
@ -172,6 +175,7 @@ int kbhit () {
return FD_ISSET(STDIN_FILENO, &fds); 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 // 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 // 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 // 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 // current time
now = time(NULL); now = time(NULL);

Loading…
Cancel
Save