include/apreq.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_H
00019 #define APREQ_H
00020 
00021 #ifdef APREQ_DEBUG
00022 #include <assert.h>
00023 #endif
00024 
00025 #include "apr_tables.h"
00026 #include <stddef.h>
00027 
00028 #ifdef  __cplusplus
00029  extern "C" {
00030 #endif
00031 
00040 #ifndef WIN32
00041 
00050 #define APREQ_DECLARE(d)                APR_DECLARE(d)
00051 
00060 #define APREQ_DECLARE_NONSTD(d)         APR_DECLARE_NONSTD(d)
00061 
00071 #define APREQ_DECLARE_DATA
00072 #elif defined (APREQ_DECLARE_STATIC)
00073 #define APREQ_DECLARE(type)             type __stdcall
00074 #define APREQ_DECLARE_NONSTD(type)      type
00075 #define APREQ_DECLARE_DATA
00076 #elif defined (APREQ_DECLARE_EXPORT)
00077 #define APREQ_DECLARE(type)             __declspec(dllexport) type __stdcall
00078 #define APREQ_DECLARE_NONSTD(type)      __declspec(dllexport) type
00079 #define APREQ_DECLARE_DATA              __declspec(dllexport)
00080 #else
00081 #define APREQ_DECLARE(type)             __declspec(dllimport) type __stdcall
00082 #define APREQ_DECLARE_NONSTD(type)      __declspec(dllimport) type
00083 #define APREQ_DECLARE_DATA              __declspec(dllimport)
00084 #endif
00085 
00090 #define APREQ_DEFAULT_READ_BLOCK_SIZE   (64  * 1024)
00091 
00098 #define APREQ_DEFAULT_READ_LIMIT        (64 * 1024 * 1024)
00099 
00105 #define APREQ_DEFAULT_BRIGADE_LIMIT     (256 * 1024)
00106 
00111 #define APREQ_DEFAULT_NELTS              8
00112 
00113 
00114 
00118 #define APREQ_FLAGS_OFF(f, name) ((f) &= ~(name##_MASK << name##_BIT))
00119 
00122 #define APREQ_FLAGS_ON(f, name)  ((f) |=  (name##_MASK << name##_BIT))
00123 
00126 #define APREQ_FLAGS_GET(f, name) (((f) >> name##_BIT) & name##_MASK)
00127 
00133 #define APREQ_FLAGS_SET(f, name, value)                 \
00134     ((f) = (((f) & ~(name##_MASK << name##_BIT))        \
00135             | ((name##_MASK & (value)) << name##_BIT)))
00136 
00142 #define APREQ_CHARSET_BIT           0
00143 
00149 #define APREQ_CHARSET_MASK        255
00150 
00156 #define APREQ_TAINTED_BIT           8
00157 
00162 #define APREQ_TAINTED_MASK          1
00163 
00170 #define APREQ_COOKIE_VERSION_BIT   11
00171 
00176 #define APREQ_COOKIE_VERSION_MASK   3
00177 
00183 #define APREQ_COOKIE_SECURE_BIT    13
00184 
00189 #define APREQ_COOKIE_SECURE_MASK    1
00190 
00192 typedef enum {
00193     APREQ_CHARSET_ASCII  =0,
00194     APREQ_CHARSET_LATIN1 =1, /* ISO-8859-1   */
00195     APREQ_CHARSET_CP1252 =2, /* Windows-1252 */
00196     APREQ_CHARSET_UTF8   =8
00197 } apreq_charset_t;
00198 
00199 
00201 typedef enum {
00202     APREQ_JOIN_AS_IS,      
00203     APREQ_JOIN_ENCODE,     
00204     APREQ_JOIN_DECODE,     
00205     APREQ_JOIN_QUOTE       
00206 } apreq_join_t;
00207 
00209 typedef enum {
00210     APREQ_MATCH_FULL,       
00211     APREQ_MATCH_PARTIAL     
00212 } apreq_match_t;
00213 
00215 typedef enum {
00216     APREQ_EXPIRES_HTTP,       
00217     APREQ_EXPIRES_NSCOOKIE    
00218 } apreq_expires_t;
00219 
00220 
00222 typedef struct apreq_value_t {
00223     char             *name;    
00224     apr_size_t        nlen;    
00225     apr_size_t        dlen;    
00226     char              data[1]; 
00227 } apreq_value_t;
00228 
00240 static APR_INLINE
00241 void apreq_value_table_add(const apreq_value_t *v, apr_table_t *t) {
00242     apr_table_addn(t, v->name, v->data);
00243 }
00244 
00252 #define apreq_attr_to_type(T,A,P) ( (T*) ((char*)(P)-offsetof(T,A)) )
00253 
00265 APREQ_DECLARE(apr_status_t) apreq_initialize(apr_pool_t *pool);
00266 
00267 
00279 APREQ_DECLARE(apr_status_t) apreq_pre_initialize(apr_pool_t *pool);
00280 
00288 APREQ_DECLARE(apr_status_t) apreq_post_initialize(apr_pool_t *pool);
00289 
00290 
00291 #ifdef __cplusplus
00292  }
00293 #endif
00294 
00295 #endif /* APREQ_H */