00001 #ifndef LIST_H_INCLUDED 00002 #define LIST_H_INCLUDED 00003 #define LIST_H_VERSION "$Id: list.h,v 2.0 2002/06/04 14:34:21 jongfoster Exp $" 00004 /* ****************************************************************** 00005 * $Source: /cvsroot/ijbswa/current/src/list.h,v $ 00006 * ****************************************************************** 00007 * 00008 * Written by and Copyright (C) 2001 the SourceForge 00009 * Privoxy team. http://www.privoxy.org/ 00010 * 00011 * Based on the Internet Junkbuster originally written 00012 * by and Copyright (C) 1997 Anonymous Coders and 00013 * Junkbusters Corporation. http://www.junkbusters.com 00014 * 00015 * This program is free software; you can redistribute it 00016 * and/or modify it under the terms of the GNU General 00017 * Public License as published by the Free Software 00018 * Foundation; either version 2 of the License, or (at 00019 * your option) any later version. 00020 * 00021 * This program is distributed in the hope that it will 00022 * be useful, but WITHOUT ANY WARRANTY; without even the 00023 * implied warranty of MERCHANTABILITY or FITNESS FOR A 00024 * PARTICULAR PURPOSE. See the GNU General Public 00025 * License for more details. 00026 * 00027 * The GNU General Public License should be included with 00028 * this file. If not, you can view it at 00029 * http://www.gnu.org/copyleft/gpl.html 00030 * or write to the Free Software Foundation, Inc., 59 00031 * Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00032 * 00033 * *****************************************************************/ 00034 /** 00035 * @file 00036 * 00037 * Declares functions to handle lists. 00038 * Functions declared include: 00039 * `destroy_list', `enlist' and `list_to_text' 00040 * 00041 * 00042 * $Log: list.h,v $ 00043 * Revision 2.0 2002/06/04 14:34:21 jongfoster 00044 * Moving source files to src/ 00045 * 00046 * Revision 1.12 2002/03/26 22:29:55 swa 00047 * we have a new homepage! 00048 * 00049 * Revision 1.11 2002/03/24 13:25:43 swa 00050 * name change related issues 00051 * 00052 * Revision 1.10 2002/03/07 03:46:17 oes 00053 * Fixed compiler warnings 00054 * 00055 * Revision 1.9 2001/10/23 21:21:03 jongfoster 00056 * New error handling - error codes are now jb_errs, not ints. 00057 * Changed the way map() handles out-of-memory, to dramatically 00058 * reduce the amount of error-checking clutter needed. 00059 * 00060 * Revision 1.8 2001/09/16 17:30:24 jongfoster 00061 * Fixing a compiler warning. 00062 * 00063 * Revision 1.7 2001/09/16 13:20:29 jongfoster 00064 * Rewrite of list library. Now has seperate header and list_entry 00065 * structures. Also added a large sprinking of assert()s to the list 00066 * code. 00067 * 00068 * Revision 1.6 2001/08/05 16:06:20 jongfoster 00069 * Modifiying "struct map" so that there are now separate header and 00070 * "map_entry" structures. This means that functions which modify a 00071 * map no longer need to return a pointer to the modified map. 00072 * Also, it no longer reverses the order of the entries (which may be 00073 * important with some advanced template substitutions). 00074 * 00075 * Revision 1.5 2001/07/29 18:43:08 jongfoster 00076 * Changing #ifdef _FILENAME_H to FILENAME_H_INCLUDED, to conform to 00077 * ANSI C rules. 00078 * 00079 * Revision 1.4 2001/06/29 13:30:37 oes 00080 * - Introduced enlist_unique_header() 00081 * - Removed logentry from cancelled commit 00082 * 00083 * Revision 1.3 2001/06/03 11:03:48 oes 00084 * introduced functions for new list type "map": map(), lookup(), 00085 * free_map(), and extended enlist_unique 00086 * 00087 * Revision 1.2 2001/06/01 18:49:17 jongfoster 00088 * Replaced "list_share" with "list" - the tiny memory gain was not 00089 * worth the extra complexity. 00090 * 00091 * Revision 1.1 2001/05/31 21:11:53 jongfoster 00092 * - Moved linked list support to new "list.c" file. 00093 * Structure definitions are still in project.h, 00094 * function prototypes are now in "list.h". 00095 * - Added support for "struct list_share", which is identical 00096 * to "struct list" except it saves memory by not duplicating 00097 * the strings. Obviously, this only works if there is some 00098 * other way of managing the memory used by the strings. 00099 * (These list_share lists are used for lists which last 00100 * for only 1 request, and where all the list entries are 00101 * just coming directly from entries in the actionsfile.) 00102 * Note that you still need to destroy list_share lists 00103 * properly to free the nodes - it's only the strings 00104 * which are shared. 00105 * 00106 * 00107 */ 00108 /* *****************************************************************/ 00109 00110 00111 #include "project.h" 00112 00113 #ifdef __cplusplus 00114 extern "C" { 00115 #endif 00116 00117 00118 /* 00119 * struct list 00120 * 00121 * A linked list class. 00122 */ 00123 00124 extern void init_list (struct list *the_list); 00125 extern void destroy_list (struct list *the_list); 00126 00127 extern jb_err enlist (struct list *the_list, const char *str); 00128 extern jb_err enlist_unique (struct list *the_list, const char *str, size_t num_significant_chars); 00129 extern jb_err enlist_unique_header (struct list *the_list, const char *name, const char *value); 00130 extern jb_err enlist_first (struct list *the_list, const char *str); 00131 extern jb_err list_append_list_unique(struct list *dest, const struct list *src); 00132 extern jb_err list_duplicate (struct list *dest, const struct list *src); 00133 00134 extern int list_remove_item(struct list *the_list, const char *str); 00135 extern int list_remove_list(struct list *dest, const struct list *src); 00136 extern void list_remove_all (struct list *the_list); 00137 00138 extern int list_is_empty(const struct list *the_list); 00139 00140 extern char * list_to_text(const struct list *the_list); 00141 00142 00143 /* 00144 * struct map 00145 * 00146 * A class which maps names to values. 00147 * 00148 * Note: You must allocate this through new_map() and free it 00149 * through free_map(). 00150 */ 00151 00152 extern struct map * new_map (void); 00153 extern void free_map (struct map * the_map); 00154 00155 extern int map (struct map * the_map, 00156 const char * name, int name_needs_copying, 00157 const char * value, int value_needs_copying); 00158 extern const char * lookup (const struct map * the_map, const char * name); 00159 00160 00161 /* Revision control strings from this header and associated .c file */ 00162 00163 /** Version information about list.c. */ 00164 extern const char list_rcs[]; 00165 00166 /** Version information about list.h. */ 00167 extern const char list_h_rcs[]; 00168 00169 #ifdef __cplusplus 00170 } /* extern "C" */ 00171 #endif 00172 00173 #endif /* ndef LIST_H_INCLUDED */ 00174 00175 /* 00176 Local Variables: 00177 tab-width: 3 00178 end: 00179 */