/********************************************************************** * * librarymain.cpp -- * Copyright (C) 1999 The New Zaland Digital Library Project * * A component of the Greenstone digital library software * from the New Zealand Digital Library Project at the * University of Waikato, New Zealand. * * This program 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 2 of the License, or * (at your option) any later version. * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *********************************************************************/ #include "gsdl_modules_cfg.h" #include "receptionist.h" #include "cgiwrapper.h" #include "fileutil.h" #include "nullproto.h" // z39.50 stuff - johnmcp #if defined(USE_Z3950) #include "z3950proto.h" #endif #include "collectset.h" #include "action.h" #include "authenaction.h" #include "browseaction.h" #include "collectoraction.h" #include "depositoraction.h" #include "documentaction.h" #include "dynamicclassifieraction.h" #include "extlinkaction.h" #include "pageaction.h" #include "phindaction.h" #include "pingaction.h" #include "queryaction.h" #include "tipaction.h" #include "statusaction.h" #include "usersaction.h" #include "browserclass.h" #include "vlistbrowserclass.h" #include "hlistbrowserclass.h" #include "datelistbrowserclass.h" #include "invbrowserclass.h" #include "pagedbrowserclass.h" #include "htmlbrowserclass.h" #include "phindbrowserclass.h" int main () { receptionist recpt; nullproto nproto; collectset *cservers; #if defined(USE_Z3950) z3950proto zproto; #endif text_t gsdlhome; text_t collecthome; cservers = new collectset(gsdlhome,collecthome); // configure the receptionist server list text_tarray collection_list; cservers->getCollectionList(collection_list); text_tarray::iterator collection_iterator = collection_list.begin(); while (collection_iterator != collection_list.end()) { text_tarray colinfo; colinfo.push_back(*collection_iterator); colinfo.push_back(gsdlhome); colinfo.push_back(collecthome); colinfo.push_back(gsdlhome); recpt.configure("collectinfo", colinfo); collection_iterator++; } // set up the null protocol nproto.set_collectset(cservers); // add the protocol to the receptionist recpt.add_protocol (&nproto); // z39.50 stuff - johnmcp #if defined(USE_Z3950) // add the z39.50 server information. Read in the file // etc/recpt/z3950.cfg for list of servers and their databases. text_t z3950cfg = filename_cat (gsdlhome, "etc"); z3950cfg = filename_cat (z3950cfg, "packages"); z3950cfg = filename_cat (z3950cfg, "z3950.cfg"); #ifdef USE_FASTCGI // currently can't use z39.50 if fastcgi used #warning "Disabling z39.50 support as fastcgi is in use" if (0) { #else if (file_exists(z3950cfg)) { #endif text_t z3950err = filename_cat (gsdlhome, "etc", "z3950log.txt"); zproto.read_config_file(z3950cfg,z3950err); // only add this protocol if we have any servers configured. if (zproto.getServerCount()>0) recpt.add_protocol (&zproto); } #endif // the list of actions. Note: these actions will become invalid // at the end of this function. We will clean them. #ifdef GSDL_USE_TIP_ACTION recpt.add_action (new tipaction()); #endif #ifdef GSDL_USE_STATUS_ACTION statusaction *astatusaction = new statusaction(); astatusaction->set_receptionist (&recpt); recpt.add_action (astatusaction); #endif pageaction *apageaction = new pageaction(); apageaction->set_receptionist (&recpt); recpt.add_action (apageaction); #ifdef GSDL_USE_PING_ACTION recpt.add_action (new pingaction()); #endif queryaction *aqueryaction = new queryaction(); aqueryaction->set_receptionist (&recpt); recpt.add_action (aqueryaction); documentaction *adocumentaction = new documentaction(); adocumentaction->set_receptionist (&recpt); recpt.add_action (adocumentaction); text_t userdbfile = filename_cat(gsdlhome, "etc", "users.db"); userdbclass *udb = new userdbclass(userdbfile); text_t keydbfile = filename_cat(gsdlhome, "etc", "key.db"); keydbclass *kdb = new keydbclass(keydbfile); #ifdef GSDL_USE_USERS_ACTION usersaction *ausersaction = new usersaction(); ausersaction->set_userdb(udb); recpt.add_action (ausersaction); #endif #ifdef GSDL_USE_EXTLINK_ACTION extlinkaction *aextlinkaction = new extlinkaction(); aextlinkaction->set_receptionist(&recpt); recpt.add_action (aextlinkaction); #endif #ifdef GSDL_USE_AUTHEN_ACTION authenaction *aauthenaction = new authenaction(); aauthenaction->set_userdb(udb); aauthenaction->set_keydb(kdb); aauthenaction->set_receptionist(&recpt); recpt.add_action (aauthenaction); #endif #ifdef GSDL_USE_COLLECTOR_ACTION collectoraction *acollectoraction = new collectoraction(); acollectoraction->set_receptionist (&recpt); recpt.add_action(acollectoraction); #endif #ifdef GSDL_USE_DEPOSITOR_ACTION depositoraction *adepositoraction = new depositoraction(); adepositoraction->set_receptionist (&recpt); recpt.add_action(adepositoraction); #endif #ifdef GSDL_USE_BROWSE_ACTION browseaction *abrowseaction = new browseaction(); abrowseaction->set_receptionist (&recpt); recpt.add_action(abrowseaction); #endif #ifdef GSDL_USE_PHIND_ACTION recpt.add_action(new phindaction()); #endif #ifdef GSDL_USE_GTI_ACTION gtiaction *agtiaction = new gtiaction(); agtiaction->set_receptionist(&recpt); recpt.add_action(agtiaction); #endif dynamicclassifieraction *adynamicclassifieraction = new dynamicclassifieraction(); adynamicclassifieraction->set_receptionist(&recpt); recpt.add_action(adynamicclassifieraction); // list of browsers vlistbrowserclass avlistbrowserclass; avlistbrowserclass.set_receptionist(&recpt); recpt.add_browser (&avlistbrowserclass); recpt.setdefaultbrowser ("VList"); hlistbrowserclass ahlistbrowserclass; ahlistbrowserclass.set_receptionist(&recpt); recpt.add_browser (&ahlistbrowserclass); #ifdef GSDL_USE_DATELIST_BROWSER datelistbrowserclass adatelistbrowserclass; recpt.add_browser (&adatelistbrowserclass); #endif invbrowserclass ainvbrowserclass; recpt.add_browser (&ainvbrowserclass); #ifdef GSDL_USE_PAGED_BROWSER pagedbrowserclass apagedbrowserclass; recpt.add_browser (&apagedbrowserclass); #endif #ifdef GSDL_USE_HTML_BROWSER htmlbrowserclass ahtmlbrowserclass; recpt.add_browser (&ahtmlbrowserclass); #endif #ifdef GSDL_USE_PHIND_BROWSER phindbrowserclass aphindbrowserclass; recpt.add_browser (&aphindbrowserclass); #endif cgiwrapper (recpt, ""); delete cservers; delete udb; delete kdb; // clean up the actions actionmapclass::iterator thisAction = recpt.get_actionmap_ptr()->begin(); actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->begin(); while (thisAction != endAction) { delete thisAction->second.a; thisAction->second.a = NULL; ++thisAction; } thisAction = recpt.get_actionmap_ptr()->begin(); recpt.get_actionmap_ptr()->erase(thisAction, endAction); return 0; }