Skip to content

Commit ba8855f

Browse files
authored
added to portfwd tool - Windows keyboard fix (ntop#1035)
* added to portfwd tool - Windows keyboard fix * is it just a hick-up
1 parent 504a552 commit ba8855f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tools/n2n-portfwd.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#define SOCKET_TIMEOUT 2
2727
#define INFO_INTERVAL 5
2828

29+
// REVISIT: may become obsolete
2930
#ifdef WIN32
3031
#define STDIN_FILENO _fileno(stdin)
3132
#endif
@@ -156,10 +157,12 @@ int get_port_from_json (uint16_t *port, json_object_t *json, char *key, int tag,
156157

157158

158159
// -------------------------------------------------------------------------------------------------------
160+
// PLATFORM-DEPENDANT CODE
159161

160162

163+
#if !defined(WIN32)
161164
// taken from https://web.archive.org/web/20170407122137/http://cc.byexamples.com/2007/04/08/non-blocking-user-input-in-loop-without-ncurses/
162-
int kbhit () {
165+
int _kbhit () {
163166

164167
struct timeval tv;
165168
fd_set fds;
@@ -172,6 +175,7 @@ int kbhit () {
172175

173176
return FD_ISSET(STDIN_FILENO, &fds);
174177
}
178+
#endif
175179

176180

177181
// -------------------------------------------------------------------------------------------------------
@@ -311,7 +315,7 @@ int main (int argc, char* argv[]) {
311315
// read answer packet by packet which are only accepted if a corresponding request was sent before
312316
// of which we know about by having set the related tag, tag_info
313317
// a valid sock address indicates that we have seen a valid answer to the info request
314-
while(keep_running && !kbhit()) {
318+
while(keep_running && !_kbhit()) {
315319
// current time
316320
now = time(NULL);
317321

0 commit comments

Comments
 (0)