Permalink
Browse files

openssl: fix keypress requirement in apps on win32

Reapply b910613 .

Fixes: #589
PR-URL: #1389
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information...
1 parent f5b77fd commit c4678d2f9ac8f527d968384cf16b30b21fe290b5 @shigeki shigeki committed with MylesBorins Feb 17, 2015
Showing with 13 additions and 7 deletions.
  1. +13 −7 deps/openssl/openssl/apps/s_client.c
@@ -180,6 +180,13 @@ typedef unsigned int u_int;
# include <fcntl.h>
#endif
+/* Use Windows API with STD_INPUT_HANDLE when checking for input?
+ Don't look at OPENSSL_SYS_MSDOS for this, since it is always defined if
+ OPENSSL_SYS_WINDOWS is defined */
+#if defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_WINCE) && defined(STD_INPUT_HANDLE)
+#define OPENSSL_USE_STD_INPUT_HANDLE
+#endif
+
#undef PROG
#define PROG s_client_main
@@ -1790,17 +1797,16 @@ int MAIN(int argc, char **argv)
tv.tv_usec = 0;
i = select(width, (void *)&readfds, (void *)&writefds,
NULL, &tv);
-# if defined(OPENSSL_SYS_WINCE) || defined(OPENSSL_SYS_MSDOS)
- if (!i && (!_kbhit() || !read_tty))
- continue;
-# else
+#if defined(OPENSSL_USE_STD_INPUT_HANDLE)
if (!i && (!((_kbhit())
|| (WAIT_OBJECT_0 ==
WaitForSingleObject(GetStdHandle
(STD_INPUT_HANDLE),
0)))
|| !read_tty))
continue;
+#else
+ if(!i && (!_kbhit() || !read_tty) ) continue;
# endif
} else
i = select(width, (void *)&readfds, (void *)&writefds,
@@ -2002,12 +2008,12 @@ int MAIN(int argc, char **argv)
}
}
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
-# if defined(OPENSSL_SYS_WINCE) || defined(OPENSSL_SYS_MSDOS)
- else if (_kbhit())
-# else
+#if defined(OPENSSL_USE_STD_INPUT_HANDLE)
else if ((_kbhit())
|| (WAIT_OBJECT_0 ==
WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0)))
+#else
+ else if (_kbhit())
# endif
#elif defined (OPENSSL_SYS_NETWARE)
else if (_kbhit())

0 comments on commit c4678d2

Please sign in to comment.