diff -urN ijb20/cache.c ijb20-cache/cache.c
--- ijb20/cache.c	1970-01-01 01:00:00.000000000 +0100
+++ ijb20-cache/cache.c	2000-01-03 21:30:00.000000000 +0100
@@ -0,0 +1,121 @@
+/*
+
+    cache.c
+
+    Compulsive caching code for the Internet Junkbuster.
+
+    Copyright (C) 2000 Angel Ortega <angel@triptico.com>
+
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    as published by the Free Software Foundation; either version 2
+    of the License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+    http://www.triptico.com
+
+    --------
+
+    This is a quick & dirty hack. All files seen by Junkbuster
+    are written under /var/cache/ijb. Useful for slurping web sites.
+
+    DANGER! Full of untested strcats. Use it at your own risk.
+
+*/
+
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <gnu_regex.h>
+#include "jcc.h"
+#include "cache.h"
+
+static int _cache_fd=-1;
+
+#define CACHE_DIR "/var/cache/ijb/"
+
+
+void cache_open(struct http_request * http)
+{
+	char tmp[1024];
+	char tmp2[4096];
+	char * ptr;
+	char * filename;
+
+	umask(0);
+
+	if(strchr(http->path, '?'))
+		return;
+
+	strcpy(tmp, CACHE_DIR);
+	mkdir(tmp, 0777);
+	strcat(tmp, http->hostport);
+	strcat(tmp, "/");
+	mkdir(tmp, 0777);
+
+	strcpy(tmp2, http->path);
+
+	/* takes basename */
+	filename=strrchr(tmp2, '/');
+	if(filename)
+	{
+		*filename='\0';
+		filename++;
+
+		ptr=strtok(tmp2, "/");
+
+		while(ptr)
+		{
+			strcat(tmp, ptr);
+			strcat(tmp, "/");
+			mkdir(tmp, 0777);
+			ptr=strtok(NULL, "/");
+		}
+	}
+	else
+		filename=tmp2;
+
+	if(filename[0] == '\0') filename="index.html";
+
+	strcat(tmp,filename);
+
+	_cache_fd=open(tmp,O_CREAT|O_TRUNC|O_RDWR, 0666);
+}
+
+
+void cache_flush(struct client_state * csp)
+{
+	struct iob *iob = csp->iob;
+	int n = iob->eod - iob->cur;
+
+	if(n <= 0) return;
+
+	write(_cache_fd, iob->cur, n);
+}
+
+
+void cache_write(char * buf, int size)
+{
+	if(_cache_fd!=-1)
+		write(_cache_fd, buf, size);
+}
+
+
+void cache_close(void)
+{
+	if(_cache_fd!=-1)
+	{
+		close(_cache_fd);
+		_cache_fd=-1;
+	}
+}
diff -urN ijb20/cache.h ijb20-cache/cache.h
--- ijb20/cache.h	1970-01-01 01:00:00.000000000 +0100
+++ ijb20-cache/cache.h	2000-01-03 21:30:00.000000000 +0100
@@ -0,0 +1,8 @@
+/*
+
+	cache.h
+
+*/
+
+void cache_open(struct http_request * http);
+void cache_close(void);
diff -urN ijb20/jcc.c ijb20-cache/jcc.c
--- ijb20/jcc.c	2005-09-20 19:00:57.000000000 +0200
+++ ijb20-cache/jcc.c	2000-01-03 21:30:00.000000000 +0100
@@ -43,6 +43,7 @@
 #endif
 
 #include "jcc.h"
+#include "cache.h"
 
 char *prog;
 
@@ -438,6 +439,7 @@
 	 */
 
 	server_body = 0;
+	cache_open(http);
 
 	for(;;) {
 		FD_ZERO(&rfds);
@@ -463,6 +465,8 @@
 
 			if(n <= 0) break; /* "game over, man" */
 
+			if(server_body) cache_write(buf,n);
+
 			if(write_socket(csp->sfd, buf, n) != n) {
 				fprintf(logfp, "%s: write to: %s failed: ",
 						prog, http->host);
@@ -500,6 +504,8 @@
 			 * of the server document, just write it to the client.
 			 */
 
+			if(server_body) cache_write(buf,n);
+
 			if(server_body || http->ssl) {
 				/* just write */
 				if(write_socket(csp->cfd, buf, n) != n) {
@@ -556,6 +562,8 @@
 				 * may be in the buffer)
 				 */
 
+				cache_flush(csp);
+
 				if((write_socket(csp->cfd, hdr, n) != n)
 				|| (flush_socket(csp->cfd, csp   ) <  0)) {
 					if(DEBUG(CON)) {
@@ -582,6 +590,8 @@
 
 		return; /* huh? we should never get here */
 	}
+
+	cache_close();
 }
 
 void
diff -urN ijb20/Makefile ijb20-cache/Makefile
--- ijb20/Makefile	1998-10-30 22:58:48.000000000 +0100
+++ ijb20-cache/Makefile	2000-01-03 21:30:00.000000000 +0100
@@ -50,7 +50,8 @@
 CFLAGS  = $(DEFAULT_CFLAGS) $(MORE_CFLAGS)
 
 OBJS =	jcc.$(O) parsers.$(O) filters.$(O) loaders.$(O) bind.$(O) conn.$(O) \
-	encode.$(O) ssplit.$(O) socks4.$(O) acl.$(O) gnu_regex.$(O) win32.$(O)
+	encode.$(O) ssplit.$(O) socks4.$(O) acl.$(O) gnu_regex.$(O) win32.$(O) \
+	cache.$(O)
 
 $(PROG): $(OBJS)
 	$(CC) $(CFLAGS) -o $(PROG) $(OBJS) $(LDFLAGS)
