using new string modifiers in Jambase
[k8jam.git] / src / lists.h
blob8e647a9ede190fc2b44c5a98021e333753b4b565
1 /*
2 * Copyright 1993, 1995 Christopher Seiwald.
4 * This file is part of Jam - see jam.c for Copyright information.
5 */
6 /*
7 * lists.h - the LIST structure and routines to manipulate them
9 * The whole of jam relies on lists of strings as a datatype. This
10 * module, in conjunction with newstr.c, handles these relatively
11 * efficiently.
13 * Structures defined:
15 * LIST - list of strings
16 * LOL - list of LISTs
18 * External routines:
20 * list_append() - append a list onto another one, returning total
21 * list_new() - tack a string onto the end of a list of strings
22 * list_copy() - copy a whole list of strings
23 * list_sublist() - copy a subset of a list of strings
24 * list_free() - free a list of strings
25 * list_print() - print a list of strings to stdout
26 * list_printq() - print a list of safely quoted strings to a file
27 * list_length() - return the number of items in the list
29 * lol_init() - initialize a LOL (list of lists)
30 * lol_add() - append a LIST onto an LOL
31 * lol_free() - free the LOL and its LISTs
32 * lol_get() - return one of the LISTs in the LOL
33 * lol_print() - debug print LISTS separated by ":"
35 * 04/13/94 (seiwald) - added shorthand L0 for null list pointer
36 * 08/23/94 (seiwald) - new list_append()
37 * 10/22/02 (seiwald) - list_new() now does its own newstr()/copystr()
38 * 11/04/02 (seiwald) - const-ing for string literals
39 * 12/09/02 (seiwald) - new list_printq() for writing lists to Jambase
41 #ifndef JAMH_LISTS_H
42 #define JAMH_LISTS_H
44 #include <stdio.h>
47 /* LIST - list of strings */
48 typedef struct _list LIST;
49 struct _list {
50 LIST *next;
51 LIST *tail; /* only valid in head node */
52 const char *string; /* private copy */
56 /* LOL - list of LISTs */
57 #define LOL_MAX (64)
58 typedef struct _lol LOL;
59 struct _lol {
60 int count;
61 LIST *list[LOL_MAX];
65 enum {
66 LPFLAG_DEFAULT = 0,
67 LPFLAG_NO_SPACES = 0x01,
68 LPFLAG_NO_TRSPACE = 0x02 /* suppress only trailing space */
71 extern LIST *list_append (LIST *l, LIST *nl);
72 extern LIST *list_copy (LIST *l, LIST *nl);
73 extern void list_free (LIST *head);
74 extern LIST *list_new (LIST *head, const char *string, int copy);
75 extern void list_print_ex (FILE *fo, const LIST *l, int flags); /* LPFLAG_xxx */
76 static inline void list_print (const LIST *l) { list_print_ex(stdout, l, LPFLAG_DEFAULT); }
77 extern int list_length (const LIST *l) JAMFA_PURE;
78 extern LIST *list_sublist (LIST *l, int start, int count);
79 extern LIST *list_sort (LIST *l);
81 extern LIST *list_removeall (LIST *l, LIST *nl);
83 #define list_next(l) ((l)->next)
85 #define L0 ((LIST *)0)
87 extern void lol_add (LOL *lol, LIST *l);
88 extern void lol_init (LOL *lol);
89 extern void lol_free (LOL *lol);
90 extern LIST *lol_get (LOL *lol, int i) JAMFA_PURE;
91 extern void lol_print (const LOL *lol);
94 #endif