libmicrohttpd2

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

commit 199e7bb6c7e87fb9ac5c9607e620d8bb27dd665f
parent 977a39e189caa7b1532001b99b0d29de86c06709
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date:   Fri, 21 Mar 2025 20:24:50 +0300

Refactored MHD_lib_get_info_dynamic_sz() and relevant types

Resulting values now are individual for each query value.

Diffstat:
Msrc/include/microhttpd2.h | 33+++++++++++++++++++--------------
Msrc/include/microhttpd2_main.h.in | 33+++++++++++++++++++--------------
Msrc/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 @@ -9146,24 +9146,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 , @@ -9176,7 +9176,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 , @@ -9198,14 +9198,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 @@ -4524,24 +4524,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 , @@ -4554,7 +4554,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 , @@ -4576,14 +4576,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 @@ -478,24 +478,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; @@ -506,11 +506,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