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_ENV_H 00018 #define APREQ_ENV_H 00019 00020 #include "apreq_params.h" 00021 #include "apreq_cookie.h" 00022 #include <stdarg.h> 00023 00024 #ifdef HAVE_SYSLOG 00025 #include <syslog.h> 00026 00027 #ifndef LOG_PRIMASK 00028 #define LOG_PRIMASK 7 00029 #endif 00030 00031 00032 #define APREQ_LOG_EMERG LOG_EMERG /* system is unusable */ 00033 #define APREQ_LOG_ALERT LOG_ALERT /* action must be taken immediately */ 00034 #define APREQ_LOG_CRIT LOG_CRIT /* critical conditions */ 00035 #define APREQ_LOG_ERR LOG_ERR /* error conditions */ 00036 #define APREQ_LOG_WARNING LOG_WARNING /* warning conditions */ 00037 #define APREQ_LOG_NOTICE LOG_NOTICE /* normal but significant condition */ 00038 #define APREQ_LOG_INFO LOG_INFO /* informational */ 00039 #define APREQ_LOG_DEBUG LOG_DEBUG /* debug-level messages */ 00040 00041 #define APREQ_LOG_LEVELMASK LOG_PRIMASK /* mask off the level value */ 00042 00043 #else 00044 00045 #define APREQ_LOG_EMERG 0 /* system is unusable */ 00046 #define APREQ_LOG_ALERT 1 /* action must be taken immediately */ 00047 #define APREQ_LOG_CRIT 2 /* critical conditions */ 00048 #define APREQ_LOG_ERR 3 /* error conditions */ 00049 #define APREQ_LOG_WARNING 4 /* warning conditions */ 00050 #define APREQ_LOG_NOTICE 5 /* normal but significant condition */ 00051 #define APREQ_LOG_INFO 6 /* informational */ 00052 #define APREQ_LOG_DEBUG 7 /* debug-level messages */ 00053 00054 #define APREQ_LOG_LEVELMASK 7 /* mask off the level value */ 00055 00056 #endif 00057 00058 #define APREQ_LOG_MARK __FILE__ , __LINE__ 00059 00060 #define APREQ_DEBUG APREQ_LOG_MARK, APREQ_LOG_DEBUG, 00061 #define APREQ_WARN APREQ_LOG_MARK, APREQ_LOG_WARNING, 00062 #define APREQ_ERROR APREQ_LOG_MARK, APREQ_LOG_ERR, 00063 00064 #ifdef __cplusplus 00065 extern "C" { 00066 #endif 00067 00084 APREQ_DECLARE_NONSTD(void) apreq_log(const char *file, int line, 00085 int level, apr_status_t status, 00086 void *env, const char *fmt, ...); 00093 APREQ_DECLARE(apr_pool_t *) apreq_env_pool(void *env); 00094 00103 APREQ_DECLARE(apreq_jar_t *) apreq_env_jar(void *env, apreq_jar_t *jar); 00104 00113 APREQ_DECLARE(apreq_request_t *) apreq_env_request(void *env, 00114 apreq_request_t *req); 00115 00121 APREQ_DECLARE(const char *) apreq_env_query_string(void *env); 00122 00130 APREQ_DECLARE(const char *) apreq_env_header_in(void *env, const char *name); 00131 00132 00138 #define apreq_env_content_type(env) apreq_env_header_in(env, "Content-Type") 00139 00140 00146 #define apreq_env_cookie(env) apreq_env_header_in(env, "Cookie") 00147 00153 #define apreq_env_cookie2(env) apreq_env_header_in(env, "Cookie2") 00154 00162 APREQ_DECLARE(apr_status_t)apreq_env_header_out(void *env, 00163 const char *name, 00164 char *val); 00165 00172 #define apreq_env_set_cookie(e,s) apreq_env_header_out(e,"Set-Cookie",s) 00173 00180 #define apreq_env_set_cookie2(e,s) apreq_env_header_out(e,"Set-Cookie2",s) 00181 00191 APREQ_DECLARE(apr_status_t) apreq_env_read(void *env, 00192 apr_read_type_e block, 00193 apr_off_t bytes); 00194 00203 APREQ_DECLARE(const char *) apreq_env_temp_dir(void *env, const char *path); 00204 00215 APREQ_DECLARE(apr_off_t) apreq_env_max_body(void *env, apr_off_t bytes); 00216 00227 APREQ_DECLARE(apr_ssize_t) apreq_env_max_brigade(void *env, apr_ssize_t bytes); 00228 00236 typedef struct apreq_env_t { 00237 const char *name; 00238 apr_uint32_t magic_number; 00239 void (*log)(const char *,int,int,apr_status_t,void *,const char *,va_list); 00240 apr_pool_t *(*pool)(void *); 00241 apreq_jar_t *(*jar)(void *,apreq_jar_t *); 00242 apreq_request_t *(*request)(void *,apreq_request_t *); 00243 const char *(*query_string)(void *); 00244 const char *(*header_in)(void *,const char *); 00245 apr_status_t (*header_out)(void *, const char *,char *); 00246 apr_status_t (*read)(void *,apr_read_type_e,apr_off_t); 00247 const char *(*temp_dir)(void *, const char *); 00248 apr_off_t (*max_body)(void *,apr_off_t); 00249 apr_ssize_t (*max_brigade)(void *, apr_ssize_t); 00250 } apreq_env_t; 00251 00261 #define APREQ_ENV_MODULE(pre, name, mmn) const apreq_env_t pre##_module = { \ 00262 name, mmn, pre##_log, pre##_pool, pre##_jar, pre##_request, \ 00263 pre##_query_string, pre##_header_in, pre##_header_out, pre##_read, \ 00264 pre##_temp_dir, pre##_max_body, pre##_max_brigade } 00265 00266 00274 APREQ_DECLARE(const apreq_env_t *) apreq_env_module(const apreq_env_t *mod); 00275 00279 #define apreq_env_name (apreq_env_module(NULL)->name) 00280 00284 #define apreq_env_magic_number (apreq_env_module(NULL)->magic_number) 00285 00286 #ifdef __cplusplus 00287 } 00288 #endif 00289 00290 #endif