Imported Upstream version 2.5.11
[libapache-mod-security.git] / apache2 / apache2.h
1 /*
2  * ModSecurity for Apache 2.x, http://www.modsecurity.org/
3  * Copyright (c) 2004-2009 Breach Security, Inc. (http://www.breach.com/)
4  *
5  * This product is released under the terms of the General Public Licence,
6  * version 2 (GPLv2). Please refer to the file LICENSE (included with this
7  * distribution) which contains the complete text of the licence.
8  *
9  * There are special exceptions to the terms and conditions of the GPL
10  * as it is applied to this software. View the full text of the exception in
11  * file MODSECURITY_LICENSING_EXCEPTION in the directory of this software
12  * distribution.
13  *
14  * If any of the files related to licensing are missing or if you have any
15  * other questions related to licensing please contact Breach Security, Inc.
16  * directly using the email address support@breach.com.
17  *
18  */
19 #ifndef _APACHE2_H_
20 #define _APACHE2_H_
21
22 #include "http_core.h"
23 #include "http_request.h"
24 #include "httpd.h"
25 #include "ap_release.h"
26
27 #include <apr_general.h>
28 #include <apr_optional.h>
29
30
31 #if (!defined(NO_MODSEC_API))
32 /* Optional functions. */
33
34 APR_DECLARE_OPTIONAL_FN(void, modsec_register_tfn, (const char *name, void *fn));
35 APR_DECLARE_OPTIONAL_FN(void, modsec_register_operator, (const char *name, void *fn_init, void *fn_exec));
36 APR_DECLARE_OPTIONAL_FN(void, modsec_register_variable,
37     (const char *name, unsigned int type,
38      unsigned int argc_min, unsigned int argc_max,
39      void *fn_validate, void *fn_generate,
40      unsigned int is_cacheable, unsigned int availability));
41 #endif
42
43 /* ap_get_server_version() is gone in 2.3.0.
44  * It was replaced by two calls in 2.2.4 and higher:
45  *   ap_get_server_banner()
46  *   ap_get_server_description()
47  */
48 #if (AP_SERVER_MAJORVERSION_NUMBER > 2) \
49     || ((AP_SERVER_MAJORVERSION_NUMBER == 2)&& (AP_SERVER_MINORVERSION_NUMBER > 2)) \
50     || ((AP_SERVER_MAJORVERSION_NUMBER == 2) && (AP_SERVER_MINORVERSION_NUMBER == 2) && (AP_SERVER_PATCHLEVEL_NUMBER >= 4))
51 #define apache_get_server_version() ap_get_server_banner()
52 #else
53 #define apache_get_server_version() ap_get_server_version()
54 #endif
55
56
57 /* Configuration functions. */
58
59 void DSOLOCAL *create_directory_config(apr_pool_t *mp, char *path);
60
61 void DSOLOCAL *merge_directory_configs(apr_pool_t *mp, void *_parent, void *_child);
62
63 void DSOLOCAL init_directory_config(directory_config *dcfg);
64
65
66 /* IO functions. */
67
68 apr_status_t DSOLOCAL input_filter(ap_filter_t *f, apr_bucket_brigade *bb_out,
69     ap_input_mode_t mode, apr_read_type_e block, apr_off_t nbytes);
70
71 apr_status_t DSOLOCAL output_filter(ap_filter_t *f, apr_bucket_brigade *bb_in);
72
73 apr_status_t DSOLOCAL read_request_body(modsec_rec *msr, char **error_msg);
74
75
76 /* Utility functions */
77
78 int DSOLOCAL perform_interception(modsec_rec *msr);
79
80 apr_status_t DSOLOCAL send_error_bucket(modsec_rec *msr, ap_filter_t *f, int status);
81
82 int DSOLOCAL apache2_exec(modsec_rec *msr, const char *command, const char **argv, char **output);
83
84 void DSOLOCAL record_time_checkpoint(modsec_rec *msr, int checkpoint_no);
85
86 char DSOLOCAL *get_apr_error(apr_pool_t *p, apr_status_t rc);
87
88 char DSOLOCAL *get_env_var(request_rec *r, char *name);
89
90 void DSOLOCAL internal_log_ex(request_rec *r, directory_config *dcfg, modsec_rec *msr,
91     int level, int fixup, const char *text, va_list ap);
92
93 void DSOLOCAL internal_log(request_rec *r, directory_config *dcfg, modsec_rec *msr,
94     int level, const char *text, va_list ap);
95
96 void DSOLOCAL msr_log(modsec_rec *msr, int level, const char *text, ...) PRINTF_ATTRIBUTE(3,4);
97
98 void DSOLOCAL msr_log_error(modsec_rec *msr, const char *text, ...) PRINTF_ATTRIBUTE(2,3);
99
100 void DSOLOCAL msr_log_warn(modsec_rec *msr, const char *text, ...) PRINTF_ATTRIBUTE(2,3);
101
102 char DSOLOCAL *format_error_log_message(apr_pool_t *mp, error_message *em);
103
104 const DSOLOCAL char *get_response_protocol(request_rec *r);
105
106
107 #endif
108