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 | * $Id: librarymain.cpp 746 1999-10-25 22:29:32Z sjboddie $
|
---|
25 | *
|
---|
26 | *********************************************************************/
|
---|
27 |
|
---|
28 | /*
|
---|
29 | $Log$
|
---|
30 | Revision 1.18 1999/10/25 22:29:31 sjboddie
|
---|
31 | receptionist now checks collect diectory for collections
|
---|
32 | rather than collections.txt file
|
---|
33 |
|
---|
34 | Revision 1.17 1999/10/19 03:23:43 davidb
|
---|
35 | Collection building support through web pages
|
---|
36 | and internal and external link handling for collection documents
|
---|
37 |
|
---|
38 | Revision 1.16 1999/10/18 20:07:33 sjboddie
|
---|
39 | added htmlbrowserclass
|
---|
40 |
|
---|
41 | Revision 1.15 1999/10/14 23:03:10 sjboddie
|
---|
42 | another browser
|
---|
43 |
|
---|
44 | Revision 1.14 1999/10/10 08:14:09 sjboddie
|
---|
45 | - metadata now returns mp rather than array
|
---|
46 | - redesigned browsing support (although it's not finished so
|
---|
47 | won't currently work ;-)
|
---|
48 |
|
---|
49 | Revision 1.13 1999/09/16 21:39:35 sjboddie
|
---|
50 | added gb converters
|
---|
51 |
|
---|
52 | Revision 1.12 1999/09/14 22:42:06 sjboddie
|
---|
53 | included utf8 converter
|
---|
54 |
|
---|
55 | Revision 1.11 1999/09/14 22:03:27 sjboddie
|
---|
56 | now reads in collections from a file to avoid recompiling
|
---|
57 |
|
---|
58 | Revision 1.10 1999/09/08 00:51:11 sjboddie
|
---|
59 | removed old interface stuff
|
---|
60 |
|
---|
61 | Revision 1.9 1999/09/07 04:56:56 sjboddie
|
---|
62 | added GPL notice
|
---|
63 |
|
---|
64 | Revision 1.8 1999/07/15 06:08:55 rjmcnab
|
---|
65 | Moved the adding of the actions to librarymain so that they can
|
---|
66 | be overriden easier.
|
---|
67 |
|
---|
68 | Revision 1.7 1999/06/15 01:56:12 sjboddie
|
---|
69 | Got multiple collections working
|
---|
70 |
|
---|
71 | Revision 1.6 1999/05/10 03:40:39 sjboddie
|
---|
72 | lots of changes - slowly getting document action sorted out
|
---|
73 |
|
---|
74 | Revision 1.5 1999/04/19 23:56:10 rjmcnab
|
---|
75 | Finished the gdbm metadata stuff
|
---|
76 |
|
---|
77 | Revision 1.4 1999/04/12 03:45:05 rjmcnab
|
---|
78 | Finished the query filter.
|
---|
79 |
|
---|
80 | Revision 1.3 1999/04/06 22:20:35 rjmcnab
|
---|
81 | Got browsefilter working.
|
---|
82 |
|
---|
83 | Revision 1.2 1999/03/05 03:53:54 sjboddie
|
---|
84 |
|
---|
85 | fixed some bugs
|
---|
86 |
|
---|
87 | Revision 1.1 1999/02/21 22:35:22 rjmcnab
|
---|
88 |
|
---|
89 | Initial revision.
|
---|
90 |
|
---|
91 | */
|
---|
92 |
|
---|
93 |
|
---|
94 | #include "receptionist.h"
|
---|
95 | #include "cgiwrapper.h"
|
---|
96 | #include "nullproto.h"
|
---|
97 | #include "collectserver.h"
|
---|
98 | #include "filter.h"
|
---|
99 | #include "browsefilter.h"
|
---|
100 | #include "queryfilter.h"
|
---|
101 | #include "infodbclass.h"
|
---|
102 | #include "mgsearch.h"
|
---|
103 | #include "mggdbmsource.h"
|
---|
104 | #include "fileutil.h"
|
---|
105 | #include <assert.h>
|
---|
106 |
|
---|
107 | #include "action.h"
|
---|
108 | #include "statusaction.h"
|
---|
109 | #include "pageaction.h"
|
---|
110 | #include "pingaction.h"
|
---|
111 | #include "queryaction.h"
|
---|
112 | #include "documentaction.h"
|
---|
113 | #include "authenaction.h"
|
---|
114 | #include "usersaction.h"
|
---|
115 | #include "authenaction.h"
|
---|
116 | #include "extlinkaction.h"
|
---|
117 | #include "buildaction.h"
|
---|
118 |
|
---|
119 | #include "browserclass.h"
|
---|
120 | #include "vlistbrowserclass.h"
|
---|
121 | #include "hlistbrowserclass.h"
|
---|
122 | #include "datelistbrowserclass.h"
|
---|
123 | #include "invbrowserclass.h"
|
---|
124 | #include "pagedbrowserclass.h"
|
---|
125 | #include "htmlbrowserclass.h"
|
---|
126 |
|
---|
127 | #include "gsdlhome.h"
|
---|
128 |
|
---|
129 | int main () {
|
---|
130 | receptionist recpt;
|
---|
131 | nullproto nproto;
|
---|
132 |
|
---|
133 | text_tarray collections;
|
---|
134 | if (!read_dir (GSDL_GSDLHOME "/collect", collections)) exit (1);
|
---|
135 |
|
---|
136 | text_tarray::const_iterator thiscol = collections.begin();
|
---|
137 | text_tarray::const_iterator endcol = collections.end();
|
---|
138 |
|
---|
139 | while (thiscol != endcol) {
|
---|
140 |
|
---|
141 | // ignore the modelcol
|
---|
142 | if (*thiscol == "modelcol") {
|
---|
143 | thiscol ++;
|
---|
144 | continue;
|
---|
145 | }
|
---|
146 |
|
---|
147 | // this memory is created but never destroyed
|
---|
148 | // we're also not doing any error checking to make sure we didn't
|
---|
149 | // run out of memory
|
---|
150 | collectserver *cserver = new collectserver();
|
---|
151 | gdbmclass *gdbmhandler = new gdbmclass();
|
---|
152 | mgsearchclass *mgsearch = new mgsearchclass();
|
---|
153 |
|
---|
154 | // add a null filter
|
---|
155 | filterclass *filter = new filterclass ();
|
---|
156 | cserver->add_filter (filter);
|
---|
157 |
|
---|
158 | // add a browse filter
|
---|
159 | browsefilterclass *browsefilter = new browsefilterclass();
|
---|
160 | browsefilter->set_gdbmptr (gdbmhandler);
|
---|
161 | cserver->add_filter (browsefilter);
|
---|
162 |
|
---|
163 | // add a query filter
|
---|
164 | queryfilterclass *queryfilter = new queryfilterclass();
|
---|
165 | queryfilter->set_gdbmptr (gdbmhandler);
|
---|
166 | queryfilter->set_mgsearchptr (mgsearch);
|
---|
167 | cserver->add_filter (queryfilter);
|
---|
168 |
|
---|
169 | // add a mg and gdbm source
|
---|
170 | mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
|
---|
171 | mggdbmsource->set_gdbmptr (gdbmhandler);
|
---|
172 | mggdbmsource->set_mgsearchptr (mgsearch);
|
---|
173 | cserver->add_source (mggdbmsource);
|
---|
174 |
|
---|
175 | // inform collection server and everything it contains about its
|
---|
176 | // collection name
|
---|
177 | cserver->configure ("collection", *thiscol);
|
---|
178 |
|
---|
179 | nproto.add_collectserver (cserver);
|
---|
180 | thiscol ++;
|
---|
181 | }
|
---|
182 |
|
---|
183 | // add the protocol to the receptionist
|
---|
184 | recpt.add_protocol (&nproto);
|
---|
185 |
|
---|
186 | // add other converters
|
---|
187 | utf8inconvertclass utf8inconvert;
|
---|
188 | utf8outconvertclass utf8outconvert;
|
---|
189 | recpt.add_converter ("u", &utf8inconvert, &utf8outconvert);
|
---|
190 |
|
---|
191 | mapinconvertclass gbinconvert;
|
---|
192 | gbinconvert.setmapfile (GSDL_GSDLHOME, "gbku", 0x25a1);
|
---|
193 | mapoutconvertclass gboutconvert;
|
---|
194 | gboutconvert.setmapfile (GSDL_GSDLHOME, "ugbk", 0xa1f5);
|
---|
195 | recpt.add_converter ("g", &gbinconvert, &gboutconvert);
|
---|
196 |
|
---|
197 | // the list of actions. Note: these actions will become invalid
|
---|
198 | // at the end of this function.
|
---|
199 | statusaction astatusaction;
|
---|
200 | astatusaction.set_receptionist (&recpt);
|
---|
201 | recpt.add_action (&astatusaction);
|
---|
202 |
|
---|
203 | pageaction apageaction;
|
---|
204 | apageaction.set_receptionist (&recpt);
|
---|
205 | recpt.add_action (&apageaction);
|
---|
206 |
|
---|
207 | pingaction apingaction;
|
---|
208 | recpt.add_action (&apingaction);
|
---|
209 |
|
---|
210 | queryaction aqueryaction;
|
---|
211 | recpt.add_action (&aqueryaction);
|
---|
212 |
|
---|
213 | documentaction adocumentaction;
|
---|
214 | adocumentaction.set_receptionist (&recpt);
|
---|
215 | recpt.add_action (&adocumentaction);
|
---|
216 |
|
---|
217 | usersaction ausersaction;
|
---|
218 | recpt.add_action (&ausersaction);
|
---|
219 |
|
---|
220 | extlinkaction anextlinkaction;
|
---|
221 | recpt.add_action (&anextlinkaction);
|
---|
222 |
|
---|
223 | buildaction abuildaction;
|
---|
224 | abuildaction.set_receptionist (&recpt);
|
---|
225 | recpt.add_action (&abuildaction);
|
---|
226 |
|
---|
227 | authenaction aauthenaction;
|
---|
228 | aauthenaction.set_receptionist(&recpt);
|
---|
229 | recpt.add_action (&aauthenaction);
|
---|
230 |
|
---|
231 | // list of browsers
|
---|
232 | vlistbrowserclass avlistbrowserclass;
|
---|
233 | recpt.add_browser (&avlistbrowserclass);
|
---|
234 | recpt.setdefaultbrowser ("VList");
|
---|
235 |
|
---|
236 | hlistbrowserclass ahlistbrowserclass;
|
---|
237 | recpt.add_browser (&ahlistbrowserclass);
|
---|
238 |
|
---|
239 | datelistbrowserclass adatelistbrowserclass;
|
---|
240 | recpt.add_browser (&adatelistbrowserclass);
|
---|
241 |
|
---|
242 | invbrowserclass ainvbrowserclass;
|
---|
243 | recpt.add_browser (&ainvbrowserclass);
|
---|
244 |
|
---|
245 | pagedbrowserclass apagedbrowserclass;
|
---|
246 | recpt.add_browser (&apagedbrowserclass);
|
---|
247 |
|
---|
248 | htmlbrowserclass ahtmlbrowserclass;
|
---|
249 | recpt.add_browser (&ahtmlbrowserclass);
|
---|
250 |
|
---|
251 | cgiwrapper (recpt, "");
|
---|
252 | return 0;
|
---|
253 | }
|
---|
254 |
|
---|