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

apreq_params.h

Go to the documentation of this file.
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_PARAM_H
00018 #define APREQ_PARAM_H
00019 
00020 #include "apreq.h"
00021 
00022 #ifdef __cplusplus
00023 extern "C" {
00024 #endif /* __cplusplus */
00025 
00026 
00039 typedef struct apreq_param_t {
00040     apr_table_t         *info; 
00041     apr_bucket_brigade  *bb;   
00042     apreq_value_t        v;    
00043 } apreq_param_t;
00044 
00045 /* These structs are defined below */
00046 typedef struct apreq_hook_t apreq_hook_t;
00047 typedef struct apreq_parser_t apreq_parser_t;
00048 
00050 #define apreq_value_to_param(ptr) apreq_attr_to_type(apreq_param_t, v, ptr)
00051 #define apreq_param_name(p)      ((p)->v.name)
00052 #define apreq_param_value(p)     ((p)->v.data)
00053 #define apreq_param_info(p)      ((p)->info)
00054 #define apreq_param_status(p)    ((p)->v.status)
00055 #define apreq_param_brigade(p) ((p)->bb ? apreq_copy_brigade((p)->bb) : NULL)
00056 
00058 APREQ_DECLARE(apreq_param_t *) apreq_make_param(apr_pool_t *p, 
00059                                                 const char *name, 
00060                                                 const apr_size_t nlen, 
00061                                                 const char *val, 
00062                                                 const apr_size_t vlen);
00063 
00065 typedef struct apreq_request_t {
00066     apr_table_t        *args;         
00067     apr_table_t        *body;         
00068     apreq_parser_t     *parser;       
00069     void               *env;          
00070 } apreq_request_t;
00071 
00072 
00089 APREQ_DECLARE(apreq_request_t *)apreq_request(void *env, const char *qs);
00090 
00091 
00100 APREQ_DECLARE(apreq_param_t *) apreq_param(const apreq_request_t *req, 
00101                                            const char *name); 
00102 
00103 
00111 APREQ_DECLARE(apr_table_t *) apreq_params(apr_pool_t *p,
00112                                           const apreq_request_t *req);
00113 
00114 
00115 
00124 APREQ_DECLARE(apr_array_header_t *) apreq_params_as_array(apr_pool_t *p,
00125                                                           apreq_request_t *req,
00126                                                           const char *key);
00127 
00139 APREQ_DECLARE(const char *) apreq_params_as_string(apr_pool_t *p,
00140                                                    apreq_request_t *req,
00141                                                    const char *key,
00142                                                    apreq_join_t mode);
00143 
00144 
00156 APREQ_DECLARE(apreq_param_t *) apreq_decode_param(apr_pool_t *pool, 
00157                                                   const char *word,
00158                                                   const apr_size_t nlen, 
00159                                                   const apr_size_t vlen);
00167 APREQ_DECLARE(char *) apreq_encode_param(apr_pool_t *pool, 
00168                                          const apreq_param_t *param);
00169 
00182 APREQ_DECLARE(apr_status_t) apreq_parse_query_string(apr_pool_t *pool,
00183                                                      apr_table_t *t, 
00184                                                      const char *qs);
00185 
00195 APREQ_DECLARE(apr_status_t)apreq_parse_request(apreq_request_t *req, 
00196                                                apr_bucket_brigade *bb);
00205 APREQ_DECLARE(apr_table_t *) apreq_uploads(apr_pool_t *pool,
00206                                            const apreq_request_t *req);
00207 
00217 APREQ_DECLARE(apreq_param_t *) apreq_upload(const apreq_request_t *req,
00218                                             const char *key);
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                            const 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 
00279 #define APREQ_RUN_PARSER(psr,env,t,bb) (psr)->parser(psr,env,t,bb)
00280 
00287 #define APREQ_RUN_HOOK(h,env,param,bb) (h)->hook(h,env,param,bb)
00288 
00298 APREQ_DECLARE(apr_status_t) apreq_brigade_concat(void *env,
00299                                                  apr_bucket_brigade *out, 
00300                                                  apr_bucket_brigade *in);
00301 
00302 
00306 APREQ_DECLARE_PARSER(apreq_parse_headers);
00307 
00311 APREQ_DECLARE_PARSER(apreq_parse_urlencoded);
00312 
00316 APREQ_DECLARE_PARSER(apreq_parse_multipart);
00317 
00328 APREQ_DECLARE(apreq_parser_t *)
00329         apreq_make_parser(apr_pool_t *pool,
00330                           const char *enctype,
00331                           apr_status_t (*parser) APREQ_PARSER_ARGS,
00332                           apreq_hook_t *hook,
00333                           void *ctx);
00334 
00344 APREQ_DECLARE(apreq_hook_t *)
00345         apreq_make_hook(apr_pool_t *pool,
00346                         apr_status_t (*hook) APREQ_HOOK_ARGS,
00347                         apreq_hook_t *next,
00348                         void *ctx);
00349 
00356 APREQ_DECLARE(void) apreq_add_hook(apreq_parser_t *p, 
00357                                    apreq_hook_t *h);
00358 
00373 APREQ_DECLARE(apreq_parser_t *)apreq_parser(void *env,
00374                                             apreq_hook_t *hook);
00375 
00377 #ifdef __cplusplus
00378 }
00379 #endif
00380 
00381 
00382 #endif /* APREQ_PARAM_H */
00383 
00384 
00385 

Generated on Sat Jun 12 10:16:30 2004 for libapreq2 by doxygen1.2.15