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

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

(Untangling colservr/recpt) Split recpt/recptconfig into two: lib/gsdlsitecfg (reads gsdlsite.cfg file; used by both colservr and recpt) and recpt/maincfg (reads main.cfg file; used by recpt only).

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