---------------------
PatchSet 914 
Date: 2000/12/13 22:01:00
Author: rbcollins
Branch: rbcollins_clientstreamline
Tag: (none) 
Log:
first cut at organisation. Added a request modifier plugin

Members: 
	configure.in:1.6->1.6.2.1 
	src/Makefile.in:1.3->1.3.14.1 
	src/client_side.c:1.8->1.8.2.1 
	src/enums.h:1.6->1.6.2.1 
	src/protos.h:1.6->1.6.2.1 
	src/structs.h:1.8->1.8.2.1 
	src/typedefs.h:1.4->1.4.8.1 

Index: squid/configure.in
===================================================================
RCS file: /cvsroot/squid-sf//squid/configure.in,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- squid/configure.in	12 Dec 2000 23:21:13 -0000	1.6
+++ squid/configure.in	13 Dec 2000 22:01:00 -0000	1.6.2.1
@@ -3,13 +3,13 @@
 dnl
 dnl  Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9)
 dnl
-dnl  $Id: configure.in,v 1.6 2000/12/12 23:21:13 adri Exp $
+dnl  $Id: configure.in,v 1.6.2.1 2000/12/13 22:01:00 rbcollins Exp $
 dnl
 dnl
 dnl
 AC_INIT(src/main.c)
 AC_CONFIG_HEADER(include/autoconf.h)
-AC_REVISION($Revision: 1.6 $)dnl
+AC_REVISION($Revision: 1.6.2.1 $)dnl
 AC_PREFIX_DEFAULT(/usr/local/squid)
 AC_CONFIG_AUX_DIR(cfgaux)
 
@@ -370,6 +370,38 @@
 REPL_LIBS="`echo $REPL_OBJS|sed -e's%repl/%%g'`"
 AC_SUBST(REPL_LIBS)
 
+AC_ARG_ENABLE(request-modifiers,
+[  --request-modifiers=\"list of modules\"
+                          Build support for the list of request modification modules.
+                          The default is only to build the "redirector" module.
+                          See src/reqmod for a list of available modules, or
+                          Programmers Guide section <not yet written>
+                          for details on how to build your custom request mod module],
+[ case $enableval in
+  yes)
+        for module in $srcdir/src/reqmod/*; do
+            if test -f $module/Makefile.in; then
+                REQUEST_MODIFIERS="$REQUEST_MODIFIERS `basename $module`"
+            fi
+        done
+        ;;
+  no)
+        ;;
+  *)    REQUEST_MODIFIERS="`echo $enableval| sed -e 's/,/ /g;s/  */ /g'`"
+        ;;
+  esac
+],
+[ if test -z "$REQUEST_MODIFIERS"; then
+    REQUEST_MODIFIERS="redirector"
+  fi
+])
+echo "Request modifier modules built: $REQUEST_MODIFIERS"
+AC_SUBST(REQUEST_MODIFIERS)
+REQUEST_MODIFIER_OBJS="reqmod/`echo $REQUEST_MODIFIERS|sed -e's% %.a reqmod/%g'`.a"
+AC_SUBST(REQUEST_MODIFIER_OBJS)
+REQUEST_MOD_LIBS="`echo $REQUEST_MODIFIER_OBJS|sed -e's%reqmod/%%g'`"
+AC_SUBST(REQUEST_MOD_LIBS)
+
 OPT_PINGER_EXE=''
 AC_ARG_ENABLE(icmp,
 [  --enable-icmp           Enable ICMP pinging],
@@ -1678,6 +1710,13 @@
 	fi
 done
 
+REQMOD_MAKEFILES=""
+for reqmod in $REQUEST_MODIFIERS none; do
+	if test $reqmod != none; then
+		REQMOD_MAKEFILES="$REQMOD_MAKEFILES ./src/reqmod/$reqmod/Makefile"
+	fi
+done
+
 AUTH_MAKEFILES=""
 for module in $srcdir/auth_modules/*; do
 	if test -f $module/Makefile.in; then
@@ -1697,6 +1736,8 @@
 	$FS_MAKEFILES \
 	./src/repl/Makefile \
 	$REPL_MAKEFILES \
+	./src/reqmod/Makefile \
+	$REQMOD_MAKEFILES \
 	./contrib/Makefile \
 	$SNMP_MAKEFILE \
 	./icons/Makefile \
Index: squid/src/Makefile.in
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/Attic/Makefile.in,v
retrieving revision 1.3
retrieving revision 1.3.14.1
diff -u -r1.3 -r1.3.14.1
--- squid/src/Makefile.in	23 Oct 2000 15:04:19 -0000	1.3
+++ squid/src/Makefile.in	13 Dec 2000 22:01:01 -0000	1.3.14.1
@@ -1,7 +1,7 @@
 #
 #  Makefile for the Squid Object Cache server
 #
-#  $Id: Makefile.in,v 1.3 2000/10/23 15:04:19 hno Exp $
+#  $Id: Makefile.in,v 1.3.14.1 2000/12/13 22:01:01 rbcollins Exp $
 #
 #  Uncomment and customize the following to suit your needs:
 #
@@ -18,7 +18,7 @@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
-SUBDIRS		= fs repl
+SUBDIRS		= fs repl reqmod
 
 # Gotta love the DOS legacy
 #
@@ -69,6 +69,8 @@
 STORE_MODULES	= @STORE_MODULES@
 REPL_OBJS	= @REPL_OBJS@
 REPL_POLICIES	= @REPL_POLICIES@
+REQ_MOD_OBJS    = @REQUEST_MODIFIER_OBJS@
+REQ_MOD_MODULES = @REQUEST_MODIFERS@
 MV		= @MV@
 RM		= @RM@
 SHELL		= /bin/sh
@@ -208,8 +210,8 @@
 
 $(SNMP_OBJS): ../snmplib/libsnmp.a $(top_srcdir)/include/cache_snmp.h
 
-$(SQUID_EXE): $(OBJS) $(STORE_OBJS) $(REPL_OBJS)
-	$(CC) -o $@ $(LDFLAGS) $(OBJS) $(STORE_OBJS) $(REPL_OBJS) $(SQUID_LIBS)
+$(SQUID_EXE): $(OBJS) $(STORE_OBJS) $(REPL_OBJS) $(REQ_MOD_OBJS)
+	$(CC) -o $@ $(LDFLAGS) $(OBJS) $(STORE_OBJS) $(REPL_OBJS) $(REQ_MOD_OBJS) $(SQUID_LIBS)
 
 globals.o: globals.c Makefile
 	$(CC) -c globals.c $(CFLAGS) -I$(srcdir) $(DEFAULTS)
@@ -298,6 +300,15 @@
 repl_modules repl/stamp:
 	@sh -c "cd repl && $(MAKE) all"
 
+req_mod_modules.c: req_mod_modules.sh Makefile
+	sh $(srcdir)/req_mod_modules.sh $(REQ_MOD_MODULES) >req_mod_modules.c
+
+req_mod_modules.o: req_mod_modules.c
+	$(CC) -c req_mod_modules.c $(CFLAGS) -I$(srcdir)
+
+$(REQ_MOD_OBJS):
+	@sh -c "cd `dirname $@` && $(MAKE) $(MFLAGS) `basename $@`"
+
 install-mkdirs:
 	-@if test ! -d $(prefix); then \
 		echo "mkdir $(prefix)"; \
Index: squid/src/client_side.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- squid/src/client_side.c	12 Dec 2000 23:21:18 -0000	1.8
+++ squid/src/client_side.c	13 Dec 2000 22:01:01 -0000	1.8.2.1
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.c,v 1.8 2000/12/12 23:21:18 adri Exp $
+ * $Id: client_side.c,v 1.8.2.1 2000/12/13 22:01:01 rbcollins Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -113,6 +113,7 @@
 static log_type clientProcessRequest2(clientHttpRequest * http);
 static int clientReplyBodyTooLarge(int clen);
 static int clientRequestBodyTooLarge(int clen);
+static void clientManageRequest(clientHttpRequest *http);
 
 static int
 checkAccelOnly(clientHttpRequest * http)
@@ -226,9 +227,13 @@
     if (answer == ACCESS_ALLOWED) {
 	safe_free(http->uri);
 	http->uri = xstrdup(urlCanonical(http->request));
+#if 0
 	assert(http->redirect_state == REDIRECT_NONE);
 	http->redirect_state = REDIRECT_PENDING;
 	redirectStart(http, clientRedirectDone, http);
+#endif
+        http->request_state=CLIENT_R_REDIRECT_PENDING;
+        clientManageRequest(http);
     } else {
 	debug(33, 5) ("Access Denied: %s\n", http->uri);
 	debug(33, 5) ("AclMatchedName = %s\n",
@@ -315,12 +320,16 @@
 	requestUnlink(old_request);
 	http->request = requestLink(new_request);
     }
+    http->request_state=CLIENT_R_CHECK_NO_CACHE_PENDING;
+    clientManageRequest(http);
+#if 0
     clientInterpretRequestHeaders(http);
 #if HEADERS_LOG
     headersLog(0, 1, request->method, request);
 #endif
     fd_note(http->conn->fd, http->uri);
     clientCheckNoCache(http);
+#endif
 }
 
 static void
@@ -340,7 +349,11 @@
     clientHttpRequest *http = data;
     http->request->flags.cachable = answer;
     http->acl_checklist = NULL;
+    http->request_state = CLIENT_R_CHECK_NO_CACHE_DONE;
+    clientManageRequest(http);
+#if 0
     clientProcessRequest(http);
+#endif
 }
 
 static void
@@ -2729,7 +2742,10 @@
 		    break;
 		}
 	    }
+            clientManageRequest(http);
+#if 0
 	    clientAccessCheck(http);
+#endif
 	    continue;		/* while offset > 0 */
 	} else if (parser_return_code == 0) {
 	    /*
@@ -3079,3 +3095,33 @@
     }
     NHttpSockets = 0;
 }
+
+void
+clientManageRequest(clientHttpRequest *http)
+{
+    switch (http->request_state)
+    {
+        case CLIENT_R_NONE:
+            http->request_state=CLIENT_R_ACL_PENDING;
+            clientAccessCheck(http);
+            break;
+        case CLIENT_R_ACL_PENDING:
+            break;
+        case CLIENT_R_REDIRECT_PENDING:
+            assert(http->redirect_state == REDIRECT_NONE);
+            http->redirect_state = REDIRECT_PENDING;
+            redirectStart(http, clientRedirectDone, http);
+            break;
+        case CLIENT_R_CHECK_NO_CACHE_PENDING:
+            clientInterpretRequestHeaders(http);
+#if HEADERS_LOG
+            headersLog(0, 1, request->method, request);
+#endif
+            fd_note(http->conn->fd, http->uri);
+            clientCheckNoCache(http);        
+            break;
+        case CLIENT_R_CHECK_NO_CACHE_DONE:
+            clientProcessRequest(http);
+            break;
+    }
+}
Index: squid/src/enums.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/enums.h,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- squid/src/enums.h	12 Dec 2000 23:21:18 -0000	1.6
+++ squid/src/enums.h	13 Dec 2000 22:01:02 -0000	1.6.2.1
@@ -1,6 +1,6 @@
 
 /*
- * $Id: enums.h,v 1.6 2000/12/12 23:21:18 adri Exp $
+ * $Id: enums.h,v 1.6.2.1 2000/12/13 22:01:02 rbcollins Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -133,6 +133,14 @@
     ACL_PROXY_AUTH_NEEDED
 } acl_lookup_state;
 
+typedef enum {
+    CLIENT_R_NONE,
+    CLIENT_R_ACL_PENDING,
+    CLIENT_R_REDIRECT_PENDING,
+    CLIENT_R_CHECK_NO_CACHE_PENDING,
+    CLIENT_R_CHECK_NO_CACHE_DONE
+} client_request_state;
+
 enum {
     FD_NONE,
     FD_LOG,
Index: squid/src/protos.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/protos.h,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- squid/src/protos.h	12 Dec 2000 23:21:19 -0000	1.6
+++ squid/src/protos.h	13 Dec 2000 22:01:02 -0000	1.6.2.1
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.6 2000/12/12 23:21:19 adri Exp $
+ * $Id: protos.h,v 1.6.2.1 2000/12/13 22:01:02 rbcollins Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -100,6 +100,7 @@
 extern int cbdataValid(const void *p);
 extern CBDUNL cbdataXfree;
 
+/* client_side.c */
 extern void clientdbInit(void);
 extern void clientdbUpdate(struct in_addr, log_type, protocol_t, size_t);
 extern int clientdbCutoffDenied(struct in_addr);
@@ -116,6 +117,8 @@
 extern void clientHttpConnectionsOpen(void);
 extern void clientHttpConnectionsClose(void);
 extern StoreEntry *clientCreateStoreEntry(clientHttpRequest *, method_t, request_flags);
+extern void clientReqModAdd(char *, REQMODSETUP *);
+
 extern int isTcpHit(log_type);
 
 extern int commSetNonBlocking(int fd);
@@ -869,6 +872,9 @@
 /* repl_modules.c */
 extern void storeReplSetup(void);
 
+/* reqmod_modules.c */
+extern void clientReqModSetup(void);
+
 /* store_io.c */
 extern storeIOState *storeCreate(StoreEntry *, STFNCB *, STIOCB *, void *);
 extern storeIOState *storeOpen(StoreEntry *, STFNCB *, STIOCB *, void *);
Index: squid/src/structs.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/structs.h,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- squid/src/structs.h	12 Dec 2000 23:21:20 -0000	1.8
+++ squid/src/structs.h	13 Dec 2000 22:01:02 -0000	1.8.2.1
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.8 2000/12/12 23:21:20 adri Exp $
+ * $Id: structs.h,v 1.8.2.1 2000/12/13 22:01:02 rbcollins Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -905,6 +905,7 @@
 	char *location;
     } redirect;
     dlink_node active;
+    client_request_state request_state;
 };
 
 struct _ConnStateData {
@@ -1874,6 +1875,16 @@
     struct _PumpStateData *next;
 };
 
+
+/*
+ * This defines a request modifier type
+ */
+
+struct _reqmod_entry_t {
+    char *typestr;
+
+};
+
 /*
  * This defines an fs type
  */
Index: squid/src/typedefs.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v
retrieving revision 1.4
retrieving revision 1.4.8.1
diff -u -r1.4 -r1.4.8.1
--- squid/src/typedefs.h	14 Nov 2000 13:03:47 -0000	1.4
+++ squid/src/typedefs.h	13 Dec 2000 22:01:02 -0000	1.4.8.1
@@ -1,6 +1,6 @@
 
 /*
- * $Id: typedefs.h,v 1.4 2000/11/14 13:03:47 adri Exp $
+ * $Id: typedefs.h,v 1.4.8.1 2000/12/13 22:01:02 rbcollins Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -167,6 +167,7 @@
 typedef struct _queued_write queued_write;
 typedef struct _link_list link_list;
 typedef struct _PumpStateData PumpStateData;
+typedef struct _reqmod_entry_t reqmod_entry_t;
 typedef struct _storefs_entry storefs_entry_t;
 typedef struct _storerepl_entry storerepl_entry_t;
 typedef struct _diskd_queue diskd_queue;
@@ -199,6 +200,9 @@
 typedef void EVH(void *);
 typedef void PF(int, void *);
 
+/* client_side.c callback typedefs */
+typedef void REQMODSETUP(reqmod_entry_t *);
+
 /* disk.c / diskd.c callback typedefs */
 typedef void DRCB(int, const char *buf, int size, int errflag, void *data);
 							/* Disk read CB */
