ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/dlink.h
Revision: 1.3
Committed: Tue Aug 28 17:08:06 2007 UTC (16 years, 9 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.2: +15 -6 lines
Log Message:
- changed name
- updated the example config to the new system
- added more documentation
- enhanced documentation generators
- added a link to the pdf to the website
- added an RSS feed generator
- transitioned hooks to c++ callbacks
- did various merges with upstream along the way
- added const where appropriate
- removed the old block allocator
- fixed most memory leaks
- transitioned some dictionaries to std::map
- transitioned some lists to std::vector
- made some free functions members where appropriate
- renamed string to dynstr and added a static string ststr
- use NOW instead of time (NULL) if possible
- completely reworked database backends, crypto handlers and protocol handlers
  to use an object factory
- removed the old module system. ermyth does not do any dynamic loading anymore
- fixed most of the build system
- reworked how protocol commands work

File Contents

# Content
1 /*
2 * Copyright © 2005 William Pitcock, et al.
3 * Rights to this code are as documented in doc/pod/license.pod.
4 *
5 * Data structures and macros for manipulating linked lists.
6 *
7 * $Id: dlink.h,v 1.2 2007-07-21 01:29:07 pippijn Exp $
8 */
9
10 #ifndef NODE_H
11 #define NODE_H
12
13 #include <common/memory.h>
14
15 /* macros for linked lists */
16 #define LIST_FOREACH(n, head) for (n = (head); n; n = n->next)
17 #define LIST_FOREACH_NEXT(n, head) for (n = (head); n->next; n = n->next)
18 #define LIST_FOREACH_PREV(n, tail) for (n = (tail); n; n = n->prev)
19
20 #define LIST_LENGTH(list) (list)->count
21
22 #define LIST_FOREACH_SAFE(n, tn, head) for (n = (head), tn = n ? n->next : NULL; n != NULL; n = tn, tn = n ? n->next : NULL)
23
24 /* list node struct */
25 struct node_t : zero_initialised
26 {
27 node_t *next;
28 node_t *prev;
29 void *data; /* pointer to real structure */
30 };
31
32 /* node list struct */
33 struct list_t : zero_initialised
34 {
35 node_t *head;
36 node_t *tail;
37 unsigned int count; /* how many entries in the list */
38
39 list_t ()
40 : head (0), tail (0), count (0)
41 {
42 }
43 };
44
45 E node_t *node_create (void);
46 E void node_free (node_t *n);
47 E void node_add (void *data, node_t *n, list_t *l);
48 E void node_add_head (void *data, node_t *n, list_t *l);
49 E void node_add_before (void *data, node_t *n, list_t *l, node_t *before);
50 E void node_del (node_t *n, list_t *l);
51 E node_t *node_find (void *data, list_t *l);
52 E void node_move (node_t *m, list_t *oldlist, list_t *newlist);
53
54 #endif