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