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