Nuke some more __P macros.
[dragonfly.git] / usr.bin / make / lst.h
CommitLineData
984263bc
MD
1/*
2 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
3 * Copyright (c) 1988, 1989 by Adam de Boor
4 * Copyright (c) 1989 by Berkeley Softworks
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * from: @(#)lst.h 8.1 (Berkeley) 6/6/93
39 * $FreeBSD: src/usr.bin/make/lst.h,v 1.9 1999/08/28 01:03:32 peter Exp $
ccdb3baa 40 * $DragonFly: src/usr.bin/make/lst.h,v 1.4 2003/11/06 19:09:46 eirikn Exp $
984263bc
MD
41 */
42
43/*-
44 * lst.h --
45 * Header for using the list library
46 */
47#ifndef _LST_H_
48#define _LST_H_
49
50#include <sys/param.h>
51#ifdef __STDC__
52#include <stdlib.h>
53#endif
54#include "sprite.h"
55
56/*
57 * basic typedef. This is what the Lst_ functions handle
58 */
59
60typedef struct Lst *Lst;
61typedef struct LstNode *LstNode;
62
63#define NILLST ((Lst) NIL)
64#define NILLNODE ((LstNode) NIL)
65
66/*
67 * NOFREE can be used as the freeProc to Lst_Destroy when the elements are
68 * not to be freed.
69 * NOCOPY performs similarly when given as the copyProc to Lst_Duplicate.
70 */
2d8a3be7
EN
71#define NOFREE ((void (*)(ClientData)) 0)
72#define NOCOPY ((ClientData (*)(ClientData)) 0)
984263bc
MD
73
74#define LST_CONCNEW 0 /* create new LstNode's when using Lst_Concat */
75#define LST_CONCLINK 1 /* relink LstNode's when using Lst_Concat */
76
77/*
78 * Creation/destruction functions
79 */
80/* Create a new list */
2d8a3be7 81Lst Lst_Init(Boolean);
984263bc 82/* Duplicate an existing list */
2d8a3be7 83Lst Lst_Duplicate(Lst, ClientData (*)(ClientData));
984263bc 84/* Destroy an old one */
2d8a3be7 85void Lst_Destroy(Lst, void (*)(ClientData));
984263bc 86/* True if list is empty */
2d8a3be7 87Boolean Lst_IsEmpty(Lst);
984263bc
MD
88
89/*
90 * Functions to modify a list
91 */
92/* Insert an element before another */
2d8a3be7 93ReturnStatus Lst_Insert(Lst, LstNode, ClientData);
984263bc 94/* Insert an element after another */
2d8a3be7 95ReturnStatus Lst_Append(Lst, LstNode, ClientData);
984263bc 96/* Place an element at the front of a lst. */
2d8a3be7 97ReturnStatus Lst_AtFront(Lst, ClientData);
984263bc 98/* Place an element at the end of a lst. */
2d8a3be7 99ReturnStatus Lst_AtEnd(Lst, ClientData);
984263bc 100/* Remove an element */
2d8a3be7 101ReturnStatus Lst_Remove(Lst, LstNode);
984263bc 102/* Replace a node with a new value */
2d8a3be7 103ReturnStatus Lst_Replace(LstNode, ClientData);
984263bc 104/* Concatenate two lists */
2d8a3be7 105ReturnStatus Lst_Concat(Lst, Lst, int);
984263bc
MD
106
107/*
108 * Node-specific functions
109 */
110/* Return first element in list */
2d8a3be7 111LstNode Lst_First(Lst);
984263bc 112/* Return last element in list */
2d8a3be7 113LstNode Lst_Last(Lst);
984263bc 114/* Return successor to given element */
2d8a3be7 115LstNode Lst_Succ(LstNode);
984263bc 116/* Get datum from LstNode */
2d8a3be7 117ClientData Lst_Datum(LstNode);
984263bc
MD
118
119/*
120 * Functions for entire lists
121 */
122/* Find an element in a list */
ccdb3baa
EN
123LstNode Lst_Find(Lst, ClientData,
124 int (*)(ClientData, ClientData));
984263bc 125/* Find an element starting from somewhere */
ccdb3baa
EN
126LstNode Lst_FindFrom(Lst, LstNode, ClientData,
127 int (*cProc)(ClientData, ClientData));
984263bc
MD
128/*
129 * See if the given datum is on the list. Returns the LstNode containing
130 * the datum
131 */
2d8a3be7 132LstNode Lst_Member(Lst, ClientData);
984263bc 133/* Apply a function to all elements of a lst */
2d8a3be7
EN
134void Lst_ForEach(Lst, int (*)(ClientData, ClientData),
135 ClientData);
984263bc
MD
136/*
137 * Apply a function to all elements of a lst starting from a certain point.
138 * If the list is circular, the application will wrap around to the
139 * beginning of the list again.
140 */
2d8a3be7 141void Lst_ForEachFrom(Lst, LstNode,
984263bc 142 int (*)(ClientData, ClientData),
2d8a3be7 143 ClientData);
984263bc
MD
144/*
145 * these functions are for dealing with a list as a table, of sorts.
146 * An idea of the "current element" is kept and used by all the functions
147 * between Lst_Open() and Lst_Close().
148 */
149/* Open the list */
2d8a3be7 150ReturnStatus Lst_Open(Lst);
984263bc 151/* Next element please */
2d8a3be7 152LstNode Lst_Next(Lst);
984263bc 153/* Done yet? */
2d8a3be7 154Boolean Lst_IsAtEnd(Lst);
984263bc 155/* Finish table access */
2d8a3be7 156void Lst_Close(Lst);
984263bc
MD
157
158/*
159 * for using the list as a queue
160 */
161/* Place an element at tail of queue */
2d8a3be7 162ReturnStatus Lst_EnQueue(Lst, ClientData);
984263bc 163/* Remove an element from head of queue */
2d8a3be7 164ClientData Lst_DeQueue(Lst);
984263bc
MD
165
166#endif /* _LST_H_ */