---------------------
PatchSet 6 
Date: 2002/10/15 02:09:40
Author: rbcollins
Branch: trie
Tag: (none) 
Log:
squid3 trie support

Members: 
	bootstrap.sh:1.1->1.1.4.1 
	configure.in:1.1->1.1.4.1 
	lib/Makefile.am:1.1->1.1.4.1 
	src/HttpHdrCc.cc:1.1->1.1.4.1 
	src/HttpHeader.cc:1.1->1.1.4.1 
	src/Makefile.am:1.2->1.2.4.1 
	src/protos.h:1.2->1.2.4.1 

Index: squid3/bootstrap.sh
===================================================================
RCS file: /cvsroot/squid-sf//squid3/bootstrap.sh,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -r1.1 -r1.1.4.1
--- squid3/bootstrap.sh	14 Oct 2002 00:20:06 -0000	1.1
+++ squid3/bootstrap.sh	15 Oct 2002 02:09:40 -0000	1.1.4.1
@@ -65,3 +65,5 @@
 bootstrap autoconf$acver
 
 echo "Autotool bootstrapping complete."
+echo "bootstrapping sub projects."
+cd lib/libTrie && $SHELL ./bootstrap.sh
Index: squid3/configure.in
===================================================================
RCS file: /cvsroot/squid-sf//squid3/configure.in,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -r1.1 -r1.1.4.1
--- squid3/configure.in	14 Oct 2002 00:20:06 -0000	1.1
+++ squid3/configure.in	15 Oct 2002 02:09:40 -0000	1.1.4.1
@@ -3,7 +3,7 @@
 dnl
 dnl  Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9)
 dnl
-dnl  $Id: configure.in,v 1.1 2002/10/14 00:20:06 squidadm Exp $
+dnl  $Id: configure.in,v 1.1.4.1 2002/10/15 02:09:40 rbcollins Exp $
 dnl
 dnl
 dnl
@@ -13,7 +13,7 @@
 AC_CONFIG_AUX_DIR(cfgaux)
 AM_INIT_AUTOMAKE(squid, 2.6-DEVEL)
 AM_CONFIG_HEADER(include/autoconf.h)
-AC_REVISION($Revision: 1.1 $)dnl
+AC_REVISION($Revision: 1.1.4.1 $)dnl
 AC_PREFIX_DEFAULT(/usr/local/squid)
 AM_MAINTAINER_MODE
 
@@ -2366,4 +2366,7 @@
 	helpers/external_acl/wbinfo_group/Makefile \
 	helpers/external_acl/winbind_group/Makefile \
 ])
+
+AC_CONFIG_SUBDIRS(lib/libTrie)
+
 AC_OUTPUT
Index: squid3/lib/Makefile.am
===================================================================
RCS file: /cvsroot/squid-sf//squid3/lib/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -r1.1 -r1.1.4.1
--- squid3/lib/Makefile.am	14 Oct 2002 00:18:18 -0000	1.1
+++ squid3/lib/Makefile.am	15 Oct 2002 02:09:41 -0000	1.1.4.1
@@ -1,8 +1,10 @@
 ## Process this file with automake to produce Makefile.in
 #
-#  $Id: Makefile.am,v 1.1 2002/10/14 00:18:18 squidadm Exp $
+#  $Id: Makefile.am,v 1.1.4.1 2002/10/15 02:09:41 rbcollins Exp $
 #
 
+SUBDIRS = libTrie
+
 if ENABLE_XPROF_STATS
 XPROF_STATS_SOURCE = Profiler.c
 else
@@ -56,6 +58,8 @@
 	uudecode.c \
 	$(XPROF_STATS_SOURCE)
 libmiscutil_a_LIBADD = \
+        libTrie/src/Trie.o \
+	libTrie/src/TrieNode.o \
 	@LIBOBJS@
 # $(top_srcdir)/include/version.h should be a dependency
 libregex_a_SOURCES = \
Index: squid3/src/HttpHdrCc.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/HttpHdrCc.cc,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -r1.1 -r1.1.4.1
--- squid3/src/HttpHdrCc.cc	14 Oct 2002 00:18:19 -0000	1.1
+++ squid3/src/HttpHdrCc.cc	15 Oct 2002 02:09:41 -0000	1.1.4.1
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHdrCc.cc,v 1.1 2002/10/14 00:18:19 squidadm Exp $
+ * $Id: HttpHdrCc.cc,v 1.1.4.1 2002/10/15 02:09:41 rbcollins Exp $
  *
  * DEBUG: section 65    HTTP Cache Control Header
  * AUTHOR: Alex Rousskov
@@ -36,6 +36,7 @@
 #include "squid.h"
 #include "Store.h"
 #include "HttpHeader.h"
+#include "Trie.h"
 
 /* this table is used for parsing cache control header */
 static const HttpHeaderFieldAttrs CcAttrs[CC_ENUM_END] =
@@ -62,6 +63,8 @@
 }
 
 
+static Trie *ccTrie = NULL;
+
 /* local prototypes */
 static int httpHdrCcParseInit(HttpHdrCc * cc, const String * str);
 
@@ -71,7 +74,13 @@
 void
 httpHdrCcInitModule(void)
 {
+    int i;
     CcFieldsInfo = httpHeaderBuildFieldsInfo(CcAttrs, CC_ENUM_END);
+    assert (ccTrie == NULL);
+    ccTrie = new Trie;
+    for (i = 0; i < CC_ENUM_END; ++i)
+	if (!ccTrie->add(strBuf(CcFieldsInfo[i].name), strLen(CcFieldsInfo[i].name), (void *) (i + 1)))
+	    fatal("Could not build CC search trie\n"); 
 }
 
 void
@@ -79,6 +88,8 @@
 {
     httpHeaderDestroyFieldsInfo(CcFieldsInfo, CC_ENUM_END);
     CcFieldsInfo = NULL;
+    delete ccTrie;
+    ccTrie = NULL;
 }
 
 /* implementation */
@@ -121,7 +132,7 @@
 	    ilen = p++ - item;
 	/* find type */
 	type = (http_hdr_cc_type ) httpHeaderIdByName(item, ilen,
-	    CcFieldsInfo, CC_ENUM_END);
+	    ccTrie);
 	if (type < 0) {
 	    debug(65, 2) ("hdr cc: unknown cache-directive: near '%s' in '%s'\n", item, strBuf(*str));
 	    type = CC_OTHER;
Index: squid3/src/HttpHeader.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/HttpHeader.cc,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -r1.1 -r1.1.4.1
--- squid3/src/HttpHeader.cc	14 Oct 2002 00:18:19 -0000	1.1
+++ squid3/src/HttpHeader.cc	15 Oct 2002 02:09:41 -0000	1.1.4.1
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHeader.cc,v 1.1 2002/10/14 00:18:19 squidadm Exp $
+ * $Id: HttpHeader.cc,v 1.1.4.1 2002/10/15 02:09:41 rbcollins Exp $
  *
  * DEBUG: section 55    HTTP Header
  * AUTHOR: Alex Rousskov
@@ -36,6 +36,7 @@
 #include "squid.h"
 #include "Store.h"
 #include "HttpHeader.h"
+#include "Trie.h"
 
 /*
  * On naming conventions:
@@ -234,6 +235,8 @@
 
 static int HeaderEntryParsedCount = 0;
 
+static Trie *headerTrie = NULL;
+
 /*
  * local routines
  */
@@ -262,6 +265,12 @@
     assert(countof(HeadersAttrs) == HDR_ENUM_END);
     if (!Headers)
 	Headers = httpHeaderBuildFieldsInfo(HeadersAttrs, HDR_ENUM_END);
+    /* Add to Trie */
+    assert (!headerTrie);
+    headerTrie = new Trie;
+    for (i = 0; i < HDR_ENUM_END; ++i)
+	if (!headerTrie->add(strBuf(Headers[i].name), strLen(Headers[i].name), (void *) (i + 1)))
+	    fatal("Could not build Header search trie\n");
     /* create masks */
     httpHeaderMaskInit(&ListHeadersMask, 0);
     httpHeaderCalcMask(&ListHeadersMask, (const int *) ListHeadersArr, countof(ListHeadersArr));
@@ -294,6 +303,8 @@
 {
     httpHeaderDestroyFieldsInfo(Headers, HDR_ENUM_END);
     Headers = NULL;
+    delete headerTrie;
+    headerTrie = NULL;
     httpHdrCcCleanModule();
 }
 
@@ -530,7 +541,7 @@
     while ((e = httpHeaderGetEntry(hdr, &pos))) {
 	if (!strCaseCmp(e->name, name)) {
 	    httpHeaderDelAt(hdr, pos);
-	    count++;
+	    ++count;
 	} else
 	    CBIT_SET(hdr->mask, e->id);
     }
@@ -1061,7 +1072,7 @@
     e = (HttpHeaderEntry *)memAllocate(MEM_HTTP_HDR_ENTRY);
     debug(55, 9) ("creating entry %p: near '%s'\n", e, getStringPrefix(field_start, field_end));
     /* is it a "known" field? */
-    id = httpHeaderIdByName(field_start, name_len, Headers, HDR_ENUM_END);
+    id = httpHeaderIdByName(field_start, name_len, headerTrie);
     if (id < 0)
 	id = HDR_OTHER;
     assert_eid(id);
@@ -1212,6 +1223,15 @@
 }
 
 http_hdr_type
+httpHeaderIdByName(const char *name, int name_len, Trie *aTrie)
+{
+    void *t;
+    int ourLen = name_len > -1 ? name_len: strlen (name) - 1;
+    t = aTrie->find( name, ourLen);
+    return (http_hdr_type)(((int) t) - 1);
+}
+
+http_hdr_type
 httpHeaderIdByName(const char *name, int name_len, const HttpHeaderFieldInfo * info, int end)
 {
     int i;
@@ -1230,7 +1250,8 @@
 {
     if (!Headers)
 	Headers = httpHeaderBuildFieldsInfo(HeadersAttrs, HDR_ENUM_END);
-    return httpHeaderIdByName(name, name_len, Headers, HDR_ENUM_END);
+    assert (headerTrie);
+    return httpHeaderIdByName(name, name_len, headerTrie);
 }
 
 const char *
Index: squid3/src/Makefile.am
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -r1.2 -r1.2.4.1
--- squid3/src/Makefile.am	14 Oct 2002 09:09:09 -0000	1.2
+++ squid3/src/Makefile.am	15 Oct 2002 02:09:41 -0000	1.2.4.1
@@ -1,7 +1,7 @@
 #
 #  Makefile for the Squid Object Cache server
 #
-#  $Id: Makefile.am,v 1.2 2002/10/14 09:09:09 squidadm Exp $
+#  $Id: Makefile.am,v 1.2.4.1 2002/10/15 02:09:41 rbcollins Exp $
 #
 #  Uncomment and customize the following to suit your needs:
 #
@@ -73,7 +73,8 @@
 
 SUBDIRS		= fs repl auth
 
-INCLUDES        = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include
+INCLUDES        = -I. -I$(srcdir) -I$(top_builddir)/include \
+	-I$(top_srcdir)/include -I$(top_srcdir)/lib/libTrie/include
 
 EXTRA_PROGRAMS = \
 	unlinkd \
@@ -236,7 +237,7 @@
 	auth_modules.cc \
 	store_modules.cc \
 	cf_parser.h \
-	globals.c \
+	globals.cc \
 	string_arrays.c
 
 squid_LDADD = \
@@ -265,12 +266,12 @@
 recv_announce_SOURCES = recv-announce.cc
 
 nodist_pinger_SOURCES = \
-	globals.c
+	globals.cc
 
 BUILT_SOURCES = \
 	cf_gen_defines.h \
 	cf_parser.h \
-	globals.c \
+	globals.cc \
 	string_arrays.c \
 	repl_modules.cc \
 	auth_modules.cc \
@@ -320,7 +321,7 @@
 
 snmp_core.o snmp_agent.o: ../snmplib/libsnmp.a $(top_srcdir)/include/cache_snmp.h
 
-globals.c: globals.h mk-globals-c.pl
+globals.cc: globals.h mk-globals-c.pl
 	$(PERL) $(srcdir)/mk-globals-c.pl < $(srcdir)/globals.h > $@
 
 string_arrays.c: enums.h mk-string-arrays.pl
@@ -401,7 +402,7 @@
 	fi
 
 DISTCLEANFILES = cf_gen_defines.h cf.data cf_parser.h squid.conf.default \
-	globals.c string_arrays.c repl_modules.cc auth_modules.cc store_modules.cc
+	globals.cc string_arrays.c repl_modules.cc auth_modules.cc store_modules.cc
 
 ##install-pinger:
 ##	@f=$(PINGER_EXE); \
Index: squid3/src/protos.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/protos.h,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -r1.2 -r1.2.4.1
--- squid3/src/protos.h	14 Oct 2002 09:09:09 -0000	1.2
+++ squid3/src/protos.h	15 Oct 2002 02:09:41 -0000	1.2.4.1
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.2 2002/10/14 09:09:09 squidadm Exp $
+ * $Id: protos.h,v 1.2.4.1 2002/10/15 02:09:41 rbcollins Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -407,7 +407,8 @@
 /* Http Header Tools */
 SQUIDCEXTERN HttpHeaderFieldInfo *httpHeaderBuildFieldsInfo(const HttpHeaderFieldAttrs * attrs, int count);
 SQUIDCEXTERN void httpHeaderDestroyFieldsInfo(HttpHeaderFieldInfo * info, int count);
-SQUIDCEXTERN http_hdr_type httpHeaderIdByName(const char *name, int name_len, const HttpHeaderFieldInfo * attrs, int end);
+class Trie;
+extern http_hdr_type httpHeaderIdByName(const char *name, int name_len, Trie *searchIn);
 SQUIDCEXTERN http_hdr_type httpHeaderIdByNameDef(const char *name, int name_len);
 SQUIDCEXTERN const char *httpHeaderNameById(int id);
 SQUIDCEXTERN void httpHeaderMaskInit(HttpHeaderMask * mask, int value);
