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