#ifndef IRC_LINE_H
#define IRC_LINE_H
#include "error.h"
/*
* The maximum length of a line, including terminating CRLF
*/
#define IRC_LINE_MAX 512
/*
* The maximum number of arguments for a single command
*/
#define IRC_ARG_MAX 15
/*
* Chars that are invalid inside of tokens
*/
#define IRC_TOKEN_INVALID "\r\n\n "
#define IRC_TOKEN_TRAILING_INVALID "\r\n\n"
/*
* Low-level IRC protocol unit is a line with its bits
*/
struct irc_line {
/* The message source, either a server name or a nickmask */
const char *prefix;
/* The command, either a numeric or a primary command */
const char *command;
/* The arguments, with unused ones set to NULL */
const char *args[IRC_ARG_MAX];
};
/*
* Parse an IRC message to fill in an irc_line. This mutates the value of data (to insert NULs between tokens), and
* stores pointers into this data into the irc_line.
*/
err_t irc_line_parse (struct irc_line *line, char *data);
/*
* Formats an irc_line as a protocol line into the given buffer (which should hold at least IRC_LINE_MAX bytes).
*/
err_t irc_line_build (const struct irc_line *line, char *buf);
#endif /* IRC_LINE_H */