incubator-triplesoup-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject svn commit: r528394 [5/35] - in /incubator/triplesoup/donations/TRIPLES-3-RDFStore: ./ dbms/ dbms/client/ dbms/client/t/ dbms/dbmsproxy/ dbms/deamon/ dbms/doc/ dbms/include/ dbms/libdbms/ dbms/utils/ doc/ include/ lib/ lib/DBD/ lib/RDFStore/ lib/RDFSto...
Date Fri, 13 Apr 2007 08:56:16 GMT
Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/INSTALL
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/INSTALL?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/INSTALL (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/INSTALL Fri Apr 13 01:56:01 2007
@@ -0,0 +1,21 @@
+
+(you should stop any other DBMS running on this machine on port 1234)
+
+Edit the file 'arch.conf' for any platform specific things, in particular
+the location od your db1/db2 libraries on linux.
+
+Type:
+
+make;
+make test;
+make install;
+
+By default the dbmsd get installed under the /RDFStore branch
+ 
+
+NOTE for Linux or no-BSD platforms:
+----------------------------------
+
+The dbmsd(8) TCP/IP deamon code is actually under development and has only been tested on FreeBSD platforms using old Berkeley DB 1.x style interface. Most Linux distributions today come with newer BerkeleyDB >>1.85 (2.x or better) bundled installations and db185 compatibility API and code compiled in. To properly compile dbmsd(8) you must have libdb1 and db_185.h properly installed on your machine. Then edit the deamon/Makefile (LIBS = -ldb1) and compile the package.
+
+If you can not get it to compile, do not disperate and try to use BerkleyDB, DB_File or SDBM_File styles instead :-)

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/Makefile
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/Makefile?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/Makefile (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/Makefile Fri Apr 13 01:56:01 2007
@@ -0,0 +1,45 @@
+# *
+# *     Copyright (c) 2000-2006 Alberto Reggiori <areggiori@webweaving.org>
+# *                        Dirk-Willem van Gulik <dirkx@webweaving.org>
+# *
+# * NOTICE
+# *
+# * This product is distributed under a BSD/ASF like license as described in the 'LICENSE'
+# * file you should have received together with this source code. If you did not get a
+# * a copy of such a license agreement you can pick up one at:
+# *
+# *     http://rdfstore.sourceforge.net/LICENSE
+# *
+# * 
+TFILE=dbms-`date +%Y-%m-%d`
+
+all: 
+	( cd deamon; make )
+	( cd libdbms; make )
+	( cd dbmsproxy; make )
+	( cd client; perl Makefile.PL && make )
+
+tar:	clean
+	if [ -f client/Makefile ] ; then ( cd client; make realclean ); fi
+	( cd deamon; make clean )
+	mkdir -p ../$(TFILE) 
+	cp -r . ../$(TFILE)
+	cd ..
+	tar zcf $(TFILE).tar.gz $(TFILE)
+
+test:
+	( cd deamon; make test )
+
+clean:
+	( cd deamon; make clean )
+	( cd libdbms; make clean )
+	( cd dbmsproxy; make clean )
+	( cd client; make realclean )
+
+install: all
+	( cd deamon; make install )
+	( cd dbmsproxy; make install )
+	( cd libdbms; make install )
+
+depend:
+	( cd deamon; make depend )

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/VERSION
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/VERSION?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/VERSION (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/VERSION Fri Apr 13 01:56:01 2007
@@ -0,0 +1 @@
+$Id: VERSION,v 1.1.1.1 2002/06/17 09:30:35 areggiori Exp $

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/arch.conf
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/arch.conf?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/arch.conf (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/arch.conf Fri Apr 13 01:56:01 2007
@@ -0,0 +1,94 @@
+# *
+# *     Copyright (c) 2000-2006 Alberto Reggiori  <areggiori@webweaving.org>
+# *     		        Dirk-Willem van Gulik <dirkx@webweaving.org>
+# *
+# * NOTICE
+# *
+# * This product is distributed under a BSD/ASF like license as described in the 'LICENSE'
+# * file you should have received together with this source code. If you did not get a
+# * a copy of such a license agreement you can pick up one at:
+# *
+# *     http://rdfstore.sourceforge.net/LICENSE
+# *
+#
+INSTDIR=/RDFStore
+
+TESTDIR=/usr/tmp/test.dbstore
+PIDFILE=/usr/tmp/test.dbstore.pid
+
+#CC = gcc
+RANLIB = ranlib
+LINT = lint
+LINTFLAGS = -chapbx
+
+INCLUDES= -I../include -I../../include
+
+DEFINES +=  -DRDFSTORE_PLATFORM_DARWIN
+
+###### BEGIN specific confs
+
+# add the include directory of your BDB installation is if not found to the bottom line
+#INCLUDES += -I/usr/local/BerkeleyDB-4.0.14/include
+
+# add the library directory of your BDB installation is if not found to the bottom line
+LIBS_DIR  = -L../libdbms  # -L/usr/local/BerkeleyDB-4.0.14/lib
+#BDB_LD_LIBS_DIR = /usr/local/BerkeleyDB-4.0.14/lib
+
+
+# uncomment one the following lines if your BDB library is not found. 
+#
+# NOTE: most BSD systems have BDB built in in the 'libc' standard C 
+#       library and do not need the bottom definition
+#
+
+# anything not built in and linux platforms in general
+#LIBS = -ldb
+UID=root
+GID=wheel
+
+
+# uncomment the following line to use BDB 1.85 compatibility code
+#DEFINES += " -DCOMPAT185 -DDB_LIBRARY_COMPATIBILITY_API "
+
+###### END specific confs
+
+LFLAGS = -g3 
+CFLAGS = -g3
+
+
+#
+# Whether to fork(on BSD) or multitread(on Irix)
+# or not at all. You propably want to leave this
+# in as the non-tread/non-fork versions have not
+# been used in a long time...
+#
+DEFINES += -DFORKING
+#
+# General debugging; also, some asserts present
+# so should use -NDEBUG :-)
+#
+# DEFINES += -DRDFSTORE_DBMS_DEBUG
+# 
+# Bit of malloc tracing, basically a
+# free check on termination
+#
+# DEFINES += -DRDFSTORE_DBMS_DEBUG_MALLOC
+# 
+# Wether to malloc once; and keep it on
+# a linked list; or contineously malloc/free
+# for dbase/child/connect structs, i.e. the
+# 'long' lived things (i.e. >= session time)
+#
+DEFINES += -DSTATIC_BUFF
+#
+# Same for short (per transact) buffers
+#
+DEFINES +=  -DSTATIC_CS_BUFF
+DEFINES +=  -DSTATIC_SC_BUFF
+#
+# If your kernel allows it.. *implies a 
+# kernel recompile normally*
+#
+# DEFINES += -DFD_SETSIZE=4048
+#
+

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/arch.conf-sample
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/arch.conf-sample?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/arch.conf-sample (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/arch.conf-sample Fri Apr 13 01:56:01 2007
@@ -0,0 +1,94 @@
+# *
+# *     Copyright (c) 2000-2006 Alberto Reggiori  <areggiori@webweaving.org>
+# *     		        Dirk-Willem van Gulik <dirkx@webweaving.org>
+# *
+# * NOTICE
+# *
+# * This product is distributed under a BSD/ASF like license as described in the 'LICENSE'
+# * file you should have received together with this source code. If you did not get a
+# * a copy of such a license agreement you can pick up one at:
+# *
+# *     http://rdfstore.sourceforge.net/LICENSE
+# *
+#
+INSTDIR=/RDFStore
+
+TESTDIR=/usr/tmp/test.dbstore
+PIDFILE=/usr/tmp/test.dbstore.pid
+
+#CC = gcc
+RANLIB = ranlib
+LINT = lint
+LINTFLAGS = -chapbx
+
+INCLUDES= -I../include
+
+DEFINES +=  -DRDFSTORE_PLATFORM_FREEBSD
+
+###### BEGIN specific confs
+
+# add the include directory of your BDB installation is if not found to the bottom line
+#INCLUDES += -I/usr/local/BerkeleyDB-4.0.14/include
+
+# add the library directory of your BDB installation is if not found to the bottom line
+#LIBS_DIR = -L/usr/local/BerkeleyDB-4.0.14/lib
+
+# uncomment one the following lines if your BDB library is not found. 
+#
+# NOTE: most BSD systems have BDB built in in the 'libc' standard C 
+#       library and do not need the bottom definition
+#
+
+# anything not built in and linux platforms in general
+#LIBS = -ldb
+UID=bin
+GID=bin
+
+
+# uncomment the following line to use BDB 1.85 compatibility code
+#DEFINES += " -DCOMPAT185 -DDB_LIBRARY_COMPATIBILITY_API "
+
+###### END specific confs
+
+LFLAGS = -g3 
+CFLAGS = -g3 -Wall -Werror
+
+# For profiling..
+# CFLAGS += -a -pg
+
+#
+# Whether to fork(on BSD) or multitread(on Irix)
+# or not at all. You propably want to leave this
+# in as the non-tread/non-fork versions have not
+# been used in a long time...
+#
+DEFINES += -DFORKING
+#
+# General debugging; also, some asserts present
+# so should use -NDEBUG :-)
+#
+# DEFINES += -DRDFSTORE_DBMS_DEBUG
+# 
+# Bit of malloc tracing, basically a
+# free check on termination
+#
+# DEFINES += -DRDFSTORE_DBMS_DEBUG_MALLOC
+# 
+# Wether to malloc once; and keep it on
+# a linked list; or contineously malloc/free
+# for dbase/child/connect structs, i.e. the
+# 'long' lived things (i.e. >= session time)
+#
+DEFINES += -DSTATIC_BUFF
+#
+# Same for short (per transact) buffers
+#
+DEFINES +=  -DSTATIC_CS_BUFF
+DEFINES +=  -DSTATIC_SC_BUFF
+#
+# If your kernel allows it.. *implies a 
+# kernel recompile normally*
+#
+# DEFINES += -DFD_SETSIZE=4048
+#
+

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/.cvsignore
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/.cvsignore?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/.cvsignore (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/.cvsignore Fri Apr 13 01:56:01 2007
@@ -0,0 +1,5 @@
+blib
+Makefile
+pm_to_blib
+DBMS.c
+DBMS.bs

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/Makefile.PL
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/Makefile.PL?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/Makefile.PL (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/Makefile.PL Fri Apr 13 01:56:01 2007
@@ -0,0 +1,42 @@
+# *
+# *     Copyright (c) 2000-2006 Alberto Reggiori <areggiori@webweaving.org>
+# *                        Dirk-Willem van Gulik <dirkx@webweaving.org>
+# *
+# * NOTICE
+# *
+# * This product is distributed under a BSD/ASF like license as described in the 'LICENSE'
+# * file you should have received together with this source code. If you did not get a
+# * a copy of such a license agreement you can pick up one at:
+# *
+# *     http://rdfstore.sourceforge.net/LICENSE
+# *
+# *
+# *     $Id: Makefile.PL,v 1.13 2006/06/19 10:10:22 areggiori Exp $
+
+use strict;
+use ExtUtils::MakeMaker 5.16 qw(WriteMakefile prompt);
+use Config;
+
+die "RDFStore needs Perl 5.004_05 or better. This is $]
+"
+    if $] <= 5.00404;
+
+$| = 1;
+
+# this makefile will be used *just* for perl based dbmsd(8) testing (see ../README)
+WriteMakefile(
+        # any idea how to just make the bloody Makefile.PL to see ../../lib/DBMS.pm dyna linked to ../blib/arch/auto/RDFStore/RDFStore.so ???
+        # just now copy all the modules of the main dir locally to while makeing test - the DBMS.pm module is installed with the main dist anyway!
+        #PM => {'../../blib/lib/DBMS.pm' => '$(INST_LIBDIR)/DBMS.pm'}
+        #PM => { '../../blib/lib/RDFStore.pm' => '$(INST_LIBDIR)/RDFStore.pm', '../../blib/lib/DBMS.pm' => '$(INST_LIBDIR)/DBMS.pm' }
+        # this is the only one making sense and kinda working....
+        PMLIBDIRS => [ '../../blib/lib', '../../blib/arch/' ]
+        );
+
+# XXXX -- perhaps overwrite the DBMS.pm and
+# add:
+#	eval("sub DBMS_XSMODE_DEFAULT () { 0; }") unless defined(&DBMS_XSMODE_DEFAULT);
+#	eval("sub DBMS_XSMODE_RDONLY () { 1; }") unless defined(&DBMS_XSMODE_RDONLY);
+#	eval("sub DBMS_XSMODE_RDWR () { 2; }") unless defined(&DBMS_XSMODE_RDWR);
+#	eval("sub DBMS_XSMODE_CREAT () { 3; }") unless defined(&DBMS_XSMODE_CREAT);
+#	eval("sub DBMS_XSMODE_DROP () { 4; }") unless defined(&DBMS_XSMODE_DROP);

Propchange: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/Makefile.PL
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/00.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/00.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/00.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/00.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,13 @@
+print "1..3\n";
+use DBMS;
+
+
+# Check if h2ph on ../dbms/include/dbms.h gerunned is..
+#
+
+
+tie %a ,DBMS,'aah',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$a{'key_in_a'} = 'val_in_a';
+print (($a{ "key_in_a" } eq "val_in_a") ? "ok\n" : "not ok\n");
+untie %a;
+print "ok\n";

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/01.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/01.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/01.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/01.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,23 @@
+print "1..8\n";
+
+use DBMS;
+
+
+tie %a ,DBMS,'aah',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "$! 1";
+untie %a;
+tie %b ,DBMS,'bee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "$! 2";
+untie %b;
+
+tie %a ,DBMS,'aah',&DBMS::XSMODE_RDONLY,0 and print "ok\n" or die "$! 3";
+tie %b ,DBMS,'bee',&DBMS::XSMODE_RDONLY,0 and print "ok\n" or die "$! 4";
+$p = $a{ key_in_a };
+$p = $a{ key_in_b };
+
+tie %a ,DBMS,'aah',&DBMS::XSMODE_RDWR,0 and print "ok\n" or die "$! 3";
+tie %b ,DBMS,'bee',&DBMS::XSMODE_RDWR,0 and print "ok\n" or die "$! 4";
+$a{ key_in_a } = val_in_a;
+$b{ key_in_b } = val_in_b;
+
+untie %b and print "ok\n" or warn $!;
+untie %a and print "ok\n" or warn $!;
+ 

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/02.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/02.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/02.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/02.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,26 @@
+print "1..4\n";
+
+$|=1;
+$N=shift || 500;
+use DBMS;
+
+no strict;
+
+foreach my $ci (1 .. 4) {
+	undef $DBMS::ERROR;
+	my $a=tie %aap, 'DBMS','zappazoink',&DBMS::XSMODE_CREAT,0
+		or die "E= $DBMS::ERROR $! $@ $?";
+
+	for $i (1 .. $N) {
+		$aap{ $i } = $i;
+		};
+
+	for $i (1 .. $N) {
+		($c=$aap{ $i }) == $i || print "not ok\n";
+		print "not ok\n" unless defined $c;
+		};
+
+	undef $a;
+	untie %aap;
+	print "ok\n";
+	};

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/03.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/03.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/03.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/03.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,27 @@
+print "1..100\n";
+
+$|=1;
+$N=shift || 150;
+use DBMS;
+
+no strict;
+undef $DBMS::ERROR;
+
+my $a=tie %aap, 'DBMS','zappazoink',&DBMS::XSMODE_CREAT,0
+	or die "E= $DBMS::ERROR $! $@ $?";
+
+foreach my $ci (1 .. 100) {
+
+	for $i (1 .. $N) {
+		$aap{ $i } = $i;
+		};
+
+	for $i (1 .. $N) {
+		($c=$aap{ $i }) == $i || print "not ok\n";
+		print "not ok\n" unless defined $c;
+		};
+print "ok\n";
+	};
+
+undef $a;
+untie %aap;

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/04.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/04.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/04.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/04.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,26 @@
+print "1..5\n";
+
+$|=1;
+$N=shift || 500;
+use DBMS;
+
+no strict;
+
+foreach $db (1 .. 5) {
+my $a=tie %aap, 'DBMS','zappazoink'.$db,&DBMS::XSMODE_CREAT,0
+	or print "not ok\n";
+
+for $i (1..$N) {
+	$aap{ $i } = $i;
+	};
+
+for $i (1..$N) {
+	($c=$aap{ $i }) == $i || print "not ok\n";
+	print "not ok\n" unless defined $c;
+	};
+
+undef $a;
+untie %aap;
+
+print "ok\n";
+}

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/05.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/05.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/05.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/05.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,40 @@
+$childs=12;
+$|=1;
+print "1..".(1+$childs*6)."\n";
+
+use DBMS;
+
+
+for $c ( 1..$childs ) {
+	if (fork()==0) {
+$|=1;
+tie %a ,DBMS,'aah',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+tie %b ,DBMS,'bee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$a{ key_in_a } = val_in_a;
+$b{ key_in_b } = val_in_b;
+untie %b;
+untie %a;
+
+tie %c ,DBMS,'cee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$c{ key_in_c } = val_in_c;
+untie %c;
+
+tie %a ,DBMS,'aah',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+tie %b ,DBMS,'bee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$a{ key_in_a } = val_in_a;
+$b{ key_in_b } = val_in_b;
+untie %b;
+untie %a;
+
+tie %c ,DBMS,'cee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$c{ key_in_c } = val_in_c;
+untie %c;
+exit;
+};
+};
+
+while(1) {
+	last if wait == -1;
+	};
+
+print "ok\n";

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/06.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/06.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/06.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/06.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,31 @@
+print "1..8\n";
+
+use DBMS;
+
+
+tie %a,DBMS,'zoink',&DBMS::XSMODE_CREAT,0 and print "ok\n"
+	or die "could not connect $!";
+
+%a=();
+for $r ( 1 .. 10) {
+	$a{ $r } = $r x (16*8);
+	};
+
+print "ok\n";
+
+$|=1;
+for $i (1..3) {
+	untie %a;
+	tie %a,DBMS,'zoink',&DBMS::XSMODE_CREAT,0 and print "ok\n"
+		or die "could not connect $!";
+
+	for $i (1..2) {
+		for $r (1..10) {
+			$c = $a{ $r };
+			$c='';
+			};
+		};
+	print "ok\n";
+	};
+%a=();
+untie %a;

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/07.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/07.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/07.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/07.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,15 @@
+$|=1;
+print "1..32\n";
+
+use DBMS;
+fork(); fork(); fork(); 
+fork(); 
+# fork(); # 64
+# fork();  #128
+$|=1;
+
+tie %a ,DBMS,'aah',&DBMS::XSMODE_CREAT,0 and print "ok\n" or print "not ok\n";
+print "ok\n";
+sleep(1);
+
+untie %a;

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/08.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/08.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/08.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/08.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,13 @@
+$|=1;
+print "1..32\n";
+
+
+use DBMS;
+fork(); fork(); fork(); 
+fork(); # fork(); fork();  # 128
+$|=1;
+
+tie %a ,DBMS,'aah'.$$,&DBMS::XSMODE_CREAT,0 and print "ok\n" or print "not ok\n";
+print "ok\n";
+sleep(1);
+untie %a;

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/09.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/09.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/09.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/09.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,38 @@
+$childs=3;
+$|=1;
+print "1..".(1+$childs*6)."\n";
+
+use DBMS;
+for $cc ( 1..$childs ) {
+	if (fork()==0) {
+$|=1;
+tie %a ,DBMS,'aah'.$cc.$$,&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+tie %b ,DBMS,'bee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$a{ key_in_a } = val_in_a;
+$b{ key_in_b } = val_in_b;
+untie %b;
+untie %a;
+
+tie %c ,DBMS,'cee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$c{ key_in_c } = val_in_c;
+untie %c;
+
+tie %a ,DBMS,'aah',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+tie %b ,DBMS,'bee'.$cc.$$,&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$a{ key_in_a } = val_in_a;
+$b{ key_in_b } = val_in_b;
+untie %b;
+untie %a;
+
+tie %c ,DBMS,'cee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$c{ key_in_c } = val_in_c;
+untie %c;
+exit;
+};
+};
+
+while(1) {
+	last if wait == -1;
+	};
+
+print "ok\n";

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/10.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/10.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/10.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/10.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,24 @@
+$|=1;
+print "1..6\n";
+
+use DBMS;
+
+
+tie %a ,DBMS,'aah',&DBMS::XSMODE_RDWR,0 and print "ok\n" or die "$! 1";
+untie %a;
+tie %b ,DBMS,'bee',&DBMS::XSMODE_RDWR,0 and print "ok\n" or die "$! 2";
+untie %b;
+
+# Set to readonly - and we should see two fails
+print STDERR "Two fails coming up\n";
+tie %a ,DBMS,'aah',&DBMS::XSMODE_RDONLY,0 and print "ok\n" or die "$! 3";
+tie %b ,DBMS,'bee',&DBMS::XSMODE_RDONLY,0 and print "ok\n" or die "$! 4";
+
+$a{ key_in_a } = val_in_a;
+$b{ key_in_b } = val_in_b;
+
+print STDERR "No more fails here.\n";
+
+untie %b and print "ok\n" or warn $!;
+untie %a and print "ok\n" or warn $!;
+ 

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/11.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/11.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/11.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/11.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,171 @@
+
+$|=1;
+$nfork = 0;
+$nft = 10;
+$tests = 12 + $nfork;
+$n= 100;
+
+#use DB_File;
+use DBMS;
+
+#use File::Path qw(rmtree);
+
+no strict;
+
+print "1..$tests\n";
+$start = time;
+$forreal =1;
+$test=0;
+
+$test++; # 1
+print 1==1 ? "ok $test\n" : "not ok $test\n"
+	if $forreal;
+
+$aap = 'aap'.$$;
+$noot = 'noot'.$$;
+
+#rmtree '/usr/tmp/ti';
+
+# 2 
+$test++;
+tie %aap, 'DBMS','tiepje',&DBMS::XSMODE_CREAT,0 and print "ok $test\n" or die $!;
+
+
+# 3
+%aap=();
+$tans++;
+# try a fetch
+$test++;
+$tans++;
+print ! defined $aap{ $aap } ? "ok $test\n" : "not ok $test\n"
+	if $forreal;
+
+# 4
+# try a store..
+$aap{ $aap } = $noot;
+$test++;print 1 ? "ok $test\n" : "not ok $test\n"
+	if $forreal;
+$trans++;
+
+# 5
+# try a fetch...
+$test++;print $aap{ $aap } eq $noot ? "ok $test\n" : "not ok $test\n"
+	if $forreal;
+$trans++;
+
+# 6 
+
+$c='';$d='';
+for $i (1..$n) {
+	$j = 1+$i;
+	$c .= ( $i * $i ).'x'.$$;
+	$d .= ( $j * $j ).'y'.$$;
+	$c=substr($c,-150) if length($c) > 160;
+	$d=substr($d,-150) if length($d) > 160;
+	$aap{ $c } = $d;
+$trans++;
+	};
+$test++;print 1 ? "ok $test\n" : "not ok $test\n"
+	if $forreal;
+
+# 7 	
+$x=0;
+$c='';$d='';
+for $i (1..$n) {
+	$j = 1+$i;
+	$c .= ( $i * $i ).'x'.$$;
+	$d .= ( $j * $j ).'y'.$$;
+	$c=substr($c,-150) if length($c) > 160;
+	$d=substr($d,-150) if length($d) > 160;
+	$trans++;
+	next unless defined $aap{ $c };
+	$trans++;
+	$x++ if $aap{ $c } eq $d;
+	};
+
+$trans++;
+$test++;print $x==$n ? "ok $test\n" : "not ok $test\n"
+	if $forreal;
+
+# 8
+@keys=keys %aap;
+$trans+=1+$#keys;
+$test++;print $#keys == $n ? "ok $test\n" : "not ok $test\n"
+	if $forreal;
+
+# 9
+$trans++;
+$test++;print exists $aap{ $aap } ? "ok $test\n" : "not ok $test\n"
+	if $forreal;
+
+# 10
+$trans++;
+$test++;print !exists $aap{ $noot } ? "ok $test\n" : "not ok $test\n"
+	if $forreal;
+# 11
+
+$trans++;
+%aap = ();
+$trans++;
+$test++;print !exists $aap{ $aap } ? "ok $test\n" : "not ok $test\n"
+ 	if $forreal;
+untie %aap;
+
+# 12
+if ($nfork) {
+for $child ( 1 .. $nfork ) {
+	if (fork() == 0) {
+  	    if (fork() == 0) {
+		@k=();
+		tie %aap, 'DBMS','tiepje',&DBMS::XSMODE_CREAT,0 or die;
+		tie %aap2, 'DBMS','tiepje'.$$,&DBMS::XSMODE_CREAT,0 or die;
+		for $i ( 1 .. $nft ) {
+			$k = $i.$$.'hello';	
+			$aap{ $k } = $i.$$;
+			$aap2{ $k } = $i.$$;
+			push @k,$k;
+			};
+		foreach $k (@k) {
+			warn "1 child $child fail $$ $k" unless defined $aap{ $k };#  and $aap{ $k } eq $i.$$;
+			warn "2 child $child fail $$ $k" unless defined $aap2{ $k };#  and $aap2{ $k } eq $i.$$;
+			};
+		untie %aap2;
+		untie %aap;
+		print "ok ".($test+$child)."\n";
+		sleep(1);
+		exit 0;
+		};
+	     exit;
+	     };	
+	};
+
+do {
+	$t = wait;
+	} while ($t > 0 );
+wait;
+};
+
+tie %aap, 'DBMS','tiepje',&DBMS::XSMODE_CREAT,0;
+$trans += $nfork * $nft;
+$test += $nfork;
+
+# 13 
+$i=0;
+foreach (keys(%aap)) {
+	$trans++;
+	next unless m/hello$/;
+	$i++;
+	};
+$test++;
+print $i == $nfork * $nft ? "ok $test\n" : "not ok $test\n";
+
+%aap=();
+untie %aap;
+
+$end = time;
+my $d2 = $end - $start;
+
+#print "$trans Net Transactions ".( ($d2) ? ($trans/$d2) : 'N/A' )." tps\n";
+
+exit;
+

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/12.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/12.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/12.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/12.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,74 @@
+use strict ;
+ 
+BEGIN { print "1..8\n"; };
+END {print "not ok 1\n" unless $::loaded;};
+
+sub ok
+{
+    my $no = shift ;
+    my $result = shift ;
+ 
+    print "not " unless $result ;
+    print "ok $no\n" ;
+}
+ 
+sub docat
+{
+    my $file = shift;
+    local $/ = undef;
+    open(CAT,$file) || die "Cannot open $file:$!";
+    my $result = <CAT>;
+    close(CAT);
+    return $result;
+};
+
+umask(0);
+
+use DBMS;
+
+
+$::loaded = 1;
+print "ok 1\n";
+
+my %c;
+
+ok 2, my $db5 = tie %c,"DBMS",'test3',&DBMS::XSMODE_CREAT,0;
+
+#inc() method
+eval {
+	$c{count}=0;
+	for(1..100) { 
+		die unless $db5->inc('count'); 
+	};
+};
+ok 3, !$@;
+
+ok 4, ($c{count}==100);
+
+#dec() method
+eval {
+	for(1..100) { 
+		die unless defined $db5->dec('count'); 
+	};
+};
+ok 5, !$@;
+
+ok 6, ($c{count}==0);
+
+
+# clear
+# NOTE: the one on the DBMS server side can not obviously removed
+eval {
+	%c=()
+		if defined $db5 and tied(%c);
+};
+ok 7, !$@;
+
+eval {
+	# NOTE: the one on the DBMS server side can not obviously removed
+	%c=()
+		if defined $db5 and tied(%c);
+	undef $db5;
+	die unless untie %c;
+};
+ok 8, !$@;

Propchange: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/12.t
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/13.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/13.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/13.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/13.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,48 @@
+$childs=6;
+$|=1;
+
+print "1..".(6+$childs*6)."\n";
+$M=500;
+$dt=time;
+my $ttt = ($M*4+6+2) * $childs;
+
+use DBMS;
+for $cc ( 1..$childs ) {
+	if (fork()==0) {
+$|=1;
+tie %a ,DBMS,'aah'.$cc.$$,&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+tie %b ,DBMS,'bee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+for(1 .. $M){
+$a{ key_in_a.$_ } = val_in_a.$_;
+$b{ key_in_b } = val_in_b;
+};
+untie %b;
+untie %a;
+
+tie %c ,DBMS,'cee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$c{ key_in_c } = val_in_c;
+untie %c;
+
+tie %a ,DBMS,'aah',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+tie %b ,DBMS,'bee'.$cc.$$,&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+for(1..$M){
+$a{ key_in_a.$_ } = val_in_a;
+$b{ key_in_b } = val_in_b;
+};
+untie %b;
+untie %a;
+
+tie %c ,DBMS,'cee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$c{ key_in_c } = val_in_c;
+untie %c;
+exit;
+};
+};
+
+while(1) {
+	last if wait == -1;
+   print "ok\n";
+	};
+
+$dt = time - $dt;
+#print "N=".$ttt." ".($ttt/$dt)." ok\n";

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/14.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/14.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/14.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/14.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,26 @@
+print "1..6\n";
+use DBMS;
+
+
+$|=1;
+tie %a ,DBMS,'aah',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+tie %b ,DBMS,'bee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$a{ key_in_a } = val_in_a;
+$b{ key_in_b } = val_in_b;
+untie %b;
+untie %a;
+
+tie %c ,DBMS,'cee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$c{ key_in_c } = val_in_c;
+untie %c;
+
+tie %a ,DBMS,'aah',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+tie %b ,DBMS,'bee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$a{ key_in_a } = val_in_a;
+$b{ key_in_b } = val_in_b;
+untie %b;
+untie %a;
+
+tie %c ,DBMS,'cee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$c{ key_in_c } = val_in_c;
+untie %c;

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/20.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/20.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/20.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/20.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,27 @@
+print "1..4\n";
+
+use DBMS;
+
+
+for my $a (1..2) {
+
+tie %a,DBMS,'biggie',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+%a=();
+$last_a=$last='';
+for $i ( 1 .. 100 ) {
+	$a=  '.' x ( $i * 128 );
+
+	$a{ $i } = $a
+		or die "Storing failed: $!";
+
+	die "Retrieval failed"
+		if defined($a{ $last}) && ($a{ $last } ne $last_a) ;
+
+	$last_a = $a;
+	$last  = $i;
+	};
+%a=();
+untie %a;
+
+print "ok\n";
+};

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/33.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/33.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/33.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/33.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,44 @@
+$childs=6;
+
+$|=1;
+print "1..".(6+$childs*6)."\n";
+$M=500;
+$dt=time;
+my $ttt = ($M*4+6+2) * $childs;
+
+use DBMS;
+for $cc ( 1..$childs ) {
+	if (fork()==0) {
+$|=1;
+tie %a ,DBMS,'aah'.$cc.$$,&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+tie %b ,DBMS,'bee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$a{ key_in_a } = val_in_a;
+$b{ key_in_b } = val_in_b;
+untie %b;
+untie %a;
+
+tie %c ,DBMS,'cee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$c{ key_in_c } = val_in_c;
+untie %c;
+
+tie %a ,DBMS,'aah',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+tie %b ,DBMS,'bee'.$cc.$$,&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$a{ key_in_a } = val_in_a;
+$b{ key_in_b } = val_in_b;
+untie %b;
+untie %a;
+
+tie %c ,DBMS,'cee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$c{ key_in_c } = val_in_c;
+untie %c;
+exit;
+};
+};
+
+while(1) {
+	last if wait == -1;
+   print "ok\n";
+	};
+
+$dt = time - $dt;
+#print "N=".$ttt." ".($ttt/$dt)." ok\n";

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/40.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/40.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/40.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/40.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,20 @@
+print "1..300\n";
+use DBMS;
+
+
+$|=1;
+
+for (1 .. 100) {
+tie %a ,DBMS,'aah',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+tie %b ,DBMS,'bee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+
+$a{ key_in_a } = val_in_a;
+$b{ key_in_b } = val_in_b;
+
+untie %b;
+untie %a;
+
+tie %c ,DBMS,'cee',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$c{ key_in_c } = val_in_c;
+untie %c;
+};

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/50.t
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/50.t?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/50.t (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/client/t/50.t Fri Apr 13 01:56:01 2007
@@ -0,0 +1,11 @@
+print "1..2\n";
+
+use DBMS;
+
+
+$|=1;
+tie %a ,DBMS,'aah',&DBMS::XSMODE_CREAT,0 and print "ok\n" or die "could not connect $!";
+$a{ key_in_a } = val_in_a;
+untie %a;
+
+print "ok\n";

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/Makefile
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/Makefile?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/Makefile (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/Makefile Fri Apr 13 01:56:01 2007
@@ -0,0 +1,42 @@
+# *
+# *     Copyright (c) 2005 Asemantics S.R.L., All Rights Reserved.
+# *
+
+include ../arch.conf
+
+CFLAGS+=-Wall -ggdb
+
+# CFLAGS+= -DLOCALTEST
+
+SRCS = dbmsproxy.c
+OBJS = ${SRCS:c=o}
+INCL = dbmsproxy.h
+
+INSTALL = install -c 
+
+all: dbmsget dbmsproxy
+
+${OBJS}: Makefile *.h
+
+.c.o: Makefile
+	$(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) $(LIBS_DIR) -c -o $@ $<
+
+dbmsget: dbmsget.o
+	${CC} $(CFLAGS) ${LFLAGS} $(LIBS_DIR) -o $@ $? ${LIBS}
+
+dbmsproxy: dbmsproxy.o
+	${CC} $(CFLAGS) ${LFLAGS} $(LIBS_DIR) -o $@ $? ${LIBS} -ldbms
+
+clean:
+	rm -f *.o ktrace.* *core dbmsproxy dbmsget
+
+install: dbmsproxy dbmsget
+	$(INSTALL) -m 0555 -o $(UID) -g $(GID) dbmsproxy $(INSTDIR)/bin
+	$(INSTALL) -m 0555 -o $(UID) -g $(GID) dbmsget $(INSTDIR)/bin
+	$(INSTALL) -m 0444 -o $(UID) -g $(GID) dbmsproxy.h $(INSTDIR)/include
+
+depend:
+	makedepend $(INCLUDES) $(DEFINES) $(SRCS)
+
+distclean: clean
+	rm -f *% 

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/README
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/README?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/README (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/README Fri Apr 13 01:56:01 2007
@@ -0,0 +1,42 @@
+Problem
+	Some utilities quickly need
+	to get a value from the DBMS.
+
+	However setting up a tcp
+	scoket, having de dbmsd
+	pass it of to a handler
+	and a teardown is relatively
+	expensive for just a get.
+
+Solution
+	a proxy which bundles the
+	requests.
+
+A simple 'GET' based proxy which
+is contineously connected to a
+specific DBMS backend and table.
+
+Locally it exposes a unix domain
+socket; to which applications 
+can quickly and efficiently connect,
+get a value, and disconnect.
+
+Usage
+---
+
+for testing:
+	./dbmsproxy -U -X dbms://localhost/test100
+or in the background:
+	./dbmsproxy -p /var/tmp/test100.sock dbms://localhost/test100
+
+Put some data in the db
+
+	vi test.pl
+	perl test.pl
+
+And fetch it
+
+	./dbmsget -d /var/tmp/test100.sock
+or
+	echo foo bar | ./dbmsget
+

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/dbmsget.c
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/dbmsget.c?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/dbmsget.c (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/dbmsget.c Fri Apr 13 01:56:01 2007
@@ -0,0 +1,118 @@
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <stdio.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "dbmsproxy.h"
+
+#ifndef pdie
+#define pdie(x) { perror(x); exit(1); }
+#endif
+
+static void process(int sockfd, char * key) {
+	char buff[258], *p;
+	int n, l;
+
+	/*
+	 * send request <len>, <key of 'len' bytes> i.e. keylen+1 bytes in
+	 * length
+	 */
+	buff[0] = strlen(key);
+	strncpy(buff + 1, key, sizeof(buff - 2));
+
+	for (p = buff, l = strlen(key) + 1; l > 0;) {
+	    n = write(sockfd, p, l);
+	    if (n < 0) {
+		if ((errno != EAGAIN) && (errno != EINTR))
+		    pdie("write()");
+		continue;
+	    }
+	    else if (n == 0)
+		pdie("Connection closed during send");
+	    l -= n;
+	    p += n;
+	};
+
+	/* expect <len><status>< len bytes of answer> back */
+	for (l = 0, p = buff;;) {
+	    n = read(sockfd, p, l ? l : 1);
+	    if (n < 0) {
+		if ((errno != EAGAIN) && (errno != EINTR))
+		    pdie("read()");
+		continue;
+	    }
+	    else if (n == 0)
+		pdie("Connection closed during read");
+
+	    if (l == 0) {
+		l = buff[0] + 2 - 1;
+	    }
+	    else {
+		l = l - n;
+	    };
+	    p += n;
+
+	    if (l <= 0)
+		break;
+	};
+	*p = '\0';
+
+	if (buff[1]) {
+	    fprintf(stderr, "No key: %s\n", buff + 2);
+	    exit(buff[1]);
+	};
+
+	printf("%s\n", buff + 2);
+    }
+
+int main(int argc, char ** argv)
+{
+    struct sockaddr_un server;
+    int sockfd, len;
+    char * sock = UNIX_SOCK;
+
+    if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
+	pdie("socket()");
+
+    argv++; --argc;
+    if (argc && (!strcmp(*argv, "-p"))) {
+	    argv++; --argc;
+            sock = *argv; 
+	    argv++; --argc;
+	};
+
+    memset(&server, 0, sizeof(server));
+    server.sun_family = SOCK_STREAM;
+
+    strncpy(server.sun_path, sock, sizeof(server.sun_path) - 1);
+
+#if defined(SCM_RIGHTS) && !defined(RDFSTORE_PLATFORM_LINUX)
+    len = sizeof(server.sun_family) + strlen(server.sun_path) + sizeof(server.sun_len) + 1;
+    server.sun_len = len;
+#else
+    len = strlen(server.sun_path) + sizeof(server.sun_family);
+#endif
+
+    if (connect(sockfd, (struct sockaddr *) & server, len) < 0)
+	pdie("connect()");
+
+    if (argc) {
+	for(;argc--;argv++)
+	    	process(sockfd, *argv);
+    } else {
+	char buff[1024];
+	while(fgets(buff,sizeof(buff),stdin)) {
+		char * q, * p = buff;
+		while((q = strsep(&p," \r\n\t")))
+			if (strlen(q))
+				process(sockfd, q);
+	}
+    }
+
+    exit(0);
+};

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/dbmsproxy.c
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/dbmsproxy.c?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/dbmsproxy.c (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/dbmsproxy.c Fri Apr 13 01:56:01 2007
@@ -0,0 +1,483 @@
+/* DBMS Proxy
+ *
+ * Copyright (c) 2005 Asemantics S.R.L., All Rights Reserved.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <stdio.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <errno.h>
+#ifdef RDFSTORE_PLATFORM_DARWIN
+#include <stdint.h>
+#endif
+#include <unistd.h>
+
+#include <dbms.h>
+#include <dbms_comms.h>
+
+#include "dbmsproxy.h"
+
+#define RBUFF (1024)
+#define WBUFF (1024)
+
+#ifndef pdie
+#define pdie(x) { perror(x); exit(1); }
+#endif
+
+#ifndef max
+#define max(x,y) (((x) > (y)) ? (x) : (y))
+#endif
+
+FILE *errorout;
+int verbose = 0, debug = 0, trace_on = 0, sysloglog = 1, stderrlog = 0;
+
+static void childied(int i)
+{
+    return;
+}
+
+static void _log(int level, char *msg,...)
+{
+}
+
+static void select_loop(void);
+static int process(unsigned char *cmd_buff, int r, unsigned char *out_buff, int *w, int maxw);
+
+int sockfd;
+dbms *dc;
+fd_set rset, wset, eset, alleset, allrset, allwset;
+int maxfd;
+
+static void usage(const char *s)
+{
+    fprintf(stderr, "Syntax: %s "
+	    "[-U | -u <userid>] "	/* run as user */
+	    "[-e <file>]"	/* error log */
+	    "[-P <pid-file>] "	/* write pid file to */
+	    "[-d <directory_prefix>] "	/* chroot */
+	    "[-p <socket-device (default is " UNIX_SOCK ")>] "	/* unix datagram socket
+								 * path */
+	    "[-X] "		/* max error debuggin */
+	    "[-t] "		/* tracing */
+	    "[-D] "		/* do not detach */
+	    "[-v] "		/* version */
+	    "<dbms url>\n", s);
+    exit(1);
+}
+
+int main(int argc, char *argv[])
+{
+    struct sockaddr_un server;
+    char *sockpath = UNIX_SOCK;
+    int dtch = 1;
+    char *as_user = USER;
+    struct sigaction act, oact;
+    char *my_dir = DIR_PREFIX;
+    char *pid_file = PID_FILE;
+    int i, len;
+    char *pname = argv[0];
+    char ch;
+    errorout = stderr;
+
+    while ((ch = getopt(argc, argv, "p:d:u:UP:xDtvXe:Eh")) != -1)
+	switch (ch) {
+	case 'p':
+	    sockpath = optarg;
+	    break;
+	case 'd':
+	    my_dir = optarg;
+	    break;
+	case 'u':
+	    as_user = optarg;
+	    break;
+	case 'U':
+	    as_user = NULL;
+	    break;
+	case 'P':
+	    pid_file = optarg;
+	    break;
+	case 'x':
+	    verbose++;
+	    debug++;
+	    if (debug > 2)
+		dtch = 0;
+	    break;
+	case 'D':
+	    dtch = 0;
+	    break;
+	case 't':
+	    trace_on = 1;
+	    break;
+	case 'v':
+	    printf("Version:        %s\n", VERSION);
+	    printf("Default dir:    %s\n", DIR_PREFIX);
+	    printf("Default device: %s\n", UNIX_SOCK);
+	    printf("Default pidfle: %s\n", PID_FILE);
+	    exit(0);
+	    break;
+	case 'X':
+	    verbose = debug = 100;
+	    dtch = 0;
+	    sysloglog = 0;
+	    stderrlog = 1;
+	    break;
+	case 'e':
+	    stderrlog = 1;
+	    if ((errorout = fopen(argv[++i], "a")) == NULL) {
+		fprintf(stderr, "Aborted. Cannot open logfile %s for writing: %s\n",
+			argv[i], strerror(errno));
+		exit(1);
+	    };
+	    break;
+	case 'E':
+	    stderrlog = 1;
+	    break;
+	case 'h':
+	default:
+	    usage(pname);
+	    break;
+	};
+    argc -= optind;
+    argv += optind;
+    if (argc != 1)
+	usage(pname);
+
+    {
+	char *uri = *argv;
+	char *host = NULL;
+	char *db = NULL;
+	int port = 0;
+	if (!strncasecmp(uri, "dbms://", 7))
+	    uri += 7;
+	if ((db = index(uri, '/'))) {
+	    char *p;
+	    host = uri;
+	    *db = '\0';
+	    db++;
+	    if ((p = index(host, ':'))) {
+		*p = '\0';
+		port = atoi(p++);
+	    };
+	}
+	else {
+	    db = uri;
+	};
+
+	if (!(dc = dbms_connect(db, host, port, DBMS_XSMODE_RDONLY, NULL, NULL, NULL, NULL, 0)))
+	    pdie(dbms_get_error(NULL));
+    };
+
+    if (sysloglog)
+	openlog(pname, LOG_LOCAL4, LOG_PID | LOG_CONS);
+
+    unlink(sockpath);		/* XX warn, etc.. */
+
+    if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
+	pdie("Could not open socket");
+
+    memset(&server, 0, sizeof(server));
+    server.sun_family = SOCK_STREAM;
+    strncpy(server.sun_path, sockpath, sizeof(server.sun_path) - 1);
+
+#if defined(SCM_RIGHTS) && !defined(RDFSTORE_PLATFORM_LINUX)
+    len = sizeof(server.sun_family) + strlen(server.sun_path) + sizeof(server.sun_len) + 1;
+    server.sun_len = len;
+#else
+    len = strlen(server.sun_path) + sizeof(server.sun_family);
+#endif
+
+    if ((bind(sockfd, (struct sockaddr *) & server, len)) < 0)
+	pdie("Cannot bind server to unix domain socket.");
+
+    if (listen(sockfd, 0) < 0)
+	pdie("Could not start to listen to my port");
+
+    /*
+     * fork and detach if ness.
+     */
+    if (dtch) {
+	pid_t pid;
+	fclose(stdin);
+	if (!trace_on)
+	    fclose(stdout);
+	if ((pid = fork()) < 0) {
+	    perror("Could not fork");
+	    exit(1);
+	}
+	else if (pid != 0) {
+	    FILE *fd;
+	    if (!(fd = fopen(pid_file, "w"))) {
+		fprintf(stderr, "Warning: Could not write pid file %s:%s",
+			pid_file, strerror(errno));
+		exit(1);
+	    };
+	    fprintf(fd, "%d\n", (int) pid);
+	    fclose(fd);
+	    exit(0);
+	};
+
+	/*
+	 * become session leader
+	 */
+	if ((setsid()) < 0)
+	    pdie("Could not become session leader");
+    };
+
+    /*
+     * XXX security hole.. fix ..
+     */
+    if (as_user != NULL) {
+	struct passwd *p = getpwnam(as_user);
+	uid_t uid;
+
+	uid = (p == NULL) ? atoi(as_user) : p->pw_uid;
+
+	if (!uid || setuid(uid)) {
+	    perror("Cannot setuid");
+	    exit(0);
+	};
+    };
+
+    chdir(my_dir);		/* change working directory */
+    chroot(my_dir);		/* for sanities sake -- must be after things
+				 * like pid file where written */
+    umask(0);			/* clear our file mode creation mask */
+
+    FD_ZERO(&allrset);
+    FD_ZERO(&allwset);
+    FD_ZERO(&alleset);
+
+    FD_SET(sockfd, &allrset);
+    FD_SET(sockfd, &alleset);
+
+    maxfd = sockfd;
+    _log(LOG_NOTICE, "Waiting for connections on %s", sockpath);
+
+#if 0
+    signal(SIGHUP, dumpie);
+    signal(SIGUSR1, loglevel);
+    signal(SIGUSR2, loglevel);
+    signal(SIGINT, cleandown);
+    signal(SIGQUIT, cleandown);
+    signal(SIGKILL, cleandown);
+    signal(SIGTERM, cleandown);
+#endif
+    signal(SIGCHLD, childied);
+
+    /*
+     * for now, SA_RESTART any interupted PIPE calls
+     */
+    act.sa_handler = SIG_IGN;
+    sigemptyset(&act.sa_mask);
+    act.sa_flags = SA_RESTART;
+    sigaction(SIGPIPE, &act, &oact);
+
+    select_loop();
+    return 0;			/* keep the compiler happy.. */
+}
+
+
+void select_loop(void)
+{
+    unsigned char *rbuff[FD_SETSIZE], *wbuff[FD_SETSIZE];
+    int fd, w[FD_SETSIZE], r[FD_SETSIZE];
+
+    for (;;) {
+	struct timeval np = {600, 0};	/* seconds and micro seconds. */
+	int n;
+
+	rset = allrset;
+	wset = allwset;
+	eset = alleset;
+
+	if ((n = select(maxfd + 1, &rset, &wset, &eset, &np)) < 0) {
+	    if (errno != EINTR)
+		_log(LOG_ERR, "RWE Select Probem %s", strerror(errno));
+	    continue;
+	};
+
+#if 0
+	/* We've been idle for 600 seconds (np above) */
+	if (n == 0)
+	    exit(0);
+#endif
+
+	/*
+	 * Is someone knocking on our front door ?
+	 */
+	if (FD_ISSET(sockfd, &rset)) {
+	    struct sockaddr_in client;
+	    int len = sizeof(client);
+
+	    if ((fd = accept(sockfd,
+			     (struct sockaddr *) & client, &len)) < 0) {
+		_log(LOG_ERR, "Could not accept");
+	    }
+	    else {
+		/* activate select on my connection */
+		FD_SET(fd, &allrset);
+		FD_SET(fd, &alleset);
+		maxfd = max(maxfd, fd);
+		rbuff[fd] = malloc(RBUFF);
+		wbuff[fd] = malloc(WBUFF);
+		r[fd] = 0;
+		w[fd] = 0;
+	    };
+	}			/* knock on the door */
+
+	for (fd = 0; fd <= maxfd; fd++) {
+	    int cc = 0;
+
+	    if (fd == sockfd)
+		continue;
+
+	    if (FD_ISSET(fd, &rset)) {
+		int n;
+		if (r[fd] > RBUFF) {
+		    _log(LOG_ERR, "Closed due to rbuffer overfilling");
+		    goto _c;
+		};
+		n = read(fd, rbuff[fd], RBUFF);
+		if (n == 0) {
+		    _log(LOG_DEBUG, "Closed after zero read (normal close)");
+		    goto _c;
+		}
+		else if ((n < 0) && (errno != EINTR) && (errno != EAGAIN)) {
+		    _log(LOG_ERR, "Closed after read error");
+		    exit(0);
+		}
+		else if (n > 0) {
+		    int p;
+		    r[fd] += n;
+		    p = process(rbuff[fd], r[fd], wbuff[fd], &w[fd], WBUFF);
+		    if (p) {
+			if (p < 0) {
+			    _log(LOG_ERR, "Output buffer overflow");
+			    goto _c;
+			};
+			r[fd] -= p;
+			if (r[fd] > 0) {
+			    memcpy(rbuff, rbuff[fd] + p, r[fd]);
+			}
+			else {
+			    r[fd] = 0;
+			}
+			FD_SET(fd, &allwset);
+			cc = 1;
+		    }
+		}
+	    }
+	    if (cc | FD_ISSET(fd, &wset)) {
+		int n = write(fd, wbuff[fd], w[fd]);
+		if ((n == 0) && w[fd]) {
+		    _log(LOG_DEBUG, "Closed on zero write");
+		    goto _c;
+		}
+		else if ((n < 0) && (errno != EINTR) && (errno != EAGAIN)) {
+		    _log(LOG_ERR, "Closed after write error");
+		    goto _c;
+		}
+		else if (n > 0) {
+		    w[fd] -= n;
+		    if (w[fd] > 0) {
+			memcpy(wbuff[fd], rbuff[fd] + n, w[fd]);
+		    }
+		    else {
+			w[fd] = 0;
+			FD_CLR(fd, &allwset);
+		    }
+		};
+	    }
+	    if (FD_ISSET(fd, &eset)) {
+		_log(LOG_ERR, "Somethinig nasty");
+		exit(0);
+	    }
+	    continue;
+
+    _c:
+	    FD_CLR(fd, &allrset);
+	    FD_CLR(fd, &allwset);
+	    FD_CLR(fd, &alleset);
+	    free(rbuff[fd]);
+	    free(wbuff[fd]);
+	    r[fd] = -1;
+	    w[fd] = -1;
+	}			/* loop over all FD's */
+    }				/* endless for */
+}
+
+int process(
+	        unsigned char *cmd_buff, int r,
+	        unsigned char *out_buff, int *wp,
+	        int maxw
+)
+{
+    int at = 0;
+    out_buff += *wp;
+
+    /* Request - <1 byte len of key> [ key ] */
+    /* Reply <1 byte len>, 1 byte ok/nok, string */
+
+    for (; at < r;) {
+	unsigned char *cmd = cmd_buff + at;
+	int len = cmd[0];
+
+	char key[256];
+	DBT k, val;
+	int e;
+
+	/* Wait for more data if there is not a complete packet to process. */
+	if (r < len + 1)
+	    return at;
+
+	strncpy(key, cmd + 1, len);
+	key[len] = '\0';
+
+	at = at + len + 1;
+
+	k.data = key;
+	k.size = len;
+
+	if (trace_on)
+	    printf("Requesting %s\n", key);
+
+	r = 0;
+#ifdef LOCALTEST
+	val.data = "1234567890";
+	val.size = 10;
+	e = 0;
+#else
+	e = dbms_comms(dc, TOKEN_FETCH, &r, &k, NULL, NULL, &val);
+#endif
+	if (e || r != 0) {
+	    if (*wp + 10 > maxw)
+		return -1;
+	    strcpy(out_buff + 2, dbms_get_error(dc));
+	    out_buff[0] = strlen(out_buff + 2);
+	    out_buff[1] = 1;
+	}
+	else {
+	    if (*wp + 1 + val.size > maxw)
+		return -1;
+
+	    strncpy(out_buff + 2, val.data, val.size);
+	    out_buff[0] = val.size;
+	    out_buff[1] = 0;
+	};
+	if (trace_on)
+	    printf("	reply '%s' len(%d)\n", out_buff + 2, out_buff[0]);
+
+	/* Queue up the output */
+	*wp += 2 + out_buff[0];
+
+    };
+
+    /* Return pointer to any partial/non completed commands */
+    return at;
+}

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/dbmsproxy.h
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/dbmsproxy.h?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/dbmsproxy.h (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/dbmsproxy.h Fri Apr 13 01:56:01 2007
@@ -0,0 +1,20 @@
+
+#ifndef VERSION
+#define VERSION "1.00"
+#endif
+
+#ifndef UNIX_SOCK
+#define UNIX_SOCK 	"/var/tmp/dbmsproxy_socket"
+#endif
+
+#ifndef USER
+#define USER 		"nobody"
+#endif
+
+#ifndef DIR_PREFIX
+#define DIR_PREFIX	"/var/tmp"
+#endif
+
+#ifndef PID_FILE
+#define	PID_FILE 	"/var/run/dbmsproxy.pid"
+#endif

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/test.pl
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/test.pl?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/test.pl (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/test.pl Fri Apr 13 01:56:01 2007
@@ -0,0 +1,15 @@
+#!/usr/bin/perl
+
+die "$0 <dbms-uri>"
+        unless $#ARGV == 0;
+
+my $URI = shift @ARGV;
+
+use DBMS;
+tie %a ,DBMS,$URI,&DBMS::XSMODE_CREAT,0 or die $!;
+
+$a{ foo } = bar;
+for (1 .. 100) {
+	$a{ 'key'.$_ } = "Some value ". ('x' x $_);
+};
+

Propchange: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/test.pl
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/test2.pl
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/test2.pl?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/test2.pl (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/test2.pl Fri Apr 13 01:56:01 2007
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+
+die "$0 <dbms-uri>"
+	unless $#ARGV == 0;
+
+my $URI = shift @ARGV;
+
+use DBMS;
+tie %a ,DBMS,$URI,&DBMS::XSMODE_RDONLY,0 or die $!;
+
+while(my ($k,$v) = each %a) {
+	print "$k\n\t$v\n";
+};
+

Propchange: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/dbmsproxy/test2.pl
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/.cvsignore
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/.cvsignore?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/.cvsignore (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/.cvsignore Fri Apr 13 01:56:01 2007
@@ -0,0 +1,6 @@
+version.c
+dbmsd
+dbmscheckconf
+*.gz
+*.core
+gmon.out

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/Makefile
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/Makefile?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/Makefile (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/Makefile Fri Apr 13 01:56:01 2007
@@ -0,0 +1,99 @@
+# *
+# *     Copyright (c) 2000-2006 Alberto Reggiori <areggiori@webweaving.org>
+# *     		   Dirk-Willem van Gulik <dirkx@webweaving.org>
+# *
+# * NOTICE
+# *
+# * This product is distributed under a BSD/ASF like license as described in the 'LICENSE'
+# * file you should have received together with this source code. If you did not get a
+# * a copy of such a license agreement you can pick up one at:
+# *
+# *     http://rdfstore.sourceforge.net/LICENSE
+# *
+INSTDIR=/RDFStore
+
+include ../arch.conf
+
+SRCS = deamon.c mymalloc.c handler.c main.c children.c loop.c pathmake.c conf.c
+OBJS = ${SRCS:c=o}
+INCL = dbmsd.h deamon.h handler.h mymalloc.h pathmake.h conf.h
+
+INSTALL = install -c 
+
+CFLAGS += -DDIR_PREFIX="\"${INSTDIR}\"" -DCONF_FILE="\"${INSTDIR}/etc/dbms.conf\"" 
+
+all: dbmscheckconf dbmsd $(INCL) ../include/dbms.h Makefile man
+
+test: dbmsd testconf dbms-allow-all.conf   
+	@rm -f ${TESTDIR}/*/*db
+	@rm -f *db
+	-@../utils/stop_dbserver ${PIDFILE} 2> /dev/null 1>&2
+
+	@mkdir -p ${TESTDIR}
+	@echo -n Starting DBMS deamon.....
+	LD_LIBRARY_PATH=$(BDB_LD_LIBS_DIR) ./dbmsd -U -d ${TESTDIR} -P ${PIDFILE} -c dbms-allow-all.conf &
+	@echo DONE
+
+	@(cd ../client; make test)
+
+	@echo -n Stopping DBMS deamon.....
+	@../utils/stop_dbserver ${PIDFILE} 2> /dev/null 1>&2
+	@echo DONE
+
+	@rm -f *.gmon bb.*
+	@rm -f ${TESTDIR}/*/*db
+	@rm -f *db
+
+.c.o:	Makefile
+	$(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) $(LIBS_DIR) -c -o $@ $<
+
+version: 
+	./version.pl > version.c
+	$(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) $(LIBS_DIR) -c -o version.o version.c
+
+${OBJS}: Makefile *.h
+
+dbmsd:	${OBJS} version
+	${CC} $(CFLAGS) ${LFLAGS} $(LIBS_DIR) -o $@ ${OBJS} version.o ${LIBS}
+
+clean:
+	rm -f version.c dbmsd dbmsd.8.gz
+	rm -f *.o *.gmon bb.* core.* *.core *.db dbmscheckconf dbmscheckconf.8.gz
+
+man: dbmsd.8 dbmscheckconf.8
+	cat dbmsd.8 | gzip > dbmsd.8.gz
+	cat dbmscheckconf.8 | gzip > dbmscheckconf.8.gz
+
+install: dbmsd man dbmscheckconf dbms.conf
+	mkdir -p $(INSTDIR)/bin $(INSTDIR)/rc $(INSTDIR)/man/man8 $(INSTDIR)/dbms  $(INSTDIR)/etc $(INSTDIR)/run $(INSTDIR)/logs
+	-chmod a+w $(INSTDIR)/dbms
+	-chmod a+w $(INSTDIR)/logs
+	-chmod a+w $(INSTDIR)/run
+	-cp $(INSTDIR)/etc/dbms.conf $(INSTDIR)/etc/dbms.conf.ORIG
+	$(INSTALL) -m 0555 -o $(UID) -g $(GID) dbms-allow-all.conf $(INSTDIR)/etc/dbms.conf
+	$(INSTALL) -m 0555 -o $(UID) -g $(GID) dbms.conf $(INSTDIR)/etc/dbms.conf-sample
+	$(INSTALL) -m 0555 -o $(UID) -g $(GID) dbmsd $(INSTDIR)/bin
+	$(INSTALL) -m 0555 -o $(UID) -g $(GID) dbmscheckconf $(INSTDIR)/bin
+	$(INSTALL) -m 0555 -o $(UID) -g $(GID) ../utils/dbmsd.sh $(INSTDIR)/rc
+	$(INSTALL) -m 0555 -o $(UID) -g $(GID) ../utils/start_dbserver $(INSTDIR)/rc
+	$(INSTALL) -m 0555 -o $(UID) -g $(GID) ../utils/stop_dbserver $(INSTDIR)/rc
+	$(INSTALL) -m 0555 -o $(UID) -g $(GID) ../utils/dbms_mirror.pl $(INSTDIR)/bin
+	$(INSTALL) -m 0644 -o $(UID) -g $(GID) dbmsd.8.gz $(INSTDIR)/man/man8
+	$(INSTALL) -m 0644 -o $(UID) -g $(GID) dbmscheckconf.8.gz $(INSTDIR)/man/man8
+
+	@echo "Remember to set your local LD_LIBRARY_PATH to point to the right Berkeley DB libraries directory if not found by ld program"
+
+depend:
+	makedepend $(INCLUDES) $(DEFINES) $(SRCS)
+
+distclean: clean
+	rm -f *% 
+
+dbmscheckconf: conf.c $(INCL) 
+	 $(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) $(LIBS_DIR) -D__TESTING__CONF__ -o $@ conf.c $(LIBS)
+
+testconf: dbmscheckconf
+	LD_LIBRARY_PATH=$(BDB_LD_LIBS_DIR) ./dbmscheckconf ./dbms.conf `cat test-xs.conf`
+
+lint: 
+	$(LINT) $(LINTFLAGS) $(INCLUDES) $(DEFINES) $(LIBS_DIR) ${SRCS}

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/README
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/README?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/README (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/README Fri Apr 13 01:56:01 2007
@@ -0,0 +1,69 @@
+/*
+ *     Copyright (c) 2000-2006 Alberto Reggiori <areggiori@webweaving.org>
+ *		          Dirk-Willem van Gulik <dirkx@webweaving.org>
+ *
+ * NOTICE
+ *
+ * This product is distributed under a BSD/ASF like license as described in the 'LICENSE'
+ * file you should have received together with this source code. If you did not get a
+ * a copy of such a license agreement you can pick up one at:
+ *
+ *     http://rdfstore.sourceforge.net/LICENSE
+ *
+ */
+
+Tried sofar
+
+	fork per database, select loop
+
+	preforked per database, select loop
+
+	fork per connection, add locking
+
+	thread per connection, cheaper locking
+
+	thread per database, cheaper switching
+
+Conclusions sofar
+
+	on BSD	fork/dbase is good compromise; thread per database
+	is about the same speed but more overhead. thread per
+	connection is faster for few connections, but has a lot
+	more overhead. Forking sofar scales best < mmlimit. Above
+	that thread per connection is best, but by far best is single
+	select loop per database.
+
+Files
+
+	children.c	fork and msg passing
+	children_trd.c	thread; no msg passing
+	children_ltr.c  NSPR treads, msg passing
+
+	deamon.c	Handles fairly efficient read/write
+			to a socked. Without blocking where
+			needed.
+
+	handler.c	simple call outs to libDB
+
+			The nasty exception is get_dbp() which
+			has some funny return values due to the
+			internal fork() or pthread attaching.
+
+	loop.c		main select loop
+	loop_conn.c	main wait loop treaded case
+
+	main.c		process kick off
+
+	mymalloc.c	debugging malloc.
+
+	pathmake.c	misc.
+
+There are a couple of not so obvious optimizations where we
+build explicit tables or pointer lists to avoids doing for
+loops through lists of arrays; often at the expense of a
+some memory. Secondly we use some funny struc's which are
+linked and created in a way to kind of blow not to many
+caches if possible. The only big remaining niggle is that
+we should collapse more functions into just a few; as to
+get the heap/stack both as shallow as possible. As this
+seems to speeds up the NSPR and Pthreads greatly.

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/children.c
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/children.c?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/children.c (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/children.c Fri Apr 13 01:56:01 2007
@@ -0,0 +1,509 @@
+/*
+ *     Copyright (c) 2000-2006 Alberto Reggiori <areggiori@webweaving.org>
+ *                        Dirk-Willem van Gulik <dirkx@webweaving.org>
+ *
+ * NOTICE
+ *
+ * This product is distributed under a BSD/ASF like license as described in the 'LICENSE'
+ * file you should have received together with this source code. If you did not get a
+ * a copy of such a license agreement you can pick up one at:
+ *
+ *     http://rdfstore.sourceforge.net/LICENSE
+ *
+ * DBMS Server
+ *
+ * Dealing with birth(control) of children, handing of
+ * tasks and subsequent reaping of accidentally terminal
+ * cases. 
+ *
+ * Strategy/Design/Bumpf
+ *
+ * 	The idea here is that each time a new/init comes
+ *	in from a client; we check if we already have the database
+ *	requested open (note; we assume a strict one socket
+ *	per database relation). If one of our children already
+ *	has the database openened; hand off the connection to
+ * 	that child and forget about the connection.
+ *
+ *	This way we do not have to worry about locks; as each
+ * 	dbm has just one process handling it.
+ *
+ *	If no child is currently handing the requested database
+ *	we check how many we have running, and either spawn a
+ *	new child; or ask an existing one to take the additional
+ *	load. The assumtion here is that forking processis are
+ *	able to handle RQ's more independently; thus allowing
+ *	better utilizition of the bus to the disk; as we have
+ *	decoupled the H function.
+ *
+ *	For now we changed to a fork(); rather than pull from a 
+ *	thread pool as in the UKDCils. The main reasons are that
+ *	we are worried about one DB blowing up another, and that
+ *	some of the older FreeBSD production boxes give the same
+ *	problems we had with the IMS user land hangs. But really
+ *	treading would be better; and just require a few mutexi-es.
+ *
+ * $Id: children.c,v 1.20 2006/06/19 10:10:22 areggiori Exp $
+ */                                   
+#ifdef FORKING
+
+#include "dbms.h"
+#include "dbms_comms.h"
+#include "dbmsd.h"
+
+#include "deamon.h"
+#include "handler.h"
+#include "children.h"
+#include "mymalloc.h"
+
+// unpatched solaris and FreeBSD<2.2 need them. I think.
+//
+#ifndef ALIGN
+#define ALIGN(x) (x)
+#endif
+
+#ifndef CMSG_LEN      
+#if RDFSTORE_PLATFORM_SOLARIS
+#define CMSG_LEN(x) (ALIGN(sizeof(struct cmsghdr)) + ALIGN(x))
+#else
+#define CMSG_LEN(x) (_CMSG_HDR_ALIGN(x))
+#endif
+#endif
+
+#ifndef CMSG_SPACE
+#if RDFSTORE_PLATFORM_SOLARIS
+#define CMSG_SPACE(x) ( ALIGN(sizeof(struct cmsghdr)) + x)
+#else
+#define CMSG_SPACE(x) (_CMSG_DATA_ALIGN(x))
+#endif
+#endif
+
+#ifdef STATIC_BUFF
+static child_rec * free_child_list = NULL;
+static int free_child_list_len = 0;
+static int free_child_list_keep= 2;
+static int free_child_list_max = 4;
+#endif
+int child_counter = 0;
+
+// XXX inline or macro :-) most of the following functions are
+// just used in one or two places..
+
+int atomic_send(
+	int fd,
+  	struct msghdr * msg,
+	int tosend
+	)
+{
+  int n;
+  assert(tosend != 0); // otherwise we cannot detect a child close
+
+retry_snd:
+  /* XXX does MSG_WAITALL actually work ?? 
+   * SCO acts strange compared to BSDi....
+   * we normally would do a proper loop;
+   * but this should be atomic accourding
+   * to the BSD man page. 
+   */
+   n=sendmsg(fd,msg,0); 
+
+   if ((n<0) && (errno=EAGAIN))
+	goto retry_snd;
+
+   if ((n<=0) && (errno=EINTR)) 
+	goto retry_snd;
+ 
+   if (n<0) { 
+	dbms_log(L_ERROR,"Could not atomically send msg: %s",strerror(errno)); 
+	return -1; 
+	} 	
+   else
+   if (n==0) {
+	dbms_log(L_ERROR,"Child closed connection"); 
+	return -1; 
+	} 
+
+   assert(n==tosend); // who trust the man page ?
+   return 0;
+}
+
+void free_child( child_rec * r) 
+{
+	dbms_log(L_DEBUG,"Freeing child %x %d",r,r->pid);
+	if (r->r) {
+		dbms_log(L_DEBUG,"And marking close fd=%d",r->r->clientfd);
+		r->r->close = 1; MX;
+		if (mum_pid)
+			zap(r->r);/* XXXXXXXX */
+	};
+
+#ifdef STATIC_BUFF
+	if (free_child_list_len < free_child_list_keep) {
+		r->nxt = free_child_list;
+		assert( r != free_child_list);
+		free_child_list = r;
+		free_child_list_len ++;
+	} else
+#endif
+	myfree(r);
+
+	child_counter--;
+}
+	
+void zap_child( child_rec * r)
+{
+	child_rec * * p;
+
+	dbms_log(L_DEBUG,"Zapped memory for a child");
+        for ( p = &children; *p && *p != r; )
+                p = &((*p)->nxt);
+
+	//if (*p == NULL)
+	//	dbms_log(L_ERROR,"Zapping unkown child ? children=%p",children);
+	assert( *p );
+
+	*p = r->nxt;
+	free_child(r);
+}
+
+void
+clean_children( void )
+{
+	child_rec * p;
+
+	for(p=children;p;) {
+		child_rec * q=p; 
+		p=p->nxt;
+		free_child(q);
+		};
+
+	children=NULL;
+}
+
+/* Create a new child/thread. And then hand over the file descriptor of the current
+ * incoming connection.
+ *
+ * Return values:
+ *	ptr			child created; ptr to record with details.
+ *	null, errno = 0		we are the child.
+ *	noll, errno != 0	error occured.
+ */
+child_rec *
+create_new_child( void )
+{
+	/* fork off a child.. make sure we keep the contact
+	 * details so that we can pass on file descriptors
+	 * later, should the need arise.
+	 */
+	int pipefd[2];
+	child_rec * child = NULL;
+	pid_t pid,this_pid;
+	dbms_log(L_INFORM,"Creating new child");
+
+	if ((socketpair(AF_UNIX, SOCK_STREAM,0,pipefd))<0)	
+		return NULL;
+
+/*
+	XXXX
+
+	Braindead... we fork and then always clean all the
+	child cruft; as that child does not need to have
+	global knowledge. i.e. we faul the page and cause
+	a copy on first write and all that. Multi treading
+	used to solve this; but no longer with the new fork().
+*/
+
+	this_pid=getpid();
+	pid=fork();
+	if (pid <0 ) {
+		dbms_log(L_ERROR,"Failed to create a child: %s",strerror(errno));
+
+		return NULL;
+		} else
+	if (pid == 0) {
+                connection * r;
+		struct sigaction 	act,oact;
+		int mum_fd = pipefd[1];
+		mum_pid = this_pid;
+
+		close(pipefd[0]);
+
+		dbms_log(L_DEBUG,"Child created - I am the Child fd=%d",mum_fd);
+
+      		FD_CLR(sockfd,&allwset);
+        	FD_CLR(sockfd,&allrset);
+        	FD_CLR(sockfd,&alleset);
+
+		close(sockfd);
+		sockfd = -1; /* moved out of the way */
+
+		/* for now, SA_RESTART any interupted PIPE calls
+		 */
+		act.sa_handler = SIG_IGN;
+		sigemptyset(&act.sa_mask);
+		act.sa_flags = SA_RESTART;
+		sigaction(SIGPIPE,&act,&oact);
+
+                for(r=client_list; r; r=r->next) {
+			assert(r);
+			r->type = C_LEGACY;
+			r->close=1; MX;
+			};
+
+                close_all_dbps(); /* XXX wrong; I should not have any ? */
+                clean_children(); 
+
+		child = NULL;
+
+		/* make sure we listen to our mother... both for
+		 * reading and for exceptions.. This is the channel
+		 * used (later) to pass off any connections, (re)do
+		 * an init on; etc, etc.
+		 */
+		/* XXX no error trapping */
+		mum = handle_new_local_connection(mum_fd,C_MUM);
+		} 
+	else {
+		/* for the mother.. 
+		 */
+		int childfd = pipefd[0];
+		close(pipefd[1]);
+
+		dbms_log(L_DEBUG,"Child created - I am the Mother fd=%d",childfd);
+
+#ifdef STATIC_BUFF
+		/* If we still have free-ed children on the list
+		 * then use those.
+	         */
+		if (free_child_list) {
+			child = free_child_list;
+			free_child_list = free_child_list->nxt;
+			free_child_list_len --;
+		} else {
+			/* Increase the keep treshold if we have to malloc often. */
+			if (free_child_list_keep < free_child_list_max)
+				free_child_list_keep += 2;
+#else
+{
+#endif
+			child = (struct child_rec *) mymalloc(sizeof(struct child_rec));
+		}
+		if (child == NULL )
+				return NULL;
+
+		/* Tie into the list of active children. */
+		child ->nxt = children;
+		children = child;
+
+		/* For statistics and logging - no real reasons */
+		child_counter ++;
+		child->pid=pid;
+
+		/* Initalize the child 'real' structure */
+		child->r=NULL;
+		child->close=0;
+		child->num_dbs=0;
+
+		/* And take over the connection. 
+		 */
+		if ((child->r = handle_new_local_connection(childfd,C_CHILD)) == NULL) {
+			free_child(child);
+			return NULL;
+			};
+		}
+
+	/* return myself.. or null to signal that
+	 * we are the child.
+	 */
+        errno=0;
+	
+	return child;
+}
+
+int
+handoff_fd(
+	struct child_rec * child, 
+	connection * r
+	)
+{
+  struct header cmd;
+  struct iovec iov[3];
+  struct msghdr	msg;
+  union {
+	struct cmsghdr	cm;
+	char   		control[ CMSG_SPACE( sizeof( int ) ) ];	
+	} cmsgbuf;
+  struct cmsghdr * cmptr;
+
+  assert(mum_pid == 0);
+  dbms_log(L_DEBUG, "Handoff fd=%d across on connection fd=%d to child",
+	r ? r->clientfd : 0,
+	child->r ? child->r->clientfd : 0
+	);
+
+  /* preamble.. we KNOW that the socket we
+   * now use is _BLOCKing_ so no one else
+   * is going to get between them and us..
+   */
+
+  cmd.token = TOKEN_FDPASS | F_INTERNAL;
+
+  cmd.len1 = htonl(r->v1.size);
+  cmd.len2 = htonl(r->v2.size);
+
+  iov[0].iov_base = (void *)&cmd;
+  iov[0].iov_len = sizeof(cmd);
+
+  iov[1].iov_base = r->v1.data;
+  iov[1].iov_len  = r->v1.size;
+
+  iov[2].iov_base = r->v2.data;
+  iov[2].iov_len  = r->v2.size;
+
+  bzero( (void *) &msg, sizeof msg);
+  msg.msg_name = NULL;
+  msg.msg_namelen = 0;
+  msg.msg_iov =iov;
+  msg.msg_iovlen = 3;
+  msg.msg_control = NULL;
+  msg.msg_controllen = 0;
+
+  if (atomic_send(child->r->clientfd,&msg,
+	iov[0].iov_len + iov[1].iov_len + iov[2].iov_len    )<0) {
+  	dbms_log(L_DEBUG, "Handoff fd=%d on fd=%d Fail: %s",
+		r->clientfd,child->r->clientfd,
+		strerror(errno));
+	return -1;
+	};
+
+  bzero( (void *) &msg, sizeof msg);
+  bzero( (void *) &cmsgbuf, sizeof cmsgbuf);
+
+  /* use a special message to tell about
+   * the file descriptior.
+   */ 
+  msg.msg_name = NULL;
+  msg.msg_namelen = 0;
+  msg.msg_iov = iov;
+  msg.msg_iovlen = 1;
+  msg.msg_control = cmsgbuf.control;
+  msg.msg_controllen = sizeof cmsgbuf.control;
+
+  /* pass an 'r' pointer as a future reference, and
+   * to possibly side step a recfromit() issue.
+   */
+  iov[0].iov_base = (void *)&r;
+  iov[0].iov_len = sizeof(r);
+
+  cmptr = CMSG_FIRSTHDR( &msg );
+
+  cmptr->cmsg_len = CMSG_LEN( sizeof(int) ); 
+  cmptr->cmsg_level = SOL_SOCKET;
+  cmptr->cmsg_type = SCM_RIGHTS;
+
+  *(int *)CMSG_DATA(cmptr) = r->clientfd;
+
+  if (atomic_send(child->r->clientfd, &msg, 
+	iov[0].iov_len  )<0) {
+  	dbms_log(L_DEBUG, "Handoff fd=%d on fd=%d Fail: %s",
+		r->clientfd,child->r->clientfd,
+		strerror(errno));
+	return -1;
+	};
+
+  /* we did it, forget about any work _we_ where doing
+   * on this connection  and/or database association 
+   * except perhaps for the pid..
+   * we only mark; to avoid double close if it gets
+   * re-used somehow.
+   */
+  dbms_log(L_DEBUG, "Marking fd=%d ass closed",r->clientfd);
+  r->close = 1; MX; 
+  r->type = C_LEGACY;
+  zap(r);
+  return  0;
+}
+  
+int
+takeon_fd(int conn_fd)
+{
+  int fd;
+  struct msghdr msg;
+  struct iovec iov[1];
+  connection * tmp;
+  union {
+	struct cmsghdr	cm;
+	char   		control[ CMSG_SPACE( sizeof( int ) ) ];	
+	} cmsgbuf;
+  struct cmsghdr * cmptr;
+
+  assert(mum_pid != 0);
+	
+  /* XXX really needed ? 
+   */
+  bzero( (void *) &msg, sizeof msg);
+  bzero( (void *) &cmsgbuf, sizeof cmsgbuf);
+
+  /* expect a special message to tell about
+   * the file descriptior.
+   */
+  msg.msg_name = NULL;
+  msg.msg_namelen = 0;
+
+  msg.msg_iov = iov;
+  msg.msg_iovlen = 1;
+  msg.msg_control = cmsgbuf.control;
+  msg.msg_controllen = sizeof cmsgbuf.control;
+
+  iov[0].iov_base = (void *)&tmp;
+  iov[0].iov_len = sizeof(tmp);
+
+  /* we could use MSG_WAITALL here ?! */
+
+  /* XXX message could be '0' in size !? */
+  while(1) {
+	int e=recvmsg(conn_fd,&msg,0);
+	if ((e<0) && (errno == EAGAIN))
+		continue;
+	if ((e<=0) && (errno==EINTR))
+		continue;
+	if (e<0)
+		return -1;
+	break;
+	};
+		
+  if ((cmptr=CMSG_FIRSTHDR(&msg)) == NULL ) {
+	dbms_log(L_ERROR,"Not the right msg struct");
+	return -1;
+	};
+
+   if (cmptr->cmsg_len != CMSG_LEN(sizeof(int))) {
+	dbms_log(L_ERROR,"Not the right length of fd struct %d",
+		cmptr->cmsg_len);
+	return -1;
+	};
+
+  if (cmptr->cmsg_type != SCM_RIGHTS)  {
+	dbms_log(L_ERROR,"Not the right SCM_RIGHTS passed");
+	return -1;
+	};
+
+  if ( cmptr->cmsg_level != SOL_SOCKET) {
+	dbms_log(L_ERROR,"Not the right SOL_SOCKET passed");
+	return -1;
+	};
+
+  fd = *(int *)CMSG_DATA(cmptr);
+
+  if (fd<0)
+	dbms_log(L_FATAL,"Negative value ? %d",fd);
+
+  dbms_log(L_VERBOSE,"Received FD=%d",fd);
+
+  /* this is going to be follwed by an INIT type of msg so we
+   * kinda are not going to handle right here. (We could do it,
+   * as it would save a (cheapish) select call later. XXXX
+   */
+  return fd;
+}
+#endif

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/children.h
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/children.h?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/children.h (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/children.h Fri Apr 13 01:56:01 2007
@@ -0,0 +1,16 @@
+/*
+ *     Copyright (c) 2000-2006 Alberto Reggiori <areggiori@webweaving.org>
+ *                        Dirk-Willem van Gulik <dirkx@webweaving.org>
+ *
+ * NOTICE
+ *
+ * This product is distributed under a BSD/ASF like license as described in the 'LICENSE'
+ * file you should have received together with this source code. If you did not get a
+ * a copy of such a license agreement you can pick up one at:
+ *
+ *     http://rdfstore.sourceforge.net/LICENSE
+ *
+ *
+ * $Id: children.h,v 1.4 2006/06/19 10:10:22 areggiori Exp $
+ */
+extern int child_counter;

Added: incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/conf.c
URL: http://svn.apache.org/viewvc/incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/conf.c?view=auto&rev=528394
==============================================================================
--- incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/conf.c (added)
+++ incubator/triplesoup/donations/TRIPLES-3-RDFStore/dbms/deamon/conf.c Fri Apr 13 01:56:01 2007
@@ -0,0 +1,552 @@
+/*
+ *     Copyright (c) 2000-2006 Alberto Reggiori <areggiori@webweaving.org>
+ *                        Dirk-Willem van Gulik <dirkx@webweaving.org>
+ *
+ * NOTICE
+ *
+ * This product is distributed under a BSD/ASF like license as described in the 'LICENSE'
+ * file you should have received together with this source code. If you did not get a
+ * a copy of such a license agreement you can pick up one at:
+ *
+ *     http://rdfstore.sourceforge.net/LICENSE
+ *
+ *
+ * $Id: conf.c,v 1.16 2006/06/19 10:10:22 areggiori Exp $
+ */
+
+#include "dbms.h"
+#include "dbmsd.h"
+#include "dbms_compat.h"
+#include "deamon.h"
+#include "dbms_comms.h"
+
+#include "conf.h"
+
+typedef struct xscf {
+	tops op;
+	u_long ip, mask;
+	struct xscf * nxt;
+} txscf;
+
+typedef enum ordertypes { 
+	T_UNSET, T_ALLOW, T_DENY
+} torder;
+
+typedef struct xsctrl {
+	char * dbase;
+	torder first;
+	struct xscf * recdeny, * recallow;
+	struct xsctrl * nxt;
+} txsctrl;
+
+txsctrl * xscontrols  = NULL;    
+
+const char  *
+op2string(tops p) {
+	const char * op;
+
+	switch(p) {
+	case T_NONE:	op="none";break;
+	case T_RDONLY:	op="rdonly";break;
+	case T_RDWR:	op="rdwr";break;
+	case T_CREAT:	op="creat";break;
+	case T_DROP:	op="drop";break;
+	case T_ALL:	op="all";break;
+	default:	op = "undefined";break;
+	};
+
+	return op;
+}
+
+static u_long 
+getip(char * word) {
+	struct in_addr ip;
+
+#ifdef RDFSTORE_PLATFORM_SOLARIS
+	ip.s_addr = inet_addr(word);
+	if (ip.s_addr ==INADDR_NONE) {
+#else
+	if (inet_aton(word,&ip) != 1) {
+#endif
+                 struct hostent * hp;
+                 if((hp = gethostbyname(word))==NULL) 
+			return INADDR_NONE; /* rely on errno */
+		ip.s_addr = *(u_long *) hp->h_addr;
+	};
+
+	errno = 0;
+	return ip.s_addr;
+}
+
+static tops
+decode_ops(char * p) {
+	if (!strcmp(p,"none")) {
+		return T_NONE;
+	} else
+	if (!strcmp(p,"rdonly")) {
+		return T_RDONLY;
+	} else
+	if (!strcmp(p,"rdwr")) {
+		return T_RDWR;
+	} else
+	if (!strcmp(p,"creat")) {
+		return T_CREAT;
+	}
+	if (!strcmp(p,"drop")) {
+		return T_DROP;
+	}
+	if (!strcmp(p,"all")) {
+		return T_ALL;
+	}
+	return T_ERR;
+}
+
+static char *
+getnextword(char ** p) {
+	char *q;
+	while(**p && isspace((int)(**p))) 
+		(*p)++;	/* Skip any space */
+ 	q = *p;
+	while(**p && (!(
+		isspace((int)(**p)) || (**p == ',') || (**p == '>')
+	       ))) (*p)++;	/* Run until we see space */
+	if (**p) {
+		**p = '\0';
+		(*p)++;
+	}
+	return q;
+}
+
+/* Expect things like 
+ *	single hostname
+ * 	IP/bits
+ * 	IP netmask
+s*/
+static int
+decode_mask(struct xscf *cnf, char * p) {
+	char * s;
+	cnf->ip = 0;
+	cnf->mask = INADDR_NONE;	/* Mask as exact as possible */
+	if (!strcmp(p,"all")) {
+		cnf->mask = INADDR_ANY; /* 0.0.0.0 */
+		cnf->ip= INADDR_NONE; /* 255.255.255.255 */
+	} else {
+		if ((s = index(p,'/'))) {
+			long len = strtol(s+1,NULL,10);
+			if ((len == 0) && (errno = EINVAL))
+				return -1;
+			if ((len <0) || (len >32))
+				return -1;
+			*s = '\0';
+			s++;
+			cnf->mask = htonl(~((1<<(32-len))-1));
+		} else
+		if ((s = index(p,' '))) {
+			char * q = getnextword(&p);
+			if (!strcmp("netmask",q))
+				q = getnextword(&p);
+			if (((cnf->mask = getip(q))==INADDR_NONE) && (errno))
+				return -1;
+			*s = '\0';
+			s++;
+		}
+
+		if (((cnf->ip = getip(p))==INADDR_NONE) && (errno))
+			return -1;
+	};
+	/* Any bits in the IP which are masked/hidden */
+	cnf->ip &= (cnf->mask);
+	return 0;
+}
+
+static void 
+free_config(txsctrl * cf) {
+        txscf * cnf;
+	for(;cf;) {
+		txsctrl * p = cf; cf=cf->nxt;
+
+		if (p->dbase) 
+			free(p->dbase);
+
+		for(cnf =  p->recallow; cnf;) {
+			txscf * q = cnf; cnf=cnf->nxt;
+			free(q);
+		};
+
+		for(cnf =  p->recdeny; cnf;) {
+			txscf * q = cnf; cnf=cnf->nxt;
+			free(q);
+		};
+
+		free(p);			
+	}
+}
+
+const char *
+parse_config(char * configfile) {
+	static char errbuff[ 1024 ];
+	char str[1024];
+	char *p, * erm = NULL;
+	int line = 0;
+	int e = 1;
+	char * nested = NULL;
+	FILE * fin = stdin;
+	txsctrl * nw_xscontrols = NULL;
+
+	if (strcmp(configfile,"-")) 
+		fin = fopen(configfile,"r");
+
+	if (fin== NULL) {
+		snprintf(errbuff,sizeof(errbuff),"Cannot open %s: %s",configfile,strerror(errno));
+		return errbuff;
+	}
+
+	#define	doerr(x) { erm = x; goto xt; };
+
+ 	while((p = fgets(str,sizeof(str),fin))) {
+		char * q;
+		line ++;
+		/* Strip any white space.. */
+		while (*p && isspace((int)(*p))) 
+			p++;
+
+		if (!*p) 
+			continue; /* ignore empty lines */
+
+		if (*p == '#') 
+			continue; /* ignore comments */
+
+		if ((*p == '<') && (p[1] == '/')) {
+			p= p+2;
+			q = getnextword(&p);
+			if (!nested) 
+				doerr("Nesting close but no start");
+			if (strcmp(q,nested))
+				doerr("Nesting mismatch");
+			free(nested);
+			nested = NULL;
+		} else
+		if (*p == '<') {
+			txsctrl * cnf =  malloc(sizeof(txsctrl));
+			if (nested)  
+				doerr("Nested too deeply");
+			p++;
+			nested = strdup(getnextword(&p));
+			if (strcmp(nested,"dbase")) 
+				doerr("Expected dbase");
+
+			cnf->nxt = nw_xscontrols; 
+			nw_xscontrols = cnf;
+
+			cnf->dbase = strdup(getnextword(&p));
+			cnf->recallow = NULL;
+			cnf->recdeny = NULL;
+			cnf->first = T_UNSET;
+		} else
+		if ((q = getnextword(&p))) {
+			char * r;
+			tops op;
+			if (!nested) 
+				doerr("Not a valid directive");
+
+			/* <order> [by] <deny|allow>,<allow,deny> 
+			 * <allow|deny> [operation] <ops> [from] <spec> 
+                         */
+			do {
+	 			r = getnextword(&p);
+			} while ((!strcmp(r,"operation")) || (!strcmp(r,"by")));
+
+			if (!strcmp(q,"order")) {
+				// char * r;
+ 				// r = getnextword(&p);
+				if (!strcmp(r,"allow")) 
+					nw_xscontrols->first = T_ALLOW;
+				else
+				if (!strcmp(r,"deny")) 
+					nw_xscontrols->first = T_DENY;
+				else
+					doerr("deny or allow expected after order.");
+
+				r = getnextword(&p);
+				if ((nw_xscontrols->first == T_DENY) && (strcmp(r,"allow")))
+					doerr("expected allow after order deny");
+				if ((nw_xscontrols->first == T_ALLOW) && (strcmp(r,"deny")))
+					doerr("expected deny after order allow");
+				r = getnextword(&p);
+				if (r && *r)
+					doerr("trailing info after ordere line");
+				continue;
+			};
+
+			/* <allow|deny> [operation] <ops> [from] <spec> 
+			 */
+			if ((op = decode_ops(r))==T_ERR)
+				doerr("ops spec not recognized");
+
+			/* [from] <spec> 
+			 */
+	 		do { 
+				r = getnextword(&p);
+			} while (!strcmp(r,"from"));
+
+			/* <spec> 
+			 */
+			if (!r || !*r)
+				doerr("expected an argument\n");
+
+			if (!strcmp(q,"allow")) {
+				txscf * s = malloc(sizeof(txscf));
+				if (decode_mask(s, r))
+					doerr("syntax error in allow specification");
+				s->op = op;
+				s->nxt = nw_xscontrols->recallow;
+				nw_xscontrols->recallow = s;
+			} else
+			if (!strcmp(q,"deny")) {
+				txscf * s = malloc(sizeof(txscf));
+				if (decode_mask(s, r))
+					doerr("syntax error in deny specification");
+				s->op = op;
+				s->nxt = nw_xscontrols->recdeny;
+				nw_xscontrols->recdeny = s;
+			} else
+				doerr("Unknown directive (deny from, allow from or order expected");
+		} else {
+			doerr("Line terminated early");
+		}
+	}
+
+	if (ferror(stdin)) {
+		snprintf(errbuff,sizeof(errbuff),"Error reading config file: %s",strerror(errno));
+		goto xt;
+	};
+
+	e = 0;
+
+	/* Plase any baseline spec's at the start of the sequence.. */
+{
+	txsctrl * p, * * q, * h;
+	for(p=nw_xscontrols;(p) && (p->nxt);p=p->nxt) {
+		if (!strcmp(p->nxt->dbase,"_")) {
+			txsctrl * cnf = nw_xscontrols;
+			nw_xscontrols = p->nxt;
+			p->nxt = p->nxt->nxt;
+			nw_xscontrols->nxt = cnf;
+		};
+	}
+	/* Place any fall through *'s at the end of the sequence */
+	h = NULL;
+	for(q = &nw_xscontrols; *q;) {
+		txsctrl ** r = q; 
+		q = &((*q)->nxt);
+		if (!strcmp((*r)->dbase,"*")) {
+			txsctrl * i = h;
+			h = *r;
+			(*r) = (*r)->nxt;
+			h->nxt = i;
+		};
+	};
+	for(q = &nw_xscontrols; *q; q=&( (*q)->nxt )) {};
+	(*q) = h;
+}
+	 
+xt:
+	fclose(stdin);
+	if (erm) 
+		snprintf(errbuff,sizeof(errbuff),"Error parsing config file at line %d: %s",line,erm);
+
+	/* If the parse is success full; clean up the old config struct, if
+	 * any; and swap in the new one. Otherwise clean up the new partially
+	 * created conf; and keep the old one in place.
+	 */
+	if (e) {
+		free_config(nw_xscontrols);
+	} else {
+		free_config(xscontrols);
+		xscontrols=nw_xscontrols;
+	}
+	return e ? errbuff : NULL;
+}
+
+/* String compare; which allows a '*' at
+ * the end of a name.
+ */
+static int 
+_dbcmp(char * name, char *conf) {
+	int l = strlen(conf);
+	if (conf[l-1] == '*')
+		return strncmp(conf,name,l-1);
+	return strcmp(conf,name);
+}
+
+tops  _allowed(txscf *p, u_long ip) {
+	tops l = T_ERR;
+	for(;p;p=p->nxt) {
+		/* Should we also check on how exact the match is - and 
+		 * do the bigger masks first ? Or do them in order ?
+		 */
+		if ((ip & p->mask) == p->ip)
+			l = MAX(l,p->op);
+			/* if (mask > last_mask) { l = p->op; last_mask = p->mask; }; */
+	}
+	return l;
+}
+
+static tops 
+_deny( tops x) {
+	if (x == T_ALL) 		/* deny all */
+		return T_NONE;
+	if (x == T_DROP)		/* dropping no - but create fine */
+		return T_CREAT;
+	if (x == T_CREAT) 		/* deny create - i.e. up to rdw*/
+		return T_RDWR;
+	if (x == T_RDWR)		/* deny rdwr - i.e. up to rdonly */
+		return T_RDONLY;
+	if (x == T_RDONLY)		
+		return T_NONE;
+	if (x == T_NONE)		/* deny none - i.e. all allowed */
+		return T_CREAT;
+	return T_ERR;
+}
+
+static tops 
+_allow( tops x) {
+	if (x == T_ALL) 		/* allow all */
+		return T_DROP;
+	return x;
+}
+
+tops _allowed_ops_cnf(txsctrl * cnf, u_long ip) {
+	tops a = _allow(_allowed(cnf->recallow, ip));
+	tops d = _deny(_allowed(cnf->recdeny, ip));
+	if (a==T_ERR)
+		return d;
+	if (d==T_ERR)
+		return a;
+	if (cnf->first == T_DENY) {
+		return MAX(a,d);
+	} else {
+		return MIN(a,d);
+	}
+}
+
+/* Return the OPS level allowed to this
+ * IP; regardless of database.
+ */
+tops allowed_ops(u_long ip) {
+	txsctrl * p = xscontrols;
+	tops min = T_NONE;
+
+	for(;p;p=p->nxt) 
+		min = MAX(min,_allowed_ops_cnf(p,ip));
+
+	/* Return the baseline, if any.. */
+	return min;
+}
+
+/* Return the OPS level allowed to this
+ * IP and database
+ */
+tops allowed_ops_on_dbase(u_long ip, char *dbase) {
+	txsctrl * p = xscontrols;
+	tops min = T_NONE;
+
+	for(;p;p=p->nxt) {
+		/* Apply baseline specification.. 
+		 */
+		if ((p->dbase) && (!strcmp("_",p->dbase)))
+			min = _allowed_ops_cnf(p,ip);
+
+		/* Any specifics.. or the tailing default will
+		 * override the baseline.
+		 */
+		if ((p->dbase) && ((!_dbcmp(dbase,p->dbase)) || (!strcmp("*",p->dbase)))) {
+			tops s = _allowed_ops_cnf(p,ip);
+			if (s != T_ERR)
+				return s;
+			min = MAX(min,s);
+		}
+	}
+
+	/* Return the baseline, if any.. */
+	return min;
+}
+		
+#if __TESTING__CONF__
+
+
+void dump_config( txsctrl * p) {
+	if (!p) 
+		printf("No configurations.\n");
+	for(;p;p=p->nxt) {
+		int i;
+		printf("<dbase %s>\n",p->dbase);
+		for(i=0;i<2;i++) {
+			txscf * q = NULL;
+			char * what;
+			if (p->first == T_ALLOW) 
+				q = i ? p->recdeny : p->recallow;
+			else
+			if (p->first == T_DENY) 
+				q = i ? p->recallow : p->recdeny;
+			else
+				printf("Error!\n");
+
+			if (!i)
+				printf("\torder %s\n", (p->first == T_ALLOW) ? "allow, deny" : "deny, allow");
+			if (q)
+				printf("	# %s check\n",i ? "Then" : "First");
+
+			what = (q == p->recallow) ? "allow" : "deny";
+
+			for(;q; q=q->nxt) {
+				struct in_addr in;
+				const char * op = op2string(q->op);
+				printf("	%s %s from",what,op);
+				in.s_addr = q->ip;
+				printf(" ip %s",inet_ntoa(in));
+				in.s_addr = q->mask;
+				printf(" netmask %s",inet_ntoa(in));
+				printf("\n");
+			};
+		};
+		printf("</dbase>\n\n");
+	};
+}
+
+int main(int argc, char ** argv) {
+	int i; const char * e;
+	if (argc < 2)  {
+		fprintf(stderr,"Specify file name and perhaps some IPs/Hosts\n");
+		exit(1);
+	}
+
+	if ((e=parse_config(argv[1]))) {
+		fprintf(stderr,"Failed: %s\n",e);
+		exit(2);
+	};
+
+	dump_config(xscontrols);
+
+	if (argc == 2)
+		exit(0);
+	
+	if (argc % 2) {
+		fprintf(stderr,"Need dbase and host pairs\n");
+		exit(3);	
+	}
+			
+	for(i = 2; i<argc;i+=2) {
+		u_long ip = getip(argv[i+1]);
+		tops p;
+		struct in_addr in; 
+		in.s_addr = ip; 
+		if ((argv[i][0] == '\0') || (argv[i][0] == '*'))
+			p = allowed_ops(ip);
+		else
+			p = allowed_ops_on_dbase(ip,argv[i]);
+		printf("DBASE '%s': From Host:%s (%s) --> %s\n",argv[i],argv[i+1],inet_ntoa(in),op2string(p));
+	}
+	exit(0);
+}
+#endif



Mime
View raw message