00001 /* 00002 * Copyright 1993, 1995 Christopher Seiwald. 00003 * 00004 * This file is part of Jam - see jam.c for Copyright information. 00005 */ 00006 00007 /* 00008 * lists.h - the LIST structure and routines to manipulate them 00009 * 00010 * The whole of jam relies on lists of strings as a datatype. This 00011 * module, in conjunction with newstr.c, handles these relatively 00012 * efficiently. 00013 * 00014 * Structures defined: 00015 * 00016 * LIST - list of strings 00017 * LOL - list of LISTs 00018 * 00019 * External routines: 00020 * 00021 * list_new() - tack a string onto the end of a list of strings 00022 * list_copy() - copy a whole list of strings 00023 * list_append() - append a list onto another one, returning total 00024 * list_sublist() - copy a subset of a list of strings 00025 * list_free() - free a list of strings 00026 * list_print() - print a list of strings to stdout 00027 * list_printq() - print a list of safely quoted strings to a file 00028 * list_length() - return the number of items in the list 00029 * 00030 * lol_init() - initialize a LOL (list of lists) 00031 * lol_add() - append a LIST onto an LOL 00032 * lol_free() - free the LOL and its LISTs 00033 * lol_get() - return one of the LISTs in the LOL 00034 * lol_print() - debug print LISTS separated by ":" 00035 * 00036 * Changes: 00037 * 00038 * 12/09/02 (seiwald) - new list_printq() for writing lists to Jambase 00039 * 11/04/02 (seiwald) - const-ing for string literals 00040 * 10/22/02 (seiwald) - list_new() now does its own newstr()/copystr() 00041 * 08/23/94 (seiwald) - new list_append() 00042 * 04/13/94 (seiwald) - added shorthand L0 for null list pointer 00043 */ 00044 00045 /* 00046 * LIST - list of strings 00047 */ 00048 00049 typedef struct _list LIST; 00050 00051 struct _list { 00052 LIST *next; 00053 LIST *tail; /* only valid in head node */ 00054 const char *string; /* private copy */ 00055 } ; 00056 00057 /* 00058 * LOL - list of LISTs 00059 */ 00060 00061 typedef struct _lol LOL; 00062 00063 # define LOL_MAX 9 00064 00065 struct _lol { 00066 int count; 00067 LIST *list[ LOL_MAX ]; 00068 } ; 00069 00070 LIST * list_append( LIST *l, LIST *nl ); 00071 LIST * list_copy( LIST *l, LIST *nl ); 00072 void list_free( LIST *head ); 00073 LIST * list_new( LIST *head, const char *string, int copy ); 00074 void list_print( LIST *l ); 00075 int list_length( LIST *l ); 00076 LIST * list_sublist( LIST *l, int start, int count ); 00077 00078 # define list_next( l ) ((l)->next) 00079 00080 # define L0 ((LIST *)0) 00081 00082 void lol_add( LOL *lol, LIST *l ); 00083 void lol_init( LOL *lol ); 00084 void lol_free( LOL *lol ); 00085 LIST * lol_get( LOL *lol, int i ); 00086 void lol_print( LOL *lol );