---------------------
PatchSet 6706 
Date: 2008/01/23 16:46:35
Author: arthur-tumanyan
Branch: HEAD
Tag: (none) 
Log:
*** empty log message ***

Members: 
	configure.in:1.173->1.174 
	src/Makefile.am:1.136->1.137 
	src/access_log.cc:1.51->1.52 
	src/cf.data.pre:1.169->1.170 
	src/cf_gen_defines:1.4->1.5 
	src/main.cc:1.93->1.94 
	src/protos.h:1.91->1.92 
	src/structs.h:1.124->1.125 

Index: squid3/configure.in
===================================================================
RCS file: /cvsroot/squid-sf//squid3/configure.in,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -r1.173 -r1.174
--- squid3/configure.in	22 Jan 2008 15:50:56 -0000	1.173
+++ squid3/configure.in	23 Jan 2008 16:46:35 -0000	1.174
@@ -1,7 +1,7 @@
 
 dnl  Configuration input file for Squid
 dnl
-dnl  $Id: configure.in,v 1.173 2008/01/22 15:50:56 squidadm Exp $
+dnl  $Id: configure.in,v 1.174 2008/01/23 16:46:35 arthur-tumanyan Exp $
 dnl
 dnl
 dnl
@@ -11,7 +11,7 @@
 AC_CONFIG_AUX_DIR(cfgaux)
 AC_CONFIG_SRCDIR([src/main.cc])
 AM_INIT_AUTOMAKE([tar-ustar])
-AC_REVISION($Revision: 1.173 $)dnl
+AC_REVISION($Revision: 1.174 $)dnl
 AC_PREFIX_DEFAULT(/usr/local/squid)
 AM_MAINTAINER_MODE
 
@@ -856,6 +856,19 @@
 dnl SSL is not enabled by default.
 AM_CONDITIONAL(ENABLE_SSL, false)
 
+dnl  Shaga support is not enabled by default
+AM_CONDITIONAL(ENABLE_SHAGA, false)
+AC_ARG_ENABLE(shaga,
+[  --enable-shaga          Enable ShagaEngine support],
+[ if test "$enableval" != "no"; then
+    echo "ShagaEngine support enabled"
+    AC_DEFINE(USE_SHAGA, 1, [Define this to include code for ShagaEngine.])
+    AM_CONDITIONAL(ENABLE_SHAGA, true)
+	SHAGALIB="-L/usr/local/lib/mysql -lmysqlclient -lz -lcrypt -lm"	
+fi
+])
+AC_SUBST(SHAGALIB)
+
 dnl Default is to use OpenSSL when available
 AC_ARG_ENABLE(ssl,
 [  --enable-ssl            Enable ssl gatewaying support using OpenSSL],
Index: squid3/src/Makefile.am
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/Makefile.am,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -r1.136 -r1.137
--- squid3/src/Makefile.am	14 Jan 2008 13:51:53 -0000	1.136
+++ squid3/src/Makefile.am	23 Jan 2008 16:46:35 -0000	1.137
@@ -1,7 +1,7 @@
 #
 #  Makefile for the Squid Object Cache server
 #
-#  $Id: Makefile.am,v 1.136 2008/01/14 13:51:53 squidadm Exp $
+#  $Id: Makefile.am,v 1.137 2008/01/23 16:46:35 arthur-tumanyan Exp $
 #
 #  Uncomment and customize the following to suit your needs:
 #
@@ -121,6 +121,12 @@
 UNLINKD = 
 endif
 
+if ENABLE_SHAGA
+SHAGASOURCE = shaga.cc shaga.h
+else
+SHAGASOURCE = 
+endif
+
 if ENABLE_PINGER
 PINGER = pinger
 else
@@ -197,12 +203,13 @@
 
 AM_CFLAGS = @SQUID_CFLAGS@
 AM_CXXFLAGS = @SQUID_CXXFLAGS@
-
+MYSQL_INC_DIR = /usr/local/include/mysql
+MYSQL_LIB_DIR = /usr/local/lib/mysql
 EXTRA_LIBRARIES = libAIO.a libBlocking.a libDiskDaemon.a libDiskThreads.a ICAP/libicap.a
 noinst_LIBRARIES = @DISK_LIBS@ @ICAP_LIBS@
 noinst_LTLIBRARIES = libsquid.la libauth.la
 
-INCLUDES        = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir)/lib/libTrie/include
+INCLUDES        = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir)/lib/libTrie/include -I$(MYSQL_INC_DIR) -I$(MYSQL_LIB_DIR)
 INCLUDES	+= @SQUID_CPPUNIT_INC@
 
 EXTRA_PROGRAMS = \
@@ -420,6 +427,7 @@
 	ACLChecklist.cc \
 	ACLChecklist.h \
 	$(squid_ACLSOURCES) \
+	$(SHAGASOURCE) \
 	asn.cc \
 	AsyncCall.cc \
 	AsyncCall.h \
@@ -672,6 +680,7 @@
 	@SSLLIB@ \
 	-lmiscutil \
 	@XTRA_LIBS@ \
+	@SHAGALIB@ \
 	@EPOLL_LIBS@ \
 	@MINGW_LIBS@ 
 squid_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
@@ -796,6 +805,7 @@
 	clientStream.h \
 	CommIO.h \
 	$(squid_COMMSOURCES) \
+	$(SHAGASOURCE) \
 	ConfigOption.cc \
 	defines.h \
 	$(DELAY_POOL_SOURCE) \
@@ -918,6 +928,7 @@
 	-lmiscutil \
 	@XTRA_LIBS@ \
 	@EPOLL_LIBS@ \
+	@SHAGALIB@ \
 	@MINGW_LIBS@ 
 ufsdump_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
 	@STORE_OBJS@ \
@@ -1334,6 +1345,7 @@
 	client_side_request.cc \
 	clientStream.cc \
 	$(squid_COMMSOURCES) \
+	$(SHAGASOURCE) \
 	ConfigOption.cc \
 	ConfigParser.cc \
 	$(DELAY_POOL_SOURCE) \
@@ -1507,6 +1519,7 @@
 	$(DELAY_POOL_SOURCE) \
 	disk.cc \
 	$(DNSSOURCE) \
+	$(SHAGASOURCE) \
 	event.cc \
 	errorpage.cc \
 	$(ESI_SOURCE) \
@@ -1890,6 +1903,7 @@
 	peer_digest.cc \
 	peer_select.cc \
 	pconn.cc \
+	$(SHAGASOURCE) \
 	redirect.cc \
 	referer.cc \
 	refresh.cc \
@@ -2372,6 +2386,7 @@
 	gopher.cc \
 	helper.cc \
 	$(HTCPSOURCE) \
+	$(SHAGASOURCE) \
 	http.cc \
 	HttpBody.cc \
 	HttpHeader.cc \
Index: squid3/src/access_log.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/access_log.cc,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- squid3/src/access_log.cc	20 Jan 2008 09:50:56 -0000	1.51
+++ squid3/src/access_log.cc	23 Jan 2008 16:46:35 -0000	1.52
@@ -1,6 +1,6 @@
 
 /*
- * $Id: access_log.cc,v 1.51 2008/01/20 09:50:56 squidadm Exp $
+ * $Id: access_log.cc,v 1.52 2008/01/23 16:46:35 arthur-tumanyan Exp $
  *
  * DEBUG: section 46    Access Log
  * AUTHOR: Duane Wessels
@@ -1316,6 +1316,23 @@
                       hier_strings[al->hier.code],
                       al->hier.host,
                       al->http.content_type);
+
+#if USE_SHAGA
+char t_timestamp[13];
+char t_user[8];
+char t_ip[15];
+char t_byte[15];
+if(Config.onoff.enable_shaga){
+//
+snprintf(t_timestamp,13,"%9ld.%03d", (long int)current_time.tv_sec,( (int)current_time.tv_usec / 1000));
+sscanf((user ? user : dash_str),"%s",t_user);
+sscanf(client,"%s",t_ip);
+snprintf(t_byte,15,"%ld",(long int)al->cache.size);
+//
+	writeToDB(t_timestamp,t_user,t_ip,t_byte); /* write to db TIMESTAMP ,USER ,IP ,BYTE */
+}
+#endif
+
     } else {
         char *ereq = log_quote(al->headers.request);
         char *erep = log_quote(al->headers.reply);
@@ -1336,6 +1353,23 @@
                       al->http.content_type,
                       ereq,
                       erep);
+
+#if USE_SHAGA
+char t_timestamp[13];
+char t_user[8];
+char t_ip[15];
+char t_byte[15];
+if(Config.onoff.enable_shaga){
+//
+snprintf(t_timestamp,13,"%9ld.%03d", (long int)current_time.tv_sec,( (int)current_time.tv_usec / 1000));
+sscanf((user ? user : dash_str),"%s",t_user);
+sscanf(client,"%s",t_ip);
+snprintf(t_byte,15,"%ld",(long int)al->cache.size);
+//
+	writeToDB(t_timestamp,t_user,t_ip,t_byte); /* write to db TIMESTAMP ,USER ,IP ,BYTE */
+}
+#endif
+
         safe_free(ereq);
         safe_free(erep);
     }
Index: squid3/src/cf.data.pre
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/cf.data.pre,v
retrieving revision 1.169
retrieving revision 1.170
diff -u -r1.169 -r1.170
--- squid3/src/cf.data.pre	20 Jan 2008 11:51:46 -0000	1.169
+++ squid3/src/cf.data.pre	23 Jan 2008 16:46:35 -0000	1.170
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.169 2008/01/20 11:51:46 squidadm Exp $
+# $Id: cf.data.pre,v 1.170 2008/01/23 16:46:35 arthur-tumanyan Exp $
 #
 # SQUID Web Proxy Cache		http://www.squid-cache.org/
 # ----------------------------------------------------------
@@ -5520,5 +5520,69 @@
 	On Windows value less then 1000 (1 milliseconds) are
 	rounded to 1000.
 DOC_END
+NAME: enable_shaga_engine
+COMMENT: on|off
+IFDEF: USE_SHAGA
+TYPE: onoff
+LOC: Config.onoff.enable_shaga
+DEFAULT: on
+DOC_START
+	When this set to on,squid will write some entries from access.log file into database
+DOC_END
+
+NAME: shaga_db_host
+COMMENT: mysql server ip address
+IFDEF: USE_SHAGA
+TYPE: string
+LOC: Config.Shaga.db_host
+DEFAULT: 10.0.0.1
+DOC_START
+DOC_END
+
+NAME: shaga_db_port
+COMMENT: listening port of mysql server
+IFDEF: USE_SHAGA
+TYPE: ushort
+LOC: Config.Shaga.db_port
+DEFAULT: 3306
+DOC_START
+DOC_END
+
+NAME: shaga_db_name
+COMMENT: shaga database name
+IFDEF: USE_SHAGA
+TYPE: string
+LOC: Config.Shaga.db_name
+DEFAULT: shaga
+DOC_START
+DOC_END
+
+NAME: shaga_db_user
+COMMENT: shaga database user
+IFDEF: USE_SHAGA
+TYPE: string
+LOC: Config.Shaga.db_user
+DEFAULT: shaga
+DOC_START
+DOC_END
+
+NAME: shaga_db_pwd
+COMMENT: shaga database password
+IFDEF: USE_SHAGA
+TYPE: string
+LOC: Config.Shaga.db_pwd
+DEFAULT: shaga
+DOC_START
+DOC_END
+
+NAME: enable_db_config
+COMMENT: on|off
+IFDEF: USE_SHAGA
+TYPE: onoff
+LOC: Config.onoff.enable_db_config
+DEFAULT: off
+DOC_START
+	When this set to on,squid will read (some) configuration parameters from database
+DOC_END
 
 EOF
Index: squid3/src/cf_gen_defines
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/cf_gen_defines,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- squid3/src/cf_gen_defines	2 Jul 2006 17:50:45 -0000	1.4
+++ squid3/src/cf_gen_defines	23 Jan 2008 16:46:36 -0000	1.5
@@ -20,6 +20,7 @@
 	define["USE_WCCP"]="--enable-wccp"
 	define["USE_WCCPv2"]="--enable-wccpv2"
 	define["ESI"]="--enable-esi"
+	define["USE_SHAGA"]="--enable-shaga"
 }
 /^IFDEF:/ {
 	if (define[$2] != "")
Index: squid3/src/main.cc
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/main.cc,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -r1.93 -r1.94
--- squid3/src/main.cc	22 Jan 2008 17:51:40 -0000	1.93
+++ squid3/src/main.cc	23 Jan 2008 16:46:36 -0000	1.94
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.93 2008/01/22 17:51:40 squidadm Exp $
+ * $Id: main.cc,v 1.94 2008/01/23 16:46:36 arthur-tumanyan Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -667,7 +667,14 @@
 
     wccp2Init();
 #endif
+#ifdef USE_SHAGA
+if(Config.onoff.enable_shaga){
+	
+	shutdown_shaga_support();
+	init_shaga_support();
 
+}else _db_print("ShagaEngine is disabled\n");
+#endif
     serverConnectionsOpen();
 
     neighbors_init();
@@ -986,7 +993,13 @@
     wccp2Init();
 
 #endif
+#ifdef USE_SHAGA
+if(Config.onoff.enable_shaga){
+
+	init_shaga_support();
 
+}else _db_print("ShagaEngine is disabled\n");
+#endif
     serverConnectionsOpen();
 
     neighbors_init();
@@ -1628,7 +1641,11 @@
 
     wccp2ConnectionClose();
 #endif
-
+#ifdef USE_SHAGA
+if(Config.onoff.enable_shaga){
+	shutdown_shaga_support();
+}
+#endif
     releaseServerSockets();
     commCloseAllSockets();
 #if DELAY_POOLS
Index: squid3/src/protos.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/protos.h,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -r1.91 -r1.92
--- squid3/src/protos.h	22 Jan 2008 01:21:46 -0000	1.91
+++ squid3/src/protos.h	23 Jan 2008 16:46:36 -0000	1.92
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.91 2008/01/22 01:21:46 squidadm Exp $
+ * $Id: protos.h,v 1.92 2008/01/23 16:46:36 arthur-tumanyan Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -808,5 +808,15 @@
 SQUIDCEXTERN void dump_wccp2_service_info(StoreEntry * e, const char *label, void *v);
 
 #endif
+/* shaga.cc */
+#ifdef USE_SHAGA
+SQUIDCEXTERN int db_connect(char *dbhost,char *dbuser,char *dbpwd,char *dbname,unsigned int dbport);
+SQUIDCEXTERN void init_shaga_support();
+SQUIDCEXTERN void shutdown_shaga_support();
+SQUIDCEXTERN int getExcludeHosts();
+SQUIDCEXTERN int isExHost(char *host);
+SQUIDCEXTERN int writeToDB(char * __time,char * username,char * ip_address,char * byte);
+
+#endif
 
 #endif /* SQUID_PROTOS_H */
Index: squid3/src/structs.h
===================================================================
RCS file: /cvsroot/squid-sf//squid3/src/structs.h,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -r1.124 -r1.125
--- squid3/src/structs.h	19 Jan 2008 07:50:42 -0000	1.124
+++ squid3/src/structs.h	23 Jan 2008 16:46:36 -0000	1.125
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.124 2008/01/19 07:50:42 squidadm Exp $
+ * $Id: structs.h,v 1.125 2008/01/23 16:46:36 arthur-tumanyan Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -192,6 +192,16 @@
 struct _SquidConfig
 {
 
+#ifdef USE_SHAGA
+struct {
+	char 		*db_host;
+	u_short		db_port;
+	char		*db_name;
+	char		*db_user;
+	char		*db_pwd;
+}Shaga;
+#endif
+
     struct
     {
         /* These should be for the Store::Root instance.
@@ -535,6 +545,10 @@
 
         int surrogate_is_remote;
 #endif
+#if USE_SHAGA
+	int enable_shaga;
+	int enable_db_config;
+#endif
 
         int request_entities;
         int detect_broken_server_pconns;
