diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-11-06 16:52:07 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-11-06 16:52:07 +0300 |
commit | 8b10b7801c17f9d589cdb4b5131e5621ee088827 (patch) | |
tree | ed5edee8896f3ef4fdfcc570a2dc89dd88625ded | |
parent | 29a91f5ddb1e0e5e45a66c2bd628a5573139236e (diff) | |
download | libmicrohttpd-8b10b7801c17f9d589cdb4b5131e5621ee088827.tar.gz libmicrohttpd-8b10b7801c17f9d589cdb4b5131e5621ee088827.zip |
Stick to C99 standard 'bool' for internals, fallback to 'int' when 'bool' is not available
-rw-r--r-- | configure.ac | 47 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 10 | ||||
-rw-r--r-- | src/microhttpd/internal.h | 6 | ||||
-rw-r--r-- | src/microhttpd/mhd_str.c | 12 | ||||
-rw-r--r-- | src/microhttpd/test_shutdown_select.c | 6 |
5 files changed, 52 insertions, 29 deletions
diff --git a/configure.ac b/configure.ac index 557bd0cd..c8a7c3f8 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -89,19 +89,42 @@ MHD_LIBDEPS="" | |||
89 | MHD_REQ_PRIVATE='' | 89 | MHD_REQ_PRIVATE='' |
90 | MHD_LIBDEPS_PKGCFG='' | 90 | MHD_LIBDEPS_PKGCFG='' |
91 | 91 | ||
92 | AC_CHECK_TYPE([_Bool], | 92 | AH_TEMPLATE([[HAVE_STDBOOL_H]], [Define to 1 if you have the <stdbool.h> header file and <stdbool.h> defines 'bool' type.]) |
93 | [ AC_DEFINE([_MHD_bool],[_Bool],[Define to type which will be used as boolean type.]) ], | 93 | AH_TEMPLATE([[HAVE_REAL_BOOL]], [Define to 1 if you have the real boolean type.]) |
94 | AH_TEMPLATE([[bool]], [Define to type name which will be used as boolean type.]) | ||
95 | AC_CHECK_HEADER([stdbool.h], | ||
94 | [ | 96 | [ |
95 | AC_CHECK_HEADER([stdbool.h], [ AC_DEFINE([HAVE_STDBOOL_H],[1],[Define to 1 if you have the <stdbool.h> header file and it's required for _MHD_bool.]) ], [], [AC_INCLUDES_DEFAULT]) | 97 | AC_CHECK_TYPE([bool], |
96 | AC_CHECK_TYPE([bool], | 98 | [ |
97 | [ AC_DEFINE([_MHD_bool],[bool]) ], | 99 | AC_DEFINE([[HAVE_STDBOOL_H]], [[1]]) |
98 | [ AC_DEFINE([_MHD_bool],[int]) ], | 100 | AC_DEFINE([[HAVE_REAL_BOOL]], [[1]]) |
99 | [[ | 101 | ], |
100 | #ifdef HAVE_STDBOOL_H | 102 | [ |
103 | AC_MSG_WARN([[Header <stdbool.h> is present, but "bool" type cannot be detected. Check compiler flags.]]) | ||
104 | AC_DEFINE([[bool]], [[int]]) | ||
105 | ], [ | ||
101 | #include <stdbool.h> | 106 | #include <stdbool.h> |
102 | #endif | 107 | ] |
103 | ]]) | 108 | ) |
104 | ]) | 109 | ], |
110 | [ | ||
111 | AC_CHECK_TYPE([bool], | ||
112 | [AC_DEFINE([[HAVE_REAL_BOOL]], [[1]])], | ||
113 | [ | ||
114 | AC_CHECK_TYPE([_Bool], | ||
115 | [ | ||
116 | AC_DEFINE([[HAVE_REAL_BOOL]], [[1]]) | ||
117 | AC_DEFINE([[bool]], [[_Bool]]) | ||
118 | ], | ||
119 | [ | ||
120 | AC_DEFINE([[bool]], [[int]]) | ||
121 | ], [] | ||
122 | ) | ||
123 | ], [] | ||
124 | ) | ||
125 | ], | ||
126 | [AC_INCLUDES_DEFAULT] | ||
127 | ) | ||
105 | 128 | ||
106 | AX_CHECK_COMPILE_FLAG([[-Werror=attributes]], | 129 | AX_CHECK_COMPILE_FLAG([[-Werror=attributes]], |
107 | [[errattr_CFLAGS="-Werror=attributes"]], | 130 | [[errattr_CFLAGS="-Werror=attributes"]], |
@@ -131,7 +154,7 @@ choke me | |||
131 | #ifdef HAVE_STDBOOL_H | 154 | #ifdef HAVE_STDBOOL_H |
132 | #include <stdbool.h> | 155 | #include <stdbool.h> |
133 | #endif | 156 | #endif |
134 | static $inln_prfx_chk _MHD_bool cmpfn(int x, int y) | 157 | static $inln_prfx_chk bool cmpfn(int x, int y) |
135 | { return x > y; } | 158 | { return x > y; } |
136 | static $inln_prfx_chk int sumfn(int x, int y) | 159 | static $inln_prfx_chk int sumfn(int x, int y) |
137 | { return x + y; } | 160 | { return x + y; } |
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index b469c70b..1c7368ad 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -39,10 +39,6 @@ | |||
39 | #include "mhd_itc.h" | 39 | #include "mhd_itc.h" |
40 | #include "mhd_compat.h" | 40 | #include "mhd_compat.h" |
41 | 41 | ||
42 | #ifdef HAVE_STDBOOL_H | ||
43 | #include <stdbool.h> | ||
44 | #endif | ||
45 | |||
46 | #if HAVE_SEARCH_H | 42 | #if HAVE_SEARCH_H |
47 | #include <search.h> | 43 | #include <search.h> |
48 | #else | 44 | #else |
@@ -5447,14 +5443,14 @@ static void | |||
5447 | close_all_connections (struct MHD_Daemon *daemon) | 5443 | close_all_connections (struct MHD_Daemon *daemon) |
5448 | { | 5444 | { |
5449 | struct MHD_Connection *pos; | 5445 | struct MHD_Connection *pos; |
5450 | const _MHD_bool used_thr_p_c = (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)); | 5446 | const bool used_thr_p_c = (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)); |
5451 | #ifdef UPGRADE_SUPPORT | 5447 | #ifdef UPGRADE_SUPPORT |
5452 | const _MHD_bool upg_allowed = (0 != (daemon->options & MHD_USE_UPGRADE)); | 5448 | const bool upg_allowed = (0 != (daemon->options & MHD_USE_UPGRADE)); |
5453 | #endif /* UPGRADE_SUPPORT */ | 5449 | #endif /* UPGRADE_SUPPORT */ |
5454 | #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) | 5450 | #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) |
5455 | struct MHD_UpgradeResponseHandle *urh; | 5451 | struct MHD_UpgradeResponseHandle *urh; |
5456 | struct MHD_UpgradeResponseHandle *urhn; | 5452 | struct MHD_UpgradeResponseHandle *urhn; |
5457 | const _MHD_bool used_tls = (0 != (daemon->options & MHD_USE_TLS)); | 5453 | const bool used_tls = (0 != (daemon->options & MHD_USE_TLS)); |
5458 | 5454 | ||
5459 | /* give upgraded HTTPS connections a chance to finish */ | 5455 | /* give upgraded HTTPS connections a chance to finish */ |
5460 | /* 'daemon->urh_head' is not used in thread-per-connection mode. */ | 5456 | /* 'daemon->urh_head' is not used in thread-per-connection mode. */ |
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h index 22187ae5..4f6635b4 100644 --- a/src/microhttpd/internal.h +++ b/src/microhttpd/internal.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #ifndef INTERNAL_H | 27 | #ifndef INTERNAL_H |
28 | #define INTERNAL_H | 28 | #define INTERNAL_H |
29 | 29 | ||
30 | #include "mhd_options.h" | ||
30 | #include "platform.h" | 31 | #include "platform.h" |
31 | #include "microhttpd.h" | 32 | #include "microhttpd.h" |
32 | #ifdef HTTPS_SUPPORT | 33 | #ifdef HTTPS_SUPPORT |
@@ -35,7 +36,10 @@ | |||
35 | #include <gnutls/abstract.h> | 36 | #include <gnutls/abstract.h> |
36 | #endif | 37 | #endif |
37 | #endif /* HTTPS_SUPPORT */ | 38 | #endif /* HTTPS_SUPPORT */ |
38 | #include "mhd_options.h" | 39 | |
40 | #ifdef HAVE_STDBOOL_H | ||
41 | #include <stdbool.h> | ||
42 | #endif | ||
39 | 43 | ||
40 | 44 | ||
41 | #ifdef MHD_PANIC | 45 | #ifdef MHD_PANIC |
diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c index 1cea69a0..3004c795 100644 --- a/src/microhttpd/mhd_str.c +++ b/src/microhttpd/mhd_str.c | |||
@@ -56,7 +56,7 @@ | |||
56 | * @param c character to check | 56 | * @param c character to check |
57 | * @return non-zero if character is lower case letter, zero otherwise | 57 | * @return non-zero if character is lower case letter, zero otherwise |
58 | */ | 58 | */ |
59 | _MHD_inline _MHD_bool | 59 | _MHD_inline bool |
60 | isasciilower (char c) | 60 | isasciilower (char c) |
61 | { | 61 | { |
62 | return (c >= 'a') && (c <= 'z'); | 62 | return (c >= 'a') && (c <= 'z'); |
@@ -69,7 +69,7 @@ isasciilower (char c) | |||
69 | * @param c character to check | 69 | * @param c character to check |
70 | * @return non-zero if character is upper case letter, zero otherwise | 70 | * @return non-zero if character is upper case letter, zero otherwise |
71 | */ | 71 | */ |
72 | _MHD_inline _MHD_bool | 72 | _MHD_inline bool |
73 | isasciiupper (char c) | 73 | isasciiupper (char c) |
74 | { | 74 | { |
75 | return (c >= 'A') && (c <= 'Z'); | 75 | return (c >= 'A') && (c <= 'Z'); |
@@ -82,7 +82,7 @@ isasciiupper (char c) | |||
82 | * @param c character to check | 82 | * @param c character to check |
83 | * @return non-zero if character is letter in US-ASCII, zero otherwise | 83 | * @return non-zero if character is letter in US-ASCII, zero otherwise |
84 | */ | 84 | */ |
85 | _MHD_inline _MHD_bool | 85 | _MHD_inline bool |
86 | isasciialpha (char c) | 86 | isasciialpha (char c) |
87 | { | 87 | { |
88 | return isasciilower (c) || isasciiupper (c); | 88 | return isasciilower (c) || isasciiupper (c); |
@@ -95,7 +95,7 @@ isasciialpha (char c) | |||
95 | * @param c character to check | 95 | * @param c character to check |
96 | * @return non-zero if character is decimal digit, zero otherwise | 96 | * @return non-zero if character is decimal digit, zero otherwise |
97 | */ | 97 | */ |
98 | _MHD_inline _MHD_bool | 98 | _MHD_inline bool |
99 | isasciidigit (char c) | 99 | isasciidigit (char c) |
100 | { | 100 | { |
101 | return (c >= '0') && (c <= '9'); | 101 | return (c >= '0') && (c <= '9'); |
@@ -108,7 +108,7 @@ isasciidigit (char c) | |||
108 | * @param c character to check | 108 | * @param c character to check |
109 | * @return non-zero if character is decimal digit, zero otherwise | 109 | * @return non-zero if character is decimal digit, zero otherwise |
110 | */ | 110 | */ |
111 | _MHD_inline _MHD_bool | 111 | _MHD_inline bool |
112 | isasciixdigit (char c) | 112 | isasciixdigit (char c) |
113 | { | 113 | { |
114 | return isasciidigit (c) || | 114 | return isasciidigit (c) || |
@@ -123,7 +123,7 @@ isasciixdigit (char c) | |||
123 | * @param c character to check | 123 | * @param c character to check |
124 | * @return non-zero if character is decimal digit or letter, zero otherwise | 124 | * @return non-zero if character is decimal digit or letter, zero otherwise |
125 | */ | 125 | */ |
126 | _MHD_inline _MHD_bool | 126 | _MHD_inline bool |
127 | isasciialnum (char c) | 127 | isasciialnum (char c) |
128 | { | 128 | { |
129 | return isasciialpha (c) || isasciidigit (c); | 129 | return isasciialpha (c) || isasciidigit (c); |
diff --git a/src/microhttpd/test_shutdown_select.c b/src/microhttpd/test_shutdown_select.c index 96e045bf..8d779dbd 100644 --- a/src/microhttpd/test_shutdown_select.c +++ b/src/microhttpd/test_shutdown_select.c | |||
@@ -87,10 +87,10 @@ | |||
87 | #define SHUT_RDWR SD_BOTH | 87 | #define SHUT_RDWR SD_BOTH |
88 | #endif | 88 | #endif |
89 | 89 | ||
90 | static _MHD_bool check_err; | 90 | static bool check_err; |
91 | 91 | ||
92 | 92 | ||
93 | static _MHD_bool | 93 | static bool |
94 | has_in_name(const char *prog_name, const char *marker) | 94 | has_in_name(const char *prog_name, const char *marker) |
95 | { | 95 | { |
96 | size_t name_pos; | 96 | size_t name_pos; |
@@ -284,7 +284,7 @@ main (int argc, char *const *argv) | |||
284 | WSADATA wsa_data; | 284 | WSADATA wsa_data; |
285 | int err; | 285 | int err; |
286 | #endif /* MHD_WINSOCK_SOCKETS */ | 286 | #endif /* MHD_WINSOCK_SOCKETS */ |
287 | _MHD_bool test_poll; | 287 | bool test_poll; |
288 | 288 | ||
289 | test_poll = has_in_name(argv[0], "_poll"); | 289 | test_poll = has_in_name(argv[0], "_poll"); |
290 | if (!test_poll) | 290 | if (!test_poll) |