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_H 00018 #define APREQ_H 00019 00020 #include "apr_tables.h" 00021 #include "apr_file_io.h" 00022 #include "apr_buckets.h" 00023 #include <stddef.h> 00024 00025 #ifdef __cplusplus 00026 extern "C" { 00027 #endif 00028 00042 #ifndef WIN32 00043 #define APREQ_DECLARE(d) APR_DECLARE(d) 00044 #define APREQ_DECLARE_NONSTD(d) APR_DECLARE_NONSTD(d) 00045 #define APREQ_DECLARE_DATA 00046 #else 00047 #define APREQ_DECLARE(type) __declspec(dllexport) type __stdcall 00048 #define APREQ_DECLARE_NONSTD(type) __declspec(dllexport) type 00049 #define APREQ_DECLARE_DATA __declspec(dllexport) 00050 #endif 00051 00052 #define APREQ_URL_ENCTYPE "application/x-www-form-urlencoded" 00053 #define APREQ_MFD_ENCTYPE "multipart/form-data" 00054 #define APREQ_XML_ENCTYPE "application/xml" 00055 00056 #define APREQ_NELTS 8 00057 #define APREQ_READ_AHEAD (64 * 1024) 00058 00062 #define APREQ_MAX_BRIGADE_LEN (256 * 1024) 00063 00064 00066 typedef struct apreq_value_t { 00067 const char *name; 00068 apr_size_t size; 00069 char data[1]; 00070 } apreq_value_t; 00071 00072 typedef apreq_value_t *(apreq_value_merge_t)(apr_pool_t *p, 00073 const apr_array_header_t *a); 00074 typedef apreq_value_t *(apreq_value_copy_t)(apr_pool_t *p, 00075 const apreq_value_t *v); 00076 00077 00078 #define apreq_attr_to_type(T,A,P) ( (T*) ((char*)(P)-offsetof(T,A)) ) 00079 00087 #define apreq_char_to_value(ptr) apreq_attr_to_type(apreq_value_t, data, ptr) 00088 #define apreq_strtoval(ptr) apreq_char_to_value(ptr) 00089 00098 #define apreq_strlen(ptr) (apreq_strtoval(ptr)->size) 00099 00113 APREQ_DECLARE(apreq_value_t *) apreq_make_value(apr_pool_t *p, 00114 const char *name, 00115 const apr_size_t nlen, 00116 const char *val, 00117 const apr_size_t vlen); 00118 00124 APREQ_DECLARE(apreq_value_t *) apreq_copy_value(apr_pool_t *p, 00125 const apreq_value_t *val); 00126 00132 apreq_value_t * apreq_merge_values(apr_pool_t *p, 00133 const apr_array_header_t *arr); 00134 00139 APREQ_DECLARE(const char *)apreq_enctype(void *env); 00140 00142 typedef enum { 00143 APREQ_JOIN_AS_IS, 00144 APREQ_JOIN_ENCODE, 00145 APREQ_JOIN_DECODE, 00146 APREQ_JOIN_QUOTE 00147 } apreq_join_t; 00148 00158 APREQ_DECLARE(const char *) apreq_join(apr_pool_t *p, 00159 const char *sep, 00160 const apr_array_header_t *arr, 00161 apreq_join_t mode); 00162 00163 00165 typedef enum { 00166 APREQ_MATCH_FULL, 00167 APREQ_MATCH_PARTIAL 00168 } apreq_match_t; 00169 00179 APREQ_DECLARE(char *) apreq_memmem(char* hay, apr_size_t hlen, 00180 const char* ndl, apr_size_t nlen, 00181 const apreq_match_t type); 00182 00193 APREQ_DECLARE(apr_ssize_t) apreq_index(const char* hay, apr_size_t hlen, 00194 const char* ndl, apr_size_t nlen, 00195 const apreq_match_t type); 00206 APREQ_DECLARE(apr_size_t) apreq_quote(char *dest, const char *src, 00207 const apr_size_t slen); 00208 00219 APREQ_DECLARE(apr_size_t) apreq_quote_once(char *dest, const char *src, 00220 const apr_size_t slen); 00221 00230 APREQ_DECLARE(apr_size_t) apreq_encode(char *dest, const char *src, 00231 const apr_size_t slen); 00232 00242 APREQ_DECLARE(apr_ssize_t) apreq_decode(char *dest, const char *src, apr_size_t slen); 00243 00244 00256 APREQ_DECLARE(apr_status_t) apreq_decodev(char *d, apr_size_t *dlen, 00257 struct iovec *v, int nelts); 00258 00268 APREQ_DECLARE(char *) apreq_escape(apr_pool_t *p, 00269 const char *src, const apr_size_t slen); 00270 00278 APREQ_DECLARE(apr_ssize_t) apreq_unescape(char *str); 00279 00280 00282 typedef enum { 00283 APREQ_EXPIRES_HTTP, 00284 APREQ_EXPIRES_NSCOOKIE 00285 } apreq_expires_t; 00286 00302 APREQ_DECLARE(char *) apreq_expires(apr_pool_t *p, const char *time_str, 00303 const apreq_expires_t type); 00304 00311 APREQ_DECLARE(apr_int64_t) apreq_atoi64f(const char *s); 00312 00319 APREQ_DECLARE(apr_int64_t) apreq_atoi64t(const char *s); 00320 00332 APREQ_DECLARE(apr_status_t) apreq_brigade_fwrite(apr_file_t *f, 00333 apr_off_t *wlen, 00334 apr_bucket_brigade *bb); 00347 APREQ_DECLARE(apr_status_t) apreq_file_mktemp(apr_file_t **fp, 00348 apr_pool_t *pool, 00349 const char *path); 00350 00359 APREQ_DECLARE(apr_file_t *) apreq_brigade_spoolfile(apr_bucket_brigade *bb); 00360 00367 #define APREQ_BRIGADE_SETASIDE(bb,p) do { \ 00368 apr_bucket *e; \ 00369 for (e = APR_BRIGADE_FIRST(bb); e != APR_BRIGADE_SENTINEL(bb); \ 00370 e = APR_BUCKET_NEXT(e)) \ 00371 { \ 00372 apr_bucket_setaside(e, p); \ 00373 } \ 00374 } while (0) 00375 00376 00384 #define APREQ_BRIGADE_COPY(d,s) do { \ 00385 apr_bucket *e; \ 00386 for (e = APR_BRIGADE_FIRST(s); e != APR_BRIGADE_SENTINEL(s); \ 00387 e = APR_BUCKET_NEXT(e)) \ 00388 { \ 00389 apr_bucket *c; \ 00390 apr_bucket_copy(e, &c); \ 00391 APR_BRIGADE_INSERT_TAIL(d, c); \ 00392 } \ 00393 } while (0) 00394 00395 00405 APREQ_DECLARE(apr_status_t) 00406 apreq_header_attribute(const char *hdr, 00407 const char *name, const apr_size_t nlen, 00408 const char **val, apr_size_t *vlen); 00409 00410 00411 #ifdef __cplusplus 00412 } 00413 #endif 00414 00415 #endif /* APREQ_H */