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 | Authors: Andi Gutmans <andi@php.net> | 14 | Zeev Suraski <zeev@php.net> | 15 +----------------------------------------------------------------------+ 16 */ 17 18 #ifndef BASIC_FUNCTIONS_H 19 #define BASIC_FUNCTIONS_H 20 21 #include <sys/stat.h> 22 #include <wchar.h> 23 24 #include "php_filestat.h" 25 26 #include "zend_highlight.h" 27 28 #include "url_scanner_ex.h" 29 30 /* for MT_N */ 31 #include "ext/random/php_random.h" 32 33 #if defined(_WIN32) && !defined(__clang__) 34 #include <intrin.h> 35 #endif 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 ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highlighter_ini); 47 48 PHP_MINIT_FUNCTION(user_filters); 49 PHP_RSHUTDOWN_FUNCTION(user_filters); 50 PHP_RSHUTDOWN_FUNCTION(browscap); 51 52 /* Left for BC (not binary safe!) */ 53 PHPAPI int _php_error_log(int opt_err, const char *message, const char *opt, const char *headers); 54 PHPAPI int _php_error_log_ex(int opt_err, const char *message, size_t message_len, const char *opt, const char *headers); 55 PHPAPI int php_prefix_varname(zval *result, zend_string *prefix, const char *var_name, size_t var_name_len, bool add_underscore); 56 57 /* Deprecated type aliases -- use the standard types instead */ 58 typedef uint32_t php_uint32; 59 typedef int32_t php_int32; 60 61 typedef struct _php_basic_globals { 62 HashTable *user_shutdown_function_names; 63 HashTable putenv_ht; 64 zend_string *strtok_string; 65 zend_string *ctype_string; /* current LC_CTYPE locale (or NULL for 'C') */ 66 bool locale_changed; /* locale was changed and has to be restored */ 67 char *strtok_last; 68 char strtok_table[256]; 69 size_t strtok_len; 70 zend_fcall_info user_compare_fci; 71 zend_fcall_info_cache user_compare_fci_cache; 72 zend_llist *user_tick_functions; 73 74 zval active_ini_file_section; 75 76 /* pageinfo.c */ 77 zend_long page_uid; 78 zend_long page_gid; 79 zend_long page_inode; 80 time_t page_mtime; 81 82 /* filestat.c && main/streams/streams.c */ 83 zend_string *CurrentStatFile, *CurrentLStatFile; 84 php_stream_statbuf ssb, lssb; 85 86 /* syslog.c */ 87 char *syslog_device; 88 89 /* var.c */ 90 unsigned serialize_lock; /* whether to use the locally supplied var_hash instead (__sleep/__wakeup) */ 91 struct { 92 struct php_serialize_data *data; 93 unsigned level; 94 } serialize; 95 struct { 96 struct php_unserialize_data *data; 97 unsigned level; 98 } unserialize; 99 100 /* url_scanner_ex.re */ 101 url_adapt_state_ex_t url_adapt_session_ex; 102 HashTable url_adapt_session_hosts_ht; 103 url_adapt_state_ex_t url_adapt_output_ex; 104 HashTable url_adapt_output_hosts_ht; 105 HashTable *user_filter_map; 106 107 /* file.c */ 108 #if defined(_REENTRANT) 109 mbstate_t mblen_state; 110 #endif 111 112 int umask; 113 zend_long unserialize_max_depth; 114 } php_basic_globals; 115 116 #ifdef ZTS 117 #define BG(v) ZEND_TSRMG(basic_globals_id, php_basic_globals *, v) 118 PHPAPI extern int basic_globals_id; 119 #else 120 #define BG(v) (basic_globals.v) 121 PHPAPI extern php_basic_globals basic_globals; 122 #endif 123 124 PHPAPI zend_string *php_getenv(const char *str, size_t str_len); 125 126 PHPAPI double php_get_nan(void); 127 PHPAPI double php_get_inf(void); 128 129 typedef struct _php_shutdown_function_entry { 130 zend_fcall_info fci; 131 zend_fcall_info_cache fci_cache; 132 } php_shutdown_function_entry; 133 134 PHPAPI extern bool register_user_shutdown_function(const char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry); 135 PHPAPI extern bool remove_user_shutdown_function(const char *function_name, size_t function_len); 136 PHPAPI extern bool append_user_shutdown_function(php_shutdown_function_entry *shutdown_function_entry); 137 138 PHPAPI void php_call_shutdown_functions(void); 139 PHPAPI void php_free_shutdown_functions(void); 140 141 142 #endif /* BASIC_FUNCTIONS_H */ 143