Apache HTTP Server Request Library
00001 /* 00002 ** Copyright 2003-2004 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_PARAMS_H 00018 #define APREQ_PARAMS_H 00019 00020 #include "apreq.h" 00021 00022 #ifdef __cplusplus 00023 extern "C" { 00024 #endif /* __cplusplus */ 00025 00026 00034 typedef struct apreq_param_t { 00035 apr_table_t *info; 00036 apr_bucket_brigade *bb; 00037 apreq_value_t v; 00038 } apreq_param_t; 00039 00040 /* These structs are defined below */ 00041 typedef struct apreq_hook_t apreq_hook_t; 00042 typedef struct apreq_parser_t apreq_parser_t; 00043 00045 #define apreq_value_to_param(ptr) apreq_attr_to_type(apreq_param_t, v, ptr) 00046 #define apreq_param_name(p) ((p)->v.name) 00047 #define apreq_param_value(p) ((p)->v.data) 00048 #define apreq_param_info(p) ((p)->info) 00049 #define apreq_param_brigade(p) ((p)->bb ? apreq_copy_brigade((p)->bb) : NULL) 00050 00052 APREQ_DECLARE(apreq_param_t *) apreq_make_param(apr_pool_t *p, 00053 const char *name, 00054 const apr_size_t nlen, 00055 const char *val, 00056 const apr_size_t vlen); 00057 00059 typedef struct apreq_request_t { 00060 apr_table_t *args; 00061 apr_table_t *body; 00062 apreq_parser_t *parser; 00063 void *env; 00064 apr_status_t args_status; 00065 apr_status_t body_status; 00066 } apreq_request_t; 00067 00068 00085 APREQ_DECLARE(apreq_request_t *)apreq_request(void *env, const char *qs); 00086 00087 00097 APREQ_DECLARE(apreq_param_t *) apreq_param(const apreq_request_t *req, 00098 const char *name); 00099 00100 00108 APREQ_DECLARE(apr_table_t *) apreq_params(apr_pool_t *p, 00109 const apreq_request_t *req); 00110 00111 00112 00121 APREQ_DECLARE(apr_array_header_t *) apreq_params_as_array(apr_pool_t *p, 00122 apreq_request_t *req, 00123 const char *key); 00124 00136 APREQ_DECLARE(const char *) apreq_params_as_string(apr_pool_t *p, 00137 apreq_request_t *req, 00138 const char *key, 00139 apreq_join_t mode); 00140 00141 00153 APREQ_DECLARE(apreq_param_t *) apreq_decode_param(apr_pool_t *pool, 00154 const char *word, 00155 const apr_size_t nlen, 00156 const apr_size_t vlen); 00164 APREQ_DECLARE(char *) apreq_encode_param(apr_pool_t *pool, 00165 const apreq_param_t *param); 00166 00179 APREQ_DECLARE(apr_status_t) apreq_parse_query_string(apr_pool_t *pool, 00180 apr_table_t *t, 00181 const char *qs); 00182 00194 APREQ_DECLARE(apr_status_t)apreq_parse_request(apreq_request_t *req, 00195 apr_bucket_brigade *bb); 00204 APREQ_DECLARE(apr_table_t *) apreq_uploads(apr_pool_t *pool, 00205 const apreq_request_t *req); 00206 00216 APREQ_DECLARE(apreq_param_t *) apreq_upload(const apreq_request_t *req, 00217 const char *key); 00218 #include "apreq.h" 00219 00221 #define APREQ_PARSER_ARGS apreq_parser_t *parser, \ 00222 void *env, \ 00223 apr_table_t *t, \ 00224 apr_bucket_brigade *bb 00225 00227 #define APREQ_HOOK_ARGS apreq_hook_t *hook, \ 00228 void *env, \ 00229 apreq_param_t *param, \ 00230 apr_bucket_brigade *bb 00231 00235 #ifndef WIN32 00236 #define APREQ_DECLARE_PARSER(f) APREQ_DECLARE(apr_status_t) \ 00237 (f) (APREQ_PARSER_ARGS) 00238 #else 00239 #define APREQ_DECLARE_PARSER(f) APREQ_DECLARE_NONSTD(apr_status_t) \ 00240 (f) (APREQ_PARSER_ARGS) 00241 #endif 00242 00246 #ifndef WIN32 00247 #define APREQ_DECLARE_HOOK(f) APREQ_DECLARE(apr_status_t) \ 00248 (f) (APREQ_HOOK_ARGS) 00249 #else 00250 #define APREQ_DECLARE_HOOK(f) APREQ_DECLARE_NONSTD(apr_status_t) \ 00251 (f) (APREQ_HOOK_ARGS) 00252 #endif 00253 00258 struct apreq_hook_t { 00259 apr_status_t (*hook) (APREQ_HOOK_ARGS); 00260 apreq_hook_t *next; 00261 void *ctx; 00262 }; 00263 00268 struct apreq_parser_t { 00269 apr_status_t (*parser) (APREQ_PARSER_ARGS); 00270 const char *enctype; 00271 apreq_hook_t *hook; 00272 void *ctx; 00273 }; 00274 00275 00286 #define APREQ_RUN_PARSER(psr,env,t,bb) (psr)->parser(psr,env,t,bb) 00287 00294 #define APREQ_RUN_HOOK(h,env,param,bb) (h)->hook(h,env,param,bb) 00295 00305 APREQ_DECLARE(apr_status_t) apreq_brigade_concat(void *env, 00306 apr_bucket_brigade *out, 00307 apr_bucket_brigade *in); 00308 00309 00315 APREQ_DECLARE_PARSER(apreq_parse_headers); 00316 00320 APREQ_DECLARE_PARSER(apreq_parse_urlencoded); 00321 00328 APREQ_DECLARE_PARSER(apreq_parse_multipart); 00329 00340 APREQ_DECLARE(apreq_parser_t *) 00341 apreq_make_parser(apr_pool_t *pool, 00342 const char *enctype, 00343 apr_status_t (*parser) (APREQ_PARSER_ARGS), 00344 apreq_hook_t *hook, 00345 void *ctx); 00346 00356 APREQ_DECLARE(apreq_hook_t *) 00357 apreq_make_hook(apr_pool_t *pool, 00358 apr_status_t (*hook) (APREQ_HOOK_ARGS), 00359 apreq_hook_t *next, 00360 void *ctx); 00361 00362 00369 APREQ_DECLARE(void) apreq_add_hook(apreq_parser_t *p, 00370 apreq_hook_t *h); 00371 00386 APREQ_DECLARE(apreq_parser_t *)apreq_parser(void *env, 00387 apreq_hook_t *hook); 00388 00394 APREQ_DECLARE_HOOK(apreq_hook_disable_uploads); 00395 00396 #ifdef __cplusplus 00397 } 00398 00399 #endif 00400 #endif /* APREQ_PARAMS_H */ 00401 00402 00403