/[LeafOK_CVS]/pvpgn-1.7.4/src/common/elist.h
ViewVC logotype

Annotation of /pvpgn-1.7.4/src/common/elist.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (vendor branch)
Tue Jun 6 03:41:38 2006 UTC (19 years, 9 months ago) by sysadm
Branch: GNU, MAIN
CVS Tags: arelease, HEAD
Changes since 1.1: +0 -0 lines
Content type: text/x-chdr
no message

1 sysadm 1.1 /*
2     * Copyright (C) 2004 Dizzy (dizzy@roedu.net)
3     *
4     * This program is free software; you can redistribute it and/or
5     * modify it under the terms of the GNU General Public License
6     * as published by the Free Software Foundation; either version 2
7     * of the License, or (at your option) any later version.
8     *
9     * This program is distributed in the hope that it will be useful,
10     * but WITHOUT ANY WARRANTY; without even the implied warranty of
11     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12     * GNU General Public License for more details.
13     *
14     * You should have received a copy of the GNU General Public License
15     * along with this program; if not, write to the Free Software
16     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17     */
18     #ifndef INCLUDED_ELIST_TYPES
19     #define INCLUDED_ELIST_TYPES
20    
21     typedef struct elist_struct {
22     struct elist_struct *next, *prev;
23     } t_elist;
24    
25     #endif /* INCLUDED_ELIST_TYPES */
26    
27     #ifndef INCLUDED_ELIST_PROTOS
28     #define INCLUDED_ELIST_PROTOS
29    
30     #ifdef HAVE_STDDEF_H
31     # include <stddef.h>
32     #endif
33    
34     /* access to it's members */
35     #define elist_next(ptr) ((ptr)->next)
36     #define elist_prev(ptr) ((ptr)->prev)
37    
38     #define __elist_init(elist,val) { (elist)->next = (elist)->prev = (val); }
39     #define elist_init(elist) __elist_init(elist,elist)
40     #define DECLARE_ELIST_INIT(var) \
41     t_elist var = { &var, &var };
42    
43     /* link an new node just after "where" */
44     static inline void elist_add(t_elist *where, t_elist *what)
45     {
46     what->next = where->next;
47     where->next->prev = what;
48     what->prev = where;
49     where->next = what;
50     }
51    
52     /* link a new node just before "where" (usefull in creating queues) */
53     static inline void elist_add_tail(t_elist *where, t_elist *what)
54     {
55     what->prev = where->prev;
56     where->prev->next = what;
57     what->next = where;
58     where->prev = what;
59     }
60    
61     /* unlink "what" from it's list */
62     static inline void elist_del(t_elist *what)
63     {
64     what->next->prev = what->prev;
65     what->prev->next = what->next;
66     }
67    
68     /* finds out the container address by computing it from the list node
69     * address substracting the offset inside the container of the list node
70     * member */
71     #define elist_entry(ptr,type,member) ((type*)(((char*)ptr)-offsetof(type,member)))
72    
73     /* DONT remove while traversing with this ! */
74     #define elist_for_each(pos,head) \
75     for (pos = (head)->next; pos != (head); pos = pos->next)
76    
77     #define elist_for_each_rev(pos,head) \
78     for (pos = (head)->prev; pos != (head); pos = pos->prev)
79    
80     /* safe for removals while traversing */
81     #define elist_for_each_safe(pos,head,save) \
82     for (pos = (head)->next, save = pos->next; pos != (head); \
83     pos = save, save = pos->next)
84    
85     #define elist_for_each_safe_rev(pos,head,save) \
86     for (pos = (head)->prev, save = pos->prev; pos != (head); \
87     pos = save, save = pos->prev)
88    
89     #define elist_empty(ptr) ((ptr)->next == (ptr))
90    
91     #endif /* INCLUDED_ELIST_PROTOS */

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1