ircu2.10.12 pk910 fork
[ircu2.10.12-pk.git] / include / list.h
1 /** @file list.h
2  * @brief Singly and doubly linked list manipulation interface.
3  * @version $Id: list.h 1417 2005-05-30 21:07:33Z entrope $
4  */
5 #ifndef INCLUDED_list_h
6 #define INCLUDED_list_h
7 #ifndef INCLUDED_sys_types_h
8 #include <sys/types.h>         /* time_t, size_t */
9 #define INCLUDED_sys_types_h
10 #endif
11
12 struct Client;
13 struct Connection;
14 struct Channel;
15 struct ConfItem;
16
17 /*
18  * Structures
19  */
20
21 /** Node in a singly linked list. */
22 struct SLink {
23   struct SLink *next; /**< Next element in list. */
24   union {
25     struct Client *cptr;    /**< List element as a client. */
26     struct Channel *chptr;  /**< List element as a channel. */
27     struct ConfItem *aconf; /**< List element as a configuration item. */
28     char *cp;               /**< List element as a string. */
29   } value;                  /**< Value of list element. */
30   unsigned int flags;       /**< Modifier flags for list element. */
31 };
32
33 /** Node in a doubly linked list. */
34 struct DLink {
35   struct DLink*  next;      /**< Next element in list. */
36   struct DLink*  prev;      /**< Previous element in list. */
37   union {
38     struct Client*  cptr;   /**< List element as a client. */
39     struct Channel* chptr;  /**< List element as a channel. */
40     char*           ch;     /**< List element as a string. */
41   } value;                  /**< Value of list element. */
42 };
43
44 /*
45  * Proto types
46  */
47
48 extern void free_link(struct SLink *lp);
49 extern struct SLink *make_link(void);
50 extern void init_list(void);
51 extern struct Client *make_client(struct Client *from, int status);
52 extern void free_connection(struct Connection *con);
53 extern void free_client(struct Client *cptr);
54 extern struct Server *make_server(struct Client *cptr);
55 extern void remove_client_from_list(struct Client *cptr);
56 extern void add_client_to_list(struct Client *cptr);
57 extern struct DLink *add_dlink(struct DLink **lpp, struct Client *cp);
58 extern void remove_dlink(struct DLink **lpp, struct DLink *lp);
59 extern struct ConfItem *make_conf(int type);
60 extern void free_conf(struct ConfItem *aconf);
61 extern void send_listinfo(struct Client *cptr, char *name);
62
63 #endif /* INCLUDED_list_h */