2 * IRC - Internet Relay Chat, ircd/s_err.c
3 * Copyright (C) 1992 Darren Reed
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 1, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "sprintf_irc.h"
27 static Numeric replyTable[] = {
31 { RPL_WELCOME, ":Welcome to the Internet Relay Network %s", "001" },
33 { RPL_YOURHOST, ":Your host is %s, running version %s", "002" },
35 { RPL_CREATED, ":This server was created %s", "003" },
37 { RPL_MYINFO, "%s %s dioswkg biklmnopstv", "004" },
39 { RPL_ISUPPORT, "%s :are supported by this server", "005" },
45 { RPL_SNOMASK, "%d :: Server notice mask (%#x)", "008" },
47 { RPL_STATMEMTOT, "%u %u :Bytes Blocks", "009" },
50 { RPL_STATMEM, "%u %u %s %u", "010" },
52 { RPL_STATMEM, "%u %u %s", "010" },
63 { RPL_MAP, ":%s%s%s %s [%i clients]", "015" },
65 { RPL_MAPMORE, ":%s%s --> *more*", "016" },
67 { RPL_MAPEND, ":End of /MAP", "017" },
434 { RPL_TRACELINK, "Link %s%s %s %s", "200" },
436 { RPL_TRACELINK, "Link %s%s %s %s " TIME_T_FMT, "200" },
439 { RPL_TRACECONNECTING, "Try. %d %s", "201" },
441 { RPL_TRACEHANDSHAKE, "H.S. %d %s", "202" },
443 { RPL_TRACEUNKNOWN, "???? %d %s", "203" },
445 { RPL_TRACEOPERATOR, "Oper %d %s %ld", "204" },
447 { RPL_TRACEUSER, "User %d %s %ld", "205" },
449 { RPL_TRACESERVER, "Serv %d %dS %dC %s %s!%s@%s %ld %ld", "206" },
453 { RPL_TRACENEWTYPE, "<newtype> 0 %s", "208" },
455 { RPL_TRACECLASS, "Class %d %d", "209" },
459 { RPL_STATSLINKINFO, 0, "211" },
461 { RPL_STATSCOMMANDS, "%s %u %u", "212" },
463 { RPL_STATSCLINE, "%c %s * %s %d %d", "213" },
465 { RPL_STATSNLINE, "%c %s * %s %d %d", "214" },
467 { RPL_STATSILINE, "%c %s * %s %d %d", "215" },
469 { RPL_STATSKLINE, "%c %s %s %s %d %d", "216" },
471 { RPL_STATSPLINE, "P %d %d %s %s", "217" },
473 { RPL_STATSYLINE, "%c %d %d %d %d %ld", "218" },
475 { RPL_ENDOFSTATS, "%c :End of /STATS report", "219" },
479 { RPL_UMODEIS, "%s", "221" },
499 { RPL_SERVICEINFO, 0, "231" },
501 { RPL_ENDOFSERVICES, 0, "232" },
503 { RPL_SERVICE, 0, "233" },
505 { RPL_SERVLIST, 0, "234" },
507 { RPL_SERVLISTEND, 0, "235" },
519 { RPL_STATSLLINE, "%c %s * %s %d %d", "241" },
521 { RPL_STATSUPTIME, ":Server Up %d days, %d:%02d:%02d", "242" },
523 { RPL_STATSOLINE, "%c %s * %s %d %d", "243" },
525 { RPL_STATSHLINE, "%c %s * %s %d %d", "244" },
529 { RPL_STATSTLINE, "%c %s %s", "246" },
531 { RPL_STATSGLINE, "%c %s@%s " TIME_T_FMT " :%s", "247" },
533 { RPL_STATSULINE, "%c %s %s %s %d %d", "248" },
537 { RPL_STATSCONN, ":Highest connection count: %d (%d clients)", "250" },
539 { RPL_LUSERCLIENT, ":There are %d users and %d invisible on %d servers", "251" },
541 { RPL_LUSEROP, "%d :operator(s) online", "252" },
543 { RPL_LUSERUNKNOWN, "%d :unknown connection(s)", "253" },
545 { RPL_LUSERCHANNELS, "%d :channels formed", "254" },
547 { RPL_LUSERME, ":I have %d clients and %d servers", "255" },
549 { RPL_ADMINME, ":Administrative info about %s", "256" },
551 { RPL_ADMINLOC1, ":%s", "257" },
553 { RPL_ADMINLOC2, ":%s", "258" },
555 { RPL_ADMINEMAIL, ":%s", "259" },
559 { RPL_TRACELOG, "File %s %d", "261" },
561 { RPL_TRACEPING, "Ping %s %s", "262" },
579 { RPL_SILELIST, "%s %s", "271" },
581 { RPL_ENDOFSILELIST, "%s :End of Silence List", "272" },
587 { RPL_STATSDLINE, "%c %s %s", "275" },
597 { RPL_GLIST, "%s%s%s " TIME_T_FMT " %s %c :%s", "280" },
599 { RPL_ENDOFGLIST, ":End of G-line List", "281" },
601 { RPL_JUPELIST, "%s " TIME_T_FMT " %s %c :%s", "282" },
603 { RPL_ENDOFJUPELIST, ":End of Jupe List", "283" },
637 { RPL_NONE, 0, "300" },
639 { RPL_AWAY, "%s :%s", "301" },
641 { RPL_USERHOST, ":", "302" },
643 { RPL_ISON, ":", "303" },
645 { RPL_TEXT, 0, "304" },
647 { RPL_UNAWAY, ":You are no longer marked as being away", "305" },
649 { RPL_NOWAWAY, ":You have been marked as being away", "306" },
651 { RPL_USERIP, ":", "307" },
659 { RPL_WHOISUSER, "%s %s %s * :%s", "311" },
661 { RPL_WHOISSERVER, "%s %s :%s", "312" },
663 { RPL_WHOISOPERATOR, "%s :is an IRC Operator", "313" },
665 { RPL_WHOWASUSER, "%s %s %s * :%s", "314" },
667 { RPL_ENDOFWHO, "%s :End of /WHO list.", "315" },
671 { RPL_WHOISIDLE, "%s %ld %ld :seconds idle, signon time", "317" },
673 { RPL_ENDOFWHOIS, "%s :End of /WHOIS list.", "318" },
675 { RPL_WHOISCHANNELS, "%s :%s", "319" },
679 { RPL_LISTSTART, "Channel :Users Name", "321" },
681 { RPL_LIST, "%s %d :%s", "322" },
683 { RPL_LISTEND, ":End of /LIST", "323" },
685 { RPL_CHANNELMODEIS, "%s %s %s", "324" },
695 { RPL_CREATIONTIME, "%s " TIME_T_FMT, "329" },
699 { RPL_NOTOPIC, "%s :No topic is set.", "331" },
701 { RPL_TOPIC, "%s :%s", "332" },
703 { RPL_TOPICWHOTIME, "%s %s " TIME_T_FMT, "333" },
705 { RPL_LISTUSAGE, ":%s", "334" },
719 { RPL_INVITING, "%s %s", "341" },
729 { RPL_INVITELIST, ":%s", "346" },
731 { RPL_ENDOFINVITELIST, ":End of Invite List", "347" },
739 { RPL_VERSION, "%s.%s %s :%s", "351" },
741 { RPL_WHOREPLY, "%s", "352" },
743 { RPL_NAMREPLY, "%s", "353" },
745 { RPL_WHOSPCRPL, "%s", "354" },
759 { RPL_KILLDONE, 0, "361" }, /* Not used */
761 { RPL_CLOSING, "%s :Operator enforced Close", "362" },
763 { RPL_CLOSEEND, "%d :Connections Closed", "363" },
766 { RPL_LINKS, "%s %s :%d P%u %s", "364" },
768 { RPL_LINKS, "%s %s :%d P%u " TIME_T_FMT " (%s) %s", "364" },
771 { RPL_ENDOFLINKS, "%s :End of /LINKS list.", "365" },
773 { RPL_ENDOFNAMES, "%s :End of /NAMES list.", "366" },
775 { RPL_BANLIST, "%s %s %s " TIME_T_FMT, "367" },
777 { RPL_ENDOFBANLIST, "%s :End of Channel Ban List", "368" },
779 { RPL_ENDOFWHOWAS, "%s :End of WHOWAS", "369" },
783 { RPL_INFO, ":%s", "371" },
785 { RPL_MOTD, ":- %s", "372" },
787 { RPL_INFOSTART, ":Server INFO", "373" },
789 { RPL_ENDOFINFO, ":End of /INFO list.", "374" },
791 { RPL_MOTDSTART, ":- %s Message of the Day - ", "375" },
793 { RPL_ENDOFMOTD, ":End of /MOTD command.", "376" },
803 { RPL_YOUREOPER, ":You are now an IRC Operator", "381" },
805 { RPL_REHASHING, "%s :Rehashing", "382" },
809 { RPL_MYPORTIS, "%d :Port to local server is", "384" }, /* not used */
811 { RPL_NOTOPERANYMORE, 0, "385" }, /* not used */
823 { RPL_TIME, "%s " TIME_T_FMT " %ld :%s", "391" },
841 { ERR_FIRSTERROR, "", "400" },
843 { ERR_NOSUCHNICK, "%s :No such nick", "401" },
845 { ERR_NOSUCHSERVER, "%s :No such server", "402" },
847 { ERR_NOSUCHCHANNEL, "%s :No such channel", "403" },
849 { ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel", "404" },
851 { ERR_TOOMANYCHANNELS, "%s :You have joined too many channels", "405" },
853 { ERR_WASNOSUCHNICK, "%s :There was no such nickname", "406" },
855 { ERR_TOOMANYTARGETS, "%s :Duplicate recipients. No message delivered", "407" },
859 { ERR_NOORIGIN, ":No origin specified", "409" },
863 { ERR_NORECIPIENT, ":No recipient given (%s)", "411" },
865 { ERR_NOTEXTTOSEND, ":No text to send", "412" },
867 { ERR_NOTOPLEVEL, "%s :No toplevel domain specified", "413" },
869 { ERR_WILDTOPLEVEL, "%s :Wildcard in toplevel Domain", "414" },
873 { ERR_QUERYTOOLONG, "%s :Too many lines in the output, restrict your query", "416" },
883 { ERR_UNKNOWNCOMMAND, "%s :Unknown command", "421" },
885 { ERR_NOMOTD, ":MOTD File is missing", "422" },
887 { ERR_NOADMININFO, "%s :No administrative info available", "423" },
903 { ERR_NONICKNAMEGIVEN, ":No nickname given", "431" },
905 { ERR_ERRONEUSNICKNAME, "%s :Erroneous Nickname", "432" },
907 { ERR_NICKNAMEINUSE, "%s :Nickname is already in use.", "433" },
913 { ERR_NICKCOLLISION, "%s :Nickname collision KILL", "436" },
915 { ERR_BANNICKCHANGE, "%s :Cannot change nickname while banned on channel", "437" },
917 { ERR_NICKTOOFAST, "%s :Nick change too fast. Please wait %d seconds.", "438" },
919 { ERR_TARGETTOOFAST, "%s :Target change too fast. Please wait %d seconds.", "439" },
923 { ERR_USERNOTINCHANNEL, "%s %s :They aren't on that channel", "441" },
925 { ERR_NOTONCHANNEL, "%s :You're not on that channel", "442" },
927 { ERR_USERONCHANNEL, "%s %s :is already on channel", "443" },
943 { ERR_NOTREGISTERED, ":You have not registered", "451" },
963 { ERR_NEEDMOREPARAMS, "%s :Not enough parameters", "461" },
965 { ERR_ALREADYREGISTRED, ":You may not reregister", "462" },
967 { ERR_NOPERMFORHOST, ":Your host isn't among the privileged", "463" },
969 { ERR_PASSWDMISMATCH, ":Password Incorrect", "464" },
971 { ERR_YOUREBANNEDCREEP, ":You are banned from this server", "465" },
973 { ERR_YOUWILLBEBANNED, "", "466" },
975 { ERR_KEYSET, "%s :Channel key already set", "467" },
977 { ERR_INVALIDUSERNAME, "", "468" },
983 { ERR_CHANNELISFULL, "%s :Cannot join channel (+l)", "471" },
985 { ERR_UNKNOWNMODE, "%c :is unknown mode char to me", "472" },
987 { ERR_INVITEONLYCHAN, "%s :Cannot join channel (+i)", "473" },
989 { ERR_BANNEDFROMCHAN, "%s :Cannot join channel (+b)", "474" },
991 { ERR_BADCHANNELKEY, "%s :Cannot join channel (+k)", "475" },
993 { ERR_BADCHANMASK, "%s :Bad Channel Mask", "476" },
997 { ERR_BANLISTFULL, "%s %s :Channel ban/ignore list is full", "478" },
999 { ERR_BADCHANNAME, "%s :Cannot join channel (access denied on this server)", "479" },
1003 { ERR_NOPRIVILEGES, ":Permission Denied: You're not an IRC operator", "481" },
1005 { ERR_CHANOPRIVSNEEDED, "%s :You're not channel operator", "482" },
1007 { ERR_CANTKILLSERVER, ":You cant kill a server!", "483" },
1009 { ERR_ISCHANSERVICE, "%s %s :Cannot kill, kick or deop channel service", "484" },
1019 { ERR_VOICENEEDED, "%s :You're neither voiced nor channel operator", "489" },
1023 { ERR_NOOPERHOST, ":No O-lines for your host", "491" },
1037 { ERR_ISOPERLCHAN, "%s %s :Cannot kick or deop an IRC Operator on a local channel", "498" },
1043 { ERR_UMODEUNKNOWNFLAG, ":Unknown MODE flag", "501" },
1045 { ERR_USERSDONTMATCH, ":Cant change mode for other users", "502" },
1063 { ERR_SILELISTFULL, "%s :Your silence list is full", "511" },
1065 { ERR_NOSUCHGLINE, "%s :No such gline", "512" },
1067 { ERR_BADPING, "", "513" },
1069 { ERR_NOSUCHJUPE, "%s :No such jupe", "514" },
1071 { ERR_BADEXPIRE, TIME_T_FMT " :Bad expire time", "515" },
1073 { ERR_DONTCHEAT, " :Don't Cheat.", "516" },
1242 const struct Numeric* get_error_numeric(int n)
1245 assert(n < ERR_LASTERROR);
1246 assert(0 != replyTable[n].value);
1248 return &replyTable[n];
1251 static char numbuff[512];
1254 #define prepbuf(buffer, num, tail) \
1256 char *s = buffer + 4; \
1257 const char *ap = atoi_tab + (num << 2); \
1259 strcpy(buffer, ":%s 000 %s "); \
1263 strcpy(s + 5, tail); \
1266 char* err_str(int n)
1271 assert(n < ERR_LASTERROR);
1272 assert(0 != replyTable[n].value);
1275 prepbuf(numbuff, p->value, p->format);
1280 char* rpl_str(int n)
1285 assert(n < ERR_LASTERROR);
1286 assert(0 != replyTable[n].value);
1289 prepbuf(numbuff, p->value, p->format);