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

Last change on this file since 772 was 762, checked in by sjboddie, 25 years ago

no longer set receptionist for some actions that used to

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