source: gsdl/trunk/src/recpt/librarymain.cpp@ 15597

Last change on this file since 15597 was 15454, checked in by mdewsnip, 16 years ago

Removed a few unnecessary inclusions.

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