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;
60  apr_uint32_t magic_number;
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
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
136 {
137  return req->module->jar(req,t);
138 }
139 
149 static APR_INLINE
151 {
152  return req->module->args(req,t);
153 }
154 
164 static APR_INLINE
166 {
167  return req->module->body(req, t);
168 }
169 
170 
179 static APR_INLINE
181 {
182  return req->module->jar_get(req, name);
183 }
184 
193 static APR_INLINE
195 {
196  return req->module->args_get(req, name);
197 }
198 
207 static APR_INLINE
209 {
210  return req->module->body_get(req, name);
211 }
212 
222 static APR_INLINE
224  const apreq_parser_t **parser)
225 {
226  return req->module->parser_get(req, parser);
227 }
228 
229 
238 static APR_INLINE
240  apreq_parser_t *parser)
241 {
242  return req->module->parser_set(req, parser);
243 }
244 
253 static APR_INLINE
255 {
256  return req->module->hook_add(req, hook);
257 }
258 
259 
269 static APR_INLINE
271  apr_size_t bytes)
272 {
273  return req->module->brigade_limit_set(req, bytes);
274 }
275 
285 static APR_INLINE
287  apr_size_t *bytes)
288 {
289  return req->module->brigade_limit_get(req, bytes);
290 }
291 
301 static APR_INLINE
303  apr_uint64_t bytes)
304 {
305  return req->module->read_limit_set(req, bytes);
306 }
307 
317 static APR_INLINE
319  apr_uint64_t *bytes)
320 {
321  return req->module->read_limit_get(req, bytes);
322 }
323 
332 static APR_INLINE
334 {
335  return req->module->temp_dir_set(req, path);
336 }
337 
348 static APR_INLINE
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 
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 */
#define APREQ_DECLARE(d)
Definition: apreq.h:50
Error status codes.
#define APREQ_ERROR_NOPARSER
Definition: apreq_error.h:80
#define APREQ_ERROR_NOHEADER
Definition: apreq_error.h:78
#define APREQ_ERROR_NODATA
Definition: apreq_error.h:72
apreq_param_t * apreq_param(apreq_handle_t *req, const char *key)
static APR_INLINE unsigned apreq_module_status_is_error(apr_status_t s)
Definition: apreq_module.h:110
static APR_INLINE apr_status_t apreq_hook_add(apreq_handle_t *req, apreq_hook_t *hook)
Definition: apreq_module.h:254
apr_table_t * apreq_params(apreq_handle_t *req, apr_pool_t *p)
static APR_INLINE apr_status_t apreq_parser_get(apreq_handle_t *req, const apreq_parser_t **parser)
Definition: apreq_module.h:223
static APR_INLINE apr_status_t apreq_jar(apreq_handle_t *req, const apr_table_t **t)
Definition: apreq_module.h:135
apreq_handle_t * apreq_handle_cgi(apr_pool_t *pool)
static APR_INLINE apr_status_t apreq_temp_dir_get(apreq_handle_t *req, const char **path)
Definition: apreq_module.h:349
static APR_INLINE apreq_cookie_t * apreq_jar_get(apreq_handle_t *req, const char *name)
Definition: apreq_module.h:180
static APR_INLINE apr_status_t apreq_parser_set(apreq_handle_t *req, apreq_parser_t *parser)
Definition: apreq_module.h:239
apr_table_t * apreq_cookies(apreq_handle_t *req, apr_pool_t *p)
static APR_INLINE apreq_param_t * apreq_body_get(apreq_handle_t *req, const char *name)
Definition: apreq_module.h:208
static APR_INLINE apr_status_t apreq_read_limit_set(apreq_handle_t *req, apr_uint64_t bytes)
Definition: apreq_module.h:302
static APR_INLINE apr_status_t apreq_brigade_limit_set(apreq_handle_t *req, apr_size_t bytes)
Definition: apreq_module.h:270
struct apreq_module_t apreq_module_t
Vtable describing the necessary module functions.
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_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)
struct apreq_handle_t apreq_handle_t
static APR_INLINE apr_status_t apreq_brigade_limit_get(apreq_handle_t *req, apr_size_t *bytes)
Definition: apreq_module.h:286
static APR_INLINE apr_status_t apreq_args(apreq_handle_t *req, const apr_table_t **t)
Definition: apreq_module.h:150
static APR_INLINE apr_status_t apreq_body(apreq_handle_t *req, const apr_table_t **t)
Definition: apreq_module.h:165
static APR_INLINE apreq_param_t * apreq_args_get(apreq_handle_t *req, const char *name)
Definition: apreq_module.h:194
static APR_INLINE apr_status_t apreq_temp_dir_set(apreq_handle_t *req, const char *path)
Definition: apreq_module.h:333
Request body parser API.
#define APR_INCOMPLETE
#define APR_EINIT
struct apr_bucket_alloc_t apr_bucket_alloc_t
#define APR_SUCCESS
int apr_status_t
struct apr_pool_t apr_pool_t
struct apr_table_t apr_table_t
Definition: apreq_module.h:41
apr_pool_t * pool
Definition: apreq_module.h:45
apr_bucket_alloc_t * bucket_alloc
Definition: apreq_module.h:47
const struct apreq_module_t * module
Definition: apreq_module.h:43
Definition: apreq_parser.h:83
Vtable describing the necessary module functions.
Definition: apreq_module.h:56
apr_status_t(* jar)(apreq_handle_t *, const apr_table_t **)
Definition: apreq_module.h:63
apr_status_t(* args)(apreq_handle_t *, const apr_table_t **)
Definition: apreq_module.h:65
apr_status_t(* read_limit_get)(apreq_handle_t *, apr_uint64_t *)
Definition: apreq_module.h:89
apr_status_t(* parser_get)(apreq_handle_t *, const apreq_parser_t **)
Definition: apreq_module.h:77
apr_status_t(* temp_dir_get)(apreq_handle_t *, const char **)
Definition: apreq_module.h:94
apr_status_t(* brigade_limit_set)(apreq_handle_t *, apr_size_t)
Definition: apreq_module.h:86
apreq_param_t *(* body_get)(apreq_handle_t *, const char *)
Definition: apreq_module.h:74
apr_status_t(* read_limit_set)(apreq_handle_t *, apr_uint64_t)
Definition: apreq_module.h:91
apreq_param_t *(* args_get)(apreq_handle_t *, const char *)
Definition: apreq_module.h:72
apr_status_t(* brigade_limit_get)(apreq_handle_t *, apr_size_t *)
Definition: apreq_module.h:84
apr_status_t(* temp_dir_set)(apreq_handle_t *, const char *)
Definition: apreq_module.h:96
apr_status_t(* body)(apreq_handle_t *, const apr_table_t **)
Definition: apreq_module.h:67
apr_status_t(* hook_add)(apreq_handle_t *, apreq_hook_t *)
Definition: apreq_module.h:81
apr_uint32_t magic_number
Definition: apreq_module.h:60
apr_status_t(* parser_set)(apreq_handle_t *, apreq_parser_t *)
Definition: apreq_module.h:79
apreq_cookie_t *(* jar_get)(apreq_handle_t *, const char *)
Definition: apreq_module.h:70
const char * name
Definition: apreq_module.h:58
Definition: apreq_param.h:37
Definition: apreq_parser.h:93