basic_functions.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 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. /* $Id$ */
  20. #ifndef BASIC_FUNCTIONS_H
  21. #define BASIC_FUNCTIONS_H
  22. #include <sys/stat.h>
  23. #ifdef HAVE_WCHAR_H
  24. #include <wchar.h>
  25. #endif
  26. #include "php_filestat.h"
  27. #include "zend_highlight.h"
  28. #include "url_scanner_ex.h"
  29. extern zend_module_entry basic_functions_module;
  30. #define basic_functions_module_ptr &basic_functions_module
  31. PHP_MINIT_FUNCTION(basic);
  32. PHP_MSHUTDOWN_FUNCTION(basic);
  33. PHP_RINIT_FUNCTION(basic);
  34. PHP_RSHUTDOWN_FUNCTION(basic);
  35. PHP_MINFO_FUNCTION(basic);
  36. PHP_FUNCTION(constant);
  37. PHP_FUNCTION(sleep);
  38. PHP_FUNCTION(usleep);
  39. #if HAVE_NANOSLEEP
  40. PHP_FUNCTION(time_nanosleep);
  41. PHP_FUNCTION(time_sleep_until);
  42. #endif
  43. PHP_FUNCTION(flush);
  44. #ifdef HAVE_INET_NTOP
  45. PHP_NAMED_FUNCTION(php_inet_ntop);
  46. #endif
  47. #ifdef HAVE_INET_PTON
  48. PHP_NAMED_FUNCTION(php_inet_pton);
  49. #endif
  50. PHP_FUNCTION(ip2long);
  51. PHP_FUNCTION(long2ip);
  52. /* system functions */
  53. PHP_FUNCTION(getenv);
  54. PHP_FUNCTION(putenv);
  55. PHP_FUNCTION(getopt);
  56. PHP_FUNCTION(get_current_user);
  57. PHP_FUNCTION(set_time_limit);
  58. PHP_FUNCTION(header_register_callback);
  59. PHP_FUNCTION(get_cfg_var);
  60. PHP_FUNCTION(set_magic_quotes_runtime);
  61. PHP_FUNCTION(get_magic_quotes_runtime);
  62. PHP_FUNCTION(get_magic_quotes_gpc);
  63. PHP_FUNCTION(error_log);
  64. PHP_FUNCTION(error_get_last);
  65. PHP_FUNCTION(call_user_func);
  66. PHP_FUNCTION(call_user_func_array);
  67. PHP_FUNCTION(call_user_method);
  68. PHP_FUNCTION(call_user_method_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. /* From the INI parser */
  102. PHP_FUNCTION(parse_ini_file);
  103. PHP_FUNCTION(parse_ini_string);
  104. #if ZEND_DEBUG
  105. PHP_FUNCTION(config_get_hash);
  106. #endif
  107. PHP_FUNCTION(str_rot13);
  108. PHP_FUNCTION(stream_get_filters);
  109. PHP_FUNCTION(stream_filter_register);
  110. PHP_FUNCTION(stream_bucket_make_writeable);
  111. PHP_FUNCTION(stream_bucket_prepend);
  112. PHP_FUNCTION(stream_bucket_append);
  113. PHP_FUNCTION(stream_bucket_new);
  114. PHP_MINIT_FUNCTION(user_filters);
  115. PHP_RSHUTDOWN_FUNCTION(user_filters);
  116. PHP_RSHUTDOWN_FUNCTION(browscap);
  117. /* Left for BC (not binary safe!) */
  118. PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers TSRMLS_DC);
  119. PHPAPI int _php_error_log_ex(int opt_err, char *message, int message_len, char *opt, char *headers TSRMLS_DC);
  120. PHPAPI int php_prefix_varname(zval *result, zval *prefix, char *var_name, int var_name_len, zend_bool add_underscore TSRMLS_DC);
  121. #if SIZEOF_INT == 4
  122. /* Most 32-bit and 64-bit systems have 32-bit ints */
  123. typedef unsigned int php_uint32;
  124. typedef signed int php_int32;
  125. #elif SIZEOF_LONG == 4
  126. /* 16-bit systems? */
  127. typedef unsigned long php_uint32;
  128. typedef signed long php_int32;
  129. #else
  130. #error Need type which holds 32 bits
  131. #endif
  132. #define MT_N (624)
  133. typedef struct _php_basic_globals {
  134. HashTable *user_shutdown_function_names;
  135. HashTable putenv_ht;
  136. zval *strtok_zval;
  137. char *strtok_string;
  138. char *locale_string;
  139. char *strtok_last;
  140. char strtok_table[256];
  141. 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. long page_uid;
  151. long page_gid;
  152. 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. /* rand.c */
  158. php_uint32 state[MT_N+1]; /* state vector + 1 extra to not violate ANSI C */
  159. php_uint32 *next; /* next random value is computed from here */
  160. int left; /* can *next++ this many times before reloading */
  161. unsigned int rand_seed; /* Seed for rand(), in ts version */
  162. zend_bool rand_is_seeded; /* Whether rand() has been seeded */
  163. zend_bool mt_rand_is_seeded; /* Whether mt_rand() has been seeded */
  164. /* syslog.c */
  165. char *syslog_device;
  166. /* var.c */
  167. zend_class_entry *incomplete_class;
  168. unsigned serialize_lock; /* whether to use the locally supplied var_hash instead (__sleep/__wakeup) */
  169. struct {
  170. void *var_hash;
  171. unsigned level;
  172. } serialize;
  173. struct {
  174. void *var_hash;
  175. unsigned level;
  176. } unserialize;
  177. /* url_scanner_ex.re */
  178. url_adapt_state_ex_t url_adapt_state_ex;
  179. #ifdef HAVE_MMAP
  180. void *mmap_file;
  181. size_t mmap_len;
  182. #endif
  183. HashTable *user_filter_map;
  184. /* file.c */
  185. #if defined(_REENTRANT) && defined(HAVE_MBRLEN) && defined(HAVE_MBSTATE_T)
  186. mbstate_t mblen_state;
  187. #endif
  188. int umask;
  189. } php_basic_globals;
  190. #ifdef ZTS
  191. #define BG(v) TSRMG(basic_globals_id, php_basic_globals *, v)
  192. PHPAPI extern int basic_globals_id;
  193. #else
  194. #define BG(v) (basic_globals.v)
  195. PHPAPI extern php_basic_globals basic_globals;
  196. #endif
  197. #if HAVE_PUTENV
  198. typedef struct {
  199. char *putenv_string;
  200. char *previous_value;
  201. char *key;
  202. int key_len;
  203. } putenv_entry;
  204. #endif
  205. PHPAPI double php_get_nan(void);
  206. PHPAPI double php_get_inf(void);
  207. typedef struct _php_shutdown_function_entry {
  208. zval **arguments;
  209. int arg_count;
  210. } php_shutdown_function_entry;
  211. PHPAPI extern zend_bool register_user_shutdown_function(char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry TSRMLS_DC);
  212. PHPAPI extern zend_bool remove_user_shutdown_function(char *function_name, size_t function_len TSRMLS_DC);
  213. PHPAPI extern zend_bool append_user_shutdown_function(php_shutdown_function_entry shutdown_function_entry TSRMLS_DC);
  214. PHPAPI void php_call_shutdown_functions(TSRMLS_D);
  215. PHPAPI void php_free_shutdown_functions(TSRMLS_D);
  216. #endif /* BASIC_FUNCTIONS_H */