source: trunk/gsdl/src/recpt/receptionist.h@ 595

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

added some file locking stuff for logging. Windows still needs to
be done.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 7.2 KB
RevLine 
[108]1/**********************************************************************
2 *
3 * receptionist.h -- a web interface for the gsdl
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
[533]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.
[108]9 *
[533]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 *
[108]24 * $Id: receptionist.h 595 1999-09-16 21:38:17Z sjboddie $
25 *
26 *********************************************************************/
27
28
29#ifndef RECEPTIONIST_H
30#define RECEPTIONIST_H
31
[145]32#include "gsdlconf.h"
[108]33#include "text_t.h"
34#include "cgiargs.h"
[155]35#include "display.h"
36#include "action.h"
[165]37#include "recptproto.h"
38#include "converter.h"
[108]39
[530]40// the MACROPRECEDENCE macro is used as a default. override
41// it using something like:
42//
43// macroprecedence c,l
44//
45// in your configuration file
[108]46#ifndef MACROPRECEDENCE
[530]47#define MACROPRECEDENCE "c,l"
[108]48#endif
49
50
[165]51struct recptconf {
52 text_t gsdlhome;
53 text_t collection; // will equal "" in 'general' mode
54 text_t collectdir; // will equal gsdlhome in 'general' mode
[305]55 text_t httpprefix;
[165]56 text_t httpimg;
57 text_t gwcgi;
58 text_tarray macrofiles;
59 text_t saveconf;
[526]60 bool usecookies; // true if we want cookies set
61 bool logcgiargs; // true if we want to log cgi arguments
[530]62
63 text_tmap pageparams;
64 text_t macroprecedence;
[526]65
66 void clear ();
67 recptconf () {clear();}
[165]68};
69
70
[108]71class receptionist {
[165]72protected:
73 recptconf configinfo;
74
75 cgiargsinfoclass argsinfo;
76 actionmapclass actions;
77 recptprotolistclass protocols;
78 displayclass disp;
79 convertinfoclass converters;
[418]80 ColInfoResponse_t collectinfo;
[296]81
[173]82 // prepare_page sets up page parameters, sets display macros
83 // and opens the page ready for output
[418]84 virtual void prepare_page (action *a, cgiargsclass &args, recptproto *collectproto,
85 outconvertclass &outconvert, ostream &logout);
[438]86
87 virtual void translate_OIDs (cgiargsclass &args, recptproto *collectproto, ostream &logout);
88
[463]89 bool get_cookie (text_t &cookie);
90 bool get_cookie ();
[165]91
[456]92 virtual void define_general_macros (cgiargsclass &args, recptproto *collectproto,
93 outconvertclass &outconvert, ostream &logout);
94
[595]95 bool append_logstr (const text_t &filename, const text_t &logstr,
96 ostream &logout);
97
[108]98public:
[388]99 receptionist ();
[108]100 virtual ~receptionist() {}
101
[165]102 // add_action makes another action available to the receptionist
103 // the action remains the property of the calling code and that
104 // code should destroy the action after the recptionist has been
105 // destroyed.
[530]106 void add_action (action *theaction);
[165]107 actionmapclass *get_actionmap_ptr () {return &actions;}
[108]108
[165]109 // add_protocol makes another protocol available to the receptionist
110 // without any protocols, no collections will be available. The
111 // protocols remain the property of the calling code.
112 void add_protocol (recptproto *theprotocol) {protocols.addrecptproto(theprotocol);}
113 recptprotolistclass *get_recptprotolist_ptr () {return &protocols;}
114
115 // add_converter makes another converter available to the receptionist.
116 // Converters are needed to display pages using different encodings.
117 // The converters remain the property of the calling code.
118 void add_converter (const text_t &name, inconvertclass *inconverter,
[456]119 rzwsoutconvertclass *outconverter) {
120 converters.add_converter(name, inconverter, outconverter);}
[165]121 convertinfoclass *get_convertinfo_ptr () {return &converters;}
[456]122
123
[165]124 // configure should be called for each line in the
125 // configuration files to configure the receptionist and everything
126 // it contains. The configuration should take place after everything
127 // has been added but before the initialisation.
[418]128 virtual void configure (const text_t &key, const text_tarray &cfgline);
129 virtual void configure (const text_t &key, const text_t &value);
[165]130 const recptconf &get_configinfo () {return configinfo;}
131 cgiargsinfoclass *get_cgiargsinfo_ptr () {return &argsinfo;}
132
[108]133
[165]134 // init should be called after all the actions, protocols, and
135 // converters have been added to the receptionist and after everything
136 // has been configured but before any pages are created.
[108]137 // It returns true on success and false on failure. If false is
138 // returned getpage should not be called (without producing
139 // meaningless output), instead an error page should be
140 // produced by the calling code.
[418]141 virtual bool init (ostream &logout);
[108]142
143 // There are two ways to produce a page. You can either call parse_cgi_args,
[155]144 // get_cgihead_info, and produce_content or you can just call parse_cgi_args and
145 // produce_cgi_page (which will be satisfactory in most cases). You might want to call
[108]146 // parse_cgi_args, get_cgihead_info, and produce_content when you want to
[155]147 // interface directly with a web server for which the standard header is inappropriate.
[108]148
149 // parse_cgi_args parses cgi arguments into an argument class.
[155]150 // This function should be called for each page request. It returns false
151 // if there was a major problem with the cgi arguments.
[418]152 virtual bool parse_cgi_args (const text_t &argstr, cgiargsclass &args, ostream &logout);
[108]153
[463]154 virtual bool log_cgi_args (cgiargsclass &args, ostream &logout);
155
[155]156 // produce_cgi_page will call get_cgihead_info and
157 // produce_content in the appropriate way to output a cgi header and
158 // the page content (if needed). If a page could not be created it
159 // will return false
[418]160 virtual bool produce_cgi_page (cgiargsclass &args, ostream &contentout,
161 ostream &logout);
[456]162
[108]163 // get_cgihead_info determines the cgi header information for
164 // a set of cgi arguments. If response contains location then
165 // response_data contains the redirect address. If reponse
166 // contains content then reponse_data contains the content-type.
167 // Note that images can now be produced by the receptionist.
[418]168 virtual void get_cgihead_info (cgiargsclass &args, response_t &response,
169 text_t &response_data, ostream &logout);
[456]170
[108]171 // produce the page content
[418]172 virtual bool produce_content (cgiargsclass &args, ostream &contentout,
173 ostream &logout);
[456]174
[108]175 // returns the compressed argument ("e") corresponding to the argument
176 // list. This can be used to save preferences between sessions.
[362]177 text_t get_compressed_arg (cgiargsclass &args, ostream &logout);
[456]178
[108]179protected:
[155]180 // will read in all the macro files. If one is not found an
181 // error message will be written to logout and the method will
182 // return false.
[418]183 virtual bool read_macrofiles (ostream &logout);
[108]184
[155]185 // check_mainargs will check all the main arguments. If a major
186 // error is found it will return false and no cgi page should
187 // be created using the arguments.
188 virtual bool check_mainargs (cgiargsclass &args, ostream &logout);
[108]189};
190
191
192#endif
Note: See TracBrowser for help on using the repository browser.