Refactored MHD_lib_get_info_dynamic_sz() and relevant types

Resulting values now are individual for each query value.
This commit is contained in:
Evgeny Grin (Karlson2k)
2025-03-22 15:21:32 +03:00
parent fe030395f6
commit 3f55902b83
3 changed files with 52 additions and 41 deletions
+19 -14
View File
@@ -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.
+19 -14
View File
@@ -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.
+14 -13
View File
@@ -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