[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 251/335: Implemented MHD_daemon_get_info_fixed_sz()
From: |
gnunet |
Subject: |
[libmicrohttpd] 251/335: Implemented MHD_daemon_get_info_fixed_sz() |
Date: |
Sat, 27 Jul 2024 22:02:27 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to tag stf-m2
in repository libmicrohttpd.
commit aa12afc69a70e109e1de1e56b2ddb5c6199a95f5
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Jul 21 15:41:04 2024 +0200
Implemented MHD_daemon_get_info_fixed_sz()
---
src/include/microhttpd2.h | 38 ++++++++++++++--
src/mhd2/Makefile.am | 1 +
src/mhd2/daemon_get_info.c | 87 +++++++++++++++++++++++++++++++++++++
src/tests/basic/test_basic_checks.c | 1 -
4 files changed, 123 insertions(+), 4 deletions(-)
diff --git a/src/include/microhttpd2.h b/src/include/microhttpd2.h
index 20bdd213..77df726c 100644
--- a/src/include/microhttpd2.h
+++ b/src/include/microhttpd2.h
@@ -1292,6 +1292,41 @@ enum MHD_FIXED_ENUM_MHD_SET_ MHD_StatusCode
* The "Content-Length" header is not allowed in the reply
*/
MHD_SC_REPLY_CONTENT_LENGTH_NOT_ALLOWED = 60102
+ ,
+ /**
+ * The requested type of information is not recognised.
+ */
+ MHD_SC_INFO_TYPE_UNKNOWN = 60200
+ ,
+ /**
+ * The requested type of information is not recognised.
+ */
+ MHD_SC_INFO_GET_INFO_TYPE_UNKNOWN = 60200
+ ,
+ /**
+ * The information of the requested type is too large to fit into
+ * the provided buffer.
+ */
+ MHD_SC_INFO_GET_BUFF_TOO_SMALL = 60201
+ ,
+ /**
+ * The type of the information is not supported by this MHD build.
+ * It can be information not supported on the current platform or related
+ * to feature disabled for this build.
+ */
+ MHD_SC_INFO_GET_TYPE_NOT_SUPP_BY_BUILD = 60202
+ ,
+ /**
+ * The type of the information is not available due to configuration
+ * or state of the object.
+ */
+ MHD_SC_INFO_GET_TYPE_UNSUPPORTED = 60203
+ ,
+ /**
+ * The type of the information should be available for the object, but
+ * cannot be provided due to some error or other reasons.
+ */
+ MHD_SC_INFO_GET_TYPE_UNAVAILALBE = 60204
};
@@ -8991,7 +9026,4 @@ MHD_lib_set_panic_func (MHD_PanicCallback cb,
MHD_lib_set_panic_func (MHD_STATIC_CAST_ (MHD_PanicCallback,NULL),NULL)
MHD_C_DECLRATIONS_FINISH_HERE_
-MHD_EXTERN_ void
-MHD_lib_global_fake (void);
-
#endif /* ! MICROHTTPD2_H */
diff --git a/src/mhd2/Makefile.am b/src/mhd2/Makefile.am
index f43f5f09..a95081f1 100644
--- a/src/mhd2/Makefile.am
+++ b/src/mhd2/Makefile.am
@@ -64,6 +64,7 @@ libmicrohttpd2_la_SOURCES = \
daemon_options.h daemon_set_options.c \
daemon_create.c \
daemon_start.c \
+ daemon_get_info.c \
daemon_add_conn.c daemon_add_conn.h \
daemon_funcs.c daemon_funcs.h \
conn_data_process.c conn_data_process.h \
diff --git a/src/mhd2/daemon_get_info.c b/src/mhd2/daemon_get_info.c
new file mode 100644
index 00000000..02a40b4e
--- /dev/null
+++ b/src/mhd2/daemon_get_info.c
@@ -0,0 +1,87 @@
+/*
+ This file is part of GNU libmicrohttpd
+ Copyright (C) 2024 Evgeny Grin (Karlson2k)
+
+ GNU libmicrohttpd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ GNU libmicrohttpd is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
+
+*/
+
+/**
+ * @file src/mhd2/daemon_get_info.c
+ * @brief The implementation of MHD_daemon_get_info_*() functions
+ * @author Karlson2k (Evgeny Grin)
+ */
+
+#include "mhd_sys_options.h"
+
+#include "sys_base_types.h"
+#include "sys_sockets_types.h"
+
+#include "mhd_socket_type.h"
+#include "mhd_daemon.h"
+
+#include "mhd_public_api.h"
+
+MHD_EXTERN_
+MHD_FN_PAR_NONNULL_ (1)
+MHD_FN_PAR_NONNULL_ (3) MHD_FN_PAR_OUT_ (3)
+MHD_FN_PURE_ enum MHD_StatusCode
+MHD_daemon_get_info_fixed_sz (struct MHD_Daemon *daemon,
+ enum MHD_DaemonInfoFixedType info_type,
+ union MHD_DaemonInfoFixedData *return_value,
+ size_t return_value_size)
+{
+ switch (info_type)
+ {
+ case MHD_DAEMON_INFO_FIXED_LISTEN_SOCKET:
+ if (MHD_INVALID_SOCKET == daemon->net.listen.fd)
+ return MHD_SC_INFO_GET_TYPE_UNSUPPORTED;
+ if (sizeof(MHD_Socket) > return_value_size)
+ return MHD_SC_INFO_GET_BUFF_TOO_SMALL;
+ return_value->v_socket = daemon->net.listen.fd;
+ return MHD_SC_OK;
+ case MHD_DAEMON_INFO_FIXED_AGGREAGATE_FD:
+#ifdef MHD_USE_EPOLL
+ if (! mhd_D_IS_USING_EPOLL (daemon))
+ return MHD_SC_INFO_GET_TYPE_UNSUPPORTED;
+ if (sizeof(int) > return_value_size)
+ return MHD_SC_INFO_GET_BUFF_TOO_SMALL;
+ return_value->v_fd = daemon->events.data.epoll.e_fd;
+ return MHD_SC_OK;
+#else
+ return MHD_SC_INFO_GET_TYPE_NOT_SUPP_BY_BUILD;
+#endif
+ break;
+ case MHD_DAEMON_INFO_FIXED_BIND_PORT:
+ if (MHD_INVALID_SOCKET == daemon->net.listen.fd)
+ return MHD_SC_INFO_GET_TYPE_UNSUPPORTED;
+ if (mhd_SOCKET_TYPE_UNKNOWN > daemon->net.listen.type)
+ return MHD_SC_INFO_GET_TYPE_UNSUPPORTED;
+ if (0 == daemon->net.listen.port)
+ {
+ if (mhd_SOCKET_TYPE_IP != daemon->net.listen.type)
+ return MHD_SC_INFO_GET_TYPE_UNSUPPORTED;
+ return MHD_SC_INFO_GET_TYPE_UNAVAILALBE;
+ }
+ if (sizeof(return_value->v_port) > return_value_size)
+ return MHD_SC_INFO_GET_BUFF_TOO_SMALL;
+ return_value->v_port = daemon->net.listen.port;
+ return MHD_SC_OK;
+ case MHD_DAEMON_INFO_FIXED_SENTINEL:
+ default:
+ break;
+ }
+ return MHD_SC_INFO_TYPE_UNKNOWN;
+}
diff --git a/src/tests/basic/test_basic_checks.c
b/src/tests/basic/test_basic_checks.c
index 9f498a50..1db7f3ad 100644
--- a/src/tests/basic/test_basic_checks.c
+++ b/src/tests/basic/test_basic_checks.c
@@ -146,7 +146,6 @@ my_req_process (void *cls,
uint_fast64_t upload_size)
{
(void) cls; (void) request; (void) path; (void) method; (void) upload_size;
- // MHD_lib_global_fake();
fprintf (stderr, "Unexpected call of the request callback.\n");
err_flag = ! 0;
return NULL;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] 212/335: configure: check for uintptr_t type, (continued)
- [libmicrohttpd] 212/335: configure: check for uintptr_t type, gnunet, 2024/07/27
- [libmicrohttpd] 214/335: configure: added check for various levels of compound literals support, gnunet, 2024/07/27
- [libmicrohttpd] 243/335: Copy-paste fixes, gnunet, 2024/07/27
- [libmicrohttpd] 225/335: Still WIP, gnunet, 2024/07/27
- [libmicrohttpd] 242/335: Fixes, gnunet, 2024/07/27
- [libmicrohttpd] 245/335: WIP-4, gnunet, 2024/07/27
- [libmicrohttpd] 231/335: WIP more, gnunet, 2024/07/27
- [libmicrohttpd] 235/335: GNU/Linux fixes, gnunet, 2024/07/27
- [libmicrohttpd] 237/335: GNU/Linux fixes-3, gnunet, 2024/07/27
- [libmicrohttpd] 236/335: More GNU/Linux fixes, gnunet, 2024/07/27
- [libmicrohttpd] 251/335: Implemented MHD_daemon_get_info_fixed_sz(),
gnunet <=
- [libmicrohttpd] 246/335: WIP-5, gnunet, 2024/07/27
- [libmicrohttpd] 224/335: Minor update, gnunet, 2024/07/27
- [libmicrohttpd] 253/335: fix issues in test logic, gnunet, 2024/07/27
- [libmicrohttpd] 240/335: more example test code, gnunet, 2024/07/27
- [libmicrohttpd] 254/335: Fixed GET parameters parsing, gnunet, 2024/07/27
- [libmicrohttpd] 239/335: first test against test framework, gnunet, 2024/07/27
- [libmicrohttpd] 241/335: WIP-3, gnunet, 2024/07/27
- [libmicrohttpd] 248/335: WIP-5 fixes-2, gnunet, 2024/07/27
- [libmicrohttpd] 244/335: microhttpd2.h: improved URI and termination callbacks and related data, gnunet, 2024/07/27
- [libmicrohttpd] 252/335: expand test suite, gnunet, 2024/07/27