- Fixed add_help_link to link to the (now split) actions
[privoxy.git] / loaders.h
1 #ifndef LOADERS_H_INCLUDED
2 #define LOADERS_H_INCLUDED
3 #define LOADERS_H_VERSION "$Id: loaders.h,v 1.18 2002/03/24 13:25:43 swa Exp $"
4 /*********************************************************************
5  *
6  * File        :  $Source: /cvsroot/ijbswa/current/loaders.h,v $
7  *
8  * Purpose     :  Functions to load and unload the various
9  *                configuration files.  Also contains code to manage
10  *                the list of active loaders, and to automatically 
11  *                unload files that are no longer in use.
12  *
13  * Copyright   :  Written by and Copyright (C) 2001 the SourceForge
14  *                Privoxy team. http://www.privoxy.org/
15  *
16  *                Based on the Internet Junkbuster originally written
17  *                by and Copyright (C) 1997 Anonymous Coders and 
18  *                Junkbusters Corporation.  http://www.junkbusters.com
19  *
20  *                This program is free software; you can redistribute it 
21  *                and/or modify it under the terms of the GNU General
22  *                Public License as published by the Free Software
23  *                Foundation; either version 2 of the License, or (at
24  *                your option) any later version.
25  *
26  *                This program is distributed in the hope that it will
27  *                be useful, but WITHOUT ANY WARRANTY; without even the
28  *                implied warranty of MERCHANTABILITY or FITNESS FOR A
29  *                PARTICULAR PURPOSE.  See the GNU General Public
30  *                License for more details.
31  *
32  *                The GNU General Public License should be included with
33  *                this file.  If not, you can view it at
34  *                http://www.gnu.org/copyleft/gpl.html
35  *                or write to the Free Software Foundation, Inc., 59
36  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
37  *
38  * Revisions   :
39  *    $Log: loaders.h,v $
40  *    Revision 1.18  2002/03/24 13:25:43  swa
41  *    name change related issues
42  *
43  *    Revision 1.17  2002/03/16 23:54:06  jongfoster
44  *    Adding graceful termination feature, to help look for memory leaks.
45  *    If you enable this (which, by design, has to be done by hand
46  *    editing config.h) and then go to http://i.j.b/die, then the program
47  *    will exit cleanly after the *next* request.  It should free all the
48  *    memory that was used.
49  *
50  *    Revision 1.16  2002/03/07 03:46:17  oes
51  *    Fixed compiler warnings
52  *
53  *    Revision 1.15  2002/01/22 23:46:18  jongfoster
54  *    Moving edit_read_line() and simple_read_line() to loaders.c, and
55  *    extending them to support reading MS-DOS, Mac and UNIX style files
56  *    on all platforms.
57  *
58  *    Modifying read_config_line() (without changing it's prototype) to
59  *    be a trivial wrapper for edit_read_line().  This means that we have
60  *    one function to read a line and handle comments, which is common
61  *    between the initialization code and the edit interface.
62  *
63  *    Revision 1.14  2002/01/17 21:03:08  jongfoster
64  *    Moving all our URL and URL pattern parsing code to urlmatch.c.
65  *
66  *    Renaming free_url to free_url_spec, since it frees a struct url_spec.
67  *
68  *    Revision 1.13  2001/12/30 14:07:32  steudten
69  *    - Add signal handling (unix)
70  *    - Add SIGHUP handler (unix)
71  *    - Add creation of pidfile (unix)
72  *    - Add action 'top' in rc file (RH)
73  *    - Add entry 'SIGNALS' to manpage
74  *    - Add exit message to logfile (unix)
75  *
76  *    Revision 1.12  2001/11/07 00:02:13  steudten
77  *    Add line number in error output for lineparsing for
78  *    actionsfile and configfile.
79  *    Special handling for CLF added.
80  *
81  *    Revision 1.11  2001/10/23 21:38:53  jongfoster
82  *    Adding error-checking to create_url_spec()
83  *
84  *    Revision 1.10  2001/09/22 16:36:59  jongfoster
85  *    Removing unused parameter fs from read_config_line()
86  *
87  *    Revision 1.9  2001/07/30 22:08:36  jongfoster
88  *    Tidying up #defines:
89  *    - All feature #defines are now of the form FEATURE_xxx
90  *    - Permanently turned off WIN_GUI_EDIT
91  *    - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
92  *
93  *    Revision 1.8  2001/07/29 18:58:15  jongfoster
94  *    Removing nested #includes, adding forward declarations for needed
95  *    structures, and changing the #define _FILENAME_H to FILENAME_H_INCLUDED.
96  *
97  *    Revision 1.7  2001/07/13 14:01:54  oes
98  *    Removed all #ifdef PCRS
99  *
100  *    Revision 1.6  2001/06/07 23:14:38  jongfoster
101  *    Removing ACL and forward file loaders - these files have
102  *    been merged into the config file.
103  *
104  *    Revision 1.5  2001/05/31 21:28:49  jongfoster
105  *    Removed all permissionsfile code - it's now called the actions
106  *    file, and (almost) all the code is in actions.c
107  *
108  *    Revision 1.4  2001/05/29 09:50:24  jongfoster
109  *    Unified blocklist/imagelist/permissionslist.
110  *    File format is still under discussion, but the internal changes
111  *    are (mostly) done.
112  *
113  *    Also modified interceptor behaviour:
114  *    - We now intercept all URLs beginning with one of the following
115  *      prefixes (and *only* these prefixes):
116  *        * http://i.j.b/
117  *        * http://ijbswa.sf.net/config/
118  *        * http://ijbswa.sourceforge.net/config/
119  *    - New interceptors "home page" - go to http://i.j.b/ to see it.
120  *    - Internal changes so that intercepted and fast redirect pages
121  *      are not replaced with an image.
122  *    - Interceptors now have the option to send a binary page direct
123  *      to the client. (i.e. ijb-send-banner uses this)
124  *    - Implemented show-url-info interceptor.  (Which is why I needed
125  *      the above interceptors changes - a typical URL is
126  *      "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
127  *      The previous mechanism would not have intercepted that, and
128  *      if it had been intercepted then it then it would have replaced
129  *      it with an image.)
130  *
131  *    Revision 1.3  2001/05/26 00:28:36  jongfoster
132  *    Automatic reloading of config file.
133  *    Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
134  *    Most of the global variables have been moved to a new
135  *    struct configuration_spec, accessed through csp->config->globalname
136  *    Most of the globals remaining are used by the Win32 GUI.
137  *
138  *    Revision 1.2  2001/05/20 01:21:20  jongfoster
139  *    Version 2.9.4 checkin.
140  *    - Merged popupfile and cookiefile, and added control over PCRS
141  *      filtering, in new "permissionsfile".
142  *    - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
143  *      file error you now get a message box (in the Win32 GUI) rather
144  *      than the program exiting with no explanation.
145  *    - Made killpopup use the PCRS MIME-type checking and HTTP-header
146  *      skipping.
147  *    - Removed tabs from "config"
148  *    - Moved duplicated url parsing code in "loaders.c" to a new funcition.
149  *    - Bumped up version number.
150  *
151  *    Revision 1.1.1.1  2001/05/15 13:59:00  oes
152  *    Initial import of version 2.9.3 source tree
153  *
154  *
155  *********************************************************************/
156 \f
157
158 #ifdef __cplusplus
159 extern "C" {
160 #endif
161
162 /* Structures taken from project.h */
163 struct client_state;
164 struct file_list;
165 struct configuration_spec;
166 struct url_spec;
167
168 extern void sweep(void);
169 extern char *read_config_line(char *buf, size_t buflen, FILE *fp, unsigned long *linenum);
170 extern int check_file_changed(const struct file_list * current,
171                               const char * filename,
172                               struct file_list ** newfl);
173
174 extern jb_err edit_read_line(FILE *fp,
175                              char **raw_out,
176                              char **prefix_out,
177                              char **data_out,
178                              int *newline,
179                              unsigned long *line_number);
180
181 extern jb_err simple_read_line(FILE *fp, char **dest, int *newline);
182
183 /*
184  * Various types of newlines that a file may contain.
185  */
186 #define NEWLINE_UNKNOWN 0  /* Newline convention in file is unknown */
187 #define NEWLINE_UNIX    1  /* Newline convention in file is '\n'   (ASCII 10) */
188 #define NEWLINE_DOS     2  /* Newline convention in file is '\r\n' (ASCII 13,10) */
189 #define NEWLINE_MAC     3  /* Newline convention in file is '\r'   (ASCII 13) */
190
191 /*
192  * Types of newlines that a file may contain, as strings.  If you have an
193  * extremely wierd compiler that does not have '\r' == CR == ASCII 13 and
194  * '\n' == LF == ASCII 10), then fix CHAR_CR and CHAR_LF in loaders.c as
195  * well as these definitions.
196  */
197 #define NEWLINE(style) ((style)==NEWLINE_DOS ? "\r\n" : \
198                         ((style)==NEWLINE_MAC ? "\r" : "\n"))
199
200
201 extern short int MustReload;
202 extern int load_actions_file(struct client_state *csp);
203 extern int load_re_filterfile(struct client_state *csp);
204
205 #ifdef FEATURE_TRUST
206 extern int load_trustfile(struct client_state *csp);
207 #endif /* def FEATURE_TRUST */
208
209 #ifdef FEATURE_GRACEFUL_TERMINATION
210 #ifdef FEATURE_TRUST
211 void unload_current_trust_file(void);
212 #endif
213 void unload_current_re_filterfile(void);
214 #endif /* FEATURE_GRACEFUL_TERMINATION */
215
216
217 extern void add_loader(int (*loader)(struct client_state *), 
218                        struct configuration_spec * config);
219 extern int run_loader(struct client_state *csp);
220
221 /* Revision control strings from this header and associated .c file */
222 extern const char loaders_rcs[];
223 extern const char loaders_h_rcs[];
224
225 #ifdef __cplusplus
226 } /* extern "C" */
227 #endif
228
229 #endif /* ndef LOADERS_H_INCLUDED */
230
231 /*
232   Local Variables:
233   tab-width: 3
234   end:
235 */