~ubuntu-branches/ubuntu/hardy/pmake/hardy

« back to all changes in this revision

Viewing changes to lst.h

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hocevar (Debian packages)
  • Date: 2004-03-12 13:14:27 UTC
  • mfrom: (0.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040312131427-us94ehmatt3kxhm8
Tags: 1.98-3
* mk/bsd.man.mk:
  + Use symlinks instead of hard links when using the MLINKS directive
    to link manual pages, courtesy of Robert Millan.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*      $NetBSD: lst.h,v 1.7 1996/11/06 17:59:12 christos Exp $ */
 
1
/*      $NetBSD: lst.h,v 1.10 2003/08/07 11:14:53 agc Exp $     */
2
2
 
3
3
/*
4
4
 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
 
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. Neither the name of the University nor the names of its contributors
 
19
 *    may be used to endorse or promote products derived from this software
 
20
 *    without specific prior written permission.
 
21
 *
 
22
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 
23
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
24
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
25
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 
26
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
27
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
28
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
29
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
30
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
31
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
32
 * SUCH DAMAGE.
 
33
 *
 
34
 *      from: @(#)lst.h 8.1 (Berkeley) 6/6/93
 
35
 */
 
36
 
 
37
/*
5
38
 * Copyright (c) 1988, 1989 by Adam de Boor
6
39
 * Copyright (c) 1989 by Berkeley Softworks
7
40
 * All rights reserved.
47
80
#ifndef _LST_H_
48
81
#define _LST_H_
49
82
 
50
 
#include        <sprite.h>
51
83
#include        <sys/param.h>
52
 
#if __STDC__
53
84
#include        <stdlib.h>
54
 
#endif
 
85
 
 
86
#include        "sprite.h"
55
87
 
56
88
/*
57
89
 * basic typedef. This is what the Lst_ functions handle
68
100
 *      not to be freed.
69
101
 * NOCOPY performs similarly when given as the copyProc to Lst_Duplicate.
70
102
 */
71
 
#define NOFREE          ((void (*) __P((ClientData))) 0)
72
 
#define NOCOPY          ((ClientData (*) __P((ClientData))) 0)
 
103
#define NOFREE          ((void (*)(ClientData)) 0)
 
104
#define NOCOPY          ((ClientData (*)(ClientData)) 0)
73
105
 
74
106
#define LST_CONCNEW     0   /* create new LstNode's when using Lst_Concat */
75
107
#define LST_CONCLINK    1   /* relink LstNode's when using Lst_Concat */
78
110
 * Creation/destruction functions
79
111
 */
80
112
/* Create a new list */
81
 
Lst             Lst_Init __P((Boolean));
 
113
Lst             Lst_Init(Boolean);
82
114
/* Duplicate an existing list */
83
 
Lst             Lst_Duplicate __P((Lst, ClientData (*)(ClientData)));
 
115
Lst             Lst_Duplicate(Lst, ClientData (*)(ClientData));
84
116
/* Destroy an old one */
85
 
void            Lst_Destroy __P((Lst, void (*)(ClientData)));
 
117
void            Lst_Destroy(Lst, void (*)(ClientData));
86
118
/* True if list is empty */
87
 
Boolean         Lst_IsEmpty __P((Lst));
 
119
Boolean         Lst_IsEmpty(Lst);
88
120
 
89
121
/*
90
122
 * Functions to modify a list
91
123
 */
92
124
/* Insert an element before another */
93
 
ReturnStatus    Lst_Insert __P((Lst, LstNode, ClientData));
 
125
ReturnStatus    Lst_Insert(Lst, LstNode, ClientData);
94
126
/* Insert an element after another */
95
 
ReturnStatus    Lst_Append __P((Lst, LstNode, ClientData));
 
127
ReturnStatus    Lst_Append(Lst, LstNode, ClientData);
96
128
/* Place an element at the front of a lst. */
97
 
ReturnStatus    Lst_AtFront __P((Lst, ClientData));
 
129
ReturnStatus    Lst_AtFront(Lst, ClientData);
98
130
/* Place an element at the end of a lst. */
99
 
ReturnStatus    Lst_AtEnd __P((Lst, ClientData));
 
131
ReturnStatus    Lst_AtEnd(Lst, ClientData);
100
132
/* Remove an element */
101
 
ReturnStatus    Lst_Remove __P((Lst, LstNode));
 
133
ReturnStatus    Lst_Remove(Lst, LstNode);
102
134
/* Replace a node with a new value */
103
 
ReturnStatus    Lst_Replace __P((LstNode, ClientData));
 
135
ReturnStatus    Lst_Replace(LstNode, ClientData);
104
136
/* Concatenate two lists */
105
 
ReturnStatus    Lst_Concat __P((Lst, Lst, int));
 
137
ReturnStatus    Lst_Concat(Lst, Lst, int);
106
138
 
107
139
/*
108
140
 * Node-specific functions
109
141
 */
110
142
/* Return first element in list */
111
 
LstNode         Lst_First __P((Lst));
 
143
LstNode         Lst_First(Lst);
112
144
/* Return last element in list */
113
 
LstNode         Lst_Last __P((Lst));
 
145
LstNode         Lst_Last(Lst);
114
146
/* Return successor to given element */
115
 
LstNode         Lst_Succ __P((LstNode));
 
147
LstNode         Lst_Succ(LstNode);
116
148
/* Get datum from LstNode */
117
 
ClientData      Lst_Datum __P((LstNode));
 
149
ClientData      Lst_Datum(LstNode);
118
150
 
119
151
/*
120
152
 * Functions for entire lists
121
153
 */
122
154
/* Find an element in a list */
123
 
LstNode         Lst_Find __P((Lst, ClientData,
124
 
                              int (*)(ClientData, ClientData)));
 
155
LstNode         Lst_Find(Lst, ClientData, int (*)(ClientData, ClientData));
125
156
/* Find an element starting from somewhere */
126
 
LstNode         Lst_FindFrom __P((Lst, LstNode, ClientData,
127
 
                                  int (*cProc)(ClientData, ClientData)));
 
157
LstNode         Lst_FindFrom(Lst, LstNode, ClientData,
 
158
                             int (*cProc)(ClientData, ClientData));
128
159
/*
129
160
 * See if the given datum is on the list. Returns the LstNode containing
130
161
 * the datum
131
162
 */
132
 
LstNode         Lst_Member __P((Lst, ClientData));
 
163
LstNode         Lst_Member(Lst, ClientData);
133
164
/* Apply a function to all elements of a lst */
134
 
void            Lst_ForEach __P((Lst, int (*)(ClientData, ClientData),
135
 
                                 ClientData));
 
165
void            Lst_ForEach(Lst, int (*)(ClientData, ClientData), ClientData);
136
166
/*
137
167
 * Apply a function to all elements of a lst starting from a certain point.
138
168
 * If the list is circular, the application will wrap around to the
139
169
 * beginning of the list again.
140
170
 */
141
 
void            Lst_ForEachFrom __P((Lst, LstNode,
142
 
                                     int (*)(ClientData, ClientData),
143
 
                                     ClientData));
 
171
void            Lst_ForEachFrom(Lst, LstNode, int (*)(ClientData, ClientData),
 
172
                                ClientData);
144
173
/*
145
174
 * these functions are for dealing with a list as a table, of sorts.
146
175
 * An idea of the "current element" is kept and used by all the functions
147
176
 * between Lst_Open() and Lst_Close().
148
177
 */
149
178
/* Open the list */
150
 
ReturnStatus    Lst_Open __P((Lst));
 
179
ReturnStatus    Lst_Open(Lst);
151
180
/* Next element please */
152
 
LstNode         Lst_Next __P((Lst));
 
181
LstNode         Lst_Next(Lst);
153
182
/* Done yet? */
154
 
Boolean         Lst_IsAtEnd __P((Lst));
 
183
Boolean         Lst_IsAtEnd(Lst);
155
184
/* Finish table access */
156
 
void            Lst_Close __P((Lst));
 
185
void            Lst_Close(Lst);
157
186
 
158
187
/*
159
188
 * for using the list as a queue
160
189
 */
161
190
/* Place an element at tail of queue */
162
 
ReturnStatus    Lst_EnQueue __P((Lst, ClientData));
 
191
ReturnStatus    Lst_EnQueue(Lst, ClientData);
163
192
/* Remove an element from head of queue */
164
 
ClientData      Lst_DeQueue __P((Lst));
 
193
ClientData      Lst_DeQueue(Lst);
165
194
 
166
195
#endif /* _LST_H_ */