Remove constant qualifiers to allow more free usage, add few missing commands and tokenizers

This commit is contained in:
Alex 2020-07-12 16:32:54 +02:00
parent fcd18d93c7
commit ba7b46160d
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
5 changed files with 119 additions and 96 deletions

View File

@ -3,50 +3,53 @@
#ifdef UIRC_HELPERS
#ifndef _UIRC_HELPERS_INCLUDED
#define _UIRC_HELPERS_INCLUDED
extern IRC_Message* Assm_cmd_NICK(const char* nick);
extern IRC_Message* Assm_cmd_USER(const char* user, const char* realname, const int modes);
extern IRC_Message* Assm_cmd_PASS(const char* password);
extern IRC_Message* Assm_cmd_OPER(const char* name, const char* password);
extern IRC_Message* Assm_cmd_MODE(const char* nick, const char* modes, const char* modeparams);
extern IRC_Message* Assm_cmd_SERVICE(const char* nickname, const char* distribution, const char* type, const char* info);
extern IRC_Message* Assm_cmd_QUIT(const char* mesg, const IRC_User* user);
extern IRC_Message* Assm_cmd_SQUIT(const char* server, const char* comment, const IRC_User* user);
extern IRC_Message* Assm_cmd_JOIN(const char* channels, const char* keys, const IRC_User* user);
extern IRC_Message* Assm_cmd_PART(const char* channel, const char* message, const IRC_User* user);
extern IRC_Message* Assm_cmd_TOPIC(const char* channel, const char* topic, const IRC_User* user);
extern IRC_Message* Assm_cmd_NAMES(const char* channels, const char* target);
extern IRC_Message* Assm_cmd_LIST(const char* channels, const char* target);
extern IRC_Message* Assm_cmd_INVITE(const char* nick, const char* channel, const IRC_User* user);
extern IRC_Message* Assm_cmd_KICK(const char* channels, const char* users, const char* comment, const IRC_User* user);
extern IRC_Message* Assm_cmd_PRIVMSG(const char* target, const char* message, const IRC_User* source);
extern IRC_Message* Assm_cmd_NOTICE(const char* target, const char* text, const IRC_User* user);
extern IRC_Message* Assm_cmd_MOTD(const char* target);
extern IRC_Message* Assm_cmd_LUSERS(const char* mask, const char* target);
extern IRC_Message* Assm_cmd_VERSION(const char* target);
extern IRC_Message* Assm_cmd_STATS(const char* query, const char* target);
extern IRC_Message* Assm_cmd_LINKS(const char* remoteserv, const char* servmask);
extern IRC_Message* Assm_cmd_TIME(const char* target);
extern IRC_Message* Assm_cmd_CONNECT(const char* target, const char* port, const char* remote);
extern IRC_Message* Assm_cmd_TRACE(const char* target);
extern IRC_Message* Assm_cmd_ADMIN(const char* target);
extern IRC_Message* Assm_cmd_INFO(const char* target);
extern IRC_Message* Assm_cmd_SERVLIST(const char* mask, const char* type);
extern IRC_Message* Assm_cmd_SQUERY(const char* servicename, const char* text);
extern IRC_Message* Assm_cmd_WHO(const char* mask, const bool oper);
extern IRC_Message* Assm_cmd_WHOIS(const char* target, const char* mask);
extern IRC_Message* Assm_cmd_WHOWAS(const char* nick, const char* count, const char* target);
extern IRC_Message* Assm_cmd_KILL(const char* nick, const char* comment);
extern IRC_Message* Assm_cmd_PING(const char* source, const char* target);
extern IRC_Message* Assm_cmd_PONG(const char* source, const char* target);
extern IRC_Message* Assm_cmd_ERROR(const char* message);
extern IRC_Message* Assm_cmd_AWAY(const char* mesg);
extern IRC_Message* Assm_cmd_NICK(char* nick);
extern IRC_Message* Assm_cmd_USER(char* user, char* realname, int modes);
extern IRC_Message* Assm_cmd_PASS(char* password);
extern IRC_Message* Assm_cmd_OPER(char* name, char* password);
extern IRC_Message* Assm_cmd_MODE(char* nick, char* modes, char* modeparams);
extern IRC_Message* Assm_cmd_SERVICE(char* nickname, char* distribution, char* type, char* info);
extern IRC_Message* Assm_cmd_QUIT(char* mesg, IRC_User* user);
extern IRC_Message* Assm_cmd_SQUIT(char* server, char* comment, IRC_User* user);
extern IRC_Message* Assm_cmd_JOIN(char* channels, char* keys, IRC_User* user);
extern IRC_Message* Assm_cmd_PART(char* channel, char* message, IRC_User* user);
extern IRC_Message* Assm_cmd_TOPIC(char* channel, char* topic, IRC_User* user);
extern IRC_Message* Assm_cmd_NAMES(char* channels, char* target);
extern IRC_Message* Assm_cmd_LIST(char* channels, char* target);
extern IRC_Message* Assm_cmd_INVITE(char* nick, char* channel, IRC_User* user);
extern IRC_Message* Assm_cmd_KICK(char* channels, char* users, char* comment, IRC_User* user);
extern IRC_Message* Assm_cmd_PRIVMSG(char* target, char* message, IRC_User* source);
extern IRC_Message* Assm_cmd_NOTICE(char* target, char* text, IRC_User* user);
extern IRC_Message* Assm_cmd_MOTD(char* target);
extern IRC_Message* Assm_cmd_LUSERS(char* mask, char* target);
extern IRC_Message* Assm_cmd_VERSION(char* target);
extern IRC_Message* Assm_cmd_STATS(char* query, char* target);
extern IRC_Message* Assm_cmd_LINKS(char* remoteserv, char* servmask);
extern IRC_Message* Assm_cmd_TIME(char* target);
extern IRC_Message* Assm_cmd_CONNECT(char* target, char* port, char* remote);
extern IRC_Message* Assm_cmd_TRACE(char* target);
extern IRC_Message* Assm_cmd_ADMIN(char* target);
extern IRC_Message* Assm_cmd_INFO(char* target);
extern IRC_Message* Assm_cmd_SERVLIST(char* mask, char* type);
extern IRC_Message* Assm_cmd_SQUERY(char* servicename, char* text);
extern IRC_Message* Assm_cmd_WHO(char* mask, bool oper);
extern IRC_Message* Assm_cmd_WHOIS(char* target, char* mask);
extern IRC_Message* Assm_cmd_WHOWAS(char* nick, char* count, char* target);
extern IRC_Message* Assm_cmd_KILL(char* nick, char* comment);
extern IRC_Message* Assm_cmd_PING(char* source, char* target);
extern IRC_Message* Assm_cmd_PONG(char* source, char* target);
extern IRC_Message* Assm_cmd_ERROR(char* message);
extern IRC_Message* Assm_cmd_AWAY(char* mesg);
extern IRC_Message* Assm_cmd_REHASH(void);
extern IRC_Message* Assm_cmd_DIE(void);
extern IRC_Message* Assm_cmd_RESTART(void);
extern IRC_Message* Assm_cmd_SUMMON(const char* user, const char* target, const char* channel);
extern IRC_Message* Assm_cmd_USERS(const char* target);
extern IRC_Message* Assm_cmd_WALLOPS(const char* text, const IRC_User* source);
extern IRC_Message* Assm_cmd_USERHOST(const char* users[], const IRC_User* source);
extern IRC_Message* Assm_cmd_ISON(const char* users[]);
extern IRC_Message* Assm_cmd_SUMMON(char* user, char* target, char* channel);
extern IRC_Message* Assm_cmd_USERS(char* target);
extern IRC_Message* Assm_cmd_WALLOPS(char* text, IRC_User* source);
extern IRC_Message* Assm_cmd_USERHOST(char* users[], IRC_User* source);
extern IRC_Message* Assm_cmd_ISON(char* users[]);
extern void Tok_cmd_PING(IRC_Message* mesg, char* source, char* target);
extern void Tok_FArgOpt(IRC_Message* mesg, char** optarg, char** reqarg);
#endif
#endif

View File

@ -4,16 +4,16 @@
#ifdef UIRC_IRCV3
typedef struct uirc_tag {
const char* value; /* if present, it isn't NULL and if it has no value, it is "" (aka '\0') */
char* value; /* if present, it isn't NULL and if it has no value, it is "" (aka '\0') */
bool clientbound;
} IRC_Tag;
#endif
typedef struct name {
const char* nick;
const char* user;
const char* host;
const char* orig;
const char* real;
char* nick;
char* user;
char* host;
char* orig;
char* real;
} IRC_User;
/* This is how a full user source would look like
* NOTE: 'real (Real name)' may only be used in special contexts other than communication.
@ -38,7 +38,7 @@ typedef struct uirc_message {
#endif
IRC_User name;
signed short cmd;
const char* args[15]; /* 0-13 + NULL */
const char* trailing;
char* args[15]; /* 0-13 + NULL */
char* trailing;
} IRC_Message;
#endif

View File

@ -4,12 +4,12 @@
#include <stdlib.h>
#include <string.h>
static IRC_Message imassm_mesg;
const char* const RESERVED = "*";
char* RESERVED = "*";
void clear_assm(void)
{
memset((void*)&imassm_mesg, '\0', sizeof(IRC_Message));
}
IRC_Message* Assm_cmd_NICK(const char* nick)
IRC_Message* Assm_cmd_NICK(char* nick)
{
if (nick == NULL)
return NULL;
@ -18,7 +18,7 @@ IRC_Message* Assm_cmd_NICK(const char* nick)
imassm_mesg.cmd = NICK;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_USER(const char* user, const char* realname, const int modes)
IRC_Message* Assm_cmd_USER(char* user, char* realname, int modes)
{
if (user == NULL || modes < 0 || modes > (MBMASK_INVIS | MBMASK_WALLOPS))
return NULL;
@ -32,7 +32,7 @@ IRC_Message* Assm_cmd_USER(const char* user, const char* realname, const int mod
imassm_mesg.cmd = USER;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_PASS(const char* password)
IRC_Message* Assm_cmd_PASS(char* password)
{
if (password == NULL)
return NULL;
@ -41,7 +41,7 @@ IRC_Message* Assm_cmd_PASS(const char* password)
imassm_mesg.cmd = PASS;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_OPER(const char* name, const char* password)
IRC_Message* Assm_cmd_OPER(char* name, char* password)
{
if (name == NULL || password == NULL)
return NULL;
@ -51,7 +51,7 @@ IRC_Message* Assm_cmd_OPER(const char* name, const char* password)
imassm_mesg.cmd = OPER;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_MODE(const char* nick, const char* modes, const char* modeparams)
IRC_Message* Assm_cmd_MODE(char* nick, char* modes, char* modeparams)
{
if (nick == NULL)
return NULL;
@ -62,7 +62,7 @@ IRC_Message* Assm_cmd_MODE(const char* nick, const char* modes, const char* mode
imassm_mesg.cmd = MODE;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_SERVICE(const char* nickname, const char* distribution, const char* type, const char* info)
IRC_Message* Assm_cmd_SERVICE(char* nickname, char* distribution, char* type, char* info)
{
if (nickname == NULL || distribution == NULL || type == NULL || info == NULL)
return NULL;
@ -76,7 +76,7 @@ IRC_Message* Assm_cmd_SERVICE(const char* nickname, const char* distribution, co
imassm_mesg.cmd = SERVICE;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_QUIT(const char* mesg, const IRC_User* user)
IRC_Message* Assm_cmd_QUIT(char* mesg, IRC_User* user)
{
clear_assm();
imassm_mesg.trailing = mesg;
@ -85,7 +85,7 @@ IRC_Message* Assm_cmd_QUIT(const char* mesg, const IRC_User* user)
imassm_mesg.cmd = QUIT;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_SQUIT(const char* server, const char* comment, const IRC_User* user)
IRC_Message* Assm_cmd_SQUIT(char* server, char* comment, IRC_User* user)
{
if (server == NULL || comment == NULL)
return NULL;
@ -97,7 +97,7 @@ IRC_Message* Assm_cmd_SQUIT(const char* server, const char* comment, const IRC_U
imassm_mesg.cmd = SQUIT;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_JOIN(const char* channels, const char* keys, const IRC_User* user)
IRC_Message* Assm_cmd_JOIN(char* channels, char* keys, IRC_User* user)
{
if (channels == NULL)
return NULL;
@ -109,7 +109,7 @@ IRC_Message* Assm_cmd_JOIN(const char* channels, const char* keys, const IRC_Use
imassm_mesg.cmd = JOIN;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_PART(const char* channel, const char* message, const IRC_User* user)
IRC_Message* Assm_cmd_PART(char* channel, char* message, IRC_User* user)
{
if (channel == NULL)
return NULL;
@ -124,7 +124,7 @@ IRC_Message* Assm_cmd_PART(const char* channel, const char* message, const IRC_U
/* NOTE: Use a non-NULL address (pointing at a "\0") as the topic to clear it and use a NULL address to check it
* Blame the protocol, not this >:C
*/
IRC_Message* Assm_cmd_TOPIC(const char* channel, const char* topic, const IRC_User* user)
IRC_Message* Assm_cmd_TOPIC(char* channel, char* topic, IRC_User* user)
{
if (channel == NULL)
return NULL;
@ -136,7 +136,7 @@ IRC_Message* Assm_cmd_TOPIC(const char* channel, const char* topic, const IRC_Us
imassm_mesg.cmd = TOPIC;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_NAMES(const char* channels, const char* target)
IRC_Message* Assm_cmd_NAMES(char* channels, char* target)
{
if (channels == NULL && target != NULL)
return NULL;
@ -146,7 +146,7 @@ IRC_Message* Assm_cmd_NAMES(const char* channels, const char* target)
imassm_mesg.cmd = NAMES;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_LIST(const char* channels, const char* target)
IRC_Message* Assm_cmd_LIST(char* channels, char* target)
{
if (channels == NULL && target != NULL)
return NULL;
@ -156,7 +156,7 @@ IRC_Message* Assm_cmd_LIST(const char* channels, const char* target)
imassm_mesg.cmd = LIST;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_INVITE(const char* nick, const char* channel, const IRC_User* user)
IRC_Message* Assm_cmd_INVITE(char* nick, char* channel, IRC_User* user)
{
if (nick == NULL || channel == NULL)
return NULL;
@ -168,7 +168,7 @@ IRC_Message* Assm_cmd_INVITE(const char* nick, const char* channel, const IRC_Us
imassm_mesg.cmd = INVITE;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_KICK(const char* channels, const char* users, const char* comment, const IRC_User* user)
IRC_Message* Assm_cmd_KICK(char* channels, char* users, char* comment, IRC_User* user)
{
if (channels == NULL || users == NULL)
return NULL;
@ -181,7 +181,7 @@ IRC_Message* Assm_cmd_KICK(const char* channels, const char* users, const char*
imassm_mesg.cmd = KICK;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_PRIVMSG(const char* target, const char* message, const IRC_User* source)
IRC_Message* Assm_cmd_PRIVMSG(char* target, char* message, IRC_User* source)
{
if (target == NULL || message == NULL)
return NULL;
@ -193,7 +193,7 @@ IRC_Message* Assm_cmd_PRIVMSG(const char* target, const char* message, const IRC
imassm_mesg.cmd = PRIVMSG;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_NOTICE(const char* target, const char* text, const IRC_User* user)
IRC_Message* Assm_cmd_NOTICE(char* target, char* text, IRC_User* user)
{
if (target == NULL || text == NULL)
return NULL;
@ -205,14 +205,14 @@ IRC_Message* Assm_cmd_NOTICE(const char* target, const char* text, const IRC_Use
imassm_mesg.cmd = NOTICE;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_MOTD(const char* target)
IRC_Message* Assm_cmd_MOTD(char* target)
{
clear_assm();
imassm_mesg.args[0] = target;
imassm_mesg.cmd = MOTD;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_LUSERS(const char* mask, const char* target)
IRC_Message* Assm_cmd_LUSERS(char* mask, char* target)
{
if (mask == NULL && target != NULL)
return NULL;
@ -222,14 +222,14 @@ IRC_Message* Assm_cmd_LUSERS(const char* mask, const char* target)
imassm_mesg.cmd = LUSERS;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_VERSION(const char* target)
IRC_Message* Assm_cmd_VERSION(char* target)
{
clear_assm();
imassm_mesg.args[0] = target;
imassm_mesg.cmd = VERSION;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_STATS(const char* query, const char* target)
IRC_Message* Assm_cmd_STATS(char* query, char* target)
{
if (query == NULL && target != NULL)
return NULL;
@ -239,7 +239,7 @@ IRC_Message* Assm_cmd_STATS(const char* query, const char* target)
imassm_mesg.cmd = STATS;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_LINKS(const char* remoteserv, const char* servmask)
IRC_Message* Assm_cmd_LINKS(char* remoteserv, char* servmask)
{
if (remoteserv != NULL && servmask == NULL)
return NULL;
@ -249,14 +249,14 @@ IRC_Message* Assm_cmd_LINKS(const char* remoteserv, const char* servmask)
imassm_mesg.cmd = LINKS;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_TIME(const char* target)
IRC_Message* Assm_cmd_TIME(char* target)
{
clear_assm();
imassm_mesg.args[0] = target;
imassm_mesg.cmd = TIME;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_CONNECT(const char* target, const char* port, const char* remote)
IRC_Message* Assm_cmd_CONNECT(char* target, char* port, char* remote)
{
if (target == NULL || port == NULL)
return NULL;
@ -267,28 +267,28 @@ IRC_Message* Assm_cmd_CONNECT(const char* target, const char* port, const char*
imassm_mesg.cmd = CONNECT;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_TRACE(const char* target)
IRC_Message* Assm_cmd_TRACE(char* target)
{
clear_assm();
imassm_mesg.args[0] = target;
imassm_mesg.cmd = TRACE;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_ADMIN(const char* target)
IRC_Message* Assm_cmd_ADMIN(char* target)
{
clear_assm();
imassm_mesg.args[0] = target;
imassm_mesg.cmd = ADMIN;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_INFO(const char* target)
IRC_Message* Assm_cmd_INFO(char* target)
{
clear_assm();
imassm_mesg.args[0] = target;
imassm_mesg.cmd = INFO;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_SERVLIST(const char* mask, const char* type)
IRC_Message* Assm_cmd_SERVLIST(char* mask, char* type)
{
if (type != NULL && mask == NULL)
return NULL;
@ -298,7 +298,7 @@ IRC_Message* Assm_cmd_SERVLIST(const char* mask, const char* type)
imassm_mesg.cmd = SERVLIST;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_SQUERY(const char* servicename, const char* text)
IRC_Message* Assm_cmd_SQUERY(char* servicename, char* text)
{
if (servicename == NULL || text == NULL)
return NULL;
@ -308,9 +308,9 @@ IRC_Message* Assm_cmd_SQUERY(const char* servicename, const char* text)
imassm_mesg.cmd = SQUERY;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_WHO(const char* mask, const bool oper)
IRC_Message* Assm_cmd_WHO(char* mask, bool oper)
{
static const char* const operator= "o";
static char* operator= "o";
if (oper && mask == NULL)
return NULL;
clear_assm();
@ -319,7 +319,7 @@ IRC_Message* Assm_cmd_WHO(const char* mask, const bool oper)
imassm_mesg.cmd = WHO;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_WHOIS(const char* target, const char* mask)
IRC_Message* Assm_cmd_WHOIS(char* target, char* mask)
{
if (mask == NULL)
return NULL;
@ -329,7 +329,7 @@ IRC_Message* Assm_cmd_WHOIS(const char* target, const char* mask)
imassm_mesg.cmd = WHOIS;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_WHOWAS(const char* nick, const char* count, const char* target)
IRC_Message* Assm_cmd_WHOWAS(char* nick, char* count, char* target)
{
if (nick == NULL || (target != NULL && count == NULL))
return NULL;
@ -340,7 +340,7 @@ IRC_Message* Assm_cmd_WHOWAS(const char* nick, const char* count, const char* ta
imassm_mesg.cmd = WHOWAS;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_KILL(const char* nick, const char* comment)
IRC_Message* Assm_cmd_KILL(char* nick, char* comment)
{
if (nick == NULL || comment == NULL)
return NULL;
@ -353,7 +353,7 @@ IRC_Message* Assm_cmd_KILL(const char* nick, const char* comment)
/* NOTE: This is what implementation you have to live with
* I would've just used the prefix to set the source but whatever
*/
IRC_Message* Assm_cmd_PING(const char* source, const char* target)
IRC_Message* Assm_cmd_PING(char* source, char* target)
{
if (source == NULL && target == NULL)
return NULL;
@ -364,7 +364,7 @@ IRC_Message* Assm_cmd_PING(const char* source, const char* target)
imassm_mesg.cmd = PING;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_PONG(const char* source, const char* target)
IRC_Message* Assm_cmd_PONG(char* source, char* target)
{
if (source == NULL)
return NULL;
@ -374,7 +374,7 @@ IRC_Message* Assm_cmd_PONG(const char* source, const char* target)
imassm_mesg.cmd = PONG;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_ERROR(const char* message)
IRC_Message* Assm_cmd_ERROR(char* message)
{
if (message == NULL)
return NULL;
@ -383,7 +383,7 @@ IRC_Message* Assm_cmd_ERROR(const char* message)
imassm_mesg.cmd = ERROR;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_AWAY(const char* mesg)
IRC_Message* Assm_cmd_AWAY(char* mesg)
{
clear_assm();
imassm_mesg.trailing = mesg;
@ -408,7 +408,7 @@ IRC_Message* Assm_cmd_RESTART(void)
imassm_mesg.cmd = RESTART;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_SUMMON(const char* user, const char* target, const char* channel)
IRC_Message* Assm_cmd_SUMMON(char* user, char* target, char* channel)
{
if (user == NULL || (channel != NULL && target == NULL))
return NULL;
@ -419,7 +419,7 @@ IRC_Message* Assm_cmd_SUMMON(const char* user, const char* target, const char* c
imassm_mesg.cmd = SUMMON;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_USERS(const char* target)
IRC_Message* Assm_cmd_USERS(char* target)
{
if (target == NULL)
return NULL;
@ -428,7 +428,7 @@ IRC_Message* Assm_cmd_USERS(const char* target)
imassm_mesg.cmd = USERS;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_WALLOPS(const char* text, const IRC_User* source)
IRC_Message* Assm_cmd_WALLOPS(char* text, IRC_User* source)
{
if (text == NULL)
return NULL;
@ -439,7 +439,7 @@ IRC_Message* Assm_cmd_WALLOPS(const char* text, const IRC_User* source)
imassm_mesg.cmd = WALLOPS;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_USERHOST(const char* users[], const IRC_User* source)
IRC_Message* Assm_cmd_USERHOST(char* users[], IRC_User* source)
{
if (users[0] == NULL)
return NULL;
@ -453,7 +453,7 @@ IRC_Message* Assm_cmd_USERHOST(const char* users[], const IRC_User* source)
return &imassm_mesg;
}
/* NOTE: Limited to 14 nicks per command */
IRC_Message* Assm_cmd_ISON(const char* users[])
IRC_Message* Assm_cmd_ISON(char* users[])
{
if (users[0] == NULL)
return NULL;
@ -464,3 +464,17 @@ IRC_Message* Assm_cmd_ISON(const char* users[])
imassm_mesg.cmd = ISON;
return &imassm_mesg;
}
void Tok_cmd_PING(IRC_Message* mesg, char** source, char** target)
{
*source = (mesg->args[0] == NULL) ? mesg->trailing : (mesg->args[1] != NULL) ? mesg->args[0] : NULL;
*target = (mesg->args[1] == NULL) ? mesg->args[0] : mesg->args[1];
}
/* Use with WHOIS/LINKS
* (stands for first argument optional)
* [ <optarg> ] <reqarg>
*/
void Tok_FArgOpt(IRC_Message* mesg, char** optarg, char** reqarg)
{
*optarg = (mesg->args[1] != NULL) ? mesg->args[0] : NULL;
*reqarg = (mesg->args[1] != NULL) ? mesg->args[1] : mesg->args[0];
}

View File

@ -72,15 +72,20 @@ const char* const uirc_ircmd[] = {
[BATCH] = "BATCH",
[CAP] = "CAP",
[CHGHOST] = "CHGHOST",
[FAIL] = "FAIL",
[MONITOR] = "MONITOR",
[NOTE] = "NOTE",
[RENAME] = "RENAME",
[RESUME] = "RESUME",
[SETNAME] = "SETNAME",
[WARN] = "WARN",
[WEBIRC] = "WEBIRC"
#endif
};
#ifdef UIRC_IRCV3
struct tagmapping {
const char* name;
const char* const name;
IRC_Tag* assg;
};
#endif

View File

@ -1,3 +1,4 @@
#define UIRC_HELPERS
#include "../include/uirc.h"
#include "stdio.h"
#include "stdlib.h"
@ -5,7 +6,7 @@
int main(void)
{
char mesg[513] = "@+msgid=1s32;time;+reply;account=x :nick!user@host QUIT :Finished!";
char mesg[513] = "@+msgid=1s32;time;+reply;account=x :nick!user@host QUIT arg1 :Finished!";
IRC_Message parseout;
int res = 0;
if ((res = Tok_mesg(mesg, &parseout)) <= 0) {