Browse Source

mhd_socket_error: split into enum and functions

Evgeny Grin (Karlson2k) 1 year ago
parent
commit
9276899b29

+ 1 - 1
src/mhd2/Makefile.am

@@ -37,7 +37,7 @@ libmicrohttpd2_la_SOURCES = \
   mhd_tristate.h            mhd_status_code_int.h \
   mhd_socket_type.h         mhd_sockets_macros.h \
   mhd_sockets_funcs.c       mhd_sockets_funcs.h \
-  mhd_socket_error.c        mhd_socket_error.h \
+  mhd_socket_error_funcs.c  mhd_socket_error_funcs.h  mhd_socket_error.h \
   mhd_atomic_counter.c      mhd_atomic_counter.h \
   mhd_bool.h \
   mhd_str.c                 mhd_str.h \

+ 1 - 1
src/mhd2/mhd_recv.c

@@ -33,9 +33,9 @@
 #include "mhd_socket_type.h"
 #include "sys_sockets_headers.h"
 #include "mhd_sockets_macros.h"
+#include "mhd_socket_error_funcs.h"
 
 #include "mhd_limits.h"
-#include "mhd_socket_error.h"
 
 
 static MHD_FN_PAR_NONNULL_ALL_

+ 1 - 0
src/mhd2/mhd_send.c

@@ -44,6 +44,7 @@
 #include "sys_ip_headers.h"
 #include "mhd_sockets_macros.h"
 #include "daemon_logger.h"
+#include "mhd_socket_error_funcs.h"
 
 #include "mhd_daemon.h"
 #include "mhd_connection.h"

+ 1 - 20
src/mhd2/mhd_socket_error.h

@@ -20,8 +20,7 @@
 
 /**
  * @file src/mhd2/mhd_socket_error.h
- * @brief  The definition of the mhd_SocketError enum and related macros and
- *         declarations of related functions
+ * @brief  The definition of the mhd_SocketError enum and related macros
  * @author Karlson2k (Evgeny Grin)
  */
 
@@ -140,22 +139,4 @@ enum MHD_FIXED_ENUM_ mhd_SocketError
  */
 #define mhd_SOCKET_ERR_IS_BAD(err) (mhd_SOCKET_ERR_BADF <= (err))
 
-/**
- * Map recv() / send() system socket error to the enum value
- * @param socket_err the system socket error
- * @return the enum value for the @a socket_err
- */
-MHD_INTERNAL enum mhd_SocketError
-mhd_socket_error_get_from_sys_err (int socket_err);
-
-/**
- * Get the last socket error recoded for the given socket
- * @param fd the socket to check for the error
- * @return the recorded error @a fd,
- *         #mhd_SOCKET_ERR_NOT_CHECKED if not possible to check @a fd for
- *         the error
- */
-MHD_INTERNAL enum mhd_SocketError
-mhd_socket_error_get_from_socket (MHD_Socket fd);
-
 #endif /* ! MHD_SOCKET_ERROR_H */

+ 2 - 2
src/mhd2/mhd_socket_error.c → src/mhd2/mhd_socket_error_funcs.c

@@ -19,13 +19,13 @@
 */
 
 /**
- * @file src/mhd2/mhd_socket_error.c
+ * @file src/mhd2/mhd_socket_error_funcs.c
  * @brief  The definition of mhd_SocketError-related functions
  * @author Karlson2k (Evgeny Grin)
  */
 
 #include "mhd_sys_options.h"
-#include "mhd_socket_error.h"
+#include "mhd_socket_error_funcs.h"
 #include "sys_sockets_headers.h"
 #include "mhd_sockets_macros.h"
 #include "sys_sockets_types.h"

+ 53 - 0
src/mhd2/mhd_socket_error_funcs.h

@@ -0,0 +1,53 @@
+/*
+  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/mhd_socket_error_funcs.h
+ * @brief  The declarations of functions for getting enum mhd_SocketError values
+ * @author Karlson2k (Evgeny Grin)
+ */
+
+#ifndef MHD_SOCKET_ERROR_FUNCS_H
+#define MHD_SOCKET_ERROR_FUNCS_H 1
+
+#include "mhd_sys_options.h"
+
+#include "mhd_socket_type.h"
+#include "mhd_socket_error.h"
+
+/**
+ * Map recv() / send() system socket error to the enum value
+ * @param socket_err the system socket error
+ * @return the enum value for the @a socket_err
+ */
+MHD_INTERNAL enum mhd_SocketError
+mhd_socket_error_get_from_sys_err (int socket_err);
+
+/**
+ * Get the last socket error recoded for the given socket
+ * @param fd the socket to check for the error
+ * @return the recorded error @a fd,
+ *         #mhd_SOCKET_ERR_NOT_CHECKED if not possible to check @a fd for
+ *         the error
+ */
+MHD_INTERNAL enum mhd_SocketError
+mhd_socket_error_get_from_socket (MHD_Socket fd);
+
+#endif /* ! MHD_SOCKET_ERROR_FUNCS_H */

+ 1 - 0
src/mhd2/stream_process_states.c

@@ -35,6 +35,7 @@
 #include "sys_base_types.h"
 
 #include "mhd_str_macros.h"
+#include "mhd_socket_error_funcs.h"
 
 #include "mhd_daemon.h"
 #include "mhd_connection.h"