basic_functions.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 7 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2018 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@php.net> |
  16. | Zeev Suraski <zeev@php.net> |
  17. +----------------------------------------------------------------------+
  18. */
  19. #ifndef BASIC_FUNCTIONS_H
  20. #define BASIC_FUNCTIONS_H
  21. #include <sys/stat.h>
  22. #ifdef HAVE_WCHAR_H
  23. #include <wchar.h>
  24. #endif
  25. #include "php_filestat.h"
  26. #include "zend_highlight.h"
  27. #include "url_scanner_ex.h"
  28. #if defined(_WIN32) && !defined(__clang__)
  29. #include <intrin.h>
  30. #endif
  31. extern zend_module_entry basic_functions_module;
  32. #define basic_functions_module_ptr &basic_functions_module
  33. PHP_MINIT_FUNCTION(basic);
  34. PHP_MSHUTDOWN_FUNCTION(basic);
  35. PHP_RINIT_FUNCTION(basic);
  36. PHP_RSHUTDOWN_FUNCTION(basic);
  37. PHP_MINFO_FUNCTION(basic);
  38. PHP_FUNCTION(constant);
  39. PHP_FUNCTION(sleep);
  40. PHP_FUNCTION(usleep);
  41. #if HAVE_NANOSLEEP
  42. PHP_FUNCTION(time_nanosleep);
  43. PHP_FUNCTION(time_sleep_until);
  44. #endif
  45. PHP_FUNCTION(flush);
  46. #ifdef HAVE_INET_NTOP
  47. PHP_NAMED_FUNCTION(zif_inet_ntop);
  48. #endif
  49. #ifdef HAVE_INET_PTON
  50. PHP_NAMED_FUNCTION(php_inet_pton);
  51. #endif
  52. PHP_FUNCTION(ip2long);
  53. PHP_FUNCTION(long2ip);
  54. /* system functions */
  55. PHP_FUNCTION(getenv);
  56. PHP_FUNCTION(putenv);
  57. PHP_FUNCTION(getopt);
  58. PHP_FUNCTION(get_current_user);
  59. PHP_FUNCTION(set_time_limit);
  60. PHP_FUNCTION(header_register_callback);
  61. PHP_FUNCTION(get_cfg_var);
  62. PHP_FUNCTION(get_magic_quotes_runtime);
  63. PHP_FUNCTION(get_magic_quotes_gpc);
  64. PHP_FUNCTION(error_log);
  65. PHP_FUNCTION(error_get_last);
  66. PHP_FUNCTION(error_clear_last);
  67. PHP_FUNCTION(call_user_func);
  68. PHP_FUNCTION(call_user_func_array);
  69. PHP_FUNCTION(forward_static_call);
  70. PHP_FUNCTION(forward_static_call_array);
  71. PHP_FUNCTION(register_shutdown_function);
  72. PHP_FUNCTION(highlight_file);
  73. PHP_FUNCTION(highlight_string);
  74. PHP_FUNCTION(php_strip_whitespace);
  75. ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highlighter_ini);
  76. PHP_FUNCTION(ini_get);
  77. PHP_FUNCTION(ini_get_all);
  78. PHP_FUNCTION(ini_set);
  79. PHP_FUNCTION(ini_restore);
  80. PHP_FUNCTION(get_include_path);
  81. PHP_FUNCTION(set_include_path);
  82. PHP_FUNCTION(restore_include_path);
  83. PHP_FUNCTION(print_r);
  84. PHP_FUNCTION(fprintf);
  85. PHP_FUNCTION(vfprintf);
  86. PHP_FUNCTION(connection_aborted);
  87. PHP_FUNCTION(connection_status);
  88. PHP_FUNCTION(ignore_user_abort);
  89. PHP_FUNCTION(getservbyname);
  90. PHP_FUNCTION(getservbyport);
  91. PHP_FUNCTION(getprotobyname);
  92. PHP_FUNCTION(getprotobynumber);
  93. PHP_NAMED_FUNCTION(php_if_crc32);
  94. PHP_FUNCTION(register_tick_function);
  95. PHP_FUNCTION(unregister_tick_function);
  96. #ifdef HAVE_GETLOADAVG
  97. PHP_FUNCTION(sys_getloadavg);
  98. #endif
  99. PHP_FUNCTION(is_uploaded_file);
  100. PHP_FUNCTION(move_uploaded_file);
  101. PHP_FUNCTION(net_get_interfaces);
  102. /* From the INI parser */
  103. PHP_FUNCTION(parse_ini_file);
  104. PHP_FUNCTION(parse_ini_string);
  105. #if ZEND_DEBUG
  106. PHP_FUNCTION(config_get_hash);
  107. #endif
  108. #if defined(PHP_WIN32)
  109. PHP_FUNCTION(sapi_windows_cp_set);
  110. PHP_FUNCTION(sapi_windows_cp_get);
  111. PHP_FUNCTION(sapi_windows_cp_is_utf8);
  112. PHP_FUNCTION(sapi_windows_cp_conv);
  113. #endif
  114. PHP_FUNCTION(str_rot13);
  115. PHP_FUNCTION(stream_get_filters);
  116. PHP_FUNCTION(stream_filter_register);
  117. PHP_FUNCTION(stream_bucket_make_writeable);
  118. PHP_FUNCTION(stream_bucket_prepend);
  119. PHP_FUNCTION(stream_bucket_append);
  120. PHP_FUNCTION(stream_bucket_new);
  121. PHP_MINIT_FUNCTION(user_filters);
  122. PHP_RSHUTDOWN_FUNCTION(user_filters);
  123. PHP_RSHUTDOWN_FUNCTION(browscap);
  124. /* Left for BC (not binary safe!) */
  125. PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers);
  126. PHPAPI int _php_error_log_ex(int opt_err, char *message, size_t message_len, char *opt, char *headers);
  127. PHPAPI int php_prefix_varname(zval *result, const zval *prefix, const char *var_name, size_t var_name_len, zend_bool add_underscore);
  128. #define MT_N (624)
  129. /* Deprecated type aliases -- use the standard types instead */
  130. typedef uint32_t php_uint32;
  131. typedef int32_t php_int32;
  132. typedef struct _php_basic_globals {
  133. HashTable *user_shutdown_function_names;
  134. HashTable putenv_ht;
  135. zval strtok_zval;
  136. char *strtok_string;
  137. zend_string *locale_string; /* current LC_CTYPE locale (or NULL for 'C') */
  138. zend_bool locale_changed; /* locale was changed and has to be restored */
  139. char *strtok_last;
  140. char strtok_table[256];
  141. zend_ulong strtok_len;
  142. char str_ebuf[40];
  143. zend_fcall_info array_walk_fci;
  144. zend_fcall_info_cache array_walk_fci_cache;
  145. zend_fcall_info user_compare_fci;
  146. zend_fcall_info_cache user_compare_fci_cache;
  147. zend_llist *user_tick_functions;
  148. zval active_ini_file_section;
  149. /* pageinfo.c */
  150. zend_long page_uid;
  151. zend_long page_gid;
  152. zend_long page_inode;
  153. time_t page_mtime;
  154. /* filestat.c && main/streams/streams.c */
  155. char *CurrentStatFile, *CurrentLStatFile;
  156. php_stream_statbuf ssb, lssb;
  157. /* mt_rand.c */
  158. uint32_t state[MT_N+1]; /* state vector + 1 extra to not violate ANSI C */
  159. uint32_t *next; /* next random value is computed from here */
  160. int left; /* can *next++ this many times before reloading */
  161. zend_bool mt_rand_is_seeded; /* Whether mt_rand() has been seeded */
  162. zend_long mt_rand_mode;
  163. /* syslog.c */
  164. char *syslog_device;
  165. /* var.c */
  166. zend_class_entry *incomplete_class;
  167. unsigned serialize_lock; /* whether to use the locally supplied var_hash instead (__sleep/__wakeup) */
  168. struct {
  169. struct php_serialize_data *data;
  170. unsigned level;
  171. } serialize;
  172. struct {
  173. struct php_unserialize_data *data;
  174. unsigned level;
  175. } unserialize;
  176. /* url_scanner_ex.re */
  177. url_adapt_state_ex_t url_adapt_session_ex;
  178. HashTable url_adapt_session_hosts_ht;
  179. url_adapt_state_ex_t url_adapt_output_ex;
  180. HashTable url_adapt_output_hosts_ht;
  181. #ifdef HAVE_MMAP
  182. void *mmap_file;
  183. size_t mmap_len;
  184. #endif
  185. HashTable *user_filter_map;
  186. /* file.c */
  187. #if defined(_REENTRANT) && defined(HAVE_MBRLEN) && defined(HAVE_MBSTATE_T)
  188. mbstate_t mblen_state;
  189. #endif
  190. int umask;
  191. } php_basic_globals;
  192. #ifdef ZTS
  193. #define BG(v) ZEND_TSRMG(basic_globals_id, php_basic_globals *, v)
  194. PHPAPI extern int basic_globals_id;
  195. #else
  196. #define BG(v) (basic_globals.v)
  197. PHPAPI extern php_basic_globals basic_globals;
  198. #endif
  199. #if HAVE_PUTENV
  200. typedef struct {
  201. char *putenv_string;
  202. char *previous_value;
  203. char *key;
  204. size_t key_len;
  205. } putenv_entry;
  206. #endif
  207. PHPAPI double php_get_nan(void);
  208. PHPAPI double php_get_inf(void);
  209. typedef struct _php_shutdown_function_entry {
  210. zval *arguments;
  211. int arg_count;
  212. } php_shutdown_function_entry;
  213. PHPAPI extern zend_bool register_user_shutdown_function(char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry);
  214. PHPAPI extern zend_bool remove_user_shutdown_function(char *function_name, size_t function_len);
  215. PHPAPI extern zend_bool append_user_shutdown_function(php_shutdown_function_entry shutdown_function_entry);
  216. PHPAPI void php_call_shutdown_functions(void);
  217. PHPAPI void php_free_shutdown_functions(void);
  218. #endif /* BASIC_FUNCTIONS_H */