include/apreq_param.h

Go to the documentation of this file.
00001 /*
00002 **  Licensed to the Apache Software Foundation (ASF) under one or more
00003 ** contributor license agreements.  See the NOTICE file distributed with
00004 ** this work for additional information regarding copyright ownership.
00005 ** The ASF licenses this file to You under the Apache License, Version 2.0
00006 ** (the "License"); you may not use this file except in compliance with
00007 ** the License.  You may obtain a copy of the License at
00008 **
00009 **      http://www.apache.org/licenses/LICENSE-2.0
00010 **
00011 **  Unless required by applicable law or agreed to in writing, software
00012 **  distributed under the License is distributed on an "AS IS" BASIS,
00013 **  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 **  See the License for the specific language governing permissions and
00015 **  limitations under the License.
00016 */
00017 
00018 #ifndef APREQ_PARAM_H
00019 #define APREQ_PARAM_H
00020 
00021 #include "apreq.h"
00022 #include "apr_buckets.h"
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 
00037 typedef struct apreq_param_t {
00038     apr_table_t         *info;   
00039     apr_bucket_brigade  *upload; 
00040     unsigned             flags;  
00041     const apreq_value_t  v;      
00042 } apreq_param_t;
00043 
00044 
00046 static APR_INLINE
00047 unsigned apreq_param_is_tainted(const apreq_param_t *p) {
00048     return APREQ_FLAGS_GET(p->flags, APREQ_TAINTED);
00049 }
00050 
00052 static APR_INLINE
00053 void apreq_param_tainted_on(apreq_param_t *p) {
00054     APREQ_FLAGS_ON(p->flags, APREQ_TAINTED);
00055 }
00056 
00058 static APR_INLINE
00059 void apreq_param_tainted_off(apreq_param_t *p) {
00060     APREQ_FLAGS_OFF(p->flags, APREQ_TAINTED);
00061 }
00062 
00064 static APR_INLINE
00065 apreq_charset_t apreq_param_charset_set(apreq_param_t *p, apreq_charset_t c) {
00066     apreq_charset_t old = (apreq_charset_t)
00067         APREQ_FLAGS_GET(p->flags, APREQ_CHARSET);
00068     APREQ_FLAGS_SET(p->flags, APREQ_CHARSET, c);
00069     return old;
00070 }
00071 
00073 static APR_INLINE
00074 apreq_charset_t apreq_param_charset_get(apreq_param_t *p) {
00075     return (apreq_charset_t)APREQ_FLAGS_GET(p->flags, APREQ_CHARSET);
00076 }
00077 
00078 
00080 static APR_INLINE
00081 apreq_param_t *apreq_value_to_param(const char *val)
00082 {
00083     union { const char *in; char *out; } deconst;
00084 
00085     deconst.in = val;
00086     return apreq_attr_to_type(apreq_param_t, v,
00087            apreq_attr_to_type(apreq_value_t, data, deconst.out));
00088 }
00089 
00090 
00091 
00093 APREQ_DECLARE(apreq_param_t *) apreq_param_make(apr_pool_t *p,
00094                                                 const char *name,
00095                                                 const apr_size_t nlen,
00096                                                 const char *val,
00097                                                 const apr_size_t vlen);
00098 
00115 APREQ_DECLARE(apr_status_t) apreq_param_decode(apreq_param_t **param,
00116                                                apr_pool_t *pool,
00117                                                const char *word,
00118                                                apr_size_t nlen,
00119                                                apr_size_t vlen);
00120 
00127 APREQ_DECLARE(char *) apreq_param_encode(apr_pool_t *pool,
00128                                          const apreq_param_t *param);
00129 
00141 APREQ_DECLARE(apr_status_t) apreq_parse_query_string(apr_pool_t *pool,
00142                                                      apr_table_t *t,
00143                                                      const char *qs);
00144 
00145 
00157 APREQ_DECLARE(apr_array_header_t *) apreq_params_as_array(apr_pool_t *p,
00158                                                           const apr_table_t *t,
00159                                                           const char *key);
00160 
00175 APREQ_DECLARE(const char *) apreq_params_as_string(apr_pool_t *p,
00176                                                    const apr_table_t *t,
00177                                                    const char *key,
00178                                                    apreq_join_t mode);
00179 
00187 APREQ_DECLARE(const apr_table_t *) apreq_uploads(const apr_table_t *body,
00188                                                  apr_pool_t *pool);
00189 
00198 APREQ_DECLARE(const apreq_param_t *) apreq_upload(const apr_table_t *body,
00199                                                   const char *name);
00200 
00201 
00202 #ifdef __cplusplus
00203 }
00204 #endif
00205 
00206 #endif /* APREQ_PARAM_H */
00207 
00208 
00209