2 * Copyright 1993, 1995 Christopher Seiwald.
3 * This file is part of Jam - see jam.c for Copyright information.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * lists.h - the LIST structure and routines to manipulate them
21 * The whole of jam relies on lists of strings as a datatype. This
22 * module, in conjunction with newstr.c, handles these relatively
27 * LIST - list of strings
32 * list_append() - append a list onto another one, returning total
33 * list_new() - tack a string onto the end of a list of strings
34 * list_copy() - copy a whole list of strings
35 * list_sublist() - copy a subset of a list of strings
36 * list_free() - free a list of strings
37 * list_print() - print a list of strings to stdout
38 * list_printq() - print a list of safely quoted strings to a file
39 * list_length() - return the number of items in the list
41 * lol_init() - initialize a LOL (list of lists)
42 * lol_add() - append a LIST onto an LOL
43 * lol_free() - free the LOL and its LISTs
44 * lol_get() - return one of the LISTs in the LOL
45 * lol_print() - debug print LISTS separated by ":"
53 /* LIST - list of strings */
54 typedef struct _list LIST
;
57 LIST
*tail
; /* only valid in head node */
58 const char *string
; /* private copy */
62 /* LOL - list of LISTs */
64 typedef struct _lol LOL
;
73 LPFLAG_NO_SPACES
= 0x01,
74 LPFLAG_NO_TRSPACE
= 0x02 /* suppress only trailing space */
77 extern LIST
*list_append (LIST
*l
, LIST
*nl
);
78 extern LIST
*list_copy (LIST
*l
, LIST
*nl
);
79 extern void list_free (LIST
*head
);
80 extern LIST
*list_new (LIST
*head
, const char *string
, int copy
);
81 extern void list_print_ex (FILE *fo
, const LIST
*l
, int flags
); /* LPFLAG_xxx */
82 static inline void list_print (const LIST
*l
) { list_print_ex(stdout
, l
, LPFLAG_DEFAULT
); }
83 extern int list_length (const LIST
*l
) JAMFA_PURE
;
84 extern LIST
*list_sublist (LIST
*l
, int start
, int count
);
85 extern LIST
*list_sort (LIST
*l
);
86 extern LIST
*list_reverse (const LIST
*l
); /* returns new list */
88 extern LIST
*list_removeall (LIST
*l
, LIST
*nl
);
90 #define list_next(l) ((l)->next)
92 #define L0 ((LIST *)0)
94 extern void lol_add (LOL
*lol
, LIST
*l
);
95 extern void lol_init (LOL
*lol
);
96 extern void lol_free (LOL
*lol
);
97 extern LIST
*lol_get (LOL
*lol
, int i
) JAMFA_PURE
;
98 extern void lol_print (const LOL
*lol
);