Hide edit buttons on the show-url-info CGI page if enable-edit-action
[privoxy.git] / list.h
1 #ifndef LIST_H_INCLUDED
2 #define LIST_H_INCLUDED
3 #define LIST_H_VERSION "$Id: list.h,v 1.14 2006/07/18 14:48:46 david__schmidt 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-2007 the SourceForge
13  *                Privoxy team. http://www.privoxy.org/
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.14  2006/07/18 14:48:46  david__schmidt
40  *    Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
41  *    with what was really the latest development (the v_3_0_branch branch)
42  *
43  *    Revision 1.12.2.1  2002/11/28 18:14:54  oes
44  *    Added unmap function that removes all items with a given
45  *    name from a map.
46  *
47  *    Revision 1.12  2002/03/26 22:29:55  swa
48  *    we have a new homepage!
49  *
50  *    Revision 1.11  2002/03/24 13:25:43  swa
51  *    name change related issues
52  *
53  *    Revision 1.10  2002/03/07 03:46:17  oes
54  *    Fixed compiler warnings
55  *
56  *    Revision 1.9  2001/10/23 21:21:03  jongfoster
57  *    New error handling - error codes are now jb_errs, not ints.
58  *    Changed the way map() handles out-of-memory, to dramatically
59  *    reduce the amount of error-checking clutter needed.
60  *
61  *    Revision 1.8  2001/09/16 17:30:24  jongfoster
62  *    Fixing a compiler warning.
63  *
64  *    Revision 1.7  2001/09/16 13:20:29  jongfoster
65  *    Rewrite of list library.  Now has seperate header and list_entry
66  *    structures.  Also added a large sprinking of assert()s to the list
67  *    code.
68  *
69  *    Revision 1.6  2001/08/05 16:06:20  jongfoster
70  *    Modifiying "struct map" so that there are now separate header and
71  *    "map_entry" structures.  This means that functions which modify a
72  *    map no longer need to return a pointer to the modified map.
73  *    Also, it no longer reverses the order of the entries (which may be
74  *    important with some advanced template substitutions).
75  *
76  *    Revision 1.5  2001/07/29 18:43:08  jongfoster
77  *    Changing #ifdef _FILENAME_H to FILENAME_H_INCLUDED, to conform to
78  *    ANSI C rules.
79  *
80  *    Revision 1.4  2001/06/29 13:30:37  oes
81  *    - Introduced enlist_unique_header()
82  *    - Removed logentry from cancelled commit
83  *
84  *    Revision 1.3  2001/06/03 11:03:48  oes
85  *    introduced functions for new list type "map": map(), lookup(),
86  *    free_map(), and extended enlist_unique
87  *
88  *    Revision 1.2  2001/06/01 18:49:17  jongfoster
89  *    Replaced "list_share" with "list" - the tiny memory gain was not
90  *    worth the extra complexity.
91  *
92  *    Revision 1.1  2001/05/31 21:11:53  jongfoster
93  *    - Moved linked list support to new "list.c" file.
94  *      Structure definitions are still in project.h,
95  *      function prototypes are now in "list.h".
96  *    - Added support for "struct list_share", which is identical
97  *      to "struct list" except it saves memory by not duplicating
98  *      the strings.  Obviously, this only works if there is some
99  *      other way of managing the memory used by the strings.
100  *      (These list_share lists are used for lists which last
101  *      for only 1 request, and where all the list entries are
102  *      just coming directly from entries in the actionsfile.)
103  *      Note that you still need to destroy list_share lists
104  *      properly to free the nodes - it's only the strings
105  *      which are shared.
106  *
107  *
108  *********************************************************************/
109 \f
110
111 #include "project.h"
112
113 #ifdef __cplusplus
114 extern "C" {
115 #endif
116
117
118 /*
119  * struct list
120  *
121  * A linked list class.
122  */
123
124 extern void init_list    (struct list *the_list);
125 extern void destroy_list (struct list *the_list);
126
127 extern jb_err enlist                 (struct list *the_list, const char *str);
128 extern jb_err enlist_unique          (struct list *the_list, const char *str, size_t num_significant_chars);
129 extern jb_err enlist_unique_header   (struct list *the_list, const char *name, const char *value);
130 extern jb_err enlist_first           (struct list *the_list, const char *str);
131 extern jb_err list_append_list_unique(struct list *dest,     const struct list *src);
132 extern jb_err list_duplicate         (struct list *dest,     const struct list *src);
133
134 extern int    list_remove_item(struct list *the_list, const char *str);
135 extern int    list_remove_list(struct list *dest,     const struct list *src);
136 extern void   list_remove_all (struct list *the_list);
137
138 extern int    list_is_empty(const struct list *the_list);
139
140 extern char * list_to_text(const struct list *the_list);
141
142 extern int    list_contains_item(const struct list *the_list, const char *str);
143
144 /*
145  * struct map
146  *
147  * A class which maps names to values.
148  *
149  * Note: You must allocate this through new_map() and free it
150  * through free_map().
151  */
152
153 extern struct map * new_map  (void);
154 extern void         free_map (struct map * the_map);
155
156 extern jb_err       map      (struct map * the_map,
157                               const char * name, int name_needs_copying,
158                               const char * value, int value_needs_copying);
159 extern jb_err       unmap    (struct map *the_map,
160                               const char *name);
161 extern const char * lookup   (const struct map * the_map, const char * name);
162
163
164 /* Revision control strings from this header and associated .c file */
165 extern const char list_rcs[];
166 extern const char list_h_rcs[];
167
168 #ifdef __cplusplus
169 } /* extern "C" */
170 #endif
171
172 #endif /* ndef LIST_H_INCLUDED */
173
174 /*
175   Local Variables:
176   tab-width: 3
177   end:
178 */