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

Last change on this file since 1838 was 1838, checked in by sjboddie, 23 years ago

Added support for Cyrillic languages (windows codepage 1251) - yet to be
tested by anyone who understands any such language though ;)

  • Property svn:keywords set to Author Date Id Revision
File size: 6.4 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 "fileutil.h"
29#include "nullproto.h"
30// z39.50 stuff - johnmcp
31#include "z3950proto.h"
32
33#include "action.h"
34#include "statusaction.h"
35#include "pageaction.h"
36#include "pingaction.h"
37#include "queryaction.h"
38#include "documentaction.h"
39#include "authenaction.h"
40#include "usersaction.h"
41#include "extlinkaction.h"
42#include "delhistoryaction.h"
43#include "tipaction.h"
44#include "collectoraction.h"
45
46#include "browserclass.h"
47#include "vlistbrowserclass.h"
48#include "hlistbrowserclass.h"
49#include "datelistbrowserclass.h"
50#include "invbrowserclass.h"
51#include "pagedbrowserclass.h"
52#include "htmlbrowserclass.h"
53#include "phindbrowserclass.h"
54
55#include "recptconfig.h"
56
57int main () {
58 receptionist recpt;
59 nullproto nproto;
60#ifndef __WIN32__
61 z3950proto zproto;
62#endif
63
64 text_tarray collections;
65
66 // get gsdlhome
67 text_t gsdlhome;
68 site_cfg_read (gsdlhome);
69 text_t collectdir = filename_cat (gsdlhome, "collect");
70 read_dir (collectdir, collections);
71
72 text_tarray::const_iterator thiscol = collections.begin();
73 text_tarray::const_iterator endcol = collections.end();
74
75 while (thiscol != endcol) {
76
77 // ignore the modelcol
78 if (*thiscol == "modelcol") {
79 thiscol ++;
80 continue;
81 }
82
83 // create collection server and add to null protocol
84 nproto.add_collection (*thiscol, &recpt, gsdlhome, gsdlhome);
85
86 thiscol ++;
87 }
88
89 // add the protocol to the receptionist
90 recpt.add_protocol (&nproto);
91
92 // z39.50 stuff - johnmcp
93#ifndef __WIN32__
94 // add the z39.50 server information. Read in the file
95 // etc/recpt/z3950.cfg for list of servers and their databases.
96 text_t z3950cfg = filename_cat (gsdlhome, "etc");
97 z3950cfg = filename_cat (z3950cfg, "recpt");
98 z3950cfg = filename_cat (z3950cfg, "z3950.cfg");
99#ifdef USE_FASTCGI
100 // currently can't use z39.50 if fastcgi is in use
101 if (0) {
102#else
103 if (file_exists(z3950cfg)) {
104#endif
105 text_t z3950err = filename_cat (gsdlhome, "etc", "z3950log.txt");
106 zproto.read_config_file(z3950cfg,z3950err);
107 // only add this protocol if we have any servers configured.
108 if (zproto.getServerCount()>0)
109 recpt.add_protocol (&zproto);
110 }
111#endif
112
113 // add other converters
114 utf8inconvertclass utf8inconvert;
115 utf8outconvertclass utf8outconvert;
116 recpt.add_converter ("u", &utf8inconvert, &utf8outconvert);
117
118 mapinconvertclass gbinconvert;
119 gbinconvert.setmapfile (gsdlhome, "gbku", 0x25a1);
120 mapoutconvertclass gboutconvert;
121 gboutconvert.setmapfile (gsdlhome, "ugbk", 0xa1f5);
122 recpt.add_converter ("g", &gbinconvert, &gboutconvert);
123
124 // arabic
125 text_t mapfile = filename_cat (gsdlhome, "unicode", "MAPPINGS");
126 mapfile = filename_cat (mapfile, "WINDOWS", "1256.TXT");
127 simplemapinconvertclass arinconvert;
128 arinconvert.setmapfile (mapfile);
129 simplemapoutconvertclass aroutconvert;
130 aroutconvert.setmapfile (mapfile);
131 recpt.add_converter ("a", &arinconvert, &aroutconvert);
132
133 // cyrillic
134 mapfile = filename_cat (gsdlhome, "unicode", "MAPPINGS");
135 mapfile = filename_cat (mapfile, "WINDOWS", "1251.TXT");
136 simplemapinconvertclass cyinconvert;
137 cyinconvert.setmapfile (mapfile);
138 simplemapoutconvertclass cyoutconvert;
139 cyoutconvert.setmapfile (mapfile);
140 recpt.add_converter ("c", &cyinconvert, &cyoutconvert);
141
142 // hindi
143// armapfile = filename_cat (gsdlhome, "unicode", "MAPPINGS");
144// armapfile = filename_cat (armapfile, "ISCII", "Devanagari.txt");
145// simplemapinconvertclass arinconvert;
146// arinconvert.setmapfile (armapfile);
147// simplemapoutconvertclass aroutconvert;
148// aroutconvert.setmapfile (armapfile);
149// recpt.add_converter ("a", &arinconvert, &aroutconvert);
150
151
152 // the list of actions. Note: these actions will become invalid
153 // at the end of this function.
154 tipaction atipaction;
155 recpt.add_action (&atipaction);
156
157 statusaction astatusaction;
158 astatusaction.set_receptionist (&recpt);
159 recpt.add_action (&astatusaction);
160
161 pageaction apageaction;
162 apageaction.set_receptionist (&recpt);
163 recpt.add_action (&apageaction);
164
165 pingaction apingaction;
166 recpt.add_action (&apingaction);
167
168 queryaction aqueryaction;
169 aqueryaction.set_receptionist (&recpt);
170 recpt.add_action (&aqueryaction);
171
172 documentaction adocumentaction;
173 adocumentaction.set_receptionist (&recpt);
174 recpt.add_action (&adocumentaction);
175
176 usersaction ausersaction;
177 recpt.add_action (&ausersaction);
178
179 extlinkaction anextlinkaction;
180 recpt.add_action (&anextlinkaction);
181
182 authenaction aauthenaction;
183 aauthenaction.set_receptionist(&recpt);
184 recpt.add_action (&aauthenaction);
185
186 delhistoryaction adelhistoryaction;
187 recpt.add_action(&adelhistoryaction);
188
189 collectoraction acollectoraction;
190 acollectoraction.set_receptionist (&recpt);
191 recpt.add_action(&acollectoraction);
192
193 // list of browsers
194 vlistbrowserclass avlistbrowserclass;
195 recpt.add_browser (&avlistbrowserclass);
196 recpt.setdefaultbrowser ("VList");
197
198 hlistbrowserclass ahlistbrowserclass;
199 recpt.add_browser (&ahlistbrowserclass);
200
201 datelistbrowserclass adatelistbrowserclass;
202 recpt.add_browser (&adatelistbrowserclass);
203
204 invbrowserclass ainvbrowserclass;
205 recpt.add_browser (&ainvbrowserclass);
206
207 pagedbrowserclass apagedbrowserclass;
208 recpt.add_browser (&apagedbrowserclass);
209
210 htmlbrowserclass ahtmlbrowserclass;
211 recpt.add_browser (&ahtmlbrowserclass);
212
213 phindbrowserclass aphindbrowserclass;
214 recpt.add_browser (&aphindbrowserclass);
215
216 cgiwrapper (recpt, "");
217 return 0;
218}
219
Note: See TracBrowser for help on using the repository browser.