summaryrefslogtreecommitdiff
path: root/csvncgi/ctx.h
blob: fc074db7d43fe7c0de65b0d2d6824c8785fc04e8 (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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#ifndef    __CONTEXT_H
#define    __CONTEXT_H

#ifdef __cplusplus
extern "C" {
#endif


#define CONTEXT_MEM_SIZE  524288

struct __context
{
  void *_cur_brk;
  unsigned char _mem[CONTEXT_MEM_SIZE];
};

extern struct __context *pmctx;

#define __cur_brk  (*((void **)&(pmctx->_cur_brk)))
#define __mem      ((unsigned char *)&((pmctx->_mem)[0]))

extern void __mctx_init( void );
extern void *__sbrk( int incr );


struct csvn_tmplt_vars {
  const char *css;
  const char *owner;
  const char *author;
  const char *description;
  const char *keywords;
  const char *title;
  const char *favicon_path;
  const char *syntax_highlight_css;
  const char *logo;
  const char *logo_alt;
  const char *logo_link;
  const char *home_page;
  const char *snapshots;
  const char *status_line;
  const char *main_menu_logo;
  const char *main_menu_item;
  const char *left_menu_items;
  const char *popup_menu_items;
  const char *right_menu_items;
  const char *copyright_notice;
  const char *copyright;
  const char *page_type;
  const char *page_size;
  const char *num_of_repos;
};

#define KIND_DIR     0
#define KIND_FILE    1
#define KIND_UNKNOWN 2
#define CSVN_INFO_INIT  (struct csvn_info) { .kind = KIND_UNKNOWN, .revision = 0, .author = NULL, .date = 0, .mime = NULL, .lang = NULL }

struct csvn_info {
  int kind;
  int revision;
  const char *author;
  time_t date;
  const char *mime;
  const char *lang;
};

struct csvn_repository {
  const char       *name;
  struct csvn_info  info;
  const char       *repo_root;
  const char       *relative_path;
  struct csvn_info  relative_info;
  const char       *relative_html;
  const char       *relative_href;
  const char       *search_placeholder;
  const char       *trunk;    /* trunk    directory name */
  const char       *branches; /* branches directory name */
  const char       *tags;     /* tags     directory name */
  const char       *checkout_prefix;
  const char       *checkout_ro_prefix;
  int               nbranches; /* number of branches */
  int               ntags;     /* number of tags     */
};

struct csvn_page {
  time_t modified;
  time_t expires;
  size_t size;
  const char *mimetype;
  const char *charset;
  int status;
  const char *status_message;
  const char *header;
  const char *footer;
};

struct csvn_environment {
  const char *http_host;
  const char *https;
  const char *no_http;
  const char *path_info;
  const char *query_string;
  const char *request_uri;
  const char *request_scheme;
  const char *request_method;
  const char *script_name;
  const char *server_name;
  const char *server_port;
  const char *http_cookie;
  unsigned int content_lenght;
  const char *http_root;
  int authenticated;
};

struct csvn_query {
  int ofs;
  int rev;
  const char *revision;
  const char *operation;
  const char *search;
};

struct csvn_versions {
  const char *subversion;
  const char *nginx;
  const char *csvn;
};

struct csvn_promotion {
  const char *analytic_links;
  const char *analytic_scripts;
  int donate;
  const char *donate_css;
  const char *donate_html;
  const char *donate_js;
  const char *donate_header;
  const char *donate_purpose;
};

struct csvn_context {
  struct csvn_environment  env;
  struct csvn_promotion    promo;
  struct csvn_query        query;
  struct csvn_page         page;
  struct csvn_tmplt_vars   vars;
  struct csvn_repository   repo;
  struct csvn_versions     vers;
};


extern const char *ptype_repolist;
extern const char *ptype_repo;

extern struct csvn_context ctx;

/*
  header/footer template variables:
  ================================
  ${css}
  ${owner}
  ${author}
  ${description}
  ${keywords}
  ${title}
  ${favicon-path}
  ${syntax-highlight-css}
  ${logo}
  ${logo-alt}
  ${logo-link}
  ${home-page}
  ${snapshots}
  ${status-line}
  ${main-menu-logo}
  ${main-menu-item}
  ${left-menu-items}
  ${popup-menu-items}
  ${right-menu-items}
  ${relative-html}
  ${search-placeholder}

  ${analytic-links}
  ${analytic-scripts}
  ${donate-css}
  ${donate-html}
  ${donate-js}
  ${donate-header}
  ${donate-purpose}

  ${svn-version}
  ${nginx-version}
  ${csvn-version}
  ${copyright-notice}
  ${copyright}

  ${page-type}
  ${page-size}
  ${num-of-repos}
 */

extern void csvn_prepare_context( void );
extern void csvn_prepare_template_variables( void );
extern void csvn_release_template_variables( void );

extern void csvn_parse_query( void );

extern int ctx_grab_int_query_param( const char *name );
extern const char *ctx_remove_query_param( const char *query_string, const char *name );


#ifdef __cplusplus
}
#endif

#endif  /* __CONTEXT_H */