1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
<HTML>
<BODY BGCOLOR=white>
<PRE>
<!-- Manpage converted by man2html 3.0.1 -->
NAME
lAddElemStr, lDelElemStr, lGetElemStr - list operations
lAddSubStr, lDelSubStr, lGetSubStr - sub-list operations
SYNOPSIS
#include "cull.h"
lListElem* lAddElemStr(
lList** lpp,
int nm,
char *s,
lDescr *dp
);
int lDelElemStr(
lList** lpp,
int nm,
char *s
);
lListElem *lGetElemStr(
lList* lp,
int nm,
char *s
);
lListElem* lAddSubStr(
lListElem* ep,
int nm,
char *s,
B
int snm,
lDescr *dp
);
int lDelSubStr(
lListElem* ep,
int nm,
char *s,
int snm
);
lListElem *lGetSubStr(
lListElem* ep,
int nm,
char *s,
int snm
);
lListElem *lDiffListStr(
int nm,
lList** lpp1,
lList** lpp1,
);
DESCRIPTION
lListElem *lAddElemStr(lpp, nm, s, dp)
Appends an element to the list *lpp. The new element
gets the type dp (using <B><A HREF="../htmlman3/lCreateElem.html">lCreateElem(3)</A></B>). Field nm of
the new elements gets the value s (using <I>lSet-</I>
<B><A HREF="../htmlman3/String.html">String(3)</A></B>). No test are made to ensure uniqueness of
elements in the list. If *lpp is NULL a new list head
gets created (using <B><A HREF="../htmlman3/lCreateList.html">lCreateList(3)</A></B>). lAddElemStr()
fails if the given list or descriptor has no field nm.
int lDelElemStr(lpp, nm, s)
Removes one element containing s at field nm in the
list *lpp. <I>lGetElemStr</I> is used to find the element. It
gets unchained and freed. If no more elements are in
the list after unchaining the list head gets freed and
NULL is written to *lpp. <I>lDelElemStr</I> fails if the
given list has no field nm.
lListElem *lGetElemStr(lp, nm, s)
Searches the first element containing s at field nm in
the list lp. <B><A HREF="../htmlman3/strcmp.html">strcmp(3)</A></B> s used to perform the compare.
<I>lGetElemStr</I> returns the element.
lListElem *lAddSubStr(ep, nm, s, snm, dp)
Uses <I>lAddElemStr</I> to append an element to the sub-list
field snm of the element ep.
int lDelSubStr(ep, nm, s, snm)
Uses <I>lDelElemStr</I> to remove an element from the sub-list
field snm of the element ep.
lListElem *lGetSubStr(ep, nm, s, snm)
Uses <I>lGetElemStr</I> to find an element in the sub-list
field snm of the element ep.
int lDiffListStr(nm, lpp1, lpp2)
<I>lDiffListStr</I> removes and frees elements in <I>both</I> lists
with the same string key in field nm.
EXAMPLES
The first example shows the usage of list functions:
=======================================================================
#include "cull.h"
f()
{
lList *lp = NULL;
lListElem *ep;
/* add a queue element where QU_qname is "balin.q" to the list lp */
if (!(ep=lAddElemStr(&lp, QU_qname, "balin.q", QU_Type))) {
/* ... */
}
lSetString(ep, QU_qhostname, "balin.mydomain");
/* get the element of lp where QU_qname is "balin.q" */
if (!(ep=lGetElemStr(lp, QU_qname, "balin.q"))) {
/* ... */
}
/* remove the element of lp where QU_qname is "balin.q" */
if (!lDelElemStr(&lp, QU_qname, "balin.q")) {
/* ... */
}
/* here lp will be NULL again */
return;
}
=======================================================================
The second example shows the usage of sub-list functions:
=======================================================================
#include "cull.h"
g(queue)
lListElem *queue;
{
lListElem *ep;
/* add an owner element with OW_name "bill" to the */
/* sub-list QU_ownerlist of the element ep */
ep = lAddSubStr(ep, OW_name, "bill", QU_ownerlist, OW_Type);
if ( !ep ) {
/* ... */
}
lSetString(ep, OW_permissions, "everything");
/* get the element in the sub-list QU_ownerlist of */
/* the element ep where OW_name is "bill" */
if (!(ep=lGetSubStr(ep, OW_name, "bill", QU_ownerlist))) {
/* ... */
}
printf("Owner: %s0, lGetString(ep, OW_name));
/* remove the element in the sub-list of element ep */
/* where OW_name is "bill" */
if (!lDelSubStr(ep, OW_name, "bill", QU_ownerlist)) {
/* ... */
}
return;
}
=======================================================================
RETURN VALUES
<I>lAddElemStr</I> and <I>lAddSubStr</I> return a pointer to the added
list element or NULL on error. <I>lDelElemStr</I> and <I>lDelSubStr</I>
return 1 on success and 0 on error. <I>lGetElemStr</I> and <I>lGet-</I>
<I>SubStr</I> return a pointer to the found list element or NULL on
error. <I>lDiffListStr</I> returns 0 on success and -1 on error.
SEE ALSO
<B><A HREF="../htmlman1/sge_intro.html">sge_intro(1)</A></B>, <B><A HREF="../htmlman3/list_intro.html">list_intro(3)</A></B>, <B><A HREF="../htmlman3/lSetString.html">lSetString(3)</A></B>, <B><A HREF="../htmlman3/lGetString.html">lGetString(3)</A></B>,
<B><A HREF="../htmlman3/lAppendElem.html">lAppendElem(3)</A></B>, <B><A HREF="../htmlman3/lDechainElem.html">lDechainElem(3)</A></B>, <B><A HREF="../htmlman3/lCreateElem.html">lCreateElem(3)</A></B>, <I>lCreateL-</I>
<B><A HREF="../htmlman3/ist.html">ist(3)</A></B>.
COPYRIGHT
See <B><A HREF="../htmlman1/sge_intro.html">sge_intro(1)</A></B> for a full statement of rights and permis-
sions.
</PRE>
<HR>
<ADDRESS>
Man(1) output converted with
<a href="http://www.oac.uci.edu/indiv/ehood/man2html.html">man2html</a>
</ADDRESS>
</BODY>
</HTML>
|