source: trunk/niupepa/src/recpt/niupepalibrarymain.cpp@ 1521

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

updated niupepa collection

  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1/**********************************************************************
2 *
3 * niupepalibrarymain.cpp --
4 * A component of the Greenstone digital library software
5 * from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * Copyright (C) 1999 The New Zealand Digital Library Project
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: niupepalibrarymain.cpp 1521 2000-09-08 03:17:08Z nzdl $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.2 2000/09/08 03:17:08 nzdl
31 updated niupepa collection
32
33 Revision 1.1.1.1 2000/03/08 20:44:49 sjboddie
34 added niupepa to CVS
35
36 Revision 1.2 1999/09/07 22:19:50 sjboddie
37 added GPL header
38
39 Revision 1.1 1999/08/29 23:35:08 sjboddie
40 niupepa 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 "mgqueryfilter.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 "niupepadocaction.h"
63#include "authenaction.h"
64#include "usersaction.h"
65#include "delhistoryaction.h"
66
67#include "browserclass.h"
68#include "niupepavlistbrowserclass.h"
69#include "niupepahlistbrowserclass.h"
70#include "datelistbrowserclass.h"
71#include "invbrowserclass.h"
72#include "niupepapagedbrowserclass.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 ("niupepa");
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 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 mgqueryfilterclass *queryfilter = new mgqueryfilterclass();
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 // configure receptionist's collectinfo structure
125 text_tarray colinfo;
126 colinfo.push_back (*thiscol);
127 colinfo.push_back (gsdlhome);
128 colinfo.push_back (gsdlhome);
129 recpt.configure ("collectinfo", colinfo);
130
131 nproto.add_collectserver (cserver);
132 thiscol ++;
133 }
134
135 // add the protocol to the receptionist
136 recpt.add_protocol (&nproto);
137
138 // add other converters
139 utf8inconvertclass utf8inconvert;
140 utf8outconvertclass utf8outconvert;
141 recpt.add_converter ("u", &utf8inconvert, &utf8outconvert);
142
143 mapinconvertclass gbinconvert;
144 gbinconvert.setmapfile (gsdlhome, "gbku", 0x25a1);
145 mapoutconvertclass gboutconvert;
146 gboutconvert.setmapfile (gsdlhome, "ugbk", 0xa1f5);
147 recpt.add_converter ("g", &gbinconvert, &gboutconvert);
148
149 text_t armapfile = filename_cat (gsdlhome, "unicode", "MAPPINGS");
150 armapfile = filename_cat (armapfile, "WINDOWS", "1256.TXT");
151 simplemapinconvertclass arinconvert;
152 arinconvert.setmapfile (armapfile);
153 simplemapoutconvertclass aroutconvert;
154 aroutconvert.setmapfile (armapfile);
155 recpt.add_converter ("a", &arinconvert, &aroutconvert);
156
157 // the list of actions. Note: these actions will become invalid
158 // at the end of this function.
159 statusaction astatusaction;
160 astatusaction.set_receptionist (&recpt);
161 recpt.add_action (&astatusaction);
162
163 pageaction apageaction;
164 apageaction.set_receptionist (&recpt);
165 recpt.add_action (&apageaction);
166
167 pingaction apingaction;
168 recpt.add_action (&apingaction);
169
170 queryaction aqueryaction;
171 aqueryaction.set_receptionist (&recpt);
172 recpt.add_action (&aqueryaction);
173
174 niupepadocaction adocumentaction;
175 adocumentaction.set_receptionist (&recpt);
176 recpt.add_action (&adocumentaction);
177
178 usersaction ausersaction;
179 recpt.add_action (&ausersaction);
180
181 authenaction aauthenaction;
182 aauthenaction.set_receptionist(&recpt);
183 recpt.add_action (&aauthenaction);
184
185 delhistoryaction adelhistoryaction;
186 recpt.add_action(&adelhistoryaction);
187
188
189 // list of browsers
190 niupepavlistbrowserclass avlistbrowserclass;
191 recpt.add_browser (&avlistbrowserclass);
192 recpt.setdefaultbrowser ("VList");
193
194 niupepahlistbrowserclass ahlistbrowserclass;
195 recpt.add_browser (&ahlistbrowserclass);
196
197 datelistbrowserclass adatelistbrowserclass;
198 recpt.add_browser (&adatelistbrowserclass);
199
200 invbrowserclass ainvbrowserclass;
201 recpt.add_browser (&ainvbrowserclass);
202
203 niupepapagedbrowserclass apagedbrowserclass;
204 recpt.add_browser (&apagedbrowserclass);
205
206 htmlbrowserclass ahtmlbrowserclass;
207 recpt.add_browser (&ahtmlbrowserclass);
208
209 cgiwrapper (recpt, "niupepa");
210 return 0;
211}
Note: See TracBrowser for help on using the repository browser.