terom@72: #ifndef IRC_USER_H terom@72: #define IRC_USER_H terom@72: terom@72: /** terom@87: * @file terom@87: * terom@72: * Minimal state for tracking per-user state for an irc_net. Mainly, the purpose of this module is to support the terom@87: * irc_chan::users implementation, such that when a user's nickname is changed, one does not need to modify all terom@72: * irc_chan lists, but rather, just replace the nickname field here. terom@72: * terom@72: * XXX: should this tie in to irc_net to register its own NICK/QUIT handlers? terom@72: */ terom@72: #include "irc_net.h" terom@72: #include "error.h" terom@72: terom@72: /** terom@87: * Basic per-network user info. The lifetime of an irc_user struct is strictly for the duration between the user terom@72: * JOIN'ing onto the first irc_chan we are on (or us JOIN'ing onto it while they are on it), and them PART'ing the terom@87: * last channel we see them on, or QUIT'ing. terom@72: */ terom@72: struct irc_user { terom@72: /** The user's nickname */ terom@72: char *nickname; terom@72: terom@74: /** Refcount for irc_chan.users lists */ terom@74: size_t refcount; terom@74: terom@72: /** Our entry in the irc_net list */ terom@72: LIST_ENTRY(irc_user) net_users; terom@72: }; terom@72: terom@72: /** terom@72: * Create a new irc_user with the given nickname. The nickname is copied for storage. terom@74: * terom@74: * XXX: this is a private function for use by irc_net terom@72: */ terom@72: err_t irc_user_create (struct irc_user **user_ptr, struct irc_net *net, const char *nickname); terom@72: terom@72: /** terom@78: * Rename the irc_user with a new nickname terom@78: */ terom@78: err_t irc_user_rename (struct irc_user *user, const char *new_nickname); terom@78: terom@78: /** terom@72: * Destroy an irc_user, releasing memory terom@72: */ terom@72: void irc_user_destroy (struct irc_user *user); terom@72: terom@72: #endif