Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

project.h

Go to the documentation of this file.
00001 #ifndef PROJECT_H_INCLUDED
00002 #define PROJECT_H_INCLUDED
00003 /** Version string. */
00004 #define PROJECT_H_VERSION "$Id: project.h,v 2.1 2002/06/04 16:35:56 jongfoster Exp $"
00005 /* ******************************************************************
00006  * $Source: /cvsroot/ijbswa/current/src/project.h,v $
00007  * ******************************************************************
00008  *
00009  * Written by and Copyright (C) 2001 the SourceForge
00010  * Privoxy team. http://www.privoxy.org/
00011  * 
00012  * Based on the Internet Junkbuster originally written
00013  * by and Copyright (C) 1997 Anonymous Coders and
00014  * Junkbusters Corporation.  http://www.junkbusters.com
00015  * 
00016  * This program is free software; you can redistribute it
00017  * and/or modify it under the terms of the GNU General
00018  * Public License as published by the Free Software
00019  * Foundation; either version 2 of the License, or (at
00020  * your option) any later version.
00021  * 
00022  * This program is distributed in the hope that it will
00023  * be useful, but WITHOUT ANY WARRANTY; without even the
00024  * implied warranty of MERCHANTABILITY or FITNESS FOR A
00025  * PARTICULAR PURPOSE.  See the GNU General Public
00026  * License for more details.
00027  * 
00028  * The GNU General Public License should be included with
00029  * this file.  If not, you can view it at
00030  * http://www.gnu.org/copyleft/gpl.html
00031  * or write to the Free Software Foundation, Inc., 59
00032  * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00033  * 
00034  * *****************************************************************/
00035 /**
00036  * @file
00037  *
00038  * Defines data structures which are widely used in the
00039  * project.  Does not define any variables or functions
00040  * (though it does declare some macros).
00041  * 
00042  *
00043  * $Log: project.h,v $
00044  * Revision 2.1  2002/06/04 16:35:56  jongfoster
00045  * Moving three variable declarations to jcc.c from project.h
00046  * 
00047  * Revision 2.0  2002/06/04 14:34:21  jongfoster
00048  * Moving source files to src/
00049  * 
00050  * Revision 1.72  2002/05/14 21:35:49  oes
00051  * Split HELP_LINK_PREFIX into ACTIONS_HELP_PREFIX and CONFIG_HELP_PREFIX
00052  * because of split in user-manual
00053  * 
00054  * Revision 1.71  2002/05/12 21:39:36  jongfoster
00055  * - Adding Doxygen-style comments to structures and #defines.
00056  * 
00057  * Revision 1.70  2002/05/12 16:05:50  jongfoster
00058  * Fixing ACTION_MASK_ALL to be unsigned long rather than
00059  * just unsigned int.  I don't know if anyone is porting
00060  * Privoxy to 16-bit platforms, but if so, +limit-connect
00061  * wouldn't have worked because of this bug.
00062  * 
00063  * Revision 1.69  2002/05/08 16:00:16  oes
00064  * Added size member to struct iob, so it can
00065  * be alloced larger than needed.
00066  * 
00067  * Revision 1.68  2002/04/26 12:56:00  oes
00068  * Killed REDIRECT_URL, added USER_MANUAL_URL and HELP_LINK_PREFIX
00069  * 
00070  * Revision 1.67  2002/04/24 02:12:43  oes
00071  *  - Jon's multiple AF patch:
00072  *    - Make csp->actions_list an array
00073  *    - #define MAX_ACTION_FILES
00074  *  - Moved CGI_PARAM_LEN_MAX (500) here
00075  * 
00076  * Revision 1.66  2002/04/15 19:06:43  jongfoster
00077  * Typos
00078  * 
00079  * Revision 1.65  2002/04/04 00:36:36  gliptak
00080  * always use pcre for matching
00081  * 
00082  * Revision 1.64  2002/04/03 22:28:03  gliptak
00083  * Removed references to gnu_regex
00084  * 
00085  * Revision 1.63  2002/03/31 17:19:00  jongfoster
00086  * Win32 only: Enabling STRICT to fix a VC++ compile warning.
00087  * 
00088  * Revision 1.62  2002/03/26 22:48:49  swa
00089  * new homepage url
00090  * 
00091  * Revision 1.61  2002/03/26 22:29:55  swa
00092  * we have a new homepage!
00093  * 
00094  * Revision 1.60  2002/03/24 15:52:17  jongfoster
00095  * Changing CGI URL prefixes for new name
00096  * 
00097  * Revision 1.59  2002/03/24 15:23:33  jongfoster
00098  * Name changes
00099  * 
00100  * Revision 1.58  2002/03/24 13:25:43  swa
00101  * name change related issues
00102  * 
00103  * Revision 1.57  2002/03/16 20:28:34  oes
00104  * Added descriptions to the filters so users will know what they select in the cgi editor
00105  * 
00106  * Revision 1.56  2002/03/13 20:27:30  oes
00107  * Fixing bug with CT_TABOO
00108  * 
00109  * Revision 1.55  2002/03/12 01:42:50  oes
00110  * Introduced modular filters
00111  * 
00112  * Revision 1.54  2002/03/09 20:03:52  jongfoster
00113  * - Making various functions return int rather than size_t.
00114  *   (Undoing a recent change).  Since size_t is unsigned on
00115  *   Windows, functions like read_socket that return -1 on
00116  *   error cannot return a size_t.
00117  * 
00118  *   THIS WAS A MAJOR BUG - it caused frequent, unpredictable
00119  *   crashes, and also frequently caused JB to jump to 100%
00120  *   CPU and stay there.  (Because it thought it had just
00121  *   read ((unsigned)-1) == 4Gb of data...)
00122  * 
00123  * - The signature of write_socket has changed, it now simply
00124  *   returns success=0/failure=nonzero.
00125  * 
00126  * - Trying to get rid of a few warnings --with-debug on
00127  *   Windows, I've introduced a new type "jb_socket".  This is
00128  *   used for the socket file descriptors.  On Windows, this
00129  *   is SOCKET (a typedef for unsigned).  Everywhere else, it's
00130  *   an int.  The error value can't be -1 any more, so it's
00131  *   now JB_INVALID_SOCKET (which is -1 on UNIX, and in
00132  *   Windows it maps to the #define INVALID_SOCKET.)
00133  * 
00134  * - The signature of bind_port has changed.
00135  * 
00136  * Revision 1.53  2002/03/08 16:48:55  oes
00137  * Added FEATURE_NO_GIFS and BUILTIN_IMAGE_MIMETYPE
00138  * 
00139  * Revision 1.52  2002/03/07 03:46:17  oes
00140  * Fixed compiler warnings
00141  * 
00142  * Revision 1.51  2002/03/05 04:52:42  oes
00143  * Deleted non-errlog debugging code
00144  * 
00145  * Revision 1.50  2002/03/04 19:32:07  oes
00146  * Changed default port to 8118
00147  * 
00148  * Revision 1.49  2002/03/04 18:28:55  oes
00149  * Deleted PID_FILE_NAME
00150  * 
00151  * Revision 1.48  2002/03/03 14:50:40  oes
00152  * Fixed CLF logging: Added ocmd member for client's request to struct http_request
00153  * 
00154  * Revision 1.47  2002/02/20 23:15:13  jongfoster
00155  * Parsing functions now handle out-of-memory gracefully by returning
00156  * an error code.
00157  * 
00158  * Revision 1.46  2002/01/17 21:06:09  jongfoster
00159  * Now #defining the URLs of the config interface
00160  * 
00161  * Minor changes to struct http_request and struct url_spec due to
00162  * standardizing that struct http_request is used to represent a URL, and
00163  * struct url_spec is used to represent a URL pattern.  (Before, URLs were
00164  * represented as seperate variables and a partially-filled-in url_spec).
00165  * 
00166  * Revision 1.45  2002/01/09 14:33:27  oes
00167  * Added HOSTENT_BUFFER_SIZE
00168  * 
00169  * Revision 1.44  2001/12/30 14:07:32  steudten
00170  * - Add signal handling (unix)
00171  * - Add SIGHUP handler (unix)
00172  * - Add creation of pidfile (unix)
00173  * - Add action 'top' in rc file (RH)
00174  * - Add entry 'SIGNALS' to manpage
00175  * - Add exit message to logfile (unix)
00176  * 
00177  * Revision 1.43  2001/11/22 21:57:51  jongfoster
00178  * Making action_spec->flags into an unsigned long rather than just an
00179  * unsigned int.
00180  * Adding ACTION_NO_COOKIE_KEEP
00181  * 
00182  * Revision 1.42  2001/11/05 21:42:41  steudten
00183  * Include DBG() macro.
00184  * 
00185  * Revision 1.41  2001/10/28 19:12:06  jongfoster
00186  * Adding ijb_toupper()
00187  * 
00188  * Revision 1.40  2001/10/26 17:40:47  oes
00189  * Moved ijb_isspace and ijb_tolower to project.h
00190  * Removed http->user_agent, csp->referrer and csp->accept_types
00191  * 
00192  * Revision 1.39  2001/10/25 03:45:02  david__schmidt
00193  * Adding a (void*) cast to freez() because Visual Age C++ won't expand the
00194  * macro when called with a cast; so moving the cast to the macro def'n
00195  * seems to both eliminate compiler warnings (on darwin and OS/2, anyway) and
00196  * doesn't make macro expansion complain.  Hope this works for everyone else
00197  * too...
00198  * 
00199  * Revision 1.38  2001/10/23 21:19:04  jongfoster
00200  * New error-handling support: jb_err type and JB_ERR_xxx constants
00201  * CGI functions now return a jb_err, and their parameters map is const.
00202  * Support for RUNTIME_FEATUREs to enable/disable config editor
00203  * Adding a few comments
00204  * 
00205  * Revision 1.37  2001/10/14 22:14:01  jongfoster
00206  * Removing name_length field from struct cgi_dispatcher, as this is
00207  * now calculated at runtime from the "name" field.
00208  * 
00209  * Revision 1.36  2001/10/10 16:45:15  oes
00210  * Added LIMIT_CONNECT action and string
00211  * Fixed HTTP message line termination
00212  * Added CFORBIDDEN HTTP message
00213  * 
00214  * Revision 1.35  2001/10/07 18:06:43  oes
00215  * Added status member to struct http_request
00216  * 
00217  * Revision 1.34  2001/10/07 15:45:25  oes
00218  * Added url member to struct http_request and commented all
00219  *   members
00220  * 
00221  * Added CT_TABOO
00222  * 
00223  * Added ACTION_DOWNGRADE and ACTION_NO_COMPRESSION
00224  * 
00225  * Replaced struct client_state members rejected,
00226  *   force, active and toggled_on with "flags" bitmap.
00227  * 
00228  * Added CSP_FLAG_MODIFIED and CSP_FLAG_CHUNKED
00229  * 
00230  * Added buffer_limit to struct configuration_spec
00231  * 
00232  * Revision 1.33  2001/09/20 13:30:08  steudten
00233  * 
00234  * Make freez() more secure in case of: if (exp) { free(z) ; a=*z }
00235  * Last case will set z to NULL in free(z) and thats bad..
00236  * 
00237  * Revision 1.32  2001/09/16 23:02:51  jongfoster
00238  * Fixing warning
00239  * 
00240  * Revision 1.31  2001/09/16 13:20:29  jongfoster
00241  * Rewrite of list library.  Now has seperate header and list_entry
00242  * structures.  Also added a large sprinking of assert()s to the list
00243  * code.
00244  * 
00245  * Revision 1.30  2001/09/13 23:52:00  jongfoster
00246  * Support for both static and dynamically generated CGI pages
00247  * 
00248  * Revision 1.29  2001/09/13 23:29:43  jongfoster
00249  * Defining FORWARD_SPEC_INITIALIZER
00250  * 
00251  * Revision 1.28  2001/09/13 23:05:50  jongfoster
00252  * Changing the string paramater to the header parsers a "const".
00253  * 
00254  * Revision 1.27  2001/08/05 16:06:20  jongfoster
00255  * Modifiying "struct map" so that there are now separate header and
00256  * "map_entry" structures.  This means that functions which modify a
00257  * map no longer need to return a pointer to the modified map.
00258  * Also, it no longer reverses the order of the entries (which may be
00259  * important with some advanced template substitutions).
00260  * 
00261  * Revision 1.26  2001/07/30 22:08:36  jongfoster
00262  * Tidying up #defines:
00263  * - All feature #defines are now of the form FEATURE_xxx
00264  * - Permanently turned off WIN_GUI_EDIT
00265  * - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
00266  * 
00267  * Revision 1.25  2001/07/29 18:43:08  jongfoster
00268  * Changing #ifdef _FILENAME_H to FILENAME_H_INCLUDED, to conform to
00269  * ANSI C rules.
00270  * 
00271  * Revision 1.24  2001/07/25 17:20:27  oes
00272  * Introduced http->user_agent
00273  * 
00274  * Revision 1.23  2001/07/18 12:32:23  oes
00275  * - Added ACTION_STRING_DEANIMATE
00276  * - moved #define freez from jcc.h to project.h
00277  * 
00278  * Revision 1.22  2001/07/15 17:51:41  jongfoster
00279  * Renaming #define STATIC to STATIC_PCRE
00280  * 
00281  * Revision 1.21  2001/07/13 14:03:19  oes
00282  *  - Reorganized regex header inclusion and #defines to
00283  *    comply to the scheme in configure.in
00284  *  - Added csp->content_type and its CT_* keys
00285  *  - Added ACTION_DEANIMATE
00286  *  - Removed all #ifdef PCRS
00287  * 
00288  * Revision 1.20  2001/06/29 21:45:41  oes
00289  * Indentation, CRLF->LF, Tab-> Space
00290  * 
00291  * Revision 1.19  2001/06/29 13:33:36  oes
00292  * - Improved comments
00293  * - Introduced http_request.host_ip_addr_str
00294  * - Introduced http_response.head_length
00295  * - Introduced config.my_ip_addr_str, config.my_hostname,
00296  *   config.admin_address and config.proxy_info_url
00297  * - Removed config.proxy_args_header and config.proxy_args_trailer,
00298  *   renamed config.proxy_args_invocation to config.proxy_args
00299  * - Removed HTML snipplets and GIFs
00300  * - Removed logentry from cancelled commit
00301  * 
00302  * Revision 1.18  2001/06/09 10:57:39  jongfoster
00303  * Adding definition of BUFFER_SIZE.
00304  * Changing struct cgi_dispatcher to use "const" strings.
00305  * 
00306  * Revision 1.17  2001/06/07 23:15:09  jongfoster
00307  * Merging ACL and forward files into config file.
00308  * Moving struct gateway members into struct forward_spec
00309  * Removing config->proxy_args_gateways
00310  * Cosmetic: Adding a few comments
00311  * 
00312  * Revision 1.16  2001/06/04 18:31:58  swa
00313  * files are now prefixed with either `confdir' or `logdir'.
00314  * `make redhat-dist' replaces both entries confdir and logdir
00315  * with redhat values
00316  * 
00317  * Revision 1.15  2001/06/04 11:28:53  swa
00318  * redirect did not work due to missing /
00319  * 
00320  * Revision 1.14  2001/06/03 11:03:48  oes
00321  * Added struct map,
00322  * added struct http_response,
00323  * changed struct interceptors to struct cgi_dispatcher,
00324  * moved HTML stuff to cgi.h
00325  * 
00326  * Revision 1.13  2001/06/01 20:05:36  jongfoster
00327  * Support for +image-blocker{}: added ACTION_IMAGE_BLOCKER
00328  * constant, and removed csp->tinygif.
00329  * 
00330  * Revision 1.12  2001/06/01 18:49:17  jongfoster
00331  * Replaced "list_share" with "list" - the tiny memory gain was not
00332  * worth the extra complexity.
00333  * 
00334  * Revision 1.11  2001/06/01 10:32:47  oes
00335  * Added constants for anchoring selection bitmap
00336  * 
00337  * Revision 1.10  2001/05/31 21:33:53  jongfoster
00338  * Changes for new actions file, replacing permissionsfile
00339  * and parts of the config file.  Also added support for
00340  * list_shared.
00341  * 
00342  * Revision 1.9  2001/05/31 17:32:31  oes
00343  * 
00344  *  - Enhanced domain part globbing with infix and prefix asterisk
00345  *    matching and optional unanchored operation
00346  * 
00347  * Revision 1.8  2001/05/29 20:09:15  joergs
00348  * HTTP_REDIRECT_TEMPLATE fixed.
00349  * 
00350  * Revision 1.7  2001/05/29 09:50:24  jongfoster
00351  * Unified blocklist/imagelist/actionslist.
00352  * File format is still under discussion, but the internal changes
00353  * are (mostly) done.
00354  * 
00355  * Also modified interceptor behaviour:
00356  * - We now intercept all URLs beginning with one of the following
00357  *   prefixes (and *only* these prefixes):
00358  *     * http://i.j.b/
00359  *     * http://ijbswa.sf.net/config/
00360  *     * http://ijbswa.sourceforge.net/config/
00361  * - New interceptors "home page" - go to http://i.j.b/ to see it.
00362  * - Internal changes so that intercepted and fast redirect pages
00363  *   are not replaced with an image.
00364  * - Interceptors now have the option to send a binary page direct
00365  *   to the client. (i.e. ijb-send-banner uses this)
00366  * - Implemented show-url-info interceptor.  (Which is why I needed
00367  *   the above interceptors changes - a typical URL is
00368  *   "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
00369  *   The previous mechanism would not have intercepted that, and
00370  *   if it had been intercepted then it then it would have replaced
00371  *   it with an image.)
00372  * 
00373  * Revision 1.6  2001/05/27 22:17:04  oes
00374  * 
00375  * - re_process_buffer no longer writes the modified buffer
00376  *   to the client, which was very ugly. It now returns the
00377  *   buffer, which it is then written by chat.
00378  * 
00379  * - content_length now adjusts the Content-Length: header
00380  *   for modified documents rather than crunch()ing it.
00381  *   (Length info in csp->content_length, which is 0 for
00382  *   unmodified documents)
00383  * 
00384  * - For this to work, sed() is called twice when filtering.
00385  * 
00386  * Revision 1.5  2001/05/26 00:28:36  jongfoster
00387  * Automatic reloading of config file.
00388  * Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
00389  * Most of the global variables have been moved to a new
00390  * struct configuration_spec, accessed through csp->config->globalname
00391  * Most of the globals remaining are used by the Win32 GUI.
00392  * 
00393  * Revision 1.4  2001/05/22 18:46:04  oes
00394  * 
00395  * - Enabled filtering banners by size rather than URL
00396  *   by adding patterns that replace all standard banner
00397  *   sizes with the "Junkbuster" gif to the re_filterfile
00398  * 
00399  * - Enabled filtering WebBugs by providing a pattern
00400  *   which kills all 1x1 images
00401  * 
00402  * - Added support for PCRE_UNGREEDY behaviour to pcrs,
00403  *   which is selected by the (nonstandard and therefore
00404  *   capital) letter 'U' in the option string.
00405  *   It causes the quantifiers to be ungreedy by default.
00406  *   Appending a ? turns back to greedy (!).
00407  * 
00408  * - Added a new interceptor ijb-send-banner, which
00409  *   sends back the "Junkbuster" gif. Without imagelist or
00410  *   MSIE detection support, or if tinygif = 1, or the
00411  *   URL isn't recognized as an imageurl, a lame HTML
00412  *   explanation is sent instead.
00413  * 
00414  * - Added new feature, which permits blocking remote
00415  *   script redirects and firing back a local redirect
00416  *   to the browser.
00417  *   The feature is conditionally compiled, i.e. it
00418  *   can be disabled with --disable-fast-redirects,
00419  *   plus it must be activated by a "fast-redirects"
00420  *   line in the config file, has its own log level
00421  *   and of course wants to be displayed by show-proxy-args
00422  *   Note: Boy, all the #ifdefs in 1001 locations and
00423  *   all the fumbling with configure.in and acconfig.h
00424  *   were *way* more work than the feature itself :-(
00425  * 
00426  * - Because a generic redirect template was needed for
00427  *   this, tinygif = 3 now uses the same.
00428  * 
00429  * - Moved GIFs, and other static HTTP response templates
00430  *   to project.h
00431  * 
00432  * - Some minor fixes
00433  * 
00434  * - Removed some >400 CRs again (Jon, you really worked
00435  *   a lot! ;-)
00436  * 
00437  * Revision 1.3  2001/05/20 01:21:20  jongfoster
00438  * Version 2.9.4 checkin.
00439  * - Merged popupfile and cookiefile, and added control over PCRS
00440  *   filtering, in new "actionsfile".
00441  * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
00442  *   file error you now get a message box (in the Win32 GUI) rather
00443  *   than the program exiting with no explanation.
00444  * - Made killpopup use the PCRS MIME-type checking and HTTP-header
00445  *   skipping.
00446  * - Removed tabs from "config"
00447  * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
00448  * - Bumped up version number.
00449  * 
00450  * Revision 1.2  2001/05/17 23:01:01  oes
00451  *  - Cleaned CRLF's from the sources and related files
00452  * 
00453  * Revision 1.1.1.1  2001/05/15 13:59:03  oes
00454  * Initial import of version 2.9.3 source tree
00455  * 
00456  * 
00457  */
00458 /* *****************************************************************/
00459 
00460 
00461 /* Declare struct FILE for vars and funcs. */
00462 #include <stdio.h>
00463 
00464 /* Need time_t for file_list */
00465 #include <time.h>
00466 
00467 /*
00468  * Include appropriate regular expression libraries.
00469  * Note that pcrs and pcre (native) are needed for cgi
00470  * and are included anyway.
00471  */
00472 
00473 #ifdef STATIC_PCRE
00474 #  include "pcre.h"
00475 #else
00476 #  include <pcre.h>
00477 #endif
00478 
00479 #ifdef STATIC_PCRS
00480 #  include "pcrs.h"
00481 #else
00482 #  include <pcrs.h>
00483 #endif
00484 
00485 #ifdef STATIC_PCRE
00486 #  include "pcreposix.h"
00487 #else
00488 #  include <pcreposix.h>
00489 #endif
00490 
00491 #ifdef AMIGA
00492 #include "amiga.h"
00493 #endif /* def AMIGA */
00494 
00495 #ifdef _WIN32
00496 /*
00497  * I don't want to have to #include all this just for the declaration
00498  * of SOCKET.  However, it looks like we have to...
00499  */
00500 #ifndef STRICT
00501 #define STRICT
00502 #endif
00503 #include <windows.h>
00504 #endif
00505 
00506 
00507 #ifdef __cplusplus
00508 extern "C" {
00509 #endif
00510 
00511 #ifdef _WIN32
00512 
00513 typedef SOCKET jb_socket;
00514 
00515 #define JB_INVALID_SOCKET INVALID_SOCKET
00516 
00517 #else /* ndef _WIN32 */
00518 
00519 /**
00520  * The type used by sockets.  On UNIX it's an int.  Microsoft decided to
00521  * make it an unsigned.
00522  */
00523 typedef int jb_socket;
00524 
00525 /**
00526  * The error value used for variables of type jb_socket.  On UNIX this
00527  * is -1, however Microsoft decided to make socket handles unsigned, so
00528  * they use a different value.
00529  */
00530 
00531 #define JB_INVALID_SOCKET (-1)
00532 
00533 #endif /* ndef _WIN32 */
00534 
00535 
00536 /**
00537  * A standard error code.  This should be JB_ERR_OK or one of the JB_ERR_xxx
00538  * series of errors.
00539  */
00540 typedef int jb_err;
00541 
00542 #define JB_ERR_OK         0 /**< Success, no error                        */
00543 #define JB_ERR_MEMORY     1 /**< Out of memory                            */
00544 #define JB_ERR_CGI_PARAMS 2 /**< Missing or corrupt CGI parameters        */
00545 #define JB_ERR_FILE       3 /**< Error opening, reading or writing a file */
00546 #define JB_ERR_PARSE      4 /**< Error parsing file                       */
00547 #define JB_ERR_MODIFIED   5 /**< File has been modified outside of the  
00548                                  CGI actions editor.                      */
00549 
00550 
00551 /**
00552  * This macro is used to free a pointer that may be NULL.
00553  * It also sets the variable to NULL after it's been freed.
00554  * The paramater should be a simple variable without side effects.
00555  */
00556 #define freez(X)  { if(X) { free((void*)X); X = NULL ; } }
00557 
00558 
00559 /**
00560  * Fix a problem with Solaris.  There should be no effect on other
00561  * platforms.
00562  *
00563  * Solaris's isspace() is a macro which uses it's argument directly
00564  * as an array index.  Therefore we need to make sure that high-bit
00565  * characters generate +ve values, and ideally we also want to make
00566  * the argument match the declared parameter type of "int".
00567  *
00568  * Note: Remember to #include <ctype.h> if you use these macros.
00569  */
00570 #define ijb_toupper(__X) toupper((int)(unsigned char)(__X))
00571 #define ijb_tolower(__X) tolower((int)(unsigned char)(__X))
00572 #define ijb_isspace(__X) isspace((int)(unsigned char)(__X))  
00573 
00574 /**
00575  * Use for statically allocated buffers if you have no other choice.
00576  * Remember to check the length of what you write into the buffer
00577  * - we don't want any buffer overflows!
00578  */
00579 #define BUFFER_SIZE 5000
00580 
00581 /**
00582  * Max length of CGI parameters (arbitrary limit).
00583  */
00584 #define CGI_PARAM_LEN_MAX 500
00585 
00586 /**
00587  * Buffer size for capturing struct hostent data in the
00588  * gethostby(name|addr)_r library calls. Since we don't
00589  * loop over gethostbyname_r, the buffer must be sufficient
00590  * to accomodate multiple IN A RRs, as used in DNS round robin
00591  * load balancing. W3C's wwwlib uses 1K, so that should be
00592  * good enough for us, too.
00593  */
00594 #define HOSTENT_BUFFER_SIZE 1024
00595 
00596 /**
00597  * Do not use.  Originally this was so that you can
00598  * say "while (FOREVER) { ...do something... }".
00599  * However, this gives a warning with some compilers (e.g. VC++).
00600  * Instead, use "for (;;) { ...do something... }".
00601  */
00602 #define FOREVER 1
00603 
00604 /**
00605  * Default IP address to listen on, as a string.
00606  * Set to "127.0.0.1".
00607  */
00608 #define HADDR_DEFAULT   "127.0.0.1"
00609 
00610 /**
00611  * Default port to listen on, as a number.
00612  * Set to 8118.
00613  */
00614 #define HADDR_PORT      8118
00615 
00616 
00617 /* Forward def for struct client_state */
00618 struct configuration_spec;
00619 
00620 
00621 /**
00622  * Entry in a linked list of strings.
00623  */
00624 struct list_entry
00625 {
00626    /**
00627     * The string.  The "const" is only to discourage modification,
00628     * you can actually change it if you *really* want to.
00629     * You can even freez() it and replace it with another
00630     * malloc()d string.  If you replace it with NULL, the list
00631     * functions will work, just be careful next time you iterate
00632     * through the list in your own code.
00633     *
00634     * FIXME: Should we remove the "const"?
00635     */
00636    const char *str;
00637    
00638    /** Next entry in the linked list, or NULL if no more. */
00639    struct list_entry *next;
00640 };
00641 
00642 /**
00643  * A header for a linked list of strings.
00644  */
00645 struct list
00646 {
00647    /** First entry in the list, or NULL if the list is empty. */
00648    struct list_entry *first;
00649 
00650    /** Last entry in the list, or NULL if the list is empty. */
00651    struct list_entry *last;
00652 };
00653 
00654 
00655 /**
00656  * An entry in a map.  This is a name=value pair.
00657  */
00658 struct map_entry
00659 {
00660    /** The key for the map. */
00661    const char *name;
00662    /** The value associated with that key. */
00663    const char *value;
00664    /** The next map entry, or NULL if none. */
00665    struct map_entry *next;
00666 };
00667 
00668 /**
00669  * A map from a string to another string.
00670  * This is used for the paramaters passed in a HTTP GET request, and
00671  * to store the exports when the CGI interface is filling in a template.
00672  */
00673 struct map
00674 {
00675    /** The first map entry, or NULL if the map is empty. */
00676    struct map_entry *first;
00677    /** The last map entry, or NULL if the map is empty. */
00678    struct map_entry *last;
00679 };
00680 
00681 
00682 /**
00683  * A HTTP request.  This includes the method (GET, POST) and
00684  * the parsed URL.
00685  *
00686  * This is also used whenever we want to match a URL against a
00687  * URL pattern.  This always contains the URL to match, and never
00688  * a URL pattern.  (See struct url_spec).
00689  */
00690 struct http_request
00691 {
00692    char *cmd;      /**< Whole command line: method, URL, Version */
00693    char *ocmd;     /**< Backup of original cmd for CLF logging */
00694    char *gpc;      /**< HTTP method: GET, POST, ... */
00695    char *url;      /**< The URL */
00696    char *ver;      /**< Protocol version */
00697    int status;     /**< HTTP Status */
00698 
00699    char *host;     /**< Host part of URL */
00700    int   port;     /**< Port of URL or 80 (default) */
00701    char *path;     /**< Path of URL */
00702    char *hostport; /**< host[:port] */
00703    int   ssl;      /**< Flag if protocol is https */
00704 
00705    char *host_ip_addr_str; /**< String with dotted decimal representation
00706                                 of host's IP. NULL before connect_to() */
00707 
00708    char  *dbuffer; /**< Buffer with '\0'-delimited domain name.           */
00709    char **dvec;    /**< List of pointers to the strings in dbuffer.       */
00710    int    dcount;  /**< How many parts to this domain? (length of dvec)   */
00711 };
00712 
00713 
00714 /**
00715  * Response generated by CGI, blocker, or error handler
00716  */
00717 struct http_response
00718 {
00719   char  *status;          /**< HTTP status (string). */
00720   struct list headers[1]; /**< List of header lines. */
00721   char  *head;            /**< Formatted http response head. */
00722   size_t head_length;     /**< Length of http response head. */
00723   char  *body;            /**< HTTP document body. */
00724   size_t content_length;  /**< Length of body, REQUIRED if binary body. */
00725   int    is_static;       /**< Nonzero if the content will never change and
00726                                should be cached by the browser (e.g. images). */
00727 };
00728 
00729 /**
00730  * A URL pattern.
00731  */
00732 struct url_spec
00733 {
00734    /** The string which was parsed to produce this url_spec.
00735        Used for debugging or display only.  */
00736    char  *spec;
00737 
00738    char  *dbuffer;     /**< Buffer with '\0'-delimited domain name, or NULL to match all hosts. */
00739    char **dvec;        /**< List of pointers to the strings in dbuffer.       */
00740    int    dcount;      /**< How many parts to this domain? (length of dvec)   */
00741    int    unanchored;  /**< Bitmap - flags are ANCHOR_LEFT and ANCHOR_RIGHT.  */
00742 
00743    int   port;         /**< The port number, or 0 to match all ports.         */
00744 
00745    char *path;         /**< The source for the regex.                         */
00746    int   pathlen;      /**< ==strlen(path).  Needed for prefix matching.  FIXME: Now obsolete?     */
00747    regex_t *preg;      /**< Regex for matching path part                      */
00748 };
00749 
00750 /**
00751  * If you declare a static url_spec, this is the value to initialize it to zero.
00752  */
00753 #define URL_SPEC_INITIALIZER { NULL, NULL, NULL, 0, 0, 0, NULL, 0, NULL }
00754 
00755 /**
00756  * Constant for host part matching in URLs.  If set, indicates that the start of
00757  * the pattern must match the start of the URL.  E.g. this is not set for the
00758  * pattern ".example.com", so that it will match both "example.com" and
00759  * "www.example.com".  It is set for the pattern "example.com", which makes it
00760  * match "example.com" only, not "www.example.com".
00761  */
00762 #define ANCHOR_LEFT  1
00763 
00764 /**
00765  * Constant for host part matching in URLs.  If set, indicates that the end of
00766  * the pattern must match the end of the URL.  E.g. this is not set for the
00767  * pattern "ad.", so that it will match any host called "ad", irrespective
00768  * of how many subdomains are in the fully-qualified domain name.
00769  */
00770 #define ANCHOR_RIGHT 2
00771 
00772 
00773 /**
00774  * An I/O buffer.  Holds a string which can be appended to, and can have data
00775  * removed from the beginning.
00776  */
00777 struct iob
00778 {
00779    char *buf;    /**< Start of buffer        */
00780    char *cur;    /**< Start of relevant data */
00781    char *eod;    /**< End of relevant data   */
00782    size_t size;  /**< Size as malloc()ed     */
00783 };
00784 
00785 
00786 /**
00787  * Return the number of bytes in the I/O buffer associated with the passed
00788  * client_state pointer.
00789  * May be zero.
00790  */
00791 #define IOB_PEEK(CSP) ((CSP->iob->cur > CSP->iob->eod) ? (CSP->iob->eod - CSP->iob->cur) : 0)
00792 
00793 
00794 /**
00795  * Remove any data in the I/O buffer associated with the passed
00796  * client_state pointer.
00797  */
00798 #define IOB_RESET(CSP) if(CSP->iob->buf) free(CSP->iob->buf); memset(CSP->iob, '\0', sizeof(CSP->iob));
00799 
00800 /* Bits for csp->content_type */
00801 #define CT_TEXT   1 /**< csp->content_type bitmask:
00802                          Suitable for pcrs filtering. */
00803 #define CT_GIF    2 /**< csp->content_type bitmask:
00804                          Suitable for GIF filtering.  */
00805 #define CT_TABOO  4 /**< csp->content_type bitmask:
00806                          DO NOT filter, irrespective of other flags. */
00807 
00808 /**
00809  * The mask which includes all actions.
00810  */
00811 #define ACTION_MASK_ALL        (~0UL)
00812 
00813 /**
00814  * The most compatible set of actions - i.e. none.
00815  */
00816 #define ACTION_MOST_COMPATIBLE 0x00000000UL
00817 
00818 /** Action bitmap: Block the request. */
00819 #define ACTION_BLOCK           0x00000001UL
00820 /** Action bitmap: Deanimate if it's a GIF. */
00821 #define ACTION_DEANIMATE       0x00000002UL
00822 /** Action bitmap: Downgrade HTTP/1.1 to 1.0. */
00823 #define ACTION_DOWNGRADE       0x00000004UL
00824 /** Action bitmap: Fast redirects. */
00825 #define ACTION_FAST_REDIRECTS  0x00000008UL
00826 /** Action bitmap: Remove existing "Forwarded" header, and do not add another. */
00827 #define ACTION_HIDE_FORWARDED  0x00000010UL
00828 /** Action bitmap: Hide "From" header. */
00829 #define ACTION_HIDE_FROM       0x00000020UL
00830 /** Action bitmap: Hide "Referer" header.  (sic - follow HTTP, not English). */
00831 #define ACTION_HIDE_REFERER    0x00000040UL
00832 /** Action bitmap: Hide "User-Agent" and similar headers. */
00833 #define ACTION_HIDE_USER_AGENT 0x00000080UL
00834 /** Action bitmap: This is an image. */
00835 #define ACTION_IMAGE           0x00000100UL
00836 /** Action bitmap: Sets the image blocker. */
00837 #define ACTION_IMAGE_BLOCKER   0x00000200UL
00838 /** Action bitmap: Prevent compression. */
00839 #define ACTION_NO_COMPRESSION  0x00000400UL
00840 /** Action bitmap: Change cookies to session only cookies. */
00841 #define ACTION_NO_COOKIE_KEEP  0x00000800UL
00842 /** Action bitmap: Block rending cookies. */
00843 #define ACTION_NO_COOKIE_READ  0x00001000UL
00844 /** Action bitmap: Block setting cookies. */
00845 #define ACTION_NO_COOKIE_SET   0x00002000UL
00846 /** Action bitmap: Filter out popups. */
00847 #define ACTION_NO_POPUPS       0x00004000UL
00848 /** Action bitmap: Send a vanilla wafer. */
00849 #define ACTION_VANILLA_WAFER   0x00008000UL
00850 /** Action bitmap: Limit CONNECT requests to safe ports. */
00851 #define ACTION_LIMIT_CONNECT   0x00010000UL
00852 
00853 /** Action string index: How to deanimate GIFs */
00854 #define ACTION_STRING_DEANIMATE     0
00855 /** Action string index: Replacement for "From:" header */
00856 #define ACTION_STRING_FROM          1
00857 /** Action string index: How to block images */
00858 #define ACTION_STRING_IMAGE_BLOCKER 2
00859 /** Action string index: Replacement for "Referer:" header */
00860 #define ACTION_STRING_REFERER       3
00861 /** Action string index: Replacement for "User-Agent:" header */
00862 #define ACTION_STRING_USER_AGENT    4
00863 /** Action string index: Legal CONNECT ports. */
00864 #define ACTION_STRING_LIMIT_CONNECT 5
00865 /** Number of string actions. */
00866 #define ACTION_STRING_COUNT         6
00867 
00868 /** Index into current_action_spec::multi[] for headers to add. */
00869 #define ACTION_MULTI_ADD_HEADER     0
00870 /** Index into current_action_spec::multi[] for headers to add. */
00871 #define ACTION_MULTI_WAFER          1
00872 /** Index into current_action_spec::multi[] for filters to apply. */
00873 #define ACTION_MULTI_FILTER         2
00874 /** Number of multi-string actions. */
00875 #define ACTION_MULTI_COUNT          3
00876 
00877 
00878 /**
00879  * This structure contains a list of actions to apply to a URL.
00880  * It only contains positive instructions - no "-" options.
00881  * It is not used to store the actions list itself, only for
00882  * url_actions() to return the current values.
00883  */
00884 struct current_action_spec
00885 {
00886    /** Actions to apply.  A bit set to "1" means perform the action. */
00887    unsigned long flags;
00888 
00889    /**
00890     * Paramaters for those actions that require them.
00891     * Each entry is valid if & only if the corresponding entry in "flags" is
00892     * set.
00893     */
00894    char * string[ACTION_STRING_COUNT];
00895 
00896    /** Lists of strings for multi-string actions. */
00897    struct list multi[ACTION_MULTI_COUNT][1];
00898 };
00899 
00900 
00901 /**
00902  * This structure contains a set of changes to actions.
00903  * It can contain both positive and negative instructions.
00904  * It is used to store an entry in the actions list.
00905  */
00906 struct action_spec
00907 {
00908    unsigned long mask; /**< Actions to keep. A bit set to "0" means remove action. */
00909    unsigned long add;  /**< Actions to add.  A bit set to "1" means add action.    */
00910 
00911    /**
00912     * Paramaters for those actions that require them.
00913     * Each entry is valid if & only if the corresponding entry in "flags" is
00914     * set.
00915     */
00916    char * string[ACTION_STRING_COUNT];
00917 
00918    /** Lists of strings to remove, for multi-string actions. */
00919    struct list multi_remove[ACTION_MULTI_COUNT][1];
00920 
00921    /** If nonzero, remove *all* strings from the multi-string action. */
00922    int         multi_remove_all[ACTION_MULTI_COUNT];
00923 
00924    /** Lists of strings to add, for multi-string actions. */
00925    struct list multi_add[ACTION_MULTI_COUNT][1];
00926 };
00927 
00928 
00929 /**
00930  * This structure is used to store the actions list.
00931  *
00932  * It contains a URL pattern, and the chages to the actions.
00933  * It is a linked list.
00934  */
00935 struct url_actions
00936 {
00937    struct url_spec url[1];        /**< URL pattern. */
00938 
00939    struct action_spec action[1];  /**< Actions. */
00940 
00941    struct url_actions * next;     /**< Next action in file, or NULL. */
00942 };
00943 
00944 
00945 /*
00946  * Flags for use in csp->flags
00947  */
00948  
00949 /**
00950  * Flag for csp->flags: Set if this client is processing data.
00951  * Cleared when the thread associated with this structure dies.
00952  */
00953 #define CSP_FLAG_ACTIVE     0x01
00954 
00955 /**
00956  * Flag for csp->flags: Set if the server's reply is in "chunked"
00957  * transfer encoding
00958  */
00959 #define CSP_FLAG_CHUNKED    0x02
00960 
00961 /**
00962  * Flag for csp->flags: Set if this request was enforced, although it would
00963  * normally have been blocked.
00964  */
00965 #define CSP_FLAG_FORCED     0x04
00966 
00967 /**
00968  * Flag for csp->flags: Set if any modification to the body was done.
00969  */
00970 #define CSP_FLAG_MODIFIED   0x08
00971 
00972 /**
00973  * Flag for csp->flags: Set if request was blocked.
00974  */
00975 #define CSP_FLAG_REJECTED   0x10
00976 
00977 /**
00978  * Flag for csp->flags: Set if we are toggled on (FEATURE_TOGGLE).
00979  */
00980 #define CSP_FLAG_TOGGLED_ON 0x20
00981 
00982 
00983 /**
00984  * Maximum number of actions files.  This limit is arbitrary - it's just used
00985  * to size an array.
00986  */
00987 #define MAX_ACTION_FILES 10
00988 
00989 /**
00990  * The state of a Privoxy processing thread.
00991  */
00992 struct client_state
00993 {
00994    /** The proxy's configuration */
00995    struct configuration_spec * config;
00996 
00997    /** The actions to perform on the current request */
00998    struct current_action_spec  action[1];
00999 
01000    /** socket to talk to client (web browser) */
01001    jb_socket cfd;
01002 
01003    /** socket to talk to server (web server or proxy) */
01004    jb_socket sfd;
01005 
01006    /** Multi-purpose flag container, see CSP_FLAG_* above */
01007    unsigned short int flags;
01008 
01009    /** Client PC's IP address, as reported by the accept() function.
01010        As a string. */
01011    char *ip_addr_str;
01012    /** Client PC's IP address, as reported by the accept() function.
01013        As a number. */
01014    long  ip_addr_long;
01015 
01016    /** Our IP address. I.e. the IP address that the client used to reach us,
01017        as a string. */
01018    char *my_ip_addr_str;
01019 
01020    /** Our hostname. I.e. the reverse DNS of the IP address that the client
01021        used to reach us, as a string. */
01022    char *my_hostname;
01023 
01024    /** The URL that was requested */
01025    struct http_request http[1];
01026 
01027    /** An I/O buffer used for buffering data read from the network */
01028    struct iob iob[1];
01029 
01030    /** List of all headers for this request */
01031    struct list headers[1];
01032 
01033    /** List of all cookies for this request */
01034    struct list cookie_list[1];
01035 
01036    /** MIME-Type key, see CT_* above */
01037    unsigned short int content_type;
01038 
01039    /** The "X-Forwarded-For:" header sent by the client */
01040    char   *x_forwarded;
01041 
01042    /** Actions files associated with this client */
01043    struct file_list *actions_list[MAX_ACTION_FILES];
01044 
01045    /** pcrs job file. */
01046    struct file_list *rlist;
01047 
01048    /** Length after content modification. */
01049    size_t content_length;
01050 
01051 #ifdef FEATURE_TRUST
01052 
01053    /** Trust file. */
01054    struct file_list *tlist;
01055 
01056 #endif /* def FEATURE_TRUST */
01057 
01058    /** Next thread in linked list. Only read or modify from the main thread! */
01059    struct client_state *next;
01060 };
01061 
01062 
01063 /**
01064  * A function to add a header
01065  */
01066 typedef jb_err (*add_header_func_ptr)(struct client_state *);
01067 
01068 /**
01069  * A function to process a header
01070  */
01071 typedef jb_err (*parser_func_ptr    )(struct client_state *, char **);
01072 
01073 
01074 /**
01075  * List of functions to run on a list of headers
01076  */
01077 struct parsers
01078 {
01079    /** The header prefix to match */
01080    char   *str;
01081    
01082    /** The length of the prefix to match */
01083    size_t len;
01084    
01085    /** The function to apply to this line */
01086    parser_func_ptr parser;
01087 };
01088 
01089 
01090 /**
01091  * List of available CGI functions.
01092  */
01093 struct cgi_dispatcher
01094 {
01095    /** The URL of the CGI, relative to the CGI root. */
01096    const char * const name;
01097 
01098    /** The handler function for the CGI */
01099    jb_err    (* const handler)(struct client_state *csp, struct http_response *rsp, const struct map *parameters);
01100 
01101    /** The description of the CGI, to appear on the main menu, or NULL to hide it. */
01102    const char * const description;
01103 };
01104 
01105 
01106 /**
01107  * A data file used by Privoxy.  Kept in a linked list.
01108  */
01109 struct file_list
01110 {
01111    /**
01112     * This is a pointer to the data structures associated with the file.
01113     * Read-only once the structure has been created.
01114     */
01115    void *f;
01116 
01117    /**
01118     * The unloader function.
01119     * Normally NULL.  When we are finished with file (i.e. when we have
01120     * loaded a new one), set to a pointer to an unloader function.
01121     * Unloader will be called by sweep() (called from main loop) when
01122     * all clients using this file are done.  This prevents threading
01123     * problems.
01124     */
01125    void (*unloader)(void *);
01126 
01127    /**
01128     * Used internally by sweep().  Do not access from elsewhere.
01129     */
01130    int active;
01131 
01132    /**
01133     * File last-modified time, so we can check if file has been changed.
01134     * Read-only once the structure has been created.
01135     */
01136    time_t lastmodified;
01137    
01138    /**
01139     * The full filename.
01140     */
01141    char * filename;
01142 
01143    /**
01144     * Pointer to next entry in the linked list of all "file_list"s.
01145     * This linked list is so that sweep() can navigate it.
01146     * Since sweep() can remove items from the list, we must be careful
01147     * to only access this value from main thread (when we know sweep
01148     * won't be running).
01149     */
01150    struct file_list *next;
01151 };
01152 
01153 
01154 #ifdef FEATURE_TRUST
01155 
01156 /**
01157  * The format of a trust file when loaded into memory.
01158  */
01159 struct block_spec
01160 {
01161    struct url_spec url[1];   /**< The URL pattern              */
01162    int    reject;            /**< FIXME: Please document this! */
01163    struct block_spec *next;  /**< Next entry in linked list    */
01164 };
01165 
01166 #endif /* def FEATURE_TRUST */
01167 
01168 
01169 #define SOCKS_NONE    0    /**< Don't use a SOCKS server               */
01170 #define SOCKS_4      40    /**< original SOCKS 4 protocol              */
01171 #define SOCKS_4A     41    /**< as modified for hosts w/o external DNS */
01172 
01173 
01174 /**
01175  * How to forward a connection to a parent proxy.
01176  */
01177 struct forward_spec
01178 {
01179    /** URL pattern that this forward_spec is for. */
01180    struct url_spec url[1];
01181 
01182    /** Connection type.  Must be SOCKS_NONE, SOCKS_4, or SOCKS_4A. */
01183    int   type;
01184 
01185    /** SOCKS server hostname.  Only valid if "type" is SOCKS_4 or SOCKS_4A. */
01186    char *gateway_host;
01187 
01188    /** SOCKS server port. */
01189    int   gateway_port;
01190 
01191    /** Parent HTTP proxy hostname, or NULL for none. */
01192    char *forward_host;
01193 
01194    /** Parent HTTP proxy port. */
01195    int   forward_port;
01196 
01197    /** Next entry in the linked list. */
01198    struct forward_spec *next;
01199 };
01200 
01201 
01202 /**
01203  * Initializer for a static struct forward_spec.
01204  */
01205 #define FORWARD_SPEC_INITIALIZER { { URL_SPEC_INITIALIZER }, 0, NULL, 0, NULL, 0, NULL }
01206 
01207 
01208 /**
01209  * This struct represents one filter (one block) from
01210  * the re_filterfile. If there is more than one filter
01211  * in the file, the file will be represented by a
01212  * chained list of re_filterfile specs.
01213  */
01214 struct re_filterfile_spec
01215 {
01216    char *name;                      /**< Name from FILTER: statement in re_filterfile. */
01217    char *description;               /**< Description from FILTER: statement in re_filterfile. */
01218    struct list patterns[1];         /**< The patterns from the re_filterfile. */
01219    pcrs_job *joblist;               /**< The resulting compiled pcrs_jobs. */
01220    struct re_filterfile_spec *next; /**< The pointer for chaining. */
01221 };
01222 
01223 
01224 #ifdef FEATURE_ACL
01225 
01226 #define ACL_PERMIT   1  /**< Accept connection request */
01227 #define ACL_DENY     2  /**< Reject connection request */
01228 
01229 /**
01230  * An IP address pattern.  Used to specify networks in the ACL.
01231  */
01232 struct access_control_addr
01233 {
01234    unsigned long addr;  /**< The IP address as an integer. */
01235    unsigned long mask;  /**< The network mask as an integer. */
01236    unsigned long port;  /**< The port number. */
01237 };
01238 
01239 /**
01240  * An access control list (ACL) entry.
01241  *
01242  * This is a linked list.
01243  */
01244 struct access_control_list
01245 {
01246    struct access_control_addr src[1];  /**< Client IP address */
01247    struct access_control_addr dst[1];  /**< Website or parent proxy IP address */
01248 
01249    short action;                       /**< ACL_PERMIT or ACL_DENY */
01250    struct access_control_list *next;   /**< The next entry in the ACL. */
01251 };
01252 
01253 #endif /* def FEATURE_ACL */
01254 
01255 
01256 /** Maximum number of loaders (actions, re_filter, ...) */
01257 #define NLOADERS 8
01258 
01259 
01260 /** configuration_spec::feature_flags: CGI actions editor. */
01261 #define RUNTIME_FEATURE_CGI_EDIT_ACTIONS  1
01262 
01263 /** configuration_spec::feature_flags: Web-based toggle. */
01264 #define RUNTIME_FEATURE_CGI_TOGGLE        2
01265 
01266 
01267 /**
01268  * Data loaded from the configuration file.
01269  *
01270  * (Anomaly: toggle is still handled through a global, not this structure)
01271  */
01272 struct configuration_spec
01273 {
01274    /** What to log */
01275    int debug;
01276    
01277    /** Nonzero to enable multithreading. */
01278    int multi_threaded;
01279 
01280    /**
01281     * Bitmask of features that can be enabled/disabled through the config
01282     * file.  Currently defined bits:
01283     *
01284     * - RUNTIME_FEATURE_CGI_EDIT_ACTIONS
01285     * - RUNTIME_FEATURE_CGI_TOGGLE
01286     */
01287    unsigned feature_flags;
01288 
01289    /** The log file name. */
01290    const char *logfile;
01291 
01292    /** The config file directory. */
01293    const char *confdir;
01294 
01295    /** The log file directory. */
01296    const char *logdir;
01297 
01298    /** The full paths to the actions files. */
01299    const char *actions_file[MAX_ACTION_FILES];
01300 
01301    /** The short names of the actions files. */
01302    const char *actions_file_short[MAX_ACTION_FILES];
01303 
01304    /** The administrator's email address */
01305    char *admin_address;
01306 
01307    /** A URL with info on this proxy */
01308    char *proxy_info_url;
01309 
01310    /** URL to the user manual (on our website or local copy) */
01311    char *usermanual;
01312 
01313    /** The file name of the pcre filter file */
01314    const char *re_filterfile;
01315 
01316 #ifdef FEATURE_COOKIE_JAR
01317 
01318    /** The file name of the cookie jar file */
01319    const char * jarfile;
01320 
01321    /** The handle to the cookie jar file */
01322    FILE * jar;
01323 
01324 #endif /* def FEATURE_COOKIE_JAR */
01325 
01326    /** IP address to bind to.  Defaults to HADDR_DEFAULT == 127.0.0.1. */
01327    const char *haddr;
01328 
01329    /** Port to bind to.  Defaults to HADDR_PORT == 8118. */
01330    int         hport;
01331 
01332    /** Size limit for IOB */
01333    size_t buffer_limit;
01334 
01335 #ifdef FEATURE_TRUST
01336 
01337    /** The file name of the trust file. */
01338    const char * trustfile;
01339 
01340    /** FIXME: DOCME: Document this. */
01341    struct list trust_info[1];
01342 
01343    /** FIXME: DOCME: Document this. */
01344    struct url_spec *trust_list[64];
01345 
01346 #endif /* def FEATURE_TRUST */
01347 
01348 #ifdef FEATURE_ACL
01349 
01350    /** The access control list (ACL). */
01351    struct access_control_list *acl;
01352 
01353 #endif /* def FEATURE_ACL */
01354 
01355    /** Information about parent proxies (forwarding). */
01356    struct forward_spec *forward;
01357 
01358    /** All options from the config file, HTML-formatted. */
01359    char *proxy_args;
01360 
01361    /** The configuration file object. */
01362    struct file_list *config_file_list;
01363 
01364    /** List of loaders */
01365    int (*loaders[NLOADERS])(struct client_state *);
01366 
01367    /** Nonzero if we need to bind() to the new port. */
01368    int need_bind;
01369 };
01370 
01371 /** Calculates the number of elements in an array, using sizeof. */
01372 #define SZ(X)  (sizeof(X) / sizeof(*X))
01373 
01374 #ifdef FEATURE_FORCE_LOAD
01375 /** The force load URL prefix. */
01376 #define FORCE_PREFIX "/PRIVOXY-FORCE"
01377 #endif /* def FEATURE_FORCE_LOAD */
01378 
01379 #ifdef FEATURE_NO_GIFS
01380 /** The MIME type for images ("image/png" or "image/gif"). */
01381 #define BUILTIN_IMAGE_MIMETYPE "image/png"
01382 #else
01383 #define BUILTIN_IMAGE_MIMETYPE "image/gif"
01384 #endif /* def FEATURE_NO_GIFS */
01385 
01386 
01387 /* 
01388  * Hardwired URLs
01389  */
01390 
01391 /** URL for the Privoxy home page. */
01392 #define HOME_PAGE_URL     "http://www.privoxy.org/"
01393 
01394 /** URL for the Privoxy user manual. */
01395 #define USER_MANUAL_URL   HOME_PAGE_URL "/" VERSION "/user-manual/"
01396 
01397 /** Prefix for actions help links  (append to USER_MANUAL_URL). */
01398 #define ACTIONS_HELP_PREFIX "actions-file.html#"
01399 
01400 /** Prefix for config option help links (append to USER_MANUAL_URL). */
01401 #define CONFIG_HELP_PREFIX  "config.html#"
01402 
01403 /*
01404  * The "hosts" to intercept and display CGI pages.
01405  * First one is a hostname only, second one can specify host and path.
01406  *
01407  * Notes:
01408  * 1) Do not specify the http: prefix
01409  * 2) CGI_SITE_2_PATH must not end with /, one will be added automatically.
01410  * 3) CGI_SITE_2_PATH must start with /, unless it is the empty string.
01411  */
01412 #define CGI_SITE_1_HOST "p.p"
01413 #define CGI_SITE_2_HOST "config.privoxy.org"
01414 #define CGI_SITE_2_PATH ""
01415 
01416 /**
01417  * The prefix for CGI pages.  Written out in generated HTML.
01418  * INCLUDES the trailing slash.
01419  */
01420 #define CGI_PREFIX  "http://" CGI_SITE_2_HOST CGI_SITE_2_PATH "/"
01421 
01422 
01423 #ifdef __cplusplus
01424 } /* extern "C" */
01425 #endif
01426 
01427 #endif /* ndef PROJECT_H_INCLUDED */
01428 
01429 /*
01430   Local Variables:
01431   tab-width: 3
01432   end:
01433 */

Generated on Tue Jun 4 18:54:48 2002 for Privoxy 3.1.1 by doxygen1.2.15