/*
openisis - an open implementation of the CDS/ISIS database
Version 0.8.x (patchlevel see file Version)
Copyright (C) 2001-2003 by Erik Grziwotz, erik@openisis.org
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
see README for more information
EOH */
/*
$Id: ois.c,v 1.9 2003/06/30 09:50:15 kripke Exp $
OpenIsis server
*/
#include <string.h> /* mem* */
#include "lsv.h"
#include "ldsp.h"
/* the db srv application */
static int dbsrv (Con *con, int task) {
int rt;
switch ( task ) {
case LSV_APPGOT:
con->grp = 0; /* single threaded */
default:
return 0;
case LSV_APPRUN:
break;
}
sMsg( LOG_INFO, "dbs %d: %d fields from %s",
svCur()->id, con->req->len, con->nam);
rt = ldspProcess (con->req, &(con->ses->res), 0, 0);
sMsg( LOG_INFO, "dbs %d: %d fields to %s (%d)",
svCur()->id, con->ses->res->len, con->nam, rt);
return rt;
}
int main ( int argc, const char **argv )
{
const char *arg0 = *argv;
/* should we ask federico for his fhc 1499 ? */
/* or use unassigned 5433 = postgresql++ ? */
const char *port = "2042"; /* isis :) */
int ndb = 0;
Srv dbs;
Rec *rec = 0;
memset( &dbs, 0, sizeof(dbs) );
dbs.prt = svPlain;
dbs.app = dbsrv;
cOpen(0);
cLog( LOG_DEBUG, 0 );
nInit( 0, 0, 0 );
while ( --argc ) {
const char *arg = *++argv;
if ( '0' <= *arg && *arg <= '9' )
port = arg;
else {
rec = rSet (rec, 0, OPENISIS_RQS_TYPE, "1", OPENISIS_COM_DBN, arg, 0 );
openIsisNSend (stub0, rec, 0, 0, 0);
CLRREC( rec );
ndb++;
/* else sMsg( LOG_ERROR, "could not open db '%s'", arg ); */
}
}
if ( ! ndb ) {
sMsg( LOG_ERROR, "usage: %s db [db ...] [port]", arg0 );
return 1;
}
return svRun( &dbs, port );
}