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

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

-fixed up location redirection
-added some usage logging, also now set a GSDL_UID cookie. Logging
does NOT presently lock the log file while it's in use. That has yet
to be done.

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