diff options
Diffstat (limited to 'src/microhttpd')
-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 | 95 | ||||
-rw-r--r-- | src/microhttpd/mhd_compat.h | 67 | ||||
-rw-r--r-- | src/microhttpd/test_postprocessor.c | 1 | ||||
-rw-r--r-- | src/microhttpd/test_postprocessor_large.c | 1 |
10 files changed, 174 insertions, 14 deletions
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 = \ | |||
5 | 5 | ||
6 | AM_CFLAGS = $(HIDDEN_VISIBILITY_CFLAGS) | 6 | AM_CFLAGS = $(HIDDEN_VISIBILITY_CFLAGS) |
7 | 7 | ||
8 | if HAVE_W32 | ||
9 | MHD_W32_LIB = $(top_builddir)/src/platform/libplatform_interface.la | ||
10 | endif | ||
11 | |||
12 | lib_LTLIBRARIES = \ | 8 | lib_LTLIBRARIES = \ |
13 | libmicrohttpd.la | 9 | libmicrohttpd.la |
14 | 10 | ||
@@ -71,6 +67,7 @@ libmicrohttpd_la_SOURCES = \ | |||
71 | mhd_locks.h \ | 67 | mhd_locks.h \ |
72 | mhd_sockets.c mhd_sockets.h \ | 68 | mhd_sockets.c mhd_sockets.h \ |
73 | mhd_itc.c mhd_itc.h \ | 69 | mhd_itc.c mhd_itc.h \ |
70 | mhd_compat.c mhd_compat.h \ | ||
74 | response.c response.h | 71 | response.c response.h |
75 | libmicrohttpd_la_CPPFLAGS = \ | 72 | libmicrohttpd_la_CPPFLAGS = \ |
76 | $(AM_CPPFLAGS) $(MHD_LIB_CPPFLAGS) \ | 73 | $(AM_CPPFLAGS) $(MHD_LIB_CPPFLAGS) \ |
@@ -82,9 +79,7 @@ libmicrohttpd_la_LDFLAGS = \ | |||
82 | $(W32_MHD_LIB_LDFLAGS) \ | 79 | $(W32_MHD_LIB_LDFLAGS) \ |
83 | -version-info @LIB_VERSION_CURRENT@:@LIB_VERSION_REVISION@:@LIB_VERSION_AGE@ | 80 | -version-info @LIB_VERSION_CURRENT@:@LIB_VERSION_REVISION@:@LIB_VERSION_AGE@ |
84 | libmicrohttpd_la_LIBADD = \ | 81 | libmicrohttpd_la_LIBADD = \ |
85 | $(MHD_W32_LIB) $(MHD_LIBDEPS) | 82 | $(MHD_LIBDEPS) |
86 | libmicrohttpd_la_DEPENDENCIES = \ | ||
87 | $(MHD_W32_LIB) | ||
88 | 83 | ||
89 | if HAVE_W32 | 84 | if HAVE_W32 |
90 | MHD_DLL_RES_SRC = microhttpd_dll_res.rc | 85 | MHD_DLL_RES_SRC = microhttpd_dll_res.rc |
@@ -172,12 +167,11 @@ test_daemon_LDADD = \ | |||
172 | $(top_builddir)/src/microhttpd/libmicrohttpd.la | 167 | $(top_builddir)/src/microhttpd/libmicrohttpd.la |
173 | 168 | ||
174 | test_postprocessor_SOURCES = \ | 169 | test_postprocessor_SOURCES = \ |
175 | test_postprocessor.c | 170 | test_postprocessor.c mhd_compat.c |
176 | test_postprocessor_CPPFLAGS = \ | 171 | test_postprocessor_CPPFLAGS = \ |
177 | $(AM_CPPFLAGS) $(GNUTLS_CPPFLAGS) | 172 | $(AM_CPPFLAGS) $(GNUTLS_CPPFLAGS) |
178 | test_postprocessor_LDADD = \ | 173 | test_postprocessor_LDADD = \ |
179 | $(top_builddir)/src/microhttpd/libmicrohttpd.la \ | 174 | $(top_builddir)/src/microhttpd/libmicrohttpd.la |
180 | $(MHD_W32_LIB) | ||
181 | 175 | ||
182 | test_postprocessor_amp_SOURCES = \ | 176 | test_postprocessor_amp_SOURCES = \ |
183 | test_postprocessor_amp.c | 177 | test_postprocessor_amp.c |
@@ -187,12 +181,11 @@ test_postprocessor_amp_LDADD = \ | |||
187 | $(top_builddir)/src/microhttpd/libmicrohttpd.la | 181 | $(top_builddir)/src/microhttpd/libmicrohttpd.la |
188 | 182 | ||
189 | test_postprocessor_large_SOURCES = \ | 183 | test_postprocessor_large_SOURCES = \ |
190 | test_postprocessor_large.c | 184 | test_postprocessor_large.c mhd_compat.c |
191 | test_postprocessor_large_CPPFLAGS = \ | 185 | test_postprocessor_large_CPPFLAGS = \ |
192 | $(AM_CPPFLAGS) $(GNUTLS_CPPFLAGS) | 186 | $(AM_CPPFLAGS) $(GNUTLS_CPPFLAGS) |
193 | test_postprocessor_large_LDADD = \ | 187 | test_postprocessor_large_LDADD = \ |
194 | $(top_builddir)/src/microhttpd/libmicrohttpd.la \ | 188 | $(top_builddir)/src/microhttpd/libmicrohttpd.la |
195 | $(MHD_W32_LIB) | ||
196 | 189 | ||
197 | test_shutdown_select_SOURCES = \ | 190 | test_shutdown_select_SOURCES = \ |
198 | test_shutdown_select.c | 191 | 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 @@ | |||
26 | #include <limits.h> | 26 | #include <limits.h> |
27 | #include "internal.h" | 27 | #include "internal.h" |
28 | #include "base64.h" | 28 | #include "base64.h" |
29 | #include "mhd_compat.h" | ||
29 | 30 | ||
30 | /** | 31 | /** |
31 | * Beginning string for any valid Basic authentication header. | 32 | * 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 @@ | |||
33 | #include "mhd_str.h" | 33 | #include "mhd_str.h" |
34 | #include "mhd_locks.h" | 34 | #include "mhd_locks.h" |
35 | #include "mhd_sockets.h" | 35 | #include "mhd_sockets.h" |
36 | #include "mhd_compat.h" | ||
36 | 37 | ||
37 | 38 | ||
38 | /** | 39 | /** |
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 @@ | |||
36 | #include "mhd_locks.h" | 36 | #include "mhd_locks.h" |
37 | #include "mhd_sockets.h" | 37 | #include "mhd_sockets.h" |
38 | #include "mhd_itc.h" | 38 | #include "mhd_itc.h" |
39 | #include "mhd_compat.h" | ||
39 | 40 | ||
40 | #if HAVE_SEARCH_H | 41 | #if HAVE_SEARCH_H |
41 | #include <search.h> | 42 | #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 @@ | |||
28 | #include "md5.h" | 28 | #include "md5.h" |
29 | #include "mhd_mono_clock.h" | 29 | #include "mhd_mono_clock.h" |
30 | #include "mhd_str.h" | 30 | #include "mhd_str.h" |
31 | #include "mhd_compat.h" | ||
31 | 32 | ||
32 | #if defined(_WIN32) && defined(MHD_W32_MUTEX_) | 33 | #if defined(_WIN32) && defined(MHD_W32_MUTEX_) |
33 | #ifndef WIN32_LEAN_AND_MEAN | 34 | #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 @@ | |||
29 | 29 | ||
30 | #include "platform.h" | 30 | #include "platform.h" |
31 | #include "microhttpd.h" | 31 | #include "microhttpd.h" |
32 | #include "platform_interface.h" | ||
33 | #if HTTPS_SUPPORT | 32 | #if HTTPS_SUPPORT |
34 | #include <gnutls/gnutls.h> | 33 | #include <gnutls/gnutls.h> |
35 | #if GNUTLS_VERSION_MAJOR >= 3 | 34 | #if GNUTLS_VERSION_MAJOR >= 3 |
diff --git a/src/microhttpd/mhd_compat.c b/src/microhttpd/mhd_compat.c new file mode 100644 index 00000000..4911a1c6 --- /dev/null +++ b/src/microhttpd/mhd_compat.c | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | This file is part of libmicrohttpd | ||
3 | Copyright (C) 2014-2016 Karlson2k (Evgeny Grin) | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file microhttpd/mhd_compat.c | ||
23 | * @brief Implementation of platform missing functions. | ||
24 | * @author Karlson2k (Evgeny Grin) | ||
25 | */ | ||
26 | |||
27 | #include "mhd_compat.h" | ||
28 | #if defined(_WIN32) && !defined(__CYGWIN__) | ||
29 | #include <stdint.h> | ||
30 | #include <time.h> | ||
31 | #ifndef HAVE_SNPRINTF | ||
32 | #include <stdio.h> | ||
33 | #include <stdarg.h> | ||
34 | #endif /* HAVE_SNPRINTF */ | ||
35 | #endif /* _WIN32 && !__CYGWIN__ */ | ||
36 | |||
37 | |||
38 | /** | ||
39 | * Dummy function to silent compiler warning on empty file | ||
40 | * @return zero | ||
41 | */ | ||
42 | static int | ||
43 | static_dummy_func(void) | ||
44 | { | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | #if defined(_WIN32) && !defined(__CYGWIN__) | ||
49 | /** | ||
50 | * Static variable used by pseudo random number generator | ||
51 | */ | ||
52 | static int32_t rnd_val = 0; | ||
53 | |||
54 | /** | ||
55 | * Generate 31-bit pseudo random number. | ||
56 | * Function initialize itself at first call to current time. | ||
57 | * @return 31-bit pseudo random number. | ||
58 | */ | ||
59 | int MHD_W32_random_(void) | ||
60 | { | ||
61 | if (0 == rnd_val) | ||
62 | rnd_val = (int32_t)time(NULL); | ||
63 | /* stolen from winsup\cygwin\random.cc */ | ||
64 | rnd_val = (16807 * (rnd_val % 127773) - 2836 * (rnd_val / 127773)) | ||
65 | & 0x7fffffff; | ||
66 | return (int)rnd_val; | ||
67 | } | ||
68 | |||
69 | |||
70 | #ifndef HAVE_SNPRINTF | ||
71 | /* Emulate snprintf function on W32 */ | ||
72 | int W32_snprintf(char *__restrict s, size_t n, const char *__restrict format, ...) | ||
73 | { | ||
74 | int ret; | ||
75 | va_list args; | ||
76 | if (0 != n && NULL != s ) | ||
77 | { | ||
78 | va_start(args, format); | ||
79 | ret = _vsnprintf(s, n, format, args); | ||
80 | va_end(args); | ||
81 | if ((int)n == ret) | ||
82 | s[n - 1] = 0; | ||
83 | if (ret >= 0) | ||
84 | return ret; | ||
85 | } | ||
86 | va_start(args, format); | ||
87 | ret = _vscprintf(format, args); | ||
88 | va_end(args); | ||
89 | if (0 <= ret && 0 != n && NULL == s) | ||
90 | return -1; | ||
91 | |||
92 | return ret; | ||
93 | } | ||
94 | #endif /* HAVE_SNPRINTF */ | ||
95 | #endif /* _WIN32 && !__CYGWIN__ */ | ||
diff --git a/src/microhttpd/mhd_compat.h b/src/microhttpd/mhd_compat.h new file mode 100644 index 00000000..7fe3c735 --- /dev/null +++ b/src/microhttpd/mhd_compat.h | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | This file is part of libmicrohttpd | ||
3 | Copyright (C) 2014-2016 Karlson2k (Evgeny Grin) | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file microhttpd/mhd_compat.h | ||
23 | * @brief Header for platform missing functions. | ||
24 | * @author Karlson2k (Evgeny Grin) | ||
25 | * | ||
26 | * Provides compatibility for platforms with some missing | ||
27 | * functionality. | ||
28 | * Any functions can be implemented as macro on some platforms | ||
29 | * unless explicitly marked otherwise. | ||
30 | * Any function argument can be skipped in macro, so avoid | ||
31 | * variable modification in function parameters. | ||
32 | */ | ||
33 | |||
34 | #ifndef MHD_COMPAT_H | ||
35 | #define MHD_COMPAT_H 1 | ||
36 | |||
37 | #include "mhd_options.h" | ||
38 | |||
39 | /* Platform-independent snprintf name */ | ||
40 | #if defined(HAVE_SNPRINTF) | ||
41 | #define MHD_snprintf_ snprintf | ||
42 | #else /* ! HAVE_SNPRINTF */ | ||
43 | #if defined(_WIN32) | ||
44 | /* Emulate snprintf function on W32 */ | ||
45 | int W32_snprintf(char *__restrict s, size_t n, const char *__restrict format, ...); | ||
46 | #define MHD_snprintf_ W32_snprintf | ||
47 | #else /* ! _WIN32*/ | ||
48 | #error Your platform does not support snprintf() and MHD does not know how to emulate it on your platform. | ||
49 | #endif /* ! _WIN32*/ | ||
50 | #endif /* ! HAVE_SNPRINTF */ | ||
51 | |||
52 | #if !defined(_WIN32) || defined(__CYGWIN__) | ||
53 | #define MHD_random_() random() | ||
54 | #else /* _WIN32 && !__CYGWIN__ */ | ||
55 | #define MHD_random_() MHD_W32_random_() | ||
56 | |||
57 | /** | ||
58 | * Generate 31-bit pseudo random number. | ||
59 | * Function initialize itself at first call to current time. | ||
60 | * @return 31-bit pseudo random number. | ||
61 | */ | ||
62 | int MHD_W32_random_(void); | ||
63 | #endif /* _WIN32 && !__CYGWIN__ */ | ||
64 | |||
65 | |||
66 | |||
67 | #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 @@ | |||
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | #include <string.h> | 31 | #include <string.h> |
32 | #include <stdio.h> | 32 | #include <stdio.h> |
33 | #include "mhd_compat.h" | ||
33 | 34 | ||
34 | #ifndef WINDOWS | 35 | #ifndef WINDOWS |
35 | #include <unistd.h> | 36 | #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 @@ | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "microhttpd.h" | 28 | #include "microhttpd.h" |
29 | #include "internal.h" | 29 | #include "internal.h" |
30 | #include "mhd_compat.h" | ||
30 | 31 | ||
31 | #ifndef WINDOWS | 32 | #ifndef WINDOWS |
32 | #include <unistd.h> | 33 | #include <unistd.h> |