1/*
2 +----------------------------------------------------------------------+
3 | PHP Version 5 |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 1997-2015 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
37extern zend_module_entry basic_functions_module;
38#define basic_functions_module_ptr &basic_functions_module
39
40PHP_MINIT_FUNCTION(basic);
41PHP_MSHUTDOWN_FUNCTION(basic);
42PHP_RINIT_FUNCTION(basic);
43PHP_RSHUTDOWN_FUNCTION(basic);
44PHP_MINFO_FUNCTION(basic);
45
46PHP_FUNCTION(constant);
47PHP_FUNCTION(sleep);
48PHP_FUNCTION(usleep);
49#if HAVE_NANOSLEEP
50PHP_FUNCTION(time_nanosleep);
51PHP_FUNCTION(time_sleep_until);
52#endif
53PHP_FUNCTION(flush);
54#ifdef HAVE_INET_NTOP
55PHP_NAMED_FUNCTION(php_inet_ntop);
56#endif
57#ifdef HAVE_INET_PTON
58PHP_NAMED_FUNCTION(php_inet_pton);
59#endif
60PHP_FUNCTION(ip2long);
61PHP_FUNCTION(long2ip);
62
63/* system functions */
64PHP_FUNCTION(getenv);
65PHP_FUNCTION(putenv);
66
67PHP_FUNCTION(getopt);
68
69PHP_FUNCTION(get_current_user);
70PHP_FUNCTION(set_time_limit);
71
72PHP_FUNCTION(header_register_callback);
73
74PHP_FUNCTION(get_cfg_var);
75PHP_FUNCTION(set_magic_quotes_runtime);
76PHP_FUNCTION(get_magic_quotes_runtime);
77PHP_FUNCTION(get_magic_quotes_gpc);
78
79PHP_FUNCTION(error_log);
80PHP_FUNCTION(error_get_last);
81
82PHP_FUNCTION(call_user_func);
83PHP_FUNCTION(call_user_func_array);
84PHP_FUNCTION(call_user_method);
85PHP_FUNCTION(call_user_method_array);
86PHP_FUNCTION(forward_static_call);
87PHP_FUNCTION(forward_static_call_array);
88
89PHP_FUNCTION(register_shutdown_function);
90PHP_FUNCTION(highlight_file);
91PHP_FUNCTION(highlight_string);
92PHP_FUNCTION(php_strip_whitespace);
93ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highlighter_ini);
94
95PHP_FUNCTION(ini_get);
96PHP_FUNCTION(ini_get_all);
97PHP_FUNCTION(ini_set);
98PHP_FUNCTION(ini_restore);
99PHP_FUNCTION(get_include_path);
100PHP_FUNCTION(set_include_path);
101PHP_FUNCTION(restore_include_path);
102
103PHP_FUNCTION(print_r);
104PHP_FUNCTION(fprintf);
105PHP_FUNCTION(vfprintf);
106
107PHP_FUNCTION(connection_aborted);
108PHP_FUNCTION(connection_status);
109PHP_FUNCTION(ignore_user_abort);
110
111PHP_FUNCTION(getservbyname);
112PHP_FUNCTION(getservbyport);
113PHP_FUNCTION(getprotobyname);
114PHP_FUNCTION(getprotobynumber);
115
116PHP_NAMED_FUNCTION(php_if_crc32);
117
118PHP_FUNCTION(register_tick_function);
119PHP_FUNCTION(unregister_tick_function);
120#ifdef HAVE_GETLOADAVG
121PHP_FUNCTION(sys_getloadavg);
122#endif
123
124PHP_FUNCTION(is_uploaded_file);
125PHP_FUNCTION(move_uploaded_file);
126
127/* From the INI parser */
128PHP_FUNCTION(parse_ini_file);
129PHP_FUNCTION(parse_ini_string);
130#if ZEND_DEBUG
131PHP_FUNCTION(config_get_hash);
132#endif
133
134PHP_FUNCTION(str_rot13);
135PHP_FUNCTION(stream_get_filters);
136PHP_FUNCTION(stream_filter_register);
137PHP_FUNCTION(stream_bucket_make_writeable);
138PHP_FUNCTION(stream_bucket_prepend);
139PHP_FUNCTION(stream_bucket_append);
140PHP_FUNCTION(stream_bucket_new);
141PHP_MINIT_FUNCTION(user_filters);
142PHP_RSHUTDOWN_FUNCTION(user_filters);
143PHP_RSHUTDOWN_FUNCTION(browscap);
144
145/* Left for BC (not binary safe!) */
146PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers TSRMLS_DC);
147PHPAPI int _php_error_log_ex(int opt_err, char *message, int message_len, char *opt, char *headers TSRMLS_DC);
148PHPAPI 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 */
152typedef unsigned int php_uint32;
153typedef signed int php_int32;
154#elif SIZEOF_LONG == 4
155/* 16-bit systems? */
156typedef unsigned long php_uint32;
157typedef signed long php_int32;
158#else
159#error Need type which holds 32 bits
160#endif
161
162#define MT_N (624)
163
164typedef 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 /* pageinfo.c */
183 long page_uid;
184 long page_gid;
185 long page_inode;
186 time_t page_mtime;
187
188 /* filestat.c && main/streams/streams.c */
189 char *CurrentStatFile, *CurrentLStatFile;
190 php_stream_statbuf ssb, lssb;
191
192 /* rand.c */
193 php_uint32 state[MT_N+1]; /* state vector + 1 extra to not violate ANSI C */
194 php_uint32 *next; /* next random value is computed from here */
195 int left; /* can *next++ this many times before reloading */
196
197 unsigned int rand_seed; /* Seed for rand(), in ts version */
198
199 zend_bool rand_is_seeded; /* Whether rand() has been seeded */
200 zend_bool mt_rand_is_seeded; /* Whether mt_rand() has been seeded */
201
202 /* syslog.c */
203 char *syslog_device;
204
205 /* var.c */
206 zend_class_entry *incomplete_class;
207 unsigned serialize_lock; /* whether to use the locally supplied var_hash instead (__sleep/__wakeup) */
208 struct {
209 void *var_hash;
210 unsigned level;
211 } serialize;
212 struct {
213 void *var_hash;
214 unsigned level;
215 } unserialize;
216
217 /* url_scanner_ex.re */
218 url_adapt_state_ex_t url_adapt_state_ex;
219
220#ifdef HAVE_MMAP
221 void *mmap_file;
222 size_t mmap_len;
223#endif
224
225 HashTable *user_filter_map;
226
227 /* file.c */
228#if defined(_REENTRANT) && defined(HAVE_MBRLEN) && defined(HAVE_MBSTATE_T)
229 mbstate_t mblen_state;
230#endif
231
232 int umask;
233} php_basic_globals;
234
235#ifdef ZTS
236#define BG(v) TSRMG(basic_globals_id, php_basic_globals *, v)
237PHPAPI extern int basic_globals_id;
238#else
239#define BG(v) (basic_globals.v)
240PHPAPI extern php_basic_globals basic_globals;
241#endif
242
243#if HAVE_PUTENV
244typedef struct {
245 char *putenv_string;
246 char *previous_value;
247 char *key;
248 int key_len;
249} putenv_entry;
250#endif
251
252PHPAPI double php_get_nan(void);
253PHPAPI double php_get_inf(void);
254
255typedef struct _php_shutdown_function_entry {
256 zval **arguments;
257 int arg_count;
258} php_shutdown_function_entry;
259
260PHPAPI extern zend_bool register_user_shutdown_function(char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry TSRMLS_DC);
261PHPAPI extern zend_bool remove_user_shutdown_function(char *function_name, size_t function_len TSRMLS_DC);
262PHPAPI extern zend_bool append_user_shutdown_function(php_shutdown_function_entry shutdown_function_entry TSRMLS_DC);
263
264PHPAPI void php_call_shutdown_functions(TSRMLS_D);
265PHPAPI void php_free_shutdown_functions(TSRMLS_D);
266
267
268#endif /* BASIC_FUNCTIONS_H */
269