source: trunk/gsdl/src/recpt/librarymain.cpp@ 1285

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

Removed CVS logging information from source files

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