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