libapreq2-2.17: include/apreq_module.h Source File

Apache HTTP Server Request Library

apreq_module.h
Go to the documentation of this file.
1 /*
2 ** Licensed to the Apache Software Foundation (ASF) under one or more
3 ** contributor license agreements. See the NOTICE file distributed with
4 ** this work for additional information regarding copyright ownership.
5 ** The ASF licenses this file to You under the Apache License, Version 2.0
6 ** (the "License"); you may not use this file except in compliance with
7 ** the License. You may obtain a copy of the License at
8 **
9 ** http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17
18 #ifndef APREQ_MODULE_H
19 #define APREQ_MODULE_H
20
21 #include "apreq_cookie.h"
22 #include "apreq_parser.h"
23 #include "apreq_error.h"
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
41 typedef struct apreq_handle_t {
43 const struct apreq_module_t *module;
45 apr_pool_t *pool;
47 apr_bucket_alloc_t *bucket_alloc;
48
49 } apreq_handle_t;
50
56 typedef struct apreq_module_t {
58 const char *name;
60 apr_uint32_t magic_number;
61
63 apr_status_t (*jar)(apreq_handle_t *, const apr_table_t **);
65 apr_status_t (*args)(apreq_handle_t *, const apr_table_t **);
67 apr_status_t (*body)(apreq_handle_t *, const apr_table_t **);
68
70 apreq_cookie_t *(*jar_get)(apreq_handle_t *, const char *);
72 apreq_param_t *(*args_get)(apreq_handle_t *, const char *);
74 apreq_param_t *(*body_get)(apreq_handle_t *, const char *);
75
77 apr_status_t (*parser_get)(apreq_handle_t *, const apreq_parser_t **);
79 apr_status_t (*parser_set)(apreq_handle_t *, apreq_parser_t *);
81 apr_status_t (*hook_add)(apreq_handle_t *, apreq_hook_t *);
82
84 apr_status_t (*brigade_limit_get)(apreq_handle_t *, apr_size_t *);
86 apr_status_t (*brigade_limit_set)(apreq_handle_t *, apr_size_t);
87
89 apr_status_t (*read_limit_get)(apreq_handle_t *, apr_uint64_t *);
91 apr_status_t (*read_limit_set)(apreq_handle_t *, apr_uint64_t);
92
94 apr_status_t (*temp_dir_get)(apreq_handle_t *, const char **);
96 apr_status_t (*temp_dir_set)(apreq_handle_t *, const char *);
97
98 } apreq_module_t;
99
100
109 static APR_INLINE
110 unsigned apreq_module_status_is_error(apr_status_t s) {
111 switch (s) {
112 case APR_SUCCESS:
113 case APR_INCOMPLETE:
114 case APR_EINIT:
115 case APREQ_ERROR_NODATA:
116 case APREQ_ERROR_NOPARSER:
117 case APREQ_ERROR_NOHEADER:
118 return 0;
119 default:
120 return 1;
121 }
122 }
123
124
134 static APR_INLINE
135 apr_status_t apreq_jar(apreq_handle_t *req, const apr_table_t **t)
136 {
137 return req->module->jar(req,t);
138 }
139
149 static APR_INLINE
150 apr_status_t apreq_args(apreq_handle_t *req, const apr_table_t **t)
151 {
152 return req->module->args(req,t);
153 }
154
164 static APR_INLINE
165 apr_status_t apreq_body(apreq_handle_t *req, const apr_table_t **t)
166 {
167 return req->module->body(req, t);
168 }
169
170
179 static APR_INLINE
180 apreq_cookie_t *apreq_jar_get(apreq_handle_t *req, const char *name)
181 {
182 return req->module->jar_get(req, name);
183 }
184
193 static APR_INLINE
194 apreq_param_t *apreq_args_get(apreq_handle_t *req, const char *name)
195 {
196 return req->module->args_get(req, name);
197 }
198
207 static APR_INLINE
208 apreq_param_t *apreq_body_get(apreq_handle_t *req, const char *name)
209 {
210 return req->module->body_get(req, name);
211 }
212
222 static APR_INLINE
223 apr_status_t apreq_parser_get(apreq_handle_t *req,
224 const apreq_parser_t **parser)
225 {
226 return req->module->parser_get(req, parser);
227 }
228
229
238 static APR_INLINE
239 apr_status_t apreq_parser_set(apreq_handle_t *req,
240 apreq_parser_t *parser)
241 {
242 return req->module->parser_set(req, parser);
243 }
244
253 static APR_INLINE
254 apr_status_t apreq_hook_add(apreq_handle_t *req, apreq_hook_t *hook)
255 {
256 return req->module->hook_add(req, hook);
257 }
258
259
269 static APR_INLINE
270 apr_status_t apreq_brigade_limit_set(apreq_handle_t *req,
271 apr_size_t bytes)
272 {
273 return req->module->brigade_limit_set(req, bytes);
274 }
275
285 static APR_INLINE
286 apr_status_t apreq_brigade_limit_get(apreq_handle_t *req,
287 apr_size_t *bytes)
288 {
289 return req->module->brigade_limit_get(req, bytes);
290 }
291
301 static APR_INLINE
302 apr_status_t apreq_read_limit_set(apreq_handle_t *req,
303 apr_uint64_t bytes)
304 {
305 return req->module->read_limit_set(req, bytes);
306 }
307
317 static APR_INLINE
318 apr_status_t apreq_read_limit_get(apreq_handle_t *req,
319 apr_uint64_t *bytes)
320 {
321 return req->module->read_limit_get(req, bytes);
322 }
323
332 static APR_INLINE
333 apr_status_t apreq_temp_dir_set(apreq_handle_t *req, const char *path)
334 {
335 return req->module->temp_dir_set(req, path);
336 }
337
348 static APR_INLINE
349 apr_status_t apreq_temp_dir_get(apreq_handle_t *req, const char **path)
350 {
351 return req->module->temp_dir_get(req, path);
352 }
353
354
355
366 #define APREQ_MODULE(pre, mmn) const apreq_module_t \
367 pre##_module = { #pre, mmn, \
368 pre##_jar, pre##_args, pre##_body, \
369 pre##_jar_get, pre##_args_get, pre##_body_get, \
370 pre##_parser_get, pre##_parser_set, pre##_hook_add, \
371 pre##_brigade_limit_get, pre##_brigade_limit_set, \
372 pre##_read_limit_get, pre##_read_limit_set, \
373 pre##_temp_dir_get, pre##_temp_dir_set, \
374 }
375
376
388 APREQ_DECLARE(apreq_handle_t*) apreq_handle_cgi(apr_pool_t *pool);
389
404 APREQ_DECLARE(apreq_handle_t*) apreq_handle_custom(apr_pool_t *pool,
405 const char *query_string,
406 const char *cookie,
407 apreq_parser_t *parser,
408 apr_uint64_t read_limit,
409 apr_bucket_brigade *in);
410
420 APREQ_DECLARE(apreq_param_t *)apreq_param(apreq_handle_t *req, const char *key);
421
431 #define apreq_cookie(req, name) apreq_jar_get(req, name)
432
442 APREQ_DECLARE(apr_table_t *) apreq_params(apreq_handle_t *req, apr_pool_t *p);
443
444
451 APREQ_DECLARE(apr_table_t *)apreq_cookies(apreq_handle_t *req, apr_pool_t *p);
452
453 #ifdef __cplusplus
454 }
455 #endif
456
457 #endif /* APREQ_MODULE_H */
APREQ_DECLARE
#define APREQ_DECLARE(d)
Definition: apreq.h:50
apreq_cookie.h
Cookies and Jars.
apreq_error.h
Error status codes.
APREQ_ERROR_NOPARSER
#define APREQ_ERROR_NOPARSER
Definition: apreq_error.h:80
APREQ_ERROR_NOHEADER
#define APREQ_ERROR_NOHEADER
Definition: apreq_error.h:78
APREQ_ERROR_NODATA
#define APREQ_ERROR_NODATA
Definition: apreq_error.h:72
apreq_param
apreq_param_t * apreq_param(apreq_handle_t *req, const char *key)
apreq_module_status_is_error
static APR_INLINE unsigned apreq_module_status_is_error(apr_status_t s)
Definition: apreq_module.h:110
apreq_hook_add
static APR_INLINE apr_status_t apreq_hook_add(apreq_handle_t *req, apreq_hook_t *hook)
Definition: apreq_module.h:254
apreq_params
apr_table_t * apreq_params(apreq_handle_t *req, apr_pool_t *p)
apreq_parser_get
static APR_INLINE apr_status_t apreq_parser_get(apreq_handle_t *req, const apreq_parser_t **parser)
Definition: apreq_module.h:223
apreq_jar
static APR_INLINE apr_status_t apreq_jar(apreq_handle_t *req, const apr_table_t **t)
Definition: apreq_module.h:135
apreq_handle_cgi
apreq_handle_t * apreq_handle_cgi(apr_pool_t *pool)
apreq_temp_dir_get
static APR_INLINE apr_status_t apreq_temp_dir_get(apreq_handle_t *req, const char **path)
Definition: apreq_module.h:349
apreq_jar_get
static APR_INLINE apreq_cookie_t * apreq_jar_get(apreq_handle_t *req, const char *name)
Definition: apreq_module.h:180
apreq_parser_set
static APR_INLINE apr_status_t apreq_parser_set(apreq_handle_t *req, apreq_parser_t *parser)
Definition: apreq_module.h:239
apreq_cookies
apr_table_t * apreq_cookies(apreq_handle_t *req, apr_pool_t *p)
apreq_body_get
static APR_INLINE apreq_param_t * apreq_body_get(apreq_handle_t *req, const char *name)
Definition: apreq_module.h:208
apreq_read_limit_set
static APR_INLINE apr_status_t apreq_read_limit_set(apreq_handle_t *req, apr_uint64_t bytes)
Definition: apreq_module.h:302
apreq_brigade_limit_set
static APR_INLINE apr_status_t apreq_brigade_limit_set(apreq_handle_t *req, apr_size_t bytes)
Definition: apreq_module.h:270
apreq_module_t
struct apreq_module_t apreq_module_t
Vtable describing the necessary module functions.
apreq_read_limit_get
static APR_INLINE apr_status_t apreq_read_limit_get(apreq_handle_t *req, apr_uint64_t *bytes)
Definition: apreq_module.h:318
apreq_handle_custom
apreq_handle_t * apreq_handle_custom(apr_pool_t *pool, const char *query_string, const char *cookie, apreq_parser_t *parser, apr_uint64_t read_limit, apr_bucket_brigade *in)
apreq_handle_t
struct apreq_handle_t apreq_handle_t
apreq_brigade_limit_get
static APR_INLINE apr_status_t apreq_brigade_limit_get(apreq_handle_t *req, apr_size_t *bytes)
Definition: apreq_module.h:286
apreq_args
static APR_INLINE apr_status_t apreq_args(apreq_handle_t *req, const apr_table_t **t)
Definition: apreq_module.h:150
apreq_body
static APR_INLINE apr_status_t apreq_body(apreq_handle_t *req, const apr_table_t **t)
Definition: apreq_module.h:165
apreq_args_get
static APR_INLINE apreq_param_t * apreq_args_get(apreq_handle_t *req, const char *name)
Definition: apreq_module.h:194
apreq_temp_dir_set
static APR_INLINE apr_status_t apreq_temp_dir_set(apreq_handle_t *req, const char *path)
Definition: apreq_module.h:333
apreq_parser.h
Request body parser API.
apreq_cookie_t
Cookie type, supporting both Netscape and RFC cookie specifications.
Definition: apreq_cookie.h:53
apreq_handle_t
Definition: apreq_module.h:41
apreq_handle_t::pool
apr_pool_t * pool
Definition: apreq_module.h:45
apreq_handle_t::bucket_alloc
apr_bucket_alloc_t * bucket_alloc
Definition: apreq_module.h:47
apreq_handle_t::module
const struct apreq_module_t * module
Definition: apreq_module.h:43
apreq_hook_t
Definition: apreq_parser.h:83
apreq_module_t
Vtable describing the necessary module functions.
Definition: apreq_module.h:56
apreq_module_t::jar
apr_status_t(* jar)(apreq_handle_t *, const apr_table_t **)
Definition: apreq_module.h:63
apreq_module_t::args
apr_status_t(* args)(apreq_handle_t *, const apr_table_t **)
Definition: apreq_module.h:65
apreq_module_t::read_limit_get
apr_status_t(* read_limit_get)(apreq_handle_t *, apr_uint64_t *)
Definition: apreq_module.h:89
apreq_module_t::parser_get
apr_status_t(* parser_get)(apreq_handle_t *, const apreq_parser_t **)
Definition: apreq_module.h:77
apreq_module_t::temp_dir_get
apr_status_t(* temp_dir_get)(apreq_handle_t *, const char **)
Definition: apreq_module.h:94
apreq_module_t::brigade_limit_set
apr_status_t(* brigade_limit_set)(apreq_handle_t *, apr_size_t)
Definition: apreq_module.h:86
apreq_module_t::body_get
apreq_param_t *(* body_get)(apreq_handle_t *, const char *)
Definition: apreq_module.h:74
apreq_module_t::read_limit_set
apr_status_t(* read_limit_set)(apreq_handle_t *, apr_uint64_t)
Definition: apreq_module.h:91
apreq_module_t::args_get
apreq_param_t *(* args_get)(apreq_handle_t *, const char *)
Definition: apreq_module.h:72
apreq_module_t::brigade_limit_get
apr_status_t(* brigade_limit_get)(apreq_handle_t *, apr_size_t *)
Definition: apreq_module.h:84
apreq_module_t::temp_dir_set
apr_status_t(* temp_dir_set)(apreq_handle_t *, const char *)
Definition: apreq_module.h:96
apreq_module_t::body
apr_status_t(* body)(apreq_handle_t *, const apr_table_t **)
Definition: apreq_module.h:67
apreq_module_t::hook_add
apr_status_t(* hook_add)(apreq_handle_t *, apreq_hook_t *)
Definition: apreq_module.h:81
apreq_module_t::magic_number
apr_uint32_t magic_number
Definition: apreq_module.h:60
apreq_module_t::parser_set
apr_status_t(* parser_set)(apreq_handle_t *, apreq_parser_t *)
Definition: apreq_module.h:79
apreq_module_t::jar_get
apreq_cookie_t *(* jar_get)(apreq_handle_t *, const char *)
Definition: apreq_module.h:70
apreq_module_t::name
const char * name
Definition: apreq_module.h:58
apreq_param_t
Definition: apreq_param.h:37
apreq_parser_t
Definition: apreq_parser.h:93