~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/sys/lists/lists.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)List handling. (singly directed)
  2  * @(#)List is { int type; List *next; void *to; }
  3  */
  4 
  5 #include <tina/sys.h>
  6 #include <tina/sysfuncs.h>
  7 extern List *dd_link_alloc(void *ptr, int type);
  8 extern void  dd_ref_set(List * el, void *ptr, int type);
  9 extern List *dd_link_addtostart(List * list, List * el);
 10 extern List *dd_ref_addtostart(List * list, void *ptr, int type);
 11 extern List *dd_list_make(int n, int type);
 12 extern List *dd_get_end(List * list);
 13 extern List *dd_append(List * l1, List * l2);
 14 extern List *dd_link_addtoend(List * end, List * el);
 15 extern List *dd_ref_addtoend(List * end, void *ptr, int type);
 16 extern List *dd_list_addtoend(List * list, List * el);
 17 extern void  dd_link_addafter(List * at, List * el);
 18 extern void  dd_link_rm_next_el(List * at);
 19 extern List *dd_link_rm_el(List * at);
 20 extern void  dd_ref_free(List * at, void (*freefunc) ( /* ??? */ ));
 21 extern void  dd_link_rm_next(List * at, void (*freefunc) ( /* ??? */ )) ;
 22 extern List *dd_link_rm(List * at, void (*freefunc) ( /* ??? */ ));
 23 extern List *dd_list_rm_el(List * list, List * el, void (*freefunc) ( /* ??? */ ));
 24 extern List *dd_list_rm_el(List * list, List * el, void (*freefunc) ( /* ??? */ ));
 25 extern List *dd_list_rm_ref(List * list, void *ptr, void (*freefunc) ( /* ??? */ ));
 26 extern void  dd_list_rm_links(List * list);
 27 extern List *dd_list_rm_links_on_type(List * list, int type);
 28 extern List *dd_list_rm_links_on_func(List * list, Bool(*func) ( /* ??? */ ), void *data);
 29 extern void dd_list_free_refs(List * list, void (*freefunc) ( /* ??? */ ));
 30 extern void dd_list_rm(List * list, void (*freefunc) ( /* ??? */ ));
 31 extern List *dd_link_copy(List * el, void *(*cpfunc) ( /* ??? */ ), void *data);
 32 extern List *dd_list_copy(List * list, void *(*cpfunc) ( /* ??? */ ), void *data);
 33 extern List *dd_list_reverse(List * list);
 34 extern List *dd_list_reversecopy(List * list, void *(*cpfunc) ( /* ??? */ ), void *data);
 35 extern void  dd_apply_func(List * list, void (*func) ( /* ??? */ ), void *data);
 36 extern List *dd_get_min(List * list, Bool(*func) ( /* ??? */ ), void *data);
 37 extern List *dd_link_get_by_ref(List * list, void *ptr);
 38 extern List *dd_link_get_by_type(List * list, int type);
 39 extern List   *dd_list_add_sorted(List * list, List * el, double (*sortfunc) ( /* ??? */ ));
 40 
 41 /* Allocate space for a single list element and set reference to ptr */
 42 List   *link_alloc(void *ptr, int type)
 43 {
 44     return(dd_link_alloc(ptr, type));
 45 }
 46 
 47 /* Set list element reference to ptr */
 48 void    ref_set(List * el, void *ptr, int type)
 49 {
 50     dd_ref_set(el, ptr, type);
 51 }
 52 
 53 /* Make a list of n elements */
 54 List   *list_make(int n, int type)
 55 {
 56     dd_list_make(n, type);
 57 }
 58 
 59 /* Get last element of list */
 60 List   *list_get_end(List * list)
 61 {
 62     return(dd_get_end(list));
 63 }
 64 
 65 /* Append list l2 to l1 */
 66 List   *list_append(List * l1, List * l2)
 67 
 68 {
 69     return(dd_append(l1,l2));
 70 }
 71 
 72 /* Add new element to front of list. Return new front of list */
 73 List   *link_addtostart(List * list, List * el)
 74 {
 75     return(dd_link_addtostart(list, el));
 76 }
 77 
 78 List   *ref_addtostart(List * list, void *ptr, int type)
 79 {
 80     return(dd_ref_addtostart(list,ptr,type));
 81 }
 82 
 83 List   *list_addtostart(List * list, List * el)
 84 /* add new element to front of list */
 85 /* return new front of list */
 86 /* - same as link_addtostart */
 87 {
 88     return(dd_link_addtostart(list, el));
 89 }
 90 
 91 List   *link_addtoend(List * end, List * el)    /* add link to back of
 92                                                  * list */
 93 /* return new back of list */
 94 
 95 {
 96     return(dd_link_addtoend(end, el));
 97 }
 98 
 99 List   *ref_addtoend(List * end, void *ptr, int type)
100 {
101     return(dd_ref_addtoend(end, ptr, type));
102 }
103 
104 List   *list_addtoend(List * list, List * el)   /* add new element to
105                                                  * back of list */
106 /* return new front of list */
107 /* only if list is NULL will front change */
108 {
109     return(dd_list_addtoend(list, el));
110 }
111 
112 void    link_addafter(List * at, List * el)     /* add new element to
113                                                  * list after at */
114 
115 
116 {
117     return(dd_link_addafter(at,el));
118 }
119 
120 void    link_rm_next_el(List * at)      /* rm next element from list */
121 
122 {
123     dd_link_rm_next_el(at);
124 }
125 
126 /* rm element from list, return next element in list, the list will now
127  * be broken */
128 List   *link_rm_el(List * at)
129 {
130     return(dd_link_rm_el(at));
131 }
132 
133 /* Free the reference of this element */
134 void    ref_free(List * at, void (*freefunc) ( /* ??? */ ))
135 {
136     dd_ref_free(at, freefunc);
137 }
138 
139 void    link_rm_next(List * at, void (*freefunc) ( /* ??? */ )) 
140 /* free and rm next
141    element of list */
142 {
143     dd_link_rm_next(at, freefunc);
144 }
145 
146 /* Free and rm this * element from list */
147 List   *link_rm(List * at, void (*freefunc) ( /* ??? */ ))
148 /* return next element in list */
149 /* the list will now be broken */
150 {
151     return(dd_link_rm(at, freefunc));
152 }
153 
154 List   *list_rm_el(List * list, List * el, void (*freefunc) ( /* ??? */ ))
155 /* rm this element from list */
156 /* return new list */
157 /* the list will not be broken */
158 
159 {
160     return(dd_list_rm_el(list, el, freefunc));
161 }
162 
163 /* Rm element from list by reference. Return new list. The list will
164  * not be broken */
165 List   *list_rm_ref(List * list, void *ptr, void (*freefunc) ( /* ??? */ ))
166 {
167     return(dd_list_rm_ref(list, ptr, freefunc));
168 }
169 
170 void    list_rm_links(List * list)      /* rm all elements of list */
171 
172 {
173     dd_list_rm_links(list);
174 }
175 
176 List   *list_rm_links_on_type(List * list, int type)
177 {
178     return(dd_list_rm_links_on_type(list, type));
179 }
180 
181 List   *list_rm_links_on_func(List * list, Bool(*func) ( /* ??? */ ), 
182                               void *data)
183 {
184     return(dd_list_rm_links_on_func(list, func, data));
185 }
186 
187 /* Free all references of list */
188 void    list_free_refs(List * list, void (*freefunc) ( /* ??? */ ))
189 {
190     dd_list_free_refs(list, freefunc);
191 }
192 
193 /* Free and rm all elements of list */
194 void    list_rm(List * list, void (*freefunc) ())
195 {
196     dd_list_rm(list, freefunc);
197 }
198 
199 void    list_list_rm(List * list)
200 {
201     dd_list_rm(list, list_rm_links);
202 }
203 
204 List   *link_copy(List * el, void *(*cpfunc) ( /* ??? */ ), void *data) 
205 /* copy list element */
206 {
207     return(dd_link_copy(el, cpfunc, data));
208 }
209 
210 List   *list_copy(List * list, void *(*cpfunc) ( /* ??? */ ), void *data)       /* copy whole list */
211 {
212     return(dd_list_copy(list, cpfunc, data));
213 }
214 
215 List   *list_reverse(List * list)       /* reverse list */
216 
217 {
218     return(dd_list_reverse(list));
219 }
220 
221 /* Copy list reversed */
222 List   *list_reversecopy(List * list, void *(*cpfunc) ( /* ??? */ ), void *data)
223 {
224     return(dd_list_reversecopy(list, cpfunc, data));
225 }
226 
227 /* Apply function to list */
228 void    list_apply_func(List * list, void (*func) ( /* ??? */ ), void *data)
229 {
230     dd_apply_func(list, func, data);
231 }
232 
233 /* Find min function value */
234 List   *list_get_min(List * list, Bool(*func) ( /* ??? */ ), void *data)
235 {
236     return(dd_get_min(list, func, data));
237 }
238 
239 /* Get list element by reference */
240 List   *link_get_by_ref(List * list, void *ptr)
241 {
242     return(dd_link_get_by_ref(list, ptr));
243 }
244 
245 /* Get first list element of type */
246 List   *link_get_by_type(List * list, int type)
247 {
248     return(dd_link_get_by_type(list, type));
249 }
250 
251 List   *list_add_sorted(List * list, List * el, double (*sortfunc) ( /* ??? */ ))
252 {
253     return(dd_list_add_sorted(list, el, sortfunc));
254 }
255 
256 #ifndef ANSIFYING
257 #ifdef __STRICT_ANSI__
258 
259 
260 List   *list_of(int type,...)
261 {
262     va_list ap;
263     List   *list = NULL;
264 
265     va_start(ap, type);
266 
267     while (type)
268     {
269         void   *ptr = va_arg(ap, void *);
270 
271         list = ref_addtostart(list, ptr, type);
272         type = va_arg(ap, int);
273     }
274     va_end(ap);
275     return (list_reverse(list));
276 }
277 
278 #else
279 
280 List   *list_of(va_alist) va_dcl
281 {
282     va_list ap;
283     List   *list = NULL;
284     int     type;
285 
286     va_start(ap);
287     while ((type = va_arg(ap, int)) != 0)
288     {
289         void   *ptr = va_arg(ap, void *);
290 
291         list = ref_addtostart(list, ptr, type);
292     }
293     va_end(ap);
294     return (list_reverse(list));
295 }
296 
297 #endif                          /* __STRICT_ANSI__ */
298 #endif                          /* ANSIFYING */
299 
300 void   *list_query(List * list, void *(*match_func) ( /* ??? */ ), void *key)
301 {
302     void   *data;
303 
304     for (data = NULL;
305          list && !(data = match_func(key, list->to));
306          list = list->next);
307 
308     return data;
309 }
310 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.