2 * Copyright 1993, 1995 Christopher Seiwald.
4 * This file is part of Jam - see jam.c for Copyright information.
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
15 * LIST - list of strings
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
45 /* LIST - list of strings */
46 typedef struct _list LIST
;
49 LIST
*tail
; /* only valid in head node */
50 const char *string
; /* private copy */
54 /* LOL - list of LISTs */
56 typedef struct _lol LOL
;
63 extern LIST
*list_append (LIST
*l
, LIST
*nl
);
64 extern LIST
*list_copy (LIST
*l
, LIST
*nl
);
65 extern void list_free (LIST
*head
);
66 extern LIST
*list_new (LIST
*head
, const char *string
, int copy
);
67 extern void list_print (LIST
*l
);
68 extern int list_length (LIST
*l
) JAMFA_PURE
;
69 extern LIST
*list_sublist (LIST
*l
, int start
, int count
);
70 extern LIST
*list_sort (LIST
*l
);
72 extern LIST
*list_removeall (LIST
*l
, LIST
*nl
);
74 #define list_next(l) ((l)->next)
76 #define L0 ((LIST *)0)
78 extern void lol_add (LOL
*lol
, LIST
*l
);
79 extern void lol_init (LOL
*lol
);
80 extern void lol_free (LOL
*lol
);
81 extern LIST
*lol_get (LOL
*lol
, int i
) JAMFA_PURE
;
82 extern void lol_print (LOL
*lol
);