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

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

now reads in collections from a file to avoid recompiling

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