1b3307321Smrg/** ------------------------------------------------------------------------
2b3307321Smrg	This file contains routines for manipulating generic lists.
3b3307321Smrg	Lists are implemented with a "harness".  In other words, each
4b3307321Smrg	node in the list consists of two pointers, one to the data item
5b3307321Smrg	and one to the next node in the list.  The head of the list is
6b3307321Smrg	the same struct as each node, but the "item" ptr is used to point
7b3307321Smrg	to the current member of the list (used by the first_in_list and
8b3307321Smrg	next_in_list functions).
9b3307321Smrg
10b3307321SmrgCopyright 1994 Hewlett-Packard Co.
11b3307321SmrgCopyright 1996, 1998  The Open Group
12b3307321Smrg
13b3307321SmrgPermission to use, copy, modify, distribute, and sell this software and its
14b3307321Smrgdocumentation for any purpose is hereby granted without fee, provided that
15b3307321Smrgthe above copyright notice appear in all copies and that both that
16b3307321Smrgcopyright notice and this permission notice appear in supporting
17b3307321Smrgdocumentation.
18b3307321Smrg
19b3307321SmrgThe above copyright notice and this permission notice shall be included
20b3307321Smrgin all copies or substantial portions of the Software.
21b3307321Smrg
22b3307321SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23b3307321SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24b3307321SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25b3307321SmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
26b3307321SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27b3307321SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28b3307321SmrgOTHER DEALINGS IN THE SOFTWARE.
29b3307321Smrg
30b3307321SmrgExcept as contained in this notice, the name of The Open Group shall
31b3307321Smrgnot be used in advertising or otherwise to promote the sale, use or
32b3307321Smrgother dealings in this Software without prior written authorization
33b3307321Smrgfrom The Open Group.
34b3307321Smrg
35b3307321Smrg    -------------------------------------------------------------------- **/
36b3307321Smrg
37b3307321Smrg#ifndef LIST_DEF
38b3307321Smrg#define LIST_DEF
39b3307321Smrg
40b3307321Smrg#include <X11/Xfuncproto.h>
41b3307321Smrg#define LESS	-1
42b3307321Smrg#define EQUAL	0
43b3307321Smrg#define GREATER	1
44b3307321Smrg#define DUP_WHOLE_LIST	0
45b3307321Smrg#define START_AT_CURR	1
46b3307321Smrg
47b3307321Smrgtypedef struct _list_item {
48b3307321Smrg    struct _list_item *next;
49b3307321Smrg    union {
5074b97a6cSmrg        void *item;              /* in normal list node, pts to data */
5174b97a6cSmrg        struct _list_item *curr; /* in list head, pts to curr for 1st, next */
52b3307321Smrg    } ptr;
53b3307321Smrg} list, list_item, *list_ptr;
54b3307321Smrg
5574b97a6cSmrgtypedef void (*DESTRUCT_FUNC_PTR) (void *);
56b3307321Smrg
5774b97a6cSmrgvoid zero_list(list_ptr);
5874b97a6cSmrgint add_to_list(list_ptr, void *);
5974b97a6cSmrglist_ptr new_list(void);
6074b97a6cSmrglist_ptr dup_list_head(list_ptr, int);
6174b97a6cSmrgunsigned int list_length(list_ptr);
6274b97a6cSmrgvoid *delete_from_list(list_ptr, void *);
6374b97a6cSmrgvoid delete_list(list_ptr, int);
6474b97a6cSmrgvoid delete_list_destroying(list_ptr, DESTRUCT_FUNC_PTR);
6574b97a6cSmrgvoid *first_in_list(list_ptr);
6674b97a6cSmrgvoid *next_in_list(list_ptr);
6774b97a6cSmrgint list_is_empty(list_ptr);
68b3307321Smrg
69b3307321Smrg#endif
70