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

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

Tidied up collectoraction some more and created an add_collection
function in nullproto that does all the work of setting up a
local collection server

  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 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 armapfile = filename_cat (gsdlhome, "unicode", "MAPPINGS");
126 armapfile = filename_cat (armapfile, "WINDOWS", "1256.TXT");
127 simplemapinconvertclass arinconvert;
128 arinconvert.setmapfile (armapfile);
129 simplemapoutconvertclass aroutconvert;
130 aroutconvert.setmapfile (armapfile);
131 recpt.add_converter ("a", &arinconvert, &aroutconvert);
132
133 // hindi
134// armapfile = filename_cat (gsdlhome, "unicode", "MAPPINGS");
135// armapfile = filename_cat (armapfile, "ISCII", "Devanagari.txt");
136// simplemapinconvertclass arinconvert;
137// arinconvert.setmapfile (armapfile);
138// simplemapoutconvertclass aroutconvert;
139// aroutconvert.setmapfile (armapfile);
140// recpt.add_converter ("a", &arinconvert, &aroutconvert);
141
142
143 // the list of actions. Note: these actions will become invalid
144 // at the end of this function.
145 tipaction atipaction;
146 recpt.add_action (&atipaction);
147
148 statusaction astatusaction;
149 astatusaction.set_receptionist (&recpt);
150 recpt.add_action (&astatusaction);
151
152 pageaction apageaction;
153 apageaction.set_receptionist (&recpt);
154 recpt.add_action (&apageaction);
155
156 pingaction apingaction;
157 recpt.add_action (&apingaction);
158
159 queryaction aqueryaction;
160 aqueryaction.set_receptionist (&recpt);
161 recpt.add_action (&aqueryaction);
162
163 documentaction adocumentaction;
164 adocumentaction.set_receptionist (&recpt);
165 recpt.add_action (&adocumentaction);
166
167 usersaction ausersaction;
168 recpt.add_action (&ausersaction);
169
170 extlinkaction anextlinkaction;
171 recpt.add_action (&anextlinkaction);
172
173 authenaction aauthenaction;
174 aauthenaction.set_receptionist(&recpt);
175 recpt.add_action (&aauthenaction);
176
177 delhistoryaction adelhistoryaction;
178 recpt.add_action(&adelhistoryaction);
179
180 collectoraction acollectoraction;
181 acollectoraction.set_receptionist (&recpt);
182 recpt.add_action(&acollectoraction);
183
184 // list of browsers
185 vlistbrowserclass avlistbrowserclass;
186 recpt.add_browser (&avlistbrowserclass);
187 recpt.setdefaultbrowser ("VList");
188
189 hlistbrowserclass ahlistbrowserclass;
190 recpt.add_browser (&ahlistbrowserclass);
191
192 datelistbrowserclass adatelistbrowserclass;
193 recpt.add_browser (&adatelistbrowserclass);
194
195 invbrowserclass ainvbrowserclass;
196 recpt.add_browser (&ainvbrowserclass);
197
198 pagedbrowserclass apagedbrowserclass;
199 recpt.add_browser (&apagedbrowserclass);
200
201 htmlbrowserclass ahtmlbrowserclass;
202 recpt.add_browser (&ahtmlbrowserclass);
203
204 phindbrowserclass aphindbrowserclass;
205 recpt.add_browser (&aphindbrowserclass);
206
207 cgiwrapper (recpt, "");
208 return 0;
209}
210
Note: See TracBrowser for help on using the repository browser.