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

Last change on this file since 1937 was 1937, checked in by jrm21, 23 years ago

z39.50 support is now disabled by default, enabled by configure script.

  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1/**********************************************************************
2 *
3 * librarymain.cpp --
4 * Copyright (C) 1999 The New Zaland 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#if defined(USE_Z3950)
32#include "z3950proto.h"
33#endif
34#include "collectserver.h"
35#include "filter.h"
36#include "browsefilter.h"
37#include "mgqueryfilter.h"
38#include "mgppqueryfilter.h"
39#include "infodbclass.h"
40#include "mggdbmsource.h"
41#include "mgsearch.h"
42#include "mgppsearch.h"
43#include "collectset.h"
44#include <assert.h>
45
46#include "action.h"
47#include "statusaction.h"
48#include "pageaction.h"
49#include "pingaction.h"
50#include "queryaction.h"
51#include "documentaction.h"
52#include "authenaction.h"
53#include "usersaction.h"
54#include "extlinkaction.h"
55#include "tipaction.h"
56#include "collectoraction.h"
57
58#include "browserclass.h"
59#include "vlistbrowserclass.h"
60#include "hlistbrowserclass.h"
61#include "datelistbrowserclass.h"
62#include "invbrowserclass.h"
63#include "pagedbrowserclass.h"
64#include "htmlbrowserclass.h"
65#include "phindbrowserclass.h"
66
67int main () {
68 receptionist recpt;
69 nullproto nproto;
70 collectset *cservers;
71#if defined(USE_Z3950)
72 /*#ifndef __WIN32__*/
73 z3950proto zproto;
74#endif
75 text_t gsdlhome;
76
77 cservers = new collectset(gsdlhome);
78
79 // GRB: removed 7/9/2000; perhaps needs to be here!site_cfg_read (gsdlhome);
80
81 // set up the null protocol
82 nproto.set_collectset(cservers);
83
84 // configure the receptionist server list
85 cservers->setReceptionistServers(recpt, gsdlhome);
86
87
88 /*
89 text_t collectdir = filename_cat (gsdlhome, "collect");
90 text_tarray collections;
91 read_dir (collectdir, collections);
92
93 text_tarray::const_iterator thiscol = collections.begin();
94 text_tarray::const_iterator endcol = collections.end();
95
96 while (thiscol != endcol) {
97
98 // ignore the modelcol
99 if (*thiscol == "modelcol") {
100 thiscol ++;
101 continue;
102 }
103
104 // create collection server and add to null protocol
105 nproto.add_collection (*thiscol, &recpt, gsdlhome, gsdlhome);
106
107 confin.close();
108// #endif ? does this tie in with a WIN32 ifdef?
109
110 collectserver *cserver = new collectserver();
111 gdbmclass *gdbmhandler = new gdbmclass();
112
113 // add a null filter
114 filterclass *filter = new filterclass ();
115 cserver->add_filter (filter);
116
117 // add a browse filter
118 browsefilterclass *browsefilter = new browsefilterclass();
119 browsefilter->set_gdbmptr (gdbmhandler);
120
121 cserver->add_filter (browsefilter);
122
123 if (buildtype == "mg") {
124 mgsearchclass *mgsearch = new mgsearchclass();
125
126 // add a query filter
127 mgqueryfilterclass *queryfilter = new mgqueryfilterclass();
128 queryfilter->set_gdbmptr (gdbmhandler);
129 queryfilter->set_mgsearchptr (mgsearch);
130 cserver->add_filter (queryfilter);
131
132 // add a mg and gdbm source
133 mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
134 mggdbmsource->set_gdbmptr (gdbmhandler);
135 mggdbmsource->set_mgsearchptr (mgsearch);
136 cserver->add_source (mggdbmsource);
137 }
138#ifndef __WIN32__
139
140 else if (buildtype == "mgpp") {
141
142 mgppsearchclass *mgsearch = new mgppsearchclass();
143
144 // add a query filter
145 mgppqueryfilterclass *queryfilter = new mgppqueryfilterclass();
146 queryfilter->set_gdbmptr (gdbmhandler);
147 queryfilter->set_mgsearchptr (mgsearch);
148 cserver->add_filter (queryfilter);
149
150 // add a mg and gdbm source
151 mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
152 mggdbmsource->set_gdbmptr (gdbmhandler);
153 mggdbmsource->set_mgsearchptr (mgsearch);
154 cserver->add_source (mggdbmsource);
155
156 }
157#endif
158
159 // inform collection server and everything it contains about its
160 // collection name
161 cserver->configure ("collection", *thiscol);
162
163 // configure receptionist's collectinfo structure
164 text_tarray colinfo;
165 colinfo.push_back (*thiscol);
166 colinfo.push_back (gsdlhome);
167 colinfo.push_back (gsdlhome);
168 recpt.configure ("collectinfo", colinfo);
169
170 nproto.add_collectserver (cserver);
171 thiscol ++;
172 }
173 */
174
175 // add the protocol to the receptionist
176 recpt.add_protocol (&nproto);
177
178 // z39.50 stuff - johnmcp
179#if defined(USE_Z3950)
180 /*#ifndef __WIN32__*/
181 // add the z39.50 server information. Read in the file
182 // etc/recpt/z3950.cfg for list of servers and their databases.
183 text_t z3950cfg = filename_cat (gsdlhome, "etc");
184 z3950cfg = filename_cat (z3950cfg, "recpt");
185 z3950cfg = filename_cat (z3950cfg, "z3950.cfg");
186#ifdef USE_FASTCGI
187 // currently can't use z39.50 if fastcgi used
188#warning "Disabling z39.50 support as fastcgi is in use"
189 if (0) {
190#else
191 if (file_exists(z3950cfg)) {
192#endif
193 text_t z3950err = filename_cat (gsdlhome, "etc", "z3950log.txt");
194 zproto.read_config_file(z3950cfg,z3950err);
195 // only add this protocol if we have any servers configured.
196 if (zproto.getServerCount()>0)
197 recpt.add_protocol (&zproto);
198 }
199#endif
200
201 // the list of actions. Note: these actions will become invalid
202 // at the end of this function.
203 tipaction atipaction;
204 recpt.add_action (&atipaction);
205
206 statusaction astatusaction;
207 astatusaction.set_receptionist (&recpt);
208 recpt.add_action (&astatusaction);
209
210 pageaction apageaction;
211 apageaction.set_receptionist (&recpt);
212 recpt.add_action (&apageaction);
213
214 pingaction apingaction;
215 recpt.add_action (&apingaction);
216
217 queryaction aqueryaction;
218 aqueryaction.set_receptionist (&recpt);
219 recpt.add_action (&aqueryaction);
220
221 documentaction adocumentaction;
222 adocumentaction.set_receptionist (&recpt);
223 recpt.add_action (&adocumentaction);
224
225 usersaction ausersaction;
226 recpt.add_action (&ausersaction);
227
228 extlinkaction anextlinkaction;
229 recpt.add_action (&anextlinkaction);
230
231 authenaction aauthenaction;
232 aauthenaction.set_receptionist(&recpt);
233 recpt.add_action (&aauthenaction);
234
235 collectoraction acollectoraction;
236 acollectoraction.set_receptionist (&recpt);
237 recpt.add_action(&acollectoraction);
238
239 // list of browsers
240 vlistbrowserclass avlistbrowserclass;
241 recpt.add_browser (&avlistbrowserclass);
242 recpt.setdefaultbrowser ("VList");
243
244 hlistbrowserclass ahlistbrowserclass;
245 recpt.add_browser (&ahlistbrowserclass);
246
247 datelistbrowserclass adatelistbrowserclass;
248 recpt.add_browser (&adatelistbrowserclass);
249
250 invbrowserclass ainvbrowserclass;
251 recpt.add_browser (&ainvbrowserclass);
252
253 pagedbrowserclass apagedbrowserclass;
254 recpt.add_browser (&apagedbrowserclass);
255
256 htmlbrowserclass ahtmlbrowserclass;
257 recpt.add_browser (&ahtmlbrowserclass);
258
259 phindbrowserclass aphindbrowserclass;
260 recpt.add_browser (&aphindbrowserclass);
261
262 cgiwrapper (recpt, "");
263 delete cservers;
264 return 0;
265}
266
Note: See TracBrowser for help on using the repository browser.