[166] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * librarymain.cpp --
|
---|
[22744] | 4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
[166] | 5 | *
|
---|
[533] | 6 | * A component of the Greenstone digital library software
|
---|
| 7 | * from the New Zealand Digital Library Project at the
|
---|
| 8 | * University of Waikato, New Zealand.
|
---|
[166] | 9 | *
|
---|
[533] | 10 | * This program is free software; you can redistribute it and/or modify
|
---|
| 11 | * it under the terms of the GNU General Public License as published by
|
---|
| 12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 13 | * (at your option) any later version.
|
---|
| 14 | *
|
---|
| 15 | * This program is distributed in the hope that it will be useful,
|
---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | * GNU General Public License for more details.
|
---|
| 19 | *
|
---|
| 20 | * You should have received a copy of the GNU General Public License
|
---|
| 21 | * along with this program; if not, write to the Free Software
|
---|
| 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 23 | *
|
---|
[166] | 24 | *********************************************************************/
|
---|
| 25 |
|
---|
[7432] | 26 | #include "gsdl_modules_cfg.h"
|
---|
[166] | 27 | #include "receptionist.h"
|
---|
| 28 | #include "cgiwrapper.h"
|
---|
[1649] | 29 | #include "fileutil.h"
|
---|
[166] | 30 | #include "nullproto.h"
|
---|
[1347] | 31 | // z39.50 stuff - johnmcp
|
---|
[1937] | 32 | #if defined(USE_Z3950)
|
---|
[1347] | 33 | #include "z3950proto.h"
|
---|
[1937] | 34 | #endif
|
---|
[1860] | 35 | #include "collectset.h"
|
---|
[166] | 36 |
|
---|
[390] | 37 | #include "action.h"
|
---|
[25560] | 38 | #include "ispersistentaction.h"
|
---|
[649] | 39 | #include "browserclass.h"
|
---|
| 40 |
|
---|
[7432] | 41 |
|
---|
[15742] | 42 | int main ()
|
---|
| 43 | {
|
---|
[166] | 44 | receptionist recpt;
|
---|
[1860] | 45 | nullproto nproto;
|
---|
| 46 | collectset *cservers;
|
---|
[1937] | 47 | #if defined(USE_Z3950)
|
---|
[1860] | 48 | z3950proto zproto;
|
---|
[1429] | 49 | #endif
|
---|
[1860] | 50 | text_t gsdlhome;
|
---|
[16310] | 51 | text_t collecthome;
|
---|
[1327] | 52 |
|
---|
[16310] | 53 | cservers = new collectset(gsdlhome,collecthome);
|
---|
[226] | 54 |
|
---|
[15401] | 55 | // configure the receptionist server list
|
---|
| 56 | text_tarray collection_list;
|
---|
| 57 | cservers->getCollectionList(collection_list);
|
---|
| 58 | text_tarray::iterator collection_iterator = collection_list.begin();
|
---|
| 59 | while (collection_iterator != collection_list.end())
|
---|
| 60 | {
|
---|
| 61 | text_tarray colinfo;
|
---|
| 62 | colinfo.push_back(*collection_iterator);
|
---|
| 63 | colinfo.push_back(gsdlhome);
|
---|
[16310] | 64 | colinfo.push_back(collecthome);
|
---|
[15401] | 65 | colinfo.push_back(gsdlhome);
|
---|
| 66 | recpt.configure("collectinfo", colinfo);
|
---|
| 67 | collection_iterator++;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
[1860] | 70 | // set up the null protocol
|
---|
| 71 | nproto.set_collectset(cservers);
|
---|
| 72 |
|
---|
[166] | 73 | // add the protocol to the receptionist
|
---|
| 74 | recpt.add_protocol (&nproto);
|
---|
[1347] | 75 |
|
---|
| 76 | // z39.50 stuff - johnmcp
|
---|
[1937] | 77 | #if defined(USE_Z3950)
|
---|
[1347] | 78 | // add the z39.50 server information. Read in the file
|
---|
[19611] | 79 | // etc/packages/z3950/z3950.cfg for list of servers and their databases.
|
---|
| 80 | text_t z3950cfg = filename_cat (gsdlhome, "etc", "packages", "z3950", "z3950.cfg");
|
---|
[1366] | 81 | #ifdef USE_FASTCGI
|
---|
[1937] | 82 | // currently can't use z39.50 if fastcgi used
|
---|
| 83 | #warning "Disabling z39.50 support as fastcgi is in use"
|
---|
[1366] | 84 | if (0) {
|
---|
| 85 | #else
|
---|
[1347] | 86 | if (file_exists(z3950cfg)) {
|
---|
[1366] | 87 | #endif
|
---|
[19611] | 88 | text_t z3950err = filename_cat (gsdlhome, "etc", "packages", "z3950", "z3950log.txt");
|
---|
[1355] | 89 | zproto.read_config_file(z3950cfg,z3950err);
|
---|
[1347] | 90 | // only add this protocol if we have any servers configured.
|
---|
| 91 | if (zproto.getServerCount()>0)
|
---|
| 92 | recpt.add_protocol (&zproto);
|
---|
| 93 | }
|
---|
[1429] | 94 | #endif
|
---|
[1347] | 95 |
|
---|
[22067] | 96 | userdbclass *udb = new userdbclass(gsdlhome);
|
---|
| 97 | keydbclass *kdb = new keydbclass(gsdlhome);
|
---|
[14269] | 98 |
|
---|
[25560] | 99 | add_all_actions(recpt,udb,kdb,isNotPersistent); // apache (without mod_gsdl) is not a persistent server
|
---|
[22142] | 100 | // Note: these actions will become invalid at the end of this function.
|
---|
| 101 | // => We will retrieve them from the receptionist and delete them
|
---|
[390] | 102 |
|
---|
[22142] | 103 | add_all_browsers(recpt);
|
---|
| 104 | // Browsers are not currently deleted (at all?) in code. Seems likely they
|
---|
| 105 | // should be treated in a similar fashion to actions
|
---|
[390] | 106 |
|
---|
[268] | 107 | cgiwrapper (recpt, "");
|
---|
[1860] | 108 | delete cservers;
|
---|
[14269] | 109 | delete udb;
|
---|
| 110 | delete kdb;
|
---|
[7432] | 111 |
|
---|
| 112 | // clean up the actions
|
---|
| 113 | actionmapclass::iterator thisAction = recpt.get_actionmap_ptr()->begin();
|
---|
[22142] | 114 | actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->end();
|
---|
[7432] | 115 | while (thisAction != endAction) {
|
---|
[22142] | 116 | delete thisAction->second.a;
|
---|
| 117 | thisAction->second.a = NULL;
|
---|
[7432] | 118 | ++thisAction;
|
---|
| 119 | }
|
---|
| 120 | thisAction = recpt.get_actionmap_ptr()->begin();
|
---|
| 121 | recpt.get_actionmap_ptr()->erase(thisAction, endAction);
|
---|
[11998] | 122 |
|
---|
[22142] | 123 |
|
---|
| 124 | /*
|
---|
| 125 | // clean up the browsers
|
---|
| 126 | browsermapclass::iterator thisBrowser = recpt.get_browsermap_ptr()->begin();
|
---|
| 127 | browsermapclass::iterator endBrowser = recpt.get_browsermap_ptr()->end();
|
---|
| 128 | while (thisBrowser != endBrowser) {
|
---|
| 129 | delete thisBrowser->second.a;
|
---|
| 130 | thisBrowser->second.a = NULL;
|
---|
| 131 | ++thisBrowser;
|
---|
| 132 | }
|
---|
| 133 | thisBrowser = recpt.get_browsermap_ptr()->begin();
|
---|
| 134 | recpt.get_browsermap_ptr()->erase(thisBrowser, endBrowser);
|
---|
| 135 | */
|
---|
| 136 |
|
---|
[166] | 137 | return 0;
|
---|
| 138 | }
|
---|