jam0 use passed cflags
[platform/upstream/boost-jam.git] / lists.h
1 /*
2  * Copyright 1993, 1995 Christopher Seiwald.
3  *
4  * This file is part of Jam - see jam.c for Copyright information.
5  */
6
7 /*  This file is ALSO:
8  *  Copyright 2001-2004 David Abrahams.
9  *  Distributed under the Boost Software License, Version 1.0.
10  *  (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
11  */
12
13 /*
14  * lists.h - the LIST structure and routines to manipulate them
15  *
16  * The whole of jam relies on lists of strings as a datatype.  This
17  * module, in conjunction with newstr.c, handles these relatively
18  * efficiently.
19  *
20  * Structures defined:
21  *
22  *  LIST - list of strings
23  *  LOL - list of LISTs
24  *
25  * External routines:
26  *
27  *  list_append() - append a list onto another one, returning total
28  *  list_new() - tack a string onto the end of a list of strings
29  *  list_copy() - copy a whole list of strings
30  *  list_sublist() - copy a subset of a list of strings
31  *  list_free() - free a list of strings
32  *  list_print() - print a list of strings to stdout
33  *  list_length() - return the number of items in the list
34  *
35  *  lol_init() - initialize a LOL (list of lists)
36  *  lol_add() - append a LIST onto an LOL
37  *  lol_free() - free the LOL and its LISTs
38  *  lol_get() - return one of the LISTs in the LOL
39  *  lol_print() - debug print LISTS separated by ":"
40  *
41  * 04/13/94 (seiwald) - added shorthand L0 for null list pointer
42  * 08/23/94 (seiwald) - new list_append()
43  */
44
45 #ifndef LISTS_DWA20011022_H
46 # define LISTS_DWA20011022_H
47
48 #ifdef HAVE_PYTHON
49 #include <Python.h>
50 #endif
51
52 /*
53  * LIST - list of strings
54  */
55
56 typedef struct _list LIST;
57
58 struct _list {
59     LIST    *next;
60     LIST    *tail;      /* only valid in head node */
61     char    *string;    /* private copy */
62 };
63
64 /*
65  * LOL - list of LISTs
66  */
67
68 typedef struct _lol LOL;
69
70 # define LOL_MAX 19
71
72 struct _lol {
73     int count;
74     LIST    *list[ LOL_MAX ];
75 };
76
77 LIST *  list_append( LIST *l, LIST *nl );
78 LIST *  list_copy( LIST *l, LIST  *nl );
79 void    list_free( LIST *head );
80 LIST *  list_new( LIST *head, char *string );
81 void    list_print( LIST *l );
82 int list_length( LIST *l );
83 LIST *  list_sublist( LIST *l, int start, int count );
84 LIST *  list_pop_front( LIST *l );
85 LIST *  list_sort( LIST *l);
86 LIST *  list_unique( LIST *sorted_list);
87 int     list_in(LIST* l, char* value);
88
89 # define list_next( l ) ((l)->next)
90
91 # define L0 ((LIST *)0)
92
93 void    lol_add( LOL *lol, LIST *l );
94 void    lol_init( LOL *lol );
95 void    lol_free( LOL *lol );
96 LIST *  lol_get( LOL *lol, int i );
97 void    lol_print( LOL *lol );
98 void    lol_build( LOL* lol, char** elements );
99
100 #ifdef HAVE_PYTHON
101
102 PyObject *list_to_python(LIST *l);
103 LIST *list_from_python(PyObject *l);
104
105 #endif
106
107 #endif
108