summaryrefslogtreecommitdiffabout
path: root/include/sitecing/sitecing_interface_cgi.h
blob: da538d69460ee8ae3b27e7ab42a2fc77e463daa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef __SITECING_SITECING_INTERFACE_CGI_H
#define __SITECING_SITECING_INTERFACE_CGI_H

#include <sstream>
#include <string>
#include <map>
#include "kingate/cgi_gateway.h"
#include "sitecing/sitecing_interface.h"
#include "sitecing/sitespace.h"

/**
 * @file
 * @brief The sitecing_interface_cgi class declaration.
 */

namespace sitecing {
    using namespace std;

    /**
     * The interface to site-C-ing core for the CGI component.
     */
    class sitecing_interface_cgi : public sitecing_interface {
	public:
	    /**
	     * Pointer to the CGI gateway interface.
	     */
	    kingate::cgi_gateway* cgigw;
	    /**
	     * Type for the map of headers to spit out.
	     */
	    typedef map<string,string> headers_t;
	    /**
	     * The list of headers to spit out.
	     */
	    headers_t headers;
	    /**
	     * Here is where we prebuffer output.
	     */
	    stringbuf prebuffer;
	    /**
	     * Output stream, initially going to prebuffer.
	     */
	    ostream outs;
	    /**
	     * Have headers been sent yet?
	     */
	    bool headers_flushed;
	    /**
	     * Pointer to the sitespace object.
	     */
	    sitespace *ss; // XXX: or does it belong to the generic interface? or should this 'generic' interface exist at all?

	    /**
	     * @param s Pointer to the sitespace object.
	     */
	    sitecing_interface_cgi(sitespace *s);

	    /**
	     * Set up interface for the (possibly, new) cgi gateway object,
	     * reset headers, empty buffer, etc.
	     */
	    void prepare(kingate::cgi_gateway *cg);
	    /**
	     * Flush output stream.
	     */
	    void flush(bool keep_buffering=false);
	    /**
	     * Send headers to the output stream, if we haven't yet.
	     */
	    void flush_headers();
	    /**
	     * Are we buffering now?
	     */
	    bool is_buffering();
	    /**
	     * Control output buffering.
	     */
	    void set_buffering(bool do_buffer);

    };
}

#endif /* __SITECING_SITECING_INTERFACE_CGI_H */