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