source: branches/z3950-branch/gsdl/src/recpt/librarymain.cpp@ 1168

Last change on this file since 1168 was 1168, checked in by johnmcp, 24 years ago

added proper config file parsing for z39.50 servers, and minor changes
to pageaction (minor bug when display collections from >1 proto) and
cgiwrapper (announces which collections are z39.50 servers).

  • Property svn:keywords set to Author Date Id Revision
File size: 9.1 KB
Line 
1/**********************************************************************
2 *
3 * librarymain.cpp --
4 * Copyright (C) 1999 The New Zealand 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 * $Id: librarymain.cpp 1168 2000-05-11 01:56:34Z johnmcp $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.25.2.1 2000/05/11 01:56:29 johnmcp
31
32 added proper config file parsing for z39.50 servers, and minor changes
33 to pageaction (minor bug when display collections from >1 proto) and
34 cgiwrapper (announces which collections are z39.50 servers).
35
36 Revision 1.25 2000/04/14 02:52:05 sjboddie
37 tidied up error messaging and set up some debugging info to be output
38 when running library from command line
39
40 Revision 1.24 2000/02/29 20:59:02 sjboddie
41 added error message when unable to read from collect directory - should
42 probably write this out to a web page too
43
44 Revision 1.23 2000/02/21 21:59:37 sjboddie
45 gsdlhome now comes from gsdlsite.cfg
46
47 Revision 1.22 2000/02/17 02:35:48 sjboddie
48 tidied up a bit
49
50 Revision 1.21 2000/02/15 22:53:51 kjm18
51 search history stuff added.
52
53 Revision 1.20 1999/12/13 02:46:56 davidb
54 Teach buildaction about recptionist
55
56 Revision 1.19 1999/11/01 21:58:49 sjboddie
57 no longer set receptionist for some actions that used to
58
59 Revision 1.18 1999/10/25 22:29:31 sjboddie
60 receptionist now checks collect diectory for collections
61 rather than collections.txt file
62
63 Revision 1.17 1999/10/19 03:23:43 davidb
64 Collection building support through web pages
65 and internal and external link handling for collection documents
66
67 Revision 1.16 1999/10/18 20:07:33 sjboddie
68 added htmlbrowserclass
69
70 Revision 1.15 1999/10/14 23:03:10 sjboddie
71 another browser
72
73 Revision 1.14 1999/10/10 08:14:09 sjboddie
74 - metadata now returns mp rather than array
75 - redesigned browsing support (although it's not finished so
76 won't currently work ;-)
77
78 Revision 1.13 1999/09/16 21:39:35 sjboddie
79 added gb converters
80
81 Revision 1.12 1999/09/14 22:42:06 sjboddie
82 included utf8 converter
83
84 Revision 1.11 1999/09/14 22:03:27 sjboddie
85 now reads in collections from a file to avoid recompiling
86
87 Revision 1.10 1999/09/08 00:51:11 sjboddie
88 removed old interface stuff
89
90 Revision 1.9 1999/09/07 04:56:56 sjboddie
91 added GPL notice
92
93 Revision 1.8 1999/07/15 06:08:55 rjmcnab
94 Moved the adding of the actions to librarymain so that they can
95 be overriden easier.
96
97 Revision 1.7 1999/06/15 01:56:12 sjboddie
98 Got multiple collections working
99
100 Revision 1.6 1999/05/10 03:40:39 sjboddie
101 lots of changes - slowly getting document action sorted out
102
103 Revision 1.5 1999/04/19 23:56:10 rjmcnab
104 Finished the gdbm metadata stuff
105
106 Revision 1.4 1999/04/12 03:45:05 rjmcnab
107 Finished the query filter.
108
109 Revision 1.3 1999/04/06 22:20:35 rjmcnab
110 Got browsefilter working.
111
112 Revision 1.2 1999/03/05 03:53:54 sjboddie
113
114 fixed some bugs
115
116 Revision 1.1 1999/02/21 22:35:22 rjmcnab
117
118 Initial revision.
119
120 */
121
122
123#include "receptionist.h"
124#include "cgiwrapper.h"
125#include "nullproto.h"
126// z39.50 stuff - johnmcp
127#include "z3950proto.h"
128#include "collectserver.h"
129#include "filter.h"
130#include "browsefilter.h"
131#include "queryfilter.h"
132#include "infodbclass.h"
133#include "mgsearch.h"
134#include "mggdbmsource.h"
135#include "fileutil.h"
136#include <assert.h>
137
138#include "action.h"
139#include "statusaction.h"
140#include "pageaction.h"
141#include "pingaction.h"
142#include "queryaction.h"
143#include "documentaction.h"
144#include "authenaction.h"
145#include "usersaction.h"
146#include "extlinkaction.h"
147#include "buildaction.h"
148#include "delhistoryaction.h"
149
150#include "browserclass.h"
151#include "vlistbrowserclass.h"
152#include "hlistbrowserclass.h"
153#include "datelistbrowserclass.h"
154#include "invbrowserclass.h"
155#include "pagedbrowserclass.h"
156#include "htmlbrowserclass.h"
157
158#include "recptconfig.h"
159
160int main () {
161 receptionist recpt;
162 nullproto nproto;
163 z3950proto zproto;
164 text_tarray collections;
165
166
167 // get gsdlhome
168 text_t gsdlhome;
169 site_cfg_read (gsdlhome);
170 text_t collectdir = filename_cat (gsdlhome, "collect");
171 read_dir (collectdir, collections);
172
173 text_tarray::const_iterator thiscol = collections.begin();
174 text_tarray::const_iterator endcol = collections.end();
175
176 while (thiscol != endcol) {
177
178 // ignore the modelcol
179 if (*thiscol == "modelcol") {thiscol ++; continue;}
180
181 // this memory is created but never destroyed
182 // we're also not doing any error checking to make sure we didn't
183 // run out of memory
184 collectserver *cserver = new collectserver();
185 gdbmclass *gdbmhandler = new gdbmclass();
186 mgsearchclass *mgsearch = new mgsearchclass();
187
188 // add a null filter
189 filterclass *filter = new filterclass ();
190 cserver->add_filter (filter);
191
192 // add a browse filter
193 browsefilterclass *browsefilter = new browsefilterclass();
194 browsefilter->set_gdbmptr (gdbmhandler);
195 cserver->add_filter (browsefilter);
196
197 // add a query filter
198 queryfilterclass *queryfilter = new queryfilterclass();
199 queryfilter->set_gdbmptr (gdbmhandler);
200 queryfilter->set_mgsearchptr (mgsearch);
201 cserver->add_filter (queryfilter);
202
203 // add a mg and gdbm source
204 mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
205 mggdbmsource->set_gdbmptr (gdbmhandler);
206 mggdbmsource->set_mgsearchptr (mgsearch);
207 cserver->add_source (mggdbmsource);
208
209 // inform collection server and everything it contains about its
210 // collection name
211 cserver->configure ("collection", *thiscol);
212
213 // configure receptionist's collectinfo structure
214 text_tarray colinfo;
215 colinfo.push_back (*thiscol);
216 colinfo.push_back (gsdlhome);
217 colinfo.push_back (gsdlhome);
218 recpt.configure ("collectinfo", colinfo);
219
220 nproto.add_collectserver (cserver);
221 thiscol ++;
222 }
223
224 // add the protocol to the receptionist
225 recpt.add_protocol (&nproto);
226
227
228
229 // z39.50 stuff - johnmcp
230
231 // add the z39.50 server information. Read in the file
232 // etc/recpt/z3950.cfg for list of servers and their databases.
233 text_t z3950cfg = filename_cat (gsdlhome, "etc");
234 z3950cfg = filename_cat (z3950cfg, "recpt");
235 z3950cfg = filename_cat (z3950cfg, "z3950.cfg");
236 if (file_exists(z3950cfg)) {
237 zproto.read_config_file(z3950cfg);
238 // only add this protocol if we have any servers configured.
239 if (zproto.getServerCount()>0)
240 recpt.add_protocol (&zproto);
241 }
242
243
244 // add other converters
245 utf8inconvertclass utf8inconvert;
246 utf8outconvertclass utf8outconvert;
247 recpt.add_converter ("u", &utf8inconvert, &utf8outconvert);
248
249 if (!gsdlhome.empty()) {
250 mapinconvertclass gbinconvert;
251 gbinconvert.setmapfile (gsdlhome, "gbku", 0x25a1);
252 mapoutconvertclass gboutconvert;
253 gboutconvert.setmapfile (gsdlhome, "ugbk", 0xa1f5);
254 recpt.add_converter ("g", &gbinconvert, &gboutconvert);
255 }
256
257 // the list of actions. Note: these actions will become invalid
258 // at the end of this function.
259 statusaction astatusaction;
260 astatusaction.set_receptionist (&recpt);
261 recpt.add_action (&astatusaction);
262
263 pageaction apageaction;
264 recpt.add_action (&apageaction);
265
266 pingaction apingaction;
267 recpt.add_action (&apingaction);
268
269 queryaction aqueryaction;
270 recpt.add_action (&aqueryaction);
271
272 documentaction adocumentaction;
273 recpt.add_action (&adocumentaction);
274
275 usersaction ausersaction;
276 recpt.add_action (&ausersaction);
277
278 extlinkaction anextlinkaction;
279 recpt.add_action (&anextlinkaction);
280
281 buildaction abuildaction;
282 abuildaction.set_receptionist (&recpt);
283 recpt.add_action (&abuildaction);
284
285 authenaction aauthenaction;
286 aauthenaction.set_receptionist(&recpt);
287 recpt.add_action (&aauthenaction);
288
289 delhistoryaction adelhistoryaction;
290 recpt.add_action(&adelhistoryaction);
291
292 // list of browsers
293 vlistbrowserclass avlistbrowserclass;
294 recpt.add_browser (&avlistbrowserclass);
295 recpt.setdefaultbrowser ("VList");
296
297 hlistbrowserclass ahlistbrowserclass;
298 recpt.add_browser (&ahlistbrowserclass);
299
300 datelistbrowserclass adatelistbrowserclass;
301 recpt.add_browser (&adatelistbrowserclass);
302
303 invbrowserclass ainvbrowserclass;
304 recpt.add_browser (&ainvbrowserclass);
305
306 pagedbrowserclass apagedbrowserclass;
307 recpt.add_browser (&apagedbrowserclass);
308
309 htmlbrowserclass ahtmlbrowserclass;
310 recpt.add_browser (&ahtmlbrowserclass);
311
312 cgiwrapper (recpt, "");
313 return 0;
314}
315
316
317
318
319
Note: See TracBrowser for help on using the repository browser.