apreq_parser.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_PARSERS_H
19 #define APREQ_PARSERS_H
20 /* These structs are defined below */
21 
22 #include "apreq_param.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif /* __cplusplus */
27 
39 typedef struct apreq_hook_t apreq_hook_t;
40 
44 typedef struct apreq_parser_t apreq_parser_t;
45 
47 #define APREQ_PARSER_ARGS apreq_parser_t *parser, \
48  apr_table_t *t, \
49  apr_bucket_brigade *bb
50 
52 #define APREQ_HOOK_ARGS apreq_hook_t *hook, \
53  apreq_param_t *param, \
54  apr_bucket_brigade *bb
55 
60 
65 
69 #define APREQ_DECLARE_PARSER(f) APREQ_DECLARE_NONSTD(apr_status_t) \
70  f (APREQ_PARSER_ARGS)
71 
75 #define APREQ_DECLARE_HOOK(f) APREQ_DECLARE_NONSTD(apr_status_t) \
76  f (APREQ_HOOK_ARGS)
77 
83 struct apreq_hook_t {
87  void *ctx;
88 };
89 
97  const char *content_type;
103  apr_size_t brigade_limit;
105  const char *temp_dir;
109  void *ctx;
110 };
111 
112 
123 static APR_INLINE
125  apr_bucket_brigade *bb)
126 {
127  return psr->parser(psr, t, bb);
128 }
129 
137 static APR_INLINE
139  apr_bucket_brigade *bb)
140 {
141  return h->hook(h, param, bb);
142 }
143 
144 
150 APREQ_DECLARE_PARSER(apreq_parse_headers);
151 
155 APREQ_DECLARE_PARSER(apreq_parse_urlencoded);
156 
163 APREQ_DECLARE_PARSER(apreq_parse_multipart);
164 
173 APREQ_DECLARE_PARSER(apreq_parse_generic);
174 
182 APREQ_DECLARE_HOOK(apreq_hook_apr_xml_parser);
183 
198  apr_bucket_alloc_t *ba,
199  const char *content_type,
201  apr_size_t brigade_limit,
202  const char *temp_dir,
203  apreq_hook_t *hook,
204  void *ctx);
205 
217  apreq_hook_t *next,
218  void *ctx);
219 
220 
228  apreq_hook_t *h);
229 
230 
238 
239 
254 
255 
261 APREQ_DECLARE_HOOK(apreq_hook_disable_uploads);
262 
267 APREQ_DECLARE_HOOK(apreq_hook_discard_brigade);
268 
273  const char *name;
274  apreq_param_t *param;
275  apreq_hook_t *prev;
277 
278 
293 APREQ_DECLARE_HOOK(apreq_hook_find_param);
294 
295 
296 #ifdef __cplusplus
297 }
298 
299 #endif
300 #endif /* APREQ_PARSERS_H */
#define APREQ_DECLARE(d)
Definition: apreq.h:50
Request parsing and parameter API.
static APR_INLINE apr_status_t apreq_hook_run(struct apreq_hook_t *h, apreq_param_t *param, apr_bucket_brigade *bb)
Definition: apreq_parser.h:138
static APR_INLINE apr_status_t apreq_parser_run(struct apreq_parser_t *psr, apr_table_t *t, apr_bucket_brigade *bb)
Definition: apreq_parser.h:124
apreq_hook_t * apreq_hook_make(apr_pool_t *pool, apreq_hook_function_t hook, apreq_hook_t *next, void *ctx)
apreq_parser_t * apreq_parser_make(apr_pool_t *pool, apr_bucket_alloc_t *ba, const char *content_type, apreq_parser_function_t pfn, apr_size_t brigade_limit, const char *temp_dir, apreq_hook_t *hook, void *ctx)
apr_status_t apreq_register_parser(const char *enctype, apreq_parser_function_t pfn)
#define APREQ_HOOK_ARGS
Definition: apreq_parser.h:52
apr_status_t(* apreq_hook_function_t)(APREQ_HOOK_ARGS)
Definition: apreq_parser.h:64
apreq_parser_function_t apreq_parser(const char *enctype)
#define APREQ_DECLARE_PARSER(f)
Definition: apreq_parser.h:69
apr_status_t apreq_parser_add_hook(apreq_parser_t *p, apreq_hook_t *h)
struct apreq_hook_find_param_ctx_t apreq_hook_find_param_ctx_t
#define APREQ_DECLARE_HOOK(f)
Definition: apreq_parser.h:75
#define APREQ_PARSER_ARGS
Definition: apreq_parser.h:47
apr_status_t(* apreq_parser_function_t)(APREQ_PARSER_ARGS)
Definition: apreq_parser.h:59
struct apr_bucket_alloc_t apr_bucket_alloc_t
int apr_status_t
struct apr_pool_t apr_pool_t
struct apr_table_t apr_table_t
Definition: apreq_parser.h:272
Definition: apreq_parser.h:83
apreq_hook_t * next
Definition: apreq_parser.h:85
apr_pool_t * pool
Definition: apreq_parser.h:86
void * ctx
Definition: apreq_parser.h:87
apreq_hook_function_t hook
Definition: apreq_parser.h:84
Definition: apreq_param.h:37
Definition: apreq_parser.h:93
apr_size_t brigade_limit
Definition: apreq_parser.h:103
const char * content_type
Definition: apreq_parser.h:97
apr_pool_t * pool
Definition: apreq_parser.h:99
const char * temp_dir
Definition: apreq_parser.h:105
void * ctx
Definition: apreq_parser.h:109
apreq_parser_function_t parser
Definition: apreq_parser.h:95
apreq_hook_t * hook
Definition: apreq_parser.h:107
apr_bucket_alloc_t * bucket_alloc
Definition: apreq_parser.h:101