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

Last change on this file since 586 was 586, checked in by sjboddie, 25 years ago

included utf8 converter

  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 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 * $Id: librarymain.cpp 586 1999-09-14 22:42:06Z sjboddie $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.12 1999/09/14 22:42:06 sjboddie
31 included utf8 converter
32
33 Revision 1.11 1999/09/14 22:03:27 sjboddie
34 now reads in collections from a file to avoid recompiling
35
36 Revision 1.10 1999/09/08 00:51:11 sjboddie
37 removed old interface stuff
38
39 Revision 1.9 1999/09/07 04:56:56 sjboddie
40 added GPL notice
41
42 Revision 1.8 1999/07/15 06:08:55 rjmcnab
43 Moved the adding of the actions to librarymain so that they can
44 be overriden easier.
45
46 Revision 1.7 1999/06/15 01:56:12 sjboddie
47 Got multiple collections working
48
49 Revision 1.6 1999/05/10 03:40:39 sjboddie
50 lots of changes - slowly getting document action sorted out
51
52 Revision 1.5 1999/04/19 23:56:10 rjmcnab
53 Finished the gdbm metadata stuff
54
55 Revision 1.4 1999/04/12 03:45:05 rjmcnab
56 Finished the query filter.
57
58 Revision 1.3 1999/04/06 22:20:35 rjmcnab
59 Got browsefilter working.
60
61 Revision 1.2 1999/03/05 03:53:54 sjboddie
62
63 fixed some bugs
64
65 Revision 1.1 1999/02/21 22:35:22 rjmcnab
66
67 Initial revision.
68
69 */
70
71
72#include "receptionist.h"
73#include "cgiwrapper.h"
74#include "nullproto.h"
75#include "collectserver.h"
76#include "filter.h"
77#include "browsefilter.h"
78#include "queryfilter.h"
79#include "infodbclass.h"
80#include "mgsearch.h"
81#include "mggdbmsource.h"
82#include <assert.h>
83
84#include "action.h"
85#include "statusaction.h"
86#include "pageaction.h"
87#include "pingaction.h"
88#include "queryaction.h"
89#include "documentaction.h"
90#include "authenaction.h"
91#include "usersaction.h"
92#include "authenaction.h"
93
94#include "gsdlhome.h"
95
96int main () {
97 receptionist recpt;
98 nullproto nproto;
99
100 text_tarray collections;
101
102 ifstream collist (GSDL_GSDLHOME "/etc/collections.txt");
103 if (!collist) {
104 exit(1);
105 }
106 char collection[100];
107 while (!collist.eof()) {
108 collist.getline (collection, 100);
109 if (collection[0] != '\0')
110 collections.push_back (collection);
111 }
112 collist.close();
113
114 text_tarray::const_iterator thiscol = collections.begin();
115 text_tarray::const_iterator endcol = collections.end();
116
117 while (thiscol != endcol) {
118
119 // this memory is created but never destroyed
120 // we're also not doing any error checking to make sure we didn't
121 // run out of memory
122 collectserver *cserver = new collectserver();
123 gdbmclass *gdbmhandler = new gdbmclass();
124 mgsearchclass *mgsearch = new mgsearchclass();
125
126 // add a null filter
127 filterclass *filter = new filterclass ();
128 cserver->add_filter (filter);
129
130 // add a browse filter
131 browsefilterclass *browsefilter = new browsefilterclass();
132 browsefilter->set_gdbmptr (gdbmhandler);
133 cserver->add_filter (browsefilter);
134
135 // add a query filter
136 queryfilterclass *queryfilter = new queryfilterclass();
137 queryfilter->set_gdbmptr (gdbmhandler);
138 queryfilter->set_mgsearchptr (mgsearch);
139 cserver->add_filter (queryfilter);
140
141 // add a mg and gdbm source
142 mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
143 mggdbmsource->set_gdbmptr (gdbmhandler);
144 mggdbmsource->set_mgsearchptr (mgsearch);
145 cserver->add_source (mggdbmsource);
146
147 // inform collection server and everything it contains about its
148 // collection name
149 cserver->configure ("collection", *thiscol);
150
151 nproto.add_collectserver (cserver);
152 thiscol ++;
153 }
154
155 // add the protocol to the receptionist
156 recpt.add_protocol (&nproto);
157
158 // add other converters
159 utf8inconvertclass utf8inconvert;
160 utf8outconvertclass utf8outconvert;
161 recpt.add_converter ("u", &utf8inconvert, &utf8outconvert);
162
163 // the list of actions. Note: these actions will become invalid
164 // at the end of this function.
165 statusaction astatusaction;
166 astatusaction.set_receptionist (&recpt);
167 recpt.add_action (&astatusaction);
168
169 pageaction apageaction;
170 apageaction.set_receptionist (&recpt);
171 recpt.add_action (&apageaction);
172
173 pingaction apingaction;
174 recpt.add_action (&apingaction);
175
176 queryaction aqueryaction;
177 recpt.add_action (&aqueryaction);
178
179 documentaction adocumentaction;
180 recpt.add_action (&adocumentaction);
181
182 usersaction ausersaction;
183 recpt.add_action (&ausersaction);
184
185 authenaction aauthenaction;
186 aauthenaction.set_receptionist(&recpt);
187 recpt.add_action (&aauthenaction);
188
189 cgiwrapper (recpt, "");
190 return 0;
191}
192
Note: See TracBrowser for help on using the repository browser.