OSDN Git Service

Merge branch 'branch_0.13.0' into branch_0.13.0-svn
[modchxj/mod_chxj.git] / include / chxj_apache.h
1 /*
2  * Copyright (C) 2005-2009 Atsushi Konno All rights reserved.
3  * Copyright (C) 2005 QSDN,Inc. All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * 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 #ifndef __CHXJ_APACHE_H__
18 #define __CHXJ_APACHE_H__
19
20
21 #if defined(CHXJ_TEST)
22 #  define chxj_log_rerror test_log_rerror
23 #  define chxj_log_perror test_log_perror
24 #  define chxj_log_error test_log_error
25 #  define chxj_run_http_scheme test_run_http_scheme
26 #  include "apr.h"
27 #  include "apr_pools.h"
28 #  include "apr_tables.h"
29 #  include "apr_uri.h"
30 #  define APLOG_EMERG 0   /* system is unusable */
31 #  define APLOG_ALERT 1   /* action must be taken immediately */
32 #  define APLOG_CRIT  2   /* critical conditions */
33 #  define APLOG_ERR   3   /* error conditions */
34 #  define APLOG_WARNING   4   /* warning conditions */
35 #  define APLOG_NOTICE    5   /* normal but significant condition */
36 #  define APLOG_INFO  6   /* informational */
37 #  define APLOG_DEBUG 7   /* debug-level messages */
38 #  define APLOG_LEVELMASK 7   /* mask off the level value */
39 #  ifndef __CONFIG_H__
40 #    define __CONFIG_H__
41 #    undef PACKAGE_NAME
42 #    undef PACKAGE_STRING
43 #    undef PACKAGE_TARNAME
44 #    undef PACKAGE_VERSION
45 #    include "test_config.h"
46 #  endif
47 #  define AP_MODULE_DECLARE_DATA
48 #  define APLOG_MARK   __FILE__,__LINE__
49 #  undef ap_regex_t
50 typedef struct module_struct module;
51 struct module_struct {
52     int version;
53     int minor_version;
54     int module_index;
55     const char *name;
56     void *dynamic_load_handle;
57     struct module_struct *next;
58     unsigned long magic;
59     void (*rewrite_args) (void *process);
60     void *(*create_dir_config) (apr_pool_t *p, char *dir);
61     void *(*merge_dir_config) (apr_pool_t *p, void *base_conf, void *new_conf);
62     void *(*create_server_config) (apr_pool_t *p, void *s);
63     void *(*merge_server_config) (apr_pool_t *p, void *base_conf, void *new_conf);
64     const void *cmds;
65     void (*register_hooks) (apr_pool_t *p);
66 };
67 typedef struct ap_conf_vector_t ap_conf_vector_t;
68 typedef struct test_request_rec {
69   apr_pool_t *pool;
70   ap_conf_vector_t *per_dir_config;
71   apr_table_t *headers_in;
72   apr_table_t *headers_out;
73   apr_table_t *err_headers_out;
74   char *uri;
75   char *args;
76   char *hostname;
77   char *unparsed_uri;
78   apr_uri_t parsed_uri;
79 } request_rec;
80 #include "pcre.h"
81 typedef struct {
82     void *re_pcre;
83     apr_size_t re_nsub;
84     apr_size_t re_erroffset;
85 } ap_regex_t;
86 #undef ap_regmatch_t
87 typedef struct {
88     int rm_so;
89     int rm_eo;
90 } ap_regmatch_t;
91
92
93 extern void test_log_error(const char *file, int line, int level, apr_status_t status, const request_rec *r, const char *fmt, ...);
94 extern void test_log_rerror(const char *file, int line, int level, apr_status_t status, const request_rec *r, const char *fmt, ...);
95 extern void test_log_perror(const char *file, int line, int level, apr_status_t status, apr_pool_t *p, const char *fmt, ...);
96 extern const char *test_run_http_scheme(request_rec *r);
97 extern char *test_os_escape_path(apr_pool_t *p, const char *path, int partial);
98 extern void test_set_content_type(request_rec *r, const char *ct);
99 extern void *test_get_module_config(const ap_conf_vector_t *cv, const module *m);
100 extern char *test_ap_escape_html(apr_pool_t *p, const char *s);
101
102 #else
103 #  include "httpd.h"
104 #  include "http_config.h"
105 #  include "http_protocol.h"
106 #  include "http_request.h"
107 #  include "http_log.h"
108 #  include "ap_config.h"
109 #  include "util_filter.h"
110 #  ifndef __CONFIG_H__
111 #    define __CONFIG_H__
112
113 #    undef PACKAGE_NAME
114 #    undef PACKAGE_STRING
115 #    undef PACKAGE_TARNAME
116 #    undef PACKAGE_VERSION
117 #    undef PACKAGE_BUGREPORT
118 #    include "config.h"
119 #  endif
120 #  define chxj_log_rerror ap_log_rerror
121 #  define chxj_log_error ap_log_error
122 #  define chxj_log_perror ap_log_perror
123 #  define chxj_run_http_scheme chxj_apache_run_http_scheme
124 #endif
125
126 #define chxj_escape_uri(p,path) chxj_os_escape_path(p,path,1)
127
128 extern const char *chxj_apache_run_http_scheme(request_rec *r);
129 extern char * chxj_os_escape_path(apr_pool_t *p, const char *path, int partial);
130 extern void chxj_set_content_type(request_rec *r, const char *ct);
131 extern void * chxj_get_module_config(const ap_conf_vector_t *cv, const module *m);
132 extern char *chxj_ap_escape_html(apr_pool_t *p, const char *s);
133 extern ap_regex_t *chxj_ap_pregcomp(apr_pool_t *p, const char *pattern, int cflags);
134 extern void chxj_ap_pregfree(apr_pool_t *p, ap_regex_t *reg);
135 extern int chxj_ap_regexec(const ap_regex_t *preg, const char *string, apr_size_t nmatch, ap_regmatch_t *pmatch, int eflags);
136 extern int chxj_ap_regcomp(ap_regex_t *preg, const char *pattern, int cflags);
137 extern char *chxj_ap_pregsub(apr_pool_t *p, const char *input, const char *source, size_t nmatch, ap_regmatch_t pmatch[]);
138
139
140 #endif
141 /*
142  * vim:ts=2 et
143  */