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

Last change on this file since 1916 was 1911, checked in by kjm18, 23 years ago

delhistoryaction removed

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