terom@36: #ifndef IRC_NM_H terom@36: #define IRC_NM_H terom@36: terom@36: /** terom@36: * @file terom@36: * terom@36: * Support for IRC nickmasks terom@36: */ terom@36: #include "error.h" terom@36: #include terom@36: terom@36: /** terom@36: * Maximum length of an IRC nickname including terminating NUL terom@36: */ terom@36: #define IRC_NICK_MAX 31 terom@36: terom@36: /** terom@36: * Parsed nickmask terom@36: */ terom@36: struct irc_nm { terom@36: /** Nickname, not normalized */ terom@36: const char *nickname; terom@36: terom@36: /** Username, including any ident-related prefix from the network */ terom@36: const char *username; terom@36: terom@36: /** Hostname, either reverse DNS hostname, literal IPv4 or literal IPv6 */ terom@36: const char *hostname; terom@36: }; terom@36: terom@36: /** terom@36: * Parse a full nickmask from a prefix. This fails if the prefix is a server name. terom@36: * terom@36: * XXX: not implemented, and memory-management issues terom@36: */ terom@36: err_t irc_nm_parse (struct irc_nm *nm, char *prefix); terom@36: terom@36: /** terom@36: * Compare two nicknames for equality, with standard strcmp() semantics. terom@36: */ terom@36: int irc_cmp_nick (const char *nick1, const char *nick2); terom@36: terom@36: /** terom@36: * Compare up to the first n chars of the two nickname strings for equality, with standard strcmp() semantics. terom@36: */ terom@36: int irc_ncmp_nick (const char *nick1, const char *nick2, size_t n); terom@36: terom@36: /** terom@36: * Parse the nickname portion of a prefix, storing it in the given buffer of IRC_NICK_MAX bytes. terom@36: */ terom@36: err_t irc_prefix_parse_nick (const char *prefix, char nick[IRC_NICK_MAX]); terom@36: terom@36: /** terom@36: * Compare the nickname in the given prefix and with the given nickname for equality. terom@36: * terom@36: * @return -err for invalid prefix, 0 for match, >0 for non-match. terom@36: */ terom@36: int irc_prefix_cmp_nick (const char *prefix, const char *nick); terom@36: terom@36: #endif