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

Last change on this file since 1641 was 1523, checked in by say1, 24 years ago

adding Hindi mapping

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