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

Last change on this file since 15742 was 15742, checked in by mdewsnip, 16 years ago

Removed a whole lot of unused stuff.

  • Property svn:keywords set to Author Date Id Revision
File size: 7.1 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 "gsdl_modules_cfg.h"
27#include "receptionist.h"
28#include "cgiwrapper.h"
29#include "fileutil.h"
30#include "nullproto.h"
31// z39.50 stuff - johnmcp
32#if defined(USE_Z3950)
33#include "z3950proto.h"
34#endif
35#include "collectset.h"
36
37#include "action.h"
38#include "authenaction.h"
39#include "browseaction.h"
40#include "collectoraction.h"
41#include "depositoraction.h"
42#include "documentaction.h"
43#include "extlinkaction.h"
44#include "pageaction.h"
45#include "phindaction.h"
46#include "pingaction.h"
47#include "queryaction.h"
48#include "tipaction.h"
49#include "statusaction.h"
50#include "usersaction.h"
51
52#include "browserclass.h"
53#include "vlistbrowserclass.h"
54#include "hlistbrowserclass.h"
55#include "datelistbrowserclass.h"
56#include "invbrowserclass.h"
57#include "pagedbrowserclass.h"
58#include "htmlbrowserclass.h"
59#include "phindbrowserclass.h"
60
61
62int main ()
63{
64 receptionist recpt;
65 nullproto nproto;
66 collectset *cservers;
67#if defined(USE_Z3950)
68 z3950proto zproto;
69#endif
70 text_t gsdlhome;
71
72 cservers = new collectset(gsdlhome);
73
74 // configure the receptionist server list
75 text_tarray collection_list;
76 cservers->getCollectionList(collection_list);
77 text_tarray::iterator collection_iterator = collection_list.begin();
78 while (collection_iterator != collection_list.end())
79 {
80 text_tarray colinfo;
81 colinfo.push_back(*collection_iterator);
82 colinfo.push_back(gsdlhome);
83 colinfo.push_back(gsdlhome);
84 recpt.configure("collectinfo", colinfo);
85 collection_iterator++;
86 }
87
88 // set up the null protocol
89 nproto.set_collectset(cservers);
90
91 // add the protocol to the receptionist
92 recpt.add_protocol (&nproto);
93
94 // z39.50 stuff - johnmcp
95#if defined(USE_Z3950)
96 // add the z39.50 server information. Read in the file
97 // etc/recpt/z3950.cfg for list of servers and their databases.
98 text_t z3950cfg = filename_cat (gsdlhome, "etc");
99 z3950cfg = filename_cat (z3950cfg, "packages");
100 z3950cfg = filename_cat (z3950cfg, "z3950.cfg");
101#ifdef USE_FASTCGI
102 // currently can't use z39.50 if fastcgi used
103#warning "Disabling z39.50 support as fastcgi is in use"
104 if (0) {
105#else
106 if (file_exists(z3950cfg)) {
107#endif
108 text_t z3950err = filename_cat (gsdlhome, "etc", "z3950log.txt");
109 zproto.read_config_file(z3950cfg,z3950err);
110 // only add this protocol if we have any servers configured.
111 if (zproto.getServerCount()>0)
112 recpt.add_protocol (&zproto);
113 }
114#endif
115
116#ifdef GSDL_USE_TIP_ACTION
117 // the list of actions. Note: these actions will become invalid
118 // at the end of this function. We will clean them.
119 recpt.add_action (new tipaction());
120#endif
121
122#ifdef GSDL_USE_STATUS_ACTION
123 statusaction *astatusaction = new statusaction();
124 astatusaction->set_receptionist (&recpt);
125 recpt.add_action (astatusaction);
126#endif
127
128 pageaction *apageaction = new pageaction();
129 apageaction->set_receptionist (&recpt);
130 recpt.add_action (apageaction);
131
132#ifdef GSDL_USE_PING_ACTION
133 recpt.add_action (new pingaction());
134#endif
135
136 queryaction *aqueryaction = new queryaction();
137 aqueryaction->set_receptionist (&recpt);
138 recpt.add_action (aqueryaction);
139
140 documentaction *adocumentaction = new documentaction();
141 adocumentaction->set_receptionist (&recpt);
142 recpt.add_action (adocumentaction);
143
144 text_t userdbfile = filename_cat(gsdlhome, "etc", "users.db");
145 userdbclass *udb = new userdbclass(userdbfile);
146
147 text_t keydbfile = filename_cat(gsdlhome, "etc", "key.db");
148 keydbclass *kdb = new keydbclass(keydbfile);
149
150#ifdef GSDL_USE_USERS_ACTION
151 usersaction *ausersaction = new usersaction();
152 ausersaction->set_userdb(udb);
153 recpt.add_action (ausersaction);
154#endif
155
156#ifdef GSDL_USE_EXTLINK_ACTION
157 extlinkaction *aextlinkaction = new extlinkaction();
158 aextlinkaction->set_receptionist(&recpt);
159 recpt.add_action (aextlinkaction);
160#endif
161
162#ifdef GSDL_USE_AUTHEN_ACTION
163 authenaction *aauthenaction = new authenaction();
164 aauthenaction->set_userdb(udb);
165 aauthenaction->set_keydb(kdb);
166 aauthenaction->set_receptionist(&recpt);
167 recpt.add_action (aauthenaction);
168#endif
169
170#ifdef GSDL_USE_COLLECTOR_ACTION
171 collectoraction *acollectoraction = new collectoraction();
172 acollectoraction->set_receptionist (&recpt);
173 recpt.add_action(acollectoraction);
174#endif
175
176#ifdef GSDL_USE_DEPOSITOR_ACTION
177 depositoraction *adepositoraction = new depositoraction();
178 adepositoraction->set_receptionist (&recpt);
179 recpt.add_action(adepositoraction);
180#endif
181
182#ifdef GSDL_USE_BROWSE_ACTION
183 browseaction *abrowseaction = new browseaction();
184 abrowseaction->set_receptionist (&recpt);
185 recpt.add_action(abrowseaction);
186#endif
187
188#ifdef GSDL_USE_PHIND_ACTION
189 recpt.add_action(new phindaction());
190#endif
191
192#ifdef GSDL_USE_GTI_ACTION
193 gtiaction *agtiaction = new gtiaction();
194 agtiaction->set_receptionist(&recpt);
195 recpt.add_action(agtiaction);
196#endif
197
198 // list of browsers
199 vlistbrowserclass avlistbrowserclass;
200 avlistbrowserclass.set_receptionist(&recpt);
201 recpt.add_browser (&avlistbrowserclass);
202 recpt.setdefaultbrowser ("VList");
203
204 hlistbrowserclass ahlistbrowserclass;
205 ahlistbrowserclass.set_receptionist(&recpt);
206 recpt.add_browser (&ahlistbrowserclass);
207
208#ifdef GSDL_USE_DATELIST_BROWSER
209 datelistbrowserclass adatelistbrowserclass;
210 recpt.add_browser (&adatelistbrowserclass);
211#endif
212
213 invbrowserclass ainvbrowserclass;
214 recpt.add_browser (&ainvbrowserclass);
215
216#ifdef GSDL_USE_PAGED_BROWSER
217 pagedbrowserclass apagedbrowserclass;
218 recpt.add_browser (&apagedbrowserclass);
219#endif
220
221#ifdef GSDL_USE_HTML_BROWSER
222 htmlbrowserclass ahtmlbrowserclass;
223 recpt.add_browser (&ahtmlbrowserclass);
224#endif
225
226#ifdef GSDL_USE_PHIND_BROWSER
227 phindbrowserclass aphindbrowserclass;
228 recpt.add_browser (&aphindbrowserclass);
229#endif
230
231 cgiwrapper (recpt, "");
232 delete cservers;
233 delete udb;
234 delete kdb;
235
236 // clean up the actions
237 actionmapclass::iterator thisAction = recpt.get_actionmap_ptr()->begin();
238 actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->begin();
239 while (thisAction != endAction) {
240 delete thisAction->second.a; thisAction->second.a = NULL;
241 ++thisAction;
242 }
243 thisAction = recpt.get_actionmap_ptr()->begin();
244 recpt.get_actionmap_ptr()->erase(thisAction, endAction);
245
246 return 0;
247}
Note: See TracBrowser for help on using the repository browser.