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 |
|
---|
110 | int 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 | #ifdef GSDL_USE_USERS_ACTION
|
---|
181 | recpt.add_action (new usersaction());
|
---|
182 | #endif
|
---|
183 |
|
---|
184 | #ifdef GSDL_USE_EXTLINK_ACTION
|
---|
185 | extlinkaction *aextlinkaction = new extlinkaction();
|
---|
186 | aextlinkaction->set_receptionist(&recpt);
|
---|
187 | recpt.add_action (aextlinkaction);
|
---|
188 | #endif
|
---|
189 |
|
---|
190 | #ifdef GSDL_USE_AUTHEN_ACTION
|
---|
191 | authenaction *aauthenaction = new authenaction();
|
---|
192 | aauthenaction->set_receptionist(&recpt);
|
---|
193 | recpt.add_action (aauthenaction);
|
---|
194 | #endif
|
---|
195 |
|
---|
196 | #ifdef GSDL_USE_COLLECTOR_ACTION
|
---|
197 | collectoraction *acollectoraction = new collectoraction();
|
---|
198 | acollectoraction->set_receptionist (&recpt);
|
---|
199 | recpt.add_action(acollectoraction);
|
---|
200 | #endif
|
---|
201 |
|
---|
202 | #ifdef GSDL_USE_DEPOSITOR_ACTION
|
---|
203 | depositoraction *adepositoraction = new depositoraction();
|
---|
204 | adepositoraction->set_receptionist (&recpt);
|
---|
205 | recpt.add_action(adepositoraction);
|
---|
206 | #endif
|
---|
207 |
|
---|
208 | #ifdef GSDL_USE_BROWSE_ACTION
|
---|
209 | browseaction *abrowseaction = new browseaction();
|
---|
210 | abrowseaction->set_receptionist (&recpt);
|
---|
211 | recpt.add_action(abrowseaction);
|
---|
212 | #endif
|
---|
213 |
|
---|
214 | #ifdef GSDL_USE_PHIND_ACTION
|
---|
215 | recpt.add_action(new phindaction());
|
---|
216 | #endif
|
---|
217 |
|
---|
218 | #ifdef GSDL_USE_GTI_ACTION
|
---|
219 | gtiaction *agtiaction = new gtiaction();
|
---|
220 | agtiaction->set_receptionist(&recpt);
|
---|
221 | recpt.add_action(agtiaction);
|
---|
222 | #endif
|
---|
223 |
|
---|
224 | // list of browsers
|
---|
225 | vlistbrowserclass avlistbrowserclass;
|
---|
226 | avlistbrowserclass.set_receptionist(&recpt);
|
---|
227 | recpt.add_browser (&avlistbrowserclass);
|
---|
228 | recpt.setdefaultbrowser ("VList");
|
---|
229 |
|
---|
230 | hlistbrowserclass ahlistbrowserclass;
|
---|
231 | ahlistbrowserclass.set_receptionist(&recpt);
|
---|
232 | recpt.add_browser (&ahlistbrowserclass);
|
---|
233 |
|
---|
234 | #ifdef GSDL_USE_DATELIST_BROWSER
|
---|
235 | datelistbrowserclass adatelistbrowserclass;
|
---|
236 | recpt.add_browser (&adatelistbrowserclass);
|
---|
237 | #endif
|
---|
238 |
|
---|
239 | invbrowserclass ainvbrowserclass;
|
---|
240 | recpt.add_browser (&ainvbrowserclass);
|
---|
241 |
|
---|
242 | #ifdef GSDL_USE_PAGED_BROWSER
|
---|
243 | pagedbrowserclass apagedbrowserclass;
|
---|
244 | recpt.add_browser (&apagedbrowserclass);
|
---|
245 | #endif
|
---|
246 |
|
---|
247 | #ifdef GSDL_USE_HTML_BROWSER
|
---|
248 | htmlbrowserclass ahtmlbrowserclass;
|
---|
249 | recpt.add_browser (&ahtmlbrowserclass);
|
---|
250 | #endif
|
---|
251 |
|
---|
252 | #ifdef GSDL_USE_PHIND_BROWSER
|
---|
253 | phindbrowserclass aphindbrowserclass;
|
---|
254 | recpt.add_browser (&aphindbrowserclass);
|
---|
255 | #endif
|
---|
256 |
|
---|
257 | #ifdef GSDL_USE_CLASSIFIER_BROWSER
|
---|
258 | //list of classifier browsers
|
---|
259 | CTreeClassifierBrowserClass *pTreeClassifierBrowser = new CTreeClassifierBrowserClass();
|
---|
260 | if (pTreeClassifierBrowser != NULL) {
|
---|
261 | recpt.GetClassifierBrowsers().AddBrowser(pTreeClassifierBrowser);
|
---|
262 | recpt.GetClassifierBrowsers().SetDefaultBrowser(pTreeClassifierBrowser->GetBrowserName());
|
---|
263 | }
|
---|
264 | #ifdef GSDL_USE_TREE_EX_CLASSIFIER_BROWSER
|
---|
265 | CTreeExClassifierBrowserClass *pTreeExClassifierBrowser = new CTreeExClassifierBrowserClass();
|
---|
266 | if (pTreeExClassifierBrowser != NULL) {
|
---|
267 | recpt.GetClassifierBrowsers().AddBrowser(pTreeExClassifierBrowser);
|
---|
268 | }
|
---|
269 | #endif //GSDL_USE_TREE_EX_CLASSIFIER_BROWSER
|
---|
270 | #endif //GSDL_USE_CLASSIFIER_BROWSER
|
---|
271 |
|
---|
272 | cgiwrapper (recpt, "");
|
---|
273 | delete cservers;
|
---|
274 |
|
---|
275 | // clean up the actions
|
---|
276 | actionmapclass::iterator thisAction = recpt.get_actionmap_ptr()->begin();
|
---|
277 | actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->begin();
|
---|
278 | while (thisAction != endAction) {
|
---|
279 | delete thisAction->second.a; thisAction->second.a = NULL;
|
---|
280 | ++thisAction;
|
---|
281 | }
|
---|
282 | thisAction = recpt.get_actionmap_ptr()->begin();
|
---|
283 | recpt.get_actionmap_ptr()->erase(thisAction, endAction);
|
---|
284 |
|
---|
285 | return 0;
|
---|
286 | }
|
---|
287 |
|
---|
288 |
|
---|
289 |
|
---|
290 |
|
---|
291 |
|
---|
292 |
|
---|
293 |
|
---|