OSDN Git Service

branch: yandytex with kpathsea.
[putex/putex.git] / src / texsourc / kpathsea / kpathsea / str-llist.h
1 /* str-llist.h: a linked list of strings,
2
3    It's pretty sad that both this and str-list exist; the reason is
4    that C cannot express iterators very well, and I don't want to change
5    all the for loops.
6
7    Copyright 1993, 1994, 2008, 2010 Karl Berry.
8
9    This library is free software; you can redistribute it and/or
10    modify it under the terms of the GNU Lesser General Public
11    License as published by the Free Software Foundation; either
12    version 2.1 of the License, or (at your option) any later version.
13
14    This library is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17    Lesser General Public License for more details.
18
19    You should have received a copy of the GNU Lesser General Public License
20    along with this library; if not, see <http://www.gnu.org/licenses/>.  */
21
22 #ifndef STR_LLIST_H
23 #define STR_LLIST_H
24
25 #include <kpathsea/c-proto.h>
26 #include <kpathsea/types.h>
27
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 /* It's a little bizarre to be using the same type for the list and the
34    elements of the list, but no reason not to in this case, I think --
35    we never need a NULL string in the middle of the list, and an extra
36    NULL/NULL element always at the end is inconsequential.  */
37
38 struct str_llist_elt
39 {
40   string str;
41   boolean moved;
42   struct str_llist_elt *next;
43 };
44 typedef struct str_llist_elt str_llist_elt_type;
45 typedef struct str_llist_elt *str_llist_type;
46
47 #define STR_LLIST(sl) ((sl).str)
48 #define STR_LLIST_MOVED(sl) ((sl).moved)
49 #define STR_LLIST_NEXT(sl) ((sl).next)
50
51 #ifdef MAKE_KPSE_DLL /* libkpathsea internal only */
52
53 /* Add the new string E to the end of the list L.  */
54 extern void str_llist_add (str_llist_type *l, string e);
55
56 /* Reorganize L so that E is below only other elements that have already
57    been moved.  Set `moved' member for E.  */
58 extern void str_llist_float (str_llist_type *l, str_llist_elt_type *e);
59
60 #endif /* MAKE_KPSE_DLL */
61
62 #ifdef __cplusplus
63 }
64 #endif
65
66 #endif /* not STR_LLIST_H */