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

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

tidied up error messaging and set up some debugging info to be output
when running library from command line

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