- Added support for Perl's special variables $+, $' and $`
[privoxy.git] / project.h
1 #ifndef PROJECT_H_INCLUDED
2 #define PROJECT_H_INCLUDED
3 #define PROJECT_H_VERSION "$Id: project.h,v 1.26 2001/07/30 22:08:36 jongfoster Exp $"
4 /*********************************************************************
5  *
6  * File        :  $Source: /cvsroot/ijbswa/current/project.h,v $
7  *
8  * Purpose     :  Defines data structures which are widely used in the
9  *                project.  Does not define any variables or functions
10  *                (though it does declare some macros).
11  *
12  * Copyright   :  Written by and Copyright (C) 2001 the SourceForge
13  *                IJBSWA team.  http://ijbswa.sourceforge.net
14  *
15  *                Based on the Internet Junkbuster originally written
16  *                by and Copyright (C) 1997 Anonymous Coders and 
17  *                Junkbusters Corporation.  http://www.junkbusters.com
18  *
19  *                This program is free software; you can redistribute it 
20  *                and/or modify it under the terms of the GNU General
21  *                Public License as published by the Free Software
22  *                Foundation; either version 2 of the License, or (at
23  *                your option) any later version.
24  *
25  *                This program is distributed in the hope that it will
26  *                be useful, but WITHOUT ANY WARRANTY; without even the
27  *                implied warranty of MERCHANTABILITY or FITNESS FOR A
28  *                PARTICULAR PURPOSE.  See the GNU General Public
29  *                License for more details.
30  *
31  *                The GNU General Public License should be included with
32  *                this file.  If not, you can view it at
33  *                http://www.gnu.org/copyleft/gpl.html
34  *                or write to the Free Software Foundation, Inc., 59
35  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
36  *
37  * Revisions   :
38  *    $Log: project.h,v $
39  *    Revision 1.26  2001/07/30 22:08:36  jongfoster
40  *    Tidying up #defines:
41  *    - All feature #defines are now of the form FEATURE_xxx
42  *    - Permanently turned off WIN_GUI_EDIT
43  *    - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
44  *
45  *    Revision 1.25  2001/07/29 18:43:08  jongfoster
46  *    Changing #ifdef _FILENAME_H to FILENAME_H_INCLUDED, to conform to
47  *    ANSI C rules.
48  *
49  *    Revision 1.24  2001/07/25 17:20:27  oes
50  *    Introduced http->user_agent
51  *
52  *    Revision 1.23  2001/07/18 12:32:23  oes
53  *    - Added ACTION_STRING_DEANIMATE
54  *    - moved #define freez from jcc.h to project.h
55  *
56  *    Revision 1.22  2001/07/15 17:51:41  jongfoster
57  *    Renaming #define STATIC to STATIC_PCRE
58  *
59  *    Revision 1.21  2001/07/13 14:03:19  oes
60  *     - Reorganized regex header inclusion and #defines to
61  *       comply to the scheme in configure.in
62  *     - Added csp->content_type and its CT_* keys
63  *     - Added ACTION_DEANIMATE
64  *     - Removed all #ifdef PCRS
65  *
66  *    Revision 1.20  2001/06/29 21:45:41  oes
67  *    Indentation, CRLF->LF, Tab-> Space
68  *
69  *    Revision 1.19  2001/06/29 13:33:36  oes
70  *    - Improved comments
71  *    - Introduced http_request.host_ip_addr_str
72  *    - Introduced http_response.head_length
73  *    - Introduced config.my_ip_addr_str, config.my_hostname,
74  *      config.admin_address and config.proxy_info_url
75  *    - Removed config.proxy_args_header and config.proxy_args_trailer,
76  *      renamed config.proxy_args_invocation to config.proxy_args
77  *    - Removed HTML snipplets and GIFs
78  *    - Removed logentry from cancelled commit
79  *
80  *    Revision 1.18  2001/06/09 10:57:39  jongfoster
81  *    Adding definition of BUFFER_SIZE.
82  *    Changing struct cgi_dispatcher to use "const" strings.
83  *
84  *    Revision 1.17  2001/06/07 23:15:09  jongfoster
85  *    Merging ACL and forward files into config file.
86  *    Moving struct gateway members into struct forward_spec
87  *    Removing config->proxy_args_gateways
88  *    Cosmetic: Adding a few comments
89  *
90  *    Revision 1.16  2001/06/04 18:31:58  swa
91  *    files are now prefixed with either `confdir' or `logdir'.
92  *    `make redhat-dist' replaces both entries confdir and logdir
93  *    with redhat values
94  *
95  *    Revision 1.15  2001/06/04 11:28:53  swa
96  *    redirect did not work due to missing /
97  *
98  *    Revision 1.14  2001/06/03 11:03:48  oes
99  *    Added struct map,
100  *    added struct http_response,
101  *    changed struct interceptors to struct cgi_dispatcher,
102  *    moved HTML stuff to cgi.h
103  *
104  *    Revision 1.13  2001/06/01 20:05:36  jongfoster
105  *    Support for +image-blocker{}: added ACTION_IMAGE_BLOCKER
106  *    constant, and removed csp->tinygif.
107  *
108  *    Revision 1.12  2001/06/01 18:49:17  jongfoster
109  *    Replaced "list_share" with "list" - the tiny memory gain was not
110  *    worth the extra complexity.
111  *
112  *    Revision 1.11  2001/06/01 10:32:47  oes
113  *    Added constants for anchoring selection bitmap
114  *
115  *    Revision 1.10  2001/05/31 21:33:53  jongfoster
116  *    Changes for new actions file, replacing permissionsfile
117  *    and parts of the config file.  Also added support for
118  *    list_shared.
119  *
120  *    Revision 1.9  2001/05/31 17:32:31  oes
121  *
122  *     - Enhanced domain part globbing with infix and prefix asterisk
123  *       matching and optional unanchored operation
124  *
125  *    Revision 1.8  2001/05/29 20:09:15  joergs
126  *    HTTP_REDIRECT_TEMPLATE fixed.
127  *
128  *    Revision 1.7  2001/05/29 09:50:24  jongfoster
129  *    Unified blocklist/imagelist/actionslist.
130  *    File format is still under discussion, but the internal changes
131  *    are (mostly) done.
132  *
133  *    Also modified interceptor behaviour:
134  *    - We now intercept all URLs beginning with one of the following
135  *      prefixes (and *only* these prefixes):
136  *        * http://i.j.b/
137  *        * http://ijbswa.sf.net/config/
138  *        * http://ijbswa.sourceforge.net/config/
139  *    - New interceptors "home page" - go to http://i.j.b/ to see it.
140  *    - Internal changes so that intercepted and fast redirect pages
141  *      are not replaced with an image.
142  *    - Interceptors now have the option to send a binary page direct
143  *      to the client. (i.e. ijb-send-banner uses this)
144  *    - Implemented show-url-info interceptor.  (Which is why I needed
145  *      the above interceptors changes - a typical URL is
146  *      "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
147  *      The previous mechanism would not have intercepted that, and
148  *      if it had been intercepted then it then it would have replaced
149  *      it with an image.)
150  *
151  *    Revision 1.6  2001/05/27 22:17:04  oes
152  *
153  *    - re_process_buffer no longer writes the modified buffer
154  *      to the client, which was very ugly. It now returns the
155  *      buffer, which it is then written by chat.
156  *
157  *    - content_length now adjusts the Content-Length: header
158  *      for modified documents rather than crunch()ing it.
159  *      (Length info in csp->content_length, which is 0 for
160  *      unmodified documents)
161  *
162  *    - For this to work, sed() is called twice when filtering.
163  *
164  *    Revision 1.5  2001/05/26 00:28:36  jongfoster
165  *    Automatic reloading of config file.
166  *    Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
167  *    Most of the global variables have been moved to a new
168  *    struct configuration_spec, accessed through csp->config->globalname
169  *    Most of the globals remaining are used by the Win32 GUI.
170  *
171  *    Revision 1.4  2001/05/22 18:46:04  oes
172  *
173  *    - Enabled filtering banners by size rather than URL
174  *      by adding patterns that replace all standard banner
175  *      sizes with the "Junkbuster" gif to the re_filterfile
176  *
177  *    - Enabled filtering WebBugs by providing a pattern
178  *      which kills all 1x1 images
179  *
180  *    - Added support for PCRE_UNGREEDY behaviour to pcrs,
181  *      which is selected by the (nonstandard and therefore
182  *      capital) letter 'U' in the option string.
183  *      It causes the quantifiers to be ungreedy by default.
184  *      Appending a ? turns back to greedy (!).
185  *
186  *    - Added a new interceptor ijb-send-banner, which
187  *      sends back the "Junkbuster" gif. Without imagelist or
188  *      MSIE detection support, or if tinygif = 1, or the
189  *      URL isn't recognized as an imageurl, a lame HTML
190  *      explanation is sent instead.
191  *
192  *    - Added new feature, which permits blocking remote
193  *      script redirects and firing back a local redirect
194  *      to the browser.
195  *      The feature is conditionally compiled, i.e. it
196  *      can be disabled with --disable-fast-redirects,
197  *      plus it must be activated by a "fast-redirects"
198  *      line in the config file, has its own log level
199  *      and of course wants to be displayed by show-proxy-args
200  *      Note: Boy, all the #ifdefs in 1001 locations and
201  *      all the fumbling with configure.in and acconfig.h
202  *      were *way* more work than the feature itself :-(
203  *
204  *    - Because a generic redirect template was needed for
205  *      this, tinygif = 3 now uses the same.
206  *
207  *    - Moved GIFs, and other static HTTP response templates
208  *      to project.h
209  *
210  *    - Some minor fixes
211  *
212  *    - Removed some >400 CRs again (Jon, you really worked
213  *      a lot! ;-)
214  *
215  *    Revision 1.3  2001/05/20 01:21:20  jongfoster
216  *    Version 2.9.4 checkin.
217  *    - Merged popupfile and cookiefile, and added control over PCRS
218  *      filtering, in new "actionsfile".
219  *    - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
220  *      file error you now get a message box (in the Win32 GUI) rather
221  *      than the program exiting with no explanation.
222  *    - Made killpopup use the PCRS MIME-type checking and HTTP-header
223  *      skipping.
224  *    - Removed tabs from "config"
225  *    - Moved duplicated url parsing code in "loaders.c" to a new funcition.
226  *    - Bumped up version number.
227  *
228  *    Revision 1.2  2001/05/17 23:01:01  oes
229  *     - Cleaned CRLF's from the sources and related files
230  *
231  *    Revision 1.1.1.1  2001/05/15 13:59:03  oes
232  *    Initial import of version 2.9.3 source tree
233  *
234  *
235  *********************************************************************/
236 \f
237
238 /* Declare struct FILE for vars and funcs. */
239 #include <stdio.h>
240
241 /* Need time_t for file_list */
242 #include <time.h>
243
244 /*
245  * Include appropriate regular expression libraries.
246  * Note that pcrs and pcre (native) are needed for cgi
247  * and are included anyway.
248  */
249
250 #if defined(REGEX_PCRE) || defined (REGEX_GNU)
251 # define REGEX
252 #endif /* defined(REGEX_PCRE) || defined (REGEX_GNU) */
253
254 #ifdef STATIC_PCRE
255 #  include "pcre.h"
256 #else
257 #  include <pcre.h>
258 #endif
259
260 #ifdef STATIC_PCRS
261 #  include "pcrs.h" 
262 #else
263 #  include <pcrs.h> 
264 #endif
265
266 #if defined(REGEX_PCRE)
267 #  ifdef STATIC_PCRE
268 #    include "pcreposix.h"
269 #  else
270 #    include <pcreposix.h>
271 #  endif
272 #endif /* defined(REGEX_PCRE) */
273
274 #if defined(REGEX_GNU)
275 #  include "gnu_regex.h"
276 #endif
277
278 #ifdef AMIGA 
279 #include "amiga.h" 
280 #endif /* def AMIGA */
281
282 #ifdef __cplusplus
283 extern "C" {
284 #endif
285
286 #define freez(X)  if(X) free(X); X = NULL
287
288 #define BUFFER_SIZE 5000
289
290 #define FOREVER 1
291
292 /* Default IP and port to listen on */
293 #define HADDR_DEFAULT   "127.0.0.1"
294 #define HADDR_PORT      8000
295
296
297 /* Need this for struct client_state */
298 struct configuration_spec;
299
300 /* Generic linked list of strings */
301 struct list /* FIXME: Why not separate entries and header? */
302 {
303    char *       str;  /* valid in an entry */
304    struct list *last; /* valid in header */
305    struct list *next;
306 };
307
308 struct map_entry
309 {
310    const char *name;
311    const char *value;
312    struct map_entry *next;
313 };
314
315 struct map
316 {
317    struct map_entry *first;
318    struct map_entry *last;
319 };
320
321 struct http_request
322 {
323    char *cmd;
324    char *gpc;
325    char *host;
326    char *host_ip_addr_str; /* NULL before connect_to() */
327    int   port;
328    char *path;
329    char *ver;
330    char *hostport; /* "host[:port]" */
331    int   ssl;
332    char *user_agent; /* Client's User-Agent: header value */
333 };
334
335 /* Response generated by CGI, blocker, or error handler */
336 struct http_response
337 {
338   char *status;           /* HTTP status (string)*/
339   struct list headers[1]; /* List of header lines */
340   char *head;             /* Formatted http response head */
341   int   head_length;      /* Length of http response head */
342   char *body;             /* HTTP document body */
343   int   content_length;   /* Length of body, REQUIRED if binary body*/
344 };
345
346 /* A URL pattern */
347 struct url_spec
348 {
349    char  *spec;        /* The string which was parsed to produce this       */
350                        /* url_spec.  Used for debugging or display only.    */
351
352    /* Hostname matching: */
353    char  *domain;      /* Fully qalified domain name (FQDN) pattern.        */
354                        /* May contain "*".                                  */
355    char  *dbuf;        /* Buffer with '\0'-delimited fqdn                   */
356    char **dvec;        /* Domain ptr vector into dbuf                       */
357    int    dcnt;        /* How many domains in fqdn?                         */
358    int    unanchored;  /* Bitmap - flags are ANCHOR_LEFT and ANCHOR_RIGHT   */
359
360    /* Port matching: */
361    int   port;         /* The port number, or 0 to match all ports.         */
362
363    /* Path matching: */
364    char *path;         /* The path prefix (if not using regex), or source   */
365                        /* for the regex.                                    */
366    int   pathlen;      /* ==strlen(path).  Needed for prefix matching.      */
367 #ifdef REGEX
368    regex_t *preg;      /* Regex for matching path part                      */
369 #endif
370 };
371
372 /* Constants for host part matching in URLs */
373 #define ANCHOR_LEFT  1
374 #define ANCHOR_RIGHT 2
375
376
377 /* An I/O buffer */
378 struct iob
379 {
380    char *buf;
381    char *cur;
382    char *eod;
383 };
384
385
386 #define IOB_PEEK(CSP) ((CSP->iob->cur > CSP->iob->eod) ? (CSP->iob->eod - CSP->iob->cur) : 0)
387 #define IOB_RESET(CSP) if(CSP->iob->buf) free(CSP->iob->buf); memset(CSP->iob, '\0', sizeof(CSP->iob));
388
389 /* Keys for csp->content_type */
390 #define CT_TEXT 0x01U
391 #define CT_GIF  0x02U
392
393 #define ACTION_MASK_ALL        (~0U)
394
395 #define ACTION_MOST_COMPATIBLE 0x0000U
396
397 #define ACTION_BLOCK           0x0001U
398 #define ACTION_DEANIMATE       0x2000U
399 #define ACTION_FAST_REDIRECTS  0x0002U
400 #define ACTION_FILTER          0x0004U
401 #define ACTION_HIDE_FORWARDED  0x0008U
402 #define ACTION_HIDE_FROM       0x0010U
403 #define ACTION_HIDE_REFERER    0x0020U /* sic - follow HTTP, not English */
404 #define ACTION_HIDE_USER_AGENT 0x0040U
405 #define ACTION_IMAGE           0x0080U
406 #define ACTION_IMAGE_BLOCKER   0x0100U
407 #define ACTION_NO_COOKIE_READ  0x0200U
408 #define ACTION_NO_COOKIE_SET   0x0400U
409 #define ACTION_NO_POPUPS       0x0800U
410 #define ACTION_VANILLA_WAFER   0x1000U
411
412 #define ACTION_STRING_DEANIMATE     0
413 #define ACTION_STRING_FROM          1
414 #define ACTION_STRING_IMAGE_BLOCKER 2
415 #define ACTION_STRING_REFERER       3
416 #define ACTION_STRING_USER_AGENT    4
417 #define ACTION_STRING_COUNT         5
418
419
420 #define ACTION_MULTI_ADD_HEADER     0
421 #define ACTION_MULTI_WAFER          1
422 #define ACTION_MULTI_COUNT          2
423
424 /*
425  * This structure contains a list of actions to apply to a URL.
426  * It only contains positive instructions - no "-" options.
427  * It is not used to store the actions list itself, only for
428  * url_actions() to return the current values.
429  */
430 struct current_action_spec
431 {
432    unsigned flags;    /* a bit set to "1" = add action    */
433
434    /* For those actions that require parameters: */
435
436    /* each entry is valid if & only if corresponding entry in "add" set. */
437    char * string[ACTION_STRING_COUNT];
438
439    /* Strings to add */
440    struct list multi[ACTION_MULTI_COUNT][1];
441 };
442
443
444 /*
445  * This structure contains a set of changes to actions.
446  * It can contain both positive and negative instructions.
447  * It is used to store an entry in the actions list.
448  */
449 struct action_spec
450 {
451    unsigned mask;   /* a bit set to "0" = remove action */
452    unsigned add;    /* a bit set to "1" = add action    */
453
454    /* For those actions that require parameters: */
455
456    /* each entry is valid if & only if corresponding entry in "add" set. */
457    char * string[ACTION_STRING_COUNT];
458
459    /* Strings to remove. */
460    struct list multi_remove[ACTION_MULTI_COUNT][1];
461
462    /* If nonzero, remove *all* strings. */
463    int         multi_remove_all[ACTION_MULTI_COUNT];
464
465    /* Strings to add */
466    struct list multi_add[ACTION_MULTI_COUNT][1];
467 };
468
469 /*
470  * This structure is used to store the actions list.
471  *
472  * It contains a URL pattern, and the chages to the actions.
473  * It is a linked list.
474  */
475 struct url_actions
476 {
477    struct url_spec url[1];
478
479    struct action_spec action[1];
480
481    struct url_actions * next;
482 };
483
484
485 /* Constants defining bitmask for csp->accept_types */
486
487 #ifdef FEATURE_IMAGE_DETECT_MSIE
488
489 /* MSIE detected by user-agent string */
490 #define ACCEPT_TYPE_IS_MSIE     0x0001
491
492 /*
493  * *If* this is MSIE, it wants an image.  (Or this is a shift-reload, or
494  * it's got an image from this URL before...  yuck!)
495  * Only meaningful if ACCEPT_TYPE_IS_MSIE set 
496  */
497 #define ACCEPT_TYPE_MSIE_IMAGE  0x0002
498
499 /*
500  * *If* this is MSIE, it wants a HTML document.
501  * Only meaningful if ACCEPT_TYPE_IS_MSIE set
502  */
503 #define ACCEPT_TYPE_MSIE_HTML   0x0004
504
505 #endif /* def FEATURE_IMAGE_DETECT_MSIE */
506
507
508 struct client_state
509 {
510    /* The proxy's configuration */
511    struct configuration_spec * config;
512
513    /* The actions to perform on the current request */
514    struct current_action_spec  action[1];
515
516    /* socket to talk to client (web browser) */
517    int  cfd;
518
519    /* socket to talk to server (web server or proxy) */
520    int  sfd;
521
522
523 #ifdef FEATURE_STATISTICS
524    /* 1 if this URL was rejected, 0 otherwise. Allows actual stats inc to 
525     * occur in main thread only for thread-safety. 
526     */
527    int  rejected;
528 #endif /* def FEATURE_STATISTICS */
529
530 #ifdef FEATURE_FORCE_LOAD
531    int force;
532 #endif /* def FEATURE_FORCE_LOAD */
533
534 #ifdef FEATURE_TOGGLE
535    int   toggled_on;
536 #endif /* def FEATURE_TOGGLE */
537
538    /*
539     * Client PC's IP address, as reported by the accept()_ function.
540     * Both as string and number
541     */
542    char *ip_addr_str;
543    long  ip_addr_long;
544
545
546    /* Our IP address and hostname, i.e. the IP address that
547       the client used to reach us, and the associated hostname,
548       both as strings
549     */
550    char *my_ip_addr_str;
551    char *my_hostname;
552
553 #ifdef FEATURE_TRUST
554    /* The referer in this request, if one was specified. */
555    char *referrer;
556 #endif /* def FEATURE_TRUST */
557
558 #if defined(FEATURE_IMAGE_DETECT_MSIE)
559    /* Types the client will accept.
560     * Bitmask - see ACCEPT_TYPE_XXX constants.
561     */
562    int accept_types;
563 #endif /* defined(FEATURE_IMAGE_DETECT_MSIE) */
564
565    /* The URL that was requested */
566    struct http_request http[1];
567
568    /* An I/O buffer used for buffering data read from the client */
569    struct iob iob[1];
570
571    /* List of all headers for this request */
572    struct list headers[1];
573
574    /* List of all cookies for this request */
575    struct list cookie_list[1];
576
577    /* MIME-Type bitmap, see CT_* above */
578    unsigned char content_type;
579
580    /* The "X-Forwarded-For:" header sent by the client */
581    char   *x_forwarded;
582
583    /*
584     * Nonzero if this client is processing data.
585     * Set to zero when the thread associated with this structure dies.
586     */
587    int active;
588
589    /* files associated with this client */
590    struct file_list *actions_list;
591
592    struct file_list *rlist;   /* pcrs job file */
593    size_t content_length;     /* Length after content modification */ 
594
595 #ifdef FEATURE_TRUST
596    struct file_list *tlist;   /* trustfile */
597 #endif /* def FEATURE_TRUST */
598
599    struct client_state *next;
600 };
601
602
603 struct parsers
604 {
605    char *str;
606    char  len;
607    char *(*parser)(const struct parsers *, char *, struct client_state *);
608 };
609
610 struct cgi_dispatcher
611 {
612    const char *name;
613    int         name_length;
614    int         (*handler)(struct client_state *csp, struct http_response *rsp, struct map *parameters);
615    const char *description;
616 };
617
618 struct file_list
619 {
620    /*
621     * this is a pointer to the data structures associated with the file.
622     * Read-only once the structure has been created.
623     */
624    void *f;
625    
626    /* Normally NULL.  When we are finished with file (i.e. when we have
627     * loaded a new one), set to a pointer to an unloader function.
628     * Unloader will be called by sweep() (called from main loop) when
629     * all clients using this file are done.  This prevents threading 
630     * problems.
631     */
632    void (*unloader)(void *);
633
634    /* Used internally by sweep().  Do not access from elsewhere. */
635    int active;
636
637    /* Following variables allow us to check if file has been changed.
638     * Read-only once the structure has been created.
639     */
640    time_t lastmodified;
641    char * filename;
642
643    /* Pointer to next entry in the linked list of all "file_list"s.
644     * This linked list is so that sweep() can navigate it.
645     * Since sweep() can remove items from the list, we must be careful
646     * to only access this value from main thread (when we know sweep
647     * won't be running).
648     */
649    struct file_list *next;
650 };
651
652
653 #ifdef FEATURE_TRUST
654 struct block_spec
655 {
656    struct url_spec url[1];
657    int    reject;
658    struct block_spec *next;
659 };
660 #endif /* def FEATURE_TRUST */
661
662
663 #define SOCKS_NONE    0    /* Don't use a SOCKS server */
664 #define SOCKS_4      40    /* original SOCKS 4 protocol */
665 #define SOCKS_4A     41    /* as modified for hosts w/o external DNS */
666
667 struct forward_spec
668 {
669    struct url_spec url[1];
670
671    /* Connection type - must be a SOCKS_xxx constant */
672    int   type;
673
674    /* SOCKS server */
675    char *gateway_host;
676    int   gateway_port;
677
678    /* Parent HTTP proxy */
679    char *forward_host;
680    int   forward_port;
681
682    /* For the linked list */
683    struct forward_spec *next;
684 };
685
686 struct re_filterfile_spec
687 {
688    char *username;
689    char *filtername;
690    struct list patterns[1];
691    pcrs_job *joblist;
692 };
693
694 #ifdef FEATURE_ACL
695 #define ACL_PERMIT   1  /* accept connection request */
696 #define ACL_DENY     2  /* reject connection request */
697
698 struct access_control_addr
699 {
700    unsigned long addr;
701    unsigned long mask;
702    unsigned long port;
703 };
704
705 struct access_control_list
706 {
707    struct access_control_addr src[1];
708    struct access_control_addr dst[1];
709
710    short action;
711    struct access_control_list *next;
712 };
713 #endif /* def FEATURE_ACL */
714
715
716 /* Maximum number of loaders (actions, re_filter, ...) */
717 #define NLOADERS 8
718
719 /*
720  * Data loaded from the configuration file.
721  *
722  * (Anomaly: toggle is still handled through a global, not this structure)
723  */
724 struct configuration_spec
725 {
726    int debug;
727    int multi_threaded;
728
729    const char *logfile;
730
731    const char *confdir;
732    const char *logdir;
733    const char *actions_file;
734
735    /* The administrator's email address */
736    char *admin_address;
737
738    /* A URL with info on this proxy */
739    char *proxy_info_url;
740
741    const char *re_filterfile;
742
743 #ifdef FEATURE_COOKIE_JAR
744    const char * jarfile;
745    FILE * jar;
746 #endif /* def FEATURE_COOKIE_JAR */
747
748    /*
749     * Port and IP to bind to.
750     * Defaults to HADDR_DEFAULT:HADDR_PORT == 127.0.0.1:8000
751     */
752    const char *haddr;
753    int         hport;
754
755 #ifdef FEATURE_TRUST
756    const char * trustfile;
757
758    struct list trust_info[1];
759    struct url_spec *trust_list[64];
760 #endif /* def FEATURE_TRUST */
761
762 #ifdef FEATURE_ACL
763    struct access_control_list *acl;
764 #endif /* def FEATURE_ACL */
765
766    struct forward_spec *forward;
767
768    /* All options from the config file, HTML-formatted */
769    char *proxy_args;
770
771    /* the configuration file object. */
772    struct file_list *config_file_list;
773
774    /* List of loaders */
775    int (*loaders[NLOADERS])(struct client_state *);
776
777    /* bool, nonzero if we need to bind() to the new port */
778    int need_bind;
779 };
780
781
782 #define SZ(X)  (sizeof(X) / sizeof(*X))
783
784 #ifdef FEATURE_FORCE_LOAD
785 #define FORCE_PREFIX "/IJB-FORCE-LOAD"
786 #endif /* def FEATURE_FORCE_LOAD */
787
788 /* Hardwired URLs */
789 #define HOME_PAGE_URL  "http://ijbswa.sourceforge.net"
790 #define REDIRECT_URL HOME_PAGE_URL "/redirect.php?v=" VERSION "&to="
791 #define CGI_PREFIX_HOST "i.j.b"
792
793 /* HTTP snipplets */
794 static const char CSUCCEED[] =
795    "HTTP/1.0 200 Connection established\n"
796    "Proxy-Agent: IJ/" VERSION "\n\n";
797
798 static const char CHEADER[] =
799    "HTTP/1.0 400 Invalid header received from browser\n\n";
800
801 #ifdef __cplusplus
802 } /* extern "C" */
803 #endif
804
805 #endif /* ndef PROJECT_H_INCLUDED */
806
807 /*
808   Local Variables:
809   tab-width: 3
810   end:
811 */