This repository has been archived on 2021-01-07. You can view files and clone it, but cannot push or open issues or pull requests.
irc-toolkit/common.c

22 lines
513 B
C
Raw Normal View History

2020-10-29 20:12:34 +00:00
#include <stdio.h>
#include <string.h>
#include "common.h"
#define UIRC_IRCV3
#include "uirc/functions.h"
#include "uirc/types.h"
ssize_t get_buffer_line(char* buf, IRC_Message* parsed)
{
if (buf == NULL || parsed == NULL) return -1;
char* ppoi;
if ((ppoi = strchr(buf, '\n')) != NULL) {
*ppoi = '\0';
if (ppoi > buf && *(ppoi - 1) == '\r') *(ppoi - 1) = '\0';
if (Tok_mesg(buf, parsed) == 1) return ++ppoi - buf;
fprintf(stderr, "warning: received invalid message.\n");
return -1;
}
return 0;
}