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

Last change on this file since 826 was 826, checked in by davidb, 24 years ago

Teach buildaction about recptionist

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