Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

apreq_parser.h

Go to the documentation of this file.
00001 /*
00002 **  Copyright 2003-2006  The Apache Software Foundation
00003 **
00004 **  Licensed under the Apache License, Version 2.0 (the "License");
00005 **  you may not use this file except in compliance with the License.
00006 **  You may obtain a copy of the License at
00007 **
00008 **      http://www.apache.org/licenses/LICENSE-2.0
00009 **
00010 **  Unless required by applicable law or agreed to in writing, software
00011 **  distributed under the License is distributed on an "AS IS" BASIS,
00012 **  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013 **  See the License for the specific language governing permissions and
00014 **  limitations under the License.
00015 */
00016 
00017 #ifndef APREQ_PARSERS_H
00018 #define APREQ_PARSERS_H
00019 /* These structs are defined below */
00020 
00021 #include "apreq_param.h"
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif /* __cplusplus */
00026 
00038 typedef struct apreq_hook_t apreq_hook_t;
00039 
00043 typedef struct apreq_parser_t apreq_parser_t;
00044 
00046 #define APREQ_PARSER_ARGS  apreq_parser_t *parser,     \
00047                            apr_table_t *t,             \
00048                            apr_bucket_brigade *bb
00049 
00051 #define APREQ_HOOK_ARGS    apreq_hook_t *hook,         \
00052                            apreq_param_t *param,       \
00053                            apr_bucket_brigade *bb
00054 
00058 typedef apr_status_t (*apreq_parser_function_t)(APREQ_PARSER_ARGS);
00059 
00063 typedef apr_status_t (*apreq_hook_function_t)(APREQ_HOOK_ARGS);
00064 
00068 #define APREQ_DECLARE_PARSER(f) APREQ_DECLARE_NONSTD(apr_status_t) \
00069                                 (f) (APREQ_PARSER_ARGS)
00070 
00074 #define APREQ_DECLARE_HOOK(f)   APREQ_DECLARE_NONSTD(apr_status_t) \
00075                                 (f) (APREQ_HOOK_ARGS)
00076 
00082 struct apreq_hook_t {
00083     apreq_hook_function_t hook; 
00084     apreq_hook_t         *next; 
00085     apr_pool_t           *pool; 
00086     void *ctx; 
00087 };
00088 
00092 struct apreq_parser_t {
00094     apreq_parser_function_t parser;
00096     const char             *content_type;
00098     apr_pool_t             *pool;
00100     apr_bucket_alloc_t     *bucket_alloc;
00102     apr_size_t              brigade_limit;
00104     const char             *temp_dir;
00106     apreq_hook_t           *hook;
00108     void                   *ctx;
00109 };
00110 
00111 
00122 static APR_INLINE
00123 apr_status_t apreq_parser_run(struct apreq_parser_t *psr, apr_table_t *t,
00124                               apr_bucket_brigade *bb)
00125 {
00126     return psr->parser(psr, t, bb);
00127 }
00128 
00136 static APR_INLINE
00137 apr_status_t apreq_hook_run(struct apreq_hook_t *h, apreq_param_t *param,
00138                             apr_bucket_brigade *bb)
00139 {
00140     return h->hook(h, param, bb);
00141 }
00142 
00143 
00149 APREQ_DECLARE_PARSER(apreq_parse_headers);
00150 
00154 APREQ_DECLARE_PARSER(apreq_parse_urlencoded);
00155 
00162 APREQ_DECLARE_PARSER(apreq_parse_multipart);
00163 
00172 APREQ_DECLARE_PARSER(apreq_parse_generic);
00173 
00181 APREQ_DECLARE_HOOK(apreq_hook_apr_xml_parser);
00182 
00196 APREQ_DECLARE(apreq_parser_t *) apreq_parser_make(apr_pool_t *pool,
00197                                                   apr_bucket_alloc_t *ba,
00198                                                   const char *content_type,
00199                                                   apreq_parser_function_t pfn,
00200                                                   apr_size_t brigade_limit,
00201                                                   const char *temp_dir,
00202                                                   apreq_hook_t *hook,
00203                                                   void *ctx);
00204 
00214 APREQ_DECLARE(apreq_hook_t *) apreq_hook_make(apr_pool_t *pool,
00215                                               apreq_hook_function_t hook,
00216                                               apreq_hook_t *next,
00217                                               void *ctx);
00218 
00219 
00226 APREQ_DECLARE(apr_status_t) apreq_parser_add_hook(apreq_parser_t *p,
00227                                                   apreq_hook_t *h);
00228 
00229 
00236 APREQ_DECLARE(apreq_parser_function_t)apreq_parser(const char *enctype);
00237 
00238 
00251 APREQ_DECLARE(apr_status_t) apreq_register_parser(const char *enctype,
00252                                                   apreq_parser_function_t pfn);
00253 
00254 
00260 APREQ_DECLARE_HOOK(apreq_hook_disable_uploads);
00261 
00266 APREQ_DECLARE_HOOK(apreq_hook_discard_brigade);
00267 
00279 APREQ_DECLARE_HOOK(apreq_hook_find_param);
00280 
00281 
00282 #ifdef __cplusplus
00283 }
00284 
00285 #endif
00286 #endif /* APREQ_PARSERS_H */