summary refs log tree commit diff
diff options
context:
space:
mode:
authorNakidai <nakidai@disroot.org>2026-02-01 16:51:09 +0300
committerNakidai <nakidai@disroot.org>2026-02-01 16:51:09 +0300
commit62869d341d2a4e959b60865076287701694859dd (patch)
treef07b4ec31d8ebcffee04e84fe71000a56fc4efa1
parent9fa2ddad60c16383fb927645e50ba142050f8110 (diff)
downloadlibreircd-62869d341d2a4e959b60865076287701694859dd.tar.gz
libreircd-62869d341d2a4e959b60865076287701694859dd.zip
Remove magic numbers from ircd.h
Also make a new file config.h for storing that stuff
-rw-r--r--config.h15
-rw-r--r--ircd.h19
2 files changed, 21 insertions, 13 deletions
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..19d2958
--- /dev/null
+++ b/config.h
@@ -0,0 +1,15 @@
+#define PARAM_MAX 15
+
+#define MESSAGE_MAX 512
+#define PEERS_MAX 512
+#define CHANNELS_MAX 512
+
+#define CHANNEL_USERS_MAX 512
+#define CHANNEL_MODES_MAX 512
+#define CHANNEL_NAME_MAX 64
+
+#define PEER_CHANNELS_MAX 32
+#define PEER_NICK_MAX 16
+#define PEER_USER_MAX 16
+#define PEER_REAL_MAX 32
+#define PEER_HOST_MAX 64
diff --git a/ircd.h b/ircd.h
index 0cb20dc..ef8dbc5 100644
--- a/ircd.h
+++ b/ircd.h
@@ -19,14 +19,7 @@
 
 #include <stddef.h>
 
-
-#define PARAM_MAX 15
-
-#define MESSAGE_MAX 512
-#define PEERS_MAX 512
-#define CHANNELS_MAX 512
-#define USERS_PER_CHANNEL 512
-#define MODES_MAX 512
+#include "config.h"
 
 #define BIT(x) x##_BIT, x = 1 << x##_BIT, x##_BIT_ = x##_BIT
 #define lengthof(X) (sizeof(X) / sizeof(*(X)))
@@ -45,8 +38,8 @@ struct Peer
 {
 	int fd;
 	enum ClientType { UNREGD, CLIENT, SERVER, SERVICE } type;
-	char nick[16], user[16], real[32], host[64];
-	struct Channel *channels[32];
+	char nick[PEER_NICK_MAX], user[PEER_USER_MAX], real[PEER_REAL_MAX], host[PEER_HOST_MAX];
+	struct Channel *channels[PEER_CHANNELS_MAX];
 	enum PeerStatus {
 		BIT(DELETE),
 		BIT(ANNOUNCE),
@@ -67,12 +60,12 @@ struct Peer
 struct Channel
 {
 	enum { GLOBAL, LOCAL, MODELESS, SAFE } type;
-	char name[64];
+	char name[CHANNEL_NAME_MAX];
 	struct {
 		char mode;
 		char param[MESSAGE_MAX - 1];
-	} modes[MODES_MAX];
-	struct Peer *users[USERS_PER_CHANNEL];
+	} modes[CHANNEL_MODES_MAX];
+	struct Peer *users[CHANNEL_USERS_MAX];
 	size_t modes_c, users_c;
 };