From 3f55902b83432121525ca4cb35f81ba35df5cfde Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Fri, 21 Mar 2025 20:24:50 +0300 Subject: [PATCH] Refactored MHD_lib_get_info_dynamic_sz() and relevant types Resulting values now are individual for each query value. --- src/include/microhttpd2.h | 33 ++++++++++++++++++------------- src/include/microhttpd2_main.h.in | 33 ++++++++++++++++++------------- src/mhd2/lib_get_info.c | 27 +++++++++++++------------ 3 files changed, 52 insertions(+), 41 deletions(-) diff --git a/src/include/microhttpd2.h b/src/include/microhttpd2.h index 6ca2c252..322d9430 100644 --- a/src/include/microhttpd2.h +++ b/src/include/microhttpd2.h @@ -9148,24 +9148,24 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoDynamic /** * Get whether MHD has been successfully fully initialised. - * MHD uses lazy initialisation: a minimal initialisation is perfomed at - * startup, complete initialisation is perfomed when any daemon is created - * (or called other function which requires full initialisation). + * MHD uses lazy initialisation: a minimal initialisation is performed at + * startup, complete initialisation is performed when any daemon is created + * (or when called some function which requires full initialisation). * The result is #MHD_NO when the library has been not yet initialised * completely since startup. - * The result is placed in @a v_bool member. + * The result is placed in @a v_inited_fully_once_bool member. */ MHD_LIB_INFO_DYNAMIC_INITED_FULLY_ONCE = 0 , /** - * Get whether MHD has been successfully fully initialised. - * MHD uses lazy initialisation: a minimal initialisation is perfomed at - * startup, complete initialisation is perfomed when any daemon is created - * (or called other function which requires full initialisation). + * Get whether MHD is fully initialised. + * MHD uses lazy initialisation: a minimal initialisation is performed at + * startup, complete initialisation is perfromed when any daemon is created + * (or when called some function which requires full initialisation). * The result is #MHD_YES if library is initialised state now (meaning * that at least one daemon is created and not destroyed or some function * required full initialisation is running). - * The result is placed in @a v_bool member. + * The result is placed in @a v_inited_fully_now_bool member. */ MHD_LIB_INFO_DYNAMIC_INITED_FULLY_NOW = 1 , @@ -9178,7 +9178,7 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoDynamic * enable backends to check for their availability. * If global library initialisation failed, the function returns * #MHD_SC_INFO_GET_TYPE_UNOBTAINABLE error code. - * The result is placed in @a v_tls member. + * The result is placed in @a v_tls_backends member. */ MHD_LIB_INFO_DYNAMIC_TYPE_TLS = 100 , @@ -9200,14 +9200,19 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoDynamic union MHD_LibInfoDynamicData { /** - * The boolean value + * The data for the #MHD_LIB_INFO_DYNAMIC_INITED_FULLY_ONCE query */ - enum MHD_Bool v_bool; + enum MHD_Bool v_inited_fully_once_bool; /** - * The types of the TLS backends available + * The data for the #MHD_LIB_INFO_DYNAMIC_INITED_FULLY_NOW query */ - struct MHD_LibInfoTLSType v_tls; + enum MHD_Bool v_inited_fully_now_bool; + + /** + * The data for the #MHD_LIB_INFO_DYNAMIC_TYPE_TLS query + */ + struct MHD_LibInfoTLSType v_tls_backends; /** * Unused member. diff --git a/src/include/microhttpd2_main.h.in b/src/include/microhttpd2_main.h.in index 864ffa97..faaba95c 100644 --- a/src/include/microhttpd2_main.h.in +++ b/src/include/microhttpd2_main.h.in @@ -4526,24 +4526,24 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoDynamic /** * Get whether MHD has been successfully fully initialised. - * MHD uses lazy initialisation: a minimal initialisation is perfomed at - * startup, complete initialisation is perfomed when any daemon is created - * (or called other function which requires full initialisation). + * MHD uses lazy initialisation: a minimal initialisation is performed at + * startup, complete initialisation is performed when any daemon is created + * (or when called some function which requires full initialisation). * The result is #MHD_NO when the library has been not yet initialised * completely since startup. - * The result is placed in @a v_bool member. + * The result is placed in @a v_inited_fully_once_bool member. */ MHD_LIB_INFO_DYNAMIC_INITED_FULLY_ONCE = 0 , /** - * Get whether MHD has been successfully fully initialised. - * MHD uses lazy initialisation: a minimal initialisation is perfomed at - * startup, complete initialisation is perfomed when any daemon is created - * (or called other function which requires full initialisation). + * Get whether MHD is fully initialised. + * MHD uses lazy initialisation: a minimal initialisation is performed at + * startup, complete initialisation is perfromed when any daemon is created + * (or when called some function which requires full initialisation). * The result is #MHD_YES if library is initialised state now (meaning * that at least one daemon is created and not destroyed or some function * required full initialisation is running). - * The result is placed in @a v_bool member. + * The result is placed in @a v_inited_fully_now_bool member. */ MHD_LIB_INFO_DYNAMIC_INITED_FULLY_NOW = 1 , @@ -4556,7 +4556,7 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoDynamic * enable backends to check for their availability. * If global library initialisation failed, the function returns * #MHD_SC_INFO_GET_TYPE_UNOBTAINABLE error code. - * The result is placed in @a v_tls member. + * The result is placed in @a v_tls_backends member. */ MHD_LIB_INFO_DYNAMIC_TYPE_TLS = 100 , @@ -4578,14 +4578,19 @@ enum MHD_FIXED_ENUM_APP_SET_ MHD_LibInfoDynamic union MHD_LibInfoDynamicData { /** - * The boolean value + * The data for the #MHD_LIB_INFO_DYNAMIC_INITED_FULLY_ONCE query */ - enum MHD_Bool v_bool; + enum MHD_Bool v_inited_fully_once_bool; /** - * The types of the TLS backends available + * The data for the #MHD_LIB_INFO_DYNAMIC_INITED_FULLY_NOW query */ - struct MHD_LibInfoTLSType v_tls; + enum MHD_Bool v_inited_fully_now_bool; + + /** + * The data for the #MHD_LIB_INFO_DYNAMIC_TYPE_TLS query + */ + struct MHD_LibInfoTLSType v_tls_backends; /** * Unused member. diff --git a/src/mhd2/lib_get_info.c b/src/mhd2/lib_get_info.c index 51cc7859..55776d72 100644 --- a/src/mhd2/lib_get_info.c +++ b/src/mhd2/lib_get_info.c @@ -470,24 +470,24 @@ MHD_lib_get_info_dynamic_sz ( switch (info_type) { case MHD_LIB_INFO_DYNAMIC_INITED_FULLY_ONCE: - if (sizeof(output_buf->v_bool) > output_buf_size) + if (sizeof(output_buf->v_inited_fully_once_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; - output_buf->v_bool = + output_buf->v_inited_fully_once_bool = mhd_lib_is_fully_initialised_once () ? MHD_YES : MHD_NO; return MHD_SC_OK; case MHD_LIB_INFO_DYNAMIC_INITED_FULLY_NOW: - if (sizeof(output_buf->v_bool) > output_buf_size) + if (sizeof(output_buf->v_inited_fully_now_bool) > output_buf_size) return MHD_SC_INFO_GET_BUFF_TOO_SMALL; - output_buf->v_bool = + output_buf->v_inited_fully_now_bool = mhd_lib_is_fully_initialised_now () ? MHD_YES : MHD_NO; return MHD_SC_OK; case MHD_LIB_INFO_DYNAMIC_TYPE_TLS: - if (sizeof(output_buf->v_tls) <= output_buf_size) + 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; + output_buf->v_tls_backends.tls_supported = MHD_NO; + output_buf->v_tls_backends.backend_gnutls = MHD_NO; + output_buf->v_tls_backends.backend_openssl = MHD_NO; #else bool gnutls_avail; bool openssl_avail; @@ -498,11 +498,12 @@ MHD_lib_get_info_dynamic_sz ( gnutls_avail = mhd_tls_gnu_is_inited_fine (); openssl_avail = mhd_tls_open_is_inited_fine (); - output_buf->v_tls.tls_supported = - (gnutls_avail || openssl_avail) ? - MHD_YES : MHD_NO; - output_buf->v_tls.backend_gnutls = gnutls_avail ? MHD_YES : MHD_NO; - output_buf->v_tls.backend_openssl = openssl_avail ? MHD_YES : MHD_NO; + output_buf->v_tls_backends.tls_supported = + (gnutls_avail || openssl_avail) ? MHD_YES : MHD_NO; + output_buf->v_tls_backends.backend_gnutls = + gnutls_avail ? MHD_YES : MHD_NO; + output_buf->v_tls_backends.backend_openssl = + openssl_avail ? MHD_YES : MHD_NO; mhd_lib_deinit_global_if_needed (); #endif