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

Last change on this file since 22177 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
Line 
1/**********************************************************************
2 *
3 * librarymain.cpp --
4 * Copyright (C) 1999 The New Zaland Digital Library Project
5 *
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.
9 *
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 *
24 *********************************************************************/
25
26#include "gsdl_modules_cfg.h"
27#include "receptionist.h"
28#include "cgiwrapper.h"
29#include "fileutil.h"
30#include "nullproto.h"
31// z39.50 stuff - johnmcp
32#if defined(USE_Z3950)
33#include "z3950proto.h"
34#endif
35#include "collectset.h"
36
37#include "action.h"
38#include "browserclass.h"
39
40
41int main ()
42{
43 receptionist recpt;
44 nullproto nproto;
45 collectset *cservers;
46#if defined(USE_Z3950)
47 z3950proto zproto;
48#endif
49 text_t gsdlhome;
50 text_t collecthome;
51
52 cservers = new collectset(gsdlhome,collecthome);
53
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);
63 colinfo.push_back(collecthome);
64 colinfo.push_back(gsdlhome);
65 recpt.configure("collectinfo", colinfo);
66 collection_iterator++;
67 }
68
69 // set up the null protocol
70 nproto.set_collectset(cservers);
71
72 // add the protocol to the receptionist
73 recpt.add_protocol (&nproto);
74
75 // z39.50 stuff - johnmcp
76#if defined(USE_Z3950)
77 // add the z39.50 server information. Read in the file
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");
80#ifdef USE_FASTCGI
81 // currently can't use z39.50 if fastcgi used
82#warning "Disabling z39.50 support as fastcgi is in use"
83 if (0) {
84#else
85 if (file_exists(z3950cfg)) {
86#endif
87 text_t z3950err = filename_cat (gsdlhome, "etc", "packages", "z3950", "z3950log.txt");
88 zproto.read_config_file(z3950cfg,z3950err);
89 // only add this protocol if we have any servers configured.
90 if (zproto.getServerCount()>0)
91 recpt.add_protocol (&zproto);
92 }
93#endif
94
95 userdbclass *udb = new userdbclass(gsdlhome);
96 keydbclass *kdb = new keydbclass(gsdlhome);
97
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
101
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
105
106 cgiwrapper (recpt, "");
107 delete cservers;
108 delete udb;
109 delete kdb;
110
111 // clean up the actions
112 actionmapclass::iterator thisAction = recpt.get_actionmap_ptr()->begin();
113 actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->end();
114 while (thisAction != endAction) {
115 delete thisAction->second.a;
116 thisAction->second.a = NULL;
117 ++thisAction;
118 }
119 thisAction = recpt.get_actionmap_ptr()->begin();
120 recpt.get_actionmap_ptr()->erase(thisAction, endAction);
121
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
136 return 0;
137}
Note: See TracBrowser for help on using the repository browser.