Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef DBMS_OWA_H
#define DBMS_OWA_H
 
#include <string>
#include <unordered_map>
#include <vector>
 
#ifdef __cplusplus
extern "C"
{
#endif
 
#include "postgres.h"
#include "fmgr.h"
#include "datatype/timestamp.h"
 
Datum owa_init_cgi_env(PG_FUNCTION_ARGS);
Datum owa_init_cgi_env2(PG_FUNCTION_ARGS);
Datum owa_cookie_send(PG_FUNCTION_ARGS);
Datum owa_cookie_send2(PG_FUNCTION_ARGS);
Datum owa_cache_disable(PG_FUNCTION_ARGS);
Datum owa_cache_set_cache(PG_FUNCTION_ARGS);
Datum owa_cache_set_expires(PG_FUNCTION_ARGS);
Datum owa_cache_set_not_modified(PG_FUNCTION_ARGS);
Datum owa_cache_set_surrogate_control(PG_FUNCTION_ARGS);
Datum owa_cache_set_request_etag(PG_FUNCTION_ARGS);
Datum owa_cache_set_request_level(PG_FUNCTION_ARGS);
Datum owa_cache_get_etag(PG_FUNCTION_ARGS);
Datum owa_cache_get_etag2(PG_FUNCTION_ARGS);
Datum owa_cache_get_level(PG_FUNCTION_ARGS);
Datum owa_util_get_cgi_env(PG_FUNCTION_ARGS);
Datum owa_util_showpage(PG_FUNCTION_ARGS);
Datum owa_util_showpage_utils(PG_FUNCTION_ARGS);
 
#ifdef __cplusplus
} /* extern "C" */
 
namespace Owa
{
enum class EventKind
{
    BodyText,
    Cookie,
    Cache,
    Status
};
 
enum class PageState
{
    HeadersOpen,
    BodyStarted
};
 
struct CookieData
{
    std::string name;
    std::string value;
    bool has_expires = false;
    TimestampTz expires = 0;
    bool has_path = false;
    std::string path;
    bool has_domain = false;
    std::string domain;
    bool has_secure = false;
};
 
struct EventEntry
{
    EventKind kind;
    SubTransactionId subxid;
    std::string bodyText;
    CookieData cookieData;
    std::string cacheEtag;
    std::string cacheLevel;
    int32 cacheExpires = 0;
    bool cacheDisabled = false;
    std::string cacheSurrogateControl;
    int32 statusCode = 0;
    std::string statusReason;
};
 
struct PageContext
{
    std::vector<EventEntry> events;
    PageState state = PageState::HeadersOpen;
    bool hasRequestCacheEtag = false;
    std::string requestCacheEtag;
    bool hasRequestCacheLevel = false;
    std::string requestCacheLevel;
    bool hasRequestProtocol = false;
    std::string requestProtocol;
    std::unordered_map<std::string, std::string> cgiValues;
};
 
extern PageContext *current_page_context_;
extern bool xact_callback_registered_;
extern bool subxact_callback_registered_;
 
std::string textToString(text *value);
void validateHeaderValue(const std::string &arg_value, const char *arg_name);
void validateCookieName(const std::string &cookie_name);
void validateCacheEtag(const std::string &etag_value);
std::string validateAndNormalizeCacheLevel(const std::string &level_value);
std::string renderCacheHeaders(const std::string &etag_value, const std::string &level_value);
void validateCacheExpires(int32 expires_value);
std::string renderExpiresHeaders(int32 expires_value, const std::string &level_value);
void validateSurrogateControlValue(const std::string &value);
void ensureCallbackRegistered(void);
void ensurePageContextViaServiceInit(void);
void resetPageContext(void);
void appendHtpText(const char *text, bool add_new_line);
std::string normalizeCgiName(const std::string &cgi_name);
}
#endif
 
#endif /* DBMS_OWA_H */