This repository has been archived on 2021-04-17. You can view files and clone it, but cannot push or open issues or pull requests.
uIRC/src/command/reply.c

198 lines
6.2 KiB
C

/*
* This file is part of uIRC. (https://git.redxen.eu/caskd/uIRC)
* Copyright (c) 2019-2021 Alex-David Denes
*
* uIRC is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* uIRC is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
*/
#include "uirc/command.h"
#include <stdint.h> // uint_least16_t
#include <stdio.h> // snprintf()
static const uint_least16_t reply_table[] = {
[IRC_RPL_WELCOME] = 1,
[IRC_RPL_YOURHOST] = 2,
[IRC_RPL_CREATED] = 3,
[IRC_RPL_MYINFO] = 4,
[IRC_RPL_BOUNCE] = 5,
#ifdef UIRC_FEATURE_IRCV3
/* TO IRCv3 WG:
* Please, stop complicating implementations
* Get people in the WG that actually care about the protocol and understand why and how standards are written
*
* TO LIBRARY USERS:
* Read the above and go speak with them, or just don't use IRCv3 :)
*/
[IRC_RPL_ISUPPORT] = 5,
#endif /* UIRC_FEATURE_IRCV3 */
[IRC_RPL_TRACELINK] = 200,
[IRC_RPL_TRACECONNECTING] = 201,
[IRC_RPL_TRACEHANDSHAKE] = 202,
[IRC_RPL_TRACEUNKNOWN] = 203,
[IRC_RPL_TRACEOPERATOR] = 204,
[IRC_RPL_TRACEUSER] = 205,
[IRC_RPL_TRACESERVER] = 206,
[IRC_RPL_TRACENEWTYPE] = 208,
[IRC_RPL_STATSLINKINFO] = 211,
[IRC_RPL_STATSCOMMANDS] = 212,
[IRC_RPL_STATSCLINE] = 213,
[IRC_RPL_STATSNLINE] = 214,
[IRC_RPL_STATSILINE] = 215,
[IRC_RPL_STATSKLINE] = 216,
[IRC_RPL_STATSYLINE] = 218,
[IRC_RPL_ENDOFSTATS] = 219,
[IRC_RPL_UMODEIS] = 221,
[IRC_RPL_STATSLLINE] = 241,
[IRC_RPL_STATSUPTIME] = 242,
[IRC_RPL_STATSOLINE] = 243,
[IRC_RPL_STATSHLINE] = 244,
[IRC_RPL_LUSERCLIENT] = 251,
[IRC_RPL_LUSEROP] = 252,
[IRC_RPL_LUSERUNKNOWN] = 253,
[IRC_RPL_LUSERCHANNELS] = 254,
[IRC_RPL_LUSERME] = 255,
[IRC_RPL_ADMINME] = 256,
[IRC_RPL_ADMINLOC1] = 257,
[IRC_RPL_ADMINLOC2] = 258,
[IRC_RPL_ADMINEMAIL] = 259,
[IRC_RPL_TRACELOG] = 261,
[IRC_RPL_NONE] = 300,
[IRC_RPL_AWAY] = 301,
[IRC_RPL_USERHOST] = 302,
[IRC_RPL_ISON] = 303,
[IRC_RPL_UNAWAY] = 305,
[IRC_RPL_NOWAWAY] = 306,
[IRC_RPL_WHOISUSER] = 311,
[IRC_RPL_WHOISSERVER] = 312,
[IRC_RPL_WHOISOPERATOR] = 313,
[IRC_RPL_WHOWASUSER] = 314,
[IRC_RPL_ENDOFWHO] = 315,
[IRC_RPL_WHOISIDLE] = 317,
[IRC_RPL_ENDOFWHOIS] = 318,
[IRC_RPL_WHOISCHANNELS] = 319,
[IRC_RPL_LISTSTART] = 321,
[IRC_RPL_LIST] = 322,
[IRC_RPL_LISTEND] = 323,
[IRC_RPL_CHANNELMODEIS] = 324,
[IRC_RPL_NOTOPIC] = 331,
[IRC_RPL_TOPIC] = 332,
[IRC_RPL_INVITING] = 341,
[IRC_RPL_SUMMONING] = 342,
[IRC_RPL_VERSION] = 351,
[IRC_RPL_WHOREPLY] = 352,
[IRC_RPL_NAMREPLY] = 353,
[IRC_RPL_LINKS] = 364,
[IRC_RPL_ENDOFLINKS] = 365,
[IRC_RPL_ENDOFNAMES] = 366,
[IRC_RPL_BANLIST] = 367,
[IRC_RPL_ENDOFBANLIST] = 368,
[IRC_RPL_ENDOFWHOWAS] = 369,
[IRC_RPL_INFO] = 371,
[IRC_RPL_MOTD] = 372,
[IRC_RPL_ENDOFINFO] = 374,
[IRC_RPL_MOTDSTART] = 375,
[IRC_RPL_ENDOFMOTD] = 376,
[IRC_RPL_YOUREOPER] = 381,
[IRC_RPL_REHASHING] = 382,
[IRC_RPL_TIME] = 391,
[IRC_RPL_USERSSTART] = 392,
[IRC_RPL_USERS] = 393,
[IRC_RPL_ENDOFUSERS] = 394,
[IRC_RPL_NOUSERS] = 395,
[IRC_ERR_NOSUCHNICK] = 401,
[IRC_ERR_NOSUCHSERVER] = 402,
[IRC_ERR_NOSUCHCHANNEL] = 403,
[IRC_ERR_CANNOTSENDTOCHAN] = 404,
[IRC_ERR_TOOMANYCHANNELS] = 405,
[IRC_ERR_WASNOSUCHNICK] = 406,
[IRC_ERR_TOOMANYTARGETS] = 407,
[IRC_ERR_NOORIGIN] = 409,
[IRC_ERR_NORECIPIENT] = 411,
[IRC_ERR_NOTEXTTOSEND] = 412,
[IRC_ERR_NOTOPLEVEL] = 413,
[IRC_ERR_WILDTOPLEVEL] = 414,
[IRC_ERR_UNKNOWNCOMMAND] = 421,
[IRC_ERR_NOMOTD] = 422,
[IRC_ERR_NOADMININFO] = 423,
[IRC_ERR_FILEIRC_ERROR] = 424,
[IRC_ERR_NONICKNAMEGIVEN] = 431,
[IRC_ERR_IRC_ERRONEUSNICKNAME] = 432,
[IRC_ERR_NICKNAMEINUSE] = 433,
[IRC_ERR_NICKCOLLISION] = 436,
[IRC_ERR_USERNOTINCHANNEL] = 441,
[IRC_ERR_NOTONCHANNEL] = 442,
[IRC_ERR_USERONCHANNEL] = 443,
[IRC_ERR_NOLOGIN] = 444,
[IRC_ERR_SUMMONDISABLED] = 445,
[IRC_ERR_USERSDISABLED] = 446,
[IRC_ERR_NOTREGISTERED] = 451,
[IRC_ERR_NEEDMOREPARAMS] = 461,
[IRC_ERR_ALREADYREGISTRED] = 462,
[IRC_ERR_NOPERMFORHOST] = 463,
[IRC_ERR_PASSWDMISMATCH] = 464,
[IRC_ERR_YOUREBANNEDCREEP] = 465,
[IRC_ERR_KEYSET] = 467,
[IRC_ERR_CHANNELISFULL] = 471,
[IRC_ERR_UNKNOWNMODE] = 472,
[IRC_ERR_INVITEONLYCHAN] = 473,
[IRC_ERR_BANNEDFROMCHAN] = 474,
[IRC_ERR_BADCHANNELKEY] = 475,
[IRC_ERR_NOPRIVILEGES] = 481,
[IRC_ERR_CHANOPRIVSNEEDED] = 482,
[IRC_ERR_CANTKILLSERVER] = 483,
[IRC_ERR_NOOPERHOST] = 491,
[IRC_ERR_UMODEUNKNOWNFLAG] = 501,
[IRC_ERR_USERSDONTMATCH] = 502,
#ifdef UIRC_FEATURE_IRCV3
/* https://ircv3.net/registry */
[IRC_RPL_STARTTLS] = 670,
[IRC_ERR_STARTTLS] = 691,
[IRC_RPL_MONONLINE] = 730,
[IRC_RPL_MONOFFLINE] = 731,
[IRC_RPL_MONLIST] = 732,
[IRC_RPL_ENDOFMONLIST] = 733,
[IRC_ERR_MOLISTFULL] = 734,
[IRC_RPL_LOGGEDIN] = 900,
[IRC_RPL_LOGGEDOUT] = 901,
[IRC_ERR_NICKLOCKED] = 902,
[IRC_RPL_SASLSUCCESS] = 903,
[IRC_ERR_SASLFAIL] = 904,
[IRC_ERR_SASLTOOLONG] = 905,
[IRC_ERR_SASLABORTED] = 906,
[IRC_ERR_SASLALREADY] = 907,
[IRC_ERR_SASLMECHS] = 908,
#endif /* UIRC_FEATURE_IRCV3 */
};
uint_least16_t
IRC_RPL(enum uirc_table_replies rpl)
{
return reply_table[rpl];
}
const char*
IRC_RPL_STR(enum uirc_table_replies rpl)
{
static char cmd[4];
snprintf(cmd, 3, "%i", reply_table[rpl]);
return cmd;
}