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, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 * lists.h - the LIST structure and routines to manipulate them
20 * The whole of jam relies on lists of strings as a datatype. This
21 * module, in conjunction with newstr.c, handles these relatively
26 * LIST - list of strings
31 * list_append() - append a list onto another one, returning total
32 * list_new() - tack a string onto the end of a list of strings
33 * list_copy() - copy a whole list of strings
34 * list_sublist() - copy a subset of a list of strings
35 * list_free() - free a list of strings
36 * list_print() - print a list of strings to stdout
37 * list_printq() - print a list of safely quoted strings to a file
38 * list_length() - return the number of items in the list
40 * lol_init() - initialize a LOL (list of lists)
41 * lol_add() - append a LIST onto an LOL
42 * lol_free() - free the LOL and its LISTs
43 * lol_get() - return one of the LISTs in the LOL
44 * lol_print() - debug print LISTS separated by ":"
52 /* LIST - list of strings */
53 typedef struct _list LIST
;
56 LIST
*tail
; /* only valid in head node */
57 const char *string
; /* private copy */
61 /* LOL - list of LISTs */
63 typedef struct _lol LOL
;
72 LPFLAG_NO_SPACES
= 0x01,
73 LPFLAG_NO_TRSPACE
= 0x02 /* suppress only trailing space */
76 extern LIST
*list_append (LIST
*l
, LIST
*nl
);
77 extern LIST
*list_copy (LIST
*l
, LIST
*nl
);
78 extern void list_free (LIST
*head
);
79 extern LIST
*list_new (LIST
*head
, const char *string
, int copy
);
80 extern void list_print_ex (FILE *fo
, const LIST
*l
, int flags
); /* LPFLAG_xxx */
81 static inline void list_print (const LIST
*l
) { list_print_ex(stdout
, l
, LPFLAG_DEFAULT
); }
82 extern int list_length (const LIST
*l
) JAMFA_PURE
;
83 extern LIST
*list_sublist (LIST
*l
, int start
, int count
);
84 extern LIST
*list_sort (LIST
*l
);
85 extern LIST
*list_reverse (const LIST
*l
); /* returns new list */
87 extern LIST
*list_removeall (LIST
*l
, LIST
*nl
);
89 #define list_next(l) ((l)->next)
91 #define L0 ((LIST *)0)
93 extern void lol_add (LOL
*lol
, LIST
*l
);
94 extern void lol_init (LOL
*lol
);
95 extern void lol_free (LOL
*lol
);
96 extern LIST
*lol_get (LOL
*lol
, int i
) JAMFA_PURE
;
97 extern void lol_print (const LOL
*lol
);