diff options
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r-- | src/microhttpd/daemon.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index fae617a1..29007004 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -50,6 +50,13 @@ | |||
50 | #include <sys/sendfile.h> | 50 | #include <sys/sendfile.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #ifdef _WIN32 | ||
54 | #ifndef WIN32_LEAN_AND_MEAN | ||
55 | #define WIN32_LEAN_AND_MEAN 1 | ||
56 | #endif /* !WIN32_LEAN_AND_MEAN */ | ||
57 | #include <windows.h> | ||
58 | #endif | ||
59 | |||
53 | #ifndef HAVE_ACCEPT4 | 60 | #ifndef HAVE_ACCEPT4 |
54 | #define HAVE_ACCEPT4 0 | 61 | #define HAVE_ACCEPT4 0 |
55 | #endif | 62 | #endif |
@@ -128,6 +135,12 @@ MHD_PanicCallback mhd_panic; | |||
128 | */ | 135 | */ |
129 | void *mhd_panic_cls; | 136 | void *mhd_panic_cls; |
130 | 137 | ||
138 | #ifdef _WIN32 | ||
139 | /** | ||
140 | * Track initialization of winsock | ||
141 | */ | ||
142 | static int mhd_winsock_inited_ = 0; | ||
143 | #endif | ||
131 | 144 | ||
132 | /** | 145 | /** |
133 | * Trace up to and return master daemon. If the supplied daemon | 146 | * Trace up to and return master daemon. If the supplied daemon |
@@ -4152,8 +4165,13 @@ FUNC_CONSTRUCTOR (MHD_init) () | |||
4152 | mhd_panic = &mhd_panic_std; | 4165 | mhd_panic = &mhd_panic_std; |
4153 | mhd_panic_cls = NULL; | 4166 | mhd_panic_cls = NULL; |
4154 | 4167 | ||
4155 | #ifdef WINDOWS | 4168 | #ifdef _WIN32 |
4156 | plibc_init ("GNU", "libmicrohttpd"); | 4169 | WSADATA wsd; |
4170 | if (0 != WSAStartup(MAKEWORD(2, 2), &wsd)) | ||
4171 | MHD_PANIC ("Failed to initialize winsock\n"); | ||
4172 | mhd_winsock_inited_ = 1; | ||
4173 | if (2 != LOBYTE(wsd.wVersion) && 2 != HIBYTE(wsd.wVersion)) | ||
4174 | MHD_PANIC ("Winsock version 2.2 is not available\n"); | ||
4157 | #endif | 4175 | #endif |
4158 | #if HTTPS_SUPPORT | 4176 | #if HTTPS_SUPPORT |
4159 | #if GCRYPT_VERSION_NUMBER < 0x010600 | 4177 | #if GCRYPT_VERSION_NUMBER < 0x010600 |
@@ -4170,8 +4188,9 @@ FUNC_DESTRUCTOR (MHD_fini) () | |||
4170 | #if HTTPS_SUPPORT | 4188 | #if HTTPS_SUPPORT |
4171 | gnutls_global_deinit (); | 4189 | gnutls_global_deinit (); |
4172 | #endif | 4190 | #endif |
4173 | #ifdef WINDOWS | 4191 | #ifdef _WIN32 |
4174 | plibc_shutdown (); | 4192 | if (mhd_winsock_inited_) |
4193 | WSACleanup(); | ||
4175 | #endif | 4194 | #endif |
4176 | } | 4195 | } |
4177 | 4196 | ||