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

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

Added collector action - also changed the javascript required by all the
rollover buttons

  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 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 *********************************************************************/
25
26#include "receptionist.h"
27#include "cgiwrapper.h"
28#include "nullproto.h"
29// z39.50 stuff - johnmcp
30#include "z3950proto.h"
31#include "collectserver.h"
32#include "filter.h"
33#include "browsefilter.h"
34#include "mgqueryfilter.h"
35#include "mgppqueryfilter.h"
36#include "infodbclass.h"
37#include "mggdbmsource.h"
38#include "mgsearch.h"
39#include "mgppsearch.h"
40#include "fileutil.h"
41#include <assert.h>
42
43#include "action.h"
44#include "statusaction.h"
45#include "pageaction.h"
46#include "pingaction.h"
47#include "queryaction.h"
48#include "documentaction.h"
49#include "authenaction.h"
50#include "usersaction.h"
51#include "extlinkaction.h"
52#include "buildaction.h"
53#include "delhistoryaction.h"
54#include "tipaction.h"
55#include "collectoraction.h"
56
57#include "browserclass.h"
58#include "vlistbrowserclass.h"
59#include "hlistbrowserclass.h"
60#include "datelistbrowserclass.h"
61#include "invbrowserclass.h"
62#include "pagedbrowserclass.h"
63#include "htmlbrowserclass.h"
64
65#include "recptconfig.h"
66
67int main () {
68 receptionist recpt;
69 nullproto nproto;
70 z3950proto zproto;
71
72 text_tarray collections;
73
74 // get gsdlhome
75 text_t gsdlhome;
76 site_cfg_read (gsdlhome);
77 text_t collectdir = filename_cat (gsdlhome, "collect");
78 read_dir (collectdir, collections);
79
80 text_tarray::const_iterator thiscol = collections.begin();
81 text_tarray::const_iterator endcol = collections.end();
82
83 while (thiscol != endcol) {
84
85 // ignore the modelcol
86
87 if (*thiscol == "modelcol") {
88 thiscol ++;
89 continue;
90 }
91
92 // read config file to see if built with mg or mgpp
93 text_t buildtype = "mg"; // mg is default
94 text_tarray cfgline;
95 text_t key;
96 text_t filename = filename_cat(collectdir, *thiscol, "index/build.cfg");
97 ifstream confin(filename.getcstr());
98
99 if (confin) {
100 while (read_cfg_line(confin, cfgline) >= 0) {
101 if (cfgline.size() ==2 ) {
102 key = cfgline[0];
103 cfgline.erase(cfgline.begin());
104 if (key =="buildtype") {
105 buildtype = cfgline[0];
106 break;
107 }
108 }
109 }
110 }
111
112 confin.close();
113
114 // this memory is created but never destroyed
115 // we're also not doing any error checking to make sure we didn't
116 // run out of memory
117 collectserver *cserver = new collectserver();
118 gdbmclass *gdbmhandler = new gdbmclass();
119
120 // add a null filter
121 filterclass *filter = new filterclass ();
122 cserver->add_filter (filter);
123
124 // add a browse filter
125 browsefilterclass *browsefilter = new browsefilterclass();
126 browsefilter->set_gdbmptr (gdbmhandler);
127
128 cserver->add_filter (browsefilter);
129
130 if (buildtype == "mg") {
131 mgsearchclass *mgsearch = new mgsearchclass();
132
133 // add a query filter
134 mgqueryfilterclass *queryfilter = new mgqueryfilterclass();
135 queryfilter->set_gdbmptr (gdbmhandler);
136 queryfilter->set_mgsearchptr (mgsearch);
137 cserver->add_filter (queryfilter);
138
139 // add a mg and gdbm source
140 mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
141 mggdbmsource->set_gdbmptr (gdbmhandler);
142 mggdbmsource->set_mgsearchptr (mgsearch);
143 cserver->add_source (mggdbmsource);
144 }
145 else if (buildtype == "mgpp") {
146
147 mgppsearchclass *mgsearch = new mgppsearchclass();
148
149 // add a query filter
150 mgppqueryfilterclass *queryfilter = new mgppqueryfilterclass();
151 queryfilter->set_gdbmptr (gdbmhandler);
152 queryfilter->set_mgsearchptr (mgsearch);
153 cserver->add_filter (queryfilter);
154
155 // add a mg and gdbm source
156 mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
157 mggdbmsource->set_gdbmptr (gdbmhandler);
158 mggdbmsource->set_mgsearchptr (mgsearch);
159 cserver->add_source (mggdbmsource);
160
161 }
162
163 // inform collection server and everything it contains about its
164 // collection name
165 cserver->configure ("collection", *thiscol);
166
167 // configure receptionist's collectinfo structure
168 text_tarray colinfo;
169 colinfo.push_back (*thiscol);
170 colinfo.push_back (gsdlhome);
171 colinfo.push_back (gsdlhome);
172 recpt.configure ("collectinfo", colinfo);
173
174 nproto.add_collectserver (cserver);
175 thiscol ++;
176 }
177
178 // add the protocol to the receptionist
179 recpt.add_protocol (&nproto);
180
181
182
183 // z39.50 stuff - johnmcp
184
185 // add the z39.50 server information. Read in the file
186 // etc/recpt/z3950.cfg for list of servers and their databases.
187 text_t z3950cfg = filename_cat (gsdlhome, "etc");
188 z3950cfg = filename_cat (z3950cfg, "recpt");
189 z3950cfg = filename_cat (z3950cfg, "z3950.cfg");
190#ifdef USE_FASTCGI
191 // currently can't use z39.50 if fastcgi is in use
192 if (0) {
193#else
194 if (file_exists(z3950cfg)) {
195#endif
196 text_t z3950err = filename_cat (gsdlhome, "etc");
197 z3950err = filename_cat (z3950err, "recpt");
198 z3950err = filename_cat (z3950err, "z3950log.txt");
199 zproto.read_config_file(z3950cfg,z3950err);
200 // only add this protocol if we have any servers configured.
201 if (zproto.getServerCount()>0)
202 recpt.add_protocol (&zproto);
203 }
204
205
206 // add other converters
207 utf8inconvertclass utf8inconvert;
208 utf8outconvertclass utf8outconvert;
209 recpt.add_converter ("u", &utf8inconvert, &utf8outconvert);
210
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 text_t armapfile = filename_cat (gsdlhome, "unicode", "MAPPINGS");
218 armapfile = filename_cat (armapfile, "WINDOWS", "1256.TXT");
219 simplemapinconvertclass arinconvert;
220 arinconvert.setmapfile (armapfile);
221 simplemapoutconvertclass aroutconvert;
222 aroutconvert.setmapfile (armapfile);
223 recpt.add_converter ("a", &arinconvert, &aroutconvert);
224
225
226 // the list of actions. Note: these actions will become invalid
227 // at the end of this function.
228 tipaction atipaction;
229 recpt.add_action (&atipaction);
230
231 statusaction astatusaction;
232 astatusaction.set_receptionist (&recpt);
233 recpt.add_action (&astatusaction);
234
235 pageaction apageaction;
236 apageaction.set_receptionist (&recpt);
237 recpt.add_action (&apageaction);
238
239 pingaction apingaction;
240 recpt.add_action (&apingaction);
241
242 queryaction aqueryaction;
243 aqueryaction.set_receptionist (&recpt);
244 recpt.add_action (&aqueryaction);
245
246 documentaction adocumentaction;
247 adocumentaction.set_receptionist (&recpt);
248 recpt.add_action (&adocumentaction);
249
250 usersaction ausersaction;
251 recpt.add_action (&ausersaction);
252
253 extlinkaction anextlinkaction;
254 recpt.add_action (&anextlinkaction);
255
256 buildaction abuildaction;
257 abuildaction.set_receptionist (&recpt);
258 recpt.add_action (&abuildaction);
259
260 authenaction aauthenaction;
261 aauthenaction.set_receptionist(&recpt);
262 recpt.add_action (&aauthenaction);
263
264 delhistoryaction adelhistoryaction;
265 recpt.add_action(&adelhistoryaction);
266
267 collectoraction acollectoraction;
268 acollectoraction.set_receptionist (&recpt);
269 recpt.add_action(&acollectoraction);
270
271 // list of browsers
272 vlistbrowserclass avlistbrowserclass;
273 recpt.add_browser (&avlistbrowserclass);
274 recpt.setdefaultbrowser ("VList");
275
276 hlistbrowserclass ahlistbrowserclass;
277 recpt.add_browser (&ahlistbrowserclass);
278
279 datelistbrowserclass adatelistbrowserclass;
280 recpt.add_browser (&adatelistbrowserclass);
281
282 invbrowserclass ainvbrowserclass;
283 recpt.add_browser (&ainvbrowserclass);
284
285 pagedbrowserclass apagedbrowserclass;
286 recpt.add_browser (&apagedbrowserclass);
287
288 htmlbrowserclass ahtmlbrowserclass;
289 recpt.add_browser (&ahtmlbrowserclass);
290
291 cgiwrapper (recpt, "");
292 return 0;
293}
Note: See TracBrowser for help on using the repository browser.