]> PatchyGit - patchyircd.git/commitdiff
consolidate standard headers inclusions
authorEgor <egor@patchysicp.xyz>
Fri, 13 Jun 2025 03:35:01 +0000 (06:35 +0300)
committerEgor <egor@patchysicp.xyz>
Fri, 13 Jun 2025 03:36:18 +0000 (06:36 +0300)
18 files changed:
Makefile.am
src/admin.cpp
src/admin.h
src/common.h
src/irc.cpp
src/irc.h
src/ircfmt.cpp
src/job.cpp
src/main.cpp
src/map.cpp
src/map.h
src/net.cpp
src/net.h
src/netpoll.cpp
src/netpoll.h
src/netsock.h [deleted file]
src/util.cpp
src/util.h

index 4497393..c4cec10 100644 (file)
@@ -12,7 +12,6 @@ ircd_SOURCES = \
        src/map.cpp            src/map.h            \
        src/net.cpp            src/net.h            \
        src/netpoll.cpp        src/netpoll.h        \
-                              src/netsock.h        \
        src/passwd.cpp         src/passwd.h         \
        src/util.cpp           src/util.h           \
        src/main.cpp
index cc2c4f1..3c56f97 100644 (file)
@@ -1,5 +1,6 @@
 // Copyright (c) 2023-2025 Egor
 // SPDX-License-Identifier: GPL-2.0-or-later
+#include "common.h"
 #ifdef HAVE_LUA
 #include "admin.h"
 #include "irc.h"
index 6dd8ad1..f4c03fc 100644 (file)
@@ -1,9 +1,8 @@
-// Copyright (c) 2023-2024 Egor
+// Copyright (c) 2023-2025 Egor
 // SPDX-License-Identifier: GPL-2.0-or-later
 #ifndef ADMIN_H_
 #define ADMIN_H_
 #ifdef HAVE_LUA
-#include "common.h"
 void admin_init(void);
 void admin_fini(void);
 int admin_command(struct client_data *client, char *source, char *command, int argc, char *args[]);
index e8e4001..ea3e3fa 100644 (file)
@@ -3,15 +3,44 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 #ifndef COMMON_H_
 #define COMMON_H_
-#include "netsock.h"
-#include "netpoll.h"
-#include "map.h"
+
+/* C standard */
+#include <errno.h>
+#include <locale.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <time.h>
+
+/* POSIX */
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+/* C++ standard */
+#include <algorithm>
+#include <deque>
+#include <iterator>
+#include <utility>
+#include <vector>
+
+/* libraries */
 #ifdef HAVE_LIBTLS
 #include <tls.h>
 #else
 struct tls;
 #endif
+#include <uv.h>
+
+#include "netpoll.h"
+#include "map.h"
 
 #define MAX_NICKLEN 32
 #define MAX_CHANLEN 33
index 6519494..900ebbc 100644 (file)
@@ -1,6 +1,7 @@
 // Copyright (c) 2022, 2024 Sam Smith
 // Copyright (c) 2022-2025 Egor
 // SPDX-License-Identifier: GPL-2.0-or-later
+#include "common.h"
 #include "irc.h"
 #include "ircfmt.h"
 #include "passwd.h"
index 235068e..5b1ed10 100644 (file)
--- a/src/irc.h
+++ b/src/irc.h
@@ -1,13 +1,10 @@
 // Copyright (c) 2022 Sam Smith
-// Copyright (c) 2022-2024 Egor
+// Copyright (c) 2022-2025 Egor
 // SPDX-License-Identifier: GPL-2.0-or-later
 #ifndef IRC_H_
 #define IRC_H_
-
-#include "common.h"
 #include "net.h"
 #include "util.h"
-
 #define is_registered(cl) ((cl)->regstate == REG_REGISTERED)
 void sendbuf_monitor(const char *nick, int cookie, int positive, int negative);
 const char *format_umodes(struct client_data *cl);
index 80a3b7e..2744c09 100644 (file)
@@ -1,5 +1,6 @@
 // Copyright (c) 2022-2025 Egor
 // SPDX-License-Identifier: GPL-2.0-or-later
+#include "common.h"
 #include "ircfmt.h"
 static const char *format_prefixes(struct client_data *client, struct client_data *cl, struct channel *chan) {
        if (!chan) return "";
index bc0fd19..45e252f 100644 (file)
@@ -3,11 +3,6 @@
 #include "common.h"
 #include "job.h"
 #include "passwd.h"
-#include <unistd.h>
-#include <signal.h>
-#include <sys/wait.h>
-#include <uv.h>
-#include <deque>
 
 struct jobent {
        struct client_data *client;
index d1394cd..b5be910 100644 (file)
@@ -5,8 +5,6 @@
 #include "net.h"
 #include "irc.h"
 #include "job.h"
-#include <locale.h>
-#include <vector>
 
 static int is_running = 1;
 
index dfe6ae0..7ece2c3 100644 (file)
@@ -2,9 +2,6 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 #include "common.h"
 #include "map.h"
-#include <stdlib.h>
-#include <string.h>
-#include <algorithm>
 static int ent_find(map_base *root, const char *key, int *found)
 {
        auto it = std::partition_point(root->ptr, root->ptr + root->len,
index 440f093..69e2fee 100644 (file)
--- a/src/map.h
+++ b/src/map.h
@@ -2,9 +2,6 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 #ifndef MAP_H_
 #define MAP_H_
-#include <stdlib.h>
-#include <utility>
-#include <iterator>
 #include "util.h"
 
 /* A map abstract data type with following properties:
index 8f17b1c..cf0b731 100644 (file)
@@ -1,7 +1,7 @@
 // Copyright (c) 2022 Sam Smith
 // Copyright (c) 2022-2025 Egor
 // SPDX-License-Identifier: GPL-2.0-or-later
-#include <stdarg.h>
+#include "common.h"
 #include "net.h"
 #include "irc.h"
 #include "ircfmt.h"
index a35e64b..e8285d2 100644 (file)
--- a/src/net.h
+++ b/src/net.h
@@ -3,8 +3,6 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 #ifndef NET_H_
 #define NET_H_
-#include "common.h"
-
 void sendbuf(struct client_data *client);
 void sendbuf_visible(struct client_data *client);
 void update_poll_reg(struct client_data *cl);
@@ -13,5 +11,4 @@ void killConnection(struct client_data *client, int byChoice);
 void killConnectionPart2(struct client_data *cl);
 void read_proc(struct client_data *cl);
 void sendClient(struct client_data *cl, const char *buf, size_t len);
-
 #endif
index 721bff2..3bfcb41 100644 (file)
@@ -1,11 +1,9 @@
 // Copyright (c) 2023-2025 Egor
 // SPDX-License-Identifier: GPL-2.0-or-later
+#include "common.h"
 #include "netpoll.h"
 #include "util.h"
 
-#include <algorithm>
-#include <vector>
-
 #define container_of(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type, member)))
 
 namespace netpoll {
index c8e3649..a055c6d 100644 (file)
@@ -2,8 +2,6 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 #ifndef NETPOLL_H_
 #define NETPOLL_H_
-#include "netsock.h"
-#include <uv.h>
 namespace netpoll {
 struct event {
        void *assoc;
@@ -19,10 +17,8 @@ void change_type(uv_os_sock_t fd, int type);
 void begin(void);
 bool get(event &out);
 }
-
 #define SOCKTYPE_LISTENER 0
 #define SOCKTYPE_CLIENT 1
 #define SOCKTYPE_DYING 2
 #define SOCKTYPE_MAX 3
-
 #endif
diff --git a/src/netsock.h b/src/netsock.h
deleted file mode 100644 (file)
index 981a9df..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2022 Sam Smith
-// Copyright (c) 2022-2025 Egor
-// SPDX-License-Identifier: GPL-2.0-or-later
-#ifndef NETSOCK_H_
-#define NETSOCK_H_
-
-/* API comparision table
- * | POSIX              | Win32             | NetSock          |
- * |--------------------|-------------------|------------------|
- * | int                | SOCKET            | SOCKET           |
- * | "%d"               | (complicated)     | "%"PRISocket     |
- * | -1                 | INVALID_SOCKET    | INVALID_SOCKET   |
- * | errno              | WSAGetLastError() | net_errno()      |
- * | strerror           | (complicated)     | net_strerror()   |
- * | perror             | (complicated)     | net_perror()     |
- * | EAGAIN             | WSAEWOULDBLOCK    | net_wouldblock() |
- * | (none)             | WSAStartup()      | net_init()       |
- * | (none)             | WSACleanup()      | net_cleanup()    |
- * | close()            | closesocket()     | closesocket()    |
- * | ioctl()            | ioctlsocket()     | ioctlsocket()    |
- * | SHUT_RD            | SD_RECEIVE        | SHUT_RD          |
- * | SHUT_WR            | SD_SEND           | SHUT_WR          |
- * | SHUT_RDWR          | SD_BOTH           | SHUT_RDWR        |
- * | O_NONBLOCK/FIONBIO | FIONBIO           | net_nonblock()   |
- * | read/recv          | recv              | recv             |
- * | write/send         | send              | send             |
- * | accept4            | accept            | accept4          |
- * | SOCK_CLOEXEC       | (none)            | SOCK_CLOEXEC     |
- * | "e"                | (none)            | FOPEN_CLOEXEC    |
- */
-
-/* Standard headers */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-/* POSIX */
-#include <unistd.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/select.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <fcntl.h>
-#include <signal.h>
-#endif
index b9227c5..6a50c7c 100644 (file)
@@ -1,6 +1,7 @@
 // Copyright (c) 2022 Sam Smith
 // Copyright (c) 2022-2025 Egor
 // SPDX-License-Identifier: GPL-2.0-or-later
+#include "common.h"
 #include "util.h"
 #include <stdio.h>
 #include <string.h>
index 67bd529..0eed7b2 100644 (file)
@@ -3,10 +3,6 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 #ifndef UTIL_H_
 #define UTIL_H_
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <vector>
 void append_str(std::vector<char> *v, const char *s);
 void append_strf(std::vector<char> *v, const char *s, ...);
 #define copy_strf(d, ...) append_strf(((d)->clear(), (d)), __VA_ARGS__)