]> PatchyGit - patchyircd.git/commitdiff
split data structures out of common.hpp
authorEgor <egor@patchysicp.xyz>
Fri, 13 Jun 2025 06:26:59 +0000 (09:26 +0300)
committerEgor <egor@patchysicp.xyz>
Fri, 13 Jun 2025 06:26:59 +0000 (09:26 +0300)
Makefile.am
src/admin.hpp
src/common.hpp
src/irc.hpp
src/ircdata.hpp [new file with mode: 0644]
src/job.hpp
src/map.cpp
src/net.hpp

index 647c157..5e2ee33 100644 (file)
@@ -7,6 +7,7 @@ ircd_SOURCES = \
                               src/common.hpp         \
        src/crypt_blowfish.cpp src/crypt_blowfish.hpp \
        src/irc.cpp            src/irc.hpp            \
+                              src/ircdata.hpp        \
        src/ircfmt.cpp         src/ircfmt.hpp         \
        src/job.cpp            src/job.hpp            \
        src/map.cpp            src/map.hpp            \
index 49fe7aa..f2b31c2 100644 (file)
@@ -3,6 +3,7 @@
 #ifndef ADMIN_H_
 #define ADMIN_H_
 #ifdef HAVE_LUA
+#include "ircdata.hpp"
 void admin_init(void);
 void admin_fini(void);
 int admin_command(Client *client, char *source, char *command, int argc, char *args[]);
index 060ef0e..00142d9 100644 (file)
 struct tls;
 #endif
 #include <uv.h>
-
-#include "map.hpp"
-
-#define MAX_NICKLEN 32
-#define MAX_CHANLEN 33
-#define MONITOR_LIMIT 100
-
-#define SETBIT(var, bit, val) ((void)((val) ? ((var)|=(bit)) : ((var)&=~(bit))))
-#define UMODE_INVISIBLE 1
-#define UMODE_OPER 2
-#define UMODE_REGISTERED 8
-#define UMODE_WALLOPS 16
-#define UMODE_SECURE 32
-#define UMODE_BOT 64
-#define REG_INIT 0
-#define REG_CAPLS 1
-#define REG_REGISTERED 2
-#define CAP_302 1
-#define CAP_MULTIPREFIX 2
-#define CAP_EXTENDEDJOIN 4
-#define CAP_AWAYNOTIFY 8
-#define CAP_INVITENOTIFY 16
-#define CAP_EXTENDEDMONITOR 32
-#define CAP_CHGHOST 64
-#define CAP_SETNAME 128
-#define CAP_ACCOUNTNOTIFY 256
-struct Client {
-       char   *key; // case-mapped nick
-       uv_os_sock_t fd;
-       struct tls *cctx;
-       struct Client *next;
-       char   *nick;
-       char   *username;
-       char   *realname;
-       char   *hostname;
-       char   *nuh; // case-mapped nick!user@host
-       char   *away;
-       char   *nick_reg;
-       char   *pass_reg;
-       char   *peername;
-       unsigned short peerport;
-       char   *saslbuf;
-       size_t saslbufLen;
-       char   *saslusername;
-       char   *webircpeername;
-       char   *webirchostname;
-       char   rbuf[2048];
-       size_t rlen;
-       char   wbuf[8192];
-       size_t wlen;
-       char   umode;
-       char   regstate;
-       channelmap channels;
-       channelmap invites;
-       stringset monitor;
-       int    cookie;
-       time_t signon;
-       time_t lastactivity;
-       unsigned int caps;
-       unsigned want_write_for_read :1;
-       unsigned want_read_for_write :1;
-       unsigned want_write_for_write :1;
-       unsigned want_read_for_close :1;
-       unsigned want_write_for_close :1;
-       unsigned dying :1;
-       unsigned write_error :1;
-       unsigned poll_reg :2;
-       unsigned saslexternal :1;
-       unsigned passwait :1;
-       unsigned webircwait :2;
-};
-struct Channel {
-       char *key;
-       char *name;
-       char *topic;
-       char *topic_who;
-       time_t topic_when;
-       time_t creation;
-       clientmap members;
-       clientmap o;
-       clientmap v;
-       int member_count;
-       char dmode;
-       stringset listb;
-       stringset liste;
-       stringset listI;
-       stringset listq;
-       stringset listwo;
-       stringset listwv;
-       clientmap invitees;
-       char *chankey;
-       int member_limit;
-};
-#define DMODE_PERSIST 1
-#define DMODE_INVITEONLY 2
-#define DMODE_MODERATED 4
-#define DMODE_NOEXTERNAL 8
-#define DMODE_SECRET 16
-#define DMODE_TOPICPROT 32
-#define is_chanop(chan, client) (!!(chan)->o.has((client)))
-#define is_chanvoice(chan, client) (!!(chan)->v.has((client)))
-extern clientmap client_map;
-extern channelmap channel_map;
-extern stringset autojoin;
-extern Client  *clients;
-extern Client  *dyingclients;
 #endif
index a51bc5f..a2a9230 100644 (file)
@@ -3,6 +3,7 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 #ifndef IRC_H_
 #define IRC_H_
+#include "ircdata.hpp"
 #include "net.hpp"
 #include "util.hpp"
 #define is_registered(cl) ((cl)->regstate == REG_REGISTERED)
diff --git a/src/ircdata.hpp b/src/ircdata.hpp
new file mode 100644 (file)
index 0000000..36b4c2d
--- /dev/null
@@ -0,0 +1,111 @@
+// Copyright (c) 2022 Sam Smith
+// Copyright (c) 2022-2025 Egor
+// SPDX-License-Identifier: GPL-2.0-or-later
+#ifndef IRCDATA_H_
+#define IRCDATA_H_
+#include "map.hpp"
+
+#define MAX_NICKLEN 32
+#define MAX_CHANLEN 33
+#define MONITOR_LIMIT 100
+
+#define SETBIT(var, bit, val) ((void)((val) ? ((var)|=(bit)) : ((var)&=~(bit))))
+#define UMODE_INVISIBLE 1
+#define UMODE_OPER 2
+#define UMODE_REGISTERED 8
+#define UMODE_WALLOPS 16
+#define UMODE_SECURE 32
+#define UMODE_BOT 64
+#define REG_INIT 0
+#define REG_CAPLS 1
+#define REG_REGISTERED 2
+#define CAP_302 1
+#define CAP_MULTIPREFIX 2
+#define CAP_EXTENDEDJOIN 4
+#define CAP_AWAYNOTIFY 8
+#define CAP_INVITENOTIFY 16
+#define CAP_EXTENDEDMONITOR 32
+#define CAP_CHGHOST 64
+#define CAP_SETNAME 128
+#define CAP_ACCOUNTNOTIFY 256
+struct Client {
+       char   *key; // case-mapped nick
+       uv_os_sock_t fd;
+       struct tls *cctx;
+       struct Client *next;
+       char   *nick;
+       char   *username;
+       char   *realname;
+       char   *hostname;
+       char   *nuh; // case-mapped nick!user@host
+       char   *away;
+       char   *nick_reg;
+       char   *pass_reg;
+       char   *peername;
+       unsigned short peerport;
+       char   *saslbuf;
+       size_t saslbufLen;
+       char   *saslusername;
+       char   *webircpeername;
+       char   *webirchostname;
+       char   rbuf[2048];
+       size_t rlen;
+       char   wbuf[8192];
+       size_t wlen;
+       char   umode;
+       char   regstate;
+       channelmap channels;
+       channelmap invites;
+       stringset monitor;
+       int    cookie;
+       time_t signon;
+       time_t lastactivity;
+       unsigned int caps;
+       unsigned want_write_for_read :1;
+       unsigned want_read_for_write :1;
+       unsigned want_write_for_write :1;
+       unsigned want_read_for_close :1;
+       unsigned want_write_for_close :1;
+       unsigned dying :1;
+       unsigned write_error :1;
+       unsigned poll_reg :2;
+       unsigned saslexternal :1;
+       unsigned passwait :1;
+       unsigned webircwait :2;
+};
+struct Channel {
+       char *key;
+       char *name;
+       char *topic;
+       char *topic_who;
+       time_t topic_when;
+       time_t creation;
+       clientmap members;
+       clientmap o;
+       clientmap v;
+       int member_count;
+       char dmode;
+       stringset listb;
+       stringset liste;
+       stringset listI;
+       stringset listq;
+       stringset listwo;
+       stringset listwv;
+       clientmap invitees;
+       char *chankey;
+       int member_limit;
+};
+#define DMODE_PERSIST 1
+#define DMODE_INVITEONLY 2
+#define DMODE_MODERATED 4
+#define DMODE_NOEXTERNAL 8
+#define DMODE_SECRET 16
+#define DMODE_TOPICPROT 32
+#define is_chanop(chan, client) (!!(chan)->o.has((client)))
+#define is_chanvoice(chan, client) (!!(chan)->v.has((client)))
+extern clientmap client_map;
+extern channelmap channel_map;
+extern stringset autojoin;
+extern Client  *clients;
+extern Client  *dyingclients;
+#endif
index 6346f83..a44448c 100644 (file)
@@ -2,6 +2,7 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 #ifndef JOB_H_
 #define JOB_H_
+#include "ircdata.hpp"
 typedef int (*jobproc_t)(Client *cl, const char *data, size_t len);
 typedef void (*contproc_t)(Client *cl, int res);
 void job_init(void);
index 0ed59c8..7b596bf 100644 (file)
@@ -2,6 +2,7 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 #include "common.hpp"
 #include "map.hpp"
+#include "ircdata.hpp"
 static int ent_find(map_base *root, const char *key, int *found)
 {
        auto it = std::partition_point(root->ptr, root->ptr + root->len,
index d1b02dc..99bf166 100644 (file)
@@ -3,6 +3,7 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 #ifndef NET_H_
 #define NET_H_
+#include "ircdata.hpp"
 void sendbuf(Client *client);
 void sendbuf_visible(Client *client);
 void update_poll_reg(Client *cl);