From d52374c73bc153bcaf53d995b6ec85c402d6c92f Mon Sep 17 00:00:00 2001 From: Jessica James Date: Thu, 5 Jan 2017 15:45:21 -0500 Subject: [PATCH] Simplified IRC numerics --- Jupiter/IRC_Client.cpp | 38 +- Jupiter/IRC_Numerics.h | 1022 ++++++++++++++-------------------------- 2 files changed, 365 insertions(+), 695 deletions(-) diff --git a/Jupiter/IRC_Client.cpp b/Jupiter/IRC_Client.cpp index 05bd9f3..12bbf09 100644 --- a/Jupiter/IRC_Client.cpp +++ b/Jupiter/IRC_Client.cpp @@ -459,7 +459,7 @@ int Jupiter::IRC::Client::process_line(const Jupiter::ReadableString &line) { switch (numeric) // Numerics that don't rely on a specific connectionStatus. { - case IRC_RPL_BOUNCE: // 010 + case Reply::BOUNCE: // 010 { Jupiter::ReferenceString portToken = Jupiter::ReferenceString::getWord(line, 4, " "); unsigned short port; @@ -499,7 +499,7 @@ int Jupiter::IRC::Client::process_line(const Jupiter::ReadableString &line) case 1: // Socket established -- attempting STARTTLS switch (numeric) { - case IRC_RPL_BOUNCEOLD: // 005 + case Reply::BOUNCEOLD: // 005 if (line.matchi("*:Try server *, port *")) { Jupiter::ReferenceString portToken = Jupiter::ReferenceString::getWord(line, 6, " "); @@ -537,7 +537,7 @@ int Jupiter::IRC::Client::process_line(const Jupiter::ReadableString &line) } break; - case IRC_ERR_UNKNOWNCOMMAND: // 421 + case Error::UNKNOWNCOMMAND: // 421 { Jupiter::ReferenceString command = Jupiter::ReferenceString::getWord(line, 2, " "); if (command.equalsi("STARTTLS")) // Server doesn't support STARTTLS @@ -545,7 +545,7 @@ int Jupiter::IRC::Client::process_line(const Jupiter::ReadableString &line) } break; - case IRC_RPL_STARTTLS: // 670 + case Reply::STARTTLS: // 670 { Jupiter::SecureTCPSocket *t = new Jupiter::SecureTCPSocket(std::move(*m_socket)); delete m_socket; @@ -574,7 +574,7 @@ int Jupiter::IRC::Client::process_line(const Jupiter::ReadableString &line) } break; - case IRC_ERR_STARTTLS: // 691 + case Error::STARTTLS: // 691 Client::startCAP(); break; @@ -629,7 +629,7 @@ int Jupiter::IRC::Client::process_line(const Jupiter::ReadableString &line) } } break; - case IRC_ERR_UNKNOWNCOMMAND: // 421 + case Error::UNKNOWNCOMMAND: // 421 if (w2.equalsi("CAP")) // Server doesn't support CAP { Client::registerClient(); @@ -646,21 +646,21 @@ int Jupiter::IRC::Client::process_line(const Jupiter::ReadableString &line) switch (numeric) { // We'll take any of these 4, just in-case any of them are missing. In general, this will trigger on 001. - case IRC_RPL_MYINFO: // 004 + case Reply::MYINFO: // 004 m_server_name = Jupiter::ReferenceString::getWord(line, 3, " "); - case IRC_RPL_WELCOME: // 001 - case IRC_RPL_YOURHOST: // 002 - case IRC_RPL_CREATED: // 003 + case Reply::WELCOME: // 001 + case Reply::YOURHOST: // 002 + case Reply::CREATED: // 003 m_connection_status = 4; break; // You have a bad nickname! Try the alt. - //case IRC_ERR_NONICKNAMEGIVEN: // 431 -- Not consistently usable due to lack of command field. - case IRC_ERR_ERRONEOUSNICKNAME: // 432 + //case Error::NONICKNAMEGIVEN: // 431 -- Not consistently usable due to lack of command field. + case Error::ERRONEOUSNICKNAME: // 432 erroneous_nickname = true; - case IRC_ERR_NICKNAMEINUSE: // 433 - case IRC_ERR_NICKCOLLISION: // 436 - case IRC_ERR_BANNICKCHANGE: // 437 -- Note: This conflicts with another token. + case Error::NICKNAMEINUSE: // 433 + case Error::NICKCOLLISION: // 436 + case Error::BANNICKCHANGE: // 437 -- Note: This conflicts with another token. const Jupiter::ReadableString &altNick = Jupiter::IRC::Client::readConfigValue("AltNick"_jrs); const Jupiter::ReadableString &configNick = Jupiter::IRC::Client::readConfigValue("Nick"_jrs, "Jupiter"_jrs); @@ -720,7 +720,7 @@ int Jupiter::IRC::Client::process_line(const Jupiter::ReadableString &line) case 4: // Registration verified, but connection process in progress. switch (numeric) { - case IRC_RPL_ISUPPORT: // 005 + case Reply::ISUPPORT: // 005 { size_t pos = line.find("PREFIX=("_jrs); if (pos != Jupiter::INVALID_INDEX) @@ -763,7 +763,7 @@ int Jupiter::IRC::Client::process_line(const Jupiter::ReadableString &line) } } break; - case IRC_RPL_LUSERCLIENT: // 251 + case Reply::LUSERCLIENT: // 251 { Jupiter::StringL key = "RawData."; size_t offset; @@ -1123,7 +1123,7 @@ int Jupiter::IRC::Client::process_line(const Jupiter::ReadableString &line) } // else if ACCOUNT // else if CHGHOST - else if (numeric == IRC_RPL_NAMREPLY) // Some names. + else if (numeric == Reply::NAMREPLY) // Some names. { Jupiter::ReferenceString chan = Jupiter::ReferenceString::getWord(line, 4, " "); Jupiter::ReferenceString names = Jupiter::ReferenceString::substring(line, line.find(':', 1) + 1); @@ -1143,7 +1143,7 @@ int Jupiter::IRC::Client::process_line(const Jupiter::ReadableString &line) Client::addNamesToChannel(*channel, names); } } - else if (numeric == IRC_RPL_ENDOFNAMES) // We're done here. + else if (numeric == Reply::ENDOFNAMES) // We're done here. { Jupiter::ReferenceString chan = Jupiter::ReferenceString::getWord(line, 3, " "); Channel *channel = m_channels.get(chan); diff --git a/Jupiter/IRC_Numerics.h b/Jupiter/IRC_Numerics.h index 5ae7b43..81905e1 100644 --- a/Jupiter/IRC_Numerics.h +++ b/Jupiter/IRC_Numerics.h @@ -1,5 +1,5 @@ /** - * Copyright (C) 2013-2015 Jessica James. + * Copyright (C) 2013-2017 Jessica James. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -19,691 +19,361 @@ #if !defined _IRC_NUMERICS_H_HEADER #define _IRC_NUMERICS_H_HEADER +#include + /** * These numerics are in large part found here: https://www.alien.net.au/irc/irc2numerics.html * Not all numerics from the above list are included (generally conflicting numerics such as RPL_MAP). */ -/** -* To enable the shorter definitions (those without IRC_ in front), define "SHORT_IRC_MACROS" prior to including this file. -*/ +namespace Jupiter +{ + namespace IRC + { + typedef uint_fast16_t NumericType; + + namespace Reply + { + constexpr NumericType WELCOME = 1; /** RFC2812: Post-registration welcome message. */ + constexpr NumericType YOURHOST = 2; /** RFC2812: Post-registration. Your host is this server and I am running some daemon */ + constexpr NumericType CREATED = 3; /** RFC2812: Post-registration. This was was created at some point in time */ + constexpr NumericType MYINFO = 4; /** RFC2812: Post-registration. */ + constexpr NumericType BOUNCEOLD = 5; /** RFC2812/DEPRECATED: 005 is rarely used as a bounce indicator, but was defined in RFC2812. */ + constexpr NumericType ISUPPORT = 5; /** Used to indicate what a server supports. Does not appear in any RFC, but was drafted in 2004. */ + constexpr NumericType SNOMASK = 8; /** Server notice mask */ + constexpr NumericType STATMEMTOT = 9; /** I have no idea what this does. */ + constexpr NumericType BOUNCE = 10; /** Bounce server message. Different syntax from IRC_RPL_BOUNCEOLD */ + constexpr NumericType STATMEM = 10; /** I have no idea what this does. */ + constexpr NumericType YOURCOOKIE = 14; /** I have no idea what this does. */ + constexpr NumericType YOURID = 42; /** Informs you of your unique ID. */ + constexpr NumericType SAVENICK = 43; /** Your nick was force-changed due to a nick collision */ + constexpr NumericType ATTEMPTINGJUNC = 50; /** I have no idea what this does. */ + constexpr NumericType ATTEMPTINGREROUTE = 51; /** I have no idea what this does. */ + + constexpr NumericType TRACELINK = 200; /** RFC1459: "If the TRACE message is destined for another server, all intermediate servers must return a IRC_RPL_TRACELINK reply to indicate that the TRACE passed through it and where its going next."*/ + constexpr NumericType TRACECONNECTING = 201; /** RFC1459 */ + constexpr NumericType TRACEHANDSHAKE = 202; /** RFC1459 */ + constexpr NumericType TRACEUNKNOWN = 203; /** RFC1459 */ + constexpr NumericType TRACEOPERATOR = 204; /** RFC1459 */ + constexpr NumericType TRACEUSER = 205; /** RFC1459 */ + constexpr NumericType TRACESERVER = 206; /** RFC1459 */ + constexpr NumericType TRACESERVICE = 207; /** RFC2812 */ + constexpr NumericType TRACENEWTYPE = 208; /** RFC1459 */ + constexpr NumericType TRACECLASS = 209; /** RFC2812 */ + constexpr NumericType TRACERECONNECT = 210; /** RFC2812 */ + constexpr NumericType STATS = 210; /** I have no idea what this does. */ + constexpr NumericType STATSLINKINFO = 211; /** RFC1459 */ + constexpr NumericType STATSCOMMANDS = 212; /** RFC1459 */ + constexpr NumericType STATSCLINE = 213; /** RFC1459 */ + constexpr NumericType STATSNLINE = 214; /** RFC1459 */ + constexpr NumericType STATSILINE = 215; /** RFC1459 */ + constexpr NumericType STATSKLINE = 216; /** RFC1459 */ + constexpr NumericType STATSQLINE = 217; /** RFC1459 */ + constexpr NumericType STATSYLINE = 218; /** RFC1459 */ + constexpr NumericType ENDOFSTATS = 219; /** RFC1459 */ + constexpr NumericType UMODEIS = 221; /** RFC1459 */ + constexpr NumericType SERVICEINFO = 231; /** RFC1459 */ + constexpr NumericType ENDOFSERVICES = 232; /** RFC1459 */ + constexpr NumericType SERVICE = 233; /** RFC1459 */ + constexpr NumericType SERVLIST = 234; /** RFC2812 */ + constexpr NumericType STATSVERBOSE = 236; /** I have no idea what this does. */ + constexpr NumericType STATSENGINE = 237; /** I have no idea what this does. */ + constexpr NumericType STATSIAUTH = 239; /** I have no idea what this does. */ + constexpr NumericType STATSLLINE = 241; /** RFC1459 */ + constexpr NumericType STATSUPTIME = 242; /** RFC1459 */ + constexpr NumericType STATSOLINE = 243; /** RFC1459 */ + constexpr NumericType STATSHLINE = 244; /** RFC1459 */ + constexpr NumericType STATSSLINE = 245; /** I have no idea what this does. */ + constexpr NumericType STATSPING = 246; /** RFC2812 */ + constexpr NumericType STATSCONN = 250; /** I have no idea what this does. */ + constexpr NumericType LUSERCLIENT = 251; /** RFC1459 */ + constexpr NumericType LUSEROP = 252; /** RFC1459 */ + constexpr NumericType LUSERUNKNOWN = 253; /** RFC1459 */ + constexpr NumericType LUSERCHANNELS = 254; /** RFC1459 */ + constexpr NumericType LUSERME = 255; /** RFC1459 */ + constexpr NumericType ADMINME = 256; /** RFC1459 */ + constexpr NumericType ADMINLOC1 = 257; /** RFC1459 */ + constexpr NumericType ADMINLOC2 = 258; /** RFC1459 */ + constexpr NumericType ADMINEMAIL = 259; /** RFC1459 */ + constexpr NumericType TRACELOG = 261; /** RFC1459 */ + constexpr NumericType TRACEEND = 262; /** RFC2812 */ + constexpr NumericType TRYAGAIN = 263; /** RFC2812 */ + constexpr NumericType LOCALUSERS = 265; /** I have no idea what this does. */ + constexpr NumericType GLOBALUSERS = 266; /** I have no idea what this does. */ + constexpr NumericType START_NETSTAT = 267; /** I have no idea what this does. */ + constexpr NumericType NETSTAT = 268; /** I have no idea what this does. */ + constexpr NumericType END_NETSTAT = 269; /** I have no idea what this does. */ + constexpr NumericType PRIVS = 270; /** I have no idea what this does. */ + constexpr NumericType SILELIST = 271; /** I have no idea what this does. */ + constexpr NumericType ENDOFSILELIST = 272; /** I have no idea what this does. */ + constexpr NumericType NOTIFY = 273; /** I have no idea what this does. */ + constexpr NumericType VCHANEXIST = 276; /** I have no idea what this does. */ + constexpr NumericType VCHANLIST = 277; /** I have no idea what this does. */ + constexpr NumericType VCHANHELP = 278; /** I have no idea what this does. */ + constexpr NumericType GLIST = 280; /** I have no idea what this does. */ + constexpr NumericType CHANINFO_KICKS = 296; /** I have no idea what this does. */ + constexpr NumericType END_CHANINFO = 299; /** I have no idea what this does. */ + + constexpr NumericType NONE = 300; /** RFC1459 */ + constexpr NumericType AWAY = 301; /** RFC1459 */ + constexpr NumericType USERHOST = 302; /** RFC1459 */ + constexpr NumericType ISON = 303; /** RFC1459 */ + constexpr NumericType TEXT = 304; /** I have no idea what this does. Supposedly deprecated? */ + constexpr NumericType UNAWAY = 305; /** RFC1459 */ + constexpr NumericType NOWAWAY = 306; /** RFC1459 */ + constexpr NumericType WHOISUSER = 311; /** RFC1459 */ + constexpr NumericType WHOISSERVER = 312; /** RFC1459 */ + constexpr NumericType WHOISOPERATOR = 313; /** RFC1459 */ + constexpr NumericType WHOWASUSER = 314; /** RFC1459 */ + constexpr NumericType ENDOFWHO = 315; /** RFC1459 */ + constexpr NumericType WHOISCHANOP = 316; /** RFC1459 */ + constexpr NumericType WHOISIDLE = 317; /** RFC1459 */ + constexpr NumericType ENDOFWHOIS = 318; /** RFC1459 */ + constexpr NumericType WHOISCHANNELS = 319; /** RFC1459 */ + constexpr NumericType WHOISVIRT = 320; /** I have no idea what this does. */ + constexpr NumericType WHOIS_HIDDEN = 320; /** I have no idea what this does. */ + constexpr NumericType WHOISSPECIAL = 320; /** I have no idea what this does. */ + constexpr NumericType LISTSTART = 321; /** RFC1459 */ + constexpr NumericType LIST = 322; /** RFC1459 */ + constexpr NumericType LISTEND = 323; /** RFC1459 */ + constexpr NumericType CHANNELMODEIS = 324; /** RFC1459 */ + constexpr NumericType UNIQOPIS = 325; /** RFC2812 */ + constexpr NumericType NOCHANPASS = 326; /** I have no idea what this does. */ + constexpr NumericType CHPASSUNKNOWN = 327; /** I have no idea what this does. */ + constexpr NumericType CHANNEL_URL = 328; /** I have no idea what this does. */ + constexpr NumericType CREATIONTIME = 329; /** I have no idea what this does. */ + constexpr NumericType NOTOPIC = 331; /** RFC1459 */ + constexpr NumericType TOPIC = 332; /** RFC1459 */ + constexpr NumericType TOPICWHOTIME = 333; /** I have no idea what this does. */ + constexpr NumericType BADCHANPASS = 339; /** I have no idea what this does. */ + constexpr NumericType USERIP = 340; /** I have no idea what this does. */ + constexpr NumericType INVITING = 341; /** RFC1459 */ + constexpr NumericType SUMMONING = 342; /** RFC1459 */ + constexpr NumericType INVITED = 345; /** I have no idea what this does. */ + constexpr NumericType INVITELIST = 346; /** RFC2812 */ + constexpr NumericType ENDOFINVITELIST = 347; /** RFC2812 */ + constexpr NumericType EXCEPTLIST = 348; /** RFC2812 */ + constexpr NumericType ENDOFEXCEPTLIST = 349; /** RFC2812 */ + constexpr NumericType VERSION = 351; /** RFC1459 */ + constexpr NumericType WHOREPLY = 352; /** RFC1459 */ + constexpr NumericType NAMREPLY = 353; /** RFC1459 */ + constexpr NumericType WHOSPCRPL = 354; /** I have no idea what this does. */ + constexpr NumericType NAMREPLY_ = 355; /** I have no idea what this does. */ + constexpr NumericType KILLDONE = 361; /** RFC1459 */ + constexpr NumericType CLOSING = 362; /** RFC1459 */ + constexpr NumericType CLOSEEND = 363; /** RFC1459 */ + constexpr NumericType LINKS = 364; /** RFC1459 */ + constexpr NumericType ENDOFLINKS = 365; /** RFC1459 */ + constexpr NumericType ENDOFNAMES = 366; /** RFC1459 */ + constexpr NumericType BANLIST = 367; /** RFC1459 */ + constexpr NumericType ENDOFBANLIST = 368; /** RFC1459 */ + constexpr NumericType ENDOFWHOWAS = 369; /** RFC1459 */ + constexpr NumericType INFO = 371; /** RFC1459 */ + constexpr NumericType MOTD = 372; /** RFC1459 */ + constexpr NumericType INFOSTART = 373; /** RFC1459 */ + constexpr NumericType ENDOFINFO = 374; /** RFC1459 */ + constexpr NumericType MOTDSTART = 375; /** RFC1459 */ + constexpr NumericType ENDOFMOTD = 376; /** RFC1459 */ + constexpr NumericType YOUREOPER = 381; /** RFC1459 */ + constexpr NumericType REHASHING = 382; /** RFC1459 */ + constexpr NumericType YOURESERVICE = 383; /** RFC2812 */ + constexpr NumericType MYPORTIS = 384; /** RFC1459 */ + constexpr NumericType NOTOPERANYMORE = 385; /** You are no longer a server operator */ + constexpr NumericType ALIST = 388; /** I have no idea what this does. */ + constexpr NumericType ENDOFALIST = 389; /** I have no idea what this does. */ + constexpr NumericType TIME = 391; /** RFC1459: TIME command response. [possible extension data] :