libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 8b93f7cf96b33be64581fa5280a2c5ee577bdf56
parent 41ea8b14cd9a69d2c1b2be6e08d37282fdadd0b3
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Tue, 18 Feb 2014 18:40:06 +0000

Replace plibc_init() and plibc_shutdown()

Diffstat:
Msrc/microhttpd/daemon.c | 27+++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -50,6 +50,13 @@ #include <sys/sendfile.h> #endif +#ifdef _WIN32 +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif /* !WIN32_LEAN_AND_MEAN */ +#include <windows.h> +#endif + #ifndef HAVE_ACCEPT4 #define HAVE_ACCEPT4 0 #endif @@ -128,6 +135,12 @@ MHD_PanicCallback mhd_panic; */ void *mhd_panic_cls; +#ifdef _WIN32 +/** + * Track initialization of winsock + */ +static int mhd_winsock_inited_ = 0; +#endif /** * Trace up to and return master daemon. If the supplied daemon @@ -4152,8 +4165,13 @@ FUNC_CONSTRUCTOR (MHD_init) () mhd_panic = &mhd_panic_std; mhd_panic_cls = NULL; -#ifdef WINDOWS - plibc_init ("GNU", "libmicrohttpd"); +#ifdef _WIN32 + WSADATA wsd; + if (0 != WSAStartup(MAKEWORD(2, 2), &wsd)) + MHD_PANIC ("Failed to initialize winsock\n"); + mhd_winsock_inited_ = 1; + if (2 != LOBYTE(wsd.wVersion) && 2 != HIBYTE(wsd.wVersion)) + MHD_PANIC ("Winsock version 2.2 is not available\n"); #endif #if HTTPS_SUPPORT #if GCRYPT_VERSION_NUMBER < 0x010600 @@ -4170,8 +4188,9 @@ FUNC_DESTRUCTOR (MHD_fini) () #if HTTPS_SUPPORT gnutls_global_deinit (); #endif -#ifdef WINDOWS - plibc_shutdown (); +#ifdef _WIN32 + if (mhd_winsock_inited_) + WSACleanup(); #endif }