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

Last change on this file since 1270 was 1270, checked in by sjboddie, 24 years ago

Receptionist now caches collection information to avoid making multiple
get_collectinfo calls to collection server

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