Annotation of parser3/src/lib/ltdl/libltdl/slist.h, revision 1.2
1.1 moko 1: /* slist.h -- generalised singly linked lists
2:
1.2 ! moko 3: Copyright (C) 2000, 2004, 2009, 2011-2019, 2021-2024 Free Software
! 4: Foundation, Inc.
1.1 moko 5: Written by Gary V. Vaughan, 2000
6:
7: NOTE: The canonical source of this file is maintained with the
8: GNU Libtool package. Report bugs to bug-libtool@gnu.org.
9:
10: GNU Libltdl is free software; you can redistribute it and/or
11: modify it under the terms of the GNU Lesser General Public
12: License as published by the Free Software Foundation; either
13: version 2 of the License, or (at your option) any later version.
14:
15: As a special exception to the GNU Lesser General Public License,
16: if you distribute this file as part of a program or library that
17: is built using GNU Libtool, you may include this file under the
18: same distribution terms that you use for the rest of that program.
19:
20: GNU Libltdl is distributed in the hope that it will be useful,
21: but WITHOUT ANY WARRANTY; without even the implied warranty of
22: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23: GNU Lesser General Public License for more details.
24:
25: You should have received a copy of the GNU Lesser General Public
1.2 ! moko 26: License along with GNU Libltdl. If not, see <https://www.gnu.org/licenses/>.
1.1 moko 27: */
28:
29: /* A generalised list. This is deliberately transparent so that you
30: can make the NEXT field of all your chained data structures first,
1.2 ! moko 31: and then cast them to '(SList *)' so that they can be manipulated
1.1 moko 32: by this API.
33:
34: Alternatively, you can generate raw SList elements using slist_new(),
35: and put the element data in the USERDATA field. Either way you
36: get to manage the memory involved by yourself.
37: */
38:
1.2 ! moko 39: #if !defined SLIST_H
1.1 moko 40: #define SLIST_H 1
41:
1.2 ! moko 42: #if defined LTDL
1.1 moko 43: # include <libltdl/lt__glibc.h>
44: # include <libltdl/lt_system.h>
45: #else
46: # define LT_SCOPE
47: #endif
48:
49: #include <stddef.h>
50:
1.2 ! moko 51: #if defined __cplusplus
1.1 moko 52: extern "C" {
53: #endif
54:
55: typedef struct slist {
56: struct slist *next; /* chain forward pointer*/
1.2 ! moko 57: const void *userdata; /* for boxed 'SList' item */
1.1 moko 58: } SList;
59:
60: typedef void * SListCallback (SList *item, void *userdata);
61: typedef int SListCompare (const SList *item1, const SList *item2,
62: void *userdata);
63:
64: LT_SCOPE SList *slist_concat (SList *head, SList *tail);
65: LT_SCOPE SList *slist_cons (SList *item, SList *slist);
66:
67: LT_SCOPE SList *slist_delete (SList *slist, void (*delete_fct) (void *item));
68: LT_SCOPE SList *slist_remove (SList **phead, SListCallback *find,
69: void *matchdata);
70: LT_SCOPE SList *slist_reverse (SList *slist);
71: LT_SCOPE SList *slist_sort (SList *slist, SListCompare *compare,
72: void *userdata);
73:
74: LT_SCOPE SList *slist_tail (SList *slist);
75: LT_SCOPE SList *slist_nth (SList *slist, size_t n);
76: LT_SCOPE void * slist_find (SList *slist, SListCallback *find,
77: void *matchdata);
78: LT_SCOPE size_t slist_length (SList *slist);
79:
80: LT_SCOPE void * slist_foreach (SList *slist, SListCallback *foreach,
81: void *userdata);
82:
83: LT_SCOPE SList *slist_box (const void *userdata);
84: LT_SCOPE void * slist_unbox (SList *item);
85:
1.2 ! moko 86: #if defined __cplusplus
1.1 moko 87: }
88: #endif
89:
1.2 ! moko 90: #if !defined LTDL
1.1 moko 91: # undef LT_SCOPE
92: #endif
93:
1.2 ! moko 94: #endif /*!defined SLIST_H*/
E-mail: