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

Last change on this file since 1065 was 1065, checked in by nzdl, 24 years ago

caught cstr collection up with DocumentColumn stuff

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