libmicrohttpd2

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

commit b74171436189b0f629de7a159bc5ee0ed2242322
parent 43e15438701e9372b41b7f38b7a753d88ba6c74f
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date:   Fri,  3 Jul 2026 19:23:29 +0200

Aligned status codes for MHD_Response processing

Diffstat:
Mdoc/manual/authentication.inc | 4++--
Msrc/include/microhttpd2.h | 12++++++------
Msrc/include/microhttpd2_main.h.in | 4++--
Msrc/include/microhttpd2_preamble.h.in | 8++++----
Msrc/include/options-generator.c | 2+-
Msrc/include/r_options.rec | 4++--
Msrc/mhd2/response_add_header.c | 4++--
Msrc/mhd2/response_auth_basic.c | 4++--
Msrc/mhd2/response_auth_digest.c | 4++--
Msrc/mhd2/response_set_options.c | 6+++---
10 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/doc/manual/authentication.inc b/doc/manual/authentication.inc @@ -98,7 +98,7 @@ The function returns @item @code{MHD_SC_RESP_POINTER_NULL} if @var{response} was set to @code{NULL}, @item @code{MHD_SC_RESP_HTTP_CODE_NOT_SUITABLE} is response status code is wrong, @item @code{MHD_SC_RESP_HEADER_VALUE_INVALID} if realm is zero-length or has CR or LF characters, -@item @code{MHD_SC_RESPONSE_HEADER_MEM_ALLOC_FAILED} if memory allocation failed, +@item @code{MHD_SC_RESP_HEADER_MEM_ALLOC_FAILED} if memory allocation failed, @item or possibly other error codes (that could be defined in the future) on failure. @end itemize @@ -301,7 +301,7 @@ The function returns @item @code{MHD_SC_RESP_POINTER_NULL} if @var{response} was set to @code{NULL}, @item @code{MHD_SC_RESP_HTTP_CODE_NOT_SUITABLE} is response status code is wrong, @item @code{MHD_SC_RESP_HEADER_VALUE_INVALID} if realm is zero-length or has CR or LF characters, -@item @code{MHD_SC_RESPONSE_HEADER_MEM_ALLOC_FAILED} if memory allocation failed, +@item @code{MHD_SC_RESP_HEADER_MEM_ALLOC_FAILED} if memory allocation failed, @item or possibly other error codes (that could be defined in the future) on failure. @end itemize @end deftypefun diff --git a/src/include/microhttpd2.h b/src/include/microhttpd2.h @@ -1395,23 +1395,23 @@ enum MHD_FIXED_ENUM_MHD_SET_ MHD_StatusCode /** * Failed to acquire response mutex lock */ - MHD_SC_RESPONSE_MUTEX_LOCK_FAILED = 50500 + MHD_SC_RESP_MUTEX_LOCK_FAILED = 50500 , /** * Failed to initialise response mutex */ - MHD_SC_RESPONSE_MUTEX_INIT_FAILED = 50501 + MHD_SC_RESP_MUTEX_INIT_FAILED = 50501 , /** * Unable to clear "reusable" flag. * One this flag set, it cannot be removed for the response lifetime. */ - MHD_SC_RESPONSE_CANNOT_CLEAR_REUSE = 50520 + MHD_SC_RESP_CANNOT_CLEAR_REUSE = 50520 , /** * Unable to allocate memory for the response header */ - MHD_SC_RESPONSE_HEADER_MEM_ALLOC_FAILED = 50540 + MHD_SC_RESP_HEADER_MEM_ALLOC_FAILED = 50540 , /** * Failed to switch TCP_NODELAY option for the socket @@ -8304,7 +8304,7 @@ MHD_FN_PAR_IN_SIZE_ (5, 4); * #MHD_SC_RESP_HTTP_CODE_NOT_SUITABLE is response status code is wrong, * #MHD_SC_RESP_HEADER_VALUE_INVALID if @a realm, @a opaque or @a domain * have wrong characters or zero length (for @a realm), - * #MHD_SC_RESPONSE_HEADER_MEM_ALLOC_FAILED if memory allocation failed, + * #MHD_SC_RESP_HEADER_MEM_ALLOC_FAILED if memory allocation failed, * or other error code if failed * @ingroup authentication */ @@ -8592,7 +8592,7 @@ MHD_STATIC_INLINE_END_ * #MHD_SC_RESP_HTTP_CODE_NOT_SUITABLE is response status code is wrong, * #MHD_SC_RESP_HEADER_VALUE_INVALID if realm is zero-length or has CR * or LF characters, - * #MHD_SC_RESPONSE_HEADER_MEM_ALLOC_FAILED if memory allocation failed, + * #MHD_SC_RESP_HEADER_MEM_ALLOC_FAILED if memory allocation failed, * or other error code if failed * @ingroup authentication */ diff --git a/src/include/microhttpd2_main.h.in b/src/include/microhttpd2_main.h.in @@ -3388,7 +3388,7 @@ MHD_FN_PAR_IN_SIZE_ (5, 4); * #MHD_SC_RESP_HTTP_CODE_NOT_SUITABLE is response status code is wrong, * #MHD_SC_RESP_HEADER_VALUE_INVALID if @a realm, @a opaque or @a domain * have wrong characters or zero length (for @a realm), - * #MHD_SC_RESPONSE_HEADER_MEM_ALLOC_FAILED if memory allocation failed, + * #MHD_SC_RESP_HEADER_MEM_ALLOC_FAILED if memory allocation failed, * or other error code if failed * @ingroup authentication */ @@ -3676,7 +3676,7 @@ MHD_STATIC_INLINE_END_ * #MHD_SC_RESP_HTTP_CODE_NOT_SUITABLE is response status code is wrong, * #MHD_SC_RESP_HEADER_VALUE_INVALID if realm is zero-length or has CR * or LF characters, - * #MHD_SC_RESPONSE_HEADER_MEM_ALLOC_FAILED if memory allocation failed, + * #MHD_SC_RESP_HEADER_MEM_ALLOC_FAILED if memory allocation failed, * or other error code if failed * @ingroup authentication */ diff --git a/src/include/microhttpd2_preamble.h.in b/src/include/microhttpd2_preamble.h.in @@ -1395,23 +1395,23 @@ enum MHD_FIXED_ENUM_MHD_SET_ MHD_StatusCode /** * Failed to acquire response mutex lock */ - MHD_SC_RESPONSE_MUTEX_LOCK_FAILED = 50500 + MHD_SC_RESP_MUTEX_LOCK_FAILED = 50500 , /** * Failed to initialise response mutex */ - MHD_SC_RESPONSE_MUTEX_INIT_FAILED = 50501 + MHD_SC_RESP_MUTEX_INIT_FAILED = 50501 , /** * Unable to clear "reusable" flag. * One this flag set, it cannot be removed for the response lifetime. */ - MHD_SC_RESPONSE_CANNOT_CLEAR_REUSE = 50520 + MHD_SC_RESP_CANNOT_CLEAR_REUSE = 50520 , /** * Unable to allocate memory for the response header */ - MHD_SC_RESPONSE_HEADER_MEM_ALLOC_FAILED = 50540 + MHD_SC_RESP_HEADER_MEM_ALLOC_FAILED = 50540 , /** * Failed to switch TCP_NODELAY option for the socket diff --git a/src/include/options-generator.c b/src/include/options-generator.c @@ -1112,7 +1112,7 @@ TOP: " {\n" " need_unlock = true;\n" " if (! mhd_mutex_lock(&response->reuse.settings_lock))\n" - " return MHD_SC_RESPONSE_MUTEX_LOCK_FAILED;\n" + " return MHD_SC_RESP_MUTEX_LOCK_FAILED;\n" " mhd_assert (1 == mhd_atomic_counter_get(&response->reuse.counter));\n" " if (response->frozen) /* Firm re-check under the lock */\n" " {\n" diff --git a/src/include/r_options.rec b/src/include/r_options.rec @@ -28,7 +28,7 @@ CustomSetter: /* custom setter */ + { + if (MHD_NO == option->val.reusable) + { -+ res = MHD_SC_RESPONSE_CANNOT_CLEAR_REUSE; ++ res = MHD_SC_RESP_CANNOT_CLEAR_REUSE; + i = options_max_num - 1; + break; + } @@ -36,7 +36,7 @@ CustomSetter: /* custom setter */ + else if ((MHD_NO != option->val.reusable) && + (! response_make_reusable(response))) + { -+ res = MHD_SC_RESPONSE_MUTEX_INIT_FAILED; ++ res = MHD_SC_RESP_MUTEX_INIT_FAILED; + i = options_max_num - 1; + break; + } diff --git a/src/mhd2/response_add_header.c b/src/mhd2/response_add_header.c @@ -262,7 +262,7 @@ response_add_header_int (struct MHD_Response *restrict response, if (! response_add_header_no_check (response, name_len, name, value_len, value)) - return MHD_SC_RESPONSE_HEADER_MEM_ALLOC_FAILED; + return MHD_SC_RESP_HEADER_MEM_ALLOC_FAILED; return MHD_SC_OK; } @@ -287,7 +287,7 @@ MHD_response_add_header (struct MHD_Response *MHD_RESTRICT response, { need_unlock = true; if (! mhd_mutex_lock (&(response->reuse.settings_lock))) - return MHD_SC_RESPONSE_MUTEX_LOCK_FAILED; + return MHD_SC_RESP_MUTEX_LOCK_FAILED; mhd_assert (1 == mhd_atomic_counter_get (&(response->reuse.counter))); } else diff --git a/src/mhd2/response_auth_basic.c b/src/mhd2/response_auth_basic.c @@ -93,7 +93,7 @@ response_add_auth_basic_challenge_int (struct MHD_Response *restrict response, + hdr_name.len + 1 + hval_maxlen + 1); if (NULL == new_hdr) - return MHD_SC_RESPONSE_HEADER_MEM_ALLOC_FAILED; + return MHD_SC_RESP_HEADER_MEM_ALLOC_FAILED; /* Set the name of the header */ memcpy ((char *) (new_hdr + 1), @@ -177,7 +177,7 @@ MHD_response_add_auth_basic_challenge ( { need_unlock = true; if (! mhd_mutex_lock (&(response->reuse.settings_lock))) - return MHD_SC_RESPONSE_MUTEX_LOCK_FAILED; + return MHD_SC_RESP_MUTEX_LOCK_FAILED; mhd_assert (1 == mhd_atomic_counter_get (&(response->reuse.counter))); } else diff --git a/src/mhd2/response_auth_digest.c b/src/mhd2/response_auth_digest.c @@ -232,7 +232,7 @@ response_add_auth_digest_challenge_alg ( malloc (sizeof(struct mhd_RespAuthDigestHeader) + hdr_maxlen + 1); if (NULL == new_hdr) - return MHD_SC_RESPONSE_HEADER_MEM_ALLOC_FAILED; + return MHD_SC_RESP_HEADER_MEM_ALLOC_FAILED; hdr_str = (char *) (new_hdr + 1); /* ** Build the header ** */ @@ -527,7 +527,7 @@ MHD_response_add_auth_digest_challenge ( { need_unlock = true; if (! mhd_mutex_lock (&(response->reuse.settings_lock))) - return MHD_SC_RESPONSE_MUTEX_LOCK_FAILED; + return MHD_SC_RESP_MUTEX_LOCK_FAILED; mhd_assert (1 == mhd_atomic_counter_get (&(response->reuse.counter))); } else diff --git a/src/mhd2/response_set_options.c b/src/mhd2/response_set_options.c @@ -36,7 +36,7 @@ MHD_response_set_options ( { need_unlock = true; if (! mhd_mutex_lock(&response->reuse.settings_lock)) - return MHD_SC_RESPONSE_MUTEX_LOCK_FAILED; + return MHD_SC_RESP_MUTEX_LOCK_FAILED; mhd_assert (1 == mhd_atomic_counter_get(&response->reuse.counter)); if (response->frozen) /* Firm re-check under the lock */ { @@ -60,7 +60,7 @@ MHD_response_set_options ( { if (MHD_NO == option->val.reusable) { - res = MHD_SC_RESPONSE_CANNOT_CLEAR_REUSE; + res = MHD_SC_RESP_CANNOT_CLEAR_REUSE; i = options_max_num - 1; break; } @@ -68,7 +68,7 @@ MHD_response_set_options ( else if ((MHD_NO != option->val.reusable) && (! response_make_reusable(response))) { - res = MHD_SC_RESPONSE_MUTEX_INIT_FAILED; + res = MHD_SC_RESP_MUTEX_INIT_FAILED; i = options_max_num - 1; break; }