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