1/*
2 * Copyright 1993, 1995 Christopher Seiwald.
3 *
4 * This file is part of Jam - see jam.c for Copyright information.
5 */
6
7/*
8 * lists.h - the LIST structure and routines to manipulate them
9 *
10 * The whole of jam relies on lists of strings as a datatype.  This
11 * module, in conjunction with newstr.c, handles these relatively
12 * efficiently.
13 *
14 * Structures defined:
15 *
16 *	LIST - list of strings
17 *	LOL - list of LISTs
18 *
19 * External routines:
20 *
21 *	list_append() - append a list onto another one, returning total
22 *	list_new() - tack a string onto the end of a list of strings
23 * 	list_copy() - copy a whole list of strings
24 *	list_sublist() - copy a subset of a list of strings
25 *	list_free() - free a list of strings
26 *	list_print() - print a list of strings to stdout
27 *	list_printq() - print a list of safely quoted strings to a file
28 *	list_length() - return the number of items in the list
29 *
30 *	lol_init() - initialize a LOL (list of lists)
31 *	lol_add() - append a LIST onto an LOL
32 *	lol_free() - free the LOL and its LISTs
33 *	lol_get() - return one of the LISTs in the LOL
34 *	lol_print() - debug print LISTS separated by ":"
35 *
36 * 04/13/94 (seiwald) - added shorthand L0 for null list pointer
37 * 08/23/94 (seiwald) - new list_append()
38 * 10/22/02 (seiwald) - list_new() now does its own newstr()/copystr()
39 * 11/04/02 (seiwald) - const-ing for string literals
40 * 12/09/02 (seiwald) - new list_printq() for writing lists to Jambase
41 */
42
43/*
44 * LIST - list of strings
45 */
46
47typedef struct _list LIST;
48
49struct _list {
50	LIST		*next;
51	LIST		*tail;		/* only valid in head node */
52	const char	*string;	/* private copy */
53} ;
54
55/*
56 * LOL - list of LISTs
57 */
58
59typedef struct _lol LOL;
60
61# define LOL_MAX 9
62
63struct _lol {
64	int	count;
65	LIST	*list[ LOL_MAX ];
66} ;
67
68LIST *	list_append( LIST *l, LIST *nl );
69LIST *	list_copy( LIST *l, LIST  *nl );
70void	list_free( LIST *head );
71LIST *	list_new( LIST *head, const char *string, int copy );
72void	list_print( LIST *l );
73int	list_length( LIST *l );
74LIST *	list_sublist( LIST *l, int start, int count );
75
76# define list_next( l ) ((l)->next)
77
78# define L0 ((LIST *)0)
79
80void	lol_add( LOL *lol, LIST *l );
81void	lol_init( LOL *lol );
82void	lol_free( LOL *lol );
83LIST *	lol_get( LOL *lol, int i );
84void	lol_print( LOL *lol );
85