source: gsdl/branches/gsdl-2.74/src/recpt/librarymain.cpp@ 14270

Last change on this file since 14270 was 14270, checked in by oranfry, 17 years ago

merged selected changes to the gsdl trunk since r14217 into the 2.74 branch

  • Property svn:keywords set to Author Date Id Revision
File size: 8.4 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 "recptconfig.h"
30#include "fileutil.h"
31#include "nullproto.h"
32// z39.50 stuff - johnmcp
33#if defined(USE_Z3950)
34#include "z3950proto.h"
35#endif
36#include "collectserver.h"
37#include "filter.h"
38#include "browsefilter.h"
39#include "infodbclass.h"
40#include "collectset.h"
41#include <assert.h>
42
43#include "action.h"
44#include "statusaction.h"
45#include "pageaction.h"
46#include "pingaction.h"
47#include "queryaction.h"
48#include "documentaction.h"
49#include "authenaction.h"
50#include "usersaction.h"
51#include "extlinkaction.h"
52
53#ifdef GSDL_USE_EXPORT_ACTION
54#include "exportaction.h"
55#endif
56
57#ifdef GSDL_USE_CL_DISPLAY_ACTION
58#include "cldisplayaction.h"
59#endif
60
61#ifdef GSDL_USE_COURSES_ACTION
62#include "coursesaction.h"
63#endif
64
65#ifdef GSDL_USE_COMPOSITION_ACTION
66#include "compositionaction.h"
67#endif
68
69#ifdef GSDL_USE_INDEX_BROWSE_ACTION
70#include "indexbrowseaction.h"
71#endif
72
73#ifdef GSDL_USE_DIR_BROWSE_ACTION
74#include "dirbrowseaction.h"
75#endif
76
77#ifdef GSDL_USE_GENERATOR_ACTION
78#include "generatoraction.h"
79#endif
80
81#ifdef GSDL_USE_GTI_ACTION
82#include "gtiaction.h"
83#endif
84
85#include "tipaction.h"
86#include "collectoraction.h"
87#include "depositoraction.h"
88#include "browseaction.h"
89#include "phindaction.h"
90
91#include "browserclass.h"
92#include "vlistbrowserclass.h"
93#include "hlistbrowserclass.h"
94#include "datelistbrowserclass.h"
95#include "invbrowserclass.h"
96#include "pagedbrowserclass.h"
97#include "htmlbrowserclass.h"
98#include "phindbrowserclass.h"
99
100#ifdef GSDL_USE_CLASSIFIER_BROWSER
101//classifier browsers
102
103#include "treeclassifierbrowserclass.h"
104#ifdef GSDL_USE_TREE_EX_CLASSIFIER_BROWSER
105#include "treeexclassifierbrowserclass.h"
106#endif
107
108#endif //GSDL_USE_CLASSIFIER_BROWSER
109
110int main () {
111 receptionist recpt;
112 nullproto nproto;
113 collectset *cservers;
114#if defined(USE_Z3950)
115 z3950proto zproto;
116#endif
117 text_t gsdlhome;
118
119 cservers = new collectset(gsdlhome);
120
121 // set up the null protocol
122 nproto.set_collectset(cservers);
123
124 // configure the receptionist server list
125 cservers->setReceptionistServers(recpt, gsdlhome);
126
127 // add the protocol to the receptionist
128 recpt.add_protocol (&nproto);
129
130 // z39.50 stuff - johnmcp
131#if defined(USE_Z3950)
132 // add the z39.50 server information. Read in the file
133 // etc/recpt/z3950.cfg for list of servers and their databases.
134 text_t z3950cfg = filename_cat (gsdlhome, "etc");
135 z3950cfg = filename_cat (z3950cfg, "packages");
136 z3950cfg = filename_cat (z3950cfg, "z3950.cfg");
137#ifdef USE_FASTCGI
138 // currently can't use z39.50 if fastcgi used
139#warning "Disabling z39.50 support as fastcgi is in use"
140 if (0) {
141#else
142 if (file_exists(z3950cfg)) {
143#endif
144 text_t z3950err = filename_cat (gsdlhome, "etc", "z3950log.txt");
145 zproto.read_config_file(z3950cfg,z3950err);
146 // only add this protocol if we have any servers configured.
147 if (zproto.getServerCount()>0)
148 recpt.add_protocol (&zproto);
149 }
150#endif
151
152#ifdef GSDL_USE_TIP_ACTION
153 // the list of actions. Note: these actions will become invalid
154 // at the end of this function. We will clean them.
155 recpt.add_action (new tipaction());
156#endif
157
158#ifdef GSDL_USE_STATUS_ACTION
159 statusaction *astatusaction = new statusaction();
160 astatusaction->set_receptionist (&recpt);
161 recpt.add_action (astatusaction);
162#endif
163
164 pageaction *apageaction = new pageaction();
165 apageaction->set_receptionist (&recpt);
166 recpt.add_action (apageaction);
167
168#ifdef GSDL_USE_PING_ACTION
169 recpt.add_action (new pingaction());
170#endif
171
172 queryaction *aqueryaction = new queryaction();
173 aqueryaction->set_receptionist (&recpt);
174 recpt.add_action (aqueryaction);
175
176 documentaction *adocumentaction = new documentaction();
177 adocumentaction->set_receptionist (&recpt);
178 recpt.add_action (adocumentaction);
179
180 text_t userdbfile = filename_cat(gsdlhome, "etc", "users.db");
181 userdbclass *udb = new userdbclass(userdbfile);
182
183 text_t keydbfile = filename_cat(gsdlhome, "etc", "key.db");
184 keydbclass *kdb = new keydbclass(keydbfile);
185
186#ifdef GSDL_USE_USERS_ACTION
187 usersaction *ausersaction = new usersaction();
188 ausersaction->set_userdb(udb);
189 recpt.add_action (ausersaction);
190#endif
191
192#ifdef GSDL_USE_EXTLINK_ACTION
193 extlinkaction *aextlinkaction = new extlinkaction();
194 aextlinkaction->set_receptionist(&recpt);
195 recpt.add_action (aextlinkaction);
196#endif
197
198#ifdef GSDL_USE_AUTHEN_ACTION
199 authenaction *aauthenaction = new authenaction();
200 aauthenaction->set_userdb(udb);
201 aauthenaction->set_keydb(kdb);
202 aauthenaction->set_receptionist(&recpt);
203 recpt.add_action (aauthenaction);
204#endif
205
206#ifdef GSDL_USE_COLLECTOR_ACTION
207 collectoraction *acollectoraction = new collectoraction();
208 acollectoraction->set_receptionist (&recpt);
209 recpt.add_action(acollectoraction);
210#endif
211
212#ifdef GSDL_USE_DEPOSITOR_ACTION
213 depositoraction *adepositoraction = new depositoraction();
214 adepositoraction->set_receptionist (&recpt);
215 recpt.add_action(adepositoraction);
216#endif
217
218#ifdef GSDL_USE_BROWSE_ACTION
219 browseaction *abrowseaction = new browseaction();
220 abrowseaction->set_receptionist (&recpt);
221 recpt.add_action(abrowseaction);
222#endif
223
224#ifdef GSDL_USE_PHIND_ACTION
225 recpt.add_action(new phindaction());
226#endif
227
228#ifdef GSDL_USE_GTI_ACTION
229 gtiaction *agtiaction = new gtiaction();
230 agtiaction->set_receptionist(&recpt);
231 recpt.add_action(agtiaction);
232#endif
233
234 // list of browsers
235 vlistbrowserclass avlistbrowserclass;
236 avlistbrowserclass.set_receptionist(&recpt);
237 recpt.add_browser (&avlistbrowserclass);
238 recpt.setdefaultbrowser ("VList");
239
240 hlistbrowserclass ahlistbrowserclass;
241 ahlistbrowserclass.set_receptionist(&recpt);
242 recpt.add_browser (&ahlistbrowserclass);
243
244#ifdef GSDL_USE_DATELIST_BROWSER
245 datelistbrowserclass adatelistbrowserclass;
246 recpt.add_browser (&adatelistbrowserclass);
247#endif
248
249 invbrowserclass ainvbrowserclass;
250 recpt.add_browser (&ainvbrowserclass);
251
252#ifdef GSDL_USE_PAGED_BROWSER
253 pagedbrowserclass apagedbrowserclass;
254 recpt.add_browser (&apagedbrowserclass);
255#endif
256
257#ifdef GSDL_USE_HTML_BROWSER
258 htmlbrowserclass ahtmlbrowserclass;
259 recpt.add_browser (&ahtmlbrowserclass);
260#endif
261
262#ifdef GSDL_USE_PHIND_BROWSER
263 phindbrowserclass aphindbrowserclass;
264 recpt.add_browser (&aphindbrowserclass);
265#endif
266
267#ifdef GSDL_USE_CLASSIFIER_BROWSER
268 //list of classifier browsers
269 CTreeClassifierBrowserClass *pTreeClassifierBrowser = new CTreeClassifierBrowserClass();
270 if (pTreeClassifierBrowser != NULL) {
271 recpt.GetClassifierBrowsers().AddBrowser(pTreeClassifierBrowser);
272 recpt.GetClassifierBrowsers().SetDefaultBrowser(pTreeClassifierBrowser->GetBrowserName());
273 }
274#ifdef GSDL_USE_TREE_EX_CLASSIFIER_BROWSER
275 CTreeExClassifierBrowserClass *pTreeExClassifierBrowser = new CTreeExClassifierBrowserClass();
276 if (pTreeExClassifierBrowser != NULL) {
277 recpt.GetClassifierBrowsers().AddBrowser(pTreeExClassifierBrowser);
278 }
279#endif //GSDL_USE_TREE_EX_CLASSIFIER_BROWSER
280#endif //GSDL_USE_CLASSIFIER_BROWSER
281
282 cgiwrapper (recpt, "");
283 delete cservers;
284 delete udb;
285 delete kdb;
286
287 // clean up the actions
288 actionmapclass::iterator thisAction = recpt.get_actionmap_ptr()->begin();
289 actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->begin();
290 while (thisAction != endAction) {
291 delete thisAction->second.a; thisAction->second.a = NULL;
292 ++thisAction;
293 }
294 thisAction = recpt.get_actionmap_ptr()->begin();
295 recpt.get_actionmap_ptr()->erase(thisAction, endAction);
296
297 return 0;
298}
299
300
301
302
303
304
305
Note: See TracBrowser for help on using the repository browser.