src/irc_user.h
author Tero Marttila <terom@fixme.fi>
Thu, 26 Mar 2009 21:46:10 +0200
changeset 72 43084f103c2a
child 74 11ec458d1cbf
permissions -rw-r--r--
add irc_user module for irc_chan to track users on a channel
#ifndef IRC_USER_H
#define IRC_USER_H

/**
 * Minimal state for tracking per-user state for an irc_net. Mainly, the purpose of this module is to support the
 * irc_chan.users implementation, such that when a user's nickname is changed, one does not need to modify all
 * irc_chan lists, but rather, just replace the nickname field here.
 *
 * XXX: should this tie in to irc_net to register its own NICK/QUIT handlers?
 */
#include "irc_net.h"
#include "error.h"

/**
 * The basic per-network user info. The lifetime of an irc_user struct is strictly for the duration between the user
 * 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
 * channel or QUIT'ing.
 */
struct irc_user {
    /** The user's nickname */
    char *nickname;

    /** Our entry in the irc_net list */
    LIST_ENTRY(irc_user) net_users;
};

/**
 * Create a new irc_user with the given nickname. The nickname is copied for storage.
 */
err_t irc_user_create (struct irc_user **user_ptr, struct irc_net *net, const char *nickname);

/**
 * Destroy an irc_user, releasing memory
 */
void irc_user_destroy (struct irc_user *user);

#endif