src/irc_user.h
author Tero Marttila <terom@fixme.fi>
Thu, 26 Mar 2009 22:54:25 +0200
changeset 74 11ec458d1cbf
parent 72 43084f103c2a
child 78 941bb8379d3d
permissions -rw-r--r--
add irc_chan_on_PART, irc_net_put_user and test_irc_chan_user_part
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
#ifndef IRC_USER_H
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
#define IRC_USER_H
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
/**
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
 * Minimal state for tracking per-user state for an irc_net. Mainly, the purpose of this module is to support the
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
 * irc_chan.users implementation, such that when a user's nickname is changed, one does not need to modify all
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
 * irc_chan lists, but rather, just replace the nickname field here.
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
 *
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
 * XXX: should this tie in to irc_net to register its own NICK/QUIT handlers?
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
 */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
#include "irc_net.h"
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
#include "error.h"
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    13
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
/**
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
 * The basic per-network user info. The lifetime of an irc_user struct is strictly for the duration between the user
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
 * 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
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    17
 * channel or QUIT'ing.
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    18
 */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
struct irc_user {
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
    /** The user's nickname */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    21
    char *nickname;
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    22
74
11ec458d1cbf add irc_chan_on_PART, irc_net_put_user and test_irc_chan_user_part
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    23
    /** Refcount for irc_chan.users lists */
11ec458d1cbf add irc_chan_on_PART, irc_net_put_user and test_irc_chan_user_part
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    24
    size_t refcount;
11ec458d1cbf add irc_chan_on_PART, irc_net_put_user and test_irc_chan_user_part
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    25
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    26
    /** Our entry in the irc_net list */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    27
    LIST_ENTRY(irc_user) net_users;
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    28
};
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    29
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    30
/**
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    31
 * Create a new irc_user with the given nickname. The nickname is copied for storage.
74
11ec458d1cbf add irc_chan_on_PART, irc_net_put_user and test_irc_chan_user_part
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    32
 *
11ec458d1cbf add irc_chan_on_PART, irc_net_put_user and test_irc_chan_user_part
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    33
 * XXX: this is a private function for use by irc_net
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    34
 */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    35
err_t irc_user_create (struct irc_user **user_ptr, struct irc_net *net, const char *nickname);
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    36
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    37
/**
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
 * Destroy an irc_user, releasing memory
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
 */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    40
void irc_user_destroy (struct irc_user *user);
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    41
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    42
#endif