beta-0.89.2
[luatex.git] / source / texk / kpathsea / str-list.h
blob770abbdd3d06ca7b318cebac685f32bab02bf847
1 /* str-list.h: declarations for string lists.
3 Copyright 1993, 1994, 2007, 2008, 2010, 2012 Karl Berry.
4 Copyright 1999, 2005 Olaf Weber.
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with this library; if not, see <http://www.gnu.org/licenses/>. */
19 #ifndef KPATHSEA_STR_LIST_H
20 #define KPATHSEA_STR_LIST_H
22 #include <kpathsea/c-proto.h>
23 #include <kpathsea/types.h>
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
30 /* Lists of strings; used for, e.g., directory lists. */
31 typedef struct
33 unsigned length;
34 string *list;
35 } str_list_type;
37 /* Lists of const strings; used for, e.g., hash tables. */
38 typedef struct
40 unsigned length;
41 const_string *list;
42 } cstr_list_type;
44 #define STR_LIST_LENGTH(l) ((l).length)
45 #define STR_LIST(l) ((l).list)
46 #define STR_LIST_ELT(l, n) STR_LIST (l)[n]
47 #define STR_LIST_LAST_ELT(l) STR_LIST_ELT (l, STR_LIST_LENGTH (l) - 1)
49 #ifdef MAKE_KPSE_DLL /* libkpathsea internal only */
51 /* Return a new, empty, list. */
52 static inline str_list_type
53 str_list_init (void)
55 str_list_type ret;
57 STR_LIST_LENGTH (ret) = 0;
58 STR_LIST (ret) = NULL;
60 return ret;
62 static inline cstr_list_type
63 cstr_list_init (void)
65 cstr_list_type ret;
67 STR_LIST_LENGTH (ret) = 0;
68 STR_LIST (ret) = NULL;
70 return ret;
73 #endif /* MAKE_KPSE_DLL */
75 /* Append the string S to the list L. It's up to the caller to not
76 deallocate S; we don't copy it. Also up to the caller to terminate
77 the list with a null entry. */
78 extern KPSEDLL void str_list_add (str_list_type *l, string s);
79 extern KPSEDLL void cstr_list_add (cstr_list_type *l, const_string s);
81 #ifdef MAKE_KPSE_DLL /* libkpathsea internal only */
83 /* Append all the elements from MORE to TARGET. */
84 extern void str_list_concat (str_list_type * target, str_list_type more);
86 /* Free the space for the list elements (but not the list elements
87 themselves). */
88 extern void str_list_free (str_list_type *l);
90 /* Append each element of MORE to each element of TARGET. */
91 extern void str_list_concat_elements
92 (str_list_type *target, str_list_type more);
94 /* Remove duplicate elements from L, freeing their space. */
95 extern void str_list_uniqify (str_list_type *l);
97 #endif /* MAKE_KPSE_DLL */
99 #ifdef __cplusplus
101 #endif
103 #endif /* not KPATHSEA_STR_LIST_H */