source: main/trunk/greenstone2/runtime-src/src/recpt/librarymain.cpp@ 22665

Last change on this file since 22665 was 22142, checked in by davidb, 14 years ago

For the CGI 'e' variable to be inter-changable between mod_gsdl and library.cgi then they need to have exactly the same actions. The code has been refactored so they now use a shared function to do this, the ensure this is the case.

  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
RevLine 
[166]1/**********************************************************************
2 *
3 * librarymain.cpp --
[1937]4 * Copyright (C) 1999 The New Zaland 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"
[649]38#include "browserclass.h"
39
[7432]40
[15742]41int main ()
42{
[166]43 receptionist recpt;
[1860]44 nullproto nproto;
45 collectset *cservers;
[1937]46#if defined(USE_Z3950)
[1860]47 z3950proto zproto;
[1429]48#endif
[1860]49 text_t gsdlhome;
[16310]50 text_t collecthome;
[1327]51
[16310]52 cservers = new collectset(gsdlhome,collecthome);
[226]53
[15401]54 // configure the receptionist server list
55 text_tarray collection_list;
56 cservers->getCollectionList(collection_list);
57 text_tarray::iterator collection_iterator = collection_list.begin();
58 while (collection_iterator != collection_list.end())
59 {
60 text_tarray colinfo;
61 colinfo.push_back(*collection_iterator);
62 colinfo.push_back(gsdlhome);
[16310]63 colinfo.push_back(collecthome);
[15401]64 colinfo.push_back(gsdlhome);
65 recpt.configure("collectinfo", colinfo);
66 collection_iterator++;
67 }
68
[1860]69 // set up the null protocol
70 nproto.set_collectset(cservers);
71
[166]72 // add the protocol to the receptionist
73 recpt.add_protocol (&nproto);
[1347]74
75 // z39.50 stuff - johnmcp
[1937]76#if defined(USE_Z3950)
[1347]77 // add the z39.50 server information. Read in the file
[19611]78 // etc/packages/z3950/z3950.cfg for list of servers and their databases.
79 text_t z3950cfg = filename_cat (gsdlhome, "etc", "packages", "z3950", "z3950.cfg");
[1366]80#ifdef USE_FASTCGI
[1937]81 // currently can't use z39.50 if fastcgi used
82#warning "Disabling z39.50 support as fastcgi is in use"
[1366]83 if (0) {
84#else
[1347]85 if (file_exists(z3950cfg)) {
[1366]86#endif
[19611]87 text_t z3950err = filename_cat (gsdlhome, "etc", "packages", "z3950", "z3950log.txt");
[1355]88 zproto.read_config_file(z3950cfg,z3950err);
[1347]89 // only add this protocol if we have any servers configured.
90 if (zproto.getServerCount()>0)
91 recpt.add_protocol (&zproto);
92 }
[1429]93#endif
[1347]94
[22067]95 userdbclass *udb = new userdbclass(gsdlhome);
96 keydbclass *kdb = new keydbclass(gsdlhome);
[14269]97
[22142]98 add_all_actions(recpt,udb,kdb);
99 // Note: these actions will become invalid at the end of this function.
100 // => We will retrieve them from the receptionist and delete them
[390]101
[22142]102 add_all_browsers(recpt);
103 // Browsers are not currently deleted (at all?) in code. Seems likely they
104 // should be treated in a similar fashion to actions
[390]105
[268]106 cgiwrapper (recpt, "");
[1860]107 delete cservers;
[14269]108 delete udb;
109 delete kdb;
[7432]110
111 // clean up the actions
112 actionmapclass::iterator thisAction = recpt.get_actionmap_ptr()->begin();
[22142]113 actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->end();
[7432]114 while (thisAction != endAction) {
[22142]115 delete thisAction->second.a;
116 thisAction->second.a = NULL;
[7432]117 ++thisAction;
118 }
119 thisAction = recpt.get_actionmap_ptr()->begin();
120 recpt.get_actionmap_ptr()->erase(thisAction, endAction);
[11998]121
[22142]122
123 /*
124 // clean up the browsers
125 browsermapclass::iterator thisBrowser = recpt.get_browsermap_ptr()->begin();
126 browsermapclass::iterator endBrowser = recpt.get_browsermap_ptr()->end();
127 while (thisBrowser != endBrowser) {
128 delete thisBrowser->second.a;
129 thisBrowser->second.a = NULL;
130 ++thisBrowser;
131 }
132 thisBrowser = recpt.get_browsermap_ptr()->begin();
133 recpt.get_browsermap_ptr()->erase(thisBrowser, endBrowser);
134 */
135
[166]136 return 0;
137}
Note: See TracBrowser for help on using the repository browser.