* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
*/
+/** @file
+ * @brief Error handling support.
+ * @version $Id$
+ */
+#include "config.h"
+
#include "numeric.h"
+#include "ircd_log.h"
#include "s_debug.h"
-#include "sprintf_irc.h"
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
#include <string.h>
+/** Array of Numeric replies, indexed by numeric. */
static Numeric replyTable[] = {
/* 000 */
{ 0 },
/* 001 */
- { RPL_WELCOME, ":Welcome to the Internet Relay Network %s", "001" },
+ { RPL_WELCOME, ":Welcome to the %s IRC Network%s%s, %s", "001" },
/* 002 */
{ RPL_YOURHOST, ":Your host is %s, running version %s", "002" },
/* 003 */
{ RPL_CREATED, ":This server was created %s", "003" },
/* 004 */
- { RPL_MYINFO, "%s %s dioswkg biklmnopstv", "004" },
+ { RPL_MYINFO, "%s %s %s %s %s", "004" },
/* 005 */
{ RPL_ISUPPORT, "%s :are supported by this server", "005" },
/* 006 */
/* 007 */
{ 0 },
/* 008 */
- { RPL_SNOMASK, "%d :: Server notice mask (%#x)", "008" },
+ { RPL_SNOMASK, "%u :: Server notice mask (%#x)", "008" },
/* 009 */
- { RPL_STATMEMTOT, "%u %u :Bytes Blocks", "009" },
+ { 0 },
/* 010 */
-#ifdef MEMSIZESTATS
- { RPL_STATMEM, "%u %u %s %u", "010" },
-#else
- { RPL_STATMEM, "%u %u %s", "010" },
-#endif
+ { 0 },
/* 011 */
{ 0 },
/* 012 */
/* 014 */
{ 0 },
/* 015 */
- { RPL_MAP, ":%s%s%s %s [%i clients]", "015" },
+ { RPL_MAP, ":%s%s%s %s [%u clients]", "015" },
/* 016 */
{ RPL_MAPMORE, ":%s%s --> *more*", "016" },
/* 017 */
/* 029 */
{ 0 },
/* 030 */
- { 0 },
+ { RPL_APASSWARN_SET, ":Channel Admin password (+A) set to '%s'. Are you SURE you want to use this as Admin password? You will NOT be able to change this password anymore once the channel is more than 48 hours old!", "030" },
/* 031 */
- { 0 },
+ { RPL_APASSWARN_SECRET, ":Use \"/MODE %s -A %s\" to remove the password and then immediately set a new one. IMPORTANT: YOU CANNOT RECOVER THIS PASSWORD, EVER; WRITE THE PASSWORD DOWN (don't store this rescue password on disk)! Now set the channel user password (+U).", "031" },
/* 032 */
- { 0 },
+ { RPL_APASSWARN_CLEAR, ":WARNING: You removed the channel Admin password (+A). If you disconnect or leave the channel without setting a new password then you will not be able to set it again! SET A NEW PASSWORD NOW!", "032" },
/* 033 */
{ 0 },
/* 034 */
/* 199 */
{ 0 },
/* 200 */
- { RPL_TRACELINK, "Link %s%s %s %s", "200" },
+ { RPL_TRACELINK, "Link %s.%s %s %s", "200" },
/* 201 */
- { RPL_TRACECONNECTING, "Try. %d %s", "201" },
+ { RPL_TRACECONNECTING, "Try. %s %s", "201" },
/* 202 */
- { RPL_TRACEHANDSHAKE, "H.S. %d %s", "202" },
+ { RPL_TRACEHANDSHAKE, "H.S. %s %s", "202" },
/* 203 */
- { RPL_TRACEUNKNOWN, "???? %d %s", "203" },
+ { RPL_TRACEUNKNOWN, "???? %s %s", "203" },
/* 204 */
- { RPL_TRACEOPERATOR, "Oper %d %s %ld", "204" },
+ { RPL_TRACEOPERATOR, "Oper %s %s %ld", "204" },
/* 205 */
- { RPL_TRACEUSER, "User %d %s %ld", "205" },
+ { RPL_TRACEUSER, "User %s %s %ld", "205" },
/* 206 */
- { RPL_TRACESERVER, "Serv %d %dS %dC %s %s!%s@%s %ld %ld", "206" },
+ { RPL_TRACESERVER, "Serv %s %dS %dC %s %s!%s@%s %ld %ld", "206" },
/* 207 */
{ 0 },
/* 208 */
{ RPL_TRACENEWTYPE, "<newtype> 0 %s", "208" },
/* 209 */
- { RPL_TRACECLASS, "Class %d %d", "209" },
+ { RPL_TRACECLASS, "Class %s %u", "209" },
/* 210 */
{ 0 },
/* 211 */
/* 212 */
{ RPL_STATSCOMMANDS, "%s %u %u", "212" },
/* 213 */
- { RPL_STATSCLINE, "%c %s * %s %d %d", "213" },
+ { RPL_STATSCLINE, "C %s * %d %d %s %s", "213" },
/* 214 */
- { RPL_STATSNLINE, "%c %s * %s %d %d", "214" },
+ { 0 },
/* 215 */
- { RPL_STATSILINE, "%c %s * %s %d %d", "215" },
+ { RPL_STATSILINE, "I %s%s%s %d %s%s %d %s", "215" },
/* 216 */
- { RPL_STATSKLINE, "%c %s \"%s\" %s 0 0", "216" },
+ { RPL_STATSKLINE, "%c %s@%s \"%s\" \"%s\" 0 0", "216" },
/* 217 */
{ RPL_STATSPLINE, "P %d %d %s %s", "217" },
/* 218 */
- { RPL_STATSYLINE, "%c %d %d %d %d %ld %d", "218" },
+ { RPL_STATSYLINE, "%c %s %d %d %u %u %u", "218" },
/* 219 */
- { RPL_ENDOFSTATS, "%c :End of /STATS report", "219" },
+ { RPL_ENDOFSTATS, "%s :End of /STATS report", "219" },
/* 220 */
{ 0 },
/* 221 */
{ RPL_UMODEIS, "%s", "221" },
/* 222 */
- { 0 },
+ { RPL_STATSJLINE, "J %s", "222" },
/* 223 */
{ 0 },
/* 224 */
/* 225 */
{ 0 },
/* 226 */
- { 0 },
+ { RPL_STATSALINE, "%s", "226" },
/* 227 */
{ 0 },
/* 228 */
- { 0 },
+ { RPL_STATSQLINE, "Q %s :%s", "228" },
/* 229 */
{ 0 },
/* 230 */
{ 0 },
/* 231 */
- { RPL_SERVICEINFO, 0, "231" },
+ { 0 },
/* 232 */
- { RPL_ENDOFSERVICES, 0, "232" },
+ { 0 },
/* 233 */
- { RPL_SERVICE, 0, "233" },
+ { 0 },
/* 234 */
- { RPL_SERVLIST, 0, "234" },
+ { 0 },
/* 235 */
- { RPL_SERVLISTEND, 0, "235" },
-/* 236 */
{ 0 },
+/* 236 */
+ { RPL_STATSVERBOSE, "V :Sent as explicit", "236" },
/* 237 */
- { 0 },
+ { RPL_STATSENGINE, "%s :Event loop engine", "237" },
/* 238 */
- { RPL_STATSFLINE, "%c %s %s", "238" },
+ { RPL_STATSFLINE, "F %s %s", "238" },
/* 239 */
{ 0 },
/* 240 */
{ 0 },
/* 241 */
- { RPL_STATSLLINE, "%c %s * %s %d %d", "241" },
+ { RPL_STATSLLINE, "Module Description EntryPoint", "241" },
/* 242 */
{ RPL_STATSUPTIME, ":Server Up %d days, %d:%02d:%02d", "242" },
/* 243 */
- { RPL_STATSOLINE, "%c %s * %s %d %d", "243" },
+ { RPL_STATSOLINE, "%c %s@%s * %s %s", "243" },
/* 244 */
- { RPL_STATSHLINE, "%c %s * %s %d %d", "244" },
+ { 0 },
/* 245 */
{ 0 },
/* 246 */
{ RPL_STATSTLINE, "%c %s %s", "246" },
/* 247 */
- { RPL_STATSGLINE, "%c %s@%s " TIME_T_FMT " :%s", "247" },
+ { RPL_STATSGLINE, "%c %s%s%s %Tu %c :%s", "247" },
/* 248 */
- { RPL_STATSULINE, "%c %s %s %s %d %d", "248" },
+ { RPL_STATSULINE, "U %s", "248" },
/* 249 */
{ RPL_STATSDEBUG, 0, "249" },
/* 250 */
- { RPL_STATSCONN, ":Highest connection count: %d (%d clients)", "250" },
+ { RPL_STATSCONN, ":Highest connection count: %u (%u clients)", "250" },
/* 251 */
- { RPL_LUSERCLIENT, ":There are %d users and %d invisible on %d servers", "251" },
+ { RPL_LUSERCLIENT, ":There are %u users and %u invisible on %u servers", "251" },
/* 252 */
- { RPL_LUSEROP, "%d :operator(s) online", "252" },
+ { RPL_LUSEROP, "%u :operator(s) online", "252" },
/* 253 */
- { RPL_LUSERUNKNOWN, "%d :unknown connection(s)", "253" },
+ { RPL_LUSERUNKNOWN, "%u :unknown connection(s)", "253" },
/* 254 */
- { RPL_LUSERCHANNELS, "%d :channels formed", "254" },
+ { RPL_LUSERCHANNELS, "%u :channels formed", "254" },
/* 255 */
- { RPL_LUSERME, ":I have %d clients and %d servers", "255" },
+ { RPL_LUSERME, ":I have %u clients and %u servers", "255" },
/* 256 */
{ RPL_ADMINME, ":Administrative info about %s", "256" },
/* 257 */
/* 260 */
{ 0 },
/* 261 */
- { RPL_TRACELOG, "File %s %d", "261" },
+ { 0 },
/* 262 */
- { RPL_TRACEPING, "Ping %s %s", "262" },
+ { RPL_TRACEEND, ":End of TRACE", "262" },
/* 263 */
{ 0 },
/* 264 */
/* 270 */
{ RPL_PRIVS, "%s :", "270" },
/* 271 */
- { RPL_SILELIST, "%s %s", "271" },
+ { RPL_SILELIST, "%s %s%s", "271" },
/* 272 */
{ RPL_ENDOFSILELIST, "%s :End of Silence List", "272" },
/* 273 */
/* 275 */
{ RPL_STATSDLINE, "%c %s %s", "275" },
/* 276 */
- { 0 },
+ { RPL_STATSRLINE, "%-9s %-9s %-10s %s", "276" },
/* 277 */
{ 0 },
/* 278 */
/* 279 */
{ 0 },
/* 280 */
- { RPL_GLIST, "%s%s%s " TIME_T_FMT " %s %c :%s", "280" },
+ { RPL_GLIST, "%s%s%s %Tu %s %c :%s", "280" },
/* 281 */
{ RPL_ENDOFGLIST, ":End of G-line List", "281" },
/* 282 */
- { RPL_JUPELIST, "%s " TIME_T_FMT " %s %c :%s", "282" },
+ { RPL_JUPELIST, "%s %Tu %s %c :%s", "282" },
/* 283 */
{ RPL_ENDOFJUPELIST, ":End of Jupe List", "283" },
/* 284 */
/* 299 */
{ 0 },
/* 300 */
- { RPL_NONE, 0, "300" },
+ { 0 },
/* 301 */
{ RPL_AWAY, "%s :%s", "301" },
/* 302 */
/* 303 */
{ RPL_ISON, ":", "303" },
/* 304 */
- { RPL_TEXT, 0, "304" },
+ { 0 },
/* 305 */
{ RPL_UNAWAY, ":You are no longer marked as being away", "305" },
/* 306 */
{ RPL_NOWAWAY, ":You have been marked as being away", "306" },
/* 307 */
- { RPL_USERIP, ":", "307" },
+ { 0 },
/* 308 */
{ 0 },
/* 309 */
/* 321 */
{ RPL_LISTSTART, "Channel :Users Name", "321" },
/* 322 */
- { RPL_LIST, "%s %d :%s", "322" },
+ { RPL_LIST, "%s %u :%s", "322" },
/* 323 */
{ RPL_LISTEND, ":End of /LIST", "323" },
/* 324 */
/* 328 */
{ 0 },
/* 329 */
- { RPL_CREATIONTIME, "%s " TIME_T_FMT, "329" },
+ { RPL_CREATIONTIME, "%s %Tu", "329" },
/* 330 */
- { 0 },
+ { RPL_WHOISACCOUNT, "%s %s :is logged in as", "330" },
/* 331 */
{ RPL_NOTOPIC, "%s :No topic is set.", "331" },
/* 332 */
{ RPL_TOPIC, "%s :%s", "332" },
/* 333 */
- { RPL_TOPICWHOTIME, "%s %s " TIME_T_FMT, "333" },
+ { RPL_TOPICWHOTIME, "%s %s %Tu", "333" },
/* 334 */
{ RPL_LISTUSAGE, ":%s", "334" },
/* 335 */
/* 337 */
{ 0 },
/* 338 */
- { 0 },
+ { RPL_WHOISACTUALLY, "%s %s@%s %s :Actual user@host, Actual IP", "338" },
/* 339 */
{ 0 },
/* 340 */
- { 0 },
+ { RPL_USERIP, ":", "340" },
/* 341 */
{ RPL_INVITING, "%s %s", "341" },
/* 342 */
/* 344 */
{ 0 },
/* 345 */
- { 0 },
+ { RPL_ISSUEDINVITE, "%s %s %s :%s has been invited by %s", "345" },
/* 346 */
{ RPL_INVITELIST, ":%s", "346" },
/* 347 */
/* 354 */
{ RPL_WHOSPCRPL, "%s", "354" },
/* 355 */
- { 0 },
+ { RPL_DELNAMREPLY, "%s", "355" },
/* 356 */
{ 0 },
/* 357 */
/* 360 */
{ 0 },
/* 361 */
- { RPL_KILLDONE, 0, "361" }, /* Not used */
+ { 0 },
/* 362 */
{ RPL_CLOSING, "%s :Operator enforced Close", "362" },
/* 363 */
{ RPL_CLOSEEND, "%d :Connections Closed", "363" },
/* 364 */
- { RPL_LINKS, "%s %s :%d P%u %s", "364" },
+ { RPL_LINKS, "%s %s :%u P%u %s", "364" },
/* 365 */
{ RPL_ENDOFLINKS, "%s :End of /LINKS list.", "365" },
/* 366 */
{ RPL_ENDOFNAMES, "%s :End of /NAMES list.", "366" },
/* 367 */
- { RPL_BANLIST, "%s %s %s " TIME_T_FMT, "367" },
+ { RPL_BANLIST, "%s %s %s %Tu", "367" },
/* 368 */
{ RPL_ENDOFBANLIST, "%s :End of Channel Ban List", "368" },
/* 369 */
/* 372 */
{ RPL_MOTD, ":- %s", "372" },
/* 373 */
- { RPL_INFOSTART, ":Server INFO", "373" },
+ { 0 },
/* 374 */
{ RPL_ENDOFINFO, ":End of /INFO list.", "374" },
/* 375 */
/* 383 */
{ 0 },
/* 384 */
- { RPL_MYPORTIS, "%d :Port to local server is", "384" }, /* not used */
+ { 0 },
/* 385 */
- { RPL_NOTOPERANYMORE, 0, "385" }, /* not used */
+ { 0 },
/* 386 */
{ 0 },
/* 387 */
/* 390 */
{ 0 },
/* 391 */
- { RPL_TIME, "%s " TIME_T_FMT " %ld :%s", "391" },
+ { RPL_TIME, "%s %Tu %ld :%s", "391" },
/* 392 */
{ 0 },
/* 393 */
/* 395 */
{ 0 },
/* 396 */
- { 0 },
+ { RPL_HOSTHIDDEN, "%s :is now your hidden host", "396" },
/* 397 */
{ 0 },
/* 398 */
/* 399 */
{ 0 },
/* 400 */
- { ERR_FIRSTERROR, "", "400" },
+ { 0 },
/* 401 */
{ ERR_NOSUCHNICK, "%s :No such nick", "401" },
/* 402 */
/* 409 */
{ ERR_NOORIGIN, ":No origin specified", "409" },
/* 410 */
- { 0 },
+ { ERR_UNKNOWNCAPCMD, "%s :Unknown CAP subcommand", "410" },
/* 411 */
{ ERR_NORECIPIENT, ":No recipient given (%s)", "411" },
/* 412 */
/* 436 */
{ ERR_NICKCOLLISION, "%s :Nickname collision KILL", "436" },
/* 437 */
- { ERR_BANNICKCHANGE, "%s :Cannot change nickname while banned on channel", "437" },
+ { ERR_BANNICKCHANGE, "%s :Cannot change nickname while banned on channel or channel is moderated", "437" },
/* 438 */
{ ERR_NICKTOOFAST, "%s :Nick change too fast. Please wait %d seconds.", "438" },
/* 439 */
{ ERR_TARGETTOOFAST, "%s :Target change too fast. Please wait %d seconds.", "439" },
/* 440 */
- { 0 },
+ { ERR_SERVICESDOWN, "%s :Services are currently unavailable.", "440" },
/* 441 */
{ ERR_USERNOTINCHANNEL, "%s %s :They aren't on that channel", "441" },
/* 442 */
/* 476 */
{ ERR_BADCHANMASK, "%s :Bad Channel Mask", "476" },
/* 477 */
- { 0 },
+ { ERR_NEEDREGGEDNICK, "%s :Cannot join channel (+r): this channel requires authentication -- you can obtain an account from %s", "477" },
/* 478 */
{ ERR_BANLISTFULL, "%s %s :Channel ban/ignore list is full", "478" },
/* 479 */
/* 480 */
{ 0 },
/* 481 */
- { ERR_NOPRIVILEGES, ":Permission Denied: You're not an IRC operator", "481" },
+ { ERR_NOPRIVILEGES, ":Permission Denied: Insufficient privileges", "481" },
/* 482 */
{ ERR_CHANOPRIVSNEEDED, "%s :You're not channel operator", "482" },
/* 483 */
{ ERR_CANTKILLSERVER, ":You cant kill a server!", "483" },
/* 484 */
- { ERR_ISCHANSERVICE, "%s %s :Cannot kill, kick or deop channel service", "484" },
+ { ERR_ISCHANSERVICE, "%s %s :Cannot kill, kick or deop a network service", "484" },
/* 485 */
{ 0 },
/* 486 */
/* 490 */
{ 0 },
/* 491 */
- { ERR_NOOPERHOST, ":No O-lines for your host", "491" },
+ { ERR_NOOPERHOST, ":No Operator block for your host", "491" },
/* 492 */
{ 0 },
/* 493 */
/* 500 */
{ 0 },
/* 501 */
- { ERR_UMODEUNKNOWNFLAG, ":Unknown MODE flag", "501" },
+ { ERR_UMODEUNKNOWNFLAG, "%c :Unknown user MODE flag", "501" },
/* 502 */
{ ERR_USERSDONTMATCH, ":Cant change mode for other users", "502" },
/* 503 */
/* 514 */
{ ERR_NOSUCHJUPE, "%s :No such jupe", "514" },
/* 515 */
- { ERR_BADEXPIRE, TIME_T_FMT " :Bad expire time", "515" },
+ { ERR_BADEXPIRE, "%Tu :Bad expire time", "515" },
/* 516 */
{ ERR_DONTCHEAT, " :Don't Cheat.", "516" },
/* 517 */
{ ERR_DISABLED, "%s :Command disabled.", "517" },
/* 518 */
- { 0 },
+ { ERR_LONGMASK, " :Mask is too long", "518" },
/* 519 */
- { 0 },
+ { ERR_TOOMANYUSERS, "%d :Too many users affected by mask", "519" },
/* 520 */
- { 0 },
+ { ERR_MASKTOOWIDE, "%s :Mask is too wide", "520" },
/* 521 */
{ 0 },
/* 522 */
/* 523 */
{ 0 },
/* 524 */
- { 0 },
+ { ERR_QUARANTINED, "%s :Channel is quarantined : %s", "524" },
/* 525 */
{ 0 },
/* 526 */
/* 559 */
{ 0 },
/* 560 */
- { 0 },
+ { ERR_NOTLOWEROPLEVEL, "%s %s %hu %hu :Cannot %s someone with %s op-level", "560" },
/* 561 */
- { 0 },
+ { ERR_NOTMANAGER, "%s :You must be channel Admin to add or remove a password. Use /JOIN %s <AdminPass>.", "561" },
/* 562 */
- { 0 },
+ { ERR_CHANSECURED, "%s :Channel is older than 48 hours and secured. Cannot change Admin pass anymore", "562" },
/* 563 */
- { 0 },
+ { ERR_UPASSSET, "%s :Cannot remove Admin pass (+A) while User pass (+U) is still set. First use /MODE %s -U <userpass>", "563" },
/* 564 */
- { 0 },
+ { ERR_UPASSNOTSET, "%s :Cannot set user pass (+U) until Admin pass (+A) is set. First use /MODE %s +A <adminpass>", "564" },
/* 565 */
{ 0 },
/* 566 */
- { 0 },
+ { ERR_NOMANAGER, "%s :Re-create the channel. The channel must be completely empty for a period of %s before it can be recreated.", "566" },
/* 567 */
- { 0 },
+ { ERR_UPASS_SAME_APASS, "%s :Cannot use the same pass for both admin (+A) and user (+U) pass.", "567" },
/* 568 */
{ 0 },
/* 569 */
{ 0 }
};
+/** Return a pointer to the Numeric for a particular code.
+ * @param n %Numeric to look up.
+ * @return Numeric structure.
+ */
const struct Numeric* get_error_numeric(int n)
{
assert(0 < n);
return &replyTable[n];
}
-static char numbuff[512];
-
-/* "inline" */
-#define prepbuf(buffer, num, tail) \
-{ \
- char *s = buffer + 4; \
- const char *ap = atoi_tab + (num << 2); \
- \
- strcpy(buffer, ":%s 000 %s "); \
- *s++ = *ap++; \
- *s++ = *ap++; \
- *s = *ap; \
- strcpy(s + 5, tail); \
-}
-
-char* err_str(int n)
-{
- Numeric* p;
-
- assert(0 < n);
- assert(n < ERR_LASTERROR);
- assert(0 != replyTable[n].value);
-
- p = &replyTable[n];
- prepbuf(numbuff, p->value, p->format);
-
- return numbuff;
-}
-
+/** Return a format string for a numeric response.
+ * @param n %Numeric to look up.
+ * @return Pointer to a static buffer containing the format string.
+ */
char* rpl_str(int n)
{
+ static char numbuff[512];
Numeric* p;
assert(0 < n);
assert(0 != replyTable[n].value);
p = &replyTable[n];
- prepbuf(numbuff, p->value, p->format);
+ strcpy(numbuff, ":%s 000 %s ");
+ if (p->str) {
+ numbuff[4] = p->str[0];
+ numbuff[5] = p->str[1];
+ numbuff[6] = p->str[2];
+ strcpy(numbuff + 11, p->format);
+ }
return numbuff;
}