| 1 |
/* |
|---|
| 2 |
+----------------------------------------------------------------------+ |
|---|
| 3 |
| Turck MMCache for PHP Version 4 | |
|---|
| 4 |
+----------------------------------------------------------------------+ |
|---|
| 5 |
| Copyright (c) 2002-2003 TurckSoft, St. Petersburg | |
|---|
| 6 |
| http://www.turcksoft.com | |
|---|
| 7 |
+----------------------------------------------------------------------+ |
|---|
| 8 |
| This program is free software; you can redistribute it and/or | |
|---|
| 9 |
| modify it under the terms of the GNU General Public License | |
|---|
| 10 |
| as published by the Free Software Foundation; either version 2 | |
|---|
| 11 |
| of the License, or (at your option) any later version. | |
|---|
| 12 |
| | |
|---|
| 13 |
| This program is distributed in the hope that it will be useful, | |
|---|
| 14 |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|---|
| 15 |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|---|
| 16 |
| GNU General Public License for more details. | |
|---|
| 17 |
| | |
|---|
| 18 |
| You should have received a copy of the GNU General Public License | |
|---|
| 19 |
| along with this program; if not, write to the Free Software | |
|---|
| 20 |
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, | |
|---|
| 21 |
| MA 02111-1307, USA. | |
|---|
| 22 |
| | |
|---|
| 23 |
| A copy is availble at http://www.gnu.org/copyleft/gpl.txt | |
|---|
| 24 |
+----------------------------------------------------------------------+ |
|---|
| 25 |
| Author: Dmitry Stogov <mmcache@turckware.ru> | |
|---|
| 26 |
+----------------------------------------------------------------------+ |
|---|
| 27 |
$Id$ |
|---|
| 28 |
*/ |
|---|
| 29 |
|
|---|
| 30 |
#ifndef INCLUDED_EACCELERATOR_H |
|---|
| 31 |
#define INCLUDED_EACCELERATOR_H |
|---|
| 32 |
|
|---|
| 33 |
#include "php.h" |
|---|
| 34 |
#include "zend.h" |
|---|
| 35 |
#include "zend_API.h" |
|---|
| 36 |
#include "zend_extensions.h" |
|---|
| 37 |
|
|---|
| 38 |
#ifndef ZEND_WIN32 |
|---|
| 39 |
# if ZEND_MODULE_API_NO >= 20001222 |
|---|
| 40 |
# include "config.h" |
|---|
| 41 |
# else |
|---|
| 42 |
# include "php_config.h" |
|---|
| 43 |
# endif |
|---|
| 44 |
#endif |
|---|
| 45 |
|
|---|
| 46 |
#ifndef ZEND_WIN32 |
|---|
| 47 |
/* UnDefine if your filesystem doesn't support inodes */ |
|---|
| 48 |
# define EACCELERATOR_USE_INODE |
|---|
| 49 |
#endif |
|---|
| 50 |
|
|---|
| 51 |
/* Define some of the following macros if you like to debug eAccelerator */ |
|---|
| 52 |
/*#define DEBUG*/ |
|---|
| 53 |
/*#define TEST_PERFORMANCE*/ |
|---|
| 54 |
/*#define PROFILE_OPCODES*/ |
|---|
| 55 |
|
|---|
| 56 |
#ifdef WITH_EACCELERATOR_CRASH_DETECTION |
|---|
| 57 |
# include <signal.h> |
|---|
| 58 |
#endif |
|---|
| 59 |
|
|---|
| 60 |
#if defined(DEBUG) || defined(TEST_PERFORMANCE) || defined(PROFILE_OPCODES) |
|---|
| 61 |
/* Here you can chage debuging log filename */ |
|---|
| 62 |
#define DEBUG_LOGFILE "/var/log/httpd/eaccelerator_log" |
|---|
| 63 |
#define DEBUG_LOGFILE_CGI "/tmp/eaccelerator_log" |
|---|
| 64 |
#endif |
|---|
| 65 |
|
|---|
| 66 |
#define EACCELERATOR_MM_FILE "/tmp/eaccelerator" |
|---|
| 67 |
|
|---|
| 68 |
#ifdef HAVE_EACCELERATOR |
|---|
| 69 |
/* |
|---|
| 70 |
* Where to cache |
|---|
| 71 |
*/ |
|---|
| 72 |
typedef enum _eaccelerator_cache_place { |
|---|
| 73 |
eaccelerator_shm_and_disk, /* in shm and in disk */ |
|---|
| 74 |
eaccelerator_shm, /* in shm, but if it is not possible then on disk */ |
|---|
| 75 |
eaccelerator_shm_only, /* in shm only */ |
|---|
| 76 |
eaccelerator_disk_only, /* on disk only */ |
|---|
| 77 |
eaccelerator_none /* don't cache */ |
|---|
| 78 |
} eaccelerator_cache_place; |
|---|
| 79 |
|
|---|
| 80 |
extern eaccelerator_cache_place eaccelerator_content_cache_place; |
|---|
| 81 |
|
|---|
| 82 |
unsigned int eaccelerator_crc32(const char *p, size_t n); |
|---|
| 83 |
int eaccelerator_put(const char* key, int key_len, zval* val, time_t ttl, eaccelerator_cache_place where TSRMLS_DC); |
|---|
| 84 |
int eaccelerator_get(const char* key, int key_len, zval* return_value, eaccelerator_cache_place where TSRMLS_DC); |
|---|
| 85 |
int eaccelerator_rm(const char* key, int key_len, eaccelerator_cache_place where TSRMLS_DC); |
|---|
| 86 |
size_t eaccelerator_gc(TSRMLS_D); |
|---|
| 87 |
# ifdef WITH_EACCELERATOR_EXECUTOR |
|---|
| 88 |
ZEND_DLEXPORT void eaccelerator_execute(zend_op_array *op_array TSRMLS_DC); |
|---|
| 89 |
# endif |
|---|
| 90 |
# ifdef WITH_EACCELERATOR_OPTIMIZER |
|---|
| 91 |
void eaccelerator_optimize(zend_op_array *op_array); |
|---|
| 92 |
# endif |
|---|
| 93 |
#ifdef WITH_EACCELERATOR_ENCODER |
|---|
| 94 |
PHP_FUNCTION(eaccelerator_encode); |
|---|
| 95 |
#endif |
|---|
| 96 |
#ifdef WITH_EACCELERATOR_LOADER |
|---|
| 97 |
zend_op_array* eaccelerator_load(char* src, int src_len TSRMLS_DC); |
|---|
| 98 |
PHP_FUNCTION(eaccelerator_load); |
|---|
| 99 |
PHP_FUNCTION(_eaccelerator_loader_file); |
|---|
| 100 |
PHP_FUNCTION(_eaccelerator_loader_line); |
|---|
| 101 |
#endif |
|---|
| 102 |
#ifdef WITH_EACCELERATOR_CONTENT_CACHING |
|---|
| 103 |
void eaccelerator_content_cache_startup(); |
|---|
| 104 |
void eaccelerator_content_cache_shutdown(); |
|---|
| 105 |
|
|---|
| 106 |
PHP_FUNCTION(_eaccelerator_output_handler); |
|---|
| 107 |
PHP_FUNCTION(eaccelerator_cache_page); |
|---|
| 108 |
PHP_FUNCTION(eaccelerator_rm_page); |
|---|
| 109 |
PHP_FUNCTION(eaccelerator_cache_output); |
|---|
| 110 |
PHP_FUNCTION(eaccelerator_cache_result); |
|---|
| 111 |
#endif |
|---|
| 112 |
#endif |
|---|
| 113 |
|
|---|
| 114 |
/* |
|---|
| 115 |
* conditional filter |
|---|
| 116 |
*/ |
|---|
| 117 |
typedef struct _mm_cond_entry { |
|---|
| 118 |
char *str; |
|---|
| 119 |
int len; |
|---|
| 120 |
zend_bool not; |
|---|
| 121 |
struct _mm_cond_entry *next; |
|---|
| 122 |
} mm_cond_entry; |
|---|
| 123 |
|
|---|
| 124 |
/* |
|---|
| 125 |
* Globals (different for each process/thread) |
|---|
| 126 |
*/ |
|---|
| 127 |
ZEND_BEGIN_MODULE_GLOBALS(eaccelerator) |
|---|
| 128 |
void *used_entries; /* list of files which are used */ |
|---|
| 129 |
/* by process/thread */ |
|---|
| 130 |
zend_bool enabled; |
|---|
| 131 |
zend_bool optimizer_enabled; |
|---|
| 132 |
zend_bool compression_enabled; |
|---|
| 133 |
zend_bool compiler; |
|---|
| 134 |
zend_bool encoder; |
|---|
| 135 |
zend_bool compress; |
|---|
| 136 |
zend_bool compress_content; |
|---|
| 137 |
zend_bool in_request; |
|---|
| 138 |
zend_llist* content_headers; |
|---|
| 139 |
long compress_level; |
|---|
| 140 |
char *cache_dir; |
|---|
| 141 |
char *mem; |
|---|
| 142 |
HashTable strings; |
|---|
| 143 |
zend_class_entry *class_entry; |
|---|
| 144 |
mm_cond_entry *cond_list; |
|---|
| 145 |
zend_uint refcount_helper; |
|---|
| 146 |
char hostname[32]; |
|---|
| 147 |
#ifdef WITH_EACCELERATOR_CRASH_DETECTION |
|---|
| 148 |
#ifdef SIGSEGV |
|---|
| 149 |
void (*original_sigsegv_handler)(int); |
|---|
| 150 |
#endif |
|---|
| 151 |
#ifdef SIGFPE |
|---|
| 152 |
void (*original_sigfpe_handler)(int); |
|---|
| 153 |
#endif |
|---|
| 154 |
#ifdef SIGBUS |
|---|
| 155 |
void (*original_sigbus_handler)(int); |
|---|
| 156 |
#endif |
|---|
| 157 |
#ifdef SIGILL |
|---|
| 158 |
void (*original_sigill_handler)(int); |
|---|
| 159 |
#endif |
|---|
| 160 |
#ifdef SIGABRT |
|---|
| 161 |
void (*original_sigabrt_handler)(int); |
|---|
| 162 |
#endif |
|---|
| 163 |
#endif |
|---|
| 164 |
#if defined(DEBUG) || defined(TEST_PERFORMANCE) || defined(PROFILE_OPCODES) |
|---|
| 165 |
int xpad; |
|---|
| 166 |
#endif |
|---|
| 167 |
#ifdef WITH_EACCELERATOR_SESSIONS |
|---|
| 168 |
char *session; |
|---|
| 169 |
#endif |
|---|
| 170 |
#ifdef PROFILE_OPCODES |
|---|
| 171 |
int profile_level; |
|---|
| 172 |
long self_time[256]; |
|---|
| 173 |
#endif |
|---|
| 174 |
ZEND_END_MODULE_GLOBALS(eaccelerator) |
|---|
| 175 |
|
|---|
| 176 |
ZEND_EXTERN_MODULE_GLOBALS(eaccelerator) |
|---|
| 177 |
|
|---|
| 178 |
#ifdef ZTS |
|---|
| 179 |
# define MMCG(v) TSRMG(eaccelerator_globals_id, zend_eaccelerator_globals*, v) |
|---|
| 180 |
#else |
|---|
| 181 |
# define MMCG(v) (eaccelerator_globals.v) |
|---|
| 182 |
#endif |
|---|
| 183 |
|
|---|
| 184 |
#define EACCELERATOR_EXTENSION_NAME "eAccelerator" |
|---|
| 185 |
#define EACCELERATOR_LOADER_EXTENSION_NAME "Turck Loader" |
|---|
| 186 |
|
|---|
| 187 |
#endif /*#ifndef INCLUDED_EACCELERATOR_H*/ |
|---|