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