diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-08-23 20:13:03 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-08-23 20:13:03 +0000 |
commit | 47bfec25d8fabfa4cc118e094a08101655d63d65 (patch) | |
tree | af48bae9a35149de4be1e8c09094c39334bde192 | |
parent | 558572ec73c212b87ea999b0c0d2ed65900d82c2 (diff) |
Moved generic emulated functions to mhd_compat.h/.c, removed "platform" dir,
removed "w32functions.h/.c"
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/include/Makefile.am | 2 | ||||
-rw-r--r-- | src/include/w32functions.h | 55 | ||||
-rw-r--r-- | src/microhttpd/Makefile.am | 19 | ||||
-rw-r--r-- | src/microhttpd/basicauth.c | 1 | ||||
-rw-r--r-- | src/microhttpd/connection.c | 1 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 1 | ||||
-rw-r--r-- | src/microhttpd/digestauth.c | 1 | ||||
-rw-r--r-- | src/microhttpd/internal.h | 1 | ||||
-rw-r--r-- | src/microhttpd/mhd_compat.c (renamed from src/platform/w32functions.c) | 35 | ||||
-rw-r--r-- | src/microhttpd/mhd_compat.h (renamed from src/include/platform_interface.h) | 48 | ||||
-rw-r--r-- | src/microhttpd/test_postprocessor.c | 1 | ||||
-rw-r--r-- | src/microhttpd/test_postprocessor_large.c | 1 | ||||
-rw-r--r-- | src/platform/Makefile.am | 20 | ||||
-rw-r--r-- | src/testcurl/Makefile.am | 16 | ||||
-rw-r--r-- | src/testcurl/test_get.c | 1 | ||||
-rw-r--r-- | src/testcurl/test_get_sendfile.c | 1 | ||||
-rw-r--r-- | src/testcurl/test_quiesce.c | 1 | ||||
-rw-r--r-- | w32/common/libmicrohttpd-files.vcxproj | 5 | ||||
-rw-r--r-- | w32/common/libmicrohttpd-filters.vcxproj | 19 |
21 files changed, 80 insertions, 152 deletions
diff --git a/configure.ac b/configure.ac index 1ef58edb..f66540ec 100644 --- a/configure.ac +++ b/configure.ac @@ -1076,7 +1076,6 @@ doc/examples/Makefile m4/Makefile src/Makefile src/include/Makefile -src/platform/Makefile src/microhttpd/Makefile src/examples/Makefile src/testcurl/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index 51263449..09af041d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,7 +8,7 @@ endif endif endif -SUBDIRS = include platform microhttpd $(curltests) $(zzuftests) . +SUBDIRS = include microhttpd $(curltests) $(zzuftests) . if BUILD_EXAMPLES SUBDIRS += examples diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 42425ad8..24102d94 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -3,4 +3,4 @@ SUBDIRS = . include_HEADERS = microhttpd.h -EXTRA_DIST = platform.h platform_interface.h w32functions.h autoinit_funcs.h +EXTRA_DIST = platform.h autoinit_funcs.h diff --git a/src/include/w32functions.h b/src/include/w32functions.h deleted file mode 100644 index 0694a381..00000000 --- a/src/include/w32functions.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - This file is part of libmicrohttpd - Copyright (C) 2014 Karlson2k (Evgeny Grin) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. - If not, see <http://www.gnu.org/licenses/>. -*/ - -/** - * @file include/w32functions.h - * @brief internal functions for W32 systems - * @author Karlson2k (Evgeny Grin) - */ - -#ifndef MHD_W32FUNCTIONS_H -#define MHD_W32FUNCTIONS_H -#ifndef _WIN32 -#error w32functions.h is designed only for W32 systems -#endif - -#include "platform.h" -#include <errno.h> -#include <winsock2.h> -#include "platform_interface.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** - * Generate 31-bit pseudo random number. - * Function initialize itself at first call to current time. - * @return 31-bit pseudo random number. - */ -int MHD_W32_random_(void); - -/* Emulate snprintf function on W32 */ -int W32_snprintf(char *__restrict s, size_t n, const char *__restrict format, ...); - -#ifdef __cplusplus -} -#endif -#endif /* MHD_W32FUNCTIONS_H */ diff --git a/src/microhttpd/Makefile.am b/src/microhttpd/Makefile.am index c72e183f..1e555c18 100644 --- a/src/microhttpd/Makefile.am +++ b/src/microhttpd/Makefile.am @@ -5,10 +5,6 @@ AM_CPPFLAGS = \ AM_CFLAGS = $(HIDDEN_VISIBILITY_CFLAGS) -if HAVE_W32 -MHD_W32_LIB = $(top_builddir)/src/platform/libplatform_interface.la -endif - lib_LTLIBRARIES = \ libmicrohttpd.la @@ -71,6 +67,7 @@ libmicrohttpd_la_SOURCES = \ mhd_locks.h \ mhd_sockets.c mhd_sockets.h \ mhd_itc.c mhd_itc.h \ + mhd_compat.c mhd_compat.h \ response.c response.h libmicrohttpd_la_CPPFLAGS = \ $(AM_CPPFLAGS) $(MHD_LIB_CPPFLAGS) \ @@ -82,9 +79,7 @@ libmicrohttpd_la_LDFLAGS = \ $(W32_MHD_LIB_LDFLAGS) \ -version-info @LIB_VERSION_CURRENT@:@LIB_VERSION_REVISION@:@LIB_VERSION_AGE@ libmicrohttpd_la_LIBADD = \ - $(MHD_W32_LIB) $(MHD_LIBDEPS) -libmicrohttpd_la_DEPENDENCIES = \ - $(MHD_W32_LIB) + $(MHD_LIBDEPS) if HAVE_W32 MHD_DLL_RES_SRC = microhttpd_dll_res.rc @@ -172,12 +167,11 @@ test_daemon_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la test_postprocessor_SOURCES = \ - test_postprocessor.c + test_postprocessor.c mhd_compat.c test_postprocessor_CPPFLAGS = \ $(AM_CPPFLAGS) $(GNUTLS_CPPFLAGS) test_postprocessor_LDADD = \ - $(top_builddir)/src/microhttpd/libmicrohttpd.la \ - $(MHD_W32_LIB) + $(top_builddir)/src/microhttpd/libmicrohttpd.la test_postprocessor_amp_SOURCES = \ test_postprocessor_amp.c @@ -187,12 +181,11 @@ test_postprocessor_amp_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la test_postprocessor_large_SOURCES = \ - test_postprocessor_large.c + test_postprocessor_large.c mhd_compat.c test_postprocessor_large_CPPFLAGS = \ $(AM_CPPFLAGS) $(GNUTLS_CPPFLAGS) test_postprocessor_large_LDADD = \ - $(top_builddir)/src/microhttpd/libmicrohttpd.la \ - $(MHD_W32_LIB) + $(top_builddir)/src/microhttpd/libmicrohttpd.la test_shutdown_select_SOURCES = \ test_shutdown_select.c diff --git a/src/microhttpd/basicauth.c b/src/microhttpd/basicauth.c index 9d116751..7acae6af 100644 --- a/src/microhttpd/basicauth.c +++ b/src/microhttpd/basicauth.c @@ -26,6 +26,7 @@ #include <limits.h> #include "internal.h" #include "base64.h" +#include "mhd_compat.h" /** * Beginning string for any valid Basic authentication header. diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 037a33ff..2c799d16 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c @@ -33,6 +33,7 @@ #include "mhd_str.h" #include "mhd_locks.h" #include "mhd_sockets.h" +#include "mhd_compat.h" /** diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index d5c00e57..7a784daf 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c @@ -36,6 +36,7 @@ #include "mhd_locks.h" #include "mhd_sockets.h" #include "mhd_itc.h" +#include "mhd_compat.h" #if HAVE_SEARCH_H #include <search.h> diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c index 9a9d9e6a..5005bf2a 100644 --- a/src/microhttpd/digestauth.c +++ b/src/microhttpd/digestauth.c @@ -28,6 +28,7 @@ #include "md5.h" #include "mhd_mono_clock.h" #include "mhd_str.h" +#include "mhd_compat.h" #if defined(_WIN32) && defined(MHD_W32_MUTEX_) #ifndef WIN32_LEAN_AND_MEAN diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h index 0f70026f..40621e2d 100644 --- a/src/microhttpd/internal.h +++ b/src/microhttpd/internal.h @@ -29,7 +29,6 @@ #include "platform.h" #include "microhttpd.h" -#include "platform_interface.h" #if HTTPS_SUPPORT #include <gnutls/gnutls.h> #if GNUTLS_VERSION_MAJOR >= 3 diff --git a/src/platform/w32functions.c b/src/microhttpd/mhd_compat.c index 6fec7a3c..4911a1c6 100644 --- a/src/platform/w32functions.c +++ b/src/microhttpd/mhd_compat.c @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - Copyright (C) 2014 Karlson2k (Evgeny Grin) + Copyright (C) 2014-2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -13,27 +13,44 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library. - If not, see <http://www.gnu.org/licenses/>. + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ /** - * @file platform/w32functions.h - * @brief internal functions for W32 systems + * @file microhttpd/mhd_compat.c + * @brief Implementation of platform missing functions. * @author Karlson2k (Evgeny Grin) */ -#include "w32functions.h" -#include <string.h> +#include "mhd_compat.h" +#if defined(_WIN32) && !defined(__CYGWIN__) #include <stdint.h> #include <time.h> +#ifndef HAVE_SNPRINTF #include <stdio.h> #include <stdarg.h> +#endif /* HAVE_SNPRINTF */ +#endif /* _WIN32 && !__CYGWIN__ */ + /** + * Dummy function to silent compiler warning on empty file + * @return zero + */ +static int +static_dummy_func(void) +{ + return 0; +} + +#if defined(_WIN32) && !defined(__CYGWIN__) +/** * Static variable used by pseudo random number generator */ static int32_t rnd_val = 0; + /** * Generate 31-bit pseudo random number. * Function initialize itself at first call to current time. @@ -49,6 +66,8 @@ int MHD_W32_random_(void) return (int)rnd_val; } + +#ifndef HAVE_SNPRINTF /* Emulate snprintf function on W32 */ int W32_snprintf(char *__restrict s, size_t n, const char *__restrict format, ...) { @@ -72,3 +91,5 @@ int W32_snprintf(char *__restrict s, size_t n, const char *__restrict format, .. return ret; } +#endif /* HAVE_SNPRINTF */ +#endif /* _WIN32 && !__CYGWIN__ */ diff --git a/src/include/platform_interface.h b/src/microhttpd/mhd_compat.h index b641a002..7fe3c735 100644 --- a/src/include/platform_interface.h +++ b/src/microhttpd/mhd_compat.h @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - Copyright (C) 2014 Karlson2k (Evgeny Grin) + Copyright (C) 2014-2016 Karlson2k (Evgeny Grin) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -13,33 +13,36 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library. - If not, see <http://www.gnu.org/licenses/>. + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ /** - * @file include/platform_interface.h - * @brief internal platform abstraction functions + * @file microhttpd/mhd_compat.h + * @brief Header for platform missing functions. * @author Karlson2k (Evgeny Grin) + * + * Provides compatibility for platforms with some missing + * functionality. + * Any functions can be implemented as macro on some platforms + * unless explicitly marked otherwise. + * Any function argument can be skipped in macro, so avoid + * variable modification in function parameters. */ -#ifndef MHD_PLATFORM_INTERFACE_H -#define MHD_PLATFORM_INTERFACE_H - -#include "platform.h" -#if defined(_WIN32) && !defined(__CYGWIN__) -#include "w32functions.h" -#endif +#ifndef MHD_COMPAT_H +#define MHD_COMPAT_H 1 -/* ***************************** - General function mapping - *****************************/ +#include "mhd_options.h" /* Platform-independent snprintf name */ #if defined(HAVE_SNPRINTF) #define MHD_snprintf_ snprintf #else /* ! HAVE_SNPRINTF */ #if defined(_WIN32) +/* Emulate snprintf function on W32 */ +int W32_snprintf(char *__restrict s, size_t n, const char *__restrict format, ...); #define MHD_snprintf_ W32_snprintf #else /* ! _WIN32*/ #error Your platform does not support snprintf() and MHD does not know how to emulate it on your platform. @@ -48,8 +51,17 @@ #if !defined(_WIN32) || defined(__CYGWIN__) #define MHD_random_() random() -#else +#else /* _WIN32 && !__CYGWIN__ */ #define MHD_random_() MHD_W32_random_() -#endif -#endif /* MHD_PLATFORM_INTERFACE_H */ +/** + * Generate 31-bit pseudo random number. + * Function initialize itself at first call to current time. + * @return 31-bit pseudo random number. + */ +int MHD_W32_random_(void); +#endif /* _WIN32 && !__CYGWIN__ */ + + + +#endif /* MHD_COMPAT_H */ diff --git a/src/microhttpd/test_postprocessor.c b/src/microhttpd/test_postprocessor.c index 5a811c2b..e3a4d4c4 100644 --- a/src/microhttpd/test_postprocessor.c +++ b/src/microhttpd/test_postprocessor.c @@ -30,6 +30,7 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> +#include "mhd_compat.h" #ifndef WINDOWS #include <unistd.h> diff --git a/src/microhttpd/test_postprocessor_large.c b/src/microhttpd/test_postprocessor_large.c index 4b9e06ae..a509a7ba 100644 --- a/src/microhttpd/test_postprocessor_large.c +++ b/src/microhttpd/test_postprocessor_large.c @@ -27,6 +27,7 @@ #include "platform.h" #include "microhttpd.h" #include "internal.h" +#include "mhd_compat.h" #ifndef WINDOWS #include <unistd.h> diff --git a/src/platform/Makefile.am b/src/platform/Makefile.am deleted file mode 100644 index 448efae3..00000000 --- a/src/platform/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -# This Makefile.am is in the public domain -AM_CPPFLAGS = \ - -I$(top_srcdir)/src/include - -AM_CFLAGS = $(HIDDEN_VISIBILITY_CFLAGS) - -if USE_COVERAGE - AM_CFLAGS += --coverage -endif - -if HAVE_W32 -noinst_LTLIBRARIES = \ - libplatform_interface.la -libplatform_interface_la_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -DBUILDING_MHD_LIB=1 -libplatform_interface_la_SOURCES = \ - w32functions.c -endif - diff --git a/src/testcurl/Makefile.am b/src/testcurl/Makefile.am index 47ebda5a..55f35ee7 100644 --- a/src/testcurl/Makefile.am +++ b/src/testcurl/Makefile.am @@ -152,14 +152,6 @@ test_get_sendfile_SOURCES = \ test_get_sendfile_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ @LIBCURL@ -test_get_sendfile_DEPENDENCIES = - -if HAVE_W32 -test_get_sendfile_LDADD += \ - $(top_builddir)/src/platform/libplatform_interface.la -test_get_sendfile_DEPENDENCIES += \ - $(top_builddir)/src/platform/libplatform_interface.la -endif test_urlparse_SOURCES = \ test_urlparse.c @@ -237,14 +229,6 @@ test_get_sendfile11_SOURCES = \ test_get_sendfile11_LDADD = \ $(top_builddir)/src/microhttpd/libmicrohttpd.la \ @LIBCURL@ -test_get_sendfile11_DEPENDENCIES = - -if HAVE_W32 -test_get_sendfile11_LDADD += \ - $(top_builddir)/src/platform/libplatform_interface.la -test_get_sendfile11_DEPENDENCIES += \ - $(top_builddir)/src/platform/libplatform_interface.la -endif test_post11_SOURCES = \ test_post.c diff --git a/src/testcurl/test_get.c b/src/testcurl/test_get.c index b9d12816..892bd243 100644 --- a/src/testcurl/test_get.c +++ b/src/testcurl/test_get.c @@ -27,7 +27,6 @@ #include "MHD_config.h" #include "platform.h" -#include "platform_interface.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> diff --git a/src/testcurl/test_get_sendfile.c b/src/testcurl/test_get_sendfile.c index 19e327fd..d222a189 100644 --- a/src/testcurl/test_get_sendfile.c +++ b/src/testcurl/test_get_sendfile.c @@ -25,7 +25,6 @@ #include "MHD_config.h" #include "platform.h" -#include "platform_interface.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> diff --git a/src/testcurl/test_quiesce.c b/src/testcurl/test_quiesce.c index b0d99494..f4002348 100644 --- a/src/testcurl/test_quiesce.c +++ b/src/testcurl/test_quiesce.c @@ -25,7 +25,6 @@ #include "MHD_config.h" #include "platform.h" -#include "platform_interface.h" #include <curl/curl.h> #include <microhttpd.h> #include <stdlib.h> diff --git a/w32/common/libmicrohttpd-files.vcxproj b/w32/common/libmicrohttpd-files.vcxproj index fa75b6ad..2a615196 100644 --- a/w32/common/libmicrohttpd-files.vcxproj +++ b/w32/common/libmicrohttpd-files.vcxproj @@ -19,15 +19,13 @@ <ClCompile Include="$(MhdSrc)microhttpd\mhd_threads.c" /> <ClCompile Include="$(MhdSrc)microhttpd\mhd_sockets.c" /> <ClCompile Include="$(MhdSrc)microhttpd\mhd_itc.c" /> - <ClCompile Include="$(MhdSrc)platform\w32functions.c" /> + <ClCompile Include="$(MhdSrc)microhttpd\mhd_compat.c" /> </ItemGroup> <ItemGroup> <ClInclude Include="$(MhdSrc)include\autoinit_funcs.h" /> <ClInclude Include="$(MhdSrc)include\microhttpd.h" /> <ClInclude Include="$(MhdSrc)include\mhd_options.h" /> <ClInclude Include="$(MhdSrc)include\platform.h" /> - <ClInclude Include="$(MhdSrc)include\platform_interface.h" /> - <ClInclude Include="$(MhdSrc)include\w32functions.h" /> <ClInclude Include="$(MhdSrc)microhttpd\base64.h" /> <ClInclude Include="$(MhdSrc)microhttpd\connection.h" /> <ClInclude Include="$(MhdSrc)microhttpd\internal.h" /> @@ -44,6 +42,7 @@ <ClInclude Include="$(MhdSrc)microhttpd\mhd_locks.h" /> <ClInclude Include="$(MhdSrc)microhttpd\mhd_sockets.h" /> <ClInclude Include="$(MhdSrc)microhttpd\mhd_itc.h" /> + <ClInclude Include="$(MhdSrc)microhttpd\mhd_compat.h" /> <ClInclude Include="$(MhdW32Common)MHD_config.h" /> </ItemGroup> <ItemGroup> diff --git a/w32/common/libmicrohttpd-filters.vcxproj b/w32/common/libmicrohttpd-filters.vcxproj index 11782d00..2bb47bfd 100644 --- a/w32/common/libmicrohttpd-filters.vcxproj +++ b/w32/common/libmicrohttpd-filters.vcxproj @@ -13,10 +13,6 @@ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> </Filter> - <Filter Include="Source Files\platform_interface"> - <UniqueIdentifier>{af799bf7-9787-4134-8e56-9e5aae50c7e3}</UniqueIdentifier> - <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> - </Filter> <Filter Include="Template Files"> <UniqueIdentifier>{df5ad836-e372-437b-a0e3-299d3675d6b4}</UniqueIdentifier> <Extensions>in</Extensions> @@ -32,21 +28,12 @@ <ClInclude Include="$(MhdSrc)include\platform.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="$(MhdSrc)include\platform_interface.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="$(MhdSrc)include\w32functions.h"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="$(MhdSrc)include\mhd_options.h"> <Filter>Header Files</Filter> </ClInclude> <ClInclude Include="$(MhdW32Common)MHD_config.h"> <Filter>Header Files</Filter> </ClInclude> - <ClCompile Include="$(MhdSrc)platform\w32functions.c"> - <Filter>Source Files\platform_interface</Filter> - </ClCompile> </ItemGroup> <ItemGroup> <ClCompile Include="$(MhdSrc)microhttpd\base64.c"> @@ -151,6 +138,12 @@ <ClCompile Include="$(MhdSrc)microhttpd\mhd_itc.c"> <Filter>Source Files</Filter> </ClCompile> + <ClInclude Include="$(MhdSrc)microhttpd\mhd_compat.h"> + <Filter>Source Files</Filter> + </ClInclude> + <ClCompile Include="$(MhdSrc)microhttpd\mhd_compat.c"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ResourceCompile Include="$(MhdW32Common)microhttpd_dll_res_vc.rc"> |