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

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

gsdlhome now comes from gsdlsite.cfg

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