1/** ------------------------------------------------------------------------
2	This file contains routines for manipulating generic lists.
3	Lists are implemented with a "harness".  In other words, each
4	node in the list consists of two pointers, one to the data item
5	and one to the next node in the list.  The head of the list is
6	the same struct as each node, but the "item" ptr is used to point
7	to the current member of the list (used by the first_in_list and
8	next_in_list functions).
9
10Copyright 1994 Hewlett-Packard Co.
11Copyright 1996, 1998  The Open Group
12
13Permission to use, copy, modify, distribute, and sell this software and its
14documentation for any purpose is hereby granted without fee, provided that
15the above copyright notice appear in all copies and that both that
16copyright notice and this permission notice appear in supporting
17documentation.
18
19The above copyright notice and this permission notice shall be included
20in all copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
26OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28OTHER DEALINGS IN THE SOFTWARE.
29
30Except as contained in this notice, the name of The Open Group shall
31not be used in advertising or otherwise to promote the sale, use or
32other dealings in this Software without prior written authorization
33from The Open Group.
34
35    -------------------------------------------------------------------- **/
36
37#ifndef LIST_DEF
38#define LIST_DEF
39
40#include <X11/Xfuncproto.h>
41#define LESS	-1
42#define EQUAL	0
43#define GREATER	1
44#define DUP_WHOLE_LIST	0
45#define START_AT_CURR	1
46
47typedef struct _list_item {
48    struct _list_item *next;
49    union {
50        void *item;              /* in normal list node, pts to data */
51        struct _list_item *curr; /* in list head, pts to curr for 1st, next */
52    } ptr;
53} list, list_item, *list_ptr;
54
55typedef void (*DESTRUCT_FUNC_PTR) (void *);
56
57void zero_list(list_ptr);
58int add_to_list(list_ptr, void *);
59list_ptr new_list(void);
60list_ptr dup_list_head(list_ptr, int);
61unsigned int list_length(list_ptr);
62void *delete_from_list(list_ptr, void *);
63void delete_list(list_ptr, int);
64void delete_list_destroying(list_ptr, DESTRUCT_FUNC_PTR);
65void *first_in_list(list_ptr);
66void *next_in_list(list_ptr);
67int list_is_empty(list_ptr);
68
69#endif
70