1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * librarymain.cpp --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * PUT COPYRIGHT NOTICE HERE
|
---|
7 | *
|
---|
8 | * $Id: librarymain.cpp 390 1999-07-15 06:08:55Z rjmcnab $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 | /*
|
---|
13 | $Log$
|
---|
14 | Revision 1.8 1999/07/15 06:08:55 rjmcnab
|
---|
15 | Moved the adding of the actions to librarymain so that they can
|
---|
16 | be overriden easier.
|
---|
17 |
|
---|
18 | Revision 1.7 1999/06/15 01:56:12 sjboddie
|
---|
19 | Got multiple collections working
|
---|
20 |
|
---|
21 | Revision 1.6 1999/05/10 03:40:39 sjboddie
|
---|
22 | lots of changes - slowly getting document action sorted out
|
---|
23 |
|
---|
24 | Revision 1.5 1999/04/19 23:56:10 rjmcnab
|
---|
25 | Finished the gdbm metadata stuff
|
---|
26 |
|
---|
27 | Revision 1.4 1999/04/12 03:45:05 rjmcnab
|
---|
28 | Finished the query filter.
|
---|
29 |
|
---|
30 | Revision 1.3 1999/04/06 22:20:35 rjmcnab
|
---|
31 | Got browsefilter working.
|
---|
32 |
|
---|
33 | Revision 1.2 1999/03/05 03:53:54 sjboddie
|
---|
34 |
|
---|
35 | fixed some bugs
|
---|
36 |
|
---|
37 | Revision 1.1 1999/02/21 22:35:22 rjmcnab
|
---|
38 |
|
---|
39 | Initial revision.
|
---|
40 |
|
---|
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 "queryfilter.h"
|
---|
51 | #include "infodbclass.h"
|
---|
52 | #include "mgsearch.h"
|
---|
53 | #include "mggdbmsource.h"
|
---|
54 | #include <assert.h>
|
---|
55 |
|
---|
56 | #include "action.h"
|
---|
57 | #include "statusaction.h"
|
---|
58 | #include "pageaction.h"
|
---|
59 | #include "pingaction.h"
|
---|
60 | #include "queryaction.h"
|
---|
61 | #include "documentaction.h"
|
---|
62 | #include "authenaction.h"
|
---|
63 | #include "usersaction.h"
|
---|
64 | #include "authenaction.h"
|
---|
65 |
|
---|
66 |
|
---|
67 | int main () {
|
---|
68 | receptionist recpt;
|
---|
69 | nullproto nproto;
|
---|
70 |
|
---|
71 | // add a collection server for each collection
|
---|
72 | text_tarray collections;
|
---|
73 | collections.push_back ("gberg");
|
---|
74 | collections.push_back ("hdl");
|
---|
75 |
|
---|
76 | text_tarray::const_iterator thiscol = collections.begin();
|
---|
77 | text_tarray::const_iterator endcol = collections.end();
|
---|
78 |
|
---|
79 | while (thiscol != endcol) {
|
---|
80 |
|
---|
81 | // this memory is created but never destroyed
|
---|
82 | // we're also not doing any error checking to make sure we didn't
|
---|
83 | // run out of memory
|
---|
84 | collectserver *cserver = new collectserver();
|
---|
85 | gdbmclass *gdbmhandler = new gdbmclass();
|
---|
86 | mgsearchclass *mgsearch = new mgsearchclass();
|
---|
87 |
|
---|
88 | // add a null filter
|
---|
89 | filterclass *filter = new filterclass ();
|
---|
90 | cserver->add_filter (filter);
|
---|
91 |
|
---|
92 | // add a browse filter
|
---|
93 | browsefilterclass *browsefilter = new browsefilterclass();
|
---|
94 | browsefilter->set_gdbmptr (gdbmhandler);
|
---|
95 | cserver->add_filter (browsefilter);
|
---|
96 |
|
---|
97 | // add a query filter
|
---|
98 | queryfilterclass *queryfilter = new queryfilterclass();
|
---|
99 | queryfilter->set_gdbmptr (gdbmhandler);
|
---|
100 | queryfilter->set_mgsearchptr (mgsearch);
|
---|
101 | cserver->add_filter (queryfilter);
|
---|
102 |
|
---|
103 | // add a mg and gdbm source
|
---|
104 | mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
|
---|
105 | mggdbmsource->set_gdbmptr (gdbmhandler);
|
---|
106 | mggdbmsource->set_mgsearchptr (mgsearch);
|
---|
107 | cserver->add_source (mggdbmsource);
|
---|
108 |
|
---|
109 | // inform collection server and everything it contains about its
|
---|
110 | // collection name
|
---|
111 | cserver->configure ("collection", *thiscol);
|
---|
112 |
|
---|
113 | nproto.add_collectserver (cserver);
|
---|
114 | thiscol ++;
|
---|
115 | }
|
---|
116 |
|
---|
117 | // add the protocol to the receptionist
|
---|
118 | recpt.add_protocol (&nproto);
|
---|
119 |
|
---|
120 | // the list of actions. Note: these actions will become invalid
|
---|
121 | // at the end of this function.
|
---|
122 | statusaction astatusaction;
|
---|
123 | astatusaction.set_receptionist (&recpt);
|
---|
124 | recpt.add_action (&astatusaction);
|
---|
125 |
|
---|
126 | pageaction apageaction;
|
---|
127 | apageaction.set_receptionist (&recpt);
|
---|
128 | recpt.add_action (&apageaction);
|
---|
129 |
|
---|
130 | pingaction apingaction;
|
---|
131 | recpt.add_action (&apingaction);
|
---|
132 |
|
---|
133 | queryaction aqueryaction;
|
---|
134 | recpt.add_action (&aqueryaction);
|
---|
135 |
|
---|
136 | documentaction adocumentaction;
|
---|
137 | recpt.add_action (&adocumentaction);
|
---|
138 |
|
---|
139 | usersaction ausersaction;
|
---|
140 | recpt.add_action (&ausersaction);
|
---|
141 |
|
---|
142 | authenaction aauthenaction;
|
---|
143 | aauthenaction.set_receptionist(&recpt);
|
---|
144 | recpt.add_action (&aauthenaction);
|
---|
145 |
|
---|
146 | cgiwrapper (recpt, "");
|
---|
147 | return 0;
|
---|
148 | }
|
---|
149 |
|
---|