Adding a (void*) cast to freez() because Visual Age C++ won't expand the
[privoxy.git] / list.h
1 #ifndef LIST_H_INCLUDED
2 #define LIST_H_INCLUDED
3 #define LIST_H_VERSION "$Id: list.h,v 1.8 2001/09/16 17:30:24 jongfoster Exp $"
4 /*********************************************************************
5  *
6  * File        :  $Source: /cvsroot/ijbswa/current/list.h,v $
7  *
8  * Purpose     :  Declares functions to handle lists.
9  *                Functions declared include:
10  *                   `destroy_list', `enlist' and `list_to_text'
11  *
12  * Copyright   :  Written by and Copyright (C) 2001 the SourceForge
13  *                IJBSWA team.  http://ijbswa.sourceforge.net
14  *
15  *                Based on the Internet Junkbuster originally written
16  *                by and Copyright (C) 1997 Anonymous Coders and 
17  *                Junkbusters Corporation.  http://www.junkbusters.com
18  *
19  *                This program is free software; you can redistribute it 
20  *                and/or modify it under the terms of the GNU General
21  *                Public License as published by the Free Software
22  *                Foundation; either version 2 of the License, or (at
23  *                your option) any later version.
24  *
25  *                This program is distributed in the hope that it will
26  *                be useful, but WITHOUT ANY WARRANTY; without even the
27  *                implied warranty of MERCHANTABILITY or FITNESS FOR A
28  *                PARTICULAR PURPOSE.  See the GNU General Public
29  *                License for more details.
30  *
31  *                The GNU General Public License should be included with
32  *                this file.  If not, you can view it at
33  *                http://www.gnu.org/copyleft/gpl.html
34  *                or write to the Free Software Foundation, Inc., 59
35  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
36  *
37  * Revisions   :
38  *    $Log: list.h,v $
39  *    Revision 1.8  2001/09/16 17:30:24  jongfoster
40  *    Fixing a compiler warning.
41  *
42  *    Revision 1.7  2001/09/16 13:20:29  jongfoster
43  *    Rewrite of list library.  Now has seperate header and list_entry
44  *    structures.  Also added a large sprinking of assert()s to the list
45  *    code.
46  *
47  *    Revision 1.6  2001/08/05 16:06:20  jongfoster
48  *    Modifiying "struct map" so that there are now separate header and
49  *    "map_entry" structures.  This means that functions which modify a
50  *    map no longer need to return a pointer to the modified map.
51  *    Also, it no longer reverses the order of the entries (which may be
52  *    important with some advanced template substitutions).
53  *
54  *    Revision 1.5  2001/07/29 18:43:08  jongfoster
55  *    Changing #ifdef _FILENAME_H to FILENAME_H_INCLUDED, to conform to
56  *    ANSI C rules.
57  *
58  *    Revision 1.4  2001/06/29 13:30:37  oes
59  *    - Introduced enlist_unique_header()
60  *    - Removed logentry from cancelled commit
61  *
62  *    Revision 1.3  2001/06/03 11:03:48  oes
63  *    introduced functions for new list type "map": map(), lookup(),
64  *    free_map(), and extended enlist_unique
65  *
66  *    Revision 1.2  2001/06/01 18:49:17  jongfoster
67  *    Replaced "list_share" with "list" - the tiny memory gain was not
68  *    worth the extra complexity.
69  *
70  *    Revision 1.1  2001/05/31 21:11:53  jongfoster
71  *    - Moved linked list support to new "list.c" file.
72  *      Structure definitions are still in project.h,
73  *      function prototypes are now in "list.h".
74  *    - Added support for "struct list_share", which is identical
75  *      to "struct list" except it saves memory by not duplicating
76  *      the strings.  Obviously, this only works if there is some
77  *      other way of managing the memory used by the strings.
78  *      (These list_share lists are used for lists which last
79  *      for only 1 request, and where all the list entries are
80  *      just coming directly from entries in the actionsfile.)
81  *      Note that you still need to destroy list_share lists
82  *      properly to free the nodes - it's only the strings
83  *      which are shared.
84  *
85  *
86  *********************************************************************/
87 \f
88
89 #include "project.h"
90
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94
95
96 /*
97  * struct list
98  *
99  * A linked list class.
100  */
101
102 extern void init_list    (struct list *the_list);
103 extern void destroy_list (struct list *the_list);
104
105 extern jb_err enlist                 (struct list *the_list, const char *str);
106 extern jb_err enlist_unique          (struct list *the_list, const char *str, int num_significant_chars);
107 extern jb_err enlist_unique_header   (struct list *the_list, const char *name, const char *value);
108 extern jb_err enlist_first           (struct list *the_list, const char *str);
109 extern jb_err list_append_list_unique(struct list *dest,     const struct list *src);
110 extern jb_err list_duplicate         (struct list *dest,     const struct list *src);
111
112 extern int    list_remove_item(struct list *the_list, const char *str);
113 extern int    list_remove_list(struct list *dest,     const struct list *src);
114 extern void   list_remove_all (struct list *the_list);
115
116 extern int    list_is_empty(const struct list *the_list);
117
118 extern char * list_to_text(const struct list *the_list);
119
120
121 /*
122  * struct map
123  *
124  * A class which maps names to values.
125  *
126  * Note: You must allocate this through new_map() and free it
127  * through free_map().
128  */
129
130 extern struct map * new_map  (void);
131 extern void         free_map (struct map * the_map);
132
133 extern int          map      (struct map * the_map,
134                               const char * name, int name_needs_copying,
135                               const char * value, int value_needs_copying);
136 extern const char * lookup   (const struct map * the_map, const char * name);
137
138
139 /* Revision control strings from this header and associated .c file */
140 extern const char list_rcs[];
141 extern const char list_h_rcs[];
142
143 #ifdef __cplusplus
144 } /* extern "C" */
145 #endif
146
147 #endif /* ndef LIST_H_INCLUDED */
148
149 /*
150   Local Variables:
151   tab-width: 3
152   end:
153 */