source: main/trunk/greenstone2/runtime-src/src/recpt/librarymain.cpp@ 30465

Last change on this file since 30465 was 25560, checked in by ak19, 12 years ago

Dr Bainbridge has introduced the isPersistentAction (add the a=is-persistent to the library url). It is true for server.exe and when using mod_gsdl, but false for library.cgi which uses the apache web server (when not using mod_gsdl).

  • Property svn:keywords set to Author Date Id Revision
File size: 4.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 "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 "ispersistentaction.h"
39#include "browserclass.h"
40
41
42int main ()
43{
44 receptionist recpt;
45 nullproto nproto;
46 collectset *cservers;
47#if defined(USE_Z3950)
48 z3950proto zproto;
49#endif
50 text_t gsdlhome;
51 text_t collecthome;
52
53 cservers = new collectset(gsdlhome,collecthome);
54
55 // configure the receptionist server list
56 text_tarray collection_list;
57 cservers->getCollectionList(collection_list);
58 text_tarray::iterator collection_iterator = collection_list.begin();
59 while (collection_iterator != collection_list.end())
60 {
61 text_tarray colinfo;
62 colinfo.push_back(*collection_iterator);
63 colinfo.push_back(gsdlhome);
64 colinfo.push_back(collecthome);
65 colinfo.push_back(gsdlhome);
66 recpt.configure("collectinfo", colinfo);
67 collection_iterator++;
68 }
69
70 // set up the null protocol
71 nproto.set_collectset(cservers);
72
73 // add the protocol to the receptionist
74 recpt.add_protocol (&nproto);
75
76 // z39.50 stuff - johnmcp
77#if defined(USE_Z3950)
78 // add the z39.50 server information. Read in the file
79 // etc/packages/z3950/z3950.cfg for list of servers and their databases.
80 text_t z3950cfg = filename_cat (gsdlhome, "etc", "packages", "z3950", "z3950.cfg");
81#ifdef USE_FASTCGI
82 // currently can't use z39.50 if fastcgi used
83#warning "Disabling z39.50 support as fastcgi is in use"
84 if (0) {
85#else
86 if (file_exists(z3950cfg)) {
87#endif
88 text_t z3950err = filename_cat (gsdlhome, "etc", "packages", "z3950", "z3950log.txt");
89 zproto.read_config_file(z3950cfg,z3950err);
90 // only add this protocol if we have any servers configured.
91 if (zproto.getServerCount()>0)
92 recpt.add_protocol (&zproto);
93 }
94#endif
95
96 userdbclass *udb = new userdbclass(gsdlhome);
97 keydbclass *kdb = new keydbclass(gsdlhome);
98
99 add_all_actions(recpt,udb,kdb,isNotPersistent); // apache (without mod_gsdl) is not a persistent server
100 // Note: these actions will become invalid at the end of this function.
101 // => We will retrieve them from the receptionist and delete them
102
103 add_all_browsers(recpt);
104 // Browsers are not currently deleted (at all?) in code. Seems likely they
105 // should be treated in a similar fashion to actions
106
107 cgiwrapper (recpt, "");
108 delete cservers;
109 delete udb;
110 delete kdb;
111
112 // clean up the actions
113 actionmapclass::iterator thisAction = recpt.get_actionmap_ptr()->begin();
114 actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->end();
115 while (thisAction != endAction) {
116 delete thisAction->second.a;
117 thisAction->second.a = NULL;
118 ++thisAction;
119 }
120 thisAction = recpt.get_actionmap_ptr()->begin();
121 recpt.get_actionmap_ptr()->erase(thisAction, endAction);
122
123
124 /*
125 // clean up the browsers
126 browsermapclass::iterator thisBrowser = recpt.get_browsermap_ptr()->begin();
127 browsermapclass::iterator endBrowser = recpt.get_browsermap_ptr()->end();
128 while (thisBrowser != endBrowser) {
129 delete thisBrowser->second.a;
130 thisBrowser->second.a = NULL;
131 ++thisBrowser;
132 }
133 thisBrowser = recpt.get_browsermap_ptr()->begin();
134 recpt.get_browsermap_ptr()->erase(thisBrowser, endBrowser);
135 */
136
137 return 0;
138}
Note: See TracBrowser for help on using the repository browser.