]> PatchyGit - patchyircd.git/commitdiff
ircfmt: declutter numeric replies
authorEgor <egor@patchysicp.xyz>
Sun, 8 Feb 2026 14:49:30 +0000 (16:49 +0200)
committerEgor <egor@patchysicp.xyz>
Sun, 8 Feb 2026 14:49:30 +0000 (16:49 +0200)
src/admin.cpp
src/irc.cpp
src/ircfmt.cpp
src/ircfmt.hpp

index 9292540..24aee50 100644 (file)
@@ -504,7 +504,7 @@ void admin_dostring(const char *command)
 bool admin_command(Client *client, char *source, char *command, int argc, char *args[])
 {
        if (!is_registered(client))
-               return err_notregistered(client), sendbuf(client), false;
+               return err_notregistered(), sendbuf(client), false;
        if (!(client->umode & UMODE_OPER))
                return err_noprivileges(client), sendbuf(client), false;
        lua_State *L = GL;
index 2e85411..4b1f393 100644 (file)
@@ -510,7 +510,7 @@ saslcleanup:
                }
        } MATCH_COMMAND("OPER") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (argc < 2)
                        return err_needmoreparams(client, command), sendbuf(client), false;
                stringlower(args[0]);
@@ -527,7 +527,7 @@ saslcleanup:
                memset(args[1], 0, strlen(args[1]));
        } MATCH_COMMAND("NEWACC") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (argc < 2)
                        return err_needmoreparams(client, command), sendbuf(client), false;
                stringlower(args[0]);
@@ -571,7 +571,7 @@ saslcleanup:
                killConnection(cl, 0);
        } MATCH_COMMAND("WALLOPS") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (argc < 1)
                        return err_needmoreparams(client, command), sendbuf(client), false;
                if (!(client->umode & UMODE_OPER))
@@ -582,7 +582,7 @@ saslcleanup:
                                sendbuf(cl);
        } MATCH_COMMAND("KILL") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (!(client->umode & UMODE_OPER))
                        return err_noprivileges(client), sendbuf(client), false;
                if (argc < 1)
@@ -600,7 +600,7 @@ saslcleanup:
                killConnection(cl, 0);
        } MATCH_COMMAND("JEDGAR") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (!(client->umode & UMODE_OPER))
                        return err_noprivileges(client), sendbuf(client), false;
                if (argc < 1)
@@ -615,7 +615,7 @@ saslcleanup:
                sendbuf_chan(chan);
        } MATCH_COMMAND("JOIN") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (!args[0])
                        return err_needmoreparams(client, command), sendbuf(client), false;
                if (!strcmp(args[0], "0")) {
@@ -636,7 +636,7 @@ saslcleanup:
                } while (p);
        } MATCH_COMMAND("PART") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (!args[0])
                        return err_needmoreparams(client, command), sendbuf(client), false;
                char *p = args[0];
@@ -651,7 +651,7 @@ saslcleanup:
                } while (p);
        } MATCH_COMMAND("TOPIC") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (!args[0])
                        return err_needmoreparams(client, command), sendbuf(client), false;
                Channel *chan = findChannel(args[0]);
@@ -668,7 +668,7 @@ saslcleanup:
                }
        } MATCH_COMMAND("INVITE") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (!args[0]) {
                        // List pending invites
                        for (auto chan : client->invites)
@@ -701,7 +701,7 @@ saslcleanup:
                sendbuf_chan_caps(chan, CAP_INVITENOTIFY, 0);
        } MATCH_COMMAND("KICK") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (argc < 2)
                        return err_needmoreparams(client, command), sendbuf(client), false;
                Channel *chan = findChannel(args[0]);
@@ -727,7 +727,7 @@ saslcleanup:
        } MATCH_COMMAND("NOTICE") {
 privmsg_notice_common:
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (argc < 2)
                        return err_needmoreparams(client, command), sendbuf(client), false;
                client->lastactivity = get_time();
@@ -801,14 +801,14 @@ privmsg_notice_common:
        // Server Queries and Commands
        } MATCH_COMMAND("MOTD") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (args[0] && strcmp(args[0], hostname) != 0)
                        return err_nosuchserver(client, args[0]), sendbuf(client), false;
                // Send welcome
                sendMOTD(client);
        } MATCH_COMMAND("HELP") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                char line[512];
                FILE *f = fopen(getdatafile("help.txt"), "re");
                if (f) {
@@ -826,14 +826,14 @@ privmsg_notice_common:
                }
        } MATCH_COMMAND("VERSION") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (args[0] && strcmp(args[0], hostname) != 0)
                        return err_nosuchserver(client, args[0]), sendbuf(client), false;
                rpl_version(client, PACKAGE_VERSION, PACKAGE_STRING), sendbuf(client);
                rpl_isupport(client), sendbuf(client);
        } MATCH_COMMAND("ADMIN") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (args[0] && strcmp(args[0], hostname) != 0)
                        return err_nosuchserver(client, args[0]), sendbuf(client), false;
                char line[512];
@@ -863,17 +863,17 @@ privmsg_notice_common:
                }
        } MATCH_COMMAND("LUSERS") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                sendLUSERS(client);
        } MATCH_COMMAND("TIME") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (args[0] && strcmp(args[0], hostname) != 0)
                        return err_nosuchserver(client, args[0]), sendbuf(client), false;
                rpl_time(client, get_time()), sendbuf(client);
        } MATCH_COMMAND("MODE") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (argc == 0)
                        return err_needmoreparams(client, command), sendbuf(client), false;
                char *nick = args[0];
@@ -991,7 +991,7 @@ privmsg_notice_common:
                }
        } MATCH_COMMAND("LIST") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                rpl_liststart(client), sendbuf(client);
                for (auto chan : channel_map)
                        if (client->umode & UMODE_OPER || !(chan->dmode & DMODE_SECRET) || chan->members.contains(client))
@@ -999,7 +999,7 @@ privmsg_notice_common:
                rpl_listend(client), sendbuf(client);
        } MATCH_COMMAND("NAMES") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (argc == 0)
                        return err_needmoreparams(client, command), sendbuf(client), false;
                char *p = args[0];
@@ -1017,7 +1017,7 @@ privmsg_notice_common:
                } while (p);
        } MATCH_COMMAND("USERHOST") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (argc == 0)
                        return err_needmoreparams(client, command), sendbuf(client), false;
                Client *cls[5], **p = cls;
@@ -1033,7 +1033,7 @@ privmsg_notice_common:
        // User-Based Queries
        } MATCH_COMMAND("WHO") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (argc == 0)
                        return err_needmoreparams(client, command), sendbuf(client), false;
                if (strchr("#&", args[0][0])) {
@@ -1068,7 +1068,7 @@ privmsg_notice_common:
                rpl_endofwho(client, args[0]), sendbuf(client);
        } MATCH_COMMAND("WHOIS") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (argc == 0)
                        return err_needmoreparams(client, command), sendbuf(client), false;
                char *nick = args[1] ? args[1] : args[0];
@@ -1109,7 +1109,7 @@ privmsg_notice_common:
                }
        } MATCH_COMMAND("AWAY") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (args[0]) {
                        delete[] client->away;
                        client->away = mystrdup(args[0]);
@@ -1124,7 +1124,7 @@ privmsg_notice_common:
                sendbuf_monitor(client->key, cookie, CAP_AWAYNOTIFY|CAP_EXTENDEDMONITOR, 0);
        } MATCH_COMMAND("MONITOR") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (argc == 0)
                        return err_needmoreparams(client, command), sendbuf(client), false;
                if (!args[0][0] || args[0][1])
@@ -1189,7 +1189,7 @@ privmsg_notice_common:
                }
        } MATCH_COMMAND("SETNAME") {
                if (!is_registered(client))
-                       return err_notregistered(client), sendbuf(client), false;
+                       return err_notregistered(), sendbuf(client), false;
                if (argc == 0)
                        return err_needmoreparams(client, command), sendbuf(client), false;
                delete[] client->realname;
index 5c8ce3b..6971ce1 100644 (file)
@@ -2,6 +2,11 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 #include "common.hpp"
 #include "ircfmt.hpp"
+#define WANT_UNUSED 0
+#define num_reply_to(num, nick, ...) (copy_strf(&databuf, ":%s " #num " %s", hostname, nick), append_strf(&databuf, __VA_ARGS__))
+#define num_reply(num, ...) num_reply_to(num, client->nick, __VA_ARGS__)
+#define num_reply_check_nick(num, ...) num_reply_to(num, client->nick ? client->nick : "*", __VA_ARGS__)
+#define num_reply_anon(num, ...) num_reply_to(num, "*", __VA_ARGS__)
 static const char *format_prefixes(Client *client, Client *cl, Channel *chan) {
        if (!chan) return "";
        bool o = chan->is_op(cl);
@@ -31,7 +36,7 @@ void msg_nick(Client *src, const char *newnick)
                        src->nick, src->username, src->hostname,
                        newnick);
 }
-#if 0
+#if WANT_UNUSED
 void msg_ping(const char *token)
 {
        copy_strf(&databuf, ":%s PING :%s\r\n", hostname, token);
@@ -135,118 +140,85 @@ void msg_account(Client *src)
        copy_strf(&databuf, ":%s!%s@%s ACCOUNT %s\r\n",
                        src->nick, src->username, src->hostname, src->username[0] != '~' ? src->username : "*");
 }
-void rpl_welcome(Client *client) // 001
-{
-       copy_strf(&databuf, ":%s 001 %s :Welcome to the Patchy Network, %s\r\n", hostname, client->nick, client->nick);
+void rpl_welcome(Client *client) { // 001
+       num_reply(001, " :Welcome to the Patchy Network, %s\r\n", client->nick);
 }
-void rpl_yourhost(Client *client) // 002
-{
-       copy_strf(&databuf, ":%s 002 %s :Your host is " PACKAGE_NAME ", running version " PACKAGE_VERSION "\r\n", hostname, client->nick);
+void rpl_yourhost(Client *client) { // 002
+       num_reply(002, " :Your host is " PACKAGE_NAME ", running version " PACKAGE_VERSION "\r\n");
 }
-void rpl_created(Client *client) // 003
-{
-       copy_strf(&databuf, ":%s 003 %s :This server was created when I had cybersex with your mother.\r\n", hostname, client->nick);
+void rpl_created(Client *client) { // 003
+       num_reply(003, " :This server was created when I had cybersex with your mother.\r\n");
 }
-void rpl_myinfo(Client *client) // 004
-{
-       copy_strf(&databuf, ":%s 004 %s " PACKAGE_STRING " iworZ beIqwklPimnstov\r\n", hostname, client->nick);
+void rpl_myinfo(Client *client) { // 004
+       num_reply(004, " " PACKAGE_STRING " iworZ beIqwklPimnstov\r\n");
 }
-void rpl_isupport(Client *client) // 005
-{
-       copy_strf(&databuf, ":%s 005 %s NETWORK=PatchyIRC CASEMAPPING=ascii NICKLEN=%u CHANNELLEN=%u EXCEPTS=e INVEX=I MAXTARGETS=1 CHANMODES=beIqw,k,l,Pimnst CHANTYPES=#& PREFIX=(ov)@+ STATUSMSG=@+ BOT=B WHOX MONITOR=%u :are supported by this server\r\n", hostname, client->nick, MAX_NICKLEN-1, MAX_CHANLEN-1, MONITOR_LIMIT);
+void rpl_isupport(Client *client) { // 005
+       num_reply(005, " NETWORK=PatchyIRC CASEMAPPING=ascii NICKLEN=%u CHANNELLEN=%u EXCEPTS=e INVEX=I MAXTARGETS=1 CHANMODES=beIqw,k,l,Pimnst CHANTYPES=#& PREFIX=(ov)@+ STATUSMSG=@+ BOT=B WHOX MONITOR=%u :are supported by this server\r\n", MAX_NICKLEN-1, MAX_CHANLEN-1, MONITOR_LIMIT);
 
 }
-#if 0
-void rpl_bounce(Client *client, const char *host, const char *port, const char *info) // 010
-{
-       copy_strf(&databuf, ":%s 010 %s %s %s :%s\r\n",
-                       hostname, client->nick, host, port, info);
+#if WANT_UNUSED
+void rpl_bounce(Client *client, const char *host, const char *port, const char *info) { // 010
+       num_reply(010, " %s %s :%s\r\n", host, port, info);
 }
 #endif
-void rpl_umodeis(Client *client) // 221
-{
-       copy_strf(&databuf, ":%s 221 %s %s\r\n", hostname, client->nick, format_umodes(client));
+void rpl_umodeis(Client *client) { // 221
+       num_reply(221, " %s\r\n", format_umodes(client));
 }
-void rpl_luserclient(Client *client, int users, int invisible, int servers) // 251
-{
-       copy_strf(&databuf, ":%s 251 %s :There are %u users and %u invisible on %u servers\r\n",
-                       hostname, client->nick, users, invisible, servers);
+void rpl_luserclient(Client *client, int users, int invisible, int servers) { // 251
+       num_reply(251, " :There are %u users and %u invisible on %u servers\r\n",
+                       users, invisible, servers);
 }
-void rpl_luserop(Client *client, int ops) // 252
-{
-       copy_strf(&databuf, ":%s 252 %s %u :operator(s) online\r\n",
-                       hostname, client->nick, ops);
+void rpl_luserop(Client *client, int ops) { // 252
+       num_reply(252, " %u :operator(s) online\r\n", ops);
 }
-void rpl_luserunknown(Client *client, int unk) // 253
-{
-       copy_strf(&databuf, ":%s 253 %s %u :unknown connection(s)\r\n",
-                       hostname, client->nick, unk);
+void rpl_luserunknown(Client *client, int unk) { // 253
+       num_reply(253, " %u :unknown connection(s)\r\n", unk);
 }
-void rpl_luserchannels(Client *client, int channels) // 254
-{
-       copy_strf(&databuf, ":%s 254 %s %u :channels formed\r\n",
-                       hostname, client->nick, channels);
+void rpl_luserchannels(Client *client, int channels) { // 254
+       num_reply(254, " %u :channels formed\r\n", channels);
 }
-void rpl_luserme(Client *client, int clients, int servers) // 255
-{
-       copy_strf(&databuf, ":%s 255 %s :I have %u clients and %u servers\r\n",
-                       hostname, client->nick, clients, servers);
+void rpl_luserme(Client *client, int clients, int servers) { // 255
+       num_reply(255, " :I have %u clients and %u servers\r\n", clients, servers);
 }
-void rpl_adminme(Client *client) // 256
-{
-       copy_strf(&databuf, ":%s 256 %s %s :Administrative info\r\n",
-                       hostname, client->nick, hostname);
+void rpl_adminme(Client *client) { // 256
+       num_reply(256, " %s :Administrative info\r\n", hostname);
 }
-void rpl_adminloc1(Client *client, const char *loc) // 257
-{
-       copy_strf(&databuf, ":%s 257 %s :%s\r\n",
-                       hostname, client->nick, loc);
+void rpl_adminloc1(Client *client, const char *loc) { // 257
+       num_reply(257, " :%s\r\n", loc);
 }
-void rpl_adminloc2(Client *client, const char *loc) // 258
-{
-       copy_strf(&databuf, ":%s 258 %s :%s\r\n",
-                       hostname, client->nick, loc);
+void rpl_adminloc2(Client *client, const char *loc) { // 258
+       num_reply(258, " :%s\r\n", loc);
 }
-void rpl_adminemail(Client *client, const char *email) // 259
-{
-       copy_strf(&databuf, ":%s 259 %s :%s\r\n",
-                       hostname, client->nick, email);
+void rpl_adminemail(Client *client, const char *email) { // 259
+       num_reply(259, " :%s\r\n", email);
 }
-#if 0
-void rpl_tryagain(Client *client, const char *command) // 263
-{
-       copy_strf(&databuf, ":%s 263 %s %s :Please wait a while and try again\r\n",
-                       hostname, client->nick, command);
+#if WANT_UNUSED
+void rpl_tryagain(Client *client, const char *command) { // 263
+       num_reply(263, " %s :Please wait a while and try again\r\n", command);
 }
 #endif
-void rpl_localusers(Client *client, int current, int max) // 265
-{
-       copy_strf(&databuf, ":%s 265 %s :Current local users %u, max %u\r\n",
-                       hostname, client->nick, current, max, current, max);
+void rpl_localusers(Client *client, int current, int max) { // 265
+       num_reply(265, " :Current local users %u, max %u\r\n",
+                       current, max, current, max);
 }
-void rpl_globalusers(Client *client, int current, int max) // 266
-{
-       copy_strf(&databuf, ":%s 266 %s %u %u :Current global users %u, max %u\r\n",
-                       hostname, client->nick, current, max, current, max);
+void rpl_globalusers(Client *client, int current, int max) { // 266
+       num_reply(266, " %u %u :Current global users %u, max %u\r\n",
+                       current, max, current, max);
 }
-void rpl_whoiscertfp(Client *client, Client *cl, const char *certfp) // 276
-{
-       copy_strf(&databuf, ":%s 276 %s %s :has client certificate fingerprint %s\r\n",
-                       hostname, client->nick, cl->nick, certfp);
+void rpl_whoiscertfp(Client *client, Client *cl, const char *certfp) { // 276
+       num_reply(276, " %s :has client certificate fingerprint %s\r\n",
+                       cl->nick, certfp);
 }
-#if 0
-void rpl_none(Client *client, const char *line) // 300
-{
-       copy_strf(&databuf, ":%s 300 %s %s\r\n", hostname, client->nick, line);
+#if WANT_UNUSED
+void rpl_none(Client *client, const char *line) { // 300
+       num_reply(300, " %s\r\n", line);
 }
 #endif
-void rpl_away(Client *client, Client *cl) // 301
-{
-       copy_strf(&databuf, ":%s 301 %s %s :%s\r\n", hostname, client->nick, cl->nick, cl->away);
+void rpl_away(Client *client, Client *cl) { // 301
+       num_reply(301, " %s :%s\r\n", cl->nick, cl->away);
 }
-void rpl_userhost(Client *client, Client **cls, int count) // 302
-{
-       copy_strf(&databuf, ":%s 302 %s", hostname, client->nick);
+void rpl_userhost(Client *client, Client **cls, int count) { // 302
+       num_reply(302, "");
        for (int i = 0; i < count; i++) {
                append_strf(&databuf, " %s%s%s=%s%s",
                                i ? "" : ":",
@@ -257,24 +229,20 @@ void rpl_userhost(Client *client, Client **cls, int count) // 302
        }
        append_str(&databuf, "\r\n");
 }
-void rpl_unaway(Client *client) // 305
-{
-       copy_strf(&databuf, ":%s 305 %s :You are no longer marked as being away\r\n", hostname, client->nick);
+void rpl_unaway(Client *client) { // 305
+       num_reply(305, " :You are no longer marked as being away\r\n");
 }
-void rpl_nowaway(Client *client) // 306
-{
-       copy_strf(&databuf, ":%s 306 %s :You have been marked as being away\r\n", hostname, client->nick);
+void rpl_nowaway(Client *client) { // 306
+       num_reply(306, " :You have been marked as being away\r\n");
 }
-void rpl_whoreply(Client *client, Client *cl, Channel *chan) // 352
-{
-       copy_strf(&databuf, ":%s 352 %s %s %s %s %s %s %s%s%s%s :1 %s\r\n",
-                       hostname, client->nick, chan ? chan->name : "*", cl->username, cl->hostname, hostname, cl->nick,
+void rpl_whoreply(Client *client, Client *cl, Channel *chan) { // 352
+       num_reply(352, " %s %s %s %s %s %s%s%s%s :1 %s\r\n",
+                       chan ? chan->name : "*", cl->username, cl->hostname, hostname, cl->nick,
                        cl->away ? "G" : "H", cl->umode&UMODE_OPER ? "*" : "", format_prefixes(client, cl, chan),
                        cl->umode&UMODE_BOT ? "B" : "",
                        cl->realname);
 }
-void rpl_whospcrpl(Client *client, Client *cl, Channel *chan, const char *fmt) // 354
-{
+void rpl_whospcrpl(Client *client, Client *cl, Channel *chan, const char *fmt) { // 354
        int flags = 0;
        while (*fmt != '%')
                fmt++;
@@ -300,7 +268,7 @@ void rpl_whospcrpl(Client *client, Client *cl, Channel *chan, const char *fmt) /
                }
                fmt++;
        }
-       copy_strf(&databuf, ":%s 354 %s", hostname, client->nick);
+       num_reply(354, "");
        if (flags & 1<<0)  /* t */
                append_strf(&databuf, " %s", fmt);
        if (flags & 1<<1)  /* c */
@@ -331,60 +299,47 @@ void rpl_whospcrpl(Client *client, Client *cl, Channel *chan, const char *fmt) /
                append_strf(&databuf, " :%s", cl->realname);
        append_strf(&databuf, "\r\n");
 }
-void rpl_endofwho(Client *client, const char *query) // 315
-{
-       copy_strf(&databuf, ":%s 315 %s %s :End of WHO list\r\n", hostname, client->nick, query);
+void rpl_endofwho(Client *client, const char *query) { // 315
+       num_reply(315, " %s :End of WHO list\r\n", query);
 }
-void rpl_whoisregnick(Client *client, Client *cl) // 307
-{
-       copy_strf(&databuf, ":%s 307 %s %s :has identified for this nick\r\n", hostname, client->nick, cl->nick);
+void rpl_whoisregnick(Client *client, Client *cl) { // 307
+       num_reply(307, " %s :has identified for this nick\r\n", cl->nick);
 }
-void rpl_whoisuser(Client *client, Client *cl) // 311
-{
-       copy_strf(&databuf, ":%s 311 %s %s %s %s * :%s\r\n", hostname, client->nick, cl->nick, cl->username, cl->hostname, cl->realname);
+void rpl_whoisuser(Client *client, Client *cl) { // 311
+       num_reply(311, " %s %s %s * :%s\r\n", cl->nick, cl->username, cl->hostname, cl->realname);
 }
-void rpl_whoisserver(Client *client, Client *cl) // 312
-{
-       copy_strf(&databuf, ":%s 312 %s %s %s :Patchy server\r\n", hostname, client->nick, cl->nick, hostname);
+void rpl_whoisserver(Client *client, Client *cl) { // 312
+       num_reply(312, " %s %s :Patchy server\r\n", cl->nick, hostname);
 }
-void rpl_whoisoperator(Client *client, Client *cl) // 313
-{
-       copy_strf(&databuf, ":%s 313 %s %s :is an IRC operator\r\n", hostname, client->nick, cl->nick);
+void rpl_whoisoperator(Client *client, Client *cl) { // 313
+       num_reply(313, " %s :is an IRC operator\r\n", cl->nick);
 }
 // 314 RPL_WHOWASUSER
-void rpl_whoisidle(Client *client, Client *cl) // 317
-{
-       copy_strf(&databuf, ":%s 317 %s %s %lu %lu :seconds idle, signon time\r\n",
-                       hostname, client->nick, cl->nick, (unsigned long)(get_time()-cl->lastactivity), (unsigned long)cl->signon);
+void rpl_whoisidle(Client *client, Client *cl) { // 317
+       num_reply(317, " %s %lu %lu :seconds idle, signon time\r\n",
+                       cl->nick, (unsigned long)(get_time()-cl->lastactivity), (unsigned long)cl->signon);
 }
-void rpl_endofwhois(Client *client, Client *cl) // 318
-{
-       copy_strf(&databuf, ":%s 318 %s %s :End of /WHOIS list\r\n", hostname, client->nick, cl->nick);
+void rpl_endofwhois(Client *client, Client *cl) { // 318
+       num_reply(318, " %s :End of /WHOIS list\r\n", cl->nick);
 }
-void rpl_whoischannels(Client *client, Client *cl, Channel *chan) // 319
-{
-       copy_strf(&databuf, ":%s 319 %s %s :%s%s\r\n", hostname, client->nick, cl->nick, format_prefixes(client, cl, chan), chan->name);
+void rpl_whoischannels(Client *client, Client *cl, Channel *chan) { // 319
+       num_reply(319, " %s :%s%s\r\n", cl->nick, format_prefixes(client, cl, chan), chan->name);
 }
-void rpl_whoisspecial(Client *client, Client *cl, const char *prefix, const char *info) // 320
-{
-       copy_strf(&databuf, ":%s 320 %s %s :%s%s\r\n", hostname, client->nick, cl->nick, prefix, info);
+void rpl_whoisspecial(Client *client, Client *cl, const char *prefix, const char *info) { // 320
+       num_reply(320, " %s :%s%s\r\n", cl->nick, prefix, info);
 }
-void rpl_liststart(Client *client) // 321
-{
-       copy_strf(&databuf, ":%s 321 %s Channel :Users  Name\r\n", hostname, client->nick);
+void rpl_liststart(Client *client) { // 321
+       num_reply(321, " Channel :Users  Name\r\n");
 }
-void rpl_list(Client *client, Channel *chan) // 322
-{
-       copy_strf(&databuf, ":%s 322 %s %s %u :%s\r\n", hostname, client->nick,
+void rpl_list(Client *client, Channel *chan) { // 322
+       num_reply(322, " %s %u :%s\r\n",
                        chan->name, chan->member_count, chan->topic ? chan->topic : "");
 }
-void rpl_listend(Client *client) // 323
-{
-       copy_strf(&databuf, ":%s 323 %s :End of /LIST\r\n", hostname, client->nick);
+void rpl_listend(Client *client) { // 323
+       num_reply(323, " :End of /LIST\r\n");
 }
-void rpl_channelmodeis(Client *client, Channel *chan) // 324
-{
-       copy_strf(&databuf, ":%s 324 %s %s +", hostname, client->nick, chan->name);
+void rpl_channelmodeis(Client *client, Channel *chan) { // 324
+       num_reply(324, " %s +", chan->name);
        if (chan->dmode & DMODE_PERSIST) append_str(&databuf, "P");
        if (chan->dmode & DMODE_INVITEONLY) append_str(&databuf, "i");
        if (chan->dmode & DMODE_MODERATED) append_str(&databuf, "m");
@@ -397,72 +352,56 @@ void rpl_channelmodeis(Client *client, Channel *chan) // 324
        if (chan->chankey) append_strf(&databuf, " %s", chan->chankey);
        append_str(&databuf, "\r\n");
 }
-void rpl_creationtime(Client *client, Channel *chan) // 329
-{
-       copy_strf(&databuf, ":%s 329 %s %s %lu\r\n", hostname, client->nick, chan->name, (unsigned long)chan->creation);
+void rpl_creationtime(Client *client, Channel *chan) { // 329
+       num_reply(329, " %s %lu\r\n", chan->name, (unsigned long)chan->creation);
 }
-void rpl_whoisaccount(Client *client, Client *cl) // 330
-{
-       copy_strf(&databuf, ":%s 330 %s %s %s :is logged in as\r\n", hostname, client->nick, cl->nick, cl->username);
+void rpl_whoisaccount(Client *client, Client *cl) { // 330
+       num_reply(330, " %s %s :is logged in as\r\n", cl->nick, cl->username);
 }
-void rpl_notopic(Client *client, Channel *chan) // 331
-{
-       copy_strf(&databuf, ":%s 331 %s %s :No topic is set\r\n", hostname, client->nick,
+void rpl_notopic(Client *client, Channel *chan) { // 331
+       num_reply(331, " %s :No topic is set\r\n",
                        chan->name);
 }
-void rpl_topic(Client *client, Channel *chan) // 332
-{
-       copy_strf(&databuf, ":%s 332 %s %s :%s\r\n", hostname, client->nick,
+void rpl_topic(Client *client, Channel *chan) { // 332
+       num_reply(332, " %s :%s\r\n",
                        chan->name, chan->topic);
 }
-void rpl_topicwhotime(Client *client, Channel *chan) // 333
-{
-       copy_strf(&databuf, ":%s 333 %s %s %s %lu\r\n", hostname, client->nick,
+void rpl_topicwhotime(Client *client, Channel *chan) { // 333
+       num_reply(333, " %s %s %lu\r\n",
                        chan->name, chan->topic_who, (unsigned long)chan->topic_when);
 }
-void rpl_whoisbot(Client *client, Client *cl) // 335
-{
-       copy_strf(&databuf, ":%s 335 %s %s :is a bot\r\n", hostname, client->nick, cl->nick);
+void rpl_whoisbot(Client *client, Client *cl) { // 335
+       num_reply(335, " %s :is a bot\r\n", cl->nick);
 }
-void rpl_invitelist(Client *client, Channel *chan) // 336
-{
-       copy_strf(&databuf, ":%s 336 %s %s\r\n", hostname, client->nick, chan->name);
+void rpl_invitelist(Client *client, Channel *chan) { // 336
+       num_reply(336, " %s\r\n", chan->name);
 }
-void rpl_endofinvitelist(Client *client) // 337
-{
-       copy_strf(&databuf, ":%s 337 %s :End of /INVITE list\r\n", hostname, client->nick);
+void rpl_endofinvitelist(Client *client) { // 337
+       num_reply(337, " :End of /INVITE list\r\n");
 }
-void rpl_whoisactually(Client *client, Client *cl) // 338
-{
-       copy_strf(&databuf, ":%s 338 %s %s %s :Is actually using host\r\n", hostname, client->nick, cl->nick, cl->peername);
+void rpl_whoisactually(Client *client, Client *cl) { // 338
+       num_reply(338, " %s %s :Is actually using host\r\n", cl->nick, cl->peername);
 }
-void rpl_inviting(Client *client, Client *cl, Channel *chan) // 341
-{
-       copy_strf(&databuf, ":%s 341 %s %s %s\r\n", hostname, client->nick, cl->nick, chan->name);
+void rpl_inviting(Client *client, Client *cl, Channel *chan) { // 341
+       num_reply(341, " %s %s\r\n", cl->nick, chan->name);
 }
-void rpl_invexlist(Client *client, Channel *chan, std::string_view mask) // 346
-{
-       copy_strf(&databuf, ":%s 346 %s %s %.*s\r\n", hostname, client->nick, chan->name, (int)mask.size(), mask.data());
+void rpl_invexlist(Client *client, Channel *chan, std::string_view mask) { // 346
+       num_reply(346, " %s %.*s\r\n", chan->name, (int)mask.size(), mask.data());
 }
-void rpl_endofinvexlist(Client *client, Channel *chan) // 347
-{
-       copy_strf(&databuf, ":%s 347 %s %s :End of Channel Invite Exception List\r\n", hostname, client->nick, chan->name);
+void rpl_endofinvexlist(Client *client, Channel *chan) { // 347
+       num_reply(347, " %s :End of Channel Invite Exception List\r\n", chan->name);
 }
-void rpl_exceptlist(Client *client, Channel *chan, std::string_view mask) // 348
-{
-       copy_strf(&databuf, ":%s 348 %s %s %.*s\r\n", hostname, client->nick, chan->name, (int)mask.size(), mask.data());
+void rpl_exceptlist(Client *client, Channel *chan, std::string_view mask) { // 348
+       num_reply(348, " %s %.*s\r\n", chan->name, (int)mask.size(), mask.data());
 }
-void rpl_endofexceptlist(Client *client, Channel *chan) // 349
-{
-       copy_strf(&databuf, ":%s 349 %s %s :End of channel exception list\r\n", hostname, client->nick, chan->name);
+void rpl_endofexceptlist(Client *client, Channel *chan) { // 349
+       num_reply(349, " %s :End of channel exception list\r\n", chan->name);
 }
-void rpl_version(Client *client, const char *ver, const char *comments) // 351
-{
-       copy_strf(&databuf, ":%s 351 %s %s %s :%s\r\n", hostname, client->nick,
+void rpl_version(Client *client, const char *ver, const char *comments) { // 351
+       num_reply(351, " %s %s :%s\r\n",
                        ver, hostname, comments);
 }
-int rpl_namreply(Client *client, Channel *chan, Client *cl) // 353
-{
+int rpl_namreply(Client *client, Channel *chan, Client *cl) { // 353
        if (!cl) {
                if (databuf.size()) {
                        append_str(&databuf, "\r\n");
@@ -474,7 +413,7 @@ int rpl_namreply(Client *client, Channel *chan, Client *cl) // 353
        const char *prefix = format_prefixes(client, cl, chan);
        if (databuf.empty()) {
                const char *chanchar = chan->dmode & DMODE_SECRET ? "@" : "=";
-               copy_strf(&databuf, ":%s 353 %s %s %s :", hostname, client->nick, chanchar, chan->name);
+               num_reply(353, " %s %s :", chanchar, chan->name);
        } else {
                if (databuf.size() + 1 + strlen(prefix) + strlen(cl->nick) > 510) {
                        append_str(&databuf, "\r\n");
@@ -485,287 +424,221 @@ int rpl_namreply(Client *client, Channel *chan, Client *cl) // 353
        append_strf(&databuf, "%s%s", prefix, cl->nick);
        return 0;
 }
-void rpl_endofnames(Client *client, const char *channel) // 366
-{
-       copy_strf(&databuf, ":%s 366 %s %s :End of /NAMES list\r\n", hostname, client->nick, channel);
+void rpl_endofnames(Client *client, const char *channel) { // 366
+       num_reply(366, " %s :End of /NAMES list\r\n", channel);
 }
 // 364 RPL_LINKS
 // 365 RPL_ENDOFLINKS
-void rpl_banlist(Client *client, Channel *chan, std::string_view mask) // 367
-{
-       copy_strf(&databuf, ":%s 367 %s %s %.*s\r\n", hostname, client->nick, chan->name, (int)mask.size(), mask.data());
+void rpl_banlist(Client *client, Channel *chan, std::string_view mask) { // 367
+       num_reply(367, " %s %.*s\r\n", chan->name, (int)mask.size(), mask.data());
 }
-void rpl_endofbanlist(Client *client, Channel *chan) // 368
-{
-       copy_strf(&databuf, ":%s 368 %s %s :End of channel ban list\r\n", hostname, client->nick, chan->name);
+void rpl_endofbanlist(Client *client, Channel *chan) { // 368
+       num_reply(368, " %s :End of channel ban list\r\n", chan->name);
 }
 // 369 RPL_ENDOFWHOWAS
 // 371 RPL_INFO
 // 374 RPL_ENDOFINFO
-void rpl_motdstart(Client *client) // 375
-{
-       copy_strf(&databuf, ":%s 375 %s :- %s Message of the day - \r\n", hostname, client->nick, hostname);
+void rpl_motdstart(Client *client) { // 375
+       num_reply(375, " :- %s Message of the day - \r\n", hostname);
 }
-void rpl_motd(Client *client, const char *line) // 372
-{
-       copy_strf(&databuf, ":%s 372 %s :%s\r\n", hostname, client->nick, line);
+void rpl_motd(Client *client, const char *line) { // 372
+       num_reply(372, " :%s\r\n", line);
 }
-void rpl_endofmotd(Client *client) // 376
-{
-       copy_strf(&databuf, ":%s 376 %s :End of /MOTD command.\r\n", hostname, client->nick);
+void rpl_endofmotd(Client *client) { // 376
+       num_reply(376, " :End of /MOTD command.\r\n");
 }
 // 378 RPL_WHOISHOST
-void rpl_whoismodes(Client *client, Client *cl) // 379
-{
-       copy_strf(&databuf, ":%s 379 %s %s :is using modes %s\r\n", hostname, client->nick, cl->nick, format_umodes(cl));
+void rpl_whoismodes(Client *client, Client *cl) { // 379
+       num_reply(379, " %s :is using modes %s\r\n", cl->nick, format_umodes(cl));
 }
-void rpl_youreoper(Client *client) // 381
-{
-       copy_strf(&databuf, ":%s 381 %s :You are now an IRC operator\r\n", hostname, client->nick);
+void rpl_youreoper(Client *client) { // 381
+       num_reply(381, " :You are now an IRC operator\r\n");
 }
 // 382 RPL_REHASHING
-void rpl_time(Client *client, time_t ts) // 391
-{
+void rpl_time(Client *client, time_t ts) { // 391
        char buf[26];
        memcpy(buf, ctime(&ts), 26);
        buf[24] = '\0';
-       copy_strf(&databuf, ":%s 391 %s %s :%s\r\n", hostname, client->nick, ts, buf);
+       num_reply(391, " %s :%s\r\n", ts, buf);
 }
-void rpl_visiblehost(Client *client) // 396
-{
-       copy_strf(&databuf, ":%s 396 %s %s@%s :is now you visible host\r\n", hostname, client->nick, client->username, client->hostname);
+void rpl_visiblehost(Client *client) { // 396
+       num_reply(396, " %s@%s :is now you visible host\r\n", client->username, client->hostname);
 }
-#if 0
-void err_unknownerror(Client *client, const char *command, const char *msg) // 400
-{
-       copy_strf(&databuf, ":%s 400 %s %s :%s\r\n", hostname, client->nick, command, msg);
+#if WANT_UNUSED
+void err_unknownerror(Client *client, const char *command, const char *msg) { // 400
+       num_reply(400, " %s :%s\r\n", command, msg);
 }
 #endif
-void err_nosuchnick(Client *client, const char *nick) // 401
-{
-       copy_strf(&databuf, ":%s 401 %s %s :No such nick/channel\r\n", hostname, client->nick, nick);
+void err_nosuchnick(Client *client, const char *nick) { // 401
+       num_reply(401, " %s :No such nick/channel\r\n", nick);
 }
-void err_nosuchserver(Client *client, const char *server) // 402
-{
-       copy_strf(&databuf, ":%s 402 %s %s :No such server\r\n", hostname, client->nick, server);
+void err_nosuchserver(Client *client, const char *server) { // 402
+       num_reply(402, " %s :No such server\r\n", server);
 }
-void err_nosuchchannel(Client *client, const char *channel) // 403
-{
-       copy_strf(&databuf, ":%s 403 %s %s :No such channel\r\n", hostname, client->nick, channel);
+void err_nosuchchannel(Client *client, const char *channel) { // 403
+       num_reply(403, " %s :No such channel\r\n", channel);
 }
-void err_cannotsendtochan(Client *client, const char *channel) // 404
-{
-       copy_strf(&databuf, ":%s 404 %s %s :Cannot send to channel\r\n", hostname, client->nick, channel);
+void err_cannotsendtochan(Client *client, const char *channel) { // 404
+       num_reply(404, " %s :Cannot send to channel\r\n", channel);
 }
-#if 0
-void err_toomanychannels(Client *client, const char *channel) // 405
-{
-       copy_strf(&databuf, ":%s 405 %s %s :You have joined too many channels\r\n", hostname, client->nick, channel);
+#if WANT_UNUSED
+void err_toomanychannels(Client *client, const char *channel) { // 405
+       num_reply(405, " %s :You have joined too many channels\r\n", channel);
 }
-void err_wasnosuchnick(Client *client) // 406
-{
-       copy_strf(&databuf, ":%s 406 %s :There was no such nickname\r\n", hostname, client->nick);
+void err_wasnosuchnick(Client *client) { // 406
+       num_reply(406, " :There was no such nickname\r\n");
 }
-void err_noorigin(Client *client) // 409
-{
-       copy_strf(&databuf, ":%s 409 %s :No origin specified\r\n", hostname, client->nick);
+void err_noorigin(Client *client) { // 409
+       num_reply(409, " :No origin specified\r\n");
 }
-void err_inputtoolong(Client *client) // 417
-{
-       copy_strf(&databuf, ":%s 417 %s :Input line was too long\r\n", hostname, client->nick);
+void err_inputtoolong(Client *client) { // 417
+       num_reply(417, " :Input line was too long\r\n");
 }
 #endif
-void err_unknowncommand(Client *client, std::string_view command) // 421
-{
-       copy_strf(&databuf, ":%s 421 %s %.*s :Unknown command\r\n", hostname, client->nick ? client->nick : "*", (int)command.size(), command.data());
+void err_unknowncommand(Client *client, std::string_view command) { // 421
+       num_reply_check_nick(421, " %.*s :Unknown command\r\n", (int)command.size(), command.data());
 }
-void err_nomotd(Client *client) // 422
-{
-       copy_strf(&databuf, ":%s 422 %s :MOTD File is missing\r\n", hostname, client->nick);
+void err_nomotd(Client *client) { // 422
+       num_reply(422, " :MOTD File is missing\r\n");
 }
-void err_erroneusnickname(Client *client, const char *nick) // 432
-{
-       copy_strf(&databuf, ":%s 432 %s %s :Erroneus nickname\r\n", hostname, client->nick, nick);
+void err_erroneusnickname(Client *client, const char *nick) { // 432
+       num_reply_check_nick(432, " %s :Erroneus nickname\r\n", nick);
 }
-void err_nicknameinuse(Client *client, const char *nick) // 433
-{
-       copy_strf(&databuf, ":%s 433 %s %s :Nickname is already in use\r\n", hostname, client->nick ? client->nick : "*", nick);
+void err_nicknameinuse(Client *client, const char *nick) { // 433
+       num_reply_check_nick(433, " %s :Nickname is already in use\r\n", nick);
 }
-void err_usernotinchannel(Client *client, const char *nick, Channel *chan) // 441
-{
-       copy_strf(&databuf, ":%s 441 %s %s %s :They aren't on that channel\r\n", hostname, client->nick, nick, chan->name);
+void err_usernotinchannel(Client *client, const char *nick, Channel *chan) { // 441
+       num_reply(441, " %s %s :They aren't on that channel\r\n", nick, chan->name);
 }
-void err_notonchannel(Client *client, Channel *chan) // 442
-{
-       copy_strf(&databuf, ":%s 442 %s %s :You're not on that channel\r\n", hostname, client->nick, chan->name);
+void err_notonchannel(Client *client, Channel *chan) { // 442
+       num_reply(442, " %s :You're not on that channel\r\n", chan->name);
 }
-void err_useronchannel(Client *client, const char *nick, Channel *chan) // 443
-{
-       copy_strf(&databuf, ":%s 443 %s %s %s :is already on channel\r\n", hostname, client->nick, nick, chan->name);
+void err_useronchannel(Client *client, const char *nick, Channel *chan) { // 443
+       num_reply(443, " %s %s :is already on channel\r\n", nick, chan->name);
 }
-void err_notregistered(Client *client) // 451
-{
-       (void)client;
-       copy_strf(&databuf, ":%s 451 * :You have not registered\r\n", hostname);
+void err_notregistered(void) { // 451
+       num_reply_anon(451, " :You have not registered\r\n");
 }
-void err_needmoreparams(Client *client, std::string_view command) // 461
-{
-       copy_strf(&databuf, ":%s 461 %s %.*s :Not enough parameters\r\n", hostname, client->nick ? client->nick : "*", (int)command.size(), command.data());
+void err_needmoreparams(Client *client, std::string_view command) { // 461
+       num_reply_check_nick(461, " %.*s :Not enough parameters\r\n", (int)command.size(), command.data());
 }
-void err_alreadyregistered(Client *client) // 462
-{
-       copy_strf(&databuf, ":%s 462 %s :You may not reregister\r\n", hostname, client->nick ? client->nick : "*");
+void err_alreadyregistered(Client *client) { // 462
+       num_reply_check_nick(462, " :You may not reregister\r\n");
 }
-void err_passwdmismatch(Client *client) // 464
-{
-       copy_strf(&databuf, ":%s 464 %s :Password incorrect\r\n", hostname, client->nick ? client->nick : "*");
+void err_passwdmismatch(Client *client) { // 464
+       num_reply_check_nick(464, " :Password incorrect\r\n");
 }
-#if 0
-void err_yourebannedcreep(Client *client) // 465
-{
-       copy_strf(&databuf, ":%s 465 %s :You are banned from this server.\r\n", hostname, client->nick ? client->nick : "*");
+#if WANT_UNUSED
+void err_yourebannedcreep(Client *client) { // 465
+       num_reply_check_nick(465, " :You are banned from this server.\r\n");
 }
 #endif
-void err_channelisfull(Client *client, Channel *chan) // 471
-{
-       copy_strf(&databuf, ":%s 471 %s %s :Cannot join channel (+l)\r\n", hostname, client->nick, chan->name);
+void err_channelisfull(Client *client, Channel *chan) { // 471
+       num_reply(471, " %s :Cannot join channel (+l)\r\n", chan->name);
 }
-void err_unknownmode(Client *client, char mode) // 472
-{
+void err_unknownmode(Client *client, char mode) { // 472
        char modes[2] = {mode, 0};
-       copy_strf(&databuf, ":%s 472 %s %s :is unknown mode char to me\r\n", hostname, client->nick, modes);
+       num_reply(472, " %s :is unknown mode char to me\r\n", modes);
 }
-void err_inviteonlychan(Client *client, Channel *chan) // 473
-{
-       copy_strf(&databuf, ":%s 473 %s %s :Cannot join channel (+i)\r\n", hostname, client->nick, chan->name);
+void err_inviteonlychan(Client *client, Channel *chan) { // 473
+       num_reply(473, " %s :Cannot join channel (+i)\r\n", chan->name);
 }
-void err_bannedfromchan(Client *client, Channel *chan) // 474
-{
-       copy_strf(&databuf, ":%s 474 %s %s :Cannot join channel (+b)\r\n", hostname, client->nick, chan->name);
+void err_bannedfromchan(Client *client, Channel *chan) { // 474
+       num_reply(474, " %s :Cannot join channel (+b)\r\n", chan->name);
 }
-void err_badchannelkey(Client *client, Channel *chan) // 475
-{
-       copy_strf(&databuf, ":%s 475 %s %s :Cannot join channel (+k)\r\n", hostname, client->nick, chan->name);
+void err_badchannelkey(Client *client, Channel *chan) { // 475
+       num_reply(475, " %s :Cannot join channel (+k)\r\n", chan->name);
 }
-void err_badchanmask(Client *client, const char *channel) // 476
-{
-       copy_strf(&databuf, ":%s 476 %s :Bad Channel Mask\r\n", hostname, client->nick, channel);
+void err_badchanmask(Client *client, const char *channel) { // 476
+       num_reply(476, " :Bad Channel Mask\r\n", channel);
 }
-void err_noprivileges(Client *client) // 481
-{
-       copy_strf(&databuf, ":%s 481 %s :Permission Denied- You're not an IRC operator\r\n", hostname, client->nick);
+void err_noprivileges(Client *client) { // 481
+       num_reply(481, " :Permission Denied- You're not an IRC operator\r\n");
 }
-void err_chanoprivsneeded(Client *client, Channel *chan) // 481
-{
-       copy_strf(&databuf, ":%s 482 %s %s :You're not channel operator\r\n", hostname, client->nick, chan->name);
+void err_chanoprivsneeded(Client *client, Channel *chan) { // 481
+       num_reply(482, " %s :You're not channel operator\r\n", chan->name);
 }
 // 483 ERR_CANTKILLSERVER
 // 491 ERR_NOOPERHOST
-void err_umodeunknownflag(Client *client) // 501
-{
-       copy_strf(&databuf, ":%s 501 %s :Unknown MODE flag\r\n", hostname, client->nick);
+void err_umodeunknownflag(Client *client) { // 501
+       num_reply(501, " :Unknown MODE flag\r\n");
 }
-void err_usersdontmatch(Client *client, const char *what) // 502
-{
-       copy_strf(&databuf, ":%s 502 %s :%s\r\n", hostname, client->nick, what);
+void err_usersdontmatch(Client *client, const char *what) { // 502
+       num_reply(502, " :%s\r\n", what);
 }
-void err_helpnotfound(Client *client) // 524
-{
-       copy_strf(&databuf, ":%s 524 %s * :No help available on this topic\r\n", hostname, client->nick);
+void err_helpnotfound(Client *client) { // 524
+       num_reply(524, " * :No help available on this topic\r\n");
 }
-void err_invalidkey(Client *client, Channel *chan) // 525
-{
-       copy_strf(&databuf, ":%s 525 %s %s :Key is not well-formed\r\n", hostname, client->nick, chan->name);
+void err_invalidkey(Client *client, Channel *chan) { // 525
+       num_reply(525, " %s :Key is not well-formed\r\n", chan->name);
 }
-void err_cantsendtouser(Client *client, Client *cl) // 531
-{
-       copy_strf(&databuf, ":%s 531 %s %s :You are not permitted to send private messages to this user\r\n", hostname, client->nick, cl->nick);
+void err_cantsendtouser(Client *client, Client *cl) { // 531
+       num_reply(531, " %s :You are not permitted to send private messages to this user\r\n", cl->nick);
 }
 // 670 RPL_STARTTLS
 // 671 RPL_WHOISSECURE
 // 691 ERR_STARTTLS
 // 696 ERR_INVALIDMODEPARAM
-void rpl_helpstart(Client *client) // 704
-{
-       copy_strf(&databuf, ":%s 704 %s * :** /HELP **\r\n", hostname, client->nick);
+void rpl_helpstart(Client *client) { // 704
+       num_reply(704, " * :** /HELP **\r\n");
 }
-void rpl_helptxt(Client *client, const char *line) // 705
-{
-       copy_strf(&databuf, ":%s 705 %s * :%s\r\n", hostname, client->nick, line);
+void rpl_helptxt(Client *client, const char *line) { // 705
+       num_reply(705, " * :%s\r\n", line);
 }
-void rpl_endofhelp(Client *client) // 706
-{
-       copy_strf(&databuf, ":%s 706 %s * :End of /HELP\r\n", hostname, client->nick);
+void rpl_endofhelp(Client *client) { // 706
+       num_reply(706, " * :End of /HELP\r\n");
 }
 // 723 ERR_NOPRIVS
-void rpl_quietlist(Client *client, Channel *chan, std::string_view mask) // 728
-{
-       copy_strf(&databuf, ":%s 728 %s %s q %.*s\r\n", hostname, client->nick, chan->name, (int)mask.size(), mask.data());
+void rpl_quietlist(Client *client, Channel *chan, std::string_view mask) { // 728
+       num_reply(728, " %s q %.*s\r\n", chan->name, (int)mask.size(), mask.data());
 }
-void rpl_endofquietlist(Client *client, Channel *chan) // 729
-{
-       copy_strf(&databuf, ":%s 729 %s %s q :End of channel quiet list\r\n", hostname, client->nick, chan->name);
+void rpl_endofquietlist(Client *client, Channel *chan) { // 729
+       num_reply(729, " %s q :End of channel quiet list\r\n", chan->name);
 }
-void rpl_mononline(Client *client, Client *cl) // 730
-{
-       copy_strf(&databuf, ":%s 730 %s :%s!%s@%s\r\n", hostname, client ? client->nick : "*", cl->nick, cl->username, cl->hostname);
+void rpl_mononline(Client *client, Client *cl) { // 730
+       num_reply_check_nick(730, " :%s!%s@%s\r\n", cl->nick, cl->username, cl->hostname);
 }
-void rpl_monoffline(Client *client, std::string_view nick) // 731
-{
-       copy_strf(&databuf, ":%s 731 %s :%.*s\r\n", hostname, client ? client->nick : "*", (int)nick.size(), nick.data());
+void rpl_monoffline(Client *client, std::string_view nick) { // 731
+       num_reply_check_nick(731, " :%.*s\r\n", (int)nick.size(), nick.data());
 }
-void rpl_monlist(Client *client, std::string_view nick) // 732
-{
-       copy_strf(&databuf, ":%s 732 %s :%.*s\r\n", hostname, client->nick, (int)nick.size(), nick.data());
+void rpl_monlist(Client *client, std::string_view nick) { // 732
+       num_reply(732, " :%.*s\r\n", (int)nick.size(), nick.data());
 }
-void rpl_endofmonlist(Client *client) // 733
-{
-       copy_strf(&databuf, ":%s 733 %s :End of MONITOR list\r\n", hostname, client->nick);
+void rpl_endofmonlist(Client *client) { // 733
+       num_reply(733, " :End of MONITOR list\r\n");
 }
-void rpl_monlistfull(Client *client, int limit, const char *targets) // 734
-{
-       copy_strf(&databuf, ":%s 734 %s %d %s :Monitor list is full.\r\n", hostname, client->nick, limit, targets);
+void rpl_monlistfull(Client *client, int limit, const char *targets) { // 734
+       num_reply(734, " %d %s :Monitor list is full.\r\n", limit, targets);
 }
-void rpl_loggedin(Client *client) // 900
-{
-       copy_strf(&databuf, ":%s 900 %s %s %s :You are now logged in as %s\r\n",
-                       hostname, client->nick ? client->nick : "*", client->nuh, client->username, client->username);
+void rpl_loggedin(Client *client) { // 900
+       num_reply_check_nick(900, " %s %s :You are now logged in as %s\r\n",
+                       client->nuh, client->username, client->username);
 }
-void rpl_loggedout(Client *client) // 901
-{
-       copy_strf(&databuf, ":%s 901 %s %s :You are now logged out\r\n",
-                       hostname, client->nick ? client->nick : "*", client->nuh);
+void rpl_loggedout(Client *client) { // 901
+       num_reply_check_nick(901, " %s :You are now logged out\r\n", client->nuh);
 }
 // 902 ERR_NICKLOCKED
-void rpl_saslsuccess(void) // 903
-{
-       copy_strf(&databuf, ":%s 903 * :SASL authentication successful\r\n", hostname);
+void rpl_saslsuccess(void) { // 903
+       num_reply_anon(903, " :SASL authentication successful\r\n");
 }
-void err_saslfail(void) // 904
-{
-       copy_strf(&databuf, ":%s 904 * :SASL authentication failed\r\n", hostname);
+void err_saslfail(void) { // 904
+       num_reply_anon(904, " :SASL authentication failed\r\n");
 }
-void err_sasltoolong(void) // 905
-{
-       copy_strf(&databuf, ":%s 905 * :SASL message too long\r\n", hostname);
+void err_sasltoolong(void) { // 905
+       num_reply_anon(905, " :SASL message too long\r\n");
 }
-void err_saslaborted(void) // 906
-{
-       copy_strf(&databuf, ":%s 906 * :SASL auhtentication aborted\r\n", hostname);
+void err_saslaborted(void) { // 906
+       num_reply_anon(906, " :SASL auhtentication aborted\r\n");
 }
-void err_saslalready(void) // 907
-{
-       copy_strf(&databuf, ":%s 907 * :You have already authenticated using SASL\r\n", hostname);
+void err_saslalready(void) { // 907
+       num_reply_anon(907, " :You have already authenticated using SASL\r\n");
 }
-void rpl_saslmechs(void) // 908
-{
-       copy_strf(&databuf, ":%s 908 * PLAIN,EXTERNAL :are available SASL mechanisms\r\n", hostname);
+void rpl_saslmechs(void) { // 908
+       num_reply_anon(908, " PLAIN,EXTERNAL :are available SASL mechanisms\r\n");
 }
-void rpl_accesslist(Client *client, Channel *chan, char mode, std::string_view mask) // 910
-{
-       copy_strf(&databuf, ":%s 910 %s %s %c:%.*s\r\n", hostname, client->nick, chan->name, mode, (int)mask.size(), mask.data());
+void rpl_accesslist(Client *client, Channel *chan, char mode, std::string_view mask) { // 910
+       num_reply(910, " %s %c:%.*s\r\n", chan->name, mode, (int)mask.size(), mask.data());
 }
-void rpl_endofaccesslist(Client *client, Channel *chan) // 911
-{
-       copy_strf(&databuf, ":%s 911 %s %s :End of channel access list\r\n", hostname, client->nick, chan->name);
+void rpl_endofaccesslist(Client *client, Channel *chan) { // 911
+       num_reply(911, " %s :End of channel access list\r\n", chan->name);
 }
index 56ad82c..2819699 100644 (file)
@@ -114,7 +114,7 @@ void err_nicknameinuse(Client *client, const char *nick); // 433
 void err_usernotinchannel(Client *client, const char *nick, Channel *chan); // 441
 void err_notonchannel(Client *client, Channel *chan); // 442
 void err_useronchannel(Client *client, const char *nick, Channel *chan); // 443
-void err_notregistered(Client *client); // 451
+void err_notregistered(void); // 451
 void err_needmoreparams(Client *client, std::string_view command); // 461
 void err_alreadyregistered(Client *client); // 462
 void err_passwdmismatch(Client *client); // 464