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>
30 /* Lists of strings; used for, e.g., directory lists. */
37 /* Lists of const strings; used for, e.g., hash tables. */
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
57 STR_LIST_LENGTH (ret) = 0;
58 STR_LIST (ret) = NULL;
62 static inline cstr_list_type
67 STR_LIST_LENGTH (ret) = 0;
68 STR_LIST (ret) = NULL;
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
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 */
103 #endif /* not KPATHSEA_STR_LIST_H */