Apache HTTP Server Request Library

apreq.h
Go to the documentation of this file.
1 /*
2 ** Licensed to the Apache Software Foundation (ASF) under one or more
3 ** contributor license agreements. See the NOTICE file distributed with
4 ** this work for additional information regarding copyright ownership.
5 ** The ASF licenses this file to You under the Apache License, Version 2.0
6 ** (the "License"); you may not use this file except in compliance with
7 ** the License. You may obtain a copy of the License at
8 **
9 ** http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17
18 #ifndef APREQ_H
19 #define APREQ_H
20
21 #ifdef APREQ_DEBUG
22 #include <assert.h>
23 #endif
24
25 #include "apr_tables.h"
26 #include <stddef.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
40 #ifndef WIN32
50 #define APREQ_DECLARE(d) APR_DECLARE(d)
60 #define APREQ_DECLARE_NONSTD(d) APR_DECLARE_NONSTD(d)
71 #define APREQ_DECLARE_DATA
72 #elif defined (APREQ_DECLARE_STATIC)
73 #define APREQ_DECLARE(type) type __stdcall
74 #define APREQ_DECLARE_NONSTD(type) type
75 #define APREQ_DECLARE_DATA
76 #elif defined (APREQ_DECLARE_EXPORT)
77 #define APREQ_DECLARE(type) __declspec(dllexport) type __stdcall
78 #define APREQ_DECLARE_NONSTD(type) __declspec(dllexport) type
79 #define APREQ_DECLARE_DATA __declspec(dllexport)
80 #else
81 #define APREQ_DECLARE(type) __declspec(dllimport) type __stdcall
82 #define APREQ_DECLARE_NONSTD(type) __declspec(dllimport) type
83 #define APREQ_DECLARE_DATA __declspec(dllimport)
84 #endif
85
90 #define APREQ_DEFAULT_READ_BLOCK_SIZE (64 * 1024)
91
98 #define APREQ_DEFAULT_READ_LIMIT (64 * 1024 * 1024)
105 #define APREQ_DEFAULT_BRIGADE_LIMIT (256 * 1024)
106
111 #define APREQ_DEFAULT_NELTS 8
112
113
114
118 #define APREQ_FLAGS_OFF(f, name) ((f) &= ~(name##_MASK << name##_BIT))
122 #define APREQ_FLAGS_ON(f, name) ((f) |= (name##_MASK << name##_BIT))
126 #define APREQ_FLAGS_GET(f, name) (((f) >> name##_BIT) & name##_MASK)
133 #define APREQ_FLAGS_SET(f, name, value) \
134 ((f) = (((f) & ~(name##_MASK << name##_BIT)) \
135 | ((name##_MASK & (value)) << name##_BIT)))
136
142 #define APREQ_CHARSET_BIT 0
143
149 #define APREQ_CHARSET_MASK 255
150
156 #define APREQ_TAINTED_BIT 8
162 #define APREQ_TAINTED_MASK 1
163
170 #define APREQ_COOKIE_VERSION_BIT 11
176 #define APREQ_COOKIE_VERSION_MASK 3
177
183 #define APREQ_COOKIE_SECURE_BIT 13
189 #define APREQ_COOKIE_SECURE_MASK 1
190
196 #define APREQ_COOKIE_HTTPONLY_BIT 14
202 #define APREQ_COOKIE_HTTPONLY_MASK 1
203
205 typedef enum {
206 APREQ_CHARSET_ASCII =0,
207 APREQ_CHARSET_LATIN1 =1, /* ISO-8859-1 */
208 APREQ_CHARSET_CP1252 =2, /* Windows-1252 */
209 APREQ_CHARSET_UTF8 =8
210 } apreq_charset_t;
211
212
214 typedef enum {
215 APREQ_JOIN_AS_IS,
216 APREQ_JOIN_ENCODE,
217 APREQ_JOIN_DECODE,
218 APREQ_JOIN_QUOTE
219 } apreq_join_t;
220
222 typedef enum {
223 APREQ_MATCH_FULL,
224 APREQ_MATCH_PARTIAL
225 } apreq_match_t;
226
228 typedef enum {
229 APREQ_EXPIRES_HTTP,
230 APREQ_EXPIRES_NSCOOKIE
231 } apreq_expires_t;
232
233
235 typedef struct apreq_value_t {
236 char *name;
237 apr_size_t nlen;
238 apr_size_t dlen;
239 char data[1];
240 } apreq_value_t;
241
253 static APR_INLINE
254 void apreq_value_table_add(const apreq_value_t *v, apr_table_t *t) {
255 apr_table_addn(t, v->name, v->data);
256 }
257
265 #define apreq_attr_to_type(T,A,P) ( (T*) ((char*)(P)-offsetof(T,A)) )
266
278 APREQ_DECLARE(apr_status_t) apreq_initialize(apr_pool_t *pool);
279
280
292 APREQ_DECLARE(apr_status_t) apreq_pre_initialize(apr_pool_t *pool);
293
301 APREQ_DECLARE(apr_status_t) apreq_post_initialize(apr_pool_t *pool);
302
303
304 #ifdef __cplusplus
305 }
306 #endif
307
308 #endif /* APREQ_H */
APREQ_DECLARE
#define APREQ_DECLARE(d)
Definition: apreq.h:50
apreq_value_table_add
static APR_INLINE void apreq_value_table_add(const apreq_value_t *v, apr_table_t *t)
Definition: apreq.h:254
apreq_initialize
apr_status_t apreq_initialize(apr_pool_t *pool)
apreq_match_t
apreq_match_t
Definition: apreq.h:222
APREQ_MATCH_PARTIAL
@ APREQ_MATCH_PARTIAL
Definition: apreq.h:224
APREQ_MATCH_FULL
@ APREQ_MATCH_FULL
Definition: apreq.h:223
apreq_charset_t
apreq_charset_t
Definition: apreq.h:205
apreq_join_t
apreq_join_t
Definition: apreq.h:214
APREQ_JOIN_ENCODE
@ APREQ_JOIN_ENCODE
Definition: apreq.h:216
APREQ_JOIN_AS_IS
@ APREQ_JOIN_AS_IS
Definition: apreq.h:215
APREQ_JOIN_DECODE
@ APREQ_JOIN_DECODE
Definition: apreq.h:217
APREQ_JOIN_QUOTE
@ APREQ_JOIN_QUOTE
Definition: apreq.h:218
apreq_post_initialize
apr_status_t apreq_post_initialize(apr_pool_t *pool)
apreq_value_t
struct apreq_value_t apreq_value_t
libapreq's pre-extensible string type
apreq_expires_t
apreq_expires_t
Definition: apreq.h:228
APREQ_EXPIRES_NSCOOKIE
@ APREQ_EXPIRES_NSCOOKIE
Definition: apreq.h:230
APREQ_EXPIRES_HTTP
@ APREQ_EXPIRES_HTTP
Definition: apreq.h:229
apreq_pre_initialize
apr_status_t apreq_pre_initialize(apr_pool_t *pool)
apreq_value_t
libapreq's pre-extensible string type
Definition: apreq.h:235
apreq_value_t::name
char * name
Definition: apreq.h:236
apreq_value_t::data
char data[1]
Definition: apreq.h:239
apreq_value_t::dlen
apr_size_t dlen
Definition: apreq.h:238
apreq_value_t::nlen
apr_size_t nlen
Definition: apreq.h:237