libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

commit 977a39e189caa7b1532001b99b0d29de86c06709
parent 6c32eb7ea3a6f4c64cd10f48a9eeae93b3562eb0
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date:   Fri, 21 Mar 2025 18:58:20 +0300

Refactored MHD_lib_get_info_fixed_sz() and relevant types

Resulting values now are individual for each query value.
Some names have been updated for clarity

Diffstat:
Msrc/include/microhttpd2.h | 255+++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
Msrc/include/microhttpd2_main.h.in | 255+++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
Msrc/mhd2/lib_get_info.c | 254+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Msrc/tests/basic/test_lib_info_version.c | 37++++++++++++++++++++-----------------
4 files changed, 487 insertions(+), 314 deletions(-)

diff --git a/src/include/microhttpd2.h b/src/include/microhttpd2.h @@ -8536,15 +8536,15 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed /** * Get the MHD version as a number. - * The result is placed in @a v_uint32 member. + * The result is placed in @a v_version_num_uint32 member. */ MHD_LIB_INFO_FIXED_VERSION_NUM = 0 , /** * Get the MHD version as a string. - * The result is placed in @a v_string member. + * The result is placed in @a v_version_string member. */ - MHD_LIB_INFO_FIXED_VERSION_STR = 1 + MHD_LIB_INFO_FIXED_VERSION_STRING = 1 , /* * Basic MHD features, buid-time configurable * */ @@ -8555,63 +8555,63 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed /** * Get whether messages are supported. If supported then messages can be * printed to stderr or to an external logger. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_log_messages_bool member. */ - MHD_LIB_INFO_FIXED_HAS_LOG_MESSAGES = 11 + MHD_LIB_INFO_FIXED_SUPPORT_LOG_MESSAGES = 11 , /** * Get whether detailed automatic HTTP reply messages are supported. - * If supported then automatic responses have bodies with text expalining + * If supported then automatic responses have bodies with text explaining * the error details. * Automatic responses are sent by MHD automatically when client is violating * HTTP specification, for example, the request header has whitespace in * header name or request's "Content-Length" header has non-number value. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_auto_replies_bodies_bool member. */ - MHD_LIB_INFO_FIXED_HAS_AUTO_REPLIES_BODIES = 12 + MHD_LIB_INFO_FIXED_SUPPORT_AUTO_REPLIES_BODIES = 12 , /** * Get whether MHD was built with debug asserts disabled. * These asserts enabled only on special debug builds. * For debug builds the error log is always enabled. - * The result is placed in @a v_bool member. + * The result is placed in @a v_is_non_debug_bool member. */ MHD_LIB_INFO_FIXED_IS_NON_DEBUG = 13 , /** * Get whether MHD supports threads. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_threads_bool member. */ - MHD_LIB_INFO_FIXED_HAS_THREADS = 14 + MHD_LIB_INFO_FIXED_SUPPORT_THREADS = 14 , /** * Get whether automatic parsing of HTTP Cookie header is supported. * If disabled, no #MHD_VK_COOKIE will be generated by MHD. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_cookie_parser_bool member. */ - MHD_LIB_INFO_FIXED_HAS_COOKIE_PARSER = 15 + MHD_LIB_INFO_FIXED_SUPPORT_COOKIE_PARSER = 15 , /** * Get whether postprocessor is supported. If supported then * #MHD_action_post_processor() can be used. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_post_parser_bool member. */ - MHD_LIB_INFO_FIXED_HAS_POST_PARSER = 16 + MHD_LIB_INFO_FIXED_SUPPORT_POST_PARSER = 16 , /** * Get whether HTTP "Upgrade" is supported. * If supported then #MHD_action_upgrade() can be used. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_upgrade_bool member. */ - MHD_LIB_INFO_FIXED_HAS_UPGRADE = 17 + MHD_LIB_INFO_FIXED_SUPPORT_UPGRADE = 17 , /** * Get whether HTTP Basic authorization is supported. If supported * then functions #MHD_action_basic_auth_required_response () * and #MHD_REQUEST_INFO_DYNAMIC_AUTH_BASIC_CREDS can be used. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_auth_basic_bool member. */ - MHD_LIB_INFO_FIXED_HAS_AUTH_BASIC = 20 + MHD_LIB_INFO_FIXED_SUPPORT_AUTH_BASIC = 20 , /** * Get whether HTTP Digest authorization is supported. If @@ -8619,24 +8619,24 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * #MHD_D_O_DAUTH_MAP_SIZE and functions * #MHD_action_digest_auth_required_response () and * #MHD_digest_auth_check() can be used. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_auth_digest_bool member. */ - MHD_LIB_INFO_FIXED_HAS_AUTH_DIGEST = 21 + MHD_LIB_INFO_FIXED_SUPPORT_AUTH_DIGEST = 21 , /** * Get whether the early version the Digest Authorization (RFC 2069) is * supported (digest authorisation without QOP parameter). * Currently it is always supported if Digest Auth module is built. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_digest_auth_rfc2069_bool member. */ - MHD_LIB_INFO_FIXED_HAS_DIGEST_AUTH_RFC2069 = 22 + MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_RFC2069 = 22 , /** * Get whether the MD5-based hashing algorithms are supported for Digest * Authorization and the type of the implementation if supported. * Currently it is always supported if Digest Auth module is built * unless manually disabled in a custom build. - * The result is placed in @a v_d_algo member. + * The result is placed in @a v_type_digest_auth_md5_algo_type member. */ MHD_LIB_INFO_FIXED_TYPE_DIGEST_AUTH_MD5 = 23 , @@ -8645,7 +8645,7 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * Authorization and the type of the implementation if supported. * Currently it is always supported if Digest Auth module is built * unless manually disabled in a custom build. - * The result is placed in @a v_d_algo member. + * The result is placed in @a v_type_digest_auth_sha256_algo_type member. */ MHD_LIB_INFO_FIXED_TYPE_DIGEST_AUTH_SHA256 = 24 , @@ -8654,7 +8654,7 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * Authorization and the type of the implementation if supported. * Currently it is always supported if Digest Auth module is built * unless manually disabled in a custom build. - * The result is placed in @a v_d_algo member. + * The result is placed in @a v_type_digest_auth_sha512_256_algo_type member. */ MHD_LIB_INFO_FIXED_TYPE_DIGEST_AUTH_SHA512_256 = 25 , @@ -8662,24 +8662,24 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * Get whether QOP with value 'auth-int' (authentication with integrity * protection) is supported for Digest Authorization. * Currently it is always not supported. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_digest_auth_auth_int_bool member. */ - MHD_LIB_INFO_FIXED_HAS_DIGEST_AUTH_AUTH_INT = 28 + MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_AUTH_INT = 28 , /** * Get whether 'session' algorithms (like 'MD5-sess') are supported for Digest * Authorization. * Currently it is always not supported. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_digest_auth_algo_session_bool member. */ - MHD_LIB_INFO_FIXED_HAS_DIGEST_AUTH_ALGO_SESSION = 29 + MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_ALGO_SESSION = 29 , /** * Get whether 'userhash' is supported for Digest Authorization. * Currently it is always supported if Digest Auth module is built. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_digest_auth_userhash_bool member. */ - MHD_LIB_INFO_FIXED_HAS_DIGEST_AUTH_USERHASH = 30 + MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_USERHASH = 30 , /* * Platform-dependent features, some are configurable at build-time * */ @@ -8690,15 +8690,15 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * Get sockets polling functions/techniques supported by this MHD build. * Some functions can be disabled (like epoll) in kernel, this is not * checked. - * The result is placed in @a v_polling member. + * The result is placed in @a v_types_sockets_polling member. */ - MHD_LIB_INFO_FIXED_TYPE_SOCKETS_POLLING = 60 + MHD_LIB_INFO_FIXED_TYPES_SOCKETS_POLLING = 60 , /** * Get whether aggregate FD external polling is supported. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_aggregate_fd_bool member. */ - MHD_LIB_INFO_FIXED_HAS_AGGREGATE_FD = 61 + MHD_LIB_INFO_FIXED_SUPPORT_AGGREGATE_FD = 61 , /** * Get whether IPv6 is supported on the platform and IPv6-only listen socket @@ -8712,21 +8712,21 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed /** * Get whether TCP Fast Open is supported by MHD build. * If supported then option #MHD_D_O_TCP_FASTOPEN can be used. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_tcp_fastopen_bool member. */ - MHD_LIB_INFO_FIXED_HAS_TCP_FASTOPEN = 64 + MHD_LIB_INFO_FIXED_SUPPORT_TCP_FASTOPEN = 64 , /** * Get whether MHD support automatic detection of bind port number. * @sa #MHD_D_O_BIND_PORT - * The result is placed in @a v_bool member. + * The result is placed in @a v_has_autodetect_bind_port_bool member. */ MHD_LIB_INFO_FIXED_HAS_AUTODETECT_BIND_PORT = 65 , /** * Get whether MHD use system's sendfile() function to send * file-FD based responses over non-TLS connections. - * The result is placed in @a v_bool member. + * The result is placed in @a v_has_sendfile_bool member. */ MHD_LIB_INFO_FIXED_HAS_SENDFILE = 66 , @@ -8736,7 +8736,7 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * If SIGPIPE suppression is not supported, application must handle * SIGPIPE signal by itself whem using MHD with internal events loop. * If the platform does not have SIGPIPE the result is #MHD_YES. - * The result is placed in @a v_bool member. + * The result is placed in @a v_has_autosuppress_sigpipe_int_bool member. */ MHD_LIB_INFO_FIXED_HAS_AUTOSUPPRESS_SIGPIPE_INT = 80 , @@ -8746,19 +8746,19 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * If SIGPIPE suppression is not supported, application must handle * SIGPIPE signal by itself whem using MHD with external events loop. * If the platform does not have SIGPIPE the result is #MHD_YES. - * The result is placed in @a v_bool member. + * The result is placed in @a v_has_autosuppress_sigpipe_ext_bool member. */ MHD_LIB_INFO_FIXED_HAS_AUTOSUPPRESS_SIGPIPE_EXT = 81 , /** * Get whether MHD sets names on generated threads. - * The result is placed in @a v_bool member. + * The result is placed in @a v_has_thread_names_bool member. */ MHD_LIB_INFO_FIXED_HAS_THREAD_NAMES = 82 , /** * Get the type of supported inter-thread communication. - * The result is placed in @a v_itc member. + * The result is placed in @a v_type_itc member. */ MHD_LIB_INFO_FIXED_TYPE_ITC = 83 , @@ -8767,9 +8767,9 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * If supported then #MHD_response_from_fd() can be used with sizes and * offsets larger than 2 GiB. If not supported value of size+offset could be * limited to 2 GiB. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_large_file_bool member. */ - MHD_LIB_INFO_FIXED_HAS_LARGE_FILE = 84 + MHD_LIB_INFO_FIXED_SUPPORT_LARGE_FILE = 84 , /* * Platform-dependent features, some set on startup and some are @@ -8781,17 +8781,18 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed /** * Get whether HTTPS and which types of TLS backend(s) supported by * this build. - * The result is placed in @a v_tls member. + * The result is placed in @a v_tls_backends member. */ - MHD_LIB_INFO_FIXED_TYPE_TLS = 100 + MHD_LIB_INFO_FIXED_TLS_BACKENDS = 100 , /** * Get whether password encrypted private key for HTTPS daemon is - * supported. If supported then option #MHD_D_OPTION_TLS_KEY_CERT - * can be used with non-NULL @a mem_pass. - * The result is placed in @a v_tls member. + * supported by TLS backends. + * If supported then option #MHD_D_OPTION_TLS_KEY_CERT can be used with + * non-NULL @a mem_pass. + * The result is placed in @a v_tls_key_password_backends member. */ - MHD_LIB_INFO_FIXED_HAS_TLS_KEY_PASSWORD = 102 + MHD_LIB_INFO_FIXED_TLS_KEY_PASSWORD_BACKENDS = 102 , /* * Sentinel * */ @@ -8904,13 +8905,13 @@ enum MHD_FIXED_ENUM_MHD_SET_ MHD_LibInfoFixedITCType /** - * The types of the TLS backend supported/available/enabled + * The types of the TLS (or TLS feature) backend supported/available/enabled * @note the enum can be extended in future versions with new members */ struct MHD_LibInfoTLSType { /** - * The TLS is supported/enabled. + * The TLS (or TLS feature) is supported/enabled. * Set to #MHD_YES if any other member is #MHD_YES. */ enum MHD_Bool tls_supported; @@ -8930,40 +8931,129 @@ struct MHD_LibInfoTLSType union MHD_LibInfoFixedData { /** - * The 32-bit unsigned integer value + * The data for the #MHD_LIB_INFO_FIXED_VERSION_NUM query */ - uint_fast32_t v_uint32; + uint_fast32_t v_version_num_uint32; /** - * The MHD string value + * The data for the #MHD_LIB_INFO_FIXED_VERSION_STR query */ - struct MHD_String v_string; + struct MHD_String v_version_string; /** - * The boolean value + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_LOG_MESSAGES query */ - enum MHD_Bool v_bool; + enum MHD_Bool v_support_log_messages_bool; /** - * The type of digest algorithm implementation + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_AUTO_REPLIES_BODIES query */ - enum MHD_LibInfoFixedDigestAlgoType v_d_algo; + enum MHD_Bool v_support_auto_replies_bodies_bool; /** - * The types of the sockets polling functions/techniques supported by this MHD - * build. - * Some functions can be disabled (like epoll) in kernel, this is not - * checked. + * The data for the #MHD_LIB_INFO_FIXED_IS_NON_DEBUG query + */ + enum MHD_Bool v_is_non_debug_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_THREADS query + */ + enum MHD_Bool v_support_threads_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_COOKIE_PARSER query + */ + enum MHD_Bool v_support_cookie_parser_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_POST_PARSER query + */ + enum MHD_Bool v_support_post_parser_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_UPGRADE query + */ + enum MHD_Bool v_support_upgrade_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_AUTH_BASIC query + */ + enum MHD_Bool v_support_auth_basic_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_AUTH_DIGEST query + */ + enum MHD_Bool v_support_auth_digest_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_RFC2069 query */ - struct MHD_LibInfoFixedPollingFunc v_polling; + enum MHD_Bool v_support_digest_auth_rfc2069_bool; /** - * The type of IPv6 supported + * The data for the #MHD_LIB_INFO_FIXED_TYPE_DIGEST_AUTH_MD5 query + */ + enum MHD_LibInfoFixedDigestAlgoType v_type_digest_auth_md5_algo_type; + /** + * The data for the #MHD_LIB_INFO_FIXED_TYPE_DIGEST_AUTH_SHA256 query + */ + enum MHD_LibInfoFixedDigestAlgoType v_type_digest_auth_sha256_algo_type; + /** + * The data for the #MHD_LIB_INFO_FIXED_TYPE_DIGEST_AUTH_SHA512_256 query + */ + enum MHD_LibInfoFixedDigestAlgoType v_type_digest_auth_sha512_256_algo_type; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_AUTH_INT query + */ + enum MHD_Bool v_support_digest_auth_auth_int_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_ALGO_SESSION query + */ + enum MHD_Bool v_support_digest_auth_algo_session_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_USERHASH query + */ + enum MHD_Bool v_support_digest_auth_userhash_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_TYPES_SOCKETS_POLLING query + */ + struct MHD_LibInfoFixedPollingFunc v_types_sockets_polling; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_AGGREGATE_FD query + */ + enum MHD_Bool v_support_aggregate_fd_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_TYPE_IPV6 query */ enum MHD_LibInfoFixedIPv6Type v_ipv6; /** - * The type of inter-thread communication + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_TCP_FASTOPEN query */ - enum MHD_LibInfoFixedITCType v_itc; + enum MHD_Bool v_support_tcp_fastopen_bool; /** - * The types of the TLS backend supported by the build + * The data for the #MHD_LIB_INFO_FIXED_HAS_AUTODETECT_BIND_PORT query */ - struct MHD_LibInfoTLSType v_tls; + enum MHD_Bool v_has_autodetect_bind_port_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_HAS_SENDFILE query + */ + enum MHD_Bool v_has_sendfile_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_HAS_AUTOSUPPRESS_SIGPIPE_INT query + */ + enum MHD_Bool v_has_autosuppress_sigpipe_int_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_HAS_AUTOSUPPRESS_SIGPIPE_EXT query + */ + enum MHD_Bool v_has_autosuppress_sigpipe_ext_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_HAS_THREAD_NAMES query + */ + enum MHD_Bool v_has_thread_names_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_TYPE_ITC query + */ + enum MHD_LibInfoFixedITCType v_type_itc; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_LARGE_FILE query + */ + enum MHD_Bool v_support_large_file_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_TLS_BACKENDS query + */ + struct MHD_LibInfoTLSType v_tls_backends; + /** + * The data for the #MHD_LIB_INFO_FIXED_TLS_KEY_PASSWORD_BACKENDS query + */ + struct MHD_LibInfoTLSType v_tls_key_password_backends; }; /** @@ -9035,32 +9125,15 @@ MHD_STATIC_INLINE_ MHD_FN_PURE_ uint_fast32_t MHD_lib_get_info_ver_num (void) { union MHD_LibInfoFixedData data; - data.v_uint32 = 0; /* Not really necessary */ + data.v_version_num_uint32 = 0; /* Not really necessary */ (void) MHD_lib_get_info_fixed (MHD_LIB_INFO_FIXED_VERSION_NUM, \ &data); /* Never fail */ - return data.v_uint32; + return data.v_version_num_uint32; } MHD_STATIC_INLINE_END_ -/** - * Get the fixed boolean information about the library. - * @param info the type of requested information, must be the value with - * the boolean resulting data; behaviour is undefined if other - * types of requested information is used - * @return #MHD_YES or #MHD_NO - */ -MHD_STATIC_INLINE_ MHD_FN_PURE_ enum MHD_Bool -MHD_lib_get_fixed_info_bool (enum MHD_LibInfoFixed info_type) -{ - union MHD_LibInfoFixedData data; - (void) MHD_lib_get_info_fixed (info_type, \ - &data); /* Never fail */ - return data.v_bool; -} - -MHD_STATIC_INLINE_END_ #endif /* ! MHD_NO_STATIC_INLINE */ /** diff --git a/src/include/microhttpd2_main.h.in b/src/include/microhttpd2_main.h.in @@ -3914,15 +3914,15 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed /** * Get the MHD version as a number. - * The result is placed in @a v_uint32 member. + * The result is placed in @a v_version_num_uint32 member. */ MHD_LIB_INFO_FIXED_VERSION_NUM = 0 , /** * Get the MHD version as a string. - * The result is placed in @a v_string member. + * The result is placed in @a v_version_string member. */ - MHD_LIB_INFO_FIXED_VERSION_STR = 1 + MHD_LIB_INFO_FIXED_VERSION_STRING = 1 , /* * Basic MHD features, buid-time configurable * */ @@ -3933,63 +3933,63 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed /** * Get whether messages are supported. If supported then messages can be * printed to stderr or to an external logger. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_log_messages_bool member. */ - MHD_LIB_INFO_FIXED_HAS_LOG_MESSAGES = 11 + MHD_LIB_INFO_FIXED_SUPPORT_LOG_MESSAGES = 11 , /** * Get whether detailed automatic HTTP reply messages are supported. - * If supported then automatic responses have bodies with text expalining + * If supported then automatic responses have bodies with text explaining * the error details. * Automatic responses are sent by MHD automatically when client is violating * HTTP specification, for example, the request header has whitespace in * header name or request's "Content-Length" header has non-number value. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_auto_replies_bodies_bool member. */ - MHD_LIB_INFO_FIXED_HAS_AUTO_REPLIES_BODIES = 12 + MHD_LIB_INFO_FIXED_SUPPORT_AUTO_REPLIES_BODIES = 12 , /** * Get whether MHD was built with debug asserts disabled. * These asserts enabled only on special debug builds. * For debug builds the error log is always enabled. - * The result is placed in @a v_bool member. + * The result is placed in @a v_is_non_debug_bool member. */ MHD_LIB_INFO_FIXED_IS_NON_DEBUG = 13 , /** * Get whether MHD supports threads. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_threads_bool member. */ - MHD_LIB_INFO_FIXED_HAS_THREADS = 14 + MHD_LIB_INFO_FIXED_SUPPORT_THREADS = 14 , /** * Get whether automatic parsing of HTTP Cookie header is supported. * If disabled, no #MHD_VK_COOKIE will be generated by MHD. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_cookie_parser_bool member. */ - MHD_LIB_INFO_FIXED_HAS_COOKIE_PARSER = 15 + MHD_LIB_INFO_FIXED_SUPPORT_COOKIE_PARSER = 15 , /** * Get whether postprocessor is supported. If supported then * #MHD_action_post_processor() can be used. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_post_parser_bool member. */ - MHD_LIB_INFO_FIXED_HAS_POST_PARSER = 16 + MHD_LIB_INFO_FIXED_SUPPORT_POST_PARSER = 16 , /** * Get whether HTTP "Upgrade" is supported. * If supported then #MHD_action_upgrade() can be used. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_upgrade_bool member. */ - MHD_LIB_INFO_FIXED_HAS_UPGRADE = 17 + MHD_LIB_INFO_FIXED_SUPPORT_UPGRADE = 17 , /** * Get whether HTTP Basic authorization is supported. If supported * then functions #MHD_action_basic_auth_required_response () * and #MHD_REQUEST_INFO_DYNAMIC_AUTH_BASIC_CREDS can be used. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_auth_basic_bool member. */ - MHD_LIB_INFO_FIXED_HAS_AUTH_BASIC = 20 + MHD_LIB_INFO_FIXED_SUPPORT_AUTH_BASIC = 20 , /** * Get whether HTTP Digest authorization is supported. If @@ -3997,24 +3997,24 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * #MHD_D_O_DAUTH_MAP_SIZE and functions * #MHD_action_digest_auth_required_response () and * #MHD_digest_auth_check() can be used. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_auth_digest_bool member. */ - MHD_LIB_INFO_FIXED_HAS_AUTH_DIGEST = 21 + MHD_LIB_INFO_FIXED_SUPPORT_AUTH_DIGEST = 21 , /** * Get whether the early version the Digest Authorization (RFC 2069) is * supported (digest authorisation without QOP parameter). * Currently it is always supported if Digest Auth module is built. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_digest_auth_rfc2069_bool member. */ - MHD_LIB_INFO_FIXED_HAS_DIGEST_AUTH_RFC2069 = 22 + MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_RFC2069 = 22 , /** * Get whether the MD5-based hashing algorithms are supported for Digest * Authorization and the type of the implementation if supported. * Currently it is always supported if Digest Auth module is built * unless manually disabled in a custom build. - * The result is placed in @a v_d_algo member. + * The result is placed in @a v_type_digest_auth_md5_algo_type member. */ MHD_LIB_INFO_FIXED_TYPE_DIGEST_AUTH_MD5 = 23 , @@ -4023,7 +4023,7 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * Authorization and the type of the implementation if supported. * Currently it is always supported if Digest Auth module is built * unless manually disabled in a custom build. - * The result is placed in @a v_d_algo member. + * The result is placed in @a v_type_digest_auth_sha256_algo_type member. */ MHD_LIB_INFO_FIXED_TYPE_DIGEST_AUTH_SHA256 = 24 , @@ -4032,7 +4032,7 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * Authorization and the type of the implementation if supported. * Currently it is always supported if Digest Auth module is built * unless manually disabled in a custom build. - * The result is placed in @a v_d_algo member. + * The result is placed in @a v_type_digest_auth_sha512_256_algo_type member. */ MHD_LIB_INFO_FIXED_TYPE_DIGEST_AUTH_SHA512_256 = 25 , @@ -4040,24 +4040,24 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * Get whether QOP with value 'auth-int' (authentication with integrity * protection) is supported for Digest Authorization. * Currently it is always not supported. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_digest_auth_auth_int_bool member. */ - MHD_LIB_INFO_FIXED_HAS_DIGEST_AUTH_AUTH_INT = 28 + MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_AUTH_INT = 28 , /** * Get whether 'session' algorithms (like 'MD5-sess') are supported for Digest * Authorization. * Currently it is always not supported. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_digest_auth_algo_session_bool member. */ - MHD_LIB_INFO_FIXED_HAS_DIGEST_AUTH_ALGO_SESSION = 29 + MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_ALGO_SESSION = 29 , /** * Get whether 'userhash' is supported for Digest Authorization. * Currently it is always supported if Digest Auth module is built. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_digest_auth_userhash_bool member. */ - MHD_LIB_INFO_FIXED_HAS_DIGEST_AUTH_USERHASH = 30 + MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_USERHASH = 30 , /* * Platform-dependent features, some are configurable at build-time * */ @@ -4068,15 +4068,15 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * Get sockets polling functions/techniques supported by this MHD build. * Some functions can be disabled (like epoll) in kernel, this is not * checked. - * The result is placed in @a v_polling member. + * The result is placed in @a v_types_sockets_polling member. */ - MHD_LIB_INFO_FIXED_TYPE_SOCKETS_POLLING = 60 + MHD_LIB_INFO_FIXED_TYPES_SOCKETS_POLLING = 60 , /** * Get whether aggregate FD external polling is supported. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_aggregate_fd_bool member. */ - MHD_LIB_INFO_FIXED_HAS_AGGREGATE_FD = 61 + MHD_LIB_INFO_FIXED_SUPPORT_AGGREGATE_FD = 61 , /** * Get whether IPv6 is supported on the platform and IPv6-only listen socket @@ -4090,21 +4090,21 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed /** * Get whether TCP Fast Open is supported by MHD build. * If supported then option #MHD_D_O_TCP_FASTOPEN can be used. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_tcp_fastopen_bool member. */ - MHD_LIB_INFO_FIXED_HAS_TCP_FASTOPEN = 64 + MHD_LIB_INFO_FIXED_SUPPORT_TCP_FASTOPEN = 64 , /** * Get whether MHD support automatic detection of bind port number. * @sa #MHD_D_O_BIND_PORT - * The result is placed in @a v_bool member. + * The result is placed in @a v_has_autodetect_bind_port_bool member. */ MHD_LIB_INFO_FIXED_HAS_AUTODETECT_BIND_PORT = 65 , /** * Get whether MHD use system's sendfile() function to send * file-FD based responses over non-TLS connections. - * The result is placed in @a v_bool member. + * The result is placed in @a v_has_sendfile_bool member. */ MHD_LIB_INFO_FIXED_HAS_SENDFILE = 66 , @@ -4114,7 +4114,7 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * If SIGPIPE suppression is not supported, application must handle * SIGPIPE signal by itself whem using MHD with internal events loop. * If the platform does not have SIGPIPE the result is #MHD_YES. - * The result is placed in @a v_bool member. + * The result is placed in @a v_has_autosuppress_sigpipe_int_bool member. */ MHD_LIB_INFO_FIXED_HAS_AUTOSUPPRESS_SIGPIPE_INT = 80 , @@ -4124,19 +4124,19 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * If SIGPIPE suppression is not supported, application must handle * SIGPIPE signal by itself whem using MHD with external events loop. * If the platform does not have SIGPIPE the result is #MHD_YES. - * The result is placed in @a v_bool member. + * The result is placed in @a v_has_autosuppress_sigpipe_ext_bool member. */ MHD_LIB_INFO_FIXED_HAS_AUTOSUPPRESS_SIGPIPE_EXT = 81 , /** * Get whether MHD sets names on generated threads. - * The result is placed in @a v_bool member. + * The result is placed in @a v_has_thread_names_bool member. */ MHD_LIB_INFO_FIXED_HAS_THREAD_NAMES = 82 , /** * Get the type of supported inter-thread communication. - * The result is placed in @a v_itc member. + * The result is placed in @a v_type_itc member. */ MHD_LIB_INFO_FIXED_TYPE_ITC = 83 , @@ -4145,9 +4145,9 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed * If supported then #MHD_response_from_fd() can be used with sizes and * offsets larger than 2 GiB. If not supported value of size+offset could be * limited to 2 GiB. - * The result is placed in @a v_bool member. + * The result is placed in @a v_support_large_file_bool member. */ - MHD_LIB_INFO_FIXED_HAS_LARGE_FILE = 84 + MHD_LIB_INFO_FIXED_SUPPORT_LARGE_FILE = 84 , /* * Platform-dependent features, some set on startup and some are @@ -4159,17 +4159,18 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoFixed /** * Get whether HTTPS and which types of TLS backend(s) supported by * this build. - * The result is placed in @a v_tls member. + * The result is placed in @a v_tls_backends member. */ - MHD_LIB_INFO_FIXED_TYPE_TLS = 100 + MHD_LIB_INFO_FIXED_TLS_BACKENDS = 100 , /** * Get whether password encrypted private key for HTTPS daemon is - * supported. If supported then option #MHD_D_OPTION_TLS_KEY_CERT - * can be used with non-NULL @a mem_pass. - * The result is placed in @a v_tls member. + * supported by TLS backends. + * If supported then option #MHD_D_OPTION_TLS_KEY_CERT can be used with + * non-NULL @a mem_pass. + * The result is placed in @a v_tls_key_password_backends member. */ - MHD_LIB_INFO_FIXED_HAS_TLS_KEY_PASSWORD = 102 + MHD_LIB_INFO_FIXED_TLS_KEY_PASSWORD_BACKENDS = 102 , /* * Sentinel * */ @@ -4282,13 +4283,13 @@ enum MHD_FIXED_ENUM_MHD_SET_ MHD_LibInfoFixedITCType /** - * The types of the TLS backend supported/available/enabled + * The types of the TLS (or TLS feature) backend supported/available/enabled * @note the enum can be extended in future versions with new members */ struct MHD_LibInfoTLSType { /** - * The TLS is supported/enabled. + * The TLS (or TLS feature) is supported/enabled. * Set to #MHD_YES if any other member is #MHD_YES. */ enum MHD_Bool tls_supported; @@ -4308,40 +4309,129 @@ struct MHD_LibInfoTLSType union MHD_LibInfoFixedData { /** - * The 32-bit unsigned integer value + * The data for the #MHD_LIB_INFO_FIXED_VERSION_NUM query */ - uint_fast32_t v_uint32; + uint_fast32_t v_version_num_uint32; /** - * The MHD string value + * The data for the #MHD_LIB_INFO_FIXED_VERSION_STR query */ - struct MHD_String v_string; + struct MHD_String v_version_string; /** - * The boolean value + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_LOG_MESSAGES query */ - enum MHD_Bool v_bool; + enum MHD_Bool v_support_log_messages_bool; /** - * The type of digest algorithm implementation + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_AUTO_REPLIES_BODIES query */ - enum MHD_LibInfoFixedDigestAlgoType v_d_algo; + enum MHD_Bool v_support_auto_replies_bodies_bool; /** - * The types of the sockets polling functions/techniques supported by this MHD - * build. - * Some functions can be disabled (like epoll) in kernel, this is not - * checked. + * The data for the #MHD_LIB_INFO_FIXED_IS_NON_DEBUG query + */ + enum MHD_Bool v_is_non_debug_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_THREADS query + */ + enum MHD_Bool v_support_threads_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_COOKIE_PARSER query + */ + enum MHD_Bool v_support_cookie_parser_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_POST_PARSER query + */ + enum MHD_Bool v_support_post_parser_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_UPGRADE query + */ + enum MHD_Bool v_support_upgrade_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_AUTH_BASIC query */ - struct MHD_LibInfoFixedPollingFunc v_polling; + enum MHD_Bool v_support_auth_basic_bool; /** - * The type of IPv6 supported + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_AUTH_DIGEST query + */ + enum MHD_Bool v_support_auth_digest_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_RFC2069 query + */ + enum MHD_Bool v_support_digest_auth_rfc2069_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_TYPE_DIGEST_AUTH_MD5 query + */ + enum MHD_LibInfoFixedDigestAlgoType v_type_digest_auth_md5_algo_type; + /** + * The data for the #MHD_LIB_INFO_FIXED_TYPE_DIGEST_AUTH_SHA256 query + */ + enum MHD_LibInfoFixedDigestAlgoType v_type_digest_auth_sha256_algo_type; + /** + * The data for the #MHD_LIB_INFO_FIXED_TYPE_DIGEST_AUTH_SHA512_256 query + */ + enum MHD_LibInfoFixedDigestAlgoType v_type_digest_auth_sha512_256_algo_type; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_AUTH_INT query + */ + enum MHD_Bool v_support_digest_auth_auth_int_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_ALGO_SESSION query + */ + enum MHD_Bool v_support_digest_auth_algo_session_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_USERHASH query + */ + enum MHD_Bool v_support_digest_auth_userhash_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_TYPES_SOCKETS_POLLING query + */ + struct MHD_LibInfoFixedPollingFunc v_types_sockets_polling; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_AGGREGATE_FD query + */ + enum MHD_Bool v_support_aggregate_fd_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_TYPE_IPV6 query */ enum MHD_LibInfoFixedIPv6Type v_ipv6; /** - * The type of inter-thread communication + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_TCP_FASTOPEN query */ - enum MHD_LibInfoFixedITCType v_itc; + enum MHD_Bool v_support_tcp_fastopen_bool; /** - * The types of the TLS backend supported by the build + * The data for the #MHD_LIB_INFO_FIXED_HAS_AUTODETECT_BIND_PORT query */ - struct MHD_LibInfoTLSType v_tls; + enum MHD_Bool v_has_autodetect_bind_port_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_HAS_SENDFILE query + */ + enum MHD_Bool v_has_sendfile_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_HAS_AUTOSUPPRESS_SIGPIPE_INT query + */ + enum MHD_Bool v_has_autosuppress_sigpipe_int_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_HAS_AUTOSUPPRESS_SIGPIPE_EXT query + */ + enum MHD_Bool v_has_autosuppress_sigpipe_ext_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_HAS_THREAD_NAMES query + */ + enum MHD_Bool v_has_thread_names_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_TYPE_ITC query + */ + enum MHD_LibInfoFixedITCType v_type_itc; + /** + * The data for the #MHD_LIB_INFO_FIXED_SUPPORT_LARGE_FILE query + */ + enum MHD_Bool v_support_large_file_bool; + /** + * The data for the #MHD_LIB_INFO_FIXED_TLS_BACKENDS query + */ + struct MHD_LibInfoTLSType v_tls_backends; + /** + * The data for the #MHD_LIB_INFO_FIXED_TLS_KEY_PASSWORD_BACKENDS query + */ + struct MHD_LibInfoTLSType v_tls_key_password_backends; }; /** @@ -4413,32 +4503,15 @@ MHD_STATIC_INLINE_ MHD_FN_PURE_ uint_fast32_t MHD_lib_get_info_ver_num (void) { union MHD_LibInfoFixedData data; - data.v_uint32 = 0; /* Not really necessary */ + data.v_version_num_uint32 = 0; /* Not really necessary */ (void) MHD_lib_get_info_fixed (MHD_LIB_INFO_FIXED_VERSION_NUM, \ &data); /* Never fail */ - return data.v_uint32; + return data.v_version_num_uint32; } MHD_STATIC_INLINE_END_ -/** - * Get the fixed boolean information about the library. - * @param info the type of requested information, must be the value with - * the boolean resulting data; behaviour is undefined if other - * types of requested information is used - * @return #MHD_YES or #MHD_NO - */ -MHD_STATIC_INLINE_ MHD_FN_PURE_ enum MHD_Bool -MHD_lib_get_fixed_info_bool (enum MHD_LibInfoFixed info_type) -{ - union MHD_LibInfoFixedData data; - (void) MHD_lib_get_info_fixed (info_type, \ - &data); /* Never fail */ - return data.v_bool; -} - -MHD_STATIC_INLINE_END_ #endif /* ! MHD_NO_STATIC_INLINE */ /** diff --git a/src/mhd2/lib_get_info.c b/src/mhd2/lib_get_info.c @@ -94,21 +94,20 @@ MHD_lib_get_info_fixed_sz (enum MHD_LibInfoFixed info_type, /* * Basic MHD information * */ case MHD_LIB_INFO_FIXED_VERSION_NUM: - if (sizeof(output_buf->v_uint32) > output_buf_size) + if (sizeof(output_buf->v_version_num_uint32) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #if ! MHD_VERSION #error MHD_VERSION is not defined #endif - output_buf->v_uint32 = (uint_fast32_t) MHD_VERSION; + output_buf->v_version_num_uint32 = (uint_fast32_t) MHD_VERSION; return MHD_SC_OK; - case MHD_LIB_INFO_FIXED_VERSION_STR: - if (sizeof(output_buf->v_string) <= output_buf_size) + case MHD_LIB_INFO_FIXED_VERSION_STRING: + if (sizeof(output_buf->v_version_string) <= output_buf_size) { #ifdef VERSION static const struct MHD_String ver_str = mhd_MSTR_INIT (VERSION); - output_buf->v_string.len = ver_str.len; - output_buf->v_string.cstr = ver_str.cstr; + output_buf->v_version_string = ver_str; return MHD_SC_OK; #else /* ! VERSION */ static char str_buf[10] = @@ -134,8 +133,8 @@ MHD_lib_get_info_fixed_sz (enum MHD_LibInfoFixed info_type, str_buf + 6); str_buf[8] = 0; } - output_buf->v_string.len = 8; - output_buf->v_string.cstr = str_buf; + output_buf->v_version_str_string.len = 8; + output_buf->v_version_str_string.cstr = str_buf; return MHD_SC_OK; #endif /* ! VERSION */ } @@ -143,169 +142,188 @@ MHD_lib_get_info_fixed_sz (enum MHD_LibInfoFixed info_type, /* * Basic MHD features, buid-time configurable * */ - case MHD_LIB_INFO_FIXED_HAS_LOG_MESSAGES: - if (sizeof(output_buf->v_bool) > output_buf_size) + case MHD_LIB_INFO_FIXED_SUPPORT_LOG_MESSAGES: + if (sizeof(output_buf->v_support_log_messages_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #ifdef MHD_SUPPORT_LOG_FUNCTIONALITY - output_buf->v_bool = MHD_YES; + output_buf->v_support_log_messages_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_support_log_messages_bool = MHD_NO; #endif return MHD_SC_OK; - case MHD_LIB_INFO_FIXED_HAS_AUTO_REPLIES_BODIES: - if (sizeof(output_buf->v_bool) > output_buf_size) + case MHD_LIB_INFO_FIXED_SUPPORT_AUTO_REPLIES_BODIES: + if (sizeof(output_buf->v_support_auto_replies_bodies_bool) > + output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #ifdef MHD_ENABLE_AUTO_MESSAGES_BODIES - output_buf->v_bool = MHD_YES; + output_buf->v_support_auto_replies_bodies_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_support_auto_replies_bodies_bool = MHD_NO; #endif return MHD_SC_OK; case MHD_LIB_INFO_FIXED_IS_NON_DEBUG: - if (sizeof(output_buf->v_bool) > output_buf_size) + if (sizeof(output_buf->v_is_non_debug_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #ifdef NDEBUG - output_buf->v_bool = MHD_YES; + output_buf->v_is_non_debug_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_is_non_debug_bool = MHD_NO; #endif return MHD_SC_OK; - case MHD_LIB_INFO_FIXED_HAS_THREADS: - if (sizeof(output_buf->v_bool) > output_buf_size) + case MHD_LIB_INFO_FIXED_SUPPORT_THREADS: + if (sizeof(output_buf->v_support_threads_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #ifdef MHD_SUPPORT_THREADS - output_buf->v_bool = MHD_YES; + output_buf->v_support_threads_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_support_threads_bool = MHD_NO; #endif return MHD_SC_OK; - case MHD_LIB_INFO_FIXED_HAS_COOKIE_PARSER: - if (sizeof(output_buf->v_bool) > output_buf_size) + case MHD_LIB_INFO_FIXED_SUPPORT_COOKIE_PARSER: + if (sizeof(output_buf->v_support_cookie_parser_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #ifdef MHD_SUPPORT_COOKIES - output_buf->v_bool = MHD_YES; + output_buf->v_support_cookie_parser_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_support_cookie_parser_bool = MHD_NO; #endif return MHD_SC_OK; - case MHD_LIB_INFO_FIXED_HAS_POST_PARSER: - if (sizeof(output_buf->v_bool) > output_buf_size) + case MHD_LIB_INFO_FIXED_SUPPORT_POST_PARSER: + if (sizeof(output_buf->v_support_post_parser_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #ifdef MHD_SUPPORT_POST_PARSER - output_buf->v_bool = MHD_YES; + output_buf->v_support_post_parser_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_support_post_parser_bool = MHD_NO; #endif return MHD_SC_OK; - case MHD_LIB_INFO_FIXED_HAS_UPGRADE: - if (sizeof(output_buf->v_bool) > output_buf_size) + case MHD_LIB_INFO_FIXED_SUPPORT_UPGRADE: + if (sizeof(output_buf->v_support_upgrade_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #ifdef MHD_SUPPORT_UPGRADE - output_buf->v_bool = MHD_YES; + output_buf->v_support_upgrade_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_support_upgrade_bool = MHD_NO; #endif return MHD_SC_OK; - case MHD_LIB_INFO_FIXED_HAS_AUTH_BASIC: - if (sizeof(output_buf->v_bool) > output_buf_size) + case MHD_LIB_INFO_FIXED_SUPPORT_AUTH_BASIC: + if (sizeof(output_buf->v_support_auth_basic_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #ifdef MHD_SUPPORT_AUTH_BASIC - output_buf->v_bool = MHD_YES; + output_buf->v_support_auth_basic_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_support_auth_basic_bool = MHD_NO; #endif return MHD_SC_OK; - case MHD_LIB_INFO_FIXED_HAS_AUTH_DIGEST: - case MHD_LIB_INFO_FIXED_HAS_DIGEST_AUTH_RFC2069: - case MHD_LIB_INFO_FIXED_HAS_DIGEST_AUTH_USERHASH: - if (sizeof(output_buf->v_bool) > output_buf_size) + case MHD_LIB_INFO_FIXED_SUPPORT_AUTH_DIGEST: + case MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_RFC2069: + case MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_USERHASH: + /* Simplified code: values of 'v_support_auth_digest_bool', + 'v_support_digest_auth_rfc2069_bool' and + 'v_support_digest_auth_userhash_bool' are always the same. + To minimise the code size, use only the first member. The application + gets correct resulting values for all members. */ + if (sizeof(output_buf->v_support_auth_digest_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #ifdef MHD_SUPPORT_AUTH_DIGEST - output_buf->v_bool = MHD_YES; + output_buf->v_support_auth_digest_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_support_auth_digest_bool = MHD_NO; #endif return MHD_SC_OK; case MHD_LIB_INFO_FIXED_TYPE_DIGEST_AUTH_MD5: - if (sizeof(output_buf->v_d_algo) > output_buf_size) + if (sizeof(output_buf->v_type_digest_auth_md5_algo_type) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #if ! defined(MHD_SUPPORT_MD5) - output_buf->v_d_algo = MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_NOT_AVAILABLE; + output_buf->v_type_digest_auth_md5_algo_type = + MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_NOT_AVAILABLE; #elif ! defined(MHD_MD5_EXTR) - output_buf->v_d_algo = MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_BUILT_IN; + output_buf->v_type_digest_auth_md5_algo_type = + MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_BUILT_IN; #elif ! defined(mhd_MD5_HAS_EXT_ERROR) - output_buf->v_d_algo = + output_buf->v_type_digest_auth_md5_algo_type = MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_EXTERNAL_NEVER_FAIL; #else - output_buf->v_d_algo = + output_buf->v_type_digest_auth_md5_algo_type = MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_EXTERNAL_MAY_FAIL; #endif return MHD_SC_OK; case MHD_LIB_INFO_FIXED_TYPE_DIGEST_AUTH_SHA256: - if (sizeof(output_buf->v_d_algo) > output_buf_size) + if (sizeof(output_buf->v_type_digest_auth_sha256_algo_type) > + output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #if ! defined(MHD_SUPPORT_SHA256) - output_buf->v_d_algo = MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_NOT_AVAILABLE; + output_buf->v_type_digest_auth_sha256_algo_type = + MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_NOT_AVAILABLE; #elif ! defined(MHD_SHA256_EXTR) - output_buf->v_d_algo = MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_BUILT_IN; + output_buf->v_type_digest_auth_sha256_algo_type = + MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_BUILT_IN; #elif ! defined(mhd_SHA256_HAS_EXT_ERROR) - output_buf->v_d_algo = + output_buf->v_type_digest_auth_sha256_algo_type = MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_EXTERNAL_NEVER_FAIL; #else - output_buf->v_d_algo = + output_buf->v_type_digest_auth_sha256_algo_type = MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_EXTERNAL_MAY_FAIL; #endif return MHD_SC_OK; case MHD_LIB_INFO_FIXED_TYPE_DIGEST_AUTH_SHA512_256: - if (sizeof(output_buf->v_d_algo) > output_buf_size) + if (sizeof(output_buf->v_type_digest_auth_sha512_256_algo_type) > + output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #if ! defined(MHD_SUPPORT_SHA512_256) - output_buf->v_d_algo = MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_NOT_AVAILABLE; + output_buf->v_type_digest_auth_sha512_256_algo_type = + MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_NOT_AVAILABLE; #elif ! defined(MHD_SHA512_256_EXTR) - output_buf->v_d_algo = MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_BUILT_IN; + output_buf->v_type_digest_auth_sha512_256_algo_type = + MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_BUILT_IN; #elif ! defined(mhd_SHA512_256_HAS_EXT_ERROR) - output_buf->v_d_algo = + output_buf->v_type_digest_auth_sha512_256_algo_type = MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_EXTERNAL_NEVER_FAIL; #else - output_buf->v_d_algo = + output_buf->v_type_digest_auth_sha512_256_algo_type = MHD_LIB_INFO_FIXED_DIGEST_ALGO_TYPE_EXTERNAL_MAY_FAIL; #endif return MHD_SC_OK; - case MHD_LIB_INFO_FIXED_HAS_DIGEST_AUTH_AUTH_INT: - case MHD_LIB_INFO_FIXED_HAS_DIGEST_AUTH_ALGO_SESSION: - if (sizeof(output_buf->v_bool) > output_buf_size) + case MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_AUTH_INT: + case MHD_LIB_INFO_FIXED_SUPPORT_DIGEST_AUTH_ALGO_SESSION: + /* Simplified code: values of 'v_support_digest_auth_auth_int_bool' and + 'v_support_digest_auth_algo_session_bool' are always the same. + To minimise the code size, use only the first member. The application + gets correct resulting values for all members. */ + if (sizeof(output_buf->v_support_digest_auth_auth_int_bool) > + output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; - output_buf->v_bool = MHD_NO; + output_buf->v_support_digest_auth_auth_int_bool = MHD_NO; return MHD_SC_OK; /* * Platform-dependent features, some are configurable at build-time * */ - case MHD_LIB_INFO_FIXED_TYPE_SOCKETS_POLLING: - if (sizeof(output_buf->v_polling) > output_buf_size) + case MHD_LIB_INFO_FIXED_TYPES_SOCKETS_POLLING: + if (sizeof(output_buf->v_types_sockets_polling) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #ifdef MHD_SUPPORT_SELECT - output_buf->v_polling.func_select = MHD_YES; + output_buf->v_types_sockets_polling.func_select = MHD_YES; #else - output_buf->v_polling.func_select = MHD_NO; + output_buf->v_types_sockets_polling.func_select = MHD_NO; #endif #ifdef MHD_SUPPORT_POLL - output_buf->v_polling.func_poll = MHD_YES; + output_buf->v_types_sockets_polling.func_poll = MHD_YES; #else - output_buf->v_polling.func_poll = MHD_NO; + output_buf->v_types_sockets_polling.func_poll = MHD_NO; #endif #ifdef MHD_SUPPORT_EPOLL - output_buf->v_polling.tech_epoll = MHD_YES; + output_buf->v_types_sockets_polling.tech_epoll = MHD_YES; #else - output_buf->v_polling.tech_epoll = MHD_NO; + output_buf->v_types_sockets_polling.tech_epoll = MHD_NO; #endif return MHD_SC_OK; - case MHD_LIB_INFO_FIXED_HAS_AGGREGATE_FD: - if (sizeof(output_buf->v_bool) > output_buf_size) + case MHD_LIB_INFO_FIXED_SUPPORT_AGGREGATE_FD: + if (sizeof(output_buf->v_support_aggregate_fd_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #ifdef MHD_SUPPORT_EPOLL - output_buf->v_bool = MHD_YES; + output_buf->v_support_aggregate_fd_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_support_aggregate_fd_bool = MHD_NO; #endif return MHD_SC_OK; case MHD_LIB_INFO_FIXED_TYPE_IPV6: @@ -319,113 +337,119 @@ MHD_lib_get_info_fixed_sz (enum MHD_LibInfoFixed info_type, output_buf->v_ipv6 = MHD_LIB_INFO_FIXED_IPV6_TYPE_IPV6_PURE; #endif return MHD_SC_OK; - case MHD_LIB_INFO_FIXED_HAS_TCP_FASTOPEN: - if (sizeof(output_buf->v_bool) > output_buf_size) + case MHD_LIB_INFO_FIXED_SUPPORT_TCP_FASTOPEN: + if (sizeof(output_buf->v_support_tcp_fastopen_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #ifdef HAVE_DCLR_TCP_FASTOPEN - output_buf->v_bool = MHD_YES; + output_buf->v_support_tcp_fastopen_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_support_tcp_fastopen_bool = MHD_NO; #endif return MHD_SC_OK; case MHD_LIB_INFO_FIXED_HAS_AUTODETECT_BIND_PORT: - if (sizeof(output_buf->v_bool) > output_buf_size) + if (sizeof(output_buf->v_has_autodetect_bind_port_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #ifdef MHD_USE_GETSOCKNAME - output_buf->v_bool = MHD_YES; + output_buf->v_has_autodetect_bind_port_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_has_autodetect_bind_port_bool = MHD_NO; #endif return MHD_SC_OK; case MHD_LIB_INFO_FIXED_HAS_SENDFILE: - if (sizeof(output_buf->v_bool) > output_buf_size) + if (sizeof(output_buf->v_has_sendfile_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #ifdef mhd_USE_SENDFILE - output_buf->v_bool = MHD_YES; + output_buf->v_has_sendfile_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_has_sendfile_bool = MHD_NO; #endif return MHD_SC_OK; case MHD_LIB_INFO_FIXED_HAS_AUTOSUPPRESS_SIGPIPE_INT: - if (sizeof(output_buf->v_bool) > output_buf_size) + if (sizeof(output_buf->v_has_autosuppress_sigpipe_int_bool) > + output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #if ! defined (mhd_SEND_SPIPE_SUPPRESS_NEEDED) - output_buf->v_bool = MHD_YES; + output_buf->v_has_autosuppress_sigpipe_int_bool = MHD_YES; #elif defined (mhd_SEND_SPIPE_SUPPRESS_POSSIBLE) \ || defined(mhd_HAVE_MHD_THREAD_BLOCK_SIGPIPE) - output_buf->v_bool = MHD_YES; + output_buf->v_has_autosuppress_sigpipe_int_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_has_autosuppress_sigpipe_int_bool = MHD_NO; #endif return MHD_SC_OK; case MHD_LIB_INFO_FIXED_HAS_AUTOSUPPRESS_SIGPIPE_EXT: - if (sizeof(output_buf->v_bool) > output_buf_size) + if (sizeof(output_buf->v_has_autosuppress_sigpipe_ext_bool) > + output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #if ! defined (mhd_SEND_SPIPE_SUPPRESS_NEEDED) - output_buf->v_bool = MHD_YES; + output_buf->v_has_autosuppress_sigpipe_ext_bool = MHD_YES; #elif defined (mhd_SEND_SPIPE_SUPPRESS_POSSIBLE) - output_buf->v_bool = MHD_YES; + output_buf->v_has_autosuppress_sigpipe_ext_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_has_autosuppress_sigpipe_ext_bool = MHD_NO; #endif return MHD_SC_OK; case MHD_LIB_INFO_FIXED_HAS_THREAD_NAMES: - if (sizeof(output_buf->v_bool) > output_buf_size) + if (sizeof(output_buf->v_has_thread_names_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #ifdef mhd_USE_THREAD_NAME - output_buf->v_bool = MHD_YES; + output_buf->v_has_thread_names_bool = MHD_YES; #else - output_buf->v_bool = MHD_NO; + output_buf->v_has_thread_names_bool = MHD_NO; #endif return MHD_SC_OK; case MHD_LIB_INFO_FIXED_TYPE_ITC: - if (sizeof(output_buf->v_itc) > output_buf_size) + if (sizeof(output_buf->v_type_itc) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #if ! defined(MHD_SUPPORT_THREADS) - output_buf->v_itc = MHD_LIB_INFO_FIXED_ITC_TYPE_NONE; + output_buf->v_type_itc = MHD_LIB_INFO_FIXED_ITC_TYPE_NONE; #elif defined(MHD_ITC_SOCKETPAIR_) - output_buf->v_itc = MHD_LIB_INFO_FIXED_ITC_TYPE_SOCKETPAIR; + output_buf->v_type_itc = MHD_LIB_INFO_FIXED_ITC_TYPE_SOCKETPAIR; #elif defined(MHD_ITC_PIPE_) - output_buf->v_itc = MHD_LIB_INFO_FIXED_ITC_TYPE_PIPE; + output_buf->v_type_itc = MHD_LIB_INFO_FIXED_ITC_TYPE_PIPE; #elif defined(MHD_ITC_EVENTFD_) - output_buf->v_itc = MHD_LIB_INFO_FIXED_ITC_TYPE_EVENTFD; + output_buf->v_type_itc = MHD_LIB_INFO_FIXED_ITC_TYPE_EVENTFD; #else #error The type of ITC is not defined #endif return MHD_SC_OK; - case MHD_LIB_INFO_FIXED_HAS_LARGE_FILE: - if (sizeof(output_buf->v_bool) > output_buf_size) + case MHD_LIB_INFO_FIXED_SUPPORT_LARGE_FILE: + if (sizeof(output_buf->v_support_large_file_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; #if ! defined(HAVE_PREAD) && defined(lseek64) - output_buf->v_bool = MHD_YES; + output_buf->v_support_large_file_bool = MHD_YES; #elif defined(HAVE_PREAD64) - output_buf->v_bool = MHD_YES; + output_buf->v_support_large_file_bool = MHD_YES; #elif defined(mhd_W32_NATIVE) - output_buf->v_bool = MHD_YES; + output_buf->v_support_large_file_bool = MHD_YES; #else - output_buf->v_bool = + output_buf->v_support_large_file_bool = (0x7FFFFFFFFFFFFFFF == ((off_t) 0x7FFFFFFFFFFFFFFF)) ? MHD_YES : MHD_NO; #endif return MHD_SC_OK; - case MHD_LIB_INFO_FIXED_TYPE_TLS: - case MHD_LIB_INFO_FIXED_HAS_TLS_KEY_PASSWORD: /* Both backends have support */ - if (sizeof(output_buf->v_tls) <= output_buf_size) + case MHD_LIB_INFO_FIXED_TLS_BACKENDS: + case MHD_LIB_INFO_FIXED_TLS_KEY_PASSWORD_BACKENDS: /* Both backends have support */ + /* Simplified code: values of 'v_tls_backends' and + 'v_tls_key_password_backends' are always the same. + To minimise the code size, use only the first member. The application + gets correct resulting values for all members. */ + if (sizeof(output_buf->v_tls_backends) <= output_buf_size) { #ifndef MHD_SUPPORT_HTTPS output_buf->v_tls.tls_supported = MHD_NO; output_buf->v_tls.backend_gnutls = MHD_NO; output_buf->v_tls.backend_openssl = MHD_NO; #else - output_buf->v_tls.tls_supported = MHD_YES; + output_buf->v_tls_backends.tls_supported = MHD_YES; # ifdef MHD_SUPPORT_GNUTLS - output_buf->v_tls.backend_gnutls = MHD_YES; + output_buf->v_tls_backends.backend_gnutls = MHD_YES; # else /* ! MHD_SUPPORT_GNUTLS */ output_buf->v_tls.backend_gnutls = MHD_NO; # endif /* ! MHD_SUPPORT_GNUTLS */ # ifdef MHD_SUPPORT_OPENSSL - output_buf->v_tls.backend_openssl = MHD_YES; + output_buf->v_tls_backends.backend_openssl = MHD_YES; # else /* ! MHD_SUPPORT_OPENSSL */ - output_buf->v_tls.backend_openssl = MHD_NO; + output_buf->v_tls_backends.backend_openssl = MHD_NO; # endif /* ! MHD_SUPPORT_OPENSSL */ #endif return MHD_SC_OK; diff --git a/src/tests/basic/test_lib_info_version.c b/src/tests/basic/test_lib_info_version.c @@ -125,26 +125,27 @@ test_macro2_vs_func_str (void) { union MHD_LibInfoFixedData info_data; - if (! tst_EXPECT_OK (MHD_lib_get_info_fixed (MHD_LIB_INFO_FIXED_VERSION_STR, \ - &info_data))) + if (! tst_EXPECT_OK (MHD_lib_get_info_fixed ( \ + MHD_LIB_INFO_FIXED_VERSION_STRING, \ + &info_data))) return 1; printf ("Checking VERSION macro vs " "MHD_lib_get_info_fixed (MHD_LIB_INFO_FIXED_VERSION_STR) " "function.\n"); - if (NULL == info_data.v_string.cstr) + if (NULL == info_data.v_version_string.cstr) { fprintf (stderr, "info_data.v_string.cstr is NULL.\n"); return 1; } - if (0 != strcmp (str_macro_ver, info_data.v_string.cstr)) + if (0 != strcmp (str_macro_ver, info_data.v_version_string.cstr)) { fprintf (stderr, "'%s' vs '%s' - FAILED.\n", - str_macro_ver, info_data.v_string.cstr); + str_macro_ver, info_data.v_version_string.cstr); return 1; } printf ("'%s' vs '%s' - success.\n", - str_macro_ver, info_data.v_string.cstr); + str_macro_ver, info_data.v_version_string.cstr); return 0; } @@ -157,8 +158,9 @@ test_func_str_vs_macro_bin (void) int res; union MHD_LibInfoFixedData info_data; - if (! tst_EXPECT_OK (MHD_lib_get_info_fixed (MHD_LIB_INFO_FIXED_VERSION_STR, \ - &info_data))) + if (! tst_EXPECT_OK (MHD_lib_get_info_fixed ( \ + MHD_LIB_INFO_FIXED_VERSION_STRING, \ + &info_data))) return 1; printf ("Checking MHD_lib_get_info_fixed(MHD_LIB_INFO_FIXED_VERSION_STR) " \ @@ -180,16 +182,16 @@ test_func_str_vs_macro_bin (void) exit (99); } - if (0 != strcmp (info_data.v_string.cstr, bin_print)) + if (0 != strcmp (info_data.v_version_string.cstr, bin_print)) { fprintf (stderr, "'%s' vs '0x%08lX' ('%s') - FAILED.\n", - info_data.v_string.cstr, + info_data.v_version_string.cstr, (unsigned long) bin_macro, bin_print); return 1; } printf ("'%s' vs '0x%08lX' ('%s') - success.\n", - info_data.v_string.cstr, + info_data.v_version_string.cstr, (unsigned long) bin_macro, bin_print); return 0; @@ -274,27 +276,28 @@ test_func_str_format (void) size_t ver_len; union MHD_LibInfoFixedData info_data; - if (! tst_EXPECT_OK (MHD_lib_get_info_fixed (MHD_LIB_INFO_FIXED_VERSION_STR, \ - &info_data))) + if (! tst_EXPECT_OK (MHD_lib_get_info_fixed ( \ + MHD_LIB_INFO_FIXED_VERSION_STRING, \ + &info_data))) return 1; printf ("Checking MHD_lib_get_info_fixed(MHD_LIB_INFO_FIXED_VERSION_STR) " \ "function resulting value format.\n"); - ver_len = strlen (info_data.v_string.cstr); + ver_len = strlen (info_data.v_version_string.cstr); - if (ver_len != info_data.v_string.len) + if (ver_len != info_data.v_version_string.len) { fprintf (stderr, "strlen(info_data.v_string.cstr) ('%lu') != " "info_data.v_string.len ('%lu') - FAILED.\n", (unsigned long) ver_len, - (unsigned long) info_data.v_string.len); + (unsigned long) info_data.v_version_string.len); return 1; } printf ("strlen(info_data.v_string.cstr) ('%lu') == " "info_data.v_string.len ('%lu') - success.\n", (unsigned long) ver_len, - (unsigned long) info_data.v_string.len); + (unsigned long) info_data.v_version_string.len); return 0; }