diff --git a/include/uirc.h b/include/uirc.h
index fdc9103..fdafafd 100644
--- a/include/uirc.h
+++ b/include/uirc.h
@@ -20,14 +20,23 @@
#define UIRC_INCUDED
struct irc_message {
- signed short cmd;
- char* args[14];
- unsigned int argc;
+ struct tags {
+ /* See https://ircv3.net/registry#tags for more information */
+ char* account;
+ char* batch;
+ char* label;
+ char* msgid;
+ char* multiline_concat; /* NOTE: Still a draft */
+ char* time;
+ } tags;
struct source {
char* nick;
char* user;
char* host;
} source;
+ signed short cmd;
+ char* args[14];
+ unsigned int argc;
char* msg;
};
diff --git a/src/uirc.c b/src/uirc.c
index d9e8f32..b4d188b 100644
--- a/src/uirc.c
+++ b/src/uirc.c
@@ -61,18 +61,46 @@ const char* uirc_ircmd[] = {
int uirc_tokenize_message(struct irc_message* irc_msg, char* line)
{
char *progr, *command;
- progr = line; /* Set progress to starting point */
+ progr = line;
+ if (*progr == '@') {
+ char* tags;
+ if ((tags = strtok_r(progr + 1, " ", &progr)) != NULL) {
+ char *ctag = tags, *cval;
+ do {
+ if ((cval = strchr(ctag, '=')) != NULL) {
+ *(cval++) = '\0';
+ if (!strcmp(ctag, "time")) {
+ irc_msg->tags.time = cval;
+ } else if (!strcmp(ctag, "account")) {
+ irc_msg->tags.account = cval;
+ } else if (!strcmp(ctag, "batch")) {
+ irc_msg->tags.batch = cval;
+ } else if (!strcmp(ctag, "label")) {
+ irc_msg->tags.label = cval;
+ } else if (!strcmp(ctag, "msgid")) {
+ irc_msg->tags.msgid = cval;
+ } else if (!strcmp(ctag, "multiline-concat")) {
+ irc_msg->tags.multiline_concat = cval;
+ }
+ if ((ctag = strchr(cval, ';')) != NULL)
+ *(ctag++) = '\0';
+ }
+ } while (ctag != NULL);
+ } else
+ return 0;
+ }
if (*progr == ':') {
char* prefix;
- if ((prefix = strtok_r(progr, " ", &progr) + 1) != NULL) {
+ if ((prefix = strtok_r(progr + 1, " ", &progr)) != NULL) {
if ((irc_msg->source.host = strchr(prefix, '@')) != NULL) {
*(irc_msg->source.host++) = '\0';
if ((irc_msg->source.user = strchr(prefix, '!')) != NULL)
*(irc_msg->source.user++) = '\0';
}
- irc_msg->source.nick = prefix;
- }
+ irc_msg->source.nick = prefix; /* NOTE: This may be the server instead of a nick according to RFC2812, it is left to the library user to decide how to interpret this based on the context. */
+ } else
+ return 0;
}
command = strtok_r(progr, " ", &progr);
diff --git a/src/uirc.h b/src/uirc.h
index 43727c8..d16f6a5 100644
--- a/src/uirc.h
+++ b/src/uirc.h
@@ -16,10 +16,7 @@
* along with uIRC. If not, see .
*/
#include "../include/uirc.h"
-#include
-#include
#include
-#include
#include
#include
#include