1 #ifndef ubi_sLinkList_H
2 #define ubi_sLinkList_H
3 /* ========================================================================== **
6 * Copyright (C) 1997 by Christopher R. Hertel
8 * Email: crh@ubiqx.mn.org
9 * -------------------------------------------------------------------------- **
10 * This module implements a really simple singly-linked list.
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_sLinkList.h,v $
30 * Revision 1.1 1997/10/15 17:59:58 crh
31 * Added ubi_sLinkList module which manages simple singly-linked lists.
33 * ========================================================================== **
39 /* ========================================================================== **
42 * ubi_slNode - This is the basic node structure.
43 * ubi_slNodePtr - Pointer to a node.
44 * ubi_slList - This is the list header structure.
45 * ubi_slListPtr - Pointer to a List (i.e., a list header structure).
49 typedef struct ubi_slListNode
51 struct ubi_slListNode *Next;
54 typedef ubi_slNode *ubi_slNodePtr;
62 typedef ubi_slList *ubi_slListPtr;
64 /* ========================================================================== **
67 * ubi_slAddHead - Add a new node at the head of the list.
68 * ubi_slRemHead - Remove the node at the head of the list, if any.
69 * ubi_slFirst - Return a pointer to the first node in the list, if any.
70 * ubi_slNext - Given a node, return a pointer to the next node.
72 * Note that all of these provide type casting of the parameters. The
73 * Add and Rem macros are nothing more than nice front-ends to the
74 * Insert and Remove operations.
78 #define ubi_slAddHead( L, N ) \
79 ubi_slInsert( (ubi_slListPtr)(L), (ubi_slNodePtr)(N) )
81 #define ubi_slRemHead( L ) ubi_slRemove( (ubi_slListPtr)(L) )
83 #define ubi_slFirst( L ) (((ubi_slListPtr)(L))->Head)
85 #define ubi_slNext( N ) (((ubi_slNodePtr)(N))->Next)
88 /* ========================================================================== **
89 * Function prototypes...
92 ubi_slListPtr ubi_slInitList( ubi_slListPtr ListPtr );
93 /* ------------------------------------------------------------------------ **
94 * Initialize a singly-linked list header.
96 * Input: ListPtr - A pointer to the list structure that is to be
97 * initialized for use.
99 * Output: A pointer to the initialized list header (i.e., same as
102 * ------------------------------------------------------------------------ **
105 ubi_slNodePtr ubi_slInsert( ubi_slListPtr ListPtr,
107 /* ------------------------------------------------------------------------ **
108 * Insert a new node at the head of the list.
110 * Input: ListPtr - A pointer to the list into which the node is to
112 * New - Pointer to the node that is to be added to the list.
114 * Output: A pointer to the node that was inserted into the list (i.e.,
115 * the same as <New>).
117 * ------------------------------------------------------------------------ **
120 ubi_slNodePtr ubi_slRemove( ubi_slListPtr ListPtr );
121 /* ------------------------------------------------------------------------ **
122 * Remove a node from the head of the list.
124 * Input: ListPtr - A pointer to the list from which the node is to be
127 * Output: A pointer to the node that was removed.
129 * ------------------------------------------------------------------------ **
132 /* ================================ The End ================================= */
133 #endif /* ubi_sLinkList_H */