From 3b7411a1ef7107b1db37657d2da3bda9730e3cf7 Mon Sep 17 00:00:00 2001
From: Steven McCoy <steven.mccoy@miru.hk>
Date: Wed, 15 Jun 2011 16:48:54 -0400
Subject: [PATCH] Update Windows header file usage.


Signed-off-by: Steven McCoy <steven.mccoy@miru.hk>
---
 src/ctx.cpp     |   12 +++--
 src/select.cpp  |    9 ++--
 src/windows.hpp |  127 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 127 insertions(+), 21 deletions(-)

diff --git a/src/ctx.cpp b/src/ctx.cpp
index 2758729..d80d8ee 100644
--- a/src/ctx.cpp
+++ b/src/ctx.cpp
@@ -18,21 +18,23 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "platform.hpp"
+#if defined ZMQ_HAVE_WINDOWS
+#include "windows.hpp"
+#endif
+
 #include <new>
 #include <string.h>
 
 #include "ctx.hpp"
 #include "socket_base.hpp"
 #include "io_thread.hpp"
-#include "platform.hpp"
 #include "reaper.hpp"
 #include "err.hpp"
 #include "pipe.hpp"
 
-#if defined ZMQ_HAVE_WINDOWS
-#include "windows.h"
-#else
-#include "unistd.h"
+#if !defined ZMQ_HAVE_WINDOWS
+#include <unistd.h>
 #endif
 
 zmq::ctx_t::ctx_t (uint32_t io_threads_) :
diff --git a/src/select.cpp b/src/select.cpp
index 56f9f74..78fb6f6 100644
--- a/src/select.cpp
+++ b/src/select.cpp
@@ -19,20 +19,21 @@
 */
 
 #include "platform.hpp"
+#if defined ZMQ_HAVE_WINDOWS
+#include "windows.hpp"
+#endif
 
 #include <string.h>
 #include <algorithm>
 
-#ifdef ZMQ_HAVE_WINDOWS
-#include "winsock2.h"
-#elif defined ZMQ_HAVE_HPUX
+#if defined ZMQ_HAVE_HPUX
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #elif defined ZMQ_HAVE_OPENVMS
 #include <sys/types.h>
 #include <sys/time.h>
-#else
+#elif !defined ZMQ_HAVE_WINDOWS
 #include <sys/select.h>
 #endif
 
diff --git a/src/windows.hpp b/src/windows.hpp
index 96cd514..8ee377e 100644
--- a/src/windows.hpp
+++ b/src/windows.hpp
@@ -24,33 +24,136 @@
 // The purpose of this header file is to turn on only the items actually needed
 // on the windows platform.
 
-#define _WINSOCKAPI_
-#ifndef NOMINMAX
-#define NOMINMAX // No min and max functions, these clash with C++.
-#endif
 #define _CRT_SECURE_NO_WARNINGS
 
 #ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN
 #endif
-#ifndef NOUSER  //  No USER defines and routines.
-#define NOUSER
+#ifndef NOGDICAPMASKS
+#define NOGDICAPMASKS // CC_*, LC_*, PC_*, CP_*, TC_*, RC_
+#endif
+#ifndef NOVIRTUALKEYCODES
+#define NOVIRTUALKEYCODES // VK_*
+#endif
+#ifndef NOWINMESSAGES
+#define NOWINMESSAGES     // WM_*, EM_*, LB_*, CB_*
+#endif
+#ifndef NOWINSTYLES
+#define NOWINSTYLES       // WS_*, CS_*, ES_*, LBS_*, SBS_*, CBS_*
+#endif
+#ifndef NOSYSMETRICS
+#define NOSYSMETRICS      // SM_*
+#endif
+#ifndef NOMENUS
+#define NOMENUS           // MF_*
+#endif
+#ifndef NOICONS
+#define NOICONS           // IDI_*
+#endif
+#ifndef NOKEYSTATES
+#define NOKEYSTATES       // MK_*
+#endif
+#ifndef NOSYSCOMMANDS
+#define NOSYSCOMMANDS     // SC_*
+#endif
+#ifndef NORASTEROPS
+#define NORASTEROPS       // Binary and Tertiary raster ops
+#endif
+#ifndef NOSHOWWINDOW
+#define NOSHOWWINDOW      // SW_*
+#endif
+#ifndef OEMRESOURCE
+#define OEMRESOURCE       // OEM Resource values
+#endif
+#ifndef NOATOM
+#define NOATOM            // Atom Manager routines
+#endif
+#ifndef NOCLIPBOARD
+#define NOCLIPBOARD       // Clipboard routines
+#endif
+#ifndef NOCOLOR
+#define NOCOLOR           // Screen colors
+#endif
+#ifndef NOCTLMGR
+#define NOCTLMGR          // Control and Dialog routines
+#endif
+#ifndef NODRAWTEXT
+#define NODRAWTEXT        // DrawText() and DT_*
+#endif
+#ifndef NOGDI
+#define NOGDI             // All GDI defines and routines
+#endif
+#ifndef NOKERNEL
+#define NOKERNEL          // All KERNEL defines and routines
+#endif
+#ifndef NOUSER
+#define NOUSER            // All USER defines and routines
+#endif
+#ifndef NONLS
+#define NONLS             // All NLS defines and routines
+#endif
+#ifndef NOMB
+#define NOMB              // MB_* and MessageBox()
+#endif
+#ifndef NOMEMMGR
+#define NOMEMMGR          // GMEM_*, LMEM_*, GHND, LHND, associated routines
+#endif
+#ifndef NOMETAFILE
+#define NOMETAFILE        // typedef METAFILEPICT
+#endif
+#ifndef NOMINMAX
+#define NOMINMAX          // Macros min(a,b) and max(a,b)
+#endif
+#ifndef NOMSG
+#define NOMSG             // typedef MSG and associated routines
+#endif
+#ifndef NOOPENFILE
+#define NOOPENFILE        // OpenFile(), OemToAnsi, AnsiToOem, and OF_*
+#endif
+#ifndef NOSCROLL
+#define NOSCROLL          // SB_* and scrolling routines
+#endif
+#ifndef NOSERVICE
+#define NOSERVICE         // All Service Controller routines, SERVICE_ equates, etc.
+#endif
+#ifndef NOSOUND
+#define NOSOUND           // Sound driver routines
+#endif
+#ifndef NOTEXTMETRIC
+#define NOTEXTMETRIC      // typedef TEXTMETRIC and associated routines
+#endif
+#ifndef NOWH
+#define NOWH              // SetWindowsHook and WH_*
+#endif
+#ifndef NOWINOFFSETS
+#define NOWINOFFSETS      // GWL_*, GCL_*, associated routines
+#endif
+#ifndef NOCOMM
+#define NOCOMM            // COMM driver routines
+#endif
+#ifndef NOKANJI
+#define NOKANJI           // Kanji support stuff.
+#endif
+#ifndef NOHELP
+#define NOHELP            // Help engine interface.
 #endif
-#ifndef NOMCX   //  No Modem Configuration Extensions.
-#define NOMCX
+#ifndef NOPROFILER
+#define NOPROFILER        // Profiler interface.
 #endif
-#ifndef NOIME   //  No Input Method Editor.
-#define NOIME
+#ifndef NODEFERWINDOWPOS
+#define NODEFERWINDOWPOS  // DeferWindowPos routines
 #endif
-#ifndef NOSOUND //  No Sound driver routines.
-#define NOSOUND
+#ifndef NOMCX
+#define NOMCX             // Modem Configuration ExtensionsA
 #endif
 
 #ifdef ZMQ_HAVE_MINGW32
 #ifdef WINVER
 #undef WINVER
 #endif
+//  Set target version to Windows Server 2003, Windows XP
 #define WINVER 0x0501
+#define _WIN32_WINNT 0x0501
 #endif
 
 #include <winsock2.h>
-- 
1.7.5.1

