source: trunk/cstr/src/recpt/cstrlibrarymain.cpp@ 957

Last change on this file since 957 was 957, checked in by sjboddie, 24 years ago

gsdlhome now set from gsdlsite.cfg

  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 KB
Line 
1/**********************************************************************
2 *
3 * cstrlibrarymain.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 * $Id: cstrlibrarymain.cpp 957 2000-02-21 21:45:08Z sjboddie $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.3 2000/02/21 21:45:08 sjboddie
31 gsdlhome now set from gsdlsite.cfg
32
33 Revision 1.2 2000/02/06 21:25:22 sjboddie
34 updated cstr
35
36 Revision 1.1 1999/09/07 21:49:43 sjboddie
37 new cstr receptionist
38
39 */
40
41#include "receptionist.h"
42#include "cgiwrapper.h"
43#include "nullproto.h"
44#include "collectserver.h"
45#include "filter.h"
46#include "browsefilter.h"
47#include "queryfilter.h"
48#include "infodbclass.h"
49#include "mgsearch.h"
50#include "mggdbmsource.h"
51#include "fileutil.h"
52#include <assert.h>
53
54#include "action.h"
55#include "statusaction.h"
56#include "pageaction.h"
57#include "pingaction.h"
58#include "queryaction.h"
59#include "cstrdocaction.h"
60#include "authenaction.h"
61#include "usersaction.h"
62#include "authenaction.h"
63
64#include "browserclass.h"
65#include "vlistbrowserclass.h"
66#include "hlistbrowserclass.h"
67#include "datelistbrowserclass.h"
68#include "invbrowserclass.h"
69#include "cstrpagedbrowserclass.h"
70#include "htmlbrowserclass.h"
71
72#include "recptconfig.h"
73
74int main () {
75 receptionist recpt;
76 nullproto nproto;
77
78 // add a collection server
79 text_tarray collections;
80 collections.push_back ("cstr");
81
82 // get gsdlhome (if we fail the error will be picked up later -- in
83 // cgiwrapper)
84 text_t gsdlhome;
85 site_cfg_read (gsdlhome);
86
87 text_tarray::const_iterator thiscol = collections.begin();
88 text_tarray::const_iterator endcol = collections.end();
89
90 while (thiscol != endcol) {
91
92 // this memory is created but never destroyed
93 // we're also not doing any error checking to make sure we didn't
94 // run out of memory
95 collectserver *cserver = new collectserver();
96 gdbmclass *gdbmhandler = new gdbmclass();
97 mgsearchclass *mgsearch = new mgsearchclass();
98
99 // add a null filter
100 filterclass *filter = new filterclass ();
101 cserver->add_filter (filter);
102
103 // add a browse filter
104 browsefilterclass *browsefilter = new browsefilterclass();
105 browsefilter->set_gdbmptr (gdbmhandler);
106 cserver->add_filter (browsefilter);
107
108 // add a query filter
109 queryfilterclass *queryfilter = new queryfilterclass();
110 queryfilter->set_gdbmptr (gdbmhandler);
111 queryfilter->set_mgsearchptr (mgsearch);
112 cserver->add_filter (queryfilter);
113
114 // add a mg and gdbm source
115 mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
116 mggdbmsource->set_gdbmptr (gdbmhandler);
117 mggdbmsource->set_mgsearchptr (mgsearch);
118 cserver->add_source (mggdbmsource);
119
120 // inform collection server and everything it contains about its
121 // collection name
122 cserver->configure ("collection", *thiscol);
123
124 nproto.add_collectserver (cserver);
125 thiscol ++;
126 }
127
128 // add the protocol to the receptionist
129 recpt.add_protocol (&nproto);
130
131 // add other converters
132 utf8inconvertclass utf8inconvert;
133 utf8outconvertclass utf8outconvert;
134 recpt.add_converter ("u", &utf8inconvert, &utf8outconvert);
135
136 if (!gsdlhome.empty()) {
137 mapinconvertclass gbinconvert;
138 gbinconvert.setmapfile (gsdlhome, "gbku", 0x25a1);
139 mapoutconvertclass gboutconvert;
140 gboutconvert.setmapfile (gsdlhome, "ugbk", 0xa1f5);
141 recpt.add_converter ("g", &gbinconvert, &gboutconvert);
142 }
143
144 // the list of actions. Note: these actions will become invalid
145 // at the end of this function.
146 statusaction astatusaction;
147 astatusaction.set_receptionist (&recpt);
148 recpt.add_action (&astatusaction);
149
150 pageaction apageaction;
151 recpt.add_action (&apageaction);
152
153 pingaction apingaction;
154 recpt.add_action (&apingaction);
155
156 queryaction aqueryaction;
157 recpt.add_action (&aqueryaction);
158
159 cstrdocaction adocumentaction;
160 recpt.add_action (&adocumentaction);
161
162 usersaction ausersaction;
163 recpt.add_action (&ausersaction);
164
165 authenaction aauthenaction;
166 aauthenaction.set_receptionist(&recpt);
167 recpt.add_action (&aauthenaction);
168
169 // list of browsers
170 vlistbrowserclass avlistbrowserclass;
171 recpt.add_browser (&avlistbrowserclass);
172 recpt.setdefaultbrowser ("VList");
173
174 hlistbrowserclass ahlistbrowserclass;
175 recpt.add_browser (&ahlistbrowserclass);
176
177 datelistbrowserclass adatelistbrowserclass;
178 recpt.add_browser (&adatelistbrowserclass);
179
180 invbrowserclass ainvbrowserclass;
181 recpt.add_browser (&ainvbrowserclass);
182
183 cstrpagedbrowserclass apagedbrowserclass;
184 recpt.add_browser (&apagedbrowserclass);
185
186 htmlbrowserclass ahtmlbrowserclass;
187 recpt.add_browser (&ahtmlbrowserclass);
188
189 cgiwrapper (recpt, "cstr");
190 return 0;
191}
192
193
194
195
Note: See TracBrowser for help on using the repository browser.