| 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, 2014 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/simpletypes.h> |
| 27 |
|
| 28 |
#ifdef __cplusplus |
| 29 |
extern "C" { |
| 30 |
#endif |
| 31 |
|
| 32 |
/* It's a little bizarre to be using the same type for the list and the |
| 33 |
elements of the list, but no reason not to in this case, I think -- |
| 34 |
we never need a NULL string in the middle of the list, and an extra |
| 35 |
NULL/NULL element always at the end is inconsequential. */ |
| 36 |
|
| 37 |
struct str_llist_elt |
| 38 |
{ |
| 39 |
string str; |
| 40 |
boolean moved; |
| 41 |
struct str_llist_elt *next; |
| 42 |
}; |
| 43 |
typedef struct str_llist_elt str_llist_elt_type; |
| 44 |
typedef struct str_llist_elt *str_llist_type; |
| 45 |
|
| 46 |
#define STR_LLIST(sl) ((sl).str) |
| 47 |
#define STR_LLIST_MOVED(sl) ((sl).moved) |
| 48 |
#define STR_LLIST_NEXT(sl) ((sl).next) |
| 49 |
|
| 50 |
#ifdef MAKE_KPSE_DLL /* libkpathsea internal only */ |
| 51 |
|
| 52 |
/* Add the new string E to the end of the list L. */ |
| 53 |
extern void str_llist_add (str_llist_type *l, string e); |
| 54 |
|
| 55 |
/* Reorganize L so that E is below only other elements that have already |
| 56 |
been moved. Set `moved' member for E. */ |
| 57 |
extern void str_llist_float (str_llist_type *l, str_llist_elt_type *e); |
| 58 |
|
| 59 |
#endif /* MAKE_KPSE_DLL */ |
| 60 |
|
| 61 |
#ifdef __cplusplus |
| 62 |
} |
| 63 |
#endif |
| 64 |
|
| 65 |
#endif /* not STR_LLIST_H */ |