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.
24 #include "sprintf_irc.h"
35 static Numeric local_replies[] = {
39 {RPL_WELCOME, ":Welcome to the Internet Relay Network %s"},
41 {RPL_YOURHOST, ":Your host is %s, running version %s"},
43 {RPL_CREATED, ":This server was created %s"},
45 {RPL_MYINFO, "%s %s dioswkg biklmnopstv"},
49 {RPL_MAPMORE, ":%s%s --> *more*"},
51 {RPL_MAPEND, ":End of /MAP"},
53 {RPL_SNOMASK, "%d :: Server notice mask (%#x)"},
55 {RPL_STATMEMTOT, "%u %u :Bytes Blocks"},
58 {RPL_STATMEM, "%u %u %s %u"},
60 {RPL_STATMEM, "%u %u %s"},
65 static Numeric numeric_errors[] = {
67 {ERR_NOSUCHNICK, "%s :No such nick"},
69 {ERR_NOSUCHSERVER, "%s :No such server"},
71 {ERR_NOSUCHCHANNEL, "%s :No such channel"},
73 {ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel"},
75 {ERR_TOOMANYCHANNELS, "%s :You have joined too many channels"},
77 {ERR_WASNOSUCHNICK, "%s :There was no such nickname"},
79 {ERR_TOOMANYTARGETS, "%s :Duplicate recipients. No message delivered"},
83 {ERR_NOORIGIN, ":No origin specified"},
87 {ERR_NORECIPIENT, ":No recipient given (%s)"},
89 {ERR_NOTEXTTOSEND, ":No text to send"},
91 {ERR_NOTOPLEVEL, "%s :No toplevel domain specified"},
93 {ERR_WILDTOPLEVEL, "%s :Wildcard in toplevel Domain"},
97 {ERR_QUERYTOOLONG, "%s :Too many lines in the output, restrict your query"},
107 {ERR_UNKNOWNCOMMAND, "%s :Unknown command"},
109 {ERR_NOMOTD, ":MOTD File is missing"},
111 {ERR_NOADMININFO, "%s :No administrative info available"},
127 {ERR_NONICKNAMEGIVEN, ":No nickname given"},
129 {ERR_ERRONEUSNICKNAME, "%s :Erroneus Nickname"},
131 {ERR_NICKNAMEINUSE, "%s :Nickname is already in use."},
137 {ERR_NICKCOLLISION, "%s :Nickname collision KILL"},
139 {ERR_BANNICKCHANGE, "%s :Cannot change nickname while banned on channel"},
141 {ERR_NICKTOOFAST, "%s :Nick change too fast. Please wait %d seconds."},
143 {ERR_TARGETTOOFAST, "%s :Target change too fast. Please wait %d seconds."},
147 {ERR_USERNOTINCHANNEL, "%s %s :They aren't on that channel"},
149 {ERR_NOTONCHANNEL, "%s :You're not on that channel"},
151 {ERR_USERONCHANNEL, "%s %s :is already on channel"},
167 {ERR_NOTREGISTERED, ":You have not registered"},
187 {ERR_NEEDMOREPARAMS, "%s :Not enough parameters"},
189 {ERR_ALREADYREGISTRED, ":You may not reregister"},
191 {ERR_NOPERMFORHOST, ":Your host isn't among the privileged"},
193 {ERR_PASSWDMISMATCH, ":Password Incorrect"},
195 {ERR_YOUREBANNEDCREEP, ":You are banned from this server"},
197 {ERR_YOUWILLBEBANNED, (char *)NULL},
199 {ERR_KEYSET, "%s :Channel key already set"},
201 {ERR_INVALIDUSERNAME, (char *)NULL},
207 {ERR_CHANNELISFULL, "%s :Cannot join channel (+l)"},
209 {ERR_UNKNOWNMODE, "%c :is unknown mode char to me"},
211 {ERR_INVITEONLYCHAN, "%s :Cannot join channel (+i)"},
213 {ERR_BANNEDFROMCHAN, "%s :Cannot join channel (+b)"},
215 {ERR_BADCHANNELKEY, "%s :Cannot join channel (+k)"},
217 {ERR_BADCHANMASK, "%s :Bad Channel Mask"},
221 {ERR_BANLISTFULL, "%s %s :Channel ban/ignore list is full"},
223 {ERR_BADCHANNAME, "%s :Cannot join channel (access denied on this server)"},
227 {ERR_NOPRIVILEGES, ":Permission Denied- You're not an IRC operator"},
229 {ERR_CHANOPRIVSNEEDED, "%s :You're not channel operator"},
231 {ERR_CANTKILLSERVER, ":You cant kill a server!"},
233 {ERR_ISCHANSERVICE, "%s %s :Cannot kill, kick or deop channel service"},
243 {ERR_VOICENEEDED, "%s :You're neither voiced nor channel operator"},
247 {ERR_NOOPERHOST, ":No O-lines for your host"},
267 {ERR_UMODEUNKNOWNFLAG, ":Unknown MODE flag"},
269 {ERR_USERSDONTMATCH, ":Cant change mode for other users"},
287 {ERR_SILELISTFULL, "%s :Your silence list is full"},
289 {ERR_NOSUCHGLINE, "%s@%s :No such gline"},
291 {ERR_BADPING, (char *)NULL}
294 static Numeric numeric_replies[] = {
296 {RPL_NONE, (char *)NULL},
298 {RPL_AWAY, "%s :%s"},
304 {RPL_TEXT, (char *)NULL},
306 {RPL_UNAWAY, ":You are no longer marked as being away"},
308 {RPL_NOWAWAY, ":You have been marked as being away"},
318 {RPL_WHOISUSER, "%s %s %s * :%s"},
320 {RPL_WHOISSERVER, "%s %s :%s"},
322 {RPL_WHOISOPERATOR, "%s :is an IRC Operator"},
324 {RPL_WHOWASUSER, "%s %s %s * :%s"},
326 {RPL_ENDOFWHO, "%s :End of /WHO list."},
330 {RPL_WHOISIDLE, "%s %ld %ld :seconds idle, signon time"},
332 {RPL_ENDOFWHOIS, "%s :End of /WHOIS list."},
334 {RPL_WHOISCHANNELS, "%s :%s"},
338 {RPL_LISTSTART, "Channel :Users Name"},
340 {RPL_LIST, "%s %d :%s"},
342 {RPL_LISTEND, ":End of /LIST"},
344 {RPL_CHANNELMODEIS, "%s %s %s"},
354 {RPL_CREATIONTIME, "%s " TIME_T_FMT},
358 {RPL_NOTOPIC, "%s :No topic is set."},
360 {RPL_TOPIC, "%s :%s"},
362 {RPL_TOPICWHOTIME, "%s %s " TIME_T_FMT},
364 {RPL_LISTUSAGE, ":%s"},
378 {RPL_INVITING, "%s %s"},
398 {RPL_VERSION, "%s.%s %s :%s"},
400 {RPL_WHOREPLY, "%s"},
402 {RPL_NAMREPLY, "%s"},
404 {RPL_WHOSPCRPL, "%s"},
418 {RPL_KILLDONE, (char *)NULL},
420 {RPL_CLOSING, "%s :Closed. Status = %d"},
422 {RPL_CLOSEEND, "%d: Connections Closed"},
425 {RPL_LINKS, "%s %s :%d P%u %s"},
427 {RPL_LINKS, "%s %s :%d P%u " TIME_T_FMT " (%s) %s"},
430 {RPL_ENDOFLINKS, "%s :End of /LINKS list."},
432 {RPL_ENDOFNAMES, "%s :End of /NAMES list."},
434 {RPL_BANLIST, "%s %s %s " TIME_T_FMT},
436 {RPL_ENDOFBANLIST, "%s :End of Channel Ban List"},
438 {RPL_ENDOFWHOWAS, "%s :End of WHOWAS"},
446 {RPL_INFOSTART, ":Server INFO"},
448 {RPL_ENDOFINFO, ":End of /INFO list."},
450 {RPL_MOTDSTART, ":- %s Message of the Day - "},
452 {RPL_ENDOFMOTD, ":End of /MOTD command."},
462 {RPL_YOUREOPER, ":You are now an IRC Operator"},
464 {RPL_REHASHING, "%s :Rehashing"},
468 {RPL_MYPORTIS, "%d :Port to local server is\r\n"},
470 {RPL_NOTOPERANYMORE, (char *)NULL},
482 {RPL_TIME, "%s " TIME_T_FMT " %ld :%s"},
501 {RPL_TRACELINK, "Link %s%s %s %s"},
503 {RPL_TRACELINK, "Link %s%s %s %s " TIME_T_FMT},
506 {RPL_TRACECONNECTING, "Try. %d %s"},
508 {RPL_TRACEHANDSHAKE, "H.S. %d %s"},
510 {RPL_TRACEUNKNOWN, "???? %d %s"},
512 {RPL_TRACEOPERATOR, "Oper %d %s %ld"},
514 {RPL_TRACEUSER, "User %d %s %ld"},
516 {RPL_TRACESERVER, "Serv %d %dS %dC %s %s!%s@%s %ld %ld"},
520 {RPL_TRACENEWTYPE, "<newtype> 0 %s"},
522 {RPL_TRACECLASS, "Class %d %d"},
526 {RPL_STATSLINKINFO, (char *)NULL},
528 {RPL_STATSCOMMANDS, "%s %u %u"},
530 {RPL_STATSCLINE, "%c %s * %s %d %d"},
532 {RPL_STATSNLINE, "%c %s * %s %d %d"},
534 {RPL_STATSILINE, "%c %s * %s %d %d"},
536 {RPL_STATSKLINE, "%c %s %s %s %d %d"},
538 {RPL_STATSPLINE, "%c %d %d %#x"},
540 {RPL_STATSYLINE, "%c %d %d %d %d %ld"},
542 {RPL_ENDOFSTATS, "%c :End of /STATS report"},
566 {RPL_SERVICEINFO, (char *)NULL},
568 {RPL_ENDOFSERVICES, (char *)NULL},
570 {RPL_SERVICE, (char *)NULL},
572 {RPL_SERVLIST, (char *)NULL},
574 {RPL_SERVLISTEND, (char *)NULL},
586 {RPL_STATSLLINE, "%c %s * %s %d %d"},
588 {RPL_STATSUPTIME, ":Server Up %d days, %d:%02d:%02d"},
590 {RPL_STATSOLINE, "%c %s * %s %d %d"},
592 {RPL_STATSHLINE, "%c %s * %s %d %d"},
596 {RPL_STATSTLINE, "%c %s %s"},
598 {RPL_STATSGLINE, "%c %s@%s " TIME_T_FMT " :%s"},
600 {RPL_STATSULINE, "%c %s %s %s %d %d"},
604 {RPL_STATSCONN, ":Highest connection count: %d (%d clients)"},
606 {RPL_LUSERCLIENT, ":There are %d users and %d invisible on %d servers"},
608 {RPL_LUSEROP, "%d :operator(s) online"},
610 {RPL_LUSERUNKNOWN, "%d :unknown connection(s)"},
612 {RPL_LUSERCHANNELS, "%d :channels formed"},
614 {RPL_LUSERME, ":I have %d clients and %d servers"},
616 {RPL_ADMINME, ":Administrative info about %s"},
618 {RPL_ADMINLOC1, ":%s"},
620 {RPL_ADMINLOC2, ":%s"},
622 {RPL_ADMINEMAIL, ":%s"},
626 {RPL_TRACELOG, "File %s %d"},
628 {RPL_TRACEPING, "Ping %s %s"},
646 {RPL_SILELIST, "%s %s"},
648 {RPL_ENDOFSILELIST, "%s :End of Silence List"},
654 {RPL_STATSDLINE, "%c %s %s"},
664 {RPL_GLIST, "%s@%s " TIME_T_FMT " %s%s"},
666 {RPL_ENDOFGLIST, ":End of G-line List"}
671 static char numbuff[512];
674 #define prepbuf(buffer, num, tail) \
676 register char *s = buffer + 4; \
677 register const char *ap = atoi_tab + (num << 2); \
679 strcpy(buffer, ":%s 000 %s "); \
683 strcpy(s + 5, tail); \
686 char *err_str(int numeric)
689 Reg2 int num = numeric;
691 num -= numeric_errors[0].num_val;
694 if (num < 0 || num > ERR_USERSDONTMATCH)
696 ":%%s %d %%s :INTERNAL ERROR: BAD NUMERIC! %d", numeric, num);
699 nptr = &numeric_errors[num];
700 if (!nptr->num_form || !nptr->num_val)
701 sprintf_irc(numbuff, ":%%s %d %%s :NO ERROR FOR NUMERIC ERROR %d",
704 prepbuf(numbuff, nptr->num_val, nptr->num_form);
707 nptr = &numeric_errors[num];
708 prepbuf(numbuff, nptr->num_val, nptr->num_form);
714 char *rpl_str(int numeric)
717 Reg2 int num = numeric;
719 if (num > (int)(sizeof(local_replies) / sizeof(Numeric) - 2))
720 num -= (num > 300) ? 300 : 100;
723 if (num < 0 || num > 200)
724 sprintf_irc(numbuff, ":%%s %d %%s :INTERNAL REPLY ERROR: BAD NUMERIC! %d",
729 nptr = &numeric_replies[num];
731 nptr = &local_replies[num];
732 Debug((DEBUG_NUM, "rpl_str: numeric %d num %d nptr %p %d %p",
733 numeric, num, nptr, nptr->num_val, nptr->num_form));
734 if (!nptr->num_form || !nptr->num_val)
735 sprintf_irc(numbuff, ":%%s %d %%s :NO REPLY FOR NUMERIC ERROR %d",
738 prepbuf(numbuff, nptr->num_val, nptr->num_form);
742 nptr = &numeric_replies[num];
744 nptr = &local_replies[num];
745 prepbuf(numbuff, nptr->num_val, nptr->num_form);