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