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