Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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;
48 
50 
56 typedef struct apreq_module_t {
58  const char *name;
61 
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 
82 
87 
92 
97 
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:
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 
389 
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 
443 
444 
452 
453 #ifdef __cplusplus
454  }
455 #endif
456 
457 #endif /* APREQ_MODULE_H */
size_t apr_size_t
Definition: apr.h:375
Error status codes.Define the APREQ_ error codes.
#define APREQ_ERROR_NODATA
Definition: apreq_error.h:73
apr_status_t(* jar)(apreq_handle_t *, const apr_table_t **)
Definition: apreq_module.h:63
Definition: apreq_parser.h:93
Vtable describing the necessary module functions.
Definition: apreq_module.h:56
struct apr_bucket_alloc_t apr_bucket_alloc_t
Definition: apr_buckets.h:123
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:552
apr_status_t(* brigade_limit_set)(apreq_handle_t *, apr_size_t)
Definition: apreq_module.h:86
#define APREQ_DECLARE(x)
Definition: macros.h:12
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)
Definition: apreq_parser.h:83
apr_status_t(* temp_dir_set)(apreq_handle_t *, const char *)
Definition: apreq_module.h:96
apr_status_t(* temp_dir_get)(apreq_handle_t *, const char **)
Definition: apreq_module.h:94
Definition: apr_buckets.h:258
Definition: apreq_module.h:41
const char * name
Definition: apreq_module.h:58
apr_bucket_alloc_t * bucket_alloc
Definition: apreq_module.h:47
apr_status_t(* hook_add)(apreq_handle_t *, apreq_hook_t *)
Definition: apreq_module.h:81
apreq_param_t *(* body_get)(apreq_handle_t *, const char *)
Definition: apreq_module.h:74
struct apreq_handle_t apreq_handle_t
#define APREQ_ERROR_NOHEADER
Definition: apreq_error.h:79
apr_status_t(* brigade_limit_get)(apreq_handle_t *, apr_size_t *)
Definition: apreq_module.h:84
apr_uint32_t magic_number
Definition: apreq_module.h:60
const struct apreq_module_t * module
Definition: apreq_module.h:43
apr_pool_t * pool
Definition: apreq_module.h:45
apr_status_t(* parser_get)(apreq_handle_t *, const apreq_parser_t **)
Definition: apreq_module.h:77
apreq_cookie_t *(* jar_get)(apreq_handle_t *, const char *)
Definition: apreq_module.h:70
unsigned int apr_uint32_t
Definition: apr.h:334
Definition: apreq_param.h:37
apr_status_t(* parser_set)(apreq_handle_t *, apreq_parser_t *)
Definition: apreq_module.h:79
apr_status_t(* read_limit_get)(apreq_handle_t *, apr_uint64_t *)
Definition: apreq_module.h:89
#define APR_INLINE
Definition: apr.h:65
apr_status_t(* read_limit_set)(apreq_handle_t *, apr_uint64_t)
Definition: apreq_module.h:91
apr_pool_t * p
unsigned long apr_uint64_t
Definition: apr.h:372
apr_status_t(* args)(apreq_handle_t *, const apr_table_t **)
Definition: apreq_module.h:65
apreq_param_t * apreq_param(apreq_handle_t *req, const char *key)
struct apr_table_t apr_table_t
Definition: apr_tables.h:56
const char * name
Definition: mod_dav.h:726
Request body parser API.
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
int apr_status_t
Definition: apr_errno.h:44
struct apreq_module_t apreq_module_t
Vtable describing the necessary module functions.
apr_status_t(* body)(apreq_handle_t *, const apr_table_t **)
Definition: apreq_module.h:67
apreq_param_t *(* args_get)(apreq_handle_t *, const char *)
Definition: apreq_module.h:72
apreq_handle_t * apreq_handle_cgi(apr_pool_t *pool)
#define APR_INCOMPLETE
Definition: apr_errno.h:458
#define APR_SUCCESS
Definition: apr_errno.h:225
apr_table_t * apreq_cookies(apreq_handle_t *req, apr_pool_t *p)
#define APR_EINIT
Definition: apr_errno.h:480
#define APREQ_ERROR_NOPARSER
Definition: apreq_error.h:81
apr_table_t * apreq_params(apreq_handle_t *req, apr_pool_t *p)