aboutsummaryrefslogtreecommitdiff
path: root/apps/openssl/apps_win.c
diff options
context:
space:
mode:
authorBrent Cook <bcook@openbsd.org>2015-10-18 09:28:10 -0500
committerBrent Cook <bcook@openbsd.org>2015-10-18 09:28:10 -0500
commit0197a589691274055e3a6f47a3652a6714d676bc (patch)
tree9a2c16f2cb86605522ce747c1a71bfd0c23db389 /apps/openssl/apps_win.c
parentc8918dd0be1bbadfcebfc6631bd63f3b3e83befd (diff)
downloadportable-0197a589691274055e3a6f47a3652a6714d676bc.tar.gz
portable-0197a589691274055e3a6f47a3652a6714d676bc.tar.bz2
portable-0197a589691274055e3a6f47a3652a6714d676bc.zip
Windows compatibility fixes
VS2013 has trouble with relative include paths for apps/openssl, so move certhash_win/apps_win.c back to apps/openssl. gmtime_r on mingw64 fails with negative time_t, override gmtime_s fails all of the time unit tests, override SHUT_RD/WR are defined in newer mingw64 headers, check before overriding
Diffstat (limited to 'apps/openssl/apps_win.c')
-rw-r--r--apps/openssl/apps_win.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/apps/openssl/apps_win.c b/apps/openssl/apps_win.c
new file mode 100644
index 0000000..37bfcc9
--- /dev/null
+++ b/apps/openssl/apps_win.c
@@ -0,0 +1,60 @@
1/*
2 * Public domain
3 *
4 * Dongsheng Song <dongsheng.song@gmail.com>
5 * Brent Cook <bcook@openbsd.org>
6 */
7
8#include <windows.h>
9
10#include <io.h>
11#include <fcntl.h>
12
13#include "apps.h"
14
15double
16app_tminterval(int stop, int usertime)
17{
18 static unsigned __int64 tmstart;
19 union {
20 unsigned __int64 u64;
21 FILETIME ft;
22 } ct, et, kt, ut;
23
24 GetProcessTimes(GetCurrentProcess(), &ct.ft, &et.ft, &kt.ft, &ut.ft);
25
26 if (stop == TM_START) {
27 tmstart = ut.u64 + kt.u64;
28 } else {
29 return (ut.u64 + kt.u64 - tmstart) / (double) 10000000;
30 }
31 return 0;
32}
33
34int
35setup_ui(void)
36{
37 ui_method = UI_create_method("OpenSSL application user interface");
38 UI_method_set_opener(ui_method, ui_open);
39 UI_method_set_reader(ui_method, ui_read);
40 UI_method_set_writer(ui_method, ui_write);
41 UI_method_set_closer(ui_method, ui_close);
42
43 /*
44 * Set STDIO to binary
45 */
46 _setmode(_fileno(stdin), _O_BINARY);
47 _setmode(_fileno(stdout), _O_BINARY);
48 _setmode(_fileno(stderr), _O_BINARY);
49
50 return 0;
51}
52
53void
54destroy_ui(void)
55{
56 if (ui_method) {
57 UI_destroy_method(ui_method);
58 ui_method = NULL;
59 }
60}