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