Add trailing to the array and change the boolean to show if the last arg is a trailing one

This commit is contained in:
Alex 2020-08-01 01:38:06 +02:00
parent 0f73ea68d8
commit 0b07acd797
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
8 changed files with 88 additions and 389 deletions

View File

@ -58,7 +58,7 @@ typedef struct {
#endif
IRC_User name;
signed short cmd;
char* args[15]; /* 0-13 + NULL */
char* trailing;
char* args[16]; /* 0-13 + trailing + NULL */
bool trailing; /* Tells if the last argument is trailing */
} IRC_Message;
#endif

View File

@ -46,18 +46,12 @@ signed int Assm_mesg(char* buf, IRC_Message* in, size_t len)
pos += cnt;
else
return ERR_UIRC_GENERIC;
for (unsigned int i = 0; i < 14 && in->args[i] != NULL; i++) {
if (len - (pos - buf) > strlen(in->args[i]) + 2 && (cnt = snprintf(pos, len - (pos - buf), " %s", in->args[i])) > 0)
for (unsigned int i = 0; i < 15 && in->args[i] != NULL; i++) {
if (len - (pos - buf) > strlen(in->args[i]) + 2 && (cnt = snprintf(pos, len - (pos - buf), (in->args[i + 1] == NULL && in->trailing) ? " :%s" : " %s", in->args[i])) > 0)
pos += cnt;
else
return ERR_UIRC_BUFFER_ERR;
}
if (in->trailing != NULL) {
if (len - (pos - buf) > strlen(in->trailing) + 3 && (cnt = snprintf(pos, len - (pos - buf), " :%s", in->trailing)) > 0)
pos += cnt;
else
return ERR_UIRC_GENERIC;
}
if (!safe_strcpy(&pos, "\r\n", len - (pos - buf)))
return ERR_UIRC_BUFFER_ERR;
return pos - buf;

View File

@ -24,15 +24,20 @@ void clear_assm(void)
{
memset((void*)&imassm_mesg, '\0', sizeof(IRC_Message));
}
IRC_Message* Assm_cmd_NICK(char* nick)
IRC_Message* Assm_AUTO(int cmd, bool trailing, char** args, int req)
{
if (nick == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = nick;
imassm_mesg.cmd = NICK;
int i;
for (i = 0; args[i] != NULL && i < 15; i++) {
imassm_mesg.args[i] = args[i];
}
if (i < req)
return NULL;
imassm_mesg.trailing = trailing;
imassm_mesg.cmd = cmd;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_USER(char* user, char* realname, int modes)
{
if (user == NULL || modes < 0 || modes > (MBMASK_INVIS | MBMASK_WALLOPS))
@ -47,195 +52,7 @@ IRC_Message* Assm_cmd_USER(char* user, char* realname, int modes)
imassm_mesg.cmd = USER;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_PASS(char* password)
{
if (password == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = password;
imassm_mesg.cmd = PASS;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_OPER(char* name, char* password)
{
if (name == NULL || password == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = name;
imassm_mesg.args[1] = password;
imassm_mesg.cmd = OPER;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_MODE(char* nick, char* modes, char* modeparams)
{
if (nick == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = nick;
imassm_mesg.args[1] = modes;
imassm_mesg.args[2] = modeparams;
imassm_mesg.cmd = MODE;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_SERVICE(char* nickname, char* distribution, char* type, char* info)
{
if (nickname == NULL || distribution == NULL || type == NULL || info == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = nickname;
imassm_mesg.args[1] = RESERVED;
imassm_mesg.args[2] = distribution;
imassm_mesg.args[3] = "0";
imassm_mesg.args[4] = RESERVED;
imassm_mesg.trailing = info;
imassm_mesg.cmd = SERVICE;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_QUIT(char* mesg)
{
clear_assm();
imassm_mesg.trailing = mesg;
imassm_mesg.cmd = QUIT;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_SQUIT(char* server, char* comment)
{
if (server == NULL || comment == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = server;
imassm_mesg.trailing = comment;
imassm_mesg.cmd = SQUIT;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_JOIN(char* channels, char* keys)
{
if (channels == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = channels;
imassm_mesg.args[1] = keys;
imassm_mesg.cmd = JOIN;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_PART(char* channel, char* message)
{
if (channel == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = channel;
imassm_mesg.trailing = message;
imassm_mesg.cmd = PART;
return &imassm_mesg;
}
/* 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(char* channel, char* topic)
{
if (channel == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = channel;
imassm_mesg.trailing = topic;
imassm_mesg.cmd = TOPIC;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_NAMES(char* channels, char* target)
{
if (channels == NULL && target != NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = channels;
imassm_mesg.args[1] = target;
imassm_mesg.cmd = NAMES;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_LIST(char* channels, char* target)
{
if (channels == NULL && target != NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = channels;
imassm_mesg.args[1] = target;
imassm_mesg.cmd = LIST;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_INVITE(char* nick, char* channel)
{
if (nick == NULL || channel == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = nick;
imassm_mesg.args[1] = channel;
imassm_mesg.cmd = INVITE;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_KICK(char* channels, char* users, char* comment)
{
if (channels == NULL || users == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = channels;
imassm_mesg.args[1] = users;
imassm_mesg.trailing = comment;
imassm_mesg.cmd = KICK;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_PRIVMSG(char* target, char* message)
{
if (target == NULL || message == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = target;
imassm_mesg.trailing = message;
imassm_mesg.cmd = PRIVMSG;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_NOTICE(char* target, char* text)
{
if (target == NULL || text == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = target;
imassm_mesg.args[1] = text;
imassm_mesg.cmd = NOTICE;
return &imassm_mesg;
}
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(char* mask, char* target)
{
if (mask == NULL && target != NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = mask;
imassm_mesg.args[1] = target;
imassm_mesg.cmd = LUSERS;
return &imassm_mesg;
}
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(char* query, char* target)
{
if (query == NULL && target != NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = query;
imassm_mesg.args[1] = target;
imassm_mesg.cmd = STATS;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_LINKS(char* remoteserv, char* servmask)
{
if (remoteserv != NULL && servmask == NULL)
@ -246,65 +63,7 @@ IRC_Message* Assm_cmd_LINKS(char* remoteserv, char* servmask)
imassm_mesg.cmd = LINKS;
return &imassm_mesg;
}
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(char* target, char* port, char* remote)
{
if (target == NULL || port == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = target;
imassm_mesg.args[1] = port;
imassm_mesg.args[2] = remote;
imassm_mesg.cmd = CONNECT;
return &imassm_mesg;
}
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(char* target)
{
clear_assm();
imassm_mesg.args[0] = target;
imassm_mesg.cmd = ADMIN;
return &imassm_mesg;
}
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(char* mask, char* type)
{
if (type != NULL && mask == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = mask;
imassm_mesg.args[1] = type;
imassm_mesg.cmd = SERVLIST;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_SQUERY(char* servicename, char* text)
{
if (servicename == NULL || text == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = servicename;
imassm_mesg.trailing = text;
imassm_mesg.cmd = SQUERY;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_WHO(char* mask, bool oper)
{
static char* operator= "o";
@ -316,6 +75,7 @@ IRC_Message* Assm_cmd_WHO(char* mask, bool oper)
imassm_mesg.cmd = WHO;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_WHOIS(char* target, char* mask)
{
if (mask == NULL)
@ -326,6 +86,7 @@ IRC_Message* Assm_cmd_WHOIS(char* target, char* mask)
imassm_mesg.cmd = WHOIS;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_WHOWAS(char* nick, char* count, char* target)
{
if (nick == NULL || (target != NULL && count == NULL))
@ -337,16 +98,7 @@ IRC_Message* Assm_cmd_WHOWAS(char* nick, char* count, char* target)
imassm_mesg.cmd = WHOWAS;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_KILL(char* nick, char* comment)
{
if (nick == NULL || comment == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = nick;
imassm_mesg.trailing = comment;
imassm_mesg.cmd = KILL;
return &imassm_mesg;
}
/* NOTE: This is what implementation you have to live with
* I would've just used the prefix to set the source but whatever
*/
@ -355,56 +107,13 @@ IRC_Message* Assm_cmd_PING(char* source, char* target)
if (source == NULL && target == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = (source != NULL && target != NULL) ? source : (target != NULL) ? target : NULL;
imassm_mesg.args[0] = (source != NULL) ? source : target;
imassm_mesg.args[1] = (source != NULL && target != NULL) ? target : NULL;
imassm_mesg.trailing = (source != NULL && target == NULL) ? source : NULL;
imassm_mesg.trailing = (source != NULL && target == NULL) ? true : false;
imassm_mesg.cmd = PING;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_PONG(char* source, char* target)
{
if (source == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = source;
imassm_mesg.args[1] = target;
imassm_mesg.cmd = PONG;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_ERROR(char* message)
{
if (message == NULL)
return NULL;
clear_assm();
imassm_mesg.trailing = message;
imassm_mesg.cmd = ERROR;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_AWAY(char* mesg)
{
clear_assm();
imassm_mesg.trailing = mesg;
imassm_mesg.cmd = AWAY;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_REHASH(void)
{
clear_assm();
imassm_mesg.cmd = REHASH;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_DIE(void)
{
clear_assm();
imassm_mesg.cmd = DIE;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_RESTART(void)
{
clear_assm();
imassm_mesg.cmd = RESTART;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_SUMMON(char* user, char* target, char* channel)
{
if (user == NULL || (channel != NULL && target == NULL))
@ -416,24 +125,6 @@ IRC_Message* Assm_cmd_SUMMON(char* user, char* target, char* channel)
imassm_mesg.cmd = SUMMON;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_USERS(char* target)
{
if (target == NULL)
return NULL;
clear_assm();
imassm_mesg.args[0] = target;
imassm_mesg.cmd = USERS;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_WALLOPS(char* text)
{
if (text == NULL)
return NULL;
clear_assm();
imassm_mesg.trailing = text;
imassm_mesg.cmd = WALLOPS;
return &imassm_mesg;
}
IRC_Message* Assm_cmd_USERHOST(char* users[])
{
if (users[0] == NULL)
@ -459,7 +150,7 @@ IRC_Message* Assm_cmd_ISON(char* users[])
}
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;
*source = (mesg->args[0] == NULL && mesg->trailing) ? mesg->args[2] : (mesg->args[1] != NULL) ? mesg->args[0] : NULL;
*target = (mesg->args[1] == NULL) ? mesg->args[0] : mesg->args[1];
}
/* Use with WHOIS/LINKS

View File

@ -16,8 +16,8 @@
* along with uIRC. If not, see <https://www.gnu.org/licenses/>.
*/
#include "../include/types.h"
#include "../include/mappings.h"
#include "../include/types.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@ -25,50 +25,65 @@
#ifndef _UIRC_INCLUDED_ASSM
#define _UIRC_INCLUDED_ASSM
char* RESERVED;
void clear_assm(void);
IRC_Message* Assm_cmd_NICK(char* nick);
IRC_Message* Assm_AUTO(int cmd, bool trailing, char** args, int req);
#define Assm_cmd_REHASH() Assm_AUTO(REHASH, false, (char*[]){NULL}, 0)
#define Assm_cmd_DIE() Assm_AUTO(DIE, false, (char*[]){NULL}, 0)
#define Assm_cmd_RESTART() Assm_AUTO(RESTART, false, (char*[]){NULL}, 0)
#define Assm_cmd_QUIT(message) Assm_AUTO(QUIT, true, (char*[]){message, NULL}, 0)
#define Assm_cmd_MOTD(target) Assm_AUTO(MOTD, false, (char*[]){target, NULL}, 0)
#define Assm_cmd_VERSION(target) Assm_AUTO(VERSION, false, (char*[]){target, NULL}, 0)
#define Assm_cmd_TIME(target) Assm_AUTO(TIME, false, (char*[]){target, NULL}, 0)
#define Assm_cmd_TRACE(target) Assm_AUTO(TRACE, false, (char*[]){target, NULL}, 0)
#define Assm_cmd_ADMIN(target) Assm_AUTO(ADMIN, false, (char*[]){target, NULL}, 0)
#define Assm_cmd_INFO(target) Assm_AUTO(INFO, false, (char*[]){target, NULL}, 0)
#define Assm_cmd_AWAY(message) Assm_AUTO(AWAY, false, (char*[]){message, NULL}, 0)
#define Assm_cmd_PASS(password) Assm_AUTO(PASS, true, (char*[]){password, NULL}, 1)
#define Assm_cmd_ERROR(message) Assm_AUTO(ERROR, true, (char*[]){message, NULL}, 1)
#define Assm_cmd_WALLOPS(text) Assm_AUTO(WALLOPS, true, (char*[]){text, NULL}, 1)
#define Assm_cmd_NICK(nickname) Assm_AUTO(NICK, false, (char*[]){nickname, NULL}, 1)
#define Assm_cmd_USERS(target) Assm_AUTO(USERS, false, (char*[]){target, NULL}, 1)
#define Assm_cmd_NAMES(channels, target) Assm_AUTO(NAMES, false, (char*[]){channels, target, NULL}, 0)
#define Assm_cmd_LIST(channels, target) Assm_AUTO(LIST, false, (char*[]){channels, target, NULL}, 0)
#define Assm_cmd_LUSERS(mask, target) Assm_AUTO(LUSERS, false, (char*[]){mask, target, NULL}, 0)
#define Assm_cmd_STATS(query, target) Assm_AUTO(STATS, false, (char*[]){query, target, NULL}, 0)
#define Assm_cmd_SERVLIST(mask, type) Assm_AUTO(SERVLIST, false, (char*[]){mask, type, NULL}, 0)
#define Assm_cmd_JOIN(channels, keys) Assm_AUTO(JOIN, true, (char*[]){channels, keys, NULL}, 1)
#define Assm_cmd_PART(channel, message) Assm_AUTO(PART, true, (char*[]){channel, message, NULL}, 1)
/* 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 */
#define Assm_cmd_TOPIC(channel, topic) Assm_AUTO(TOPIC, true, (char*[]){channel, topic, NULL}, 1)
#define Assm_cmd_PONG(source, target) Assm_AUTO(PONG, true, (char*[]){source, target, NULL}, 1)
#define Assm_cmd_OPER(name, password) Assm_AUTO(OPER, true, (char*[]){name, password, NULL}, 2)
#define Assm_cmd_SQUIT(server, comment) Assm_AUTO(SQUIT, true, (char*[]){server, comment, NULL}, 2)
#define Assm_cmd_PRIVMSG(target, message) Assm_AUTO(PRIVMSG, true, (char*[]){target, message, NULL}, 2)
#define Assm_cmd_NOTICE(target, text) Assm_AUTO(NOTICE, true, (char*[]){target, text, NULL}, 2)
#define Assm_cmd_SQUERY(servicename, text) Assm_AUTO(SQUERY, true, (char*[]){servicename, text, NULL}, 2)
#define Assm_cmd_KILL(nick, comment) Assm_AUTO(KILL, true, (char*[]){nick, comment, NULL}, 2)
#define Assm_cmd_INVITE(nick, channel) Assm_AUTO(INVITE, false, (char*[]){nick, channel, NULL}, 2)
#define Assm_cmd_MODE(nickname, modes, modeparams) Assm_AUTO(MODE, false, (char*[]){nickname, modes, modeparams, NULL}, 1)
#define Assm_cmd_KICK(channels, users, comment) Assm_AUTO(KICK, true, (char*[]){channels, users, comment, NULL}, 2)
#define Assm_cmd_CONNECT(target, port, remote) Assm_AUTO(CONNECT, false, (char*[]){target, port, remote, NULL}, 2)
#define Assm_cmd_SERVICE(nickname, distribution, type, info) Assm_AUTO(SERVICE, true, (char*[]){nickname, RESERVED, distribution, "0", RESERVED, info, NULL}, 6)
IRC_Message* Assm_cmd_USER(char* user, char* realname, int modes);
IRC_Message* Assm_cmd_PASS(char* password);
IRC_Message* Assm_cmd_OPER(char* name, char* password);
IRC_Message* Assm_cmd_MODE(char* nick, char* modes, char* modeparams);
IRC_Message* Assm_cmd_SERVICE(char* nickname, char* distribution, char* type, char* info);
IRC_Message* Assm_cmd_QUIT(char* mesg);
IRC_Message* Assm_cmd_SQUIT(char* server, char* comment);
IRC_Message* Assm_cmd_JOIN(char* channels, char* keys);
IRC_Message* Assm_cmd_PART(char* channel, char* message);
IRC_Message* Assm_cmd_TOPIC(char* channel, char* topic);
IRC_Message* Assm_cmd_NAMES(char* channels, char* target);
IRC_Message* Assm_cmd_LIST(char* channels, char* target);
IRC_Message* Assm_cmd_INVITE(char* nick, char* channel);
IRC_Message* Assm_cmd_KICK(char* channels, char* users, char* comment);
IRC_Message* Assm_cmd_PRIVMSG(char* target, char* message);
IRC_Message* Assm_cmd_NOTICE(char* target, char* text);
IRC_Message* Assm_cmd_MOTD(char* target);
IRC_Message* Assm_cmd_LUSERS(char* mask, char* target);
IRC_Message* Assm_cmd_VERSION(char* target);
IRC_Message* Assm_cmd_STATS(char* query, char* target);
IRC_Message* Assm_cmd_LINKS(char* remoteserv, char* servmask);
IRC_Message* Assm_cmd_TIME(char* target);
IRC_Message* Assm_cmd_CONNECT(char* target, char* port, char* remote);
IRC_Message* Assm_cmd_TRACE(char* target);
IRC_Message* Assm_cmd_ADMIN(char* target);
IRC_Message* Assm_cmd_INFO(char* target);
IRC_Message* Assm_cmd_SERVLIST(char* mask, char* type);
IRC_Message* Assm_cmd_SQUERY(char* servicename, char* text);
IRC_Message* Assm_cmd_WHO(char* mask, bool oper);
IRC_Message* Assm_cmd_WHOIS(char* target, char* mask);
IRC_Message* Assm_cmd_WHOWAS(char* nick, char* count, char* target);
IRC_Message* Assm_cmd_KILL(char* nick, char* comment);
IRC_Message* Assm_cmd_PING(char* source, char* target);
IRC_Message* Assm_cmd_PONG(char* source, char* target);
IRC_Message* Assm_cmd_ERROR(char* message);
IRC_Message* Assm_cmd_AWAY(char* mesg);
IRC_Message* Assm_cmd_REHASH(void);
IRC_Message* Assm_cmd_DIE(void);
IRC_Message* Assm_cmd_RESTART(void);
IRC_Message* Assm_cmd_SUMMON(char* user, char* target, char* channel);
IRC_Message* Assm_cmd_USERS(char* target);
IRC_Message* Assm_cmd_WALLOPS(char* text);
IRC_Message* Assm_cmd_USERHOST(char* users[]);
IRC_Message* Assm_cmd_ISON(char* users[]);

View File

@ -54,9 +54,11 @@ signed int Tok_mesg(char* str, IRC_Message* out)
if ((out->args[i] = strtok_r(NULL, " ", &progr)) == NULL)
return ERR_UIRC_INVALID_FORMAT;
}
if (*progr) {
out->args[i++] = (*progr == ':') ? progr + 1 : progr;
out->trailing = true;
}
out->args[i] = NULL;
if (*progr)
out->trailing = (*progr == ':') ? progr + 1 : progr;
return 1;
}

View File

@ -22,15 +22,13 @@ signed int Val_mesg(IRC_Message* mesg)
{
if (mesg == NULL)
return ERR_UIRC_NULL_ARGS;
for (unsigned int i = 0; i < 14 && mesg->args[i] != NULL; i++) {
for (unsigned int i = 0; i < 15 && mesg->args[i] != NULL; i++) {
if (Val_type_nocrlf(mesg->args[i]) != 1)
return ERR_UIRC_VAL_FAILED;
if (Val_type_nospcl(mesg->args[i]) != 1)
return ERR_UIRC_VAL_FAILED;
}
if (mesg->trailing != NULL) {
if (Val_type_nocrlf(mesg->trailing) != 1)
return ERR_UIRC_VAL_FAILED;
if (!(mesg->args[i + 1] == NULL && mesg->trailing)) {
if (Val_type_nospcl(mesg->args[i]) != 1)
return ERR_UIRC_VAL_FAILED;
}
}
return 1;
}

View File

@ -13,8 +13,8 @@ int main(void)
#endif
.name = {.nick = "dad", .user = "dad-door", .host = "home.localhost"},
.cmd = PRIVMSG,
.args = {"(You)"},
.trailing = "are ya winning son?",
.args = {"(You)", "are ya winning son?", NULL},
.trailing = true,
};
int res;
if ((res = Assm_mesg(mesg, &input, 512)) <= 0) {

View File

@ -8,9 +8,8 @@ int main(void)
char mesg[513] = {0};
IRC_Message input = {
.cmd = NOTICE,
.args = {"*"},
.trailing = "Cock and ball torture (CBT), penis torture or dick torture is a sexual activity involving application of pain or constriction to the penis or testicles. This may involve directly painful activities, such as genital piercing, wax play, genital spanking, squeezing, ball-busting, genital flogging, urethral play, tickle torture, erotic electrostimulation, kneeing or kicking. The recipient of such activities may receive direct physical pleasure via masochism, or emotional pleasure through erotic humiliation, or knowledge that the play is pleasing to a sadistic dominant. Many of these practices carry significant health risks.",
};
.args = {"*", "Cock and ball torture (CBT), penis torture or dick torture is a sexual activity involving application of pain or constriction to the penis or testicles. This may involve directly painful activities, such as genital piercing, wax play, genital spanking, squeezing, ball-busting, genital flogging, urethral play, tickle torture, erotic electrostimulation, kneeing or kicking. The recipient of such activities may receive direct physical pleasure via masochism, or emotional pleasure through erotic humiliation, or knowledge that the play is pleasing to a sadistic dominant. Many of these practices carry significant health risks.", NULL},
.trailing = true};
if (Assm_mesg(mesg, &input, 512) > 0) {
return EXIT_FAILURE;
}