built-in jambase is packed now
[k8jam.git] / src / lists.h
blobda81b3eb38f69d3bf2984603cd4201524e1a5a04
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
45 /* LIST - list of strings */
46 typedef struct _list LIST;
47 struct _list {
48 LIST *next;
49 LIST *tail; /* only valid in head node */
50 const char *string; /* private copy */
54 /* LOL - list of LISTs */
55 #define LOL_MAX (64)
56 typedef struct _lol LOL;
57 struct _lol {
58 int count;
59 LIST *list[LOL_MAX];
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);
85 #endif