Move IRCv3 separately, shorten one bit of the tokenizer
This commit is contained in:
parent
74e13c4724
commit
bd5ab8cc03
|
@ -11,20 +11,13 @@
|
||||||
#define MBMASK_WALLOPS 2 /* 010 */
|
#define MBMASK_WALLOPS 2 /* 010 */
|
||||||
#define MBMASK_INVIS 4 /* 100 */
|
#define MBMASK_INVIS 4 /* 100 */
|
||||||
|
|
||||||
|
#define UIRC_FCMD ADMIN
|
||||||
enum {
|
enum {
|
||||||
ACCOUNT = 10, /* https://ircv3.net/specs/extensions/account-notify-3.1 */
|
|
||||||
ACC, /* https://github.com/ircv3/ircv3-specifications/pull/276 */
|
|
||||||
ACK, /* https://ircv3.net/specs/extensions/labeled-response */
|
|
||||||
ADMIN,
|
ADMIN,
|
||||||
AUTHENTICATE, /* https://ircv3.net/specs/extensions/sasl-3.1 */
|
|
||||||
AWAY,
|
AWAY,
|
||||||
BATCH, /* https://ircv3.net/specs/extensions/batch-3.2 */
|
|
||||||
CAP, /* https://ircv3.net/specs/core/capability-negotiation */
|
|
||||||
CHGHOST, /* https://ircv3.net/specs/extensions/chghost-3.2 */
|
|
||||||
CONNECT,
|
CONNECT,
|
||||||
DIE,
|
DIE,
|
||||||
ERROR,
|
ERROR,
|
||||||
FAIL, /* https://ircv3.net/specs/extensions/standard-replies */
|
|
||||||
INFO,
|
INFO,
|
||||||
INVITE,
|
INVITE,
|
||||||
ISON,
|
ISON,
|
||||||
|
@ -35,11 +28,9 @@ enum {
|
||||||
LIST,
|
LIST,
|
||||||
LUSERS,
|
LUSERS,
|
||||||
MODE,
|
MODE,
|
||||||
MONITOR, /* https://ircv3.net/specs/core/monitor-3.2 */
|
|
||||||
MOTD,
|
MOTD,
|
||||||
NAMES,
|
NAMES,
|
||||||
NICK,
|
NICK,
|
||||||
NOTE, /* https://ircv3.net/specs/extensions/standard-replies */
|
|
||||||
NOTICE,
|
NOTICE,
|
||||||
OPER,
|
OPER,
|
||||||
PART,
|
PART,
|
||||||
|
@ -49,13 +40,10 @@ enum {
|
||||||
PRIVMSG,
|
PRIVMSG,
|
||||||
QUIT,
|
QUIT,
|
||||||
REHASH,
|
REHASH,
|
||||||
RENAME, /* https://github.com/ircv3/ircv3-specifications/pull/420 */
|
|
||||||
RESTART,
|
RESTART,
|
||||||
RESUME, /* https://github.com/ircv3/ircv3-specifications/pull/306 */
|
|
||||||
SERVER,
|
SERVER,
|
||||||
SERVICE,
|
SERVICE,
|
||||||
SERVLIST,
|
SERVLIST,
|
||||||
SETNAME, /* https://ircv3.net/specs/extensions/setname */
|
|
||||||
SQUERY,
|
SQUERY,
|
||||||
SQUIT,
|
SQUIT,
|
||||||
STATS,
|
STATS,
|
||||||
|
@ -68,11 +56,28 @@ enum {
|
||||||
USERS,
|
USERS,
|
||||||
VERSION,
|
VERSION,
|
||||||
WALLOPS,
|
WALLOPS,
|
||||||
WARN, /* https://ircv3.net/specs/extensions/standard-replies */
|
|
||||||
WEBIRC, /* https://ircv3.net/specs/extensions/webirc */
|
|
||||||
WHO,
|
WHO,
|
||||||
WHOIS,
|
WHOIS,
|
||||||
WHOWAS
|
WHOWAS,
|
||||||
|
#define UIRC_LCMD WHOWAS
|
||||||
|
#ifdef UIRC_IRCV3
|
||||||
|
ACC, /* https://github.com/ircv3/ircv3-specifications/pull/276 */
|
||||||
|
ACCOUNT, /* https://ircv3.net/specs/extensions/account-notify-3.1 */
|
||||||
|
ACK, /* https://ircv3.net/specs/extensions/labeled-response */
|
||||||
|
AUTHENTICATE, /* https://ircv3.net/specs/extensions/sasl-3.1 */
|
||||||
|
BATCH, /* https://ircv3.net/specs/extensions/batch-3.2 */
|
||||||
|
CAP, /* https://ircv3.net/specs/core/capability-negotiation */
|
||||||
|
CHGHOST, /* https://ircv3.net/specs/extensions/chghost-3.2 */
|
||||||
|
FAIL, /* https://ircv3.net/specs/extensions/standard-replies */
|
||||||
|
MONITOR, /* https://ircv3.net/specs/core/monitor-3.2 */
|
||||||
|
NOTE, /* https://ircv3.net/specs/extensions/standard-replies */
|
||||||
|
RENAME, /* https://github.com/ircv3/ircv3-specifications/pull/420 */
|
||||||
|
RESUME, /* https://github.com/ircv3/ircv3-specifications/pull/306 */
|
||||||
|
SETNAME, /* https://ircv3.net/specs/extensions/setname */
|
||||||
|
WARN, /* https://ircv3.net/specs/extensions/standard-replies */
|
||||||
|
WEBIRC, /* https://ircv3.net/specs/extensions/webirc */
|
||||||
|
#define UIRC_LCMD WEBIRC
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
enum {
|
enum {
|
||||||
RPL_WELCOME = 1,
|
RPL_WELCOME = 1,
|
||||||
|
@ -81,6 +86,7 @@ enum {
|
||||||
RPL_MYINFO = 4,
|
RPL_MYINFO = 4,
|
||||||
RPL_BOUNCE = 5,
|
RPL_BOUNCE = 5,
|
||||||
|
|
||||||
|
#ifdef UIRC_IRCV3
|
||||||
/* TO IRCv3 WG:
|
/* TO IRCv3 WG:
|
||||||
* please, stop complicating implementations
|
* please, stop complicating implementations
|
||||||
* get people in the WG that actually care about the protocol and understand why and how standards are written
|
* get people in the WG that actually care about the protocol and understand why and how standards are written
|
||||||
|
@ -89,6 +95,7 @@ enum {
|
||||||
* Read the above and go speak with them, or just don't use IRCv3 :)
|
* Read the above and go speak with them, or just don't use IRCv3 :)
|
||||||
*/
|
*/
|
||||||
RPL_ISUPPORT = 5,
|
RPL_ISUPPORT = 5,
|
||||||
|
#endif
|
||||||
|
|
||||||
RPL_TRACELINK = 200,
|
RPL_TRACELINK = 200,
|
||||||
RPL_TRACECONNECTING = 201,
|
RPL_TRACECONNECTING = 201,
|
||||||
|
@ -209,6 +216,7 @@ enum {
|
||||||
ERR_UMODEUNKNOWNFLAG = 501,
|
ERR_UMODEUNKNOWNFLAG = 501,
|
||||||
ERR_USERSDONTMATCH = 502,
|
ERR_USERSDONTMATCH = 502,
|
||||||
|
|
||||||
|
#ifdef UIRC_IRCV3
|
||||||
/* https://ircv3.net/registry */
|
/* https://ircv3.net/registry */
|
||||||
RPL_STARTTLS = 670,
|
RPL_STARTTLS = 670,
|
||||||
ERR_STARTTLS = 691,
|
ERR_STARTTLS = 691,
|
||||||
|
@ -228,5 +236,6 @@ enum {
|
||||||
ERR_SASLABORTED = 906,
|
ERR_SASLABORTED = 906,
|
||||||
ERR_SASLALREADY = 907,
|
ERR_SASLALREADY = 907,
|
||||||
ERR_SASLMECHS = 908
|
ERR_SASLMECHS = 908
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
33
src/uirc.c
33
src/uirc.c
|
@ -18,15 +18,8 @@
|
||||||
#include "uirc.h"
|
#include "uirc.h"
|
||||||
|
|
||||||
const char* const uirc_ircmd[] = {
|
const char* const uirc_ircmd[] = {
|
||||||
[ACCOUNT] = "ACCOUNT",
|
|
||||||
[ACC] = "ACC",
|
|
||||||
[ACK] = "ACK",
|
|
||||||
[ADMIN] = "ADMIN",
|
[ADMIN] = "ADMIN",
|
||||||
[AUTHENTICATE] = "AUTHENTICATE",
|
|
||||||
[AWAY] = "AWAY",
|
[AWAY] = "AWAY",
|
||||||
[BATCH] = "BATCH",
|
|
||||||
[CAP] = "CAP",
|
|
||||||
[CHGHOST] = "CHGHOST",
|
|
||||||
[CONNECT] = "CONNECT",
|
[CONNECT] = "CONNECT",
|
||||||
[DIE] = "DIE",
|
[DIE] = "DIE",
|
||||||
[ERROR] = "ERROR",
|
[ERROR] = "ERROR",
|
||||||
|
@ -52,9 +45,7 @@ const char* const uirc_ircmd[] = {
|
||||||
[PRIVMSG] = "PRIVMSG",
|
[PRIVMSG] = "PRIVMSG",
|
||||||
[QUIT] = "QUIT",
|
[QUIT] = "QUIT",
|
||||||
[REHASH] = "REHASH",
|
[REHASH] = "REHASH",
|
||||||
[RENAME] = "RENAME",
|
|
||||||
[RESTART] = "RESTART",
|
[RESTART] = "RESTART",
|
||||||
[RESUME] = "RESUME",
|
|
||||||
[SERVER] = "SERVER",
|
[SERVER] = "SERVER",
|
||||||
[SERVICE] = "SERVICE",
|
[SERVICE] = "SERVICE",
|
||||||
[SERVLIST] = "SERVLIST",
|
[SERVLIST] = "SERVLIST",
|
||||||
|
@ -70,10 +61,22 @@ const char* const uirc_ircmd[] = {
|
||||||
[USER] = "USER",
|
[USER] = "USER",
|
||||||
[VERSION] = "VERSION",
|
[VERSION] = "VERSION",
|
||||||
[WALLOPS] = "WALLOPS",
|
[WALLOPS] = "WALLOPS",
|
||||||
[WEBIRC] = "WEBIRC",
|
|
||||||
[WHOIS] = "WHOIS",
|
[WHOIS] = "WHOIS",
|
||||||
[WHOWAS] = "WHOWAS",
|
[WHOWAS] = "WHOWAS",
|
||||||
[WHO] = "WHO"};
|
[WHO] = "WHO",
|
||||||
|
#ifdef UIRC_IRCV3
|
||||||
|
[ACCOUNT] = "ACCOUNT",
|
||||||
|
[ACC] = "ACC",
|
||||||
|
[ACK] = "ACK",
|
||||||
|
[AUTHENTICATE] = "AUTHENTICATE",
|
||||||
|
[BATCH] = "BATCH",
|
||||||
|
[CAP] = "CAP",
|
||||||
|
[CHGHOST] = "CHGHOST",
|
||||||
|
[RENAME] = "RENAME",
|
||||||
|
[RESUME] = "RESUME",
|
||||||
|
[WEBIRC] = "WEBIRC"
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
struct tagmapping {
|
struct tagmapping {
|
||||||
const char* name;
|
const char* name;
|
||||||
|
@ -83,8 +86,8 @@ signed int Ircmd_stoi(char* str)
|
||||||
{
|
{
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
return ERR_UIRC_NULL_ARGS;
|
return ERR_UIRC_NULL_ARGS;
|
||||||
for (unsigned short i = ACCOUNT; i <= WHO; i++) {
|
for (unsigned short i = UIRC_FCMD; i <= UIRC_LCMD; i++) {
|
||||||
if ((uirc_ircmd[i] != NULL) && (strcmp(uirc_ircmd[i], str) == 0))
|
if (uirc_ircmd[i] != NULL && strcmp(uirc_ircmd[i], str) == 0)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return ERR_UIRC_UNKNOWN_TOKEN;
|
return ERR_UIRC_UNKNOWN_TOKEN;
|
||||||
|
@ -125,10 +128,8 @@ signed int Tok_mesg(char* str, IRC_Message* out)
|
||||||
return ERR_UIRC_INVALID_FORMAT;
|
return ERR_UIRC_INVALID_FORMAT;
|
||||||
}
|
}
|
||||||
out->args[i] = NULL;
|
out->args[i] = NULL;
|
||||||
if (*progr == ':')
|
|
||||||
++progr;
|
|
||||||
if (*progr != '\0')
|
if (*progr != '\0')
|
||||||
out->trailing = progr;
|
out->trailing = (*progr == ':') ? progr + 1 : progr;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
signed int Assm_mesg(char* buf, IRC_Message* in)
|
signed int Assm_mesg(char* buf, IRC_Message* in)
|
||||||
|
|
Reference in New Issue