ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/include/list.h
Revision: 8751
Committed: Tue Jan 1 11:06:50 2019 UTC (7 years, 6 months ago) by michael
Content type: text/x-chdr
File size: 2608 byte(s)
Log Message:
- Update copyright years

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2865 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 8751 * Copyright (c) 2000-2019 ircd-hybrid development team
5 adx 30 *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18 michael 4564 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 adx 30 * USA
20     */
21    
22 michael 2865 /*! \file list.h
23     * \brief A header for the list manipulation routines.
24     * \version $Id$
25     */
26    
27 adx 30 #ifndef INCLUDED_list_h
28     #define INCLUDED_list_h
29    
30 michael 1011 /* These macros are basically swiped from the linux kernel
31     * they are simple yet effective
32     */
33    
34     /*
35     * Walks forward of a list.
36     * pos is your node
37     * head is your list head
38     */
39     #define DLINK_FOREACH(pos, head) for (pos = (head); pos != NULL; pos = pos->next)
40    
41     /*
42     * Walks forward of a list safely while removing nodes
43     * pos is your node
44     * n is another list head for temporary storage
45     * head is your list head
46     */
47     #define DLINK_FOREACH_SAFE(pos, n, head) for (pos = (head), n = pos ? pos->next : NULL; pos != NULL; pos = n, n = pos ? pos->next : NULL)
48     #define DLINK_FOREACH_PREV(pos, head) for (pos = (head); pos != NULL; pos = pos->prev)
49    
50     /* Returns the list length */
51     #define dlink_list_length(list) (list)->length
52    
53     /*
54     * double-linked-list stuff
55     */
56     typedef struct _dlink_node dlink_node;
57     typedef struct _dlink_list dlink_list;
58    
59     struct _dlink_node
60     {
61     void *data;
62     dlink_node *prev;
63     dlink_node *next;
64     };
65    
66     struct _dlink_list
67     {
68     dlink_node *head;
69     dlink_node *tail;
70 michael 1013 unsigned int length;
71 michael 1011 };
72    
73 michael 2865 extern void free_dlink_node(dlink_node *);
74 michael 1011 extern void dlinkAdd(void *, dlink_node *, dlink_list *);
75     extern void dlinkAddBefore(dlink_node *, void *, dlink_node *, dlink_list *);
76     extern void dlinkAddTail(void *, dlink_node *, dlink_list *);
77     extern void dlinkDelete(dlink_node *, dlink_list *);
78     extern void dlinkMoveList(dlink_list *, dlink_list *);
79 michael 1126 extern void dlink_move_node(dlink_node *, dlink_list *, dlink_list *);
80 michael 4784 extern dlink_node *dlinkFind(dlink_list *, const void *);
81 michael 1011 extern dlink_node *dlinkFindDelete(dlink_list *, void *);
82 adx 30 extern dlink_node *make_dlink_node(void);
83     #endif

Properties

Name Value
svn:eol-style native
svn:keywords Id