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

Last change on this file since 530 was 530, checked in by rjmcnab, 25 years ago

Made the page parameters configurable. Now the page parameters must
correspond to cgi arguments in name and value (ie language=zh should now
be l=zh) which makes things more consistent anyway. Removed a couple of
specialised NZDL page parameters.

Moved the combining of the cgi arguments so that the receptionist does
all the configuration now.

Made the macro precedence configurable.

Made cgi arguments totally configurable. Now any piece of information about
a cgi argument can be configured meaning that cgi arguments can be declared
from the configuration file.

Removed the argdefault configuration argument. This should now be done
using cgiarg.

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