1 /* 2 +----------------------------------------------------------------------+ 3 | PHP Version 5 | 4 +----------------------------------------------------------------------+ 5 | Copyright (c) 1997-2013 The PHP Group | 6 +----------------------------------------------------------------------+ 7 | This source file is subject to version 3.01 of the PHP license, | 8 | that is bundled with this package in the file LICENSE, and is | 9 | available through the world-wide-web at the following url: | 10 | http://www.php.net/license/3_01.txt | 11 | If you did not receive a copy of the PHP license and are unable to | 12 | obtain it through the world-wide-web, please send a note to | 13 | license@php.net so we can mail you a copy immediately. | 14 +----------------------------------------------------------------------+ 15 | Authors: Andi Gutmans <andi@zend.com> | 16 | Zeev Suraski <zeev@zend.com> | 17 +----------------------------------------------------------------------+ 18 */ 19 20 /* $Id$ */ 21 22 #ifndef BASIC_FUNCTIONS_H 23 #define BASIC_FUNCTIONS_H 24 25 #include <sys/stat.h> 26 27 #ifdef HAVE_WCHAR_H 28 #include <wchar.h> 29 #endif 30 31 #include "php_filestat.h" 32 33 #include "zend_highlight.h" 34 35 #include "url_scanner_ex.h" 36 37 extern zend_module_entry basic_functions_module; 38 #define basic_functions_module_ptr &basic_functions_module 39 40 PHP_MINIT_FUNCTION(basic); 41 PHP_MSHUTDOWN_FUNCTION(basic); 42 PHP_RINIT_FUNCTION(basic); 43 PHP_RSHUTDOWN_FUNCTION(basic); 44 PHP_MINFO_FUNCTION(basic); 45 46 PHP_FUNCTION(constant); 47 PHP_FUNCTION(sleep); 48 PHP_FUNCTION(usleep); 49 #if HAVE_NANOSLEEP 50 PHP_FUNCTION(time_nanosleep); 51 PHP_FUNCTION(time_sleep_until); 52 #endif 53 PHP_FUNCTION(flush); 54 #ifdef HAVE_INET_NTOP 55 PHP_NAMED_FUNCTION(php_inet_ntop); 56 #endif 57 #ifdef HAVE_INET_PTON 58 PHP_NAMED_FUNCTION(php_inet_pton); 59 #endif 60 PHP_FUNCTION(ip2long); 61 PHP_FUNCTION(long2ip); 62 63 /* system functions */ 64 PHP_FUNCTION(getenv); 65 PHP_FUNCTION(putenv); 66 67 PHP_FUNCTION(getopt); 68 69 PHP_FUNCTION(get_current_user); 70 PHP_FUNCTION(set_time_limit); 71 72 PHP_FUNCTION(get_cfg_var); 73 PHP_FUNCTION(set_magic_quotes_runtime); 74 PHP_FUNCTION(get_magic_quotes_runtime); 75 PHP_FUNCTION(get_magic_quotes_gpc); 76 77 PHP_FUNCTION(import_request_variables); 78 79 PHP_FUNCTION(error_log); 80 PHP_FUNCTION(error_get_last); 81 82 PHP_FUNCTION(call_user_func); 83 PHP_FUNCTION(call_user_func_array); 84 PHP_FUNCTION(call_user_method); 85 PHP_FUNCTION(call_user_method_array); 86 PHP_FUNCTION(forward_static_call); 87 PHP_FUNCTION(forward_static_call_array); 88 89 PHP_FUNCTION(register_shutdown_function); 90 PHP_FUNCTION(highlight_file); 91 PHP_FUNCTION(highlight_string); 92 PHP_FUNCTION(php_strip_whitespace); 93 ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highlighter_ini); 94 95 PHP_FUNCTION(ini_get); 96 PHP_FUNCTION(ini_get_all); 97 PHP_FUNCTION(ini_set); 98 PHP_FUNCTION(ini_restore); 99 PHP_FUNCTION(get_include_path); 100 PHP_FUNCTION(set_include_path); 101 PHP_FUNCTION(restore_include_path); 102 103 PHP_FUNCTION(print_r); 104 PHP_FUNCTION(fprintf); 105 PHP_FUNCTION(vfprintf); 106 107 PHP_FUNCTION(connection_aborted); 108 PHP_FUNCTION(connection_status); 109 PHP_FUNCTION(ignore_user_abort); 110 111 PHP_FUNCTION(getservbyname); 112 PHP_FUNCTION(getservbyport); 113 PHP_FUNCTION(getprotobyname); 114 PHP_FUNCTION(getprotobynumber); 115 116 PHP_NAMED_FUNCTION(php_if_crc32); 117 118 PHP_FUNCTION(register_tick_function); 119 PHP_FUNCTION(unregister_tick_function); 120 #ifdef HAVE_GETLOADAVG 121 PHP_FUNCTION(sys_getloadavg); 122 #endif 123 124 PHP_FUNCTION(is_uploaded_file); 125 PHP_FUNCTION(move_uploaded_file); 126 127 /* From the INI parser */ 128 PHP_FUNCTION(parse_ini_file); 129 PHP_FUNCTION(parse_ini_string); 130 #if ZEND_DEBUG 131 PHP_FUNCTION(config_get_hash); 132 #endif 133 134 PHP_FUNCTION(str_rot13); 135 PHP_FUNCTION(stream_get_filters); 136 PHP_FUNCTION(stream_filter_register); 137 PHP_FUNCTION(stream_bucket_make_writeable); 138 PHP_FUNCTION(stream_bucket_prepend); 139 PHP_FUNCTION(stream_bucket_append); 140 PHP_FUNCTION(stream_bucket_new); 141 PHP_MINIT_FUNCTION(user_filters); 142 PHP_RSHUTDOWN_FUNCTION(user_filters); 143 PHP_RSHUTDOWN_FUNCTION(browscap); 144 145 /* Left for BC (not binary safe!) */ 146 PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers TSRMLS_DC); 147 PHPAPI int _php_error_log_ex(int opt_err, char *message, int message_len, char *opt, char *headers TSRMLS_DC); 148 PHPAPI int php_prefix_varname(zval *result, zval *prefix, char *var_name, int var_name_len, zend_bool add_underscore TSRMLS_DC); 149 150 #if SIZEOF_INT == 4 151 /* Most 32-bit and 64-bit systems have 32-bit ints */ 152 typedef unsigned int php_uint32; 153 typedef signed int php_int32; 154 #elif SIZEOF_LONG == 4 155 /* 16-bit systems? */ 156 typedef unsigned long php_uint32; 157 typedef signed long php_int32; 158 #else 159 #error Need type which holds 32 bits 160 #endif 161 162 #define MT_N (624) 163 164 typedef struct _php_basic_globals { 165 HashTable *user_shutdown_function_names; 166 HashTable putenv_ht; 167 zval *strtok_zval; 168 char *strtok_string; 169 char *locale_string; 170 char *strtok_last; 171 char strtok_table[256]; 172 ulong strtok_len; 173 char str_ebuf[40]; 174 zend_fcall_info array_walk_fci; 175 zend_fcall_info_cache array_walk_fci_cache; 176 zend_fcall_info user_compare_fci; 177 zend_fcall_info_cache user_compare_fci_cache; 178 zend_llist *user_tick_functions; 179 180 zval *active_ini_file_section; 181 182 HashTable sm_protected_env_vars; 183 char *sm_allowed_env_vars; 184 185 /* pageinfo.c */ 186 long page_uid; 187 long page_gid; 188 long page_inode; 189 time_t page_mtime; 190 191 /* filestat.c && main/streams/streams.c */ 192 char *CurrentStatFile, *CurrentLStatFile; 193 php_stream_statbuf ssb, lssb; 194 195 /* rand.c */ 196 php_uint32 state[MT_N+1]; /* state vector + 1 extra to not violate ANSI C */ 197 php_uint32 *next; /* next random value is computed from here */ 198 int left; /* can *next++ this many times before reloading */ 199 200 unsigned int rand_seed; /* Seed for rand(), in ts version */ 201 202 zend_bool rand_is_seeded; /* Whether rand() has been seeded */ 203 zend_bool mt_rand_is_seeded; /* Whether mt_rand() has been seeded */ 204 205 /* syslog.c */ 206 int syslog_started; 207 char *syslog_device; 208 209 /* var.c */ 210 zend_class_entry *incomplete_class; 211 212 /* url_scanner_ex.re */ 213 url_adapt_state_ex_t url_adapt_state_ex; 214 215 #ifdef HAVE_MMAP 216 void *mmap_file; 217 size_t mmap_len; 218 #endif 219 220 HashTable *user_filter_map; 221 222 /* file.c */ 223 #if defined(_REENTRANT) && defined(HAVE_MBRLEN) && defined(HAVE_MBSTATE_T) 224 mbstate_t mblen_state; 225 #endif 226 227 int umask; 228 } php_basic_globals; 229 230 #ifdef ZTS 231 #define BG(v) TSRMG(basic_globals_id, php_basic_globals *, v) 232 PHPAPI extern int basic_globals_id; 233 #else 234 #define BG(v) (basic_globals.v) 235 PHPAPI extern php_basic_globals basic_globals; 236 #endif 237 238 #if HAVE_PUTENV 239 typedef struct { 240 char *putenv_string; 241 char *previous_value; 242 char *key; 243 int key_len; 244 } putenv_entry; 245 #endif 246 247 /* Values are comma-delimited 248 */ 249 #define SAFE_MODE_PROTECTED_ENV_VARS "LD_LIBRARY_PATH" 250 #define SAFE_MODE_ALLOWED_ENV_VARS "PHP_" 251 252 PHPAPI double php_get_nan(void); 253 PHPAPI double php_get_inf(void); 254 255 #endif /* BASIC_FUNCTIONS_H */ 256