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

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

added httpprefix

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