1 #ifndef ubi_dLinkList_H
2 #define ubi_dLinkList_H
3 /* ========================================================================== **
6 * Copyright (C) 1997 by Christopher R. Hertel
8 * Email: crh@ubiqx.mn.org
9 * -------------------------------------------------------------------------- **
10 * This module implements simple doubly-linked lists.
11 * -------------------------------------------------------------------------- **
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Library General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Library General Public License for more details.
23 * You should have received a copy of the GNU Library General Public
24 * License along with this library; if not, write to the Free
25 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 * -------------------------------------------------------------------------- **
29 * $Log: ubi_dLinkList.h,v $
30 * Revision 1.1 1997/10/10 14:46:43 crh
31 * This is the ubiqx binary tree and linked list library.
32 * This library is being included as part of the Samba distribution.
35 * Revision 0.1 1997/10/07 04:34:38 crh
39 * ========================================================================== **
45 /* ========================================================================== **
48 * ubi_dlNode - This is the basic node structure.
49 * ubi_dlNodePtr - Pointer to a node.
50 * ubi_dlList - This is the list header structure.
51 * ubi_dlListPtr - Pointer to a List (i.e., a list header structure).
55 typedef struct ubi_dlListNode
57 struct ubi_dlListNode *Next;
58 struct ubi_dlListNode *Prev;
61 typedef ubi_dlNode *ubi_dlNodePtr;
70 typedef ubi_dlList *ubi_dlListPtr;
72 /* ========================================================================== **
75 * ubi_dlAddHead - Add a new node at the head of the list.
76 * ubi_dlAddTail - Add a new node at the tail of the list.
77 * ubi_dlRemHead - Remove the node at the head of the list, if any.
78 * ubi_dlRemTail - Remove the node at the tail of the list, if any.
79 * ubi_dlFirst - Return a pointer to the first node in the list, if any.
80 * ubi_dlLast - Return a pointer to the last node in the list, if any.
81 * ubi_dlNext - Given a node, return a pointer to the next node.
82 * ubi_dlPrev - Given a node, return a pointer to the previous node.
85 #define ubi_dlAddHead( L, N ) ubi_dlInsert( (L), (N), NULL )
87 #define ubi_dlAddTail( L, N ) ubi_dlInsert( (L), (N), ((L)->Tail) )
89 #define ubi_dlRemHead( L ) ubi_dlRemove( (L), ((L)->Head) )
91 #define ubi_dlRemTail( L ) ubi_dlRemove( (L), ((L)->Tail) )
93 #define ubi_dlFirst( L ) ((L)->Head)
95 #define ubi_dlLast( L ) ((L)->Tail)
97 #define ubi_dlNext( N ) ((N)->Next)
99 #define ubi_dlPrev( N ) ((N)->Prev)
102 /* ========================================================================== **
103 * Function prototypes...
106 ubi_dlListPtr ubi_dlInitList( ubi_dlListPtr ListPtr );
107 /* ------------------------------------------------------------------------ **
108 * Initialize a doubly-linked list header.
110 * Input: ListPtr - A pointer to the list structure that is to be
111 * initialized for use.
113 * Output: A pointer to the initialized list header (i.e., same as
116 * ------------------------------------------------------------------------ **
119 ubi_dlNodePtr ubi_dlInsert( ubi_dlListPtr ListPtr,
121 ubi_dlNodePtr After );
122 /* ------------------------------------------------------------------------ **
123 * Insert a new node into the list.
125 * Input: ListPtr - A pointer to the list into which the node is to
127 * New - Pointer to the new node.
128 * After - NULL, or a pointer to a node that is already in the
130 * If NULL, then <New> will be added at the head of the
131 * list, else it will be added following <After>.
133 * Output: A pointer to the node that was inserted into the list (i.e.,
134 * the same as <New>).
136 * ------------------------------------------------------------------------ **
139 ubi_dlNodePtr ubi_dlRemove( ubi_dlListPtr ListPtr, ubi_dlNodePtr Old );
140 /* ------------------------------------------------------------------------ **
141 * Remove a node from the list.
143 * Input: ListPtr - A pointer to the list from which <Old> is to be
145 * Old - A pointer to the node that is to be removed from the
148 * Output: A pointer to the node that was removed (i.e., <Old>).
150 * ------------------------------------------------------------------------ **
154 /* ================================ The End ================================= */
155 #endif /* ubi_dLinkList_H */