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

Last change on this file since 9620 was 8073, checked in by davidb, 20 years ago

removed a handful of #include statements involving mg and mgpp that weren't
needed.

  • Property svn:keywords set to Author Date Id Revision
File size: 7.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 "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#include "tipaction.h"
82#include "collectoraction.h"
83#include "browseaction.h"
84#include "phindaction.h"
85#if defined(GSDL_USE_LANG_ACTION)
86#include "langaction.h"
87#endif
88
89#include "browserclass.h"
90#include "vlistbrowserclass.h"
91#include "hlistbrowserclass.h"
92#include "datelistbrowserclass.h"
93#include "invbrowserclass.h"
94#include "pagedbrowserclass.h"
95#include "htmlbrowserclass.h"
96#include "phindbrowserclass.h"
97
98#ifdef GSDL_USE_CLASSIFIER_BROWSER
99//classifier browsers
100
101#include "treeclassifierbrowserclass.h"
102#ifdef GSDL_USE_TREE_EX_CLASSIFIER_BROWSER
103#include "treeexclassifierbrowserclass.h"
104#endif
105
106#endif //GSDL_USE_CLASSIFIER_BROWSER
107
108int main () {
109 receptionist recpt;
110 nullproto nproto;
111 collectset *cservers;
112#if defined(USE_Z3950)
113 z3950proto zproto;
114#endif
115 text_t gsdlhome;
116
117 cservers = new collectset(gsdlhome);
118
119 // set up the null protocol
120 nproto.set_collectset(cservers);
121
122 // configure the receptionist server list
123 cservers->setReceptionistServers(recpt, gsdlhome);
124
125 // add the protocol to the receptionist
126 recpt.add_protocol (&nproto);
127
128 // z39.50 stuff - johnmcp
129#if defined(USE_Z3950)
130 // add the z39.50 server information. Read in the file
131 // etc/recpt/z3950.cfg for list of servers and their databases.
132 text_t z3950cfg = filename_cat (gsdlhome, "etc");
133 // z3950cfg = filename_cat (z3950cfg, "recpt");
134 z3950cfg = filename_cat (z3950cfg, "packages");
135 z3950cfg = filename_cat (z3950cfg, "z3950.cfg");
136#ifdef USE_FASTCGI
137 // currently can't use z39.50 if fastcgi used
138#warning "Disabling z39.50 support as fastcgi is in use"
139 if (0) {
140#else
141 if (file_exists(z3950cfg)) {
142#endif
143 text_t z3950err = filename_cat (gsdlhome, "etc", "z3950log.txt");
144 zproto.read_config_file(z3950cfg,z3950err);
145 // only add this protocol if we have any servers configured.
146 if (zproto.getServerCount()>0)
147 recpt.add_protocol (&zproto);
148 }
149#endif
150
151#ifdef GSDL_USE_TIP_ACTION
152 // the list of actions. Note: these actions will become invalid
153 // at the end of this function. We will clean them.
154 recpt.add_action (new tipaction());
155#endif
156
157#ifdef GSDL_USE_STATUS_ACTION
158 statusaction *astatusaction = new statusaction();
159 astatusaction->set_receptionist (&recpt);
160 recpt.add_action (astatusaction);
161#endif
162
163 pageaction *apageaction = new pageaction();
164 apageaction->set_receptionist (&recpt);
165 recpt.add_action (apageaction);
166
167#ifdef GSDL_USE_PING_ACTION
168 recpt.add_action (new pingaction());
169#endif
170
171 queryaction *aqueryaction = new queryaction();
172 aqueryaction->set_receptionist (&recpt);
173 recpt.add_action (aqueryaction);
174
175 documentaction *adocumentaction = new documentaction();
176 adocumentaction->set_receptionist (&recpt);
177 recpt.add_action (adocumentaction);
178
179#ifdef GSDL_USE_USERS_ACTION
180 recpt.add_action (new usersaction());
181#endif
182
183#ifdef GSDL_USE_EXTLINK_ACTION
184 recpt.add_action (new extlinkaction());
185#endif
186
187#ifdef GSDL_USE_AUTHEN_ACTION
188 authenaction *aauthenaction = new authenaction();
189 aauthenaction->set_receptionist(&recpt);
190 recpt.add_action (aauthenaction);
191#endif
192
193#ifdef GSDL_USE_COLLECTOR_ACTION
194 collectoraction *acollectoraction = new collectoraction();
195 acollectoraction->set_receptionist (&recpt);
196 recpt.add_action(acollectoraction);
197#endif
198
199#ifdef GSDL_USE_BROWSE_ACTION
200 browseaction *abrowseaction = new browseaction();
201 abrowseaction->set_receptionist (&recpt);
202 recpt.add_action(abrowseaction);
203#endif
204
205#ifdef GSDL_USE_PHIND_ACTION
206 recpt.add_action(new phindaction());
207#endif
208
209#ifdef GSDL_USE_LANG_ACTION
210 langaction *alangaction = new langaction();
211 alangaction->set_receptionist(&recpt);
212 recpt.add_action(alangaction);
213#endif
214
215 // list of browsers
216 vlistbrowserclass avlistbrowserclass;
217 avlistbrowserclass.set_receptionist(&recpt);
218 recpt.add_browser (&avlistbrowserclass);
219 recpt.setdefaultbrowser ("VList");
220
221 hlistbrowserclass ahlistbrowserclass;
222 ahlistbrowserclass.set_receptionist(&recpt);
223 recpt.add_browser (&ahlistbrowserclass);
224
225#ifdef GSDL_USE_DATELIST_BROWSER
226 datelistbrowserclass adatelistbrowserclass;
227 recpt.add_browser (&adatelistbrowserclass);
228#endif
229
230 invbrowserclass ainvbrowserclass;
231 recpt.add_browser (&ainvbrowserclass);
232
233#ifdef GSDL_USE_PAGED_BROWSER
234 pagedbrowserclass apagedbrowserclass;
235 recpt.add_browser (&apagedbrowserclass);
236#endif
237
238#ifdef GSDL_USE_HTML_BROWSER
239 htmlbrowserclass ahtmlbrowserclass;
240 recpt.add_browser (&ahtmlbrowserclass);
241#endif
242
243#ifdef GSDL_USE_PHIND_BROWSER
244 phindbrowserclass aphindbrowserclass;
245 recpt.add_browser (&aphindbrowserclass);
246#endif
247
248#ifdef GSDL_USE_CLASSIFIER_BROWSER
249 //list of classifier browsers
250 CTreeClassifierBrowserClass *pTreeClassifierBrowser = new CTreeClassifierBrowserClass();
251 if (pTreeClassifierBrowser != NULL) {
252 recpt.GetClassifierBrowsers().AddBrowser(pTreeClassifierBrowser);
253 recpt.GetClassifierBrowsers().SetDefaultBrowser(pTreeClassifierBrowser->GetBrowserName());
254 }
255#ifdef GSDL_USE_TREE_EX_CLASSIFIER_BROWSER
256 CTreeExClassifierBrowserClass *pTreeExClassifierBrowser = new CTreeExClassifierBrowserClass();
257 if (pTreeExClassifierBrowser != NULL) {
258 recpt.GetClassifierBrowsers().AddBrowser(pTreeExClassifierBrowser);
259 }
260#endif //GSDL_USE_TREE_EX_CLASSIFIER_BROWSER
261#endif //GSDL_USE_CLASSIFIER_BROWSER
262
263 cgiwrapper (recpt, "");
264 delete cservers;
265
266 // clean up the actions
267 actionmapclass::iterator thisAction = recpt.get_actionmap_ptr()->begin();
268 actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->begin();
269 while (thisAction != endAction) {
270 delete thisAction->second.a; thisAction->second.a = NULL;
271 ++thisAction;
272 }
273 thisAction = recpt.get_actionmap_ptr()->begin();
274 recpt.get_actionmap_ptr()->erase(thisAction, endAction);
275 return 0;
276}
277
278
279
280
281
282
283
Note: See TracBrowser for help on using the repository browser.