- Cosmetics: renamed and reordered functions, variables,
[privoxy.git] / project.h
1 #ifndef _PROJECT_H
2 #define _PROJECT_H
3 #define PROJECT_H_VERSION "$Id: project.h,v 1.17 2001/06/07 23:15:09 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.17  2001/06/07 23:15:09  jongfoster
40  *    Merging ACL and forward files into config file.
41  *    Moving struct gateway members into struct forward_spec
42  *    Removing config->proxy_args_gateways
43  *    Cosmetic: Adding a few comments
44  *
45  *    Revision 1.16  2001/06/04 18:31:58  swa
46  *    files are now prefixed with either `confdir' or `logdir'.
47  *    `make redhat-dist' replaces both entries confdir and logdir
48  *    with redhat values
49  *
50  *    Revision 1.15  2001/06/04 11:28:53  swa
51  *    redirect did not work due to missing /
52  *
53  *    Revision 1.14  2001/06/03 11:03:48  oes
54  *    Makefile/in
55  *
56  *    introduced cgi.c
57  *
58  *    actions.c:
59  *
60  *    adapted to new enlist_unique arg format
61  *
62  *    conf loadcfg.c
63  *
64  *    introduced confdir option
65  *
66  *    filters.c filtrers.h
67  *
68  *     extracted-CGI relevant stuff
69  *
70  *    jbsockets.c
71  *
72  *     filled comment
73  *
74  *    jcc.c
75  *
76  *     support for new cgi mechansim
77  *
78  *    list.c list.h
79  *
80  *    functions for new list type: "map"
81  *    extended enlist_unique
82  *
83  *    miscutil.c .h
84  *    introduced bindup()
85  *
86  *    parsers.c parsers.h
87  *
88  *    deleted const struct interceptors
89  *
90  *    pcrs.c
91  *    added FIXME
92  *
93  *    project.h
94  *
95  *    added struct map
96  *    added struct http_response
97  *    changes struct interceptors to struct cgi_dispatcher
98  *    moved HTML stuff to cgi.h
99  *
100  *    re_filterfile:
101  *
102  *    changed
103  *
104  *    showargs.c
105  *    NO TIME LEFT
106  *
107  *    Revision 1.13  2001/06/01 20:05:36  jongfoster
108  *    Support for +image-blocker{}: added ACTION_IMAGE_BLOCKER
109  *    constant, and removed csp->tinygif.
110  *
111  *    Revision 1.12  2001/06/01 18:49:17  jongfoster
112  *    Replaced "list_share" with "list" - the tiny memory gain was not
113  *    worth the extra complexity.
114  *
115  *    Revision 1.11  2001/06/01 10:32:47  oes
116  *    Added constants for anchoring selection bitmap
117  *
118  *    Revision 1.10  2001/05/31 21:33:53  jongfoster
119  *    Changes for new actions file, replacing permissionsfile
120  *    and parts of the config file.  Also added support for
121  *    list_shared.
122  *
123  *    Revision 1.9  2001/05/31 17:32:31  oes
124  *
125  *     - Enhanced domain part globbing with infix and prefix asterisk
126  *       matching and optional unanchored operation
127  *
128  *    Revision 1.8  2001/05/29 20:09:15  joergs
129  *    HTTP_REDIRECT_TEMPLATE fixed.
130  *
131  *    Revision 1.7  2001/05/29 09:50:24  jongfoster
132  *    Unified blocklist/imagelist/actionslist.
133  *    File format is still under discussion, but the internal changes
134  *    are (mostly) done.
135  *
136  *    Also modified interceptor behaviour:
137  *    - We now intercept all URLs beginning with one of the following
138  *      prefixes (and *only* these prefixes):
139  *        * http://i.j.b/
140  *        * http://ijbswa.sf.net/config/
141  *        * http://ijbswa.sourceforge.net/config/
142  *    - New interceptors "home page" - go to http://i.j.b/ to see it.
143  *    - Internal changes so that intercepted and fast redirect pages
144  *      are not replaced with an image.
145  *    - Interceptors now have the option to send a binary page direct
146  *      to the client. (i.e. ijb-send-banner uses this)
147  *    - Implemented show-url-info interceptor.  (Which is why I needed
148  *      the above interceptors changes - a typical URL is
149  *      "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
150  *      The previous mechanism would not have intercepted that, and
151  *      if it had been intercepted then it then it would have replaced
152  *      it with an image.)
153  *
154  *    Revision 1.6  2001/05/27 22:17:04  oes
155  *
156  *    - re_process_buffer no longer writes the modified buffer
157  *      to the client, which was very ugly. It now returns the
158  *      buffer, which it is then written by chat.
159  *
160  *    - content_length now adjusts the Content-Length: header
161  *      for modified documents rather than crunch()ing it.
162  *      (Length info in csp->content_length, which is 0 for
163  *      unmodified documents)
164  *
165  *    - For this to work, sed() is called twice when filtering.
166  *
167  *    Revision 1.5  2001/05/26 00:28:36  jongfoster
168  *    Automatic reloading of config file.
169  *    Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
170  *    Most of the global variables have been moved to a new
171  *    struct configuration_spec, accessed through csp->config->globalname
172  *    Most of the globals remaining are used by the Win32 GUI.
173  *
174  *    Revision 1.4  2001/05/22 18:46:04  oes
175  *
176  *    - Enabled filtering banners by size rather than URL
177  *      by adding patterns that replace all standard banner
178  *      sizes with the "Junkbuster" gif to the re_filterfile
179  *
180  *    - Enabled filtering WebBugs by providing a pattern
181  *      which kills all 1x1 images
182  *
183  *    - Added support for PCRE_UNGREEDY behaviour to pcrs,
184  *      which is selected by the (nonstandard and therefore
185  *      capital) letter 'U' in the option string.
186  *      It causes the quantifiers to be ungreedy by default.
187  *      Appending a ? turns back to greedy (!).
188  *
189  *    - Added a new interceptor ijb-send-banner, which
190  *      sends back the "Junkbuster" gif. Without imagelist or
191  *      MSIE detection support, or if tinygif = 1, or the
192  *      URL isn't recognized as an imageurl, a lame HTML
193  *      explanation is sent instead.
194  *
195  *    - Added new feature, which permits blocking remote
196  *      script redirects and firing back a local redirect
197  *      to the browser.
198  *      The feature is conditionally compiled, i.e. it
199  *      can be disabled with --disable-fast-redirects,
200  *      plus it must be activated by a "fast-redirects"
201  *      line in the config file, has its own log level
202  *      and of course wants to be displayed by show-proxy-args
203  *      Note: Boy, all the #ifdefs in 1001 locations and
204  *      all the fumbling with configure.in and acconfig.h
205  *      were *way* more work than the feature itself :-(
206  *
207  *    - Because a generic redirect template was needed for
208  *      this, tinygif = 3 now uses the same.
209  *
210  *    - Moved GIFs, and other static HTTP response templates
211  *      to project.h
212  *
213  *    - Some minor fixes
214  *
215  *    - Removed some >400 CRs again (Jon, you really worked
216  *      a lot! ;-)
217  *
218  *    Revision 1.3  2001/05/20 01:21:20  jongfoster
219  *    Version 2.9.4 checkin.
220  *    - Merged popupfile and cookiefile, and added control over PCRS
221  *      filtering, in new "actionsfile".
222  *    - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
223  *      file error you now get a message box (in the Win32 GUI) rather
224  *      than the program exiting with no explanation.
225  *    - Made killpopup use the PCRS MIME-type checking and HTTP-header
226  *      skipping.
227  *    - Removed tabs from "config"
228  *    - Moved duplicated url parsing code in "loaders.c" to a new funcition.
229  *    - Bumped up version number.
230  *
231  *    Revision 1.2  2001/05/17 23:01:01  oes
232  *     - Cleaned CRLF's from the sources and related files
233  *
234  *    Revision 1.1.1.1  2001/05/15 13:59:03  oes
235  *    Initial import of version 2.9.3 source tree
236  *
237  *
238  *********************************************************************/
239 \f
240
241 /* Declare struct FILE for vars and funcs. */
242 #include <stdio.h>
243
244 /* Need time_t for file_list */
245 #include <time.h>
246
247 /*
248  * Include appropriate regular expression libraries.
249  *
250  * PCRS           ==> Include pcre
251  * REGEX && PCRE  ==> Include pcre and pcreposix
252  * REGEX && !PCRE ==> Include gnu_regex
253  *
254  * STATIC  ==> Use  #include "pcre.h"  (compiling at same time)
255  * !STATIC ==> Use  #include <pcre.h>  (System library)
256  *
257  */
258 #if (defined(REGEX) && defined(PCRE)) || defined(PCRS)
259 #  ifdef STATIC
260 #    include "pcre.h"
261 #  else
262 #    include <pcre.h>
263 #  endif
264 #endif /* (defined(REGEX) && defined(PCRE)) || defined(PCRS) */
265
266 #if defined(REGEX) && defined(PCRE)
267 #  ifdef STATIC
268 #    include "pcreposix.h"
269 #  else
270 #    include <pcreposix.h>
271 #  endif
272 #endif /* defined(REGEX) && defined(PCRE) */
273
274 #if defined(REGEX) && !defined(PCRE)
275 #  include "gnu_regex.h"
276 #endif
277
278 #ifdef PCRS
279 #include "pcrs.h"
280 #endif /* def PCRS */
281
282 #ifdef AMIGA 
283 #include "amiga.h" 
284 #endif /* def AMIGA */
285
286 #ifdef __cplusplus
287 extern "C" {
288 #endif
289 \r
290 #define BUFFER_SIZE 5000\r
291
292 #define FOREVER 1
293
294 /* Default IP and port to listen on */
295 #define HADDR_DEFAULT   "127.0.0.1"
296 #define HADDR_PORT      8000
297
298
299 /* Need this for struct client_state */
300 struct configuration_spec;
301
302 /* Generic linked list of strings */
303 struct list /* FIXME: Why not separate entries and header? */
304 {
305    char *       str;  /* valid in an entry */
306    struct list *last; /* valid in header */
307    struct list *next;
308 };
309
310 struct map
311 {
312   char *name;
313   char *value;
314   struct map *next;
315 };
316
317 struct http_request
318 {
319    char *cmd;
320    char *gpc;
321    char *host;
322    int   port;
323    char *path;
324    char *ver;
325    char *hostport; /* "host[:port]" */
326    int   ssl;
327 };
328
329 /* CGI or blocker generated response */
330 struct http_response
331 {
332   char *status;             /* HTTP status */
333   struct list headers[1]; /* List of header lines */
334   int content_length;     /* Length of body, REQUIRED if binary body*/
335   char *head;             /* Formatted http response head */
336   char *body;             /* HTTP document body */
337 };
338
339 /* A URL pattern */
340 struct url_spec
341 {
342    char  *spec;        /* The string which was parsed to produce this       */
343                        /* url_spec.  Used for debugging or display only.    */
344
345    /* Hostname matching: */
346    char  *domain;      /* Fully qalified domain name (FQDN) pattern.        */
347                        /* May contain "*".                                  */
348    char  *dbuf;        /* FIXME: Comment this                               */
349    char **dvec;        /* Domain ptr vector                                 */
350    int    dcnt;        /* How many domains in fqdn?                         */
351    int    unanchored;  /* Bitmap - flags are ANCHOR_LEFT and ANCHOR_RIGHT   */
352
353    /* Port matching: */
354    int   port;         /* The port number, or 0 to match all ports.         */
355
356    /* Path matching: */
357    char *path;         /* The path prefix (if not using regex), or source   */
358                        /* for the regex.                                    */
359    int   pathlen;      /* ==strlen(path).  Needed for prefix matching.      */
360 #ifdef REGEX
361    regex_t *preg;      /* Regex for matching path part                      */
362 #endif
363 };
364
365 #define ANCHOR_LEFT  1
366 #define ANCHOR_RIGHT 2
367
368
369
370 /* An I/O buffer */
371 struct iob
372 {
373    char *buf;
374    char *cur;
375    char *eod;
376 };
377
378
379 #define IOB_PEEK(CSP) ((CSP->iob->cur > CSP->iob->eod) ? (CSP->iob->eod - CSP->iob->cur) : 0)
380 #define IOB_RESET(CSP) if(CSP->iob->buf) free(CSP->iob->buf); memset(CSP->iob, '\0', sizeof(CSP->iob));
381
382
383
384 #define ACTION_MASK_ALL        (~0U)
385
386 #define ACTION_MOST_COMPATIBLE 0x0000U
387
388 #define ACTION_BLOCK           0x0001U
389 #define ACTION_FAST_REDIRECTS  0x0002U
390 #define ACTION_FILTER          0x0004U
391 #define ACTION_HIDE_FORWARDED  0x0008U
392 #define ACTION_HIDE_FROM       0x0010U
393 #define ACTION_HIDE_REFERER    0x0020U /* sic - follow HTTP, not English */
394 #define ACTION_HIDE_USER_AGENT 0x0040U
395 #define ACTION_IMAGE           0x0080U
396 #define ACTION_IMAGE_BLOCKER   0x0100U
397 #define ACTION_NO_COOKIE_READ  0x0200U
398 #define ACTION_NO_COOKIE_SET   0x0400U
399 #define ACTION_NO_POPUPS       0x0800U
400 #define ACTION_VANILLA_WAFER   0x1000U
401
402 #define ACTION_STRING_FROM          0
403 #define ACTION_STRING_IMAGE_BLOCKER 1
404 #define ACTION_STRING_REFERER       2
405 #define ACTION_STRING_USER_AGENT    3
406 #define ACTION_STRING_COUNT         4
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 DETECT_MSIE_IMAGES
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 DETECT_MSIE_IMAGES */
494
495
496 struct client_state
497 {
498    /* The proxy's configuration */
499    struct configuration_spec * config;
500
501
502    /* The actions to perform on the current request */
503    struct current_action_spec  action[1];
504
505
506    /* socket to talk to client (web browser) */
507    int  cfd;
508
509    /* socket to talk to server (web server or proxy) */
510    int  sfd;
511
512
513 #ifdef STATISTICS
514    /* 1 if this URL was rejected, 0 otherwise. Allows actual stats inc to 
515     * occur in main thread only for thread-safety. 
516     */
517    int  rejected;
518 #endif /* def STATISTICS */
519
520 #ifdef FORCE_LOAD
521    int force;
522 #endif /* def FORCE_LOAD */
523
524 #ifdef TOGGLE
525    int   toggled_on;
526 #endif /* def TOGGLE */
527
528    /*
529     * Client PC's IP address, as reported by the accept()_ function.
530     * Both as string and number
531     */
532    char *ip_addr_str;
533    long  ip_addr_long;
534
535 #ifdef TRUST_FILES
536    /* The referer in this request, if one was specified. */
537    char *referrer;
538 #endif /* def TRUST_FILES */
539
540 #if defined(DETECT_MSIE_IMAGES)
541    /* Types the client will accept.
542     * Bitmask - see ACCEPT_TYPE_XXX constants.
543     */
544    int accept_types;
545 #endif /* defined(DETECT_MSIE_IMAGES) */
546
547    /* The URL that was requested */
548    struct http_request http[1];
549
550    /* An I/O buffer used for buffering data read from the client */
551    struct iob iob[1];
552
553    /* List of all headers for this request */
554    struct list headers[1];
555
556    /* List of all cookies for this request */
557    struct list cookie_list[1];
558
559 #if defined(PCRS) || defined(KILLPOPUPS)
560    /* Nonzero if this has a text MIME type */
561    int is_text;
562 #endif /* defined(PCRS) || defined(KILLPOPUPS) */
563
564    /* The "X-Forwarded-For:" header sent by the client */
565    char   *x_forwarded;
566
567    /*
568     * Nonzero if this client is processing data.
569     * Set to zero when the thread associated with this structure dies.
570     */
571    int active;
572
573    /* files associated with this client */
574    struct file_list *actions_list;
575
576 #ifdef PCRS
577      struct file_list *rlist;   /* Perl re_filterfile */
578      size_t content_length;     /* Length after processing */ 
579 #endif /* def PCRS */
580
581 #ifdef TRUST_FILES
582    struct file_list *tlist;   /* trustfile */
583 #endif /* def TRUST_FILES */
584
585    struct client_state *next;
586 };
587
588
589 struct parsers
590 {
591    char *str;
592    char  len;
593    char *(*parser)(const struct parsers *, char *, struct client_state *);
594 };
595
596 struct cgi_dispatcher
597 {
598    const char *name;
599    int         name_length;
600    int         (*handler)(struct client_state *csp, struct http_response *rsp, struct map *parameters);
601    const char *description;
602 };
603
604 struct file_list
605 {
606    /*
607     * this is a pointer to the data structures associated with the file.
608     * Read-only once the structure has been created.
609     */
610    void *f;
611    
612    /* Normally NULL.  When we are finished with file (i.e. when we have
613     * loaded a new one), set to a pointer to an unloader function.
614     * Unloader will be called by sweep() (called from main loop) when
615     * all clients using this file are done.  This prevents threading 
616     * problems.
617     */
618    void (*unloader)(void *);
619
620    /* Used internally by sweep().  Do not access from elsewhere. */
621    int active;
622
623 #ifndef SPLIT_PROXY_ARGS
624    /* String to be displayed as part of show-proxy-args display.
625     * Read-only once the structure has been created.
626     */
627    char *proxy_args;
628 #endif /* ndef SPLIT_PROXY_ARGS */
629
630    /* Following variables allow us to check if file has been changed.
631     * Read-only once the structure has been created.
632     */
633    time_t lastmodified;
634    char * filename;
635
636    /* Pointer to next entry in the linked list of all "file_list"s.
637     * This linked list is so that sweep() can navigate it.
638     * Since sweep() can remove items from the list, we must be careful
639     * to only access this value from main thread (when we know sweep
640     * won't be running).
641     */
642    struct file_list *next;
643 };
644
645
646 #ifdef TRUST_FILES
647 struct block_spec
648 {
649    struct url_spec url[1];
650    int    reject;
651    struct block_spec *next;
652 };
653 #endif /* def TRUST_FILES */
654
655
656 #define SOCKS_NONE    0    /* Don't use a SOCKS server */
657 #define SOCKS_4      40    /* original SOCKS 4 protocol */
658 #define SOCKS_4A     41    /* as modified for hosts w/o external DNS */
659
660 struct forward_spec
661 {
662    struct url_spec url[1];
663
664    /* Connection type - must be a SOCKS_xxx constant */
665    int   type;
666
667    /* SOCKS server */
668    char *gateway_host;
669    int   gateway_port;
670
671    /* Parent HTTP proxy */
672    char *forward_host;
673    int   forward_port;
674
675    /* For the linked list */
676    struct forward_spec *next;
677 };
678
679
680 #ifdef PCRS
681 struct re_filterfile_spec
682 {
683    struct list patterns[1];
684    pcrs_job *joblist;
685 };
686 #endif /* def PCRS */
687
688
689 #ifdef ACL_FILES
690 #define ACL_PERMIT   1  /* accept connection request */
691 #define ACL_DENY     2  /* reject connection request */
692
693 struct access_control_addr
694 {
695    unsigned long addr;
696    unsigned long mask;
697    unsigned long port;
698 };
699
700 struct access_control_list
701 {
702    struct access_control_addr src[1];
703    struct access_control_addr dst[1];
704
705    short action;
706    struct access_control_list *next;
707 };
708 #endif /* def ACL_FILES */
709
710
711 /* Maximum number of loaders (actions, re_filter, ...) */
712 #define NLOADERS 8
713
714 /*
715  * Data loaded from the configuration file.
716  *
717  * (Anomaly: toggle is still handled through a global, not this structure)
718  */
719 struct configuration_spec
720 {
721    int debug;
722    int multi_threaded;
723
724    const char *logfile;
725
726    const char *confdir;
727    const char *logdir;
728    const char *actions_file;
729
730 #ifdef PCRS
731    const char *re_filterfile;
732 #endif /* def PCRS */
733
734 #ifdef JAR_FILES
735    const char * jarfile;
736    FILE * jar;
737 #endif /* def JAR_FILES */
738
739    /*
740     * Port and IP to bind to.
741     * Defaults to HADDR_DEFAULT:HADDR_PORT == 127.0.0.1:8000
742     */
743    const char *haddr;
744    int         hport;
745
746 #ifndef SPLIT_PROXY_ARGS
747    const char *suppress_message;
748 #endif /* ndef SPLIT_PROXY_ARGS */
749
750 #ifndef SPLIT_PROXY_ARGS
751    /* suppress listing config files */
752    int suppress_blocklists;
753 #endif /* ndef SPLIT_PROXY_ARGS */
754
755 #ifdef TRUST_FILES
756    const char * trustfile;
757
758    struct list trust_info[1];
759    struct url_spec *trust_list[64];
760 #endif /* def TRUST_FILES */
761
762 #ifdef ACL_FILES
763    struct access_control_list *acl;
764 #endif /* def ACL_FILES */
765
766    struct forward_spec *forward;
767
768    /* Various strings for show-proxy-args */
769    char *proxy_args_header;
770    char *proxy_args_invocation;
771    char *proxy_args_trailer;
772
773    /* the configuration file object. */
774    struct file_list *config_file_list;
775
776    /* List of loaders */
777    int (*loaders[NLOADERS])(struct client_state *);
778
779    /* bool, nonzero if we need to bind() to the new port */
780    int need_bind;
781 };
782
783
784 #define SZ(X)  (sizeof(X) / sizeof(*X))
785
786 #define WHITEBG   "<body bgcolor=\"#ffffff\" link=\"#000078\" alink=\"#ff0022\" vlink=\"#787878\">\n"
787 #define BODY      "<body bgcolor=\"#f8f8f0\" link=\"#000078\" alink=\"#ff0022\" vlink=\"#787878\">\n"
788 #define BANNER    "<strong>Internet J<small>UNK<i><font color=\"red\">BUSTER</font></i></small></strong>"
789
790 #ifdef FORCE_LOAD
791 #define FORCE_PREFIX "/IJB-FORCE-LOAD"
792 #endif /* def FORCE_LOAD */
793
794 /* Shouldn't end with '/' */
795 #define HOME_PAGE_URL  "http://ijbswa.sourceforge.net"
796 #define REDIRECT_URL HOME_PAGE_URL "/redirect.php?v=" VERSION "&to="
797
798 #define CGI_PREFIX_HOST "i.j.b"
799
800 static const char CSUCCEED[] =
801    "HTTP/1.0 200 Connection established\n"
802    "Proxy-Agent: IJ/" VERSION "\n\n";
803
804 static const char CHEADER[] =
805    "HTTP/1.0 400 Invalid header received from browser\n\n";
806
807 static const char SHEADER[] =
808    "HTTP/1.0 502 Invalid header received from server\n\n";
809
810 #ifdef IMAGE_BLOCKING
811
812 /*
813  * Hint: You can encode your own GIFs like that:
814  * perl -e 'while (read STDIN, $c, 1) { printf("\\%.3o,", unpack("C", $c)); }'
815  */
816
817 static const char BLANKGIF[] =
818    "HTTP/1.0 200 OK\r\n"
819    "Pragma: no-cache\r\n"
820    "Last-Modified: Thu Jul 31, 1997 07:42:22 pm GMT\r\n"
821    "Expires:       Thu Jul 31, 1997 07:42:22 pm GMT\r\n"
822    "Content-type: image/gif\r\n\r\n"
823    "GIF89a\001\000\001\000\200\000\000\377\377\377\000\000"
824    "\000!\371\004\001\000\000\000\000,\000\000\000\000\001"
825    "\000\001\000\000\002\002D\001\000;";
826
827 static const char JBGIF[] =
828    "HTTP/1.0 200 OK\r\n"
829    "Pragma: no-cache\r\n"
830    "Last-Modified: Thu Jul 31, 1997 07:42:22 pm GMT\r\n"
831    "Expires:       Thu Jul 31, 1997 07:42:22 pm GMT\r\n"
832    "Content-type: image/gif\r\n\r\n"
833    "GIF89aD\000\013\000\360\000\000\000\000\000\377\377\377!"
834    "\371\004\001\000\000\001\000,\000\000\000\000D\000\013\000"
835    "\000\002a\214\217\251\313\355\277\000\200G&K\025\316hC\037"
836    "\200\234\230Y\2309\235S\230\266\206\372J\253<\3131\253\271"
837    "\270\215\342\254\013\203\371\202\264\334P\207\332\020o\266"
838    "N\215I\332=\211\312\3513\266:\026AK)\364\370\365aobr\305"
839    "\372\003S\275\274k2\354\254z\347?\335\274x\306^9\374\276"
840    "\037Q\000\000;";
841
842 #endif /* def IMAGE_BLOCKING */
843
844 #if defined(FAST_REDIRECTS) || defined(IMAGE_BLOCKING)
845
846 static const char HTTP_REDIRECT_TEMPLATE[] =
847       "HTTP/1.0 302 Local Redirect from Junkbuster\r\n" 
848       "Pragma: no-cache\r\n"
849       "Last-Modified: Thu Jul 31, 1997 07:42:22 pm GMT\r\n"
850       "Expires:       Thu Jul 31, 1997 07:42:22 pm GMT\r\n"
851       "Location: %s\r\n\r\n";
852
853 #endif /*  defined(FAST_REDIRECTS) || defined(IMAGE_BLOCKING) */
854
855 #ifdef __cplusplus
856 } /* extern "C" */
857 #endif
858
859 #endif /* ndef _PROJECT_H */
860
861 /*
862   Local Variables:
863   tab-width: 3
864   end:
865 */