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