2999
|
1 /* str-llist.h: A linked list of strings, |
|
2 |
|
3 It's pretty disgusting 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 right now. |
|
6 |
|
7 Copyright (C) 1993, 94 Karl Berry. |
|
8 |
|
9 This library is free software; you can redistribute it and/or |
|
10 modify it under the terms of the GNU Library General Public |
|
11 License as published by the Free Software Foundation; either |
|
12 version 2 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 Library General Public License for more details. |
|
18 |
|
19 You should have received a copy of the GNU Library General Public |
|
20 License along with this library; if not, write to the Free Software |
|
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
|
22 |
|
23 #ifndef STR_LLIST_H |
|
24 #define STR_LLIST_H |
|
25 |
|
26 #include <kpathsea/c-proto.h> |
|
27 #include <kpathsea/types.h> |
|
28 |
|
29 |
|
30 /* It's a little bizarre to be using the same type for the list and the |
|
31 elements of the list, but no reason not to in this case, I think -- |
|
32 we never need a NULL string in the middle of the list, and an extra |
|
33 NULL/NULL element always at the end is inconsequential. */ |
|
34 |
|
35 struct str_llist_elt |
|
36 { |
|
37 string str; |
|
38 boolean moved; |
|
39 struct str_llist_elt *next; |
|
40 }; |
|
41 typedef struct str_llist_elt str_llist_elt_type; |
|
42 typedef struct str_llist_elt *str_llist_type; |
|
43 |
|
44 #define STR_LLIST(sl) ((sl).str) |
|
45 #define STR_LLIST_MOVED(sl) ((sl).moved) |
|
46 #define STR_LLIST_NEXT(sl) ((sl).next) |
|
47 |
|
48 |
|
49 /* Add the new string E to the end of the list L. */ |
|
50 extern void str_llist_add P2H(str_llist_type *l, string e); |
|
51 |
|
52 /* Reorganize L so that E is below only other elements that have already |
|
53 been moved. Set `moved' member for E. */ |
|
54 extern void str_llist_float P2H(str_llist_type *l, str_llist_elt_type *e); |
|
55 |
|
56 #endif /* not STR_LLIST_H */ |