00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #ifndef APREQ_ENV_H
00055 #define APREQ_ENV_H
00056
00057 #include "apreq_params.h"
00058 #include "apreq_cookie.h"
00059 #include "apreq_parsers.h"
00060
00061 #ifdef HAVE_SYSLOG
00062 #include <syslog.h>
00063
00064 #ifndef LOG_PRIMASK
00065 #define LOG_PRIMASK 7
00066 #endif
00067
00068
00069 #define APREQ_LOG_EMERG LOG_EMERG
00070 #define APREQ_LOG_ALERT LOG_ALERT
00071 #define APREQ_LOG_CRIT LOG_CRIT
00072 #define APREQ_LOG_ERR LOG_ERR
00073 #define APREQ_LOG_WARNING LOG_WARNING
00074 #define APREQ_LOG_NOTICE LOG_NOTICE
00075 #define APREQ_LOG_INFO LOG_INFO
00076 #define APREQ_LOG_DEBUG LOG_DEBUG
00077
00078 #define APREQ_LOG_LEVELMASK LOG_PRIMASK
00079
00080 #else
00081
00082 #define APREQ_LOG_EMERG 0
00083 #define APREQ_LOG_ALERT 1
00084 #define APREQ_LOG_CRIT 2
00085 #define APREQ_LOG_ERR 3
00086 #define APREQ_LOG_WARNING 4
00087 #define APREQ_LOG_NOTICE 5
00088 #define APREQ_LOG_INFO 6
00089 #define APREQ_LOG_DEBUG 7
00090
00091 #define APREQ_LOG_LEVELMASK 7
00092
00093 #endif
00094
00095 #define APREQ_LOG_MARK __FILE__ , __LINE__
00096
00097 #define APREQ_DEBUG APREQ_LOG_MARK, APREQ_LOG_DEBUG,
00098 #define APREQ_WARN APREQ_LOG_MARK, APREQ_LOG_WARNING,
00099 #define APREQ_ERROR APREQ_LOG_MARK, APREQ_LOG_ERR,
00100
00101 #ifdef __cplusplus
00102 extern "C" {
00103 #endif
00104
00115 APREQ_DECLARE_NONSTD(void) apreq_log(const char *file, int line,
00116 int level, apr_status_t status,
00117 void *env, const char *fmt, ...);
00118
00119 APREQ_DECLARE(apr_pool_t *) apreq_env_pool(void *env);
00120 APREQ_DECLARE(apreq_jar_t *) apreq_env_jar(void *env, apreq_jar_t *jar);
00121 APREQ_DECLARE(apreq_request_t *) apreq_env_request(void *env,
00122 apreq_request_t *req);
00123
00124 APREQ_DECLARE(const char *) apreq_env_query_string(void *env);
00125 APREQ_DECLARE(const char *) apreq_env_header_in(void *env, const char *name);
00126
00127
00128 #define apreq_env_content_type(env) apreq_env_header_in(env, "Content-Type")
00129 #define apreq_env_cookie(env) apreq_env_header_in(env, "Cookie")
00130 #define apreq_env_cookie2(env) apreq_env_header_in(env, "Cookie2")
00131
00132 APREQ_DECLARE(apr_status_t)apreq_env_header_out(void *env,
00133 const char *name,
00134 char *val);
00135
00136 #define apreq_env_set_cookie(e,s) apreq_env_header_out(e,"Set-Cookie",s)
00137 #define apreq_env_set_cookie2(e,s) apreq_env_header_out(e,"Set-Cookie2",s)
00138
00139 APREQ_DECLARE(apr_status_t) apreq_env_read(void *env,
00140 apr_read_type_e block,
00141 apr_off_t bytes);
00142
00143 typedef struct apreq_env_t {
00144 const char *name;
00145 apr_uint32_t magic_number;
00146 void (*log)(const char *,int,int,apr_status_t,void *,const char *,va_list);
00147 apr_pool_t *(*pool)(void *);
00148 apreq_jar_t *(*jar)(void *,apreq_jar_t *);
00149 apreq_request_t *(*request)(void *,apreq_request_t *);
00150 const char *(*query_string)(void *);
00151 const char *(*header_in)(void *,const char *);
00152 apr_status_t (*header_out)(void *, const char *,char *);
00153 apr_status_t (*read)(void *,apr_read_type_e,apr_off_t);
00154 } apreq_env_t;
00155
00156 #define APREQ_ENV_MODULE(pre, name, mmn) const apreq_env_t pre##_module = { \
00157 name, mmn, pre##_log, pre##_pool, pre##_jar, pre##_request, \
00158 pre##_query_string, pre##_header_in, pre##_header_out, pre##_read }
00159
00160
00161 APREQ_DECLARE(const apreq_env_t *) apreq_env_module(const apreq_env_t *mod);
00162
00163 #define apreq_env_name (apreq_env_module(NULL)->name)
00164 #define apreq_env_magic_number (apreq_env_module(NULL)->magic_number)
00165
00167 #ifdef __cplusplus
00168 }
00169 #endif
00170
00171 #endif