summaryrefslogtreecommitdiffstats
path: root/applications/directql
diff options
context:
space:
mode:
Diffstat (limited to 'applications/directql')
-rw-r--r--applications/directql/Makefile89
-rw-r--r--applications/directql/directql.cc993
-rw-r--r--applications/directql/directql_error.cc119
-rw-r--r--applications/directql/directql_error.hh76
-rw-r--r--applications/directql/directql_signal.cc246
-rw-r--r--applications/directql/directql_signal.hh50
-rw-r--r--applications/directql/template_inst.hh149
7 files changed, 1722 insertions, 0 deletions
diff --git a/applications/directql/Makefile b/applications/directql/Makefile
new file mode 100644
index 0000000..8852a61
--- /dev/null
+++ b/applications/directql/Makefile
@@ -0,0 +1,89 @@
+# -*-Makefile-*-
+#
+# This file is part of rasdaman community.
+#
+# Rasdaman community is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Rasdaman community is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+#
+# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+# rasdaman GmbH.
+#
+# For more information please see <http://www.rasdaman.org>
+# or contact Peter Baumann via <baumann@rasdaman.com>. # Top Level makefile. This points to the various modules that have to be build
+# and/or deployed
+#
+# MAKEFILE FOR:
+# test programs of module servercomm
+#
+# COMMENTS:
+#
+##################################################################
+#
+# This is just an example Makefile for a test program.
+# The dependency of the test program on the lib of the
+# corresponding module is in the Makefile of the module.
+#
+
+######################### Definitions ############################
+
+# standard include with general options
+include $(RMANBASE)/Makefile.inc
+
+# all test programs
+SRCCXX= directql.cc directql_error.cc directql_signal.cc
+OBJS = ${SRCCXX:%.cc=%.o}
+ALLTESTS = ${SRCCXX:%.cc=%}
+
+# some additional flags for compiling and linking
+
+CXXFLAGS += -I$(RMANBASE)/servercomm -I$(RMANBASE)/commline
+LDFLAGS := -I$(RMANBASE)/servercomm $(LDFLAGS)
+
+# add communication flags
+CXXFLAGS += $(COMMCXXFLAGS)
+LDFLAGS += $(COMMLDFLAGS)
+
+# add compile and link options for STL
+CXXFLAGS += $(STLCXXFLAGS)
+LDFLAGS += $(STLLDFLAGS) -L$(RMANBASE)/lib
+
+########################### Targets ##############################
+
+# test target for servercomm
+.PHONY : directql
+
+directql: $(OBJS) \
+ $(QLPARSER) \
+ $(SERVERCOMM) \
+ $(CLIENTCOMM) \
+ $(CACHETAMGR) \
+ $(MDDIF) \
+ $(CATALOGIF) \
+ $(INDEXIF) \
+ $(INDEXMGR) \
+ $(BLOBIF) \
+ $(ADMINIF) \
+ $(PREPROCESSOR) \
+ $(STORAGEMGR) \
+ $(TILEMGR) \
+ $(RASLIB) \
+ $(RELINDEX) \
+ $(INDEXIF)
+ $(CXX) $(LDFLAGS) -o $@ $^ -lrasodmg $(CLIENTCOMM) -lnetwork $(QLPARSER) $(INDEXMGR) $(CACHETAMGR) $(RELINDEX) $(RELSTORAGEIF) $(RELADMINIF) $(STORAGEMGR) $(CONVERSION) $(INDEXIF) $(RELCATALOGIF) -lcommline -lpq -lecpg -lssl -lcrypto -lcrypt -lpgtypes -lm -ljpeg -ltiff -lpng -lmfhdf -ldf -lz -ldl -rdynamic -Xlinker --export-dynamic
+
+
+# general rules
+include $(RMANBASE)/Makefile.rel
+
+# automatically created dependencies
+include Makefile.dep
diff --git a/applications/directql/directql.cc b/applications/directql/directql.cc
new file mode 100644
index 0000000..98bd3ba
--- /dev/null
+++ b/applications/directql/directql.cc
@@ -0,0 +1,993 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+/
+
+/**
+* rasql
+*
+* PURPOSE:
+* Provides a command line interpretter for rasql queries, with
+* options for displaying results or storing them to file(s)
+*
+* COMMENTS:
+*
+* BUGS:
+* - query filename "" is interpreted as stdin
+*/
+
+
+static const char rasql_rcsid[] = "@(#)rasql,rasql.cc: $Id: rasql.cc,v 1.3 2006/11/06 21:59:01 rasdev Exp $";
+
+#ifndef RMANVERSION
+#error "Please specify RMANVERSION variable!"
+#endif
+
+#ifndef COMPDATE
+#error "Please specify the COMPDATE variable!"
+/*
+COMPDATE=`date +"%d.%m.%Y %H:%M:%S"`
+and -DCOMPDATE="\"$(COMPDATE)\"" when compiling
+*/
+#endif
+
+#define __EXECUTABLE__
+#define EARLY_TEMPLATE
+#define DEBUG_MAIN
+#define DEBUG
+#define RMANDEBUG
+
+#include "debug.hh"
+#include "template_inst.hh"
+#include "raslib/template_inst.hh"
+
+extern char* myExecArgv0 = "";
+extern int tiling = 1;
+extern unsigned long maxTransferBufferSize = 4000000;
+extern int globalOptimizationLevel = 4;
+extern char* dbSchema = 0;
+extern int noTimeOut = 0;
+bool udfEnabled = true;
+
+//RMINITGLOBALS('C');
+
+
+#ifdef __VISUALC__
+#include <strstrea.h>
+#else
+#include <strstream>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <sstream>
+#include <fstream>
+
+using namespace std;
+
+#ifdef __VISUALC__
+ #define __EXECUTABLE__
+#endif
+
+#include "rasodmg/ref.hh"
+#include "raslib/marraytype.hh"
+#include "rasodmg/set.hh"
+#include "rasodmg/marray.hh"
+#include "rasodmg/iterator.hh"
+#include "rasodmg/oqlquery.hh"
+
+#include "raslib/type.hh"
+
+#include "raslib/minterval.hh"
+
+#include "raslib/primitive.hh"
+#include "raslib/complex.hh"
+#include "raslib/structure.hh"
+
+#include "raslib/structuretype.hh"
+#include "raslib/primitivetype.hh"
+
+#include "cmlparser.hh"
+
+#include "directql_error.hh"
+
+#include "servercomm/servercomm.hh"
+
+
+#ifdef __VISUALC__
+ #undef __EXECUTABLE__
+#endif
+
+// debug facility; relies on -DDEBUG at compile time
+// tell debug that here is the place for the variables (to be done in the main() src file)
+#define DEBUG_MAIN
+#include "debug-clt.hh"
+
+const int MAX_STR_LEN = 255;
+const int MAX_QUERY_LEN = 10240;
+
+// possible types of output
+typedef enum
+{ OUT_UNDEF,
+ OUT_FILE,
+ OUT_NONE,
+ OUT_STRING,
+ OUT_HEX,
+ OUT_FORMATTED
+} OUTPUT_TYPE;
+
+// rasdaman MDD type for byte strings (default type used for file format reading)
+#define MDD_STRINGTYPE "GreyString"
+
+/// program exit codes
+#define EXIT_SUCCESS 0
+#define EXIT_USAGE 2
+#define EXIT_FAILURE -1
+
+// parameter names, defaults, and help texts
+
+#define PARAM_HELP_FLAG 'h'
+#define PARAM_HELP "help"
+#define HELP_HELP "show command line switches"
+
+#define PARAM_SERV_FLAG 's'
+#define PARAM_SERV "server"
+#define HELP_SERV "<host-name> rasdaman server"
+#define DEFAULT_SERV "localhost"
+
+#define PARAM_PORT_FLAG 'p'
+#define PARAM_PORT "port"
+#define HELP_PORT "<p> rasmgr port number"
+#define DEFAULT_PORT 5432
+#define DEFAULT_PORT_STR "5432"
+
+#define PARAM_DB_FLAG 'd'
+#define PARAM_DB "database"
+#define HELP_DB "<db-name> name of database"
+#define DEFAULT_DB "RASBASE"
+
+#define PARAM_USER "user"
+#define HELP_USER "<user-name> name of user"
+#define DEFAULT_USER "rasguest"
+
+#define PARAM_PASSWD "passwd"
+#define HELP_PASSWD "<user-passwd> password of user"
+#define DEFAULT_PASSWD "rasguest"
+
+#define PARAM_FILE_FLAG 'f'
+#define PARAM_FILE "file"
+#define HELP_FILE "<f> file name for upload through $i parameters within queries; each $i needs its own file parameter, in proper sequence. Requires --mdddomain and --mddtype"
+
+#define PARAM_DOMAIN "mdddomain"
+#define HELP_DOMAIN "<mdd-domain> domain of marray, format: \'[x0:x1,y0:y1]\' (required only if --file specified and file is in data format r_Array)"
+
+#define PARAM_MDDTYPE "mddtype"
+// this is for display only; internally MDD_STRINGTYPE is used
+#define DEFAULT_MDDTYPE "byte string"
+#define HELP_MDDTYPE "<mdd-type> type of marray (required only if --file specified and file is in data format r_Array)"
+
+#define PARAM_QUERY_FLAG 'q'
+#define PARAM_QUERY "query"
+#define HELP_QUERY "<q> query string to be sent to the rasdaman server for execution"
+
+#define PARAM_OUT "out"
+#define HELP_OUT "<t> use display method t for cell values of result MDDs where t is one of none, file, formatted, string, hex. Implies --content"
+#define DEFAULT_OUT OUT_NONE
+#define PARAM_OUT_FILE "file"
+#define PARAM_OUT_STRING "string"
+#define PARAM_OUT_HEX "hex"
+#define PARAM_OUT_FORMATTED "formatted"
+#define PARAM_OUT_NONE "none"
+#define DEFAULT_OUT_STR PARAM_OUT_NONE
+
+#define PARAM_CONTENT "content"
+#define HELP_CONTENT "display result, if any (see also --out and --type for output formatting)"
+
+#define PARAM_TYPE "type"
+#define HELP_TYPE "display type information for results"
+
+#define PARAM_OUTFILE_FLAG 'o'
+#define PARAM_OUTFILE "outfile"
+#define HELP_OUTFILE "<of> file name template for storing result images (ignored for scalar results). Use '%d' to indicate auto numbering position, like with printf(1). For well-known file types, a proper suffix is appended to the resulting file name. Implies --out file."
+#define DEFAULT_OUTFILE "rasql_%d"
+
+#define PARAM_QUIET "quiet"
+#define HELP_QUIET "print no ornament messages, only results and errors"
+
+#define PARAM_DEBUG "debug"
+#define HELP_DEBUG "generate diagnostic output"
+
+
+char globalConnectId[255] = {0};
+ServerComm *server;
+
+// global variables and default settings
+// -------------------------------------
+
+bool dbIsOpen = false;
+bool taIsOpen = false;
+
+DatabaseIf database;
+TransactionIf ta;
+
+// suppress regular messages in log? (cmd line parameter '--quiet')
+bool quietLog = false;
+// logging mechanism that respects 'quiet' flag:
+#define LOG(a) { if (!quietLog) std::cout << a; }
+
+int optionValueIndex=0;
+
+const char *serverName = DEFAULT_SERV;
+r_ULong serverPort = DEFAULT_PORT;
+const char *baseName = DEFAULT_DB;
+
+const char *user = DEFAULT_USER;
+const char *passwd = DEFAULT_PASSWD;
+
+const char *fileName = NULL;
+const char *queryString=NULL;
+
+bool output = false;
+bool displayType = false;
+
+OUTPUT_TYPE outputType = DEFAULT_OUT;
+
+const char *outFileMask = DEFAULT_OUTFILE;
+
+r_Minterval mddDomain;
+bool mddDomainDef = false;
+
+const char* mddTypeName = NULL;
+bool mddTypeNameDef = false;
+
+// query result set.
+// we define it here because on empty results the set seems to be corrupt which kills the default destructor
+r_Set< r_Ref_Any > result_set;
+
+// end of globals
+
+void
+parseParams(int argc, char** argv) throw (RasqlError, r_Error)
+{
+ CommandLineParser &cmlInter = CommandLineParser::getInstance();
+
+ CommandLineParameter &clp_help = cmlInter.addFlagParameter( PARAM_HELP_FLAG, PARAM_HELP, HELP_HELP );
+
+ CommandLineParameter &clp_query = cmlInter.addStringParameter(PARAM_QUERY_FLAG, PARAM_QUERY, HELP_QUERY );
+ CommandLineParameter &clp_file = cmlInter.addStringParameter(PARAM_FILE_FLAG, PARAM_FILE, HELP_FILE );
+
+ CommandLineParameter &clp_content = cmlInter.addFlagParameter( CommandLineParser::noShortName, PARAM_CONTENT, HELP_CONTENT );
+ CommandLineParameter &clp_out = cmlInter.addStringParameter( CommandLineParser::noShortName, PARAM_OUT, HELP_OUT, DEFAULT_OUT_STR );
+ CommandLineParameter &clp_outfile = cmlInter.addStringParameter( CommandLineParser::noShortName, PARAM_OUTFILE, HELP_OUTFILE, DEFAULT_OUTFILE );
+ CommandLineParameter &clp_mddDomain = cmlInter.addStringParameter( CommandLineParser::noShortName, PARAM_DOMAIN, HELP_DOMAIN );
+ CommandLineParameter &clp_mddType = cmlInter.addStringParameter( CommandLineParser::noShortName, PARAM_MDDTYPE, HELP_MDDTYPE, DEFAULT_MDDTYPE );
+ CommandLineParameter &clp_type = cmlInter.addFlagParameter( CommandLineParser::noShortName, PARAM_TYPE, HELP_TYPE );
+
+ CommandLineParameter &clp_server = cmlInter.addStringParameter( PARAM_SERV_FLAG, PARAM_SERV, HELP_SERV, DEFAULT_SERV );
+ CommandLineParameter &clp_port = cmlInter.addStringParameter( PARAM_PORT_FLAG, PARAM_PORT, HELP_PORT, DEFAULT_PORT_STR);
+ CommandLineParameter &clp_database = cmlInter.addStringParameter( PARAM_DB_FLAG, PARAM_DB, HELP_DB, DEFAULT_DB );
+ CommandLineParameter &clp_user = cmlInter.addStringParameter(CommandLineParser::noShortName, PARAM_USER, HELP_USER, DEFAULT_USER );
+ CommandLineParameter &clp_passwd = cmlInter.addStringParameter(CommandLineParser::noShortName, PARAM_PASSWD, HELP_PASSWD, DEFAULT_PASSWD );
+ CommandLineParameter &clp_quiet = cmlInter.addFlagParameter(CommandLineParser::noShortName, PARAM_QUIET, HELP_QUIET );
+
+#ifdef DEBUG
+ CommandLineParameter &clp_debug = cmlInter.addFlagParameter( CommandLineParser::noShortName, PARAM_DEBUG, HELP_DEBUG );
+#endif
+
+ try
+ {
+ cmlInter.processCommandLine(argc, argv);
+
+ if (cmlInter.isPresent( PARAM_HELP_FLAG ) || argc == 1)
+ {
+ cout << "usage: " << argv[0] << " [--query querystring|-q querystring] [options]" << endl;
+ cout << "options:" << endl;
+ cmlInter.printHelp();
+ exit( EXIT_USAGE ); // FIXME: exit no good style!!
+ }
+
+ // check mandatory parameters ====================================================
+
+ // evaluate mandatory parameter collection --------------------------------------
+ if (cmlInter.isPresent( PARAM_QUERY ))
+ queryString = cmlInter.getValueAsString( PARAM_QUERY );
+ else
+ throw RasqlError( NOQUERY );
+
+ // check optional parameters ====================================================
+
+ // evaluate optional parameter file --------------------------------------
+ if (cmlInter.isPresent( PARAM_FILE ))
+ fileName = cmlInter.getValueAsString( PARAM_FILE );
+
+ // evaluate optional parameter server --------------------------------------
+ if (cmlInter.isPresent( PARAM_SERV ))
+ serverName = cmlInter.getValueAsString( PARAM_SERV );
+
+ // evaluate optional parameter port --------------------------------------
+ if (cmlInter.isPresent( PARAM_PORT ))
+ serverPort = cmlInter.getValueAsLong( PARAM_PORT );
+
+ // evaluate optional parameter database --------------------------------------
+ if (cmlInter.isPresent( PARAM_DB ))
+ baseName = cmlInter.getValueAsString( PARAM_DB );
+
+ // evaluate optional parameter user --------------------------------------
+ if (cmlInter.isPresent( PARAM_USER ))
+ user = cmlInter.getValueAsString( PARAM_USER );
+
+ // evaluate optional parameter passwd --------------------------------------
+ if (cmlInter.isPresent( PARAM_PASSWD ))
+ passwd = cmlInter.getValueAsString( PARAM_PASSWD );
+
+ // evaluate optional parameter content --------------------------------------
+ if (cmlInter.isPresent( PARAM_CONTENT ))
+ output = true;
+
+ // evaluate optional parameter type --------------------------------------
+ if (cmlInter.isPresent( PARAM_TYPE ))
+ displayType = true;
+
+ // evaluate optional parameter hex --------------------------------------
+ if (cmlInter.isPresent( PARAM_OUT ))
+ {
+ output = true;
+ const char* val = cmlInter.getValueAsString( PARAM_OUT );
+ if (val !=0 && strcmp( val, PARAM_OUT_STRING ) == 0)
+ outputType = OUT_STRING;
+ else if (val !=0 && strcmp( val, PARAM_OUT_FILE ) == 0)
+ outputType = OUT_FILE;
+ else if (val !=0 && strcmp( val, PARAM_OUT_FORMATTED ) == 0)
+ outputType = OUT_FORMATTED;
+ else if (val !=0 && strcmp( val, PARAM_OUT_HEX ) == 0)
+ outputType = OUT_HEX;
+ else if (val !=0 && strcmp( val, PARAM_OUT_NONE ) == 0)
+ outputType = OUT_NONE;
+ else
+ throw RasqlError( ILLEGALOUTPUTTYPE );
+ }
+
+ // evaluate optional parameter outfile --------------------------------------
+ if (cmlInter.isPresent( PARAM_OUTFILE ))
+ {
+ outFileMask = cmlInter.getValueAsString( PARAM_OUTFILE );
+ outputType = OUT_FILE;
+ }
+
+ // evaluate optional parameter domain --------------------------------------
+ if ( cmlInter.isPresent( PARAM_DOMAIN ) )
+ {
+ try
+ {
+ mddDomain = r_Minterval(cmlInter.getValueAsString( PARAM_DOMAIN ));
+ mddDomainDef = true;
+ }
+ catch ( r_Error& e ) // Minterval constructor had syntax problems
+ {
+ throw RasqlError( NOVALIDDOMAIN );
+ }
+ }
+
+ // evaluate optional parameter MDD type name --------------------------------------
+ if (cmlInter.isPresent( PARAM_MDDTYPE ))
+ {
+ mddTypeName = cmlInter.getValueAsString( PARAM_MDDTYPE );
+ mddTypeNameDef = true;
+ }
+
+ // evaluate optional parameter 'quiet' --------------------------------------------
+ if (cmlInter.isPresent( PARAM_QUIET ))
+ {
+ quietLog = true;
+ }
+
+#ifdef DEBUG
+ // evaluate optional parameter MDD type name --------------------------------------
+ SET_OUTPUT( cmlInter.isPresent( PARAM_DEBUG ) );
+#endif
+
+ }
+ catch(CmlException& err)
+ {
+ cerr << err.what() << endl;
+ throw RasqlError( ERRORPARSINGCOMMANDLINE );
+ }
+} // parseParams()
+
+
+void
+openDatabase() throw (r_Error)
+{
+ ENTER( "openDatabase" );
+
+ if (! dbIsOpen)
+ {
+ LOG( "opening database " << baseName << " at " << serverName << ":" << serverPort << "..." << flush );
+ //
+ sprintf(globalConnectId, "tcp:postgresql://%s:%d/%s", serverName, serverPort, baseName);
+ //strcpy(globalConnectId, "tcp:postgresql://$serverName:$serverPort/$baseName");
+ printf("conn = %s\n", globalConnectId);
+
+ server = new ServerComm(300, 120, 7013, "rasmgr", 7001, "N1");
+
+
+ AdminIf* myAdmin = AdminIf::instance();
+ database.open( "RASSERVICE");
+
+ //ta.begin( &database );
+
+ ServerComm::ClientTblElt *r = new ServerComm::ClientTblElt("testclient", 2);
+ server->addClientTblEntry (r);
+ accessControl.setServerName("NT1");
+ accessControl.crunchCapability("$I1$ER.$BRASBASE$T1:3:2008:23:39:24$NNT1$D983893f406445a922cba0301bc5a85ec$K");
+ server->openDB(2, "RASBASE", "costea");
+ SET_OUTPUT(TRUE);
+
+ TALK( "ok" );
+ dbIsOpen = true;
+ LOG( "ok" << endl << flush );
+ }
+
+ LEAVE( "openDatabase" );
+} // openDatabase()
+
+void
+closeDatabase() throw (r_Error)
+{
+ ENTER( "closeDatabase" );
+
+ if (dbIsOpen)
+ {
+ TALK( "database was open, closing it" );
+ dbIsOpen = false;
+ }
+
+ LEAVE( "closeDatabase" );
+ return;
+} // closeDatabase()
+
+void
+openTransaction(bool readwrite) throw (r_Error)
+{
+ ENTER( "openTransaction, readwrite=" << (readwrite ? "rw" : "ro" ) );
+
+ if (! taIsOpen)
+ {
+ if (readwrite)
+ {
+ TALK( "transaction was closed, opening rw..." );
+ ta.begin(&database);
+ TALK( "ok" );
+ }
+ else
+ {
+ TALK( "transaction was closed, opening ro..." );
+ ta.begin(&database);
+ TALK( "ok" );
+ }
+
+ taIsOpen = true;
+ }
+
+ LEAVE( "openTransaction" );
+} // openTransaction()
+
+void
+closeTransaction( bool doCommit ) throw (r_Error)
+{
+ ENTER( "closeTransaction, doCommit=" << doCommit );
+
+ if (taIsOpen)
+ {
+ if (doCommit)
+ {
+ TALK( "transaction was open, committing it..." );
+ ta.commit();
+ TALK( "ok" );
+ }
+ else
+ {
+ TALK( "transaction was open, aborting it..." );
+ ta.abort();
+ TALK( "ok" );
+ }
+ taIsOpen = false;
+ }
+
+ LEAVE( "closeTransaction" );
+ return;
+} // closeTransaction()
+
+void printScalar( const r_Scalar& scalar )
+{
+ ENTER( "printScalar" );
+
+ switch( scalar.get_type()->type_id() )
+ {
+ case r_Type::BOOL:
+ LOG( ( ((r_Primitive*)&scalar)->get_boolean() ? "t" : "f" ) << flush );
+ break;
+
+ case r_Type::CHAR:
+ LOG( (int)((r_Primitive*)&scalar)->get_char() << flush );
+ break;
+
+ case r_Type::OCTET:
+ LOG( (int)((r_Primitive*)&scalar)->get_octet() << flush );
+ break;
+
+ case r_Type::SHORT:
+ LOG( ((r_Primitive*)&scalar)->get_short() << flush );
+ break;
+
+ case r_Type::USHORT:
+ LOG( ((r_Primitive*)&scalar)->get_ushort() << flush );
+ break;
+
+ case r_Type::LONG:
+ LOG( ((r_Primitive*)&scalar)->get_long() << flush );
+ break;
+
+ case r_Type::ULONG:
+ LOG( ((r_Primitive*)&scalar)->get_ulong() << flush );
+ break;
+
+ case r_Type::FLOAT:
+ LOG( ((r_Primitive*)&scalar)->get_float() << flush );
+ break;
+
+ case r_Type::DOUBLE:
+ LOG( ((r_Primitive*)&scalar)->get_double() << flush );
+ break;
+
+ case r_Type::COMPLEXTYPE1:
+ case r_Type::COMPLEXTYPE2:
+ LOG( "(" << ((r_Complex*)&scalar)->get_re() << "," << ((r_Complex*)&scalar)->get_im() << ")" << flush );
+ break;
+
+ case r_Type::STRUCTURETYPE:
+ {
+ r_Structure* structValue = (r_Structure*)&scalar;
+ LOG( "{ " << flush );
+ for( int i=0; i<structValue->count_elements(); i++ )
+ {
+ printScalar( (*structValue)[i] );
+ if( i < structValue->count_elements()-1 )
+ LOG( ", " << flush );
+ }
+ LOG( " }" << endl );
+ }
+ break;
+ default:
+ LOG( "scalar type " << scalar.get_type()->type_id() << " not supported!" << endl );
+ break;
+ }
+ LEAVE( "printScalar" );
+} // printScalar()
+
+
+// result_set should be parameter, but is global -- see def for reason
+void printResult( r_Minterval &mddDomain, char* &typeName,
+ char* &typeStructure,
+ r_OId &oid,
+ unsigned short &currentFormat)
+{
+ ENTER( "printResult" );
+
+ if (displayType)
+ {
+ cout << " Oid...................: " << oid << endl;
+ cout << " Type Structure........: "
+ << ( typeStructure ? typeStructure : "<nn>" ) << endl;
+ cout << endl;
+ }
+
+ /* The following can be used if the type is known and the element type is not atomic.
+
+ r_Set< r_Ref< r_Point > >* set2 = (r_Set< r_Ref< r_Point > >*)&result_set;
+ r_Iterator< r_Ref<r_Point> > iter2 = set2->create_iterator();
+ for( iter2.reset(); iter2.not_done(); iter2++ )
+ cout << **iter2 << endl;
+ */
+
+ r_Iterator< r_Ref_Any > iter = result_set.create_iterator();
+ // iter.not_done() seems to behave wrongly on empty set, therefore this additional check -- PB 2003-aug-16
+ for ( int i=1 ; i<=result_set.cardinality() && iter.not_done(); iter++, i++ )
+ {
+ switch( result_set.get_element_type_schema()->type_id() )
+ {
+ case r_Type::MARRAYTYPE:
+ switch ( outputType )
+ {
+ case OUT_NONE:
+ break;
+ case OUT_STRING:
+ {
+ int numCells = r_Ref<r_GMarray>(*iter)->get_array_size();
+ const char* theStuff = r_Ref<r_GMarray>(*iter)->get_array();
+ LOG( " Result object " << i << ": " );
+ for (int cnt = 0; cnt < numCells; cnt++)
+ cout << theStuff[cnt];
+ cout << endl;
+ }
+ break;
+ case OUT_HEX:
+ {
+ int numCells = r_Ref<r_GMarray>(*iter)->get_array_size();
+ const char* theStuff = r_Ref<r_GMarray>(*iter)->get_array();
+ LOG( " Result object " << i << ": " );
+ cout << hex;
+ for (int cnt = 0; cnt < numCells; cnt++)
+ cout << setw(2) << (unsigned short) (0xff & theStuff[cnt]) << " ";
+ cout << dec << endl;
+ }
+ break;
+ case OUT_FORMATTED:
+ LOG( " Result object " << i << ":" << endl );
+ // for (int cnt = 0; cnt < numCells; cnt++)
+ printScalar( *(r_Ref<r_Scalar>(*iter)) );
+ cout << endl;
+ break;
+ case OUT_FILE:
+ {
+ char defFileName[FILENAME_MAX];
+ (void) snprintf( defFileName, sizeof(defFileName)-1, outFileMask, i );
+ TALK( "filename for #" << i << " is " << defFileName );
+
+ // special treatment only for DEFs
+ r_Data_Format mafmt = r_Ref<r_GMarray>(*iter)->get_current_format();
+ switch (mafmt)
+ {
+ case r_TIFF:
+ strcat( defFileName, ".tif" ); break;
+ case r_JPEG:
+ strcat( defFileName, ".jpg" ); break;
+ case r_HDF:
+ strcat( defFileName, ".hdf" ); break;
+ case r_PNG:
+ strcat( defFileName, ".png" ); break;
+ case r_BMP:
+ strcat( defFileName, ".bmp" ); break;
+ case r_VFF:
+ strcat( defFileName, ".vff" ); break;
+ default:
+ strcat( defFileName, ".unknown" ); break;
+ break;
+ }
+
+ LOG( " Result object " << i << ": going into file " << defFileName << "..." << flush );
+ FILE *tfile = fopen( defFileName, "wb" );
+ fwrite((void*)r_Ref<r_GMarray>(*iter)->get_array(), 1, r_Ref<r_GMarray>(*iter)->get_array_size(), tfile );
+ fclose(tfile);
+ LOG( "ok." << endl );
+ }
+ break;
+ default:
+ cerr << "Internal error: unknown output type, ignoring action: " << outputType << endl;
+ break;
+ } // switch(outputType)
+ break;
+
+ case r_Type::POINTTYPE:
+ LOG( " Result element " << i << ": " );
+ cout << *(r_Ref<r_Point>(*iter)) << endl;
+ break;
+
+ case r_Type::SINTERVALTYPE:
+ LOG( " Result element " << i << ": " );
+ cout << *(r_Ref<r_Sinterval>(*iter)) << endl;
+ break;
+
+ case r_Type::MINTERVALTYPE:
+ LOG( " Result element " << i << ": " );
+ cout << *(r_Ref<r_Minterval>(*iter)) << endl;
+ break;
+
+ case r_Type::OIDTYPE:
+ LOG( " Result element " << i << ": " );
+ cout << *(r_Ref<r_OId>(*iter)) << endl;
+ break;
+
+ default:
+ LOG( " Result element " << i << ": " << flush );
+ printScalar( *(r_Ref<r_Scalar>(*iter)) );
+ cout << endl;
+ // or simply
+ // r_Ref<r_Scalar>(*iter)->print_status( cout );
+ } // switch
+ } // for(...)
+
+ LEAVE( "printResult" );
+} // printResult()
+
+
+/*
+ * get database type structure from type name
+ * returns ptr if an MDD type with the given name exists in the database, NULL otherwise
+ * throws r_Error upon general database comm error
+ * needs an open transaction
+ */
+r_Marray_Type * getTypeFromDatabase( const char *mddTypeName ) throw(RasqlError, r_Error)
+{
+ ENTER( "getTypeFromDatabase, mddTypeName=" << mddTypeName );
+ r_Marray_Type *retval = NULL;
+ char* typeStructure = NULL;
+
+ // first, try to get type structure from database using a separate r/o transaction
+ try
+ {
+ server->getTypeStructure(2, mddTypeName, ClientComm::r_MDDType_Type, typeStructure);
+ TALK( "type structure is " << typeStructure );
+ }
+ catch (r_Error& err)
+ {
+ if (err.get_kind() == r_Error::r_Error_DatabaseClassUndefined)
+ {
+ TALK( "Type is not a well known type: " << typeStructure );
+ typeStructure = new char[strlen(mddTypeName) + 1];
+ // earlier code tried this one below, but I feel we better are strict -- PB 2003-jul-06
+ // strcpy(typeStructure, mddTypeName);
+ // TALK( "using instead: " << typeStructure );
+ throw RasqlError( MDDTYPEINVALID );
+ }
+ else // unanticipated error
+ {
+ TALK( "Error during type retrieval from database: " << err.get_errorno() << " " << err.what() );
+ throw;
+ }
+ }
+
+ // next, find out whether it is an MDD type (and not a base or set type, eg)
+ try
+ {
+ r_Type* tempType = r_Type::get_any_type(typeStructure);
+ TALK( "get_any_type() for this type returns: " << tempType );
+ if (tempType->isMarrayType())
+ {
+ retval = (r_Marray_Type*)tempType;
+ tempType = NULL;
+ TALK( "found MDD type: " << retval );
+ }
+ else
+ {
+ TALK( "type is not an marray type: " << typeStructure );
+ delete tempType;
+ tempType = NULL;
+ retval = NULL;
+ throw RasqlError( MDDTYPEINVALID );
+ }
+ }
+ catch (r_Error& err)
+ {
+ TALK( "Error during retrieval of MDD type structure (" << typeStructure << "): " << err.get_errorno() << " " << err.what() );
+ throw;
+ }
+
+ delete [] typeStructure;
+ typeStructure = NULL;
+
+ LEAVE( "getTypeFromDatabase, retval=" << retval );
+ return retval;
+} // getTypeFromDatabase()
+
+void doStuff( int argc, char** argv ) throw (r_Error)
+{
+ char *fileContents = NULL; // contents of file satisfying "$1" parameter in query
+ r_Ref<r_GMarray> fileMDD = NULL; // MDD to satisfy a "$1" parameter
+ r_Marray_Type *mddType = NULL; // this MDD's type
+
+ ENTER( "doStuff" );
+
+ r_OQL_Query query( queryString );
+ TALK( "query is: " << query.get_query() );
+
+ if ( fileName != NULL )
+ {
+ openTransaction( false );
+
+ // if no type name was specified then assume byte string (for encoded files)
+ if ( ! mddTypeNameDef )
+ mddTypeName = MDD_STRINGTYPE;
+
+ LOG( "fetching type information for " << mddTypeName << " from database, using readonly transaction..." << flush );
+ mddType = getTypeFromDatabase( mddTypeName );
+ closeTransaction( true );
+ LOG( "ok" << endl );
+
+ LOG( "reading file " << fileName << "..." << flush );
+ FILE* fileD = fopen( fileName, "r" );
+ if (fileD == NULL)
+ throw RasqlError( FILEINACCESSIBLE );
+
+ fseek( fileD, 0, SEEK_END );
+ int size = ftell( fileD );
+ TALK( "file size is " << size << " bytes" );
+ try
+ {
+ fileContents = new char[size];
+ }
+ catch(std::bad_alloc)
+ {
+ TALK( "Unable to claim memory: " << size << " Bytes" );
+ throw RasqlError( UNABLETOCLAIMRESOURCEFORFILE );
+ }
+
+ fseek( fileD, 0, SEEK_SET );
+ fread( fileContents, 1, size, fileD );
+ fclose( fileD );
+
+ // if no domain specified (this is the case with encoded files), then set to byte stream:
+ if ( ! mddDomainDef )
+ {
+ mddDomain = r_Minterval( 1 ) << r_Sinterval ( 0, size-1 );
+ TALK( "domain set to " << mddDomain );
+ }
+
+ if (size != mddDomain.cell_count() * mddType->base_type().size())
+ throw RasqlError( FILESIZEMISMATCH );
+ LOG( "ok" << endl );
+
+ TALK( "setting up MDD with domain " << mddDomain << " and base type " << mddTypeName );
+ fileMDD = new (mddTypeName) r_GMarray( mddDomain, mddType->base_type().size() );
+ fileMDD->set_type_schema( mddType );
+ fileMDD->set_array_size( mddDomain.cell_count() * mddType->base_type().size() );
+ fileMDD->set_array( fileContents );
+
+ query << *fileMDD;
+
+ TALK( "constants are:" );
+ r_Set<r_GMarray *> * myConstSet = (r_Set<r_GMarray *> *) query.get_constants();
+ r_Iterator< r_GMarray *> iter = myConstSet->create_iterator();
+ int i;
+ for ( i=1, iter.reset(); iter.not_done(); iter++, i++ )
+ {
+ r_Ref< r_GMarray > myConstant = *iter;
+ LOG( " constant " << i << ": " );
+ myConstant->print_status( cout );
+// the following can be used for sporadic debugging of input files, but beware: is very verbose!
+#if 0
+ cout << " Contents: " << hex;
+ const char *a = myConstant->get_array();
+ for (int m=0; m < myConstant->get_array_size(); m++)
+ cout << (unsigned short) (a[m] & 0xFF) << " ";
+ cout << dec << endl;
+#endif
+ }
+ }
+
+ ExecuteQueryRes result;
+
+ if( query.is_update_query() )
+ {
+ openTransaction( true );
+
+ r_Marray<r_ULong>* mddConst = NULL;
+
+ LOG( "Executing update query..." << flush );
+ server->executeQuery(2, queryString, result );
+ LOG( "ok" << endl );
+
+ if( mddConst )
+ delete mddConst;
+
+ closeTransaction( true );
+ }
+ else
+ {
+ openTransaction( false );
+
+ // should be defined here, but is global; see def for reason
+ // r_Set< r_Ref_Any > result_set;
+
+ LOG( "Executing retrieval query..." << flush );
+ int status;
+ status = server->executeQuery(2, queryString, result );
+ switch (status)
+ {
+ case 0: LOG("holds MDD elements" << endl);
+ break;
+ case 1: LOG("holds non-MDD elements" << endl);
+ break;
+ case 2: LOG("holds no elements" << endl);
+ break;
+ };
+
+ r_Minterval mddDomain;
+ char* typeName;
+ char* typeStructure;
+ r_OId oid;
+ unsigned short currentFormat;
+
+ LOG( "Getting result..." << flush );
+ if( output ) {
+ while (true) {
+ LOG( "Getting mdd..." << endl << flush );
+ status = server->getNextMDD(2, mddDomain, typeName, typeStructure, oid, currentFormat);
+ if (status==2) {
+ printf("Empty MDD\n");
+ break;
+ }
+
+ }
+ }
+ //result_set = result;
+ LOG( "ok" << endl );
+
+ closeTransaction( true );
+ }
+
+ if (fileContents != NULL)
+ delete [] fileContents;
+
+ LEAVE( "doStuff" );
+}
+
+/*
+ * returns 0 on success, -1 on error
+ */
+int main(int argc, char** argv)
+{
+ SET_OUTPUT( true ); // inhibit unconditional debug output, await cmd line evaluation
+
+ int retval = EXIT_SUCCESS; // overall result status
+
+ try
+ {
+ parseParams( argc, argv );
+
+ // put LOG after parsing parameters to respect a '--quiet'
+ LOG( argv[0] << ": rasdaman query tool v1.0, rasdaman v" << RMANVERSION/1000 << " -- generated on " << COMPDATE << "." << endl );
+
+ openDatabase();
+ doStuff( argc, argv );
+ closeDatabase();
+ retval = EXIT_SUCCESS;
+ }
+ catch (RasqlError& e)
+ {
+ cerr << argv[0] << ": " << e.what() << endl;
+ retval = EXIT_FAILURE;
+ }
+ catch (const r_Error& e)
+ {
+ cerr << "rasdaman error " << e.get_errorno() << ": " << e.what() << endl;
+ retval = EXIT_FAILURE;
+ }
+ catch (...)
+ {
+ cerr << argv[0] << ": panic: unexpected internal exception." << endl;
+ retval = EXIT_FAILURE;
+ }
+
+ if (retval != EXIT_SUCCESS && (dbIsOpen || taIsOpen) )
+ {
+ LOG( "aborting transaction..." << flush );
+ closeTransaction( false ); // abort transaction and close database, ignore any further exceptions
+ LOG( "ok" << endl );
+ closeDatabase();
+ }
+
+ LOG( argv[0] << " done." << endl );
+ return retval;
+} // main()
+
+// end of rasql.cc
+
diff --git a/applications/directql/directql_error.cc b/applications/directql/directql_error.cc
new file mode 100644
index 0000000..cba8c5e
--- /dev/null
+++ b/applications/directql/directql_error.cc
@@ -0,0 +1,119 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+/
+
+/**
+* SOURCE: rasql_error.cc
+*
+* CLASS: RasqlError
+*
+* COMMENTS:
+* No comments
+*/
+
+
+using namespace std;
+
+static const char rcsid[] = "@(#)raslib, RasqlError: $Id: rasql_error.cc,v 1.1 2003/12/27 19:30:23 rasdev Exp $";
+
+#include <exception>
+#include <string>
+
+// for sprintf():
+#include <stdio.h>
+
+#include "directql_error.hh"
+
+// debug facility; relies on -DDEBUG at compile time
+#include "debug-clt.hh"
+
+/// error object, carrying int error code
+RasqlError::RasqlError( unsigned int e )
+{
+ TALK( "Exception: " << e );
+ errno = e;
+}
+
+/// default destructor
+RasqlError::~RasqlError()
+{
+}
+
+/// print error message (including error code)
+/// NB: not all messages can occur
+const char*
+RasqlError::what()
+{
+ char *errorMsg;
+ switch (errno)
+ {
+ case NOQUERY:
+ errorMsg = "Mandatory parameter '--query' missing.";
+ break;
+ case ERRORPARSINGCOMMANDLINE:
+ errorMsg = "Command line syntax error.";
+ break;
+ case ILLEGALOUTPUTTYPE:
+ errorMsg = "Illegal output type specifier, must be one of none, file, formatted, string, hex.";
+ break;
+ case FILEINACCESSIBLE:
+ errorMsg = "Cannot read input file.";
+ break;
+ case UNABLETOCLAIMRESOURCEFORFILE:
+ errorMsg = "Cannot allocate memory for file read.";
+ break;
+ case NOVALIDDOMAIN:
+ errorMsg = "Syntax error in mdddomain specification, must be [x0:x1,y0:y1] (forgot to quote or escape?)";
+ break;
+ case MDDTYPEINVALID:
+ errorMsg = "MDD type invalid.";
+ break;
+ case FILESIZEMISMATCH:
+ errorMsg = "Input file size does not correspond with MDD domain specified.";
+ break;
+ default :
+ errorMsg = "Unknown error code.";
+ break;
+ case ALLDONE:
+ case 0:
+ errorMsg = "No errors.";
+ }
+
+// size of error text buffer below
+#define ERRTEXT_BUFSIZ 200
+
+ static char errorText[ERRTEXT_BUFSIZ];
+
+// text constants for error msg
+#define MODULE_TAG "IO"
+#define ERROR_TEXT " Error: "
+
+ // check for buffer overflow
+ if (strlen(MODULE_TAG) + 3 + strlen(ERROR_TEXT) + strlen(errorMsg) + 1 > ERRTEXT_BUFSIZ)
+ sprintf( errorText, "%s%03d%s", MODULE_TAG, errno, "(error message too long, cannot display)" );
+ else
+ sprintf( errorText, "%s%03d%s%s", MODULE_TAG, errno, ERROR_TEXT, errorMsg );
+
+ return errorText;
+} // what()
+
+
diff --git a/applications/directql/directql_error.hh b/applications/directql/directql_error.hh
new file mode 100644
index 0000000..99d7c97
--- /dev/null
+++ b/applications/directql/directql_error.hh
@@ -0,0 +1,76 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+/
+
+/**
+ *
+ * COMMENTS:
+ *
+ * No Comments
+*/
+
+#ifndef _RASQL_ERROR_HH_
+#define _RASQL_ERROR_HH_
+
+#ifdef __VISUALC__
+#pragma warning( disable : 4290 )
+#endif
+
+//@ManMemo: Module: {\bf raslib}
+
+/*@Doc:
+
+ This class ...
+*/
+
+
+ /// valid error codes:
+#define ALLDONE -1
+#define OK 0
+#define NOQUERY 1
+#define ERRORPARSINGCOMMANDLINE 2
+#define ILLEGALOUTPUTTYPE 3
+#define FILEINACCESSIBLE 4
+#define UNABLETOCLAIMRESOURCEFORFILE 5
+#define NOVALIDDOMAIN 6
+#define MDDTYPEINVALID 7
+#define FILESIZEMISMATCH 8
+
+class RasqlError // : public std::exception
+{
+ public:
+
+ /// constructor receiving an error number
+ RasqlError( unsigned int e );
+
+ /// destructor
+ virtual ~RasqlError();
+
+ /// get an error description
+ virtual const char * what();
+
+ private:
+ /// error information
+ unsigned int errno;
+};
+
+#endif // _RASQL_ERROR_HH_
diff --git a/applications/directql/directql_signal.cc b/applications/directql/directql_signal.cc
new file mode 100644
index 0000000..3ccdb97
--- /dev/null
+++ b/applications/directql/directql_signal.cc
@@ -0,0 +1,246 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+
+/* *
+ * SOURCE: rasql_globals.cc
+ *
+ * MODULE: applications/rasql
+ *
+ * PURPOSE:
+ * provide signal handling
+ *
+ * COMMENTS:
+ *
+ * No comments
+*/
+
+static const char rcsid[] = "@(#)rasodmg/test,ImportOrthoUtil: $Id: rasql_signal.cc,v 1.1 2003/12/27 19:30:23 rasdev Exp $";
+
+#ifdef EARLY_TEMPLATE
+#define __EXECUTABLE__
+#include "raslib/template_inst.hh"
+#endif
+
+#include <iostream>
+#include <string>
+#include <iostream>
+#include <signal.h>
+#ifdef SOLARIS
+#include <strings.h>
+#endif
+
+#include "directql_error.hh"
+#include "directql_signal.hh"
+
+// debug facility; relies on -DDEBUG at compile time
+#include "debug-clt.hh"
+
+//signalCleanup function is called when a signal is received by the program.
+//You should write your function in order to have signal management
+void signalCleanup();
+
+//signalHandler function is called when a signal occurs
+void
+signalHandler(int sig);
+
+//installSignalHandlers function should be called first in main function
+//in order to receive a signal in your program
+void
+signalHandler(int sig)
+{
+ static bool handleSignal = true; // sema to prevent nested signals
+
+ cout << "Caught signal " << sig << ": ";
+ switch (sig)
+ {
+ case SIGHUP:
+ cout << "Hangup (POSIX). ";
+ break;
+ case SIGINT:
+ cout << "Interrupt (ANSI).";
+ break;
+ case SIGQUIT:
+ cout << "Quit (POSIX).";
+ break;
+ case SIGILL:
+ cout << "Illegal instruction (ANSI).";
+ break;
+ case SIGTRAP:
+ cout << "Trace trap (POSIX).";
+ break;
+ case SIGABRT:
+ cout << "Abort (ANSI) or IOT trap (4.2 BSD).";
+ break;
+ case SIGBUS:
+ cout << "BUS error (4.2 BSD).";
+ break;
+ case SIGFPE:
+ cout << "Floating-point exception (ANSI).";
+ break;
+ case SIGKILL:
+ cout << "Kill, unblockable (POSIX).";
+ break;
+ case SIGUSR1:
+ cout << "User-defined signal 1 (POSIX).";
+ break;
+ case SIGSEGV:
+ cout << "Segmentation violation (ANSI).";
+ break;
+ case SIGUSR2:
+ cout << "User-defined signal 2 (POSIX).";
+ break;
+ case SIGPIPE:
+ cout << "Broken pipe (POSIX).";
+ break;
+ case SIGALRM:
+ cout << "Alarm clock (POSIX).";
+ break;
+ case SIGTERM:
+ cout << "Termination (ANSI).";
+ break;
+#ifndef SOLARIS
+#ifndef DECALPHA
+ case SIGSTKFLT:
+ cout << "Stack fault.";
+ break;
+#endif
+#endif
+ case SIGCLD:
+ cout << "SIGCHLD (System V) or child status has changed (POSIX).";
+ break;
+ case SIGCONT:
+ cout << "Continue (POSIX).";
+ break;
+ case SIGSTOP:
+ cout << "Stop, unblockable (POSIX).";
+ break;
+ case SIGTSTP:
+ cout << "Keyboard stop (POSIX). Continuing operation.";
+ break;
+ case SIGTTIN:
+ cout << "Background read from tty (POSIX).";
+ break;
+ case SIGTTOU:
+ cout << "Background write to tty (POSIX). Continuing operation";
+ break;
+ case SIGURG:
+ cout << "Urgent condition on socket (4.2 BSD).";
+ break;
+ case SIGXCPU:
+ cout << "CPU limit exceeded (4.2 BSD).";
+ break;
+ case SIGXFSZ:
+ cout << "File size limit exceeded (4.2 BSD).";
+ break;
+ case SIGVTALRM:
+ cout << "Virtual alarm clock (4.2 BSD).";
+ break;
+ case SIGPROF:
+ cout << "Profiling alarm clock (4.2 BSD).";
+ break;
+ case SIGWINCH:
+ cout << "Window size change (4.3 BSD, Sun). Continuing operation.";
+ break;
+ case SIGPOLL:
+ cout << "Pollable event occurred (System V) or I/O now possible (4.2 BSD).";
+ break;
+ case SIGPWR:
+ cout << "Power failure restart (System V).";
+ break;
+ case SIGSYS:
+ cout << "Bad system call.";
+ break;
+ default:
+ cout << "Unknown signal.";
+ break;
+ }
+ cout << endl << flush;
+
+ // no repeated signals
+ if (handleSignal)
+ handleSignal = false;
+
+ if (sig == SIGCONT || sig == SIGTSTP || sig == SIGTTIN || sig == SIGTTOU || sig == SIGWINCH)
+ return;
+ else
+ {
+ TALK( "fatal signal, exiting." << flush );
+ exit(sig);
+ }
+}
+
+void
+installSignalHandlers()
+{
+ ENTER( "installSignalHandlers" );
+
+ signal(SIGINT, signalHandler);
+ signal(SIGTERM, signalHandler);
+ signal(SIGHUP, signalHandler);
+ signal(SIGPIPE, signalHandler);
+ signal(SIGHUP, signalHandler);
+ signal(SIGINT, signalHandler);
+ signal(SIGQUIT, signalHandler);
+ signal(SIGILL, signalHandler);
+ signal(SIGTRAP, signalHandler);
+ signal(SIGABRT, signalHandler);
+ signal(SIGIOT, signalHandler);
+ signal(SIGBUS, signalHandler);
+ signal(SIGFPE, signalHandler);
+ signal(SIGKILL, signalHandler);
+ signal(SIGUSR1, signalHandler);
+ signal(SIGSEGV, signalHandler);
+ signal(SIGUSR2, signalHandler);
+ signal(SIGPIPE, signalHandler);
+ signal(SIGALRM, signalHandler);
+ signal(SIGTERM, signalHandler);
+#ifndef SOLARIS
+#ifndef DECALPHA
+ signal(SIGSTKFLT, signalHandler);
+#endif
+#endif
+ signal(SIGCLD, signalHandler);
+ signal(SIGCHLD, signalHandler);
+ signal(SIGCONT, signalHandler);
+ signal(SIGSTOP, signalHandler);
+ signal(SIGTSTP, signalHandler);
+ signal(SIGTTIN, signalHandler);
+ signal(SIGTTOU, signalHandler);
+ signal(SIGURG, signalHandler);
+ signal(SIGXCPU, signalHandler);
+ signal(SIGXFSZ, signalHandler);
+ signal(SIGVTALRM, signalHandler);
+ signal(SIGPROF, signalHandler);
+ signal(SIGWINCH, signalHandler);
+ signal(SIGPOLL, signalHandler);
+ signal(SIGIO, signalHandler);
+ signal(SIGPWR, signalHandler);
+ signal(SIGSYS, signalHandler);
+#if !defined SOLARIS
+#if !defined DECALPHA
+ signal(SIGUNUSED, signalHandler);
+#endif
+#endif
+ LEAVE( "installSignalHandlers" );
+}
+
diff --git a/applications/directql/directql_signal.hh b/applications/directql/directql_signal.hh
new file mode 100644
index 0000000..360804e
--- /dev/null
+++ b/applications/directql/directql_signal.hh
@@ -0,0 +1,50 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+
+/* *
+ * COMMENTS:
+ *
+ * No comments
+*/
+
+#ifndef _RASQL_SIGNAL_HH_
+#define _RASQL_SIGNAL_HH_
+
+#include <signal.h>
+
+//signalCleanup function is called when a signal is received by the program.
+//You should write your function in order to have signal management
+void signalCleanup();
+
+//signalHandler function is called when a signal occurs
+void
+signalHandler(int sig);
+
+//installSignalHandlers function should be called first in main function
+//in order to receive signal in your program
+
+void
+installSignalHandlers();
+
+#endif _RASQL_SIGNAL_HH_
+
diff --git a/applications/directql/template_inst.hh b/applications/directql/template_inst.hh
new file mode 100644
index 0000000..bed46ab
--- /dev/null
+++ b/applications/directql/template_inst.hh
@@ -0,0 +1,149 @@
+/*
+* This file is part of rasdaman community.
+*
+* Rasdaman community is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* Rasdaman community is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
+*
+* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
+rasdaman GmbH.
+*
+* For more information please see <http://www.rasdaman.org>
+* or contact Peter Baumann via <baumann@rasdaman.com>.
+*/
+
+/* *
+* COMENTS
+*
+* No comments
+*/
+
+//for rb_tree, select1st
+#include <function.h>
+#include <tree.h>
+#include <vector>
+#include <utility>
+#include <memory>
+
+#if(__GNUC__==2 &&__GNUC_MINOR__==95)
+using std::rb_tree;
+using std::select1st;
+#else
+using __gnu_cxx::rb_tree;
+using __gnu_cxx::select1st;
+#endif
+
+using std::vector;
+using std::pair;
+
+// commented by Constantin Jucovschi (gcc 3.4+ no longer supports __default_alloc_template)
+//using std::__default_alloc_template;
+using std::fill_n;
+
+#include "qlparser/symtab.hh"
+
+#include "raslib/attribute.hh"
+#include "raslib/itertype.hh"
+#include "raslib/dlist.hh"
+
+#include "tile.hh"
+
+#include "indexmgr/keyobject.hh"
+
+#include "rasodmg/ref.hh"
+
+#include "reladminif/dbref.hh"
+#include "reladminif/dbobjectiditerator.hh"
+
+#include "relblobif/blobtile.hh"
+#include "relblobif/dbtile.hh"
+#include "relblobif/inlinetile.hh"
+
+#include "relcatalogif/typeiterator.hh"
+#include "relcatalogif/settype.hh"
+#include "relcatalogif/structtype.hh"
+#include "relcatalogif/mddtype.hh"
+#include "relcatalogif/inlineminterval.hh"
+#include "relcatalogif/dbminterval.hh"
+
+#include "relindexif/dbtcindex.hh"
+#include "relindexif/hierindex.hh"
+#include "relindexif/dbrcindexds.hh"
+
+#include "relmddif/dbmddobj.hh"
+#include "relmddif/dbmddset.hh"
+
+#include "relstorageif/dbudfds.hh"
+#include "relstorageif/dbudfpackageds.hh"
+#include "relstorageif/dbstoragelayout.hh"
+
+template class SymbolTable<int>;
+
+//template class r_IterType<r_Attribute>;
+
+template class r_Ref<r_Scalar>;
+template class r_Ref<r_OId>;
+
+template class DBRef<DBHierIndex>;
+template class DBRef<DBRCIndexDS>;
+template class DBRef<DBTCIndex>;
+template class DBRef<BLOBTile>;
+template class DBRef<DBTile>;
+template class DBRef<InlineTile>;
+template class DBRef<DBMDDSet>;
+template class DBRef<DBMinterval>;
+template class DBRef<DBStorageLayout>;
+template class DBRef<DBUDFDS>;
+template class DBRef<DBUDFPackageDS>;
+//template class DBRef<DBMDDObj>;
+// template bool operator< (const DBRef<DBMDDObj>&, const DBRef<DBMDDObj>&);
+
+//template TypeIterator<StructType>;
+//template TypeIterator<SetType>;
+template class TypeIterator<MDDType>;
+template class DBRef<DBMDDObj>;
+template class DBRef<DBObject>;
+
+template class DBObjectIdIterator<DBMDDObj>;
+template class DBObjectIterator<DBMDDObj>;
+template class DBObjectIterator<DBMDDSet>;
+template class DBObjectIterator<StructType>;
+template class DBObjectIterator<SetType>;
+template class DBRef<StructType>;
+template class DBRef<SetType>;
+template class DBRef<MDDType>;
+
+template std::ostream& operator<< (const vector<KeyObject>&, std::ostream&);
+template std::ostream& operator<< (std::ostream &, const vector<KeyObject>&);
+//template std::ostream& operator << (std::ostream& os, const std::vector<double>& list);
+//template std::ostream& operator << (std::ostream& os, const std::vector<r_Minterval>& list);
+
+template class rb_tree<OId, pair<OId const, DBMDDObj *>, select1st<pair<OId const, DBMDDObj *> >, less<OId> >;
+template class rb_tree<OId, pair<OId const, DBMinterval *>, select1st<pair<OId const, DBMinterval *> >, less<OId> >;
+template class rb_tree<OId, pair<OId const, DBRef<DBMDDObj> >, select1st<pair<OId const, DBRef<DBMDDObj> > >, less<OId> >;
+template class rb_tree<OId, pair<OId const, DBMDDSet *>, select1st<pair<OId const, DBMDDSet *> >, less<OId> >;
+template class rb_tree<OId, pair<OId const, MDDType *>, select1st<pair<OId const, MDDType *> >, less<OId> >;
+template class rb_tree<OId, pair<OId const, SetType *>, select1st<pair<OId const, SetType *> >, less<OId> >;
+template class rb_tree<OId, pair<OId const, StructType *>, select1st<pair<OId const, StructType *> >, less<OId> >;
+template class rb_tree<long, pair<long const, BLOBTile *>, select1st<pair<long const, BLOBTile *> >, less<long> >;
+template class rb_tree<long, pair<long const, InlineTile *>, select1st<pair<long const, InlineTile *> >, less<long> >;
+template class vector<BaseType const * >;
+template class vector<OId >;
+template class vector<Tile * >;
+template class vector<Type * >;
+template class vector<char * >;
+template class vector<char >;
+template class vector<r_Data_Format >;
+template class vector<unsigned int >;
+
+template class Tile ** fill_n<Tile **, unsigned int, Tile *>(Tile **, unsigned int, Tile * const &);
+