Browse code

Replace WIN32 by _WIN32

With c99, "WIN32" is no longer automatically defined when (cross-)building
for Windows, and proper compilation relies on including <windefs.h>,
before checking the macro. "_WIN32" is the official define that is
guaranteed to be defined by the compiler itself, no includes are needed.

So, mechanically change all occurrances of "WIN32" to "_WIN32".

While at it, get rid of unused WIN32_0_1 #define in syshead.h

See also:
http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefi
ned_macros_detect_operating_system#WindowsCygwinnonPOSIXandMinGW

Trac #746

v2: rebased to master, merge the console[_builtin].c changes

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20161113195228.74090-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13035.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Gert Doering authored on 2016/11/14 04:52:28
Showing 45 changed files
... ...
@@ -235,7 +235,7 @@ EXPAND_ONLY_PREDEF     = NO
235 235
 SEARCH_INCLUDES        = YES
236 236
 INCLUDE_PATH           =
237 237
 INCLUDE_FILE_PATTERNS  =
238
-PREDEFINED             = WIN32 NTLM USE_LZO ENABLE_FRAGMENT P2MP P2MP_SERVER ENABLE_CRYPTO ENABLE_CRYPTO_OPENSSL ENABLE_PLUGIN ENABLE_MANAGEMENT ENABLE_OCC HAVE_GETTIMEOFDAY
238
+PREDEFINED             = _WIN32 NTLM USE_LZO ENABLE_FRAGMENT P2MP P2MP_SERVER ENABLE_CRYPTO ENABLE_CRYPTO_OPENSSL ENABLE_PLUGIN ENABLE_MANAGEMENT ENABLE_OCC HAVE_GETTIMEOFDAY
239 239
 EXPAND_AS_DEFINED      =
240 240
 SKIP_FUNCTION_MACROS   = YES
241 241
 #---------------------------------------------------------------------------
... ...
@@ -154,7 +154,7 @@ typedef void *openvpn_plugin_handle_t;
154 154
 /*
155 155
  * For Windows (needs to be modified for MSVC)
156 156
  */
157
-#if defined(WIN32) && !defined(OPENVPN_PLUGIN_H)
157
+#if defined(_WIN32) && !defined(OPENVPN_PLUGIN_H)
158 158
 # define OPENVPN_EXPORT __declspec(dllexport)
159 159
 #else
160 160
 # define OPENVPN_EXPORT
... ...
@@ -32,7 +32,7 @@
32 32
 
33 33
 #include "compat.h"
34 34
 
35
-#ifdef WIN32
35
+#ifdef _WIN32
36 36
 /*
37 37
  * NOTICE: mingw has much faster gettimeofday!
38 38
  * autoconf will set HAVE_GETTIMEOFDAY
... ...
@@ -126,6 +126,6 @@ gettimeofday (struct timeval *tv, void *tz)
126 126
 	return 0;
127 127
 }
128 128
 
129
-#endif /* WIN32 */
129
+#endif /* _WIN32 */
130 130
 
131 131
 #endif /* HAVE_GETTIMEOFDAY */
... ...
@@ -32,7 +32,7 @@
32 32
 
33 33
 #include "compat.h"
34 34
 
35
-#ifdef WIN32
35
+#ifdef _WIN32
36 36
 
37 37
 #include <windows.h>
38 38
 
... ...
@@ -32,7 +32,7 @@
32 32
 
33 33
 #include "compat.h"
34 34
 
35
-#ifdef WIN32
35
+#ifdef _WIN32
36 36
 
37 37
 #include <windows.h>
38 38
 #include <string.h>
... ...
@@ -35,7 +35,7 @@
35 35
 
36 36
 #include "syshead.h"
37 37
 
38
-#ifdef WIN32
38
+#ifdef _WIN32
39 39
 
40 40
 #include <fwpmu.h>
41 41
 #include <initguid.h>
... ...
@@ -22,7 +22,7 @@
22 22
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23 23
  */
24 24
 
25
-#ifdef WIN32
25
+#ifdef _WIN32
26 26
 
27 27
 #ifndef OPENVPN_BLOCK_DNS_H
28 28
 #define OPENVPN_BLOCK_DNS_H
... ...
@@ -30,7 +30,7 @@
30 30
  */
31 31
 #ifdef USE_64_BIT_COUNTERS
32 32
   typedef unsigned long long int counter_type;
33
-# ifdef WIN32
33
+# ifdef _WIN32
34 34
 #  define counter_format  "%I64u"
35 35
 # else
36 36
 #  define counter_format  "%llu"
... ...
@@ -41,7 +41,7 @@
41 41
 #include "buffer.h"
42 42
 #include "misc.h"
43 43
 
44
-#ifdef WIN32
44
+#ifdef _WIN32
45 45
 
46 46
 #include "win32.h"
47 47
 
... ...
@@ -119,7 +119,7 @@ static bool get_console_input_win32 (const char *prompt, const bool echo, char *
119 119
     return false;
120 120
 }
121 121
 
122
-#endif   /* WIN32 */
122
+#endif   /* _WIN32 */
123 123
 
124 124
 
125 125
 #ifdef HAVE_GETPASS
... ...
@@ -176,7 +176,7 @@ static bool get_console_input (const char *prompt, const bool echo, char *input,
176 176
     ASSERT (capacity > 0);
177 177
     input[0] = '\0';
178 178
 
179
-#if defined(WIN32)
179
+#if defined(_WIN32)
180 180
     return get_console_input_win32 (prompt, echo, input, capacity);
181 181
 #elif defined(HAVE_GETPASS)
182 182
 
... ...
@@ -465,4 +465,4 @@ int SSL_CTX_use_CryptoAPI_certificate(SSL_CTX *ssl_ctx, const char *cert_prop)
465 465
 #ifdef _MSC_VER  /* Dummy function needed to avoid empty file compiler warning in Microsoft VC */
466 466
 static void dummy (void) {}
467 467
 #endif
468
-#endif				/* WIN32 */
468
+#endif				/* _WIN32 */
... ...
@@ -453,7 +453,7 @@ close_syslog ()
453 453
 #endif
454 454
 }
455 455
 
456
-#ifdef WIN32
456
+#ifdef _WIN32
457 457
 
458 458
 static HANDLE orig_stderr;
459 459
 
... ...
@@ -471,7 +471,7 @@ get_orig_stderr (void)
471 471
 void
472 472
 redirect_stdout_stderr (const char *file, bool append)
473 473
 {
474
-#if defined(WIN32)
474
+#if defined(_WIN32)
475 475
   if (!std_redir)
476 476
     {
477 477
       struct gc_arena gc = gc_new ();
... ...
@@ -622,7 +622,7 @@ x_check_status (int status,
622 622
 	      sock->info.mtu_changed = true;
623 623
 	    }
624 624
 	}
625
-#elif defined(WIN32)
625
+#elif defined(_WIN32)
626 626
       /* get possible driver error from TAP-Windows driver */
627 627
       extended_msg = tap_win_getinfo (tt, &gc);
628 628
 #endif
... ...
@@ -677,7 +677,7 @@ openvpn_exit (const int status)
677 677
 
678 678
       tun_abort();
679 679
 
680
-#ifdef WIN32
680
+#ifdef _WIN32
681 681
       uninit_win32 ();
682 682
 #endif
683 683
 
... ...
@@ -737,7 +737,7 @@ crash (void)
737 737
 }
738 738
 #endif
739 739
 
740
-#ifdef WIN32
740
+#ifdef _WIN32
741 741
 
742 742
 const char *
743 743
 strerror_win32 (DWORD errnum, struct gc_arena *gc)
... ...
@@ -71,7 +71,7 @@ struct gc_arena;
71 71
 
72 72
 /* String and Error functions */
73 73
 
74
-#ifdef WIN32
74
+#ifdef _WIN32
75 75
 # define openvpn_errno()             GetLastError()
76 76
 # define openvpn_strerror(e, gc)     strerror_win32(e, gc)
77 77
   const char *strerror_win32 (DWORD errnum, struct gc_arena *gc);
... ...
@@ -261,7 +261,7 @@ void close_syslog ();
261 261
 /* log file output */
262 262
 void redirect_stdout_stderr (const char *file, bool append);
263 263
 
264
-#ifdef WIN32
264
+#ifdef _WIN32
265 265
 /* get original stderr handle, even if redirected by --log/--log-append */
266 266
 HANDLE get_orig_stderr (void);
267 267
 #endif
... ...
@@ -356,7 +356,7 @@ static inline bool
356 356
 ignore_sys_error (const int err)
357 357
 {
358 358
   /* I/O operation pending */
359
-#ifdef WIN32
359
+#ifdef _WIN32
360 360
   if (err == WSAEWOULDBLOCK || err == WSAEINVAL)
361 361
     return true;
362 362
 #else
... ...
@@ -49,7 +49,7 @@
49 49
 /*
50 50
  * All non-windows OSes are assumed to have select()
51 51
  */
52
-#ifdef WIN32
52
+#ifdef _WIN32
53 53
 #define SELECT 0
54 54
 #else
55 55
 #define SELECT 1
... ...
@@ -74,7 +74,7 @@ tv_to_ms_timeout (const struct timeval *tv)
74 74
     return max_int (tv->tv_sec * 1000 + (tv->tv_usec + 500) / 1000, 1);
75 75
 }
76 76
 
77
-#ifdef WIN32
77
+#ifdef _WIN32
78 78
 
79 79
 struct we_set
80 80
 {
... ...
@@ -462,7 +462,7 @@ we_init (int *maxevents, unsigned int flags)
462 462
   return (struct event_set *) wes;
463 463
 }
464 464
 
465
-#endif /* WIN32 */
465
+#endif /* _WIN32 */
466 466
 
467 467
 #if EPOLL
468 468
 
... ...
@@ -1007,7 +1007,7 @@ static struct event_set *
1007 1007
 event_set_init_simple (int *maxevents, unsigned int flags)
1008 1008
 {
1009 1009
   struct event_set *ret = NULL;
1010
-#ifdef WIN32
1010
+#ifdef _WIN32
1011 1011
   ret = we_init (maxevents, flags);
1012 1012
 #elif POLL && SELECT
1013 1013
 #if 0 /* Define to 1 if EVENT_METHOD_US_TIMEOUT should cause select to be favored over poll */
... ...
@@ -42,7 +42,7 @@
42 42
 #define EVENT_METHOD_US_TIMEOUT   (1<<0)
43 43
 #define EVENT_METHOD_FAST         (1<<1)
44 44
 
45
-#ifdef WIN32
45
+#ifdef _WIN32
46 46
 
47 47
 typedef const struct rw_handle *event_t;
48 48
 
... ...
@@ -137,7 +137,7 @@ event_set_return_init (struct event_set_return *esr)
137 137
   esr->arg = NULL;
138 138
 }
139 139
 
140
-#ifdef WIN32
140
+#ifdef _WIN32
141 141
 
142 142
 static inline void
143 143
 wait_signal (struct event_set *es, void *arg)
... ...
@@ -39,7 +39,7 @@
39 39
 bool
40 40
 set_nonblock_action (int fd)
41 41
 {
42
-#ifdef WIN32
42
+#ifdef _WIN32
43 43
   u_long arg = 1;
44 44
   if (ioctlsocket (fd, FIONBIO, &arg))
45 45
     return false;
... ...
@@ -54,7 +54,7 @@ set_nonblock_action (int fd)
54 54
 bool
55 55
 set_cloexec_action (int fd)
56 56
 {
57
-#ifndef WIN32
57
+#ifndef _WIN32
58 58
   if (fcntl (fd, F_SETFD, FD_CLOEXEC) < 0)
59 59
     return false;
60 60
 #endif
... ...
@@ -37,7 +37,7 @@ void set_cloexec (int fd);
37 37
 
38 38
 static inline void openvpn_fd_set(int fd, fd_set *setp)
39 39
 {
40
-#ifndef WIN32 /* The Windows FD_SET() implementation does not overflow */
40
+#ifndef _WIN32 /* The Windows FD_SET() implementation does not overflow */
41 41
   ASSERT (fd >= 0 && fd < FD_SETSIZE);
42 42
 #endif
43 43
   FD_SET (fd, setp);
... ...
@@ -301,7 +301,7 @@ check_add_routes_dowork (struct context *c)
301 301
 	    {
302 302
 	      register_signal (c, SIGHUP, "ip-fail");
303 303
 	      c->persist.restart_sleep_seconds = 10;
304
-#ifdef WIN32
304
+#ifdef _WIN32
305 305
 	      show_routes (M_INFO|M_NOPREFIX);
306 306
 	      show_adapters (M_INFO|M_NOPREFIX);
307 307
 #endif
... ...
@@ -1420,7 +1420,7 @@ pre_select (struct context *c)
1420 1420
   c->c2.timeval.tv_sec = BIG_TIMEOUT;
1421 1421
   c->c2.timeval.tv_usec = 0;
1422 1422
 
1423
-#if defined(WIN32)
1423
+#if defined(_WIN32)
1424 1424
   if (check_debug_level (D_TAP_WIN_DEBUG))
1425 1425
     {
1426 1426
       c->c2.timeval.tv_sec = 1;
... ...
@@ -577,7 +577,7 @@ init_static (void)
577 577
   error_reset ();		/* initialize error.c */
578 578
   reset_check_status ();	/* initialize status check code in socket.c */
579 579
 
580
-#ifdef WIN32
580
+#ifdef _WIN32
581 581
   init_win32 ();
582 582
 #endif
583 583
 
... ...
@@ -1024,7 +1024,7 @@ format_common_name (struct context *c, struct gc_arena *gc)
1024 1024
 void
1025 1025
 pre_setup (const struct options *options)
1026 1026
 {
1027
-#ifdef WIN32
1027
+#ifdef _WIN32
1028 1028
   if (options->exit_event_name)
1029 1029
     {
1030 1030
       win32_signal_open (&win32_signal,
... ...
@@ -1245,7 +1245,7 @@ initialization_sequence_completed (struct context *c, const unsigned int flags)
1245 1245
   /* Test if errors */
1246 1246
   if (flags & ISC_ERRORS)
1247 1247
     {
1248
-#ifdef WIN32
1248
+#ifdef _WIN32
1249 1249
       show_routes (M_INFO|M_NOPREFIX);
1250 1250
       show_adapters (M_INFO|M_NOPREFIX);
1251 1251
       msg (M_INFO, "%s With Errors ( see http://openvpn.net/faq.html#dhcpclientserv )", message);
... ...
@@ -1260,7 +1260,7 @@ initialization_sequence_completed (struct context *c, const unsigned int flags)
1260 1260
   if ((flags & (ISC_ERRORS|ISC_SERVER)) == 0)
1261 1261
     c->options.no_advance=true;
1262 1262
 
1263
-#ifdef WIN32
1263
+#ifdef _WIN32
1264 1264
   fork_register_dns_action (c->c1.tuntap);
1265 1265
 #endif
1266 1266
 
... ...
@@ -1355,7 +1355,7 @@ do_route (const struct options *options,
1355 1355
       argv_reset (&argv);
1356 1356
     }
1357 1357
 
1358
-#ifdef WIN32
1358
+#ifdef _WIN32
1359 1359
   if (options->show_net_up)
1360 1360
     {
1361 1361
       show_routes (M_INFO|M_NOPREFIX);
... ...
@@ -1421,7 +1421,7 @@ do_open_tun (struct context *c)
1421 1421
       /* initialize (but do not open) tun/tap object */
1422 1422
       do_init_tun (c);
1423 1423
 
1424
-#ifdef WIN32
1424
+#ifdef _WIN32
1425 1425
       /* store (hide) interactive service handle in tuntap_options */
1426 1426
       c->c1.tuntap->options.msg_channel = c->options.msg_channel;
1427 1427
       msg (D_ROUTE, "interactive service msg_channel=%u", (unsigned int) c->options.msg_channel);
... ...
@@ -1482,7 +1482,7 @@ do_open_tun (struct context *c)
1482 1482
 		   c->plugins,
1483 1483
 		   OPENVPN_PLUGIN_UP,
1484 1484
 		   c->c1.tuntap->actual_name,
1485
-#ifdef WIN32
1485
+#ifdef _WIN32
1486 1486
 		   c->c1.tuntap->adapter_index,
1487 1487
 #endif
1488 1488
 		   dev_type_string (c->options.dev, c->options.dev_type),
... ...
@@ -1495,7 +1495,7 @@ do_open_tun (struct context *c)
1495 1495
 		   "up",
1496 1496
 		   c->c2.es);
1497 1497
 
1498
-#if defined(WIN32)
1498
+#if defined(_WIN32)
1499 1499
       if (c->options.block_outside_dns)
1500 1500
       {
1501 1501
         dmsg (D_LOW, "Blocking outside DNS");
... ...
@@ -1535,7 +1535,7 @@ do_open_tun (struct context *c)
1535 1535
 		     c->plugins,
1536 1536
 		     OPENVPN_PLUGIN_UP,
1537 1537
 		     c->c1.tuntap->actual_name,
1538
-#ifdef WIN32
1538
+#ifdef _WIN32
1539 1539
 		     c->c1.tuntap->adapter_index,
1540 1540
 #endif
1541 1541
 		     dev_type_string (c->options.dev, c->options.dev_type),
... ...
@@ -1547,7 +1547,7 @@ do_open_tun (struct context *c)
1547 1547
 		     NULL,
1548 1548
 		     "up",
1549 1549
 		     c->c2.es);
1550
-#if defined(WIN32)
1550
+#if defined(_WIN32)
1551 1551
       if (c->options.block_outside_dns)
1552 1552
         {
1553 1553
           dmsg (D_LOW, "Blocking outside DNS");
... ...
@@ -1585,7 +1585,7 @@ do_close_tun (struct context *c, bool force)
1585 1585
   if (c->c1.tuntap && c->c1.tuntap_owned)
1586 1586
     {
1587 1587
       const char *tuntap_actual = string_alloc (c->c1.tuntap->actual_name, &gc);
1588
-#ifdef WIN32
1588
+#ifdef _WIN32
1589 1589
       DWORD adapter_index = c->c1.tuntap->adapter_index;
1590 1590
 #endif
1591 1591
       const in_addr_t local = c->c1.tuntap->local;
... ...
@@ -1611,7 +1611,7 @@ do_close_tun (struct context *c, bool force)
1611 1611
                            c->plugins,
1612 1612
                            OPENVPN_PLUGIN_ROUTE_PREDOWN,
1613 1613
                            tuntap_actual,
1614
-#ifdef WIN32
1614
+#ifdef _WIN32
1615 1615
                            adapter_index,
1616 1616
 #endif
1617 1617
                            NULL,
... ...
@@ -1639,7 +1639,7 @@ do_close_tun (struct context *c, bool force)
1639 1639
 		       c->plugins,
1640 1640
 		       OPENVPN_PLUGIN_DOWN,
1641 1641
 		       tuntap_actual,
1642
-#ifdef WIN32
1642
+#ifdef _WIN32
1643 1643
 		       adapter_index,
1644 1644
 #endif
1645 1645
 		       NULL,
... ...
@@ -1653,7 +1653,7 @@ do_close_tun (struct context *c, bool force)
1653 1653
 		       "down",
1654 1654
 		       c->c2.es);
1655 1655
 
1656
-#if defined(WIN32)
1656
+#if defined(_WIN32)
1657 1657
             if (c->options.block_outside_dns)
1658 1658
             {
1659 1659
                 if (!win_wfp_uninit(c->options.msg_channel))
... ...
@@ -1673,7 +1673,7 @@ do_close_tun (struct context *c, bool force)
1673 1673
 			 c->plugins,
1674 1674
 			 OPENVPN_PLUGIN_DOWN,
1675 1675
 			 tuntap_actual,
1676
-#ifdef WIN32
1676
+#ifdef _WIN32
1677 1677
 			 adapter_index,
1678 1678
 #endif
1679 1679
 			 NULL,
... ...
@@ -1687,7 +1687,7 @@ do_close_tun (struct context *c, bool force)
1687 1687
 			 "down",
1688 1688
 			 c->c2.es);
1689 1689
 
1690
-#if defined(WIN32)
1690
+#if defined(_WIN32)
1691 1691
           if (c->options.block_outside_dns)
1692 1692
             {
1693 1693
               if (!win_wfp_uninit(c->options.msg_channel))
... ...
@@ -3173,7 +3173,7 @@ do_setup_fast_io (struct context *c)
3173 3173
 {
3174 3174
   if (c->options.fast_io)
3175 3175
     {
3176
-#ifdef WIN32
3176
+#ifdef _WIN32
3177 3177
       msg (M_INFO, "NOTE: --fast-io is disabled since we are running on Windows");
3178 3178
 #else
3179 3179
       if (!proto_is_udp(c->options.ce.proto))
... ...
@@ -3286,7 +3286,7 @@ management_callback_status_p2p (void *arg, const int version, struct status_outp
3286 3286
 void
3287 3287
 management_show_net_callback (void *arg, const int msglevel)
3288 3288
 {
3289
-#ifdef WIN32
3289
+#ifdef _WIN32
3290 3290
   show_routes (msglevel);
3291 3291
   show_adapters (msglevel);
3292 3292
   msg (msglevel, "END");
... ...
@@ -270,7 +270,7 @@ man_delete_unix_socket (struct management *man)
270 270
 static void
271 271
 man_close_socket (struct management *man, const socket_descriptor_t sd)
272 272
 {
273
-#ifndef WIN32
273
+#ifndef _WIN32
274 274
   /*
275 275
    * Windows doesn't need this because the ne32 event is permanently
276 276
    * enabled at struct management scope.
... ...
@@ -1413,7 +1413,7 @@ man_dispatch_command (struct management *man, struct status_output *so, const ch
1413 1413
   gc_free (&gc);
1414 1414
 }
1415 1415
 
1416
-#ifdef WIN32
1416
+#ifdef _WIN32
1417 1417
 
1418 1418
 static void
1419 1419
 man_start_ne32 (struct management *man)
... ...
@@ -1503,7 +1503,7 @@ man_new_connection_post (struct management *man, const char *description)
1503 1503
 
1504 1504
   man_connection_settings_reset (man);
1505 1505
 
1506
-#ifdef WIN32
1506
+#ifdef _WIN32
1507 1507
   man_start_ne32 (man);
1508 1508
 #endif
1509 1509
 
... ...
@@ -1590,7 +1590,7 @@ man_accept (struct management *man)
1590 1590
 
1591 1591
       if (socket_defined (man->connection.sd_top))
1592 1592
 	{
1593
-#ifdef WIN32
1593
+#ifdef _WIN32
1594 1594
 	  man_stop_ne32 (man);
1595 1595
 #endif
1596 1596
 	}
... ...
@@ -1654,7 +1654,7 @@ man_listen (struct management *man)
1654 1654
 	     print_sockaddr (man->settings.local->ai_addr, &gc));
1655 1655
     }
1656 1656
 
1657
-#ifdef WIN32
1657
+#ifdef _WIN32
1658 1658
   man_start_ne32 (man);
1659 1659
 #endif
1660 1660
   
... ...
@@ -1737,7 +1737,7 @@ man_reset_client_socket (struct management *man, const bool exiting)
1737 1737
 {
1738 1738
   if (socket_defined (man->connection.sd_cli))
1739 1739
     {
1740
-#ifdef WIN32
1740
+#ifdef _WIN32
1741 1741
       man_stop_ne32 (man);
1742 1742
 #endif
1743 1743
       man_close_socket (man, man->connection.sd_cli);
... ...
@@ -2254,7 +2254,7 @@ man_connection_init (struct management *man)
2254 2254
 {
2255 2255
   if (man->connection.state == MS_INITIAL)
2256 2256
     {
2257
-#ifdef WIN32
2257
+#ifdef _WIN32
2258 2258
       /*
2259 2259
        * This object is a sort of TCP/IP helper
2260 2260
        * for Windows.
... ...
@@ -2295,7 +2295,7 @@ man_connection_close (struct management *man)
2295 2295
 
2296 2296
   if (mc->es)
2297 2297
     event_free (mc->es);
2298
-#ifdef WIN32
2298
+#ifdef _WIN32
2299 2299
   net_event_win32_close (&mc->ne32);
2300 2300
 #endif
2301 2301
   if (socket_defined (mc->sd_top))
... ...
@@ -2731,7 +2731,7 @@ man_persist_state (unsigned int *persistent, const int n)
2731 2731
   return true;
2732 2732
 }
2733 2733
 
2734
-#ifdef WIN32
2734
+#ifdef _WIN32
2735 2735
 
2736 2736
 void
2737 2737
 management_socket_set (struct management *man,
... ...
@@ -257,7 +257,7 @@ struct man_connection {
257 257
   socket_descriptor_t sd_cli;
258 258
   struct openvpn_sockaddr remote;
259 259
 
260
-#ifdef WIN32
260
+#ifdef _WIN32
261 261
   struct net_event_win32 ne32;
262 262
 #endif
263 263
 
... ...
@@ -64,7 +64,7 @@ run_up_down (const char *command,
64 64
 	     const struct plugin_list *plugins,
65 65
 	     int plugin_type,
66 66
 	     const char *arg,
67
-#ifdef WIN32
67
+#ifdef _WIN32
68 68
 	     DWORD adapter_index,
69 69
 #endif
70 70
 	     const char *dev_type,
... ...
@@ -87,7 +87,7 @@ run_up_down (const char *command,
87 87
   setenv_str (es, "dev", arg);
88 88
   if (dev_type)
89 89
     setenv_str (es, "dev_type", dev_type);
90
-#ifdef WIN32
90
+#ifdef _WIN32
91 91
   setenv_int (es, "dev_idx", adapter_index);
92 92
 #endif
93 93
 
... ...
@@ -196,7 +196,7 @@ const char *
196 196
 system_error_message (int stat, struct gc_arena *gc)
197 197
 {
198 198
   struct buffer out = alloc_buf_gc (256, gc);
199
-#ifdef WIN32
199
+#ifdef _WIN32
200 200
   if (stat == -1)
201 201
     buf_printf (&out, "external program did not execute -- ");
202 202
   buf_printf (&out, "returned error code %d", stat);
... ...
@@ -252,7 +252,7 @@ openvpn_execve_allowed (const unsigned int flags)
252 252
 }
253 253
 
254 254
 
255
-#ifndef WIN32
255
+#ifndef _WIN32
256 256
 /*
257 257
  * Run execve() inside a fork().  Designed to replicate the semantics of system() but
258 258
  * in a safer way that doesn't require the invocation of a shell or the risks
... ...
@@ -950,7 +950,7 @@ hostname_randomize(const char *hostname, struct gc_arena *gc)
950 950
 const char *
951 951
 gen_path (const char *directory, const char *filename, struct gc_arena *gc)
952 952
 {
953
-#ifdef WIN32
953
+#ifdef _WIN32
954 954
   const int CC_PATH_RESERVED = CC_LESS_THAN|CC_GREATER_THAN|CC_COLON|
955 955
     CC_DOUBLE_QUOTE|CC_SLASH|CC_BACKSLASH|CC_PIPE|CC_QUESTION_MARK|CC_ASTERISK;
956 956
 #else
... ...
@@ -961,7 +961,7 @@ gen_path (const char *directory, const char *filename, struct gc_arena *gc)
961 961
   if (safe_filename
962 962
       && strcmp (safe_filename, ".")
963 963
       && strcmp (safe_filename, "..")
964
-#ifdef WIN32
964
+#ifdef _WIN32
965 965
       && win_safe_filename (safe_filename)
966 966
 #endif
967 967
       )
... ...
@@ -989,7 +989,7 @@ absolute_pathname (const char *pathname)
989 989
   if (pathname)
990 990
     {
991 991
       const int c = pathname[0];
992
-#ifdef WIN32
992
+#ifdef _WIN32
993 993
       return c == '\\' || (isalpha(c) && pathname[1] == ':' && pathname[2] == '\\');
994 994
 #else
995 995
       return c == '/';
... ...
@@ -56,7 +56,7 @@ void run_up_down (const char *command,
56 56
 		  const struct plugin_list *plugins,
57 57
 		  int plugin_type,
58 58
 		  const char *arg,
59
-#ifdef WIN32
59
+#ifdef _WIN32
60 60
 		  DWORD adapter_index,
61 61
 #endif
62 62
 		  const char *dev_type,
... ...
@@ -138,7 +138,7 @@ openvpn_main (int argc, char *argv[])
138 138
   return 1;
139 139
 #endif
140 140
 
141
-#ifdef WIN32
141
+#ifdef _WIN32
142 142
   SetConsoleOutputCP (CP_UTF8);
143 143
 #endif
144 144
 
... ...
@@ -172,7 +172,7 @@ openvpn_main (int argc, char *argv[])
172 172
 
173 173
 	  /* initialize environmental variable store */
174 174
 	  c.es = env_set_create (NULL);
175
-#ifdef WIN32
175
+#ifdef _WIN32
176 176
 	  set_win_sys_path_via_env (c.es);
177 177
 #endif
178 178
 
... ...
@@ -220,7 +220,7 @@ openvpn_main (int argc, char *argv[])
220 220
 
221 221
 	  /* print version number */
222 222
 	  msg (M_INFO, "%s", title_string);
223
-#ifdef WIN32
223
+#ifdef _WIN32
224 224
 	  show_windows_version(M_INFO);
225 225
 #endif
226 226
 	  show_library_versions(M_INFO);
... ...
@@ -312,7 +312,7 @@ openvpn_main (int argc, char *argv[])
312 312
   return 0;			            /* NOTREACHED */
313 313
 }
314 314
 
315
-#ifdef WIN32
315
+#ifdef _WIN32
316 316
 int
317 317
 wmain (int argc, wchar_t *wargv[]) {
318 318
   char **argv;
... ...
@@ -592,7 +592,7 @@ static const char usage_message[] =
592 592
   "                        Default is CN in the Subject field.\n"
593 593
 #endif
594 594
   "--verify-hash   : Specify SHA1 fingerprint for level-1 cert.\n"
595
-#ifdef WIN32
595
+#ifdef _WIN32
596 596
   "--cryptoapicert select-string : Load the certificate and private key from the\n"
597 597
   "                  Windows Certificate System Store.\n"
598 598
 #endif
... ...
@@ -670,7 +670,7 @@ static const char usage_message[] =
670 670
   "--show-digests  : Show message digest algorithms to use with --auth option.\n"
671 671
   "--show-engines  : Show hardware crypto accelerator engines (if available).\n"
672 672
   "--show-tls      : Show all TLS ciphers (TLS used only as a control channel).\n"
673
-#ifdef WIN32
673
+#ifdef _WIN32
674 674
   "\n"
675 675
   "Windows Specific:\n"
676 676
   "--win-sys path    : Pathname of Windows system directory. Default is the pathname\n"
... ...
@@ -720,7 +720,7 @@ static const char usage_message[] =
720 720
   "                       optional parameter controls the initial state of ex.\n"
721 721
   "--show-net-up   : Show " PACKAGE_NAME "'s view of routing table and net adapter list\n"
722 722
   "                  after TAP adapter is up and routes have been added.\n"
723
-#ifdef WIN32
723
+#ifdef _WIN32
724 724
   "--block-outside-dns   : Block DNS on other network adapters to prevent DNS leaks\n"
725 725
 #endif
726 726
   "Windows Standalone Options:\n"
... ...
@@ -816,7 +816,7 @@ init_options (struct options *o, const bool init_gc)
816 816
 #ifdef TARGET_LINUX
817 817
   o->tuntap_options.txqueuelen = 100;
818 818
 #endif
819
-#ifdef WIN32
819
+#ifdef _WIN32
820 820
 #if 0
821 821
   o->tuntap_options.ip_win32_type = IPW32_SET_ADAPTIVE;
822 822
 #else
... ...
@@ -879,7 +879,7 @@ init_options (struct options *o, const bool init_gc)
879 879
   o->auth_token_generate = false;
880 880
 
881 881
   /* Set default --tmp-dir */
882
-#ifdef WIN32
882
+#ifdef _WIN32
883 883
   /* On Windows, find temp dir via enviroment variables */
884 884
   o->tmp_dir = win_get_tempdir();
885 885
 #else
... ...
@@ -888,7 +888,7 @@ init_options (struct options *o, const bool init_gc)
888 888
   if( !o->tmp_dir ) {
889 889
           o->tmp_dir = "/tmp";
890 890
   }
891
-#endif /* WIN32 */
891
+#endif /* _WIN32 */
892 892
 #endif /* P2MP_SERVER */
893 893
   o->allow_recursive_routing = false;
894 894
 }
... ...
@@ -1141,7 +1141,7 @@ parse_hash_fingerprint(const char *str, int nbytes, int msglevel, struct gc_aren
1141 1141
 }
1142 1142
 #endif
1143 1143
 
1144
-#ifdef WIN32
1144
+#ifdef _WIN32
1145 1145
 
1146 1146
 #ifndef ENABLE_SMALL
1147 1147
 
... ...
@@ -1186,7 +1186,7 @@ show_tuntap_options (const struct tuntap_options *o)
1186 1186
 #endif
1187 1187
 #endif
1188 1188
 
1189
-#if defined(WIN32) || defined(TARGET_ANDROID)
1189
+#if defined(_WIN32) || defined(TARGET_ANDROID)
1190 1190
 static void
1191 1191
 dhcp_option_address_parse (const char *name, const char *parm, in_addr_t *array, int *len, int msglevel)
1192 1192
 {
... ...
@@ -1741,7 +1741,7 @@ show_settings (const struct options *o)
1741 1741
   show_p2mp_parms (o);
1742 1742
 #endif
1743 1743
 
1744
-#ifdef WIN32
1744
+#ifdef _WIN32
1745 1745
   SHOW_BOOL (show_net_up);
1746 1746
   SHOW_INT (route_method);
1747 1747
   SHOW_BOOL (block_outside_dns);
... ...
@@ -2033,7 +2033,7 @@ options_postprocess_verify_ce (const struct options *options, const struct conne
2033 2033
    * Windows-specific options.
2034 2034
    */
2035 2035
 
2036
-#ifdef WIN32
2036
+#ifdef _WIN32
2037 2037
       if (dev == DEV_TYPE_TUN && !(pull || (options->ifconfig_local && options->ifconfig_remote_netmask)))
2038 2038
 	msg (M_USAGE, "On Windows, --ifconfig is required when --dev tun is used");
2039 2039
 
... ...
@@ -2512,7 +2512,7 @@ options_postprocess_mutate_ce (struct options *o, struct connection_entry *ce)
2512 2512
 static void
2513 2513
 options_postprocess_mutate_invariant (struct options *options)
2514 2514
 {
2515
-#ifdef WIN32
2515
+#ifdef _WIN32
2516 2516
   const int dev = dev_type_enum (options->dev, options->dev_type);
2517 2517
 #endif
2518 2518
 
... ...
@@ -2523,7 +2523,7 @@ options_postprocess_mutate_invariant (struct options *options)
2523 2523
   if (options->inetd == INETD_NOWAIT)
2524 2524
     options->ifconfig_noexec = true;
2525 2525
 
2526
-#ifdef WIN32
2526
+#ifdef _WIN32
2527 2527
   if ((dev == DEV_TYPE_TUN || dev == DEV_TYPE_TAP) && !options->route_delay_defined)
2528 2528
     {
2529 2529
       if (options->mode == MODE_POINT_TO_POINT)
... ...
@@ -2546,7 +2546,7 @@ options_postprocess_mutate_invariant (struct options *options)
2546 2546
    */
2547 2547
   if (options->mode == MODE_SERVER)
2548 2548
     {
2549
-#ifdef WIN32
2549
+#ifdef _WIN32
2550 2550
       /*
2551 2551
        * We need to explicitly set --tap-sleep because
2552 2552
        * we do not schedule event timers in the top-level context.
... ...
@@ -2689,7 +2689,7 @@ options_postprocess_mutate (struct options *o)
2689 2689
 static void
2690 2690
 warn_if_group_others_accessible (const char* filename)
2691 2691
 {
2692
-#ifndef WIN32
2692
+#ifndef _WIN32
2693 2693
 #ifdef HAVE_STAT
2694 2694
   if (strcmp (filename, INLINE_FILE_TAG))
2695 2695
     {
... ...
@@ -3608,7 +3608,7 @@ usage_small (void)
3608 3608
   openvpn_exit (OPENVPN_EXIT_STATUS_USAGE); /* exit point */
3609 3609
 }
3610 3610
 
3611
-#ifdef WIN32
3611
+#ifdef _WIN32
3612 3612
 void show_windows_version(const unsigned int flags)
3613 3613
 {
3614 3614
   struct gc_arena gc = gc_new ();
... ...
@@ -3642,7 +3642,7 @@ usage_version (void)
3642 3642
 {
3643 3643
   msg (M_INFO|M_NOPREFIX, "%s", title_string);
3644 3644
   show_library_versions( M_INFO|M_NOPREFIX );
3645
-#ifdef WIN32
3645
+#ifdef _WIN32
3646 3646
   show_windows_version( M_INFO|M_NOPREFIX );
3647 3647
 #endif
3648 3648
   msg (M_INFO|M_NOPREFIX, "Originally developed by James Yonan");
... ...
@@ -3689,7 +3689,7 @@ positive_atoi (const char *str)
3689 3689
   return i < 0 ? 0 : i;
3690 3690
 }
3691 3691
 
3692
-#ifdef WIN32  /* This function is only used when compiling on Windows */
3692
+#ifdef _WIN32  /* This function is only used when compiling on Windows */
3693 3693
 static unsigned int
3694 3694
 atou (const char *str)
3695 3695
 {
... ...
@@ -6274,7 +6274,7 @@ add_option (struct options *options,
6274 6274
 #endif
6275 6275
   else if (streq (p[0], "msg-channel") && p[1])
6276 6276
     {
6277
-#ifdef WIN32
6277
+#ifdef _WIN32
6278 6278
       VERIFY_PERMISSION (OPT_P_GENERAL);
6279 6279
       HANDLE process = GetCurrentProcess ();
6280 6280
       HANDLE handle = (HANDLE) atoi (p[1]);
... ...
@@ -6290,7 +6290,7 @@ add_option (struct options *options,
6290 6290
       goto err;
6291 6291
 #endif
6292 6292
     }
6293
-#ifdef WIN32
6293
+#ifdef _WIN32
6294 6294
   else if (streq (p[0], "win-sys") && p[1] && !p[2])
6295 6295
     {
6296 6296
       VERIFY_PERMISSION (OPT_P_GENERAL);
... ...
@@ -6371,7 +6371,7 @@ add_option (struct options *options,
6371 6371
       to->ip_win32_defined = true; 
6372 6372
     }
6373 6373
 #endif
6374
-#if defined(WIN32) || defined(TARGET_ANDROID)
6374
+#if defined(_WIN32) || defined(TARGET_ANDROID)
6375 6375
   else if (streq (p[0], "dhcp-option") && p[1] && !p[3])
6376 6376
     {
6377 6377
       struct tuntap_options *o = &options->tuntap_options;
... ...
@@ -6424,7 +6424,7 @@ add_option (struct options *options,
6424 6424
       o->dhcp_options = true;
6425 6425
     }
6426 6426
 #endif
6427
-#ifdef WIN32
6427
+#ifdef _WIN32
6428 6428
   else if (streq (p[0], "show-adapters") && !p[1])
6429 6429
     {
6430 6430
       VERIFY_PERMISSION (OPT_P_GENERAL);
... ...
@@ -578,7 +578,7 @@ struct options
578 578
   /* special state parms */
579 579
   int foreign_option_index;
580 580
 
581
-#ifdef WIN32
581
+#ifdef _WIN32
582 582
   HANDLE msg_channel;
583 583
   const char *exit_event_name;
584 584
   bool exit_event_initial_state;
... ...
@@ -655,7 +655,7 @@ struct options
655 655
 #define PUSH_DEFINED(opt) (false)
656 656
 #endif
657 657
 
658
-#ifdef WIN32
658
+#ifdef _WIN32
659 659
 #define ROUTE_OPTION_FLAGS(o) ((o)->route_method & ROUTE_METHOD_MASK)
660 660
 #else
661 661
 #define ROUTE_OPTION_FLAGS(o) (0)
... ...
@@ -693,7 +693,7 @@ void usage_small (void);
693 693
 
694 694
 void show_library_versions(const unsigned int flags);
695 695
 
696
-#ifdef WIN32
696
+#ifdef _WIN32
697 697
 void show_windows_version(const unsigned int flags);
698 698
 #endif
699 699
 
... ...
@@ -76,8 +76,8 @@ openvpn_gettimeofday (struct timeval *tv, void *tz)
76 76
 static inline void
77 77
 update_time (void)
78 78
 {
79
-#ifdef WIN32
80
-  /* on WIN32, gettimeofday is faster than time(NULL) */
79
+#ifdef _WIN32
80
+  /* on _WIN32, gettimeofday is faster than time(NULL) */
81 81
   struct timeval tv;
82 82
   openvpn_gettimeofday (&tv, NULL);
83 83
 #else
... ...
@@ -90,8 +90,8 @@ update_time (void)
90 90
 static inline void
91 91
 update_time (void)
92 92
 {
93
-#if defined(WIN32)
94
-  /* on WIN32, gettimeofday is faster than time(NULL) */
93
+#if defined(_WIN32)
94
+  /* on _WIN32, gettimeofday is faster than time(NULL) */
95 95
   struct timeval tv;
96 96
   if (!gettimeofday (&tv, NULL))
97 97
     {
... ...
@@ -158,7 +158,7 @@ platform_nice (int niceval)
158 158
 unsigned int
159 159
 platform_getpid ()
160 160
 {
161
-#ifdef WIN32
161
+#ifdef _WIN32
162 162
   return (unsigned int) GetCurrentProcessId ();
163 163
 #else
164 164
 #ifdef HAVE_GETPID
... ...
@@ -190,7 +190,7 @@ int
190 190
 platform_chdir (const char* dir)
191 191
 {
192 192
 #ifdef HAVE_CHDIR
193
-#ifdef WIN32
193
+#ifdef _WIN32
194 194
   int res;
195 195
   struct gc_arena gc = gc_new ();
196 196
   res = _wchdir (wide_string (dir, &gc));
... ...
@@ -210,7 +210,7 @@ platform_chdir (const char* dir)
210 210
 bool
211 211
 platform_system_ok (int stat)
212 212
 {
213
-#ifdef WIN32
213
+#ifdef _WIN32
214 214
   return stat == 0;
215 215
 #else
216 216
   return stat != -1 && WIFEXITED (stat) && WEXITSTATUS (stat) == 0;
... ...
@@ -220,7 +220,7 @@ platform_system_ok (int stat)
220 220
 int
221 221
 platform_access (const char *path, int mode)
222 222
 {
223
-#ifdef WIN32
223
+#ifdef _WIN32
224 224
   struct gc_arena gc = gc_new ();
225 225
   int ret = _waccess (wide_string (path, &gc), mode & ~X_OK);
226 226
   gc_free (&gc);
... ...
@@ -236,7 +236,7 @@ platform_access (const char *path, int mode)
236 236
 void
237 237
 platform_sleep_milliseconds (unsigned int n)
238 238
 {
239
-#ifdef WIN32
239
+#ifdef _WIN32
240 240
   Sleep (n);
241 241
 #else
242 242
   struct timeval tv;
... ...
@@ -252,7 +252,7 @@ platform_sleep_milliseconds (unsigned int n)
252 252
 void
253 253
 platform_sleep_until_signal (void)
254 254
 {
255
-#ifdef WIN32
255
+#ifdef _WIN32
256 256
   ASSERT (0);
257 257
 #else
258 258
   select (0, NULL, NULL, NULL, NULL);
... ...
@@ -263,7 +263,7 @@ platform_sleep_until_signal (void)
263 263
 bool
264 264
 platform_unlink (const char *filename)
265 265
 {
266
-#if defined(WIN32)
266
+#if defined(_WIN32)
267 267
   struct gc_arena gc = gc_new ();
268 268
   BOOL ret = DeleteFileW (wide_string (filename, &gc));
269 269
   gc_free (&gc);
... ...
@@ -278,7 +278,7 @@ platform_unlink (const char *filename)
278 278
 FILE *
279 279
 platform_fopen (const char *path, const char *mode)
280 280
 {
281
-#ifdef WIN32
281
+#ifdef _WIN32
282 282
   struct gc_arena gc = gc_new ();
283 283
   FILE *f = _wfopen (wide_string (path, &gc), wide_string (mode, &gc));
284 284
   gc_free (&gc);
... ...
@@ -291,7 +291,7 @@ platform_fopen (const char *path, const char *mode)
291 291
 int
292 292
 platform_open (const char *path, int flags, int mode)
293 293
 {
294
-#ifdef WIN32
294
+#ifdef _WIN32
295 295
   struct gc_arena gc = gc_new ();
296 296
   int fd = _wopen (wide_string (path, &gc), flags, mode);
297 297
   gc_free (&gc);
... ...
@@ -304,7 +304,7 @@ platform_open (const char *path, int flags, int mode)
304 304
 int
305 305
 platform_stat (const char *path, platform_stat_t *buf)
306 306
 {
307
-#ifdef WIN32
307
+#ifdef _WIN32
308 308
   struct gc_arena gc = gc_new ();
309 309
   int res = _wstat (wide_string (path, &gc), buf);
310 310
   gc_free (&gc);
... ...
@@ -130,7 +130,7 @@ int platform_putenv (char *string);
130 130
 FILE *platform_fopen (const char *path, const char *mode);
131 131
 int platform_open (const char *path, int flags, int mode);
132 132
 
133
-#ifdef WIN32
133
+#ifdef _WIN32
134 134
 typedef struct _stat platform_stat_t;
135 135
 #else
136 136
 typedef struct stat platform_stat_t;
... ...
@@ -175,7 +175,7 @@ plugin_option_list_print (const struct plugin_option_list *list, int msglevel)
175 175
 }
176 176
 #endif
177 177
 
178
-#ifndef WIN32
178
+#ifndef _WIN32
179 179
 
180 180
 static void
181 181
 libdl_resolve_symbol (void *handle, void **dest, const char *symbol, const char *plugin_name, const unsigned int flags)
... ...
@@ -206,7 +206,7 @@ plugin_init_item (struct plugin *p, const struct plugin_option *o)
206 206
   p->so_pathname = o->so_pathname;
207 207
   p->plugin_type_mask = plugin_supported_types ();
208 208
 
209
-#ifndef WIN32
209
+#ifndef _WIN32
210 210
 
211 211
   p->handle = NULL;
212 212
 #if defined(PLUGIN_LIBDIR)
... ...
@@ -519,10 +519,10 @@ plugin_close_item (struct plugin *p)
519 519
       if (p->plugin_handle)
520 520
 	(*p->close)(p->plugin_handle);
521 521
 
522
-#ifndef WIN32
522
+#ifndef _WIN32
523 523
       if (dlclose (p->handle))
524 524
 	msg (M_WARN, "PLUGIN_CLOSE: dlclose() failed on plugin: %s", p->so_pathname);
525
-#elif defined(WIN32)
525
+#elif defined(_WIN32)
526 526
       if (!FreeLibrary (p->module))
527 527
 	msg (M_WARN, "PLUGIN_CLOSE: FreeLibrary() failed on plugin: %s", p->so_pathname);
528 528
 #endif
... ...
@@ -59,7 +59,7 @@ struct plugin {
59 59
   unsigned int plugin_type_mask;
60 60
   int requested_initialization_point;
61 61
 
62
-#ifndef WIN32
62
+#ifndef _WIN32
63 63
   void *handle;
64 64
 #else
65 65
   HMODULE module;
... ...
@@ -49,7 +49,7 @@
49 49
 #include <linux/rtnetlink.h>		/* RTM_GETROUTE etc. */
50 50
 #endif
51 51
 
52
-#ifdef WIN32
52
+#ifdef _WIN32
53 53
 #include "openvpn-msg.h"
54 54
 
55 55
 #define METRIC_NOT_USED ((DWORD)-1)
... ...
@@ -807,7 +807,7 @@ init_route_ipv6_list (struct route_ipv6_list *rl6,
807 807
 	  if ( !(rl6->rgi6.flags & RGI_ON_LINK) )
808 808
 	    { r6->gateway = rl6->rgi6.gateway.addr_ipv6; }
809 809
 	  r6->metric = 1;
810
-#ifdef WIN32
810
+#ifdef _WIN32
811 811
 	  r6->adapter_index = rl6->rgi6.adapter_index;
812 812
 #else
813 813
 	  r6->iface = rl6->rgi6.iface;
... ...
@@ -1214,7 +1214,7 @@ print_default_gateway(const int msglevel,
1214 1214
 	buf_printf (&out, " %s", print_in_addr_t (rgi->gateway.addr, 0, &gc));
1215 1215
       if (rgi->flags & RGI_NETMASK_DEFINED)
1216 1216
 	buf_printf (&out, "/%s", print_in_addr_t (rgi->gateway.netmask, 0, &gc));
1217
-#ifdef WIN32
1217
+#ifdef _WIN32
1218 1218
       if (rgi->flags & RGI_IFACE_DEFINED)
1219 1219
 	buf_printf (&out, " I=%u", (unsigned int)rgi->adapter_index);
1220 1220
 #else
... ...
@@ -1235,7 +1235,7 @@ print_default_gateway(const int msglevel,
1235 1235
 	buf_printf (&out, " ON_LINK");
1236 1236
       if (rgi6->flags & RGI_NETMASK_DEFINED)
1237 1237
 	buf_printf (&out, "/%d", rgi6->gateway.netbits_ipv6);
1238
-#ifdef WIN32
1238
+#ifdef _WIN32
1239 1239
       if (rgi6->flags & RGI_IFACE_DEFINED)
1240 1240
 	buf_printf (&out, " I=%u", (unsigned int)rgi6->adapter_index);
1241 1241
 #else
... ...
@@ -1454,7 +1454,7 @@ add_route (struct route_ipv4 *r,
1454 1454
     buf_printf (&out, "%s %s %s", network, netmask, gateway);
1455 1455
   management_android_control (management, "ROUTE", buf_bptr(&out));
1456 1456
 
1457
-#elif defined (WIN32)
1457
+#elif defined (_WIN32)
1458 1458
   {
1459 1459
     DWORD ai = TUN_ADAPTER_INDEX_INVALID;
1460 1460
     argv_printf (&argv, "%s%sc ADD %s MASK %s %s",
... ...
@@ -1682,7 +1682,7 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int fla
1682 1682
   if (! (r6->flags & RT_DEFINED) )
1683 1683
     return;
1684 1684
 
1685
-#ifndef WIN32
1685
+#ifndef _WIN32
1686 1686
   if ( r6->iface != NULL )		/* vpn server special route */
1687 1687
     {
1688 1688
       device = r6->iface;
... ...
@@ -1777,7 +1777,7 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int fla
1777 1777
 
1778 1778
     management_android_control (management, "ROUTE6", buf_bptr(&out));
1779 1779
 
1780
-#elif defined (WIN32)
1780
+#elif defined (_WIN32)
1781 1781
 
1782 1782
   if (tt->options.msg_channel)
1783 1783
     status = add_route_ipv6_service (r6, tt);
... ...
@@ -1967,7 +1967,7 @@ delete_route (struct route_ipv4 *r,
1967 1967
   argv_msg (D_ROUTE, &argv);
1968 1968
   openvpn_execve_check (&argv, es, 0, "ERROR: Linux route delete command failed");
1969 1969
 
1970
-#elif defined (WIN32)
1970
+#elif defined (_WIN32)
1971 1971
   
1972 1972
   argv_printf (&argv, "%s%sc DELETE %s MASK %s %s",
1973 1973
 	       get_win_sys_path(),
... ...
@@ -2114,7 +2114,7 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigne
2114 2114
   if ((r6->flags & (RT_DEFINED|RT_ADDED)) != (RT_DEFINED|RT_ADDED))
2115 2115
     return;
2116 2116
 
2117
-#ifndef WIN32
2117
+#ifndef _WIN32
2118 2118
   if ( r6->iface != NULL )		/* vpn server special route */
2119 2119
     {
2120 2120
       device = r6->iface;
... ...
@@ -2180,7 +2180,7 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigne
2180 2180
   argv_msg (D_ROUTE, &argv);
2181 2181
   openvpn_execve_check (&argv, es, 0, "ERROR: Linux route -6/-A inet6 del command failed");
2182 2182
 
2183
-#elif defined (WIN32)
2183
+#elif defined (_WIN32)
2184 2184
 
2185 2185
   if (tt->options.msg_channel)
2186 2186
     del_route_ipv6_service (r6, tt);
... ...
@@ -2316,7 +2316,7 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigne
2316 2316
  * to get the current default gateway.
2317 2317
  */
2318 2318
 
2319
-#if defined(WIN32)
2319
+#if defined(_WIN32)
2320 2320
 
2321 2321
 static const MIB_IPFORWARDTABLE *
2322 2322
 get_windows_routing_table (struct gc_arena *gc)
... ...
@@ -3694,7 +3694,7 @@ int netmask_to_netbits2 (in_addr_t netmask)
3694 3694
  * so that outgoing packets to these servers don't end up in the tunnel.
3695 3695
  */
3696 3696
 
3697
-#if defined(WIN32)
3697
+#if defined(_WIN32)
3698 3698
 
3699 3699
 static void
3700 3700
 add_host_route_if_nonlocal (struct route_bypass *rb, const in_addr_t addr)
... ...
@@ -3768,7 +3768,7 @@ get_bypass_addresses (struct route_bypass *rb, const unsigned int flags)  /* PLA
3768 3768
  * Used by redirect-gateway autolocal feature
3769 3769
  */
3770 3770
 
3771
-#if defined(WIN32)
3771
+#if defined(_WIN32)
3772 3772
 
3773 3773
 int
3774 3774
 test_local_addr (const in_addr_t addr, const struct route_gateway_info *rgi)
... ...
@@ -33,7 +33,7 @@
33 33
 #include "tun.h"
34 34
 #include "misc.h"
35 35
 
36
-#ifdef WIN32
36
+#ifdef _WIN32
37 37
 /*
38 38
  * Windows route methods
39 39
  */
... ...
@@ -130,7 +130,7 @@ struct route_ipv6 {
130 130
   struct in6_addr gateway;
131 131
   int metric;
132 132
   /* gateway interface */
133
-# ifdef WIN32
133
+# ifdef _WIN32
134 134
   DWORD adapter_index;		/* interface or ~0 if undefined */
135 135
 #else
136 136
   char * iface;			/* interface name (null terminated) */
... ...
@@ -153,7 +153,7 @@ struct route_gateway_info {
153 153
   unsigned int flags;
154 154
 
155 155
   /* gateway interface */
156
-# ifdef WIN32
156
+# ifdef _WIN32
157 157
   DWORD adapter_index;  /* interface or ~0 if undefined */
158 158
 #else
159 159
   char iface[16]; /* interface name (null terminated), may be empty */
... ...
@@ -181,7 +181,7 @@ struct route_ipv6_gateway_info {
181 181
   unsigned int flags;
182 182
 
183 183
   /* gateway interface */
184
-# ifdef WIN32
184
+# ifdef _WIN32
185 185
   DWORD adapter_index;  /* interface or ~0 if undefined */
186 186
 #else
187 187
   char iface[16]; /* interface name (null terminated), may be empty */
... ...
@@ -333,7 +333,7 @@ void print_route_options (const struct route_option_list *rol,
333 333
 
334 334
 void print_routes (const struct route_list *rl, int level);
335 335
 
336
-#ifdef WIN32
336
+#ifdef _WIN32
337 337
 
338 338
 void show_routes (int msglev);
339 339
 bool test_routes (const struct route_list *rl, const struct tuntap *tt);
... ...
@@ -221,7 +221,7 @@ static int signal_mode; /* GLOBAL */
221 221
 void
222 222
 pre_init_signal_catch (void)
223 223
 {
224
-#ifndef WIN32
224
+#ifndef _WIN32
225 225
 #ifdef HAVE_SIGNAL_H
226 226
   signal_mode = SM_PRE_INIT;
227 227
   signal (SIGINT, signal_handler);
... ...
@@ -231,13 +231,13 @@ pre_init_signal_catch (void)
231 231
   signal (SIGUSR2, SIG_IGN);
232 232
   signal (SIGPIPE, SIG_IGN);
233 233
 #endif /* HAVE_SIGNAL_H */
234
-#endif /* WIN32 */
234
+#endif /* _WIN32 */
235 235
 }
236 236
 
237 237
 void
238 238
 post_init_signal_catch (void)
239 239
 {
240
-#ifndef WIN32
240
+#ifndef _WIN32
241 241
 #ifdef HAVE_SIGNAL_H
242 242
   signal_mode = SM_POST_INIT;
243 243
   signal (SIGINT, signal_handler);
... ...
@@ -291,7 +291,7 @@ print_status (const struct context *c, struct status_output *so)
291 291
   status_printf (so, "Pre-encrypt truncations," counter_format, c->c2.n_trunc_pre_encrypt);
292 292
   status_printf (so, "Post-decrypt truncations," counter_format, c->c2.n_trunc_post_decrypt);
293 293
 #endif
294
-#ifdef WIN32
294
+#ifdef _WIN32
295 295
   if (tuntap_defined (c->c1.tuntap))
296 296
     status_printf (so, "TAP-WIN32 driver status,\"%s\"",
297 297
 	 tap_win_getinfo (c->c1.tuntap, &gc));
... ...
@@ -79,7 +79,7 @@ void register_signal (struct context *c, int sig, const char *text);
79 79
 void process_explicit_exit_notification_timer_wakeup (struct context *c);
80 80
 #endif
81 81
 
82
-#ifdef WIN32
82
+#ifdef _WIN32
83 83
 
84 84
 static inline void
85 85
 get_signal (volatile int *sig)
... ...
@@ -376,7 +376,7 @@ openvpn_getaddrinfo (unsigned int flags,
376 376
        */
377 377
       while (true)
378 378
         {
379
-#ifndef WIN32
379
+#ifndef _WIN32
380 380
 	  res_init ();
381 381
 #endif
382 382
           /* try hostname lookup */
... ...
@@ -690,7 +690,7 @@ socket_set_buffers (int fd, const struct socket_buffer_size *sbs)
690 690
 static bool
691 691
 socket_set_tcp_nodelay (int sd, int state)
692 692
 {
693
-#if defined(WIN32) || (defined(HAVE_SETSOCKOPT) && defined(IPPROTO_TCP) && defined(TCP_NODELAY))
693
+#if defined(_WIN32) || (defined(HAVE_SETSOCKOPT) && defined(IPPROTO_TCP) && defined(TCP_NODELAY))
694 694
   if (setsockopt (sd, IPPROTO_TCP, TCP_NODELAY, (void *) &state, sizeof (state)) != 0)
695 695
     {
696 696
       msg (M_WARN, "NOTE: setsockopt TCP_NODELAY=%d failed", state);
... ...
@@ -761,7 +761,7 @@ create_socket_tcp (struct addrinfo* addrinfo)
761 761
   if ((sd = socket (addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol)) < 0)
762 762
     msg (M_ERR, "Cannot create TCP socket");
763 763
 
764
-#ifndef WIN32 /* using SO_REUSEADDR on Windows will cause bind to succeed on port conflicts! */
764
+#ifndef _WIN32 /* using SO_REUSEADDR on Windows will cause bind to succeed on port conflicts! */
765 765
   /* set SO_REUSEADDR on socket */
766 766
   {
767 767
     int on = 1;
... ...
@@ -1066,7 +1066,7 @@ socket_listen_accept (socket_descriptor_t sd,
1066 1066
 /* older mingw versions and WinXP do not have this define,
1067 1067
  * but Vista and up support the functionality - just define it here
1068 1068
  */
1069
-#ifdef WIN32
1069
+#ifdef _WIN32
1070 1070
 # ifndef IPV6_V6ONLY
1071 1071
 #  define IPV6_V6ONLY 27
1072 1072
 # endif
... ...
@@ -1141,7 +1141,7 @@ openvpn_connect (socket_descriptor_t sd,
1141 1141
   if (status)
1142 1142
     status = openvpn_errno ();
1143 1143
   if (
1144
-#ifdef WIN32
1144
+#ifdef _WIN32
1145 1145
     status == WSAEWOULDBLOCK
1146 1146
 #else
1147 1147
     status == EINPROGRESS
... ...
@@ -1184,7 +1184,7 @@ openvpn_connect (socket_descriptor_t sd,
1184 1184
 	    {
1185 1185
 	      if (--connect_timeout < 0)
1186 1186
 		{
1187
-#ifdef WIN32
1187
+#ifdef _WIN32
1188 1188
 		  status = WSAETIMEDOUT;
1189 1189
 #else
1190 1190
 		  status = ETIMEDOUT;
... ...
@@ -1296,7 +1296,7 @@ socket_connect (socket_descriptor_t* sd,
1296 1296
 static void
1297 1297
 socket_frame_init (const struct frame *frame, struct link_socket *sock)
1298 1298
 {
1299
-#ifdef WIN32
1299
+#ifdef _WIN32
1300 1300
   overlapped_io_init (&sock->reads, frame, FALSE, false);
1301 1301
   overlapped_io_init (&sock->writes, frame, TRUE, false);
1302 1302
   sock->rw_handle.read = sock->reads.overlapped.hEvent;
... ...
@@ -1305,7 +1305,7 @@ socket_frame_init (const struct frame *frame, struct link_socket *sock)
1305 1305
 
1306 1306
   if (link_socket_connection_oriented (sock))
1307 1307
     {
1308
-#ifdef WIN32
1308
+#ifdef _WIN32
1309 1309
       stream_buf_init (&sock->stream_buf,
1310 1310
 		       &sock->reads.buf_init,
1311 1311
 		       sock->sockflags,
... ...
@@ -1971,7 +1971,7 @@ link_socket_close (struct link_socket *sock)
1971 1971
 
1972 1972
       if (socket_defined (sock->sd))
1973 1973
 	{
1974
-#ifdef WIN32
1974
+#ifdef _WIN32
1975 1975
 	  close_net_event_win32 (&sock->listen_handle, sock->sd, 0);
1976 1976
 #endif
1977 1977
 	  if (!gremlin)
... ...
@@ -1981,7 +1981,7 @@ link_socket_close (struct link_socket *sock)
1981 1981
 		msg (M_WARN | M_ERRNO, "TCP/UDP: Close Socket failed");
1982 1982
 	    }
1983 1983
 	  sock->sd = SOCKET_UNDEFINED;
1984
-#ifdef WIN32
1984
+#ifdef _WIN32
1985 1985
 	  if (!gremlin)
1986 1986
 	    {
1987 1987
 	      overlapped_io_close (&sock->reads);
... ...
@@ -2176,7 +2176,7 @@ socket_stat (const struct link_socket *s, unsigned int rwflags, struct gc_arena
2176 2176
 	{
2177 2177
 	  buf_printf (&out, "S%s",
2178 2178
 		      (s->rwflags_debug & EVENT_READ) ? "R" : "r");
2179
-#ifdef WIN32
2179
+#ifdef _WIN32
2180 2180
 	  buf_printf (&out, "%s",
2181 2181
 		      overlapped_io_state_ascii (&s->reads));
2182 2182
 #endif
... ...
@@ -2185,7 +2185,7 @@ socket_stat (const struct link_socket *s, unsigned int rwflags, struct gc_arena
2185 2185
 	{
2186 2186
 	  buf_printf (&out, "S%s",
2187 2187
 		      (s->rwflags_debug & EVENT_WRITE) ? "W" : "w");
2188
-#ifdef WIN32
2188
+#ifdef _WIN32
2189 2189
 	  buf_printf (&out, "%s",
2190 2190
 		      overlapped_io_state_ascii (&s->writes));
2191 2191
 #endif
... ...
@@ -2360,7 +2360,7 @@ stream_buf_close (struct stream_buf* sb)
2360 2360
 event_t
2361 2361
 socket_listen_event_handle (struct link_socket *s)
2362 2362
 {
2363
-#ifdef WIN32
2363
+#ifdef _WIN32
2364 2364
   if (!defined_net_event_win32 (&s->listen_handle))
2365 2365
     init_net_event_win32 (&s->listen_handle, FD_ACCEPT, s->sd, 0);
2366 2366
   return &s->listen_handle;
... ...
@@ -2837,7 +2837,7 @@ link_socket_read_tcp (struct link_socket *sock,
2837 2837
 
2838 2838
   if (!sock->stream_buf.residual_fully_formed)
2839 2839
     {
2840
-#ifdef WIN32
2840
+#ifdef _WIN32
2841 2841
       len = socket_finalize (sock->sd, &sock->reads, buf, NULL);
2842 2842
 #else
2843 2843
       struct buffer frag;
... ...
@@ -2862,7 +2862,7 @@ link_socket_read_tcp (struct link_socket *sock,
2862 2862
     return buf->len = 0; /* no error, but packet is still incomplete */
2863 2863
 }
2864 2864
 
2865
-#ifndef WIN32
2865
+#ifndef _WIN32
2866 2866
 
2867 2867
 #if ENABLE_IP_PKTINFO
2868 2868
 
... ...
@@ -2983,7 +2983,7 @@ link_socket_write_tcp (struct link_socket *sock,
2983 2983
   ASSERT (len <= sock->stream_buf.maxlen);
2984 2984
   len = htonps (len);
2985 2985
   ASSERT (buf_write_prepend (buf, &len, sizeof (len)));
2986
-#ifdef WIN32
2986
+#ifdef _WIN32
2987 2987
   return link_socket_write_win32 (sock, buf, to);
2988 2988
 #else
2989 2989
   return link_socket_write_tcp_posix (sock, buf, to);  
... ...
@@ -3071,7 +3071,7 @@ link_socket_write_udp_posix_sendmsg (struct link_socket *sock,
3071 3071
  * Win32 overlapped socket I/O functions.
3072 3072
  */
3073 3073
 
3074
-#ifdef WIN32
3074
+#ifdef _WIN32
3075 3075
 
3076 3076
 int
3077 3077
 socket_recv_queue (struct link_socket *sock, int maxsize)
... ...
@@ -3379,7 +3379,7 @@ socket_finalize (SOCKET s,
3379 3379
 	    case sizeof(struct sockaddr_in):
3380 3380
 	    case sizeof(struct sockaddr_in6):
3381 3381
 	    /* TODO(jjo): for some reason (?) I'm getting 24,28 for AF_INET6
3382
-	     * under WIN32*/
3382
+	     * under _WIN32*/
3383 3383
 	    case sizeof(struct sockaddr_in6)-4:
3384 3384
 	      break;
3385 3385
 	    default:
... ...
@@ -3405,7 +3405,7 @@ socket_finalize (SOCKET s,
3405 3405
   return ret;
3406 3406
 }
3407 3407
 
3408
-#endif /* WIN32 */
3408
+#endif /* _WIN32 */
3409 3409
 
3410 3410
 /*
3411 3411
  * Socket event notification
... ...
@@ -3426,7 +3426,7 @@ socket_set (struct link_socket *s,
3426 3426
 	  rwflags &= ~EVENT_READ;
3427 3427
 	}
3428 3428
       
3429
-#ifdef WIN32
3429
+#ifdef _WIN32
3430 3430
       if (rwflags & EVENT_READ)
3431 3431
 	socket_recv_queue (s, 0);
3432 3432
 #endif
... ...
@@ -169,7 +169,7 @@ struct link_socket
169 169
   socket_descriptor_t sd;
170 170
   socket_descriptor_t ctrl_sd;  /* only used for UDP over Socks */
171 171
 
172
-#ifdef WIN32
172
+#ifdef _WIN32
173 173
   struct overlapped_io reads;
174 174
   struct overlapped_io writes;
175 175
   struct rw_handle rw_handle;
... ...
@@ -257,7 +257,7 @@ struct link_socket
257 257
 #define MSG_NOSIGNAL 0
258 258
 #endif
259 259
 
260
-#ifdef WIN32
260
+#ifdef _WIN32
261 261
 
262 262
 #define openvpn_close_socket(s) closesocket(s)
263 263
 
... ...
@@ -842,7 +842,7 @@ socket_connection_reset (const struct link_socket *sock, int status)
842 842
       else if (status < 0)
843 843
 	{
844 844
 	  const int err = openvpn_errno ();
845
-#ifdef WIN32
845
+#ifdef _WIN32
846 846
 	  return err == WSAECONNRESET || err == WSAECONNABORTED;
847 847
 #else
848 848
 	  return err == ECONNRESET;
... ...
@@ -950,7 +950,7 @@ stream_buf_read_setup (struct link_socket* sock)
950 950
 int link_socket_read_tcp (struct link_socket *sock,
951 951
 			  struct buffer *buf);
952 952
 
953
-#ifdef WIN32
953
+#ifdef _WIN32
954 954
 
955 955
 static inline int
956 956
 link_socket_read_udp_win32 (struct link_socket *sock,
... ...
@@ -978,7 +978,7 @@ link_socket_read (struct link_socket *sock,
978 978
     {
979 979
       int res;
980 980
 
981
-#ifdef WIN32
981
+#ifdef _WIN32
982 982
       res = link_socket_read_udp_win32 (sock, buf, from);
983 983
 #else
984 984
       res = link_socket_read_udp_posix (sock, buf, from);
... ...
@@ -1006,7 +1006,7 @@ int link_socket_write_tcp (struct link_socket *sock,
1006 1006
 			   struct buffer *buf,
1007 1007
 			   struct link_socket_actual *to);
1008 1008
 
1009
-#ifdef WIN32
1009
+#ifdef _WIN32
1010 1010
 
1011 1011
 static inline int
1012 1012
 link_socket_write_win32 (struct link_socket *sock,
... ...
@@ -1068,7 +1068,7 @@ link_socket_write_udp (struct link_socket *sock,
1068 1068
 		       struct buffer *buf,
1069 1069
 		       struct link_socket_actual *to)
1070 1070
 {
1071
-#ifdef WIN32
1071
+#ifdef _WIN32
1072 1072
   return link_socket_write_win32 (sock, buf, to);
1073 1073
 #else
1074 1074
   return link_socket_write_udp_posix (sock, buf, to);
... ...
@@ -1138,7 +1138,7 @@ socket_read_residual (const struct link_socket *s)
1138 1138
 static inline event_t
1139 1139
 socket_event_handle (const struct link_socket *s)
1140 1140
 {
1141
-#ifdef WIN32
1141
+#ifdef _WIN32
1142 1142
   return &s->rw_handle;
1143 1143
 #else
1144 1144
   return s->sd;
... ...
@@ -1169,7 +1169,7 @@ socket_set_listen_persistent (struct link_socket *s,
1169 1169
 static inline void
1170 1170
 socket_reset_listen_persistent (struct link_socket *s)
1171 1171
 {
1172
-#ifdef WIN32
1172
+#ifdef _WIN32
1173 1173
   reset_net_event_win32 (&s->listen_handle, s->sd);
1174 1174
 #endif
1175 1175
 }
... ...
@@ -1978,7 +1978,7 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
1978 1978
       buf_printf (&out, "IV_PLAT=freebsd\n");
1979 1979
 #elif defined(TARGET_ANDROID)
1980 1980
       buf_printf (&out, "IV_PLAT=android\n");
1981
-#elif defined(WIN32)
1981
+#elif defined(_WIN32)
1982 1982
       buf_printf (&out, "IV_PLAT=win\n");
1983 1983
 #endif
1984 1984
 
... ...
@@ -2008,7 +2008,7 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
2008 2008
 	  if (rgi.flags & RGI_HWADDR_DEFINED)
2009 2009
 	    buf_printf (&out, "IV_HWADDR=%s\n", format_hex_ex (rgi.hwaddr, 6, 0, 1, ":", &gc));
2010 2010
 	  buf_printf (&out, "IV_SSL=%s\n", get_ssl_library_version() );
2011
-#if defined(WIN32)
2011
+#if defined(_WIN32)
2012 2012
 	  buf_printf (&out, "IV_PLAT_VER=%s\n", win32_version_string (&gc, false));
2013 2013
 #endif
2014 2014
         }
... ...
@@ -232,7 +232,7 @@ int tls_ctx_load_pkcs12(struct tls_root_ctx *ctx, const char *pkcs12_file,
232 232
  */
233 233
 #ifdef ENABLE_CRYPTOAPI
234 234
 void tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert);
235
-#endif /* WIN32 */
235
+#endif /* _WIN32 */
236 236
 
237 237
 /**
238 238
  * Load certificate file into the given TLS context. If the given certificate
... ...
@@ -283,7 +283,7 @@ tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert)
283 283
 {
284 284
   msg(M_FATAL, "Windows CryptoAPI not yet supported for mbed TLS.");
285 285
 }
286
-#endif /* WIN32 */
286
+#endif /* _WIN32 */
287 287
 
288 288
 void
289 289
 tls_ctx_load_cert_file (struct tls_root_ctx *ctx, const char *cert_file,
... ...
@@ -632,7 +632,7 @@ tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert)
632 632
   if (!SSL_CTX_use_CryptoAPI_certificate (ctx->ctx, cryptoapi_cert))
633 633
     crypto_msg (M_FATAL, "Cannot load certificate \"%s\" from Microsoft Certificate Store", cryptoapi_cert);
634 634
 }
635
-#endif /* WIN32 */
635
+#endif /* ENABLE_CRYPTOAPI */
636 636
 
637 637
 static void
638 638
 tls_ctx_add_extra_certs (struct tls_root_ctx *ctx, BIO *bio)
... ...
@@ -37,7 +37,7 @@
37 37
 # define unlikely(x)    (x)
38 38
 #endif
39 39
 
40
-#ifdef WIN32
40
+#ifdef _WIN32
41 41
 #include <windows.h>
42 42
 #include <winsock2.h>
43 43
 #define sleep(x) Sleep((x)*1000)
... ...
@@ -64,7 +64,7 @@
64 64
 # include <sys/wait.h>
65 65
 #endif
66 66
 
67
-#ifndef WIN32
67
+#ifndef _WIN32
68 68
 #ifndef WEXITSTATUS
69 69
 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
70 70
 #endif
... ...
@@ -358,7 +358,7 @@
358 358
 
359 359
 #endif /* TARGET_DARWIN */
360 360
 
361
-#ifdef WIN32
361
+#ifdef _WIN32
362 362
  // Missing declarations for MinGW 32.
363 363
  // #if !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 2
364 364
  typedef int MIB_TCP_STATE;
... ...
@@ -405,7 +405,7 @@
405 405
 /*
406 406
  * Do we have nanoseconds gettimeofday?
407 407
  */
408
-#if defined(HAVE_GETTIMEOFDAY) || defined(WIN32)
408
+#if defined(HAVE_GETTIMEOFDAY) || defined(_WIN32)
409 409
 #define HAVE_GETTIMEOFDAY_NANOSECONDS 1
410 410
 #endif
411 411
 
... ...
@@ -470,26 +470,16 @@ typedef unsigned short sa_family_t;
470 470
 /*
471 471
  * Directory separation char
472 472
  */
473
-#ifdef WIN32
473
+#ifdef _WIN32
474 474
 #define OS_SPECIFIC_DIRSEP '\\'
475 475
 #else
476 476
 #define OS_SPECIFIC_DIRSEP '/'
477 477
 #endif
478 478
 
479 479
 /*
480
- * Define a boolean value based
481
- * on Win32 status.
482
- */
483
-#ifdef WIN32
484
-#define WIN32_0_1 1
485
-#else
486
-#define WIN32_0_1 0
487
-#endif
488
-
489
-/*
490 480
  * Our socket descriptor type.
491 481
  */
492
-#ifdef WIN32
482
+#ifdef _WIN32
493 483
 #define SOCKET_UNDEFINED (INVALID_SOCKET)
494 484
 typedef SOCKET socket_descriptor_t;
495 485
 #else
... ...
@@ -590,7 +580,7 @@ socket_defined (const socket_descriptor_t sd)
590 590
 /*
591 591
  * Do we support Unix domain sockets?
592 592
  */
593
-#if defined(PF_UNIX) && !defined(WIN32)
593
+#if defined(PF_UNIX) && !defined(_WIN32)
594 594
 #define UNIX_SOCK_SUPPORT 1
595 595
 #else
596 596
 #define UNIX_SOCK_SUPPORT 0
... ...
@@ -624,7 +614,7 @@ socket_defined (const socket_descriptor_t sd)
624 624
 /*
625 625
  * Do we have CryptoAPI capability?
626 626
  */
627
-#if defined(WIN32) && defined(ENABLE_CRYPTO) && defined(ENABLE_CRYPTO_OPENSSL)
627
+#if defined(_WIN32) && defined(ENABLE_CRYPTO) && defined(ENABLE_CRYPTO_OPENSSL)
628 628
 #define ENABLE_CRYPTOAPI
629 629
 #endif
630 630
 
... ...
@@ -49,13 +49,13 @@
49 49
 
50 50
 #include "memdbg.h"
51 51
 
52
-#ifdef WIN32
52
+#ifdef _WIN32
53 53
 #include "openvpn-msg.h"
54 54
 #endif
55 55
 
56 56
 #include <string.h>
57 57
 
58
-#ifdef WIN32
58
+#ifdef _WIN32
59 59
 
60 60
 /* #define SIMULATE_DHCP_FAILED */       /* simulate bad DHCP negotiation */
61 61
 
... ...
@@ -198,7 +198,7 @@ guess_tuntap_dev (const char *dev,
198 198
 		  const char *dev_node,
199 199
 		  struct gc_arena *gc)
200 200
 {
201
-#ifdef WIN32
201
+#ifdef _WIN32
202 202
   const int dt = dev_type_enum (dev, dev_type);
203 203
   if (dt == DEV_TYPE_TUN || dt == DEV_TYPE_TAP)
204 204
     {
... ...
@@ -421,7 +421,7 @@ tun_stat (const struct tuntap *tt, unsigned int rwflags, struct gc_arena *gc)
421 421
 	{
422 422
 	  buf_printf (&out, "T%s",
423 423
 		      (tt->rwflags_debug & EVENT_READ) ? "R" : "r");
424
-#ifdef WIN32
424
+#ifdef _WIN32
425 425
 	  buf_printf (&out, "%s",
426 426
 		      overlapped_io_state_ascii (&tt->reads));
427 427
 #endif
... ...
@@ -430,7 +430,7 @@ tun_stat (const struct tuntap *tt, unsigned int rwflags, struct gc_arena *gc)
430 430
 	{
431 431
 	  buf_printf (&out, "T%s",
432 432
 		      (tt->rwflags_debug & EVENT_WRITE) ? "W" : "w");
433
-#ifdef WIN32
433
+#ifdef _WIN32
434 434
 	  buf_printf (&out, "%s",
435 435
 		      overlapped_io_state_ascii (&tt->writes));
436 436
 #endif
... ...
@@ -611,7 +611,7 @@ init_tun (const char *dev,       /* --dev option */
611 611
 	  tt->broadcast = generate_ifconfig_broadcast_addr (tt->local, tt->remote_netmask);
612 612
 	}
613 613
 
614
-#ifdef WIN32
614
+#ifdef _WIN32
615 615
       /*
616 616
        * Make sure that both ifconfig addresses are part of the
617 617
        * same .252 subnet.
... ...
@@ -665,7 +665,7 @@ init_tun_post (struct tuntap *tt,
665 665
 	       const struct tuntap_options *options)
666 666
 {
667 667
   tt->options = *options;
668
-#ifdef WIN32
668
+#ifdef _WIN32
669 669
   overlapped_io_init (&tt->reads, frame, FALSE, true);
670 670
   overlapped_io_init (&tt->writes, frame, TRUE, true);
671 671
   tt->rw_handle.read = tt->reads.overlapped.hEvent;
... ...
@@ -674,7 +674,7 @@ init_tun_post (struct tuntap *tt,
674 674
 #endif
675 675
 }
676 676
 
677
-#if defined(WIN32) || \
677
+#if defined(_WIN32) || \
678 678
     defined(TARGET_DARWIN) || defined(TARGET_NETBSD) || defined(TARGET_OPENBSD)
679 679
 
680 680
 /* some of the platforms will auto-add a "network route" pointing
... ...
@@ -1346,7 +1346,7 @@ do_ifconfig (struct tuntap *tt,
1346 1346
 	  }
1347 1347
 	env_set_destroy (aix_es);
1348 1348
       }
1349
-#elif defined (WIN32)
1349
+#elif defined (_WIN32)
1350 1350
       {
1351 1351
         ASSERT (actual != NULL);
1352 1352
 
... ...
@@ -1405,7 +1405,7 @@ static void
1405 1405
 clear_tuntap (struct tuntap *tuntap)
1406 1406
 {
1407 1407
   CLEAR (*tuntap);
1408
-#ifdef WIN32
1408
+#ifdef _WIN32
1409 1409
   tuntap->hand = NULL;
1410 1410
 #else
1411 1411
   tuntap->fd = -1;
... ...
@@ -1502,7 +1502,7 @@ read_tun_header (struct tuntap* tt, uint8_t *buf, int len)
1502 1502
 #endif
1503 1503
 
1504 1504
 
1505
-#ifndef WIN32
1505
+#ifndef _WIN32
1506 1506
 static void
1507 1507
 open_tun_generic (const char *dev, const char *dev_type, const char *dev_node,
1508 1508
 		  bool dynamic, struct tuntap *tt)
... ...
@@ -3012,7 +3012,7 @@ read_tun (struct tuntap* tt, uint8_t *buf, int len)
3012 3012
     return read (tt->fd, buf, len);
3013 3013
 }
3014 3014
 
3015
-#elif defined(WIN32)
3015
+#elif defined(_WIN32)
3016 3016
 
3017 3017
 int
3018 3018
 tun_read_queue (struct tuntap *tt, int maxsize)
... ...
@@ -25,7 +25,7 @@
25 25
 #ifndef TUN_H
26 26
 #define TUN_H
27 27
 
28
-#ifdef WIN32
28
+#ifdef _WIN32
29 29
 #include <winioctl.h>
30 30
 #include <tap-windows.h>
31 31
 #endif
... ...
@@ -38,7 +38,7 @@
38 38
 #include "proto.h"
39 39
 #include "misc.h"
40 40
 
41
-#if defined(WIN32) || defined(TARGET_ANDROID)
41
+#if defined(_WIN32) || defined(TARGET_ANDROID)
42 42
 
43 43
 #define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1)
44 44
 
... ...
@@ -58,7 +58,7 @@ struct tuntap_options {
58 58
 # define IPW32_SET_N            5
59 59
   int ip_win32_type;
60 60
 
61
-#ifdef WIN32
61
+#ifdef _WIN32
62 62
   HANDLE msg_channel;
63 63
 #endif
64 64
 
... ...
@@ -157,7 +157,7 @@ struct tuntap
157 157
   struct in6_addr remote_ipv6;
158 158
   int netbits_ipv6;
159 159
 
160
-#ifdef WIN32
160
+#ifdef _WIN32
161 161
   HANDLE hand;
162 162
   struct overlapped_io reads;
163 163
   struct overlapped_io writes;
... ...
@@ -197,7 +197,7 @@ struct tuntap
197 197
 static inline bool
198 198
 tuntap_defined (const struct tuntap *tt)
199 199
 {
200
-#ifdef WIN32
200
+#ifdef _WIN32
201 201
   return tt && tt->hand != NULL;
202 202
 #else
203 203
   return tt && tt->fd >= 0;
... ...
@@ -298,7 +298,7 @@ ifconfig_order(void)
298 298
   return IFCONFIG_AFTER_TUN_OPEN;
299 299
 #elif defined(TARGET_NETBSD)
300 300
   return IFCONFIG_AFTER_TUN_OPEN;
301
-#elif defined(WIN32)
301
+#elif defined(_WIN32)
302 302
   return IFCONFIG_AFTER_TUN_OPEN;
303 303
 #elif defined(TARGET_ANDROID)
304 304
   return IFCONFIG_BEFORE_TUN_OPEN;
... ...
@@ -322,7 +322,7 @@ route_order(void)
322 322
 }
323 323
 
324 324
 
325
-#ifdef WIN32
325
+#ifdef _WIN32
326 326
 
327 327
 #define TUN_PASS_BUFFER
328 328
 
... ...
@@ -476,7 +476,7 @@ tun_standby (struct tuntap *tt)
476 476
 static inline event_t
477 477
 tun_event_handle (const struct tuntap *tt)
478 478
 {
479
-#ifdef WIN32
479
+#ifdef _WIN32
480 480
   return &tt->rw_handle;
481 481
 #else
482 482
   return tt->fd;
... ...
@@ -499,7 +499,7 @@ tun_set (struct tuntap *tt,
499 499
 	  if (persistent)
500 500
 	    *persistent = rwflags;
501 501
 	}
502
-#ifdef WIN32
502
+#ifdef _WIN32
503 503
       if (rwflags & EVENT_READ)
504 504
 	tun_read_queue (tt, 0);
505 505
 #endif
... ...
@@ -35,7 +35,7 @@
35 35
 
36 36
 #include "syshead.h"
37 37
 
38
-#ifdef WIN32
38
+#ifdef _WIN32
39 39
 
40 40
 #include "buffer.h"
41 41
 #include "error.h"
... ...
@@ -22,7 +22,7 @@
22 22
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23 23
  */
24 24
 
25
-#ifdef WIN32
25
+#ifdef _WIN32
26 26
 #ifndef OPENVPN_WIN32_H
27 27
 #define OPENVPN_WIN32_H
28 28