src/irc_user.h
author Tero Marttila <terom@fixme.fi>
Thu, 28 May 2009 01:17:36 +0300
branchnew-lib-errors
changeset 219 cefec18b8268
parent 87 f0db6ebf18b9
permissions -rw-r--r--
some of the lib/transport stuff compiles
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
/**
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
     5
 * @file
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
     6
 *
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
 * Minimal state for tracking per-user state for an irc_net. Mainly, the purpose of this module is to support the
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
     8
 * irc_chan::users implementation, such that when a user's nickname is changed, one does not need to modify all
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
 * 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
    10
 *
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
 * 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
    12
 */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    13
#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
    14
#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
    15
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
/**
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    17
 * Basic per-network user info. The lifetime of an irc_user struct is strictly for the duration between the user
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    18
 * 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
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 78
diff changeset
    19
 * last channel we see them on, or QUIT'ing.
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
 */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    21
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
    22
    /** 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
    23
    char *nickname;
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    24
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
    25
    /** 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
    26
    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
    27
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    28
    /** 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
    29
    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
    30
};
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    31
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    32
/**
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    33
 * 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
    34
 *
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
    35
 * 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
    36
 */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    37
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
    38
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
/**
78
941bb8379d3d implement NICK/QUIT handling for irc_net/irc_chan
Tero Marttila <terom@fixme.fi>
parents: 74
diff changeset
    40
 * Rename the irc_user with a new nickname
941bb8379d3d implement NICK/QUIT handling for irc_net/irc_chan
Tero Marttila <terom@fixme.fi>
parents: 74
diff changeset
    41
 */
941bb8379d3d implement NICK/QUIT handling for irc_net/irc_chan
Tero Marttila <terom@fixme.fi>
parents: 74
diff changeset
    42
err_t irc_user_rename (struct irc_user *user, const char *new_nickname);
941bb8379d3d implement NICK/QUIT handling for irc_net/irc_chan
Tero Marttila <terom@fixme.fi>
parents: 74
diff changeset
    43
941bb8379d3d implement NICK/QUIT handling for irc_net/irc_chan
Tero Marttila <terom@fixme.fi>
parents: 74
diff changeset
    44
/**
72
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    45
 * 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
    46
 */
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    47
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
    48
43084f103c2a add irc_user module for irc_chan to track users on a channel
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    49
#endif