xref: /PHP-8.1/sapi/apache2handler/php_apache.h (revision 01b3fc03)
1 /*
2    +----------------------------------------------------------------------+
3    | Copyright (c) The PHP Group                                          |
4    +----------------------------------------------------------------------+
5    | This source file is subject to version 3.01 of the PHP license,      |
6    | that is bundled with this package in the file LICENSE, and is        |
7    | available through the world-wide-web at the following url:           |
8    | https://www.php.net/license/3_01.txt                                 |
9    | If you did not receive a copy of the PHP license and are unable to   |
10    | obtain it through the world-wide-web, please send a note to          |
11    | license@php.net so we can mail you a copy immediately.               |
12    +----------------------------------------------------------------------+
13    | Author: Sascha Schumann <sascha@schumann.cx>                         |
14    +----------------------------------------------------------------------+
15  */
16 
17 #ifndef PHP_APACHE_H
18 #define PHP_APACHE_H
19 
20 #include "httpd.h"
21 #include "http_config.h"
22 #include "http_core.h"
23 #include "http_log.h"
24 
25 #include "php.h"
26 #include "main/php_streams.h"
27 
28 /* Enable per-module logging in Apache 2.4+ */
29 #ifdef APLOG_USE_MODULE
30 APLOG_USE_MODULE(php);
31 #endif
32 
33 /* Declare this so we can get to it from outside the sapi_apache2.c file */
34 extern module AP_MODULE_DECLARE_DATA php_module;
35 
36 /* A way to specify the location of the php.ini dir in an apache directive */
37 extern char *apache2_php_ini_path_override;
38 
39 /* The server_context used by PHP */
40 typedef struct php_struct {
41 	int state;
42 	request_rec *r;
43 	apr_bucket_brigade *brigade;
44 	/* stat structure of the current file */
45 	zend_stat_t finfo;
46 	/* Whether or not we've processed PHP in the output filters yet. */
47 	int request_processed;
48 	/* final content type */
49 	char *content_type;
50 } php_struct;
51 
52 void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf);
53 void *create_php_config(apr_pool_t *p, char *dummy);
54 char *get_php_config(void *conf, char *name, size_t name_len);
55 void apply_config(void *);
56 extern const command_rec php_dir_cmds[];
57 void php_ap2_register_hook(apr_pool_t *p);
58 
59 #define APR_ARRAY_FOREACH_OPEN(arr, key, val) 		\
60 {													\
61 	apr_table_entry_t *elts;						\
62 	int i;											\
63 	elts = (apr_table_entry_t *) arr->elts;			\
64 	for (i = 0; i < arr->nelts; i++) {				\
65 		key = elts[i].key;							\
66 		val = elts[i].val;
67 
68 #define APR_ARRAY_FOREACH_CLOSE() }}
69 
70 typedef struct {
71 	bool engine;
72 	bool xbithack;
73 	bool last_modified;
74 } php_apache2_info_struct;
75 
76 extern zend_module_entry apache2_module_entry;
77 
78 #ifdef ZTS
79 extern int php_apache2_info_id;
80 #define AP2(v) ZEND_TSRMG(php_apache2_info_id, php_apache2_info_struct *, v)
81 ZEND_TSRMLS_CACHE_EXTERN()
82 #else
83 extern php_apache2_info_struct php_apache2_info;
84 #define AP2(v) (php_apache2_info.v)
85 #endif
86 
87 /* fix for gcc4 visibility patch */
88 #ifndef PHP_WIN32
89 # undef AP_MODULE_DECLARE_DATA
90 # define AP_MODULE_DECLARE_DATA PHPAPI
91 #endif
92 
93 #endif /* PHP_APACHE_H */
94