From: Egor Date: Fri, 13 Jun 2025 03:35:01 +0000 (+0300) Subject: consolidate standard headers inclusions X-Git-Url: https://git.patchysicp.xyz/?a=commitdiff_plain;h=3f172d042bd1d26477433b2ff1b17bb2cdb8d98e;p=patchyircd.git consolidate standard headers inclusions --- diff --git a/Makefile.am b/Makefile.am index 4497393..c4cec10 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/src/admin.cpp b/src/admin.cpp index cc2c4f1..3c56f97 100644 --- a/src/admin.cpp +++ b/src/admin.cpp @@ -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" diff --git a/src/admin.h b/src/admin.h index 6dd8ad1..f4c03fc 100644 --- a/src/admin.h +++ b/src/admin.h @@ -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[]); diff --git a/src/common.h b/src/common.h index e8e4001..ea3e3fa 100644 --- a/src/common.h +++ b/src/common.h @@ -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 +#include +#include +#include +#include +#include +#include #include + +/* POSIX */ +#include +#include +#include +#include +#include +#include +#include +#include + +/* C++ standard */ +#include +#include +#include +#include +#include + +/* libraries */ #ifdef HAVE_LIBTLS #include #else struct tls; #endif +#include + +#include "netpoll.h" +#include "map.h" #define MAX_NICKLEN 32 #define MAX_CHANLEN 33 diff --git a/src/irc.cpp b/src/irc.cpp index 6519494..900ebbc 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -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" diff --git a/src/irc.h b/src/irc.h index 235068e..5b1ed10 100644 --- 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); diff --git a/src/ircfmt.cpp b/src/ircfmt.cpp index 80a3b7e..2744c09 100644 --- a/src/ircfmt.cpp +++ b/src/ircfmt.cpp @@ -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 ""; diff --git a/src/job.cpp b/src/job.cpp index bc0fd19..45e252f 100644 --- a/src/job.cpp +++ b/src/job.cpp @@ -3,11 +3,6 @@ #include "common.h" #include "job.h" #include "passwd.h" -#include -#include -#include -#include -#include struct jobent { struct client_data *client; diff --git a/src/main.cpp b/src/main.cpp index d1394cd..b5be910 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,8 +5,6 @@ #include "net.h" #include "irc.h" #include "job.h" -#include -#include static int is_running = 1; diff --git a/src/map.cpp b/src/map.cpp index dfe6ae0..7ece2c3 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2,9 +2,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common.h" #include "map.h" -#include -#include -#include static int ent_find(map_base *root, const char *key, int *found) { auto it = std::partition_point(root->ptr, root->ptr + root->len, diff --git a/src/map.h b/src/map.h index 440f093..69e2fee 100644 --- 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 -#include -#include #include "util.h" /* A map abstract data type with following properties: diff --git a/src/net.cpp b/src/net.cpp index 8f17b1c..cf0b731 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2022 Sam Smith // Copyright (c) 2022-2025 Egor // SPDX-License-Identifier: GPL-2.0-or-later -#include +#include "common.h" #include "net.h" #include "irc.h" #include "ircfmt.h" diff --git a/src/net.h b/src/net.h index a35e64b..e8285d2 100644 --- 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 diff --git a/src/netpoll.cpp b/src/netpoll.cpp index 721bff2..3bfcb41 100644 --- a/src/netpoll.cpp +++ b/src/netpoll.cpp @@ -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 -#include - #define container_of(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type, member))) namespace netpoll { diff --git a/src/netpoll.h b/src/netpoll.h index c8e3649..a055c6d 100644 --- a/src/netpoll.h +++ b/src/netpoll.h @@ -2,8 +2,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later #ifndef NETPOLL_H_ #define NETPOLL_H_ -#include "netsock.h" -#include 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 index 981a9df..0000000 --- a/src/netsock.h +++ /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 -#include -#include -#include - -/* POSIX */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif diff --git a/src/util.cpp b/src/util.cpp index b9227c5..6a50c7c 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -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 #include diff --git a/src/util.h b/src/util.h index 67bd529..0eed7b2 100644 --- a/src/util.h +++ b/src/util.h @@ -3,10 +3,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later #ifndef UTIL_H_ #define UTIL_H_ -#include -#include -#include -#include void append_str(std::vector *v, const char *s); void append_strf(std::vector *v, const char *s, ...); #define copy_strf(d, ...) append_strf(((d)->clear(), (d)), __VA_ARGS__)