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