php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
basic_functions.c
Go to the documentation of this file.
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#include "php.h"
19#include "php_assert.h"
20#include "php_crypt.h"
21#include "php_streams.h"
22#include "php_main.h"
23#include "php_globals.h"
24#include "php_variables.h"
25#include "php_ini.h"
26#include "php_image.h"
27#include "php_standard.h"
28#include "php_math.h"
29#include "php_http.h"
31#include "php_getopt.h"
32#include "php_ext_syslog.h"
33#include "ext/standard/info.h"
35#include "zend_exceptions.h"
36#include "zend_attributes.h"
37#include "zend_enum.h"
38#include "zend_ini.h"
39#include "zend_operators.h"
43
44#ifdef PHP_WIN32
46#include "win32/time.h"
47#include "win32/ioutil.h"
48#endif
49
50typedef struct yy_buffer_state *YY_BUFFER_STATE;
51
52#include "zend.h"
53#include "zend_ini_scanner.h"
55#include <zend_language_parser.h>
56
57#include "zend_portability.h"
58
59#include <stdarg.h>
60#include <stdlib.h>
61#include <math.h>
62#include <time.h>
63#include <stdio.h>
64
65#ifndef PHP_WIN32
66#include <sys/types.h>
67#include <sys/stat.h>
68#endif
69
70#ifndef PHP_WIN32
71# include <netdb.h>
72#endif
73
74#ifdef HAVE_ARPA_INET_H
75# include <arpa/inet.h>
76#endif
77
78#ifdef HAVE_UNISTD_H
79# include <unistd.h>
80#endif
81
82#include <string.h>
83#include <locale.h>
84#ifdef HAVE_LANGINFO_H
85# include <langinfo.h>
86#endif
87
88#ifdef HAVE_SYS_MMAN_H
89# include <sys/mman.h>
90#endif
91
92#ifdef HAVE_SYS_LOADAVG_H
93# include <sys/loadavg.h>
94#endif
95
96#ifdef PHP_WIN32
97# include "win32/unistd.h"
98#endif
99
100#ifndef INADDR_NONE
101# define INADDR_NONE ((zend_ulong) -1)
102#endif
103
104#include "zend_globals.h"
105#include "php_globals.h"
106#include "SAPI.h"
107#include "php_ticks.h"
108
109#ifdef ZTS
110PHPAPI int basic_globals_id;
111#else
113#endif
114
115#include "php_fopen_wrappers.h"
116#include "streamsfuncs.h"
119
120#if __has_feature(memory_sanitizer)
121# include <sanitizer/msan_interface.h>
122#endif
123
129
130#ifdef HAVE_PUTENV
131typedef struct {
132 char *putenv_string;
133 char *previous_value;
135} putenv_entry;
136#endif
137
138/* some prototypes for local functions */
139static void user_shutdown_function_dtor(zval *zv);
140static void user_tick_function_dtor(user_tick_function_entry *tick_function_entry);
141
142static const zend_module_dep standard_deps[] = { /* {{{ */
143 ZEND_MOD_OPTIONAL("session")
145};
146/* }}} */
147
150 NULL,
151 standard_deps,
152 "standard", /* extension name */
153 ext_functions, /* function list */
154 PHP_MINIT(basic), /* process startup */
155 PHP_MSHUTDOWN(basic), /* process shutdown */
156 PHP_RINIT(basic), /* request startup */
157 PHP_RSHUTDOWN(basic), /* request shutdown */
158 PHP_MINFO(basic), /* extension info */
159 PHP_STANDARD_VERSION, /* extension version */
161};
162/* }}} */
163
164#ifdef HAVE_PUTENV
165static void php_putenv_destructor(zval *zv) /* {{{ */
166{
167 putenv_entry *pe = Z_PTR_P(zv);
168
169 if (pe->previous_value) {
170# ifdef PHP_WIN32
171 /* MSVCRT has a bug in putenv() when setting a variable that
172 * is already set; if the SetEnvironmentVariable() API call
173 * fails, the Crt will double free() a string.
174 * We try to avoid this by setting our own value first */
175 SetEnvironmentVariable(ZSTR_VAL(pe->key), "bugbug");
176# endif
177 putenv(pe->previous_value);
178# ifdef PHP_WIN32
179 efree(pe->previous_value);
180# endif
181 } else {
182# ifdef HAVE_UNSETENV
183 unsetenv(ZSTR_VAL(pe->key));
184# elif defined(PHP_WIN32)
185 SetEnvironmentVariable(ZSTR_VAL(pe->key), NULL);
186# ifndef ZTS
187 _putenv_s(ZSTR_VAL(pe->key), "");
188# endif
189# else
190 char **env;
191
192 for (env = environ; env != NULL && *env != NULL; env++) {
193 if (!strncmp(*env, ZSTR_VAL(pe->key), ZSTR_LEN(pe->key))
194 && (*env)[ZSTR_LEN(pe->key)] == '=') { /* found it */
195 *env = "";
196 break;
197 }
198 }
199# endif
200 }
201#ifdef HAVE_TZSET
202 /* don't forget to reset the various libc globals that
203 * we might have changed by an earlier call to tzset(). */
204 if (zend_string_equals_literal_ci(pe->key, "TZ")) {
205 tzset();
206 }
207#endif
208
209 free(pe->putenv_string);
210 zend_string_release(pe->key);
211 efree(pe);
212}
213/* }}} */
214#endif
215
216static void basic_globals_ctor(php_basic_globals *basic_globals_p) /* {{{ */
217{
218 memset(basic_globals_p, 0, sizeof(php_basic_globals));
219
220 basic_globals_p->umask = -1;
221 basic_globals_p->url_adapt_session_ex.type = 1;
222
223 zend_hash_init(&basic_globals_p->url_adapt_session_hosts_ht, 0, NULL, NULL, 1);
224 zend_hash_init(&basic_globals_p->url_adapt_output_hosts_ht, 0, NULL, NULL, 1);
225
226 basic_globals_p->page_uid = -1;
227 basic_globals_p->page_gid = -1;
228}
229/* }}} */
230
231static void basic_globals_dtor(php_basic_globals *basic_globals_p) /* {{{ */
232{
233 if (basic_globals_p->url_adapt_session_ex.tags) {
235 free(basic_globals_p->url_adapt_session_ex.tags);
236 }
237 if (basic_globals_p->url_adapt_output_ex.tags) {
239 free(basic_globals_p->url_adapt_output_ex.tags);
240 }
241
244}
245/* }}} */
246
247PHPAPI double php_get_nan(void) /* {{{ */
248{
249 return ZEND_NAN;
250}
251/* }}} */
252
253PHPAPI double php_get_inf(void) /* {{{ */
254{
255 return ZEND_INFINITY;
256}
257/* }}} */
258
259#define BASIC_MINIT_SUBMODULE(module) \
260 if (PHP_MINIT(module)(INIT_FUNC_ARGS_PASSTHRU) != SUCCESS) {\
261 return FAILURE; \
262 }
263
264#define BASIC_RINIT_SUBMODULE(module) \
265 PHP_RINIT(module)(INIT_FUNC_ARGS_PASSTHRU);
266
267#define BASIC_MINFO_SUBMODULE(module) \
268 PHP_MINFO(module)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU);
269
270#define BASIC_RSHUTDOWN_SUBMODULE(module) \
271 PHP_RSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
272
273#define BASIC_MSHUTDOWN_SUBMODULE(module) \
274 PHP_MSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
275
276PHP_MINIT_FUNCTION(basic) /* {{{ */
277{
278#ifdef ZTS
279 ts_allocate_id(&basic_globals_id, sizeof(php_basic_globals), (ts_allocate_ctor) basic_globals_ctor, (ts_allocate_dtor) basic_globals_dtor);
280# ifdef PHP_WIN32
281 ts_allocate_id(&php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor)php_win32_core_globals_ctor, (ts_allocate_dtor)php_win32_core_globals_dtor );
282# endif
283#else
284 basic_globals_ctor(&basic_globals);
285# ifdef PHP_WIN32
287# endif
288#endif
289
291
292 php_ce_incomplete_class = register_class___PHP_Incomplete_Class();
294
295 assertion_error_ce = register_class_AssertionError(zend_ce_error);
296
297 rounding_mode_ce = register_class_RoundingMode();
298
302 BASIC_MINIT_SUBMODULE(browscap)
303 BASIC_MINIT_SUBMODULE(standard_filters)
304 BASIC_MINIT_SUBMODULE(user_filters)
305 BASIC_MINIT_SUBMODULE(password)
306
307#ifdef ZTS
309#endif
310
311#ifdef ZEND_INTRIN_SSE4_2_FUNC_PTR
312 BASIC_MINIT_SUBMODULE(string_intrin)
313#endif
314
315#ifdef ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PTR
316 BASIC_MINIT_SUBMODULE(crc32_x86_intrin)
317#endif
318
319#if defined(ZEND_INTRIN_AVX2_FUNC_PTR) || defined(ZEND_INTRIN_SSSE3_FUNC_PTR)
320 BASIC_MINIT_SUBMODULE(base64_intrin)
321#endif
322
324
326#ifdef HAVE_SYSLOG_H
328#endif
331 BASIC_MINIT_SUBMODULE(url_scanner_ex)
332#ifdef PHP_CAN_SUPPORT_PROC_OPEN
334#endif
336
337 BASIC_MINIT_SUBMODULE(user_streams)
338
341#ifdef HAVE_GLOB
343#endif
347
348 return SUCCESS;
349}
350/* }}} */
351
352PHP_MSHUTDOWN_FUNCTION(basic) /* {{{ */
353{
354#ifdef ZTS
355 ts_free_id(basic_globals_id);
356#ifdef PHP_WIN32
357 ts_free_id(php_win32_core_globals_id);
358#endif
359#else
360 basic_globals_dtor(&basic_globals);
361#ifdef PHP_WIN32
363#endif
364#endif
365
369
373 BASIC_MSHUTDOWN_SUBMODULE(url_scanner_ex)
375 BASIC_MSHUTDOWN_SUBMODULE(standard_filters)
376#ifdef ZTS
378#endif
381
382 return SUCCESS;
383}
384/* }}} */
385
386PHP_RINIT_FUNCTION(basic) /* {{{ */
387{
388 memset(BG(strtok_table), 0, 256);
389
390 BG(serialize_lock) = 0;
391 memset(&BG(serialize), 0, sizeof(BG(serialize)));
392 memset(&BG(unserialize), 0, sizeof(BG(unserialize)));
393
394 BG(strtok_string) = NULL;
395 BG(strtok_last) = NULL;
396 BG(ctype_string) = NULL;
397 BG(locale_changed) = 0;
398 BG(user_compare_fci) = empty_fcall_info;
399 BG(user_compare_fci_cache) = empty_fcall_info_cache;
400 BG(page_uid) = -1;
401 BG(page_gid) = -1;
402 BG(page_inode) = -1;
403 BG(page_mtime) = -1;
404#ifdef HAVE_PUTENV
405 zend_hash_init(&BG(putenv_ht), 1, NULL, php_putenv_destructor, 0);
406#endif
407 BG(user_shutdown_function_names) = NULL;
408
411 BASIC_RINIT_SUBMODULE(url_scanner_ex)
412
413 /* Initialize memory for last http headers */
414 ZVAL_UNDEF(&BG(last_http_headers));
415
416 /* Setup default context */
417 FG(default_context) = NULL;
418
419 /* Default to global wrappers only */
420 FG(stream_wrappers) = NULL;
421
422 /* Default to global filters only */
423 FG(stream_filters) = NULL;
424
426}
427/* }}} */
428
429PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */
430{
431 if (BG(strtok_string)) {
432 zend_string_release(BG(strtok_string));
433 BG(strtok_string) = NULL;
434 }
435#ifdef HAVE_PUTENV
436 tsrm_env_lock();
437 zend_hash_destroy(&BG(putenv_ht));
438 tsrm_env_unlock();
439#endif
440
441 if (BG(umask) != -1) {
442 umask(BG(umask));
443 }
444
445 /* Check if locale was changed and change it back
446 * to the value in startup environment */
447 if (BG(locale_changed)) {
448 setlocale(LC_ALL, "C");
451 if (BG(ctype_string)) {
452 zend_string_release_ex(BG(ctype_string), 0);
453 BG(ctype_string) = NULL;
454 }
455 }
456
457 /* FG(stream_wrappers) and FG(stream_filters) are destroyed
458 * during php_request_shutdown() */
459
461#ifdef HAVE_SYSLOG_H
463#endif
465 BASIC_RSHUTDOWN_SUBMODULE(url_scanner_ex)
467#ifdef PHP_WIN32
468 BASIC_RSHUTDOWN_SUBMODULE(win32_core_globals)
469#endif
470
471 if (BG(user_tick_functions)) {
472 zend_llist_destroy(BG(user_tick_functions));
473 efree(BG(user_tick_functions));
474 BG(user_tick_functions) = NULL;
475 }
476
477 BASIC_RSHUTDOWN_SUBMODULE(user_filters)
479
480 /* Free last http headers */
481 zval_ptr_dtor(&BG(last_http_headers));
482
483 BG(page_uid) = -1;
484 BG(page_gid) = -1;
485 return SUCCESS;
486}
487/* }}} */
488
489PHP_MINFO_FUNCTION(basic) /* {{{ */
490{
496}
497/* }}} */
498
499/* {{{ Given the name of a constant this function will return the constant's associated value */
501{
502 zend_string *const_name;
503 zval *c;
505
507 Z_PARAM_STR(const_name)
509
512 if (!c) {
514 }
515
520 }
521 }
522}
523/* }}} */
524
525/* {{{ Converts a packed inet address to a human readable IP address string */
527{
528 char *address;
529 size_t address_len;
530 int af = AF_INET;
531 char buffer[40];
532
534 Z_PARAM_STRING(address, address_len)
536
537#ifdef HAVE_IPV6
538 if (address_len == 16) {
539 af = AF_INET6;
540 } else
541#endif
542 if (address_len != 4) {
544 }
545
546 if (!inet_ntop(af, address, buffer, sizeof(buffer))) {
548 }
549
551}
552/* }}} */
553
554/* {{{ Converts a human readable IP address to a packed binary string */
556{
557 int ret, af = AF_INET;
558 char *address;
559 size_t address_len;
560 char buffer[17];
561
563 Z_PARAM_STRING(address, address_len)
565
566 memset(buffer, 0, sizeof(buffer));
567
568#ifdef HAVE_IPV6
569 if (strchr(address, ':')) {
570 af = AF_INET6;
571 } else
572#endif
573 if (!strchr(address, '.')) {
575 }
576
577 ret = inet_pton(af, address, buffer);
578
579 if (ret <= 0) {
581 }
582
583 RETURN_STRINGL(buffer, af == AF_INET ? 4 : 16);
584}
585/* }}} */
586
587/* {{{ Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address */
589{
590 char *addr;
591 size_t addr_len;
592 struct in_addr ip;
593
595 Z_PARAM_STRING(addr, addr_len)
597
598 if (addr_len == 0 || inet_pton(AF_INET, addr, &ip) != 1) {
600 }
601 RETURN_LONG(ntohl(ip.s_addr));
602}
603/* }}} */
604
605/* {{{ Converts an (IPv4) Internet network address into a string in Internet standard dotted format */
607{
608 zend_ulong ip;
609 zend_long sip;
610 struct in_addr myaddr;
611 char str[40];
612
614 Z_PARAM_LONG(sip)
616
617 /* autoboxes on 32bit platforms, but that's expected */
618 ip = (zend_ulong)sip;
619
620 myaddr.s_addr = htonl(ip);
621 const char* result = inet_ntop(AF_INET, &myaddr, str, sizeof(str));
623
624 RETURN_STRING(str);
625}
626/* }}} */
627
628/********************
629 * System Functions *
630 ********************/
631
632PHPAPI zend_string *php_getenv(const char *str, size_t str_len) {
633#ifdef PHP_WIN32
634 {
635 wchar_t *keyw = php_win32_cp_conv_any_to_w(str, str_len, PHP_WIN32_CP_IGNORE_LEN_P);
636 if (!keyw) {
637 return NULL;
638 }
639
640 SetLastError(0);
641 /* If the given buffer is not large enough to hold the data, the return value is
642 * the buffer size, in characters, required to hold the string and its terminating
643 * null character. We use this return value to alloc the final buffer. */
644 wchar_t dummybuf;
645 DWORD size = GetEnvironmentVariableW(keyw, &dummybuf, 0);
646 if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
647 /* The environment variable doesn't exist. */
648 free(keyw);
649 return NULL;
650 }
651
652 if (size == 0) {
653 /* env exists, but it is empty */
654 free(keyw);
655 return ZSTR_EMPTY_ALLOC();
656 }
657
658 wchar_t *valw = emalloc((size + 1) * sizeof(wchar_t));
659 size = GetEnvironmentVariableW(keyw, valw, size);
660 if (size == 0) {
661 /* has been removed between the two calls */
662 free(keyw);
663 efree(valw);
664 return ZSTR_EMPTY_ALLOC();
665 } else {
666 char *ptr = php_win32_cp_w_to_any(valw);
667 zend_string *result = zend_string_init(ptr, strlen(ptr), 0);
668 free(ptr);
669 free(keyw);
670 efree(valw);
671 return result;
672 }
673 }
674#else
675 tsrm_env_lock();
676
677 /* system method returns a const */
678 char *ptr = getenv(str);
680 if (ptr) {
681 result = zend_string_init(ptr, strlen(ptr), 0);
682 }
683
684 tsrm_env_unlock();
685 return result;
686#endif
687}
688
689/* {{{ Get the value of an environment variable or every available environment variable
690 if no varname is present */
692{
693 char *str = NULL;
694 size_t str_len;
695 bool local_only = 0;
696
699 Z_PARAM_STRING_OR_NULL(str, str_len)
700 Z_PARAM_BOOL(local_only)
702
703 if (!str) {
706 return;
707 }
708
709 if (!local_only) {
710 /* SAPI method returns an emalloc()'d string */
711 char *ptr = sapi_getenv(str, str_len);
712 if (ptr) {
713 // TODO: avoid reallocation ???
715 efree(ptr);
716 return;
717 }
718 }
719
720 zend_string *res = php_getenv(str, str_len);
721 if (res) {
723 }
725}
726/* }}} */
727
728#ifdef HAVE_PUTENV
729/* {{{ Set the value of an environment variable */
731{
732 char *setting;
733 size_t setting_len;
734 char *p, **env;
735 putenv_entry pe;
736#ifdef PHP_WIN32
737 const char *value = NULL;
738 int error_code;
739#endif
740
742 Z_PARAM_STRING(setting, setting_len)
744
745 if (setting_len == 0 || setting[0] == '=') {
746 zend_argument_value_error(1, "must have a valid syntax");
748 }
749
750 pe.putenv_string = zend_strndup(setting, setting_len);
751 if ((p = strchr(setting, '='))) {
752 pe.key = zend_string_init(setting, p - setting, 0);
753#ifdef PHP_WIN32
754 value = p + 1;
755#endif
756 } else {
757 pe.key = zend_string_init(setting, setting_len, 0);
758 }
759
760 tsrm_env_lock();
761 zend_hash_del(&BG(putenv_ht), pe.key);
762
763 /* find previous value */
764 pe.previous_value = NULL;
765 for (env = environ; env != NULL && *env != NULL; env++) {
766 if (!strncmp(*env, ZSTR_VAL(pe.key), ZSTR_LEN(pe.key))
767 && (*env)[ZSTR_LEN(pe.key)] == '=') { /* found it */
768#ifdef PHP_WIN32
769 /* must copy previous value because MSVCRT's putenv can free the string without notice */
770 pe.previous_value = estrdup(*env);
771#else
772 pe.previous_value = *env;
773#endif
774 break;
775 }
776 }
777
778#ifdef HAVE_UNSETENV
779 if (!p) { /* no '=' means we want to unset it */
780 unsetenv(pe.putenv_string);
781 }
782 if (!p || putenv(pe.putenv_string) == 0) { /* success */
783#else
784# ifndef PHP_WIN32
785 if (putenv(pe.putenv_string) == 0) { /* success */
786# else
787 wchar_t *keyw, *valw = NULL;
788
789 keyw = php_win32_cp_any_to_w(ZSTR_VAL(pe.key));
790 if (value) {
792 }
793 /* valw may be NULL, but the failed conversion still needs to be checked. */
794 if (!keyw || !valw && value) {
795 tsrm_env_unlock();
796 free(pe.putenv_string);
797 zend_string_release(pe.key);
798 free(keyw);
799 free(valw);
801 }
802
803 error_code = SetEnvironmentVariableW(keyw, valw);
804
805 if (error_code != 0
806# ifndef ZTS
807 /* We need both SetEnvironmentVariable and _putenv here as some
808 dependency lib could use either way to read the environment.
809 Obviously the CRT version will be useful more often. But
810 generally, doing both brings us on the safe track at least
811 in NTS build. */
812 && _wputenv_s(keyw, valw ? valw : L"") == 0
813# endif
814 ) { /* success */
815# endif
816#endif
817 zend_hash_add_mem(&BG(putenv_ht), pe.key, &pe, sizeof(putenv_entry));
818#ifdef HAVE_TZSET
819 if (zend_string_equals_literal_ci(pe.key, "TZ")) {
820 tzset();
821 }
822#endif
823 tsrm_env_unlock();
824#ifdef PHP_WIN32
825 free(keyw);
826 free(valw);
827#endif
829 } else {
830 tsrm_env_unlock();
831 free(pe.putenv_string);
832 zend_string_release(pe.key);
833#ifdef PHP_WIN32
834 free(keyw);
835 free(valw);
836#endif
838 }
839}
840/* }}} */
841#endif
842
843/* {{{ free_argv()
844 Free the memory allocated to an argv array. */
845static void free_argv(char **argv, int argc)
846{
847 int i;
848
849 if (argv) {
850 for (i = 0; i < argc; i++) {
851 if (argv[i]) {
852 efree(argv[i]);
853 }
854 }
855 efree(argv);
856 }
857}
858/* }}} */
859
860/* {{{ free_longopts()
861 Free the memory allocated to an longopt array. */
862static void free_longopts(opt_struct *longopts)
863{
864 opt_struct *p;
865
866 if (longopts) {
867 for (p = longopts; p && p->opt_char != '-'; p++) {
868 if (p->opt_name != NULL) {
869 efree((char *)(p->opt_name));
870 }
871 }
872 }
873}
874/* }}} */
875
876/* {{{ parse_opts()
877 Convert the typical getopt input characters to the php_getopt struct array */
878static int parse_opts(char * opts, opt_struct ** result)
879{
880 opt_struct * paras = NULL;
881 unsigned int i, count = 0;
882 unsigned int opts_len = (unsigned int)strlen(opts);
883
884 for (i = 0; i < opts_len; i++) {
885 if ((opts[i] >= 48 && opts[i] <= 57) ||
886 (opts[i] >= 65 && opts[i] <= 90) ||
887 (opts[i] >= 97 && opts[i] <= 122)
888 ) {
889 count++;
890 }
891 }
892
893 paras = safe_emalloc(sizeof(opt_struct), count, 0);
894 memset(paras, 0, sizeof(opt_struct) * count);
895 *result = paras;
896 while ( (*opts >= 48 && *opts <= 57) || /* 0 - 9 */
897 (*opts >= 65 && *opts <= 90) || /* A - Z */
898 (*opts >= 97 && *opts <= 122) /* a - z */
899 ) {
900 paras->opt_char = *opts;
901 paras->need_param = *(++opts) == ':';
902 paras->opt_name = NULL;
903 if (paras->need_param == 1) {
904 opts++;
905 if (*opts == ':') {
906 paras->need_param++;
907 opts++;
908 }
909 }
910 paras++;
911 }
912 return count;
913}
914/* }}} */
915
916/* {{{ Get options from the command line argument list */
918{
919 char *options = NULL, **argv = NULL;
920 char opt[2] = { '\0' };
921 char *optname;
922 int argc = 0, o;
923 size_t options_len = 0, len;
924 char *php_optarg = NULL;
925 int php_optind = 1;
926 zval val, *args = NULL, *p_longopts = NULL;
927 zval *zoptind = NULL;
928 size_t optname_len = 0;
929 opt_struct *opts, *orig_opts;
930
932 Z_PARAM_STRING(options, options_len)
934 Z_PARAM_ARRAY(p_longopts)
935 Z_PARAM_ZVAL(zoptind)
937
938 /* Init zoptind to 1 */
939 if (zoptind) {
940 ZEND_TRY_ASSIGN_REF_LONG(zoptind, 1);
941 }
942
943 /* Get argv from the global symbol table. We calculate argc ourselves
944 * in order to be on the safe side, even though it is also available
945 * from the symbol table. */
946 if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global(ZSTR_KNOWN(ZEND_STR_AUTOGLOBAL_SERVER))) &&
947 ((args = zend_hash_find_ex_ind(Z_ARRVAL_P(&PG(http_globals)[TRACK_VARS_SERVER]), ZSTR_KNOWN(ZEND_STR_ARGV), 1)) != NULL ||
948 (args = zend_hash_find_ex_ind(&EG(symbol_table), ZSTR_KNOWN(ZEND_STR_ARGV), 1)) != NULL)
949 ) {
950 int pos = 0;
951 zval *entry;
952
953 if (Z_TYPE_P(args) != IS_ARRAY) {
955 }
956 argc = zend_hash_num_elements(Z_ARRVAL_P(args));
957
958 /* Attempt to allocate enough memory to hold all of the arguments
959 * and a trailing NULL */
960 argv = (char **) safe_emalloc(sizeof(char *), (argc + 1), 0);
961
962 /* Iterate over the hash to construct the argv array. */
964 zend_string *tmp_arg_str;
965 zend_string *arg_str = zval_get_tmp_string(entry, &tmp_arg_str);
966
967 argv[pos++] = estrdup(ZSTR_VAL(arg_str));
968
969 zend_tmp_string_release(tmp_arg_str);
971
972 /* The C Standard requires argv[argc] to be NULL - this might
973 * keep some getopt implementations happy. */
974 argv[argc] = NULL;
975 } else {
976 /* Return false if we can't find argv. */
978 }
979
980 len = parse_opts(options, &opts);
981
982 if (p_longopts) {
983 int count;
984 zval *entry;
985
986 count = zend_hash_num_elements(Z_ARRVAL_P(p_longopts));
987
988 /* the first <len> slots are filled by the one short ops
989 * we now extend our array and jump to the new added structs */
990 opts = (opt_struct *) safe_erealloc(opts, sizeof(opt_struct), (len + count + 1), 0);
991 orig_opts = opts;
992 opts += len;
993
994 memset(opts, 0, count * sizeof(opt_struct));
995
996 /* Iterate over the hash to construct the argv array. */
997 ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(p_longopts), entry) {
998 zend_string *tmp_arg_str;
999 zend_string *arg_str = zval_get_tmp_string(entry, &tmp_arg_str);
1000
1001 opts->need_param = 0;
1002 opts->opt_name = estrdup(ZSTR_VAL(arg_str));
1003 len = strlen(opts->opt_name);
1004 if ((len > 0) && (opts->opt_name[len - 1] == ':')) {
1005 opts->need_param++;
1006 opts->opt_name[len - 1] = '\0';
1007 if ((len > 1) && (opts->opt_name[len - 2] == ':')) {
1008 opts->need_param++;
1009 opts->opt_name[len - 2] = '\0';
1010 }
1011 }
1012 opts->opt_char = 0;
1013 opts++;
1014
1015 zend_tmp_string_release(tmp_arg_str);
1017 } else {
1018 opts = (opt_struct*) erealloc(opts, sizeof(opt_struct) * (len + 1));
1019 orig_opts = opts;
1020 opts += len;
1021 }
1022
1023 /* php_getopt want to identify the last param */
1024 opts->opt_char = '-';
1025 opts->need_param = 0;
1026 opts->opt_name = NULL;
1027
1028 /* Initialize the return value as an array. */
1030
1031 /* after our pointer arithmetic jump back to the first element */
1032 opts = orig_opts;
1033
1034 while ((o = php_getopt(argc, argv, opts, &php_optarg, &php_optind, 0, 1)) != -1) {
1035 /* Skip unknown arguments. */
1036 if (o == PHP_GETOPT_INVALID_ARG) {
1037 continue;
1038 }
1039
1040 /* Prepare the option character and the argument string. */
1041 if (o == 0) {
1042 optname = opts[php_optidx].opt_name;
1043 } else {
1044 if (o == 1) {
1045 o = '-';
1046 }
1047 opt[0] = o;
1048 optname = opt;
1049 }
1050
1051 if (php_optarg != NULL) {
1052 /* keep the arg as binary, since the encoding is not known */
1053 ZVAL_STRING(&val, php_optarg);
1054 } else {
1055 ZVAL_FALSE(&val);
1056 }
1057
1058 /* Add this option / argument pair to the result hash. */
1059 optname_len = strlen(optname);
1060 if (!(optname_len > 1 && optname[0] == '0') && is_numeric_string(optname, optname_len, NULL, NULL, 0) == IS_LONG) {
1061 /* numeric string */
1062 int optname_int = atoi(optname);
1063 if ((args = zend_hash_index_find(Z_ARRVAL_P(return_value), optname_int)) != NULL) {
1064 if (Z_TYPE_P(args) != IS_ARRAY) {
1066 }
1068 } else {
1070 }
1071 } else {
1072 /* other strings */
1073 if ((args = zend_hash_str_find(Z_ARRVAL_P(return_value), optname, strlen(optname))) != NULL) {
1074 if (Z_TYPE_P(args) != IS_ARRAY) {
1076 }
1078 } else {
1079 zend_hash_str_add(Z_ARRVAL_P(return_value), optname, strlen(optname), &val);
1080 }
1081 }
1082
1083 php_optarg = NULL;
1084 }
1085
1086 /* Set zoptind to php_optind */
1087 if (zoptind) {
1088 ZEND_TRY_ASSIGN_REF_LONG(zoptind, php_optind);
1089 }
1090
1091 free_longopts(orig_opts);
1092 efree(orig_opts);
1093 free_argv(argv, argc);
1094}
1095/* }}} */
1096
1097/* {{{ Flush the output buffer */
1104/* }}} */
1105
1106/* {{{ Delay for a given number of seconds */
1108{
1109 zend_long num;
1110
1112 Z_PARAM_LONG(num)
1114
1115 if (num < 0) {
1116 zend_argument_value_error(1, "must be greater than or equal to 0");
1117 RETURN_THROWS();
1118 }
1119
1120 RETURN_LONG(php_sleep((unsigned int)num));
1121}
1122/* }}} */
1123
1124/* {{{ Delay for a given number of micro seconds */
1126{
1127 zend_long num;
1128
1130 Z_PARAM_LONG(num)
1132
1133 if (num < 0) {
1134 zend_argument_value_error(1, "must be greater than or equal to 0");
1135 RETURN_THROWS();
1136 }
1137
1138#ifdef HAVE_USLEEP
1139 usleep((unsigned int)num);
1140#endif
1141}
1142/* }}} */
1143
1144#ifdef HAVE_NANOSLEEP
1145/* {{{ Delay for a number of seconds and nano seconds */
1147{
1148 zend_long tv_sec, tv_nsec;
1149 struct timespec php_req, php_rem;
1150
1155
1156 if (tv_sec < 0) {
1157 zend_argument_value_error(1, "must be greater than or equal to 0");
1158 RETURN_THROWS();
1159 }
1160 if (tv_nsec < 0) {
1161 zend_argument_value_error(2, "must be greater than or equal to 0");
1162 RETURN_THROWS();
1163 }
1164
1165 php_req.tv_sec = (time_t) tv_sec;
1166 php_req.tv_nsec = (long)tv_nsec;
1167 if (!nanosleep(&php_req, &php_rem)) {
1169 } else if (errno == EINTR) {
1171 add_assoc_long_ex(return_value, "seconds", sizeof("seconds")-1, php_rem.tv_sec);
1172 add_assoc_long_ex(return_value, "nanoseconds", sizeof("nanoseconds")-1, php_rem.tv_nsec);
1173 return;
1174 } else if (errno == EINVAL) {
1175 zend_value_error("Nanoseconds was not in the range 0 to 999 999 999 or seconds was negative");
1176 RETURN_THROWS();
1177 }
1178
1180}
1181/* }}} */
1182
1183/* {{{ Make the script sleep until the specified time */
1185{
1186 double target_secs;
1187 struct timeval tm;
1188 struct timespec php_req, php_rem;
1189 uint64_t current_ns, target_ns, diff_ns;
1190 const uint64_t ns_per_sec = 1000000000;
1191 const double top_target_sec = (double)(UINT64_MAX / ns_per_sec);
1192
1194 Z_PARAM_DOUBLE(target_secs)
1196
1197 if (gettimeofday((struct timeval *) &tm, NULL) != 0) {
1199 }
1200
1201 if (UNEXPECTED(!(target_secs >= 0 && target_secs <= top_target_sec))) {
1202 zend_argument_value_error(1, "must be between 0 and %" PRIu64, (uint64_t)top_target_sec);
1203 RETURN_THROWS();
1204 }
1205
1206 target_ns = (uint64_t) (target_secs * ns_per_sec);
1207 current_ns = ((uint64_t) tm.tv_sec) * ns_per_sec + ((uint64_t) tm.tv_usec) * 1000;
1208 if (target_ns < current_ns) {
1209 php_error_docref(NULL, E_WARNING, "Argument #1 ($timestamp) must be greater than or equal to the current time");
1211 }
1212
1213 diff_ns = target_ns - current_ns;
1214 php_req.tv_sec = (time_t) (diff_ns / ns_per_sec);
1215 php_req.tv_nsec = (long) (diff_ns % ns_per_sec);
1216
1217 while (nanosleep(&php_req, &php_rem)) {
1218 if (errno == EINTR) {
1219 php_req.tv_sec = php_rem.tv_sec;
1220 php_req.tv_nsec = php_rem.tv_nsec;
1221 } else {
1223 }
1224 }
1225
1227}
1228/* }}} */
1229#endif
1230
1231/* {{{ Get the name of the owner of the current PHP script */
1238/* }}} */
1239
1240#define ZVAL_SET_INI_STR(zv, val) do { \
1241 if (ZSTR_IS_INTERNED(val)) { \
1242 ZVAL_INTERNED_STR(zv, val); \
1243 } else if (ZSTR_LEN(val) == 0) { \
1244 ZVAL_EMPTY_STRING(zv); \
1245 } else if (ZSTR_LEN(val) == 1) { \
1246 ZVAL_CHAR(zv, ZSTR_VAL(val)[0]); \
1247 } else if (!(GC_FLAGS(val) & GC_PERSISTENT)) { \
1248 ZVAL_NEW_STR(zv, zend_string_copy(val)); \
1249 } else { \
1250 ZVAL_NEW_STR(zv, zend_string_init(ZSTR_VAL(val), ZSTR_LEN(val), 0)); \
1251 } \
1252} while (0)
1253
1254static void add_config_entries(HashTable *hash, zval *return_value);
1255
1256/* {{{ add_config_entry */
1257static void add_config_entry(zend_ulong h, zend_string *key, zval *entry, zval *retval)
1258{
1259 if (Z_TYPE_P(entry) == IS_STRING) {
1260 zval str_zv;
1261 ZVAL_SET_INI_STR(&str_zv, Z_STR_P(entry));
1262 if (key) {
1264 } else {
1265 add_index_zval(retval, h, &str_zv);
1266 }
1267 } else if (Z_TYPE_P(entry) == IS_ARRAY) {
1268 zval tmp;
1269 array_init(&tmp);
1270 add_config_entries(Z_ARRVAL_P(entry), &tmp);
1272 }
1273}
1274/* }}} */
1275
1276/* {{{ add_config_entries */
1277static void add_config_entries(HashTable *hash, zval *return_value) /* {{{ */
1278{
1279 zend_ulong h;
1281 zval *zv;
1282
1284 add_config_entry(h, key, zv, return_value);
1286}
1287/* }}} */
1288
1289/* {{{ Get the value of a PHP configuration option */
1291{
1292 zend_string *varname;
1293
1295 Z_PARAM_STR(varname)
1297
1298 zval *retval = cfg_get_entry_ex(varname);
1299
1300 if (retval) {
1301 if (Z_TYPE_P(retval) == IS_ARRAY) {
1303 add_config_entries(Z_ARRVAL_P(retval), return_value);
1304 return;
1305 } else {
1307 }
1308 } else {
1310 }
1311}
1312/* }}} */
1313
1314/*
1315 1st arg = error message
1316 2nd arg = error option
1317 3rd arg = optional parameters (email address or tcp address)
1318 4th arg = used for additional headers if email
1319
1320error options:
1321 0 = send to php_error_log (uses syslog or file depending on ini setting)
1322 1 = send via email to 3rd parameter 4th option = additional headers
1323 2 = send via tcp/ip to 3rd parameter (name or ip:port)
1324 3 = save to file in 3rd parameter
1325 4 = send to SAPI logger directly
1326*/
1327
1328/* {{{ Send an error message somewhere */
1330{
1331 char *message, *opt = NULL, *headers = NULL;
1332 size_t message_len, opt_len = 0, headers_len = 0;
1333 zend_long erropt = 0;
1334
1336 Z_PARAM_STRING(message, message_len)
1338 Z_PARAM_LONG(erropt)
1339 Z_PARAM_PATH_OR_NULL(opt, opt_len)
1340 Z_PARAM_STRING_OR_NULL(headers, headers_len)
1342
1343 if (_php_error_log_ex((int) erropt, message, message_len, opt, headers) == FAILURE) {
1345 }
1346
1348}
1349/* }}} */
1350
1351/* For BC (not binary-safe!) */
1352PHPAPI int _php_error_log(int opt_err, const char *message, const char *opt, const char *headers) /* {{{ */
1353{
1354 return _php_error_log_ex(opt_err, message, (opt_err == 3) ? strlen(message) : 0, opt, headers);
1355}
1356/* }}} */
1357
1358PHPAPI int _php_error_log_ex(int opt_err, const char *message, size_t message_len, const char *opt, const char *headers) /* {{{ */
1359{
1360 php_stream *stream = NULL;
1361 size_t nbytes;
1362
1363 switch (opt_err)
1364 {
1365 case 1: /*send an email */
1366 if (!php_mail(opt, "PHP error_log message", message, headers, NULL)) {
1367 return FAILURE;
1368 }
1369 break;
1370
1371 case 2: /*send to an address */
1372 zend_value_error("TCP/IP option is not available for error logging");
1373 return FAILURE;
1374
1375 case 3: /*save to a file */
1376 stream = php_stream_open_wrapper(opt, "a", REPORT_ERRORS, NULL);
1377 if (!stream) {
1378 return FAILURE;
1379 }
1380 nbytes = php_stream_write(stream, message, message_len);
1381 php_stream_close(stream);
1382 if (nbytes != message_len) {
1383 return FAILURE;
1384 }
1385 break;
1386
1387 case 4: /* send to SAPI */
1388 if (sapi_module.log_message) {
1389 sapi_module.log_message(message, -1);
1390 } else {
1391 return FAILURE;
1392 }
1393 break;
1394
1395 default:
1397 break;
1398 }
1399 return SUCCESS;
1400}
1401/* }}} */
1402
1403/* {{{ Get the last occurred error as associative array. Returns NULL if there hasn't been an error yet. */
1405{
1407
1408 if (PG(last_error_message)) {
1409 zval tmp;
1411
1412 ZVAL_LONG(&tmp, PG(last_error_type));
1413 zend_hash_update(Z_ARR_P(return_value), ZSTR_KNOWN(ZEND_STR_TYPE), &tmp);
1414
1415 ZVAL_STR_COPY(&tmp, PG(last_error_message));
1416 zend_hash_update(Z_ARR_P(return_value), ZSTR_KNOWN(ZEND_STR_MESSAGE), &tmp);
1417
1418 ZVAL_STR_COPY(&tmp, PG(last_error_file));
1419 zend_hash_update(Z_ARR_P(return_value), ZSTR_KNOWN(ZEND_STR_FILE), &tmp);
1420
1421 ZVAL_LONG(&tmp, PG(last_error_lineno));
1422 zend_hash_update(Z_ARR_P(return_value), ZSTR_KNOWN(ZEND_STR_LINE), &tmp);
1423 }
1424}
1425/* }}} */
1426
1427/* {{{ Clear the last occurred error. */
1429{
1431
1432 if (PG(last_error_message)) {
1433 PG(last_error_type) = 0;
1434 PG(last_error_lineno) = 0;
1435
1436 zend_string_release(PG(last_error_message));
1437 PG(last_error_message) = NULL;
1438
1439 if (PG(last_error_file)) {
1440 zend_string_release(PG(last_error_file));
1441 PG(last_error_file) = NULL;
1442 }
1443 }
1444}
1445/* }}} */
1446
1447/* {{{ Call a user function which is the first parameter
1448 Warning: This function is special-cased by zend_compile.c and so is usually bypassed */
1450{
1451 zval retval;
1452 zend_fcall_info fci;
1453 zend_fcall_info_cache fci_cache;
1454
1456 Z_PARAM_FUNC(fci, fci_cache)
1459
1460 fci.retval = &retval;
1461
1462 if (zend_call_function(&fci, &fci_cache) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
1463 if (Z_ISREF(retval)) {
1464 zend_unwrap_reference(&retval);
1465 }
1467 }
1468}
1469/* }}} */
1470
1471/* {{{ Call a user function which is the first parameter with the arguments contained in array
1472 Warning: This function is special-cased by zend_compile.c and so is usually bypassed */
1474{
1475 zval retval;
1476 HashTable *params;
1477 zend_fcall_info fci;
1478 zend_fcall_info_cache fci_cache;
1479
1481 Z_PARAM_FUNC(fci, fci_cache)
1482 Z_PARAM_ARRAY_HT(params)
1484
1485 fci.named_params = params;
1486 fci.retval = &retval;
1487
1488 if (zend_call_function(&fci, &fci_cache) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
1489 if (Z_ISREF(retval)) {
1490 zend_unwrap_reference(&retval);
1491 }
1493 }
1494}
1495/* }}} */
1496
1497/* {{{ Call a user function which is the first parameter */
1499{
1500 zval retval;
1501 zend_fcall_info fci;
1502 zend_fcall_info_cache fci_cache;
1503 zend_class_entry *called_scope;
1504
1506 Z_PARAM_FUNC(fci, fci_cache)
1507 Z_PARAM_VARIADIC('*', fci.params, fci.param_count)
1509
1510 if (!EX(prev_execute_data) || !EX(prev_execute_data)->func->common.scope) {
1511 zend_throw_error(NULL, "Cannot call forward_static_call() when no class scope is active");
1512 RETURN_THROWS();
1513 }
1514
1515 fci.retval = &retval;
1516
1517 called_scope = zend_get_called_scope(execute_data);
1518 if (called_scope && fci_cache.calling_scope &&
1519 instanceof_function(called_scope, fci_cache.calling_scope)) {
1520 fci_cache.called_scope = called_scope;
1521 }
1522
1523 if (zend_call_function(&fci, &fci_cache) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
1524 if (Z_ISREF(retval)) {
1525 zend_unwrap_reference(&retval);
1526 }
1528 }
1529}
1530/* }}} */
1531
1532/* {{{ Call a static method which is the first parameter with the arguments contained in array */
1534{
1535 zval retval;
1536 HashTable *params;
1537 zend_fcall_info fci;
1538 zend_fcall_info_cache fci_cache;
1539 zend_class_entry *called_scope;
1540
1542 Z_PARAM_FUNC(fci, fci_cache)
1543 Z_PARAM_ARRAY_HT(params)
1545
1546 fci.retval = &retval;
1547 /* Add positional arguments */
1548 fci.named_params = params;
1549
1550 called_scope = zend_get_called_scope(execute_data);
1551 if (called_scope && fci_cache.calling_scope &&
1552 instanceof_function(called_scope, fci_cache.calling_scope)) {
1553 fci_cache.called_scope = called_scope;
1554 }
1555
1556 if (zend_call_function(&fci, &fci_cache) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
1557 if (Z_ISREF(retval)) {
1558 zend_unwrap_reference(&retval);
1559 }
1561 }
1562}
1563/* }}} */
1564
1565static void fci_addref(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache)
1566{
1568 if (fci_cache->object) {
1569 GC_ADDREF(fci_cache->object);
1570 }
1571}
1572
1573static void fci_release(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache)
1574{
1576 if (fci_cache->object) {
1577 zend_object_release(fci_cache->object);
1578 }
1579}
1580
1581void user_shutdown_function_dtor(zval *zv) /* {{{ */
1582{
1583 php_shutdown_function_entry *shutdown_function_entry = Z_PTR_P(zv);
1584
1585 zend_fcall_info_args_clear(&shutdown_function_entry->fci, true);
1586 fci_release(&shutdown_function_entry->fci, &shutdown_function_entry->fci_cache);
1587 efree(shutdown_function_entry);
1588}
1589/* }}} */
1590
1591void user_tick_function_dtor(user_tick_function_entry *tick_function_entry) /* {{{ */
1592{
1593 zend_fcall_info_args_clear(&tick_function_entry->fci, true);
1594 fci_release(&tick_function_entry->fci, &tick_function_entry->fci_cache);
1595}
1596/* }}} */
1597
1598static int user_shutdown_function_call(zval *zv) /* {{{ */
1599{
1600 php_shutdown_function_entry *shutdown_function_entry = Z_PTR_P(zv);
1601 zval retval;
1602 zend_result call_status;
1603
1604 /* set retval zval for FCI struct */
1605 shutdown_function_entry->fci.retval = &retval;
1606 call_status = zend_call_function(&shutdown_function_entry->fci, &shutdown_function_entry->fci_cache);
1607 ZEND_ASSERT(call_status == SUCCESS);
1609
1610 return 0;
1611}
1612/* }}} */
1613
1614static void user_tick_function_call(user_tick_function_entry *tick_fe) /* {{{ */
1615{
1616 /* Prevent re-entrant calls to the same user ticks function */
1617 if (!tick_fe->calling) {
1618 zval tmp;
1619
1620 /* set tmp zval */
1621 tick_fe->fci.retval = &tmp;
1622
1623 tick_fe->calling = true;
1624 zend_call_function(&tick_fe->fci, &tick_fe->fci_cache);
1625
1626 /* Destroy return value */
1627 zval_ptr_dtor(&tmp);
1628 tick_fe->calling = false;
1629 }
1630}
1631/* }}} */
1632
1633static void run_user_tick_functions(int tick_count, void *arg) /* {{{ */
1634{
1635 zend_llist_apply(BG(user_tick_functions), (llist_apply_func_t) user_tick_function_call);
1636}
1637/* }}} */
1638
1639static int user_tick_function_compare(user_tick_function_entry * tick_fe1, user_tick_function_entry * tick_fe2) /* {{{ */
1640{
1641 zval *func1 = &tick_fe1->fci.function_name;
1642 zval *func2 = &tick_fe2->fci.function_name;
1643 int ret;
1644
1645 if (Z_TYPE_P(func1) == IS_STRING && Z_TYPE_P(func2) == IS_STRING) {
1646 ret = zend_binary_zval_strcmp(func1, func2) == 0;
1647 } else if (Z_TYPE_P(func1) == IS_ARRAY && Z_TYPE_P(func2) == IS_ARRAY) {
1648 ret = zend_compare_arrays(func1, func2) == 0;
1649 } else if (Z_TYPE_P(func1) == IS_OBJECT && Z_TYPE_P(func2) == IS_OBJECT) {
1650 ret = zend_compare_objects(func1, func2) == 0;
1651 } else {
1652 ret = 0;
1653 }
1654
1655 if (ret && tick_fe1->calling) {
1656 zend_throw_error(NULL, "Registered tick function cannot be unregistered while it is being executed");
1657 return 0;
1658 }
1659 return ret;
1660}
1661/* }}} */
1662
1664{
1665 if (BG(user_shutdown_function_names)) {
1666 zend_try {
1667 zend_hash_apply(BG(user_shutdown_function_names), user_shutdown_function_call);
1668 } zend_end_try();
1669 }
1670}
1671/* }}} */
1672
1674{
1675 if (BG(user_shutdown_function_names))
1676 zend_try {
1677 zend_hash_destroy(BG(user_shutdown_function_names));
1678 FREE_HASHTABLE(BG(user_shutdown_function_names));
1679 BG(user_shutdown_function_names) = NULL;
1680 } zend_catch {
1681 /* maybe shutdown method call exit, we just ignore it */
1682 FREE_HASHTABLE(BG(user_shutdown_function_names));
1683 BG(user_shutdown_function_names) = NULL;
1684 } zend_end_try();
1685}
1686/* }}} */
1687
1688/* {{{ Register a user-level function to be called on request termination */
1690{
1692 zval *params = NULL;
1693 uint32_t param_count = 0;
1694 bool status;
1695
1696 if (zend_parse_parameters(ZEND_NUM_ARGS(), "f*", &entry.fci, &entry.fci_cache, &params, &param_count) == FAILURE) {
1697 RETURN_THROWS();
1698 }
1699
1700 fci_addref(&entry.fci, &entry.fci_cache);
1701 zend_fcall_info_argp(&entry.fci, param_count, params);
1702
1705}
1706/* }}} */
1707
1708PHPAPI bool register_user_shutdown_function(const char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry) /* {{{ */
1709{
1710 if (!BG(user_shutdown_function_names)) {
1711 ALLOC_HASHTABLE(BG(user_shutdown_function_names));
1712 zend_hash_init(BG(user_shutdown_function_names), 0, NULL, user_shutdown_function_dtor, 0);
1713 }
1714
1715 zend_hash_str_update_mem(BG(user_shutdown_function_names), function_name, function_len, shutdown_function_entry, sizeof(php_shutdown_function_entry));
1716 return 1;
1717}
1718/* }}} */
1719
1720PHPAPI bool remove_user_shutdown_function(const char *function_name, size_t function_len) /* {{{ */
1721{
1722 if (BG(user_shutdown_function_names)) {
1723 return zend_hash_str_del(BG(user_shutdown_function_names), function_name, function_len) != FAILURE;
1724 }
1725
1726 return 0;
1727}
1728/* }}} */
1729
1731{
1732 if (!BG(user_shutdown_function_names)) {
1733 ALLOC_HASHTABLE(BG(user_shutdown_function_names));
1734 zend_hash_init(BG(user_shutdown_function_names), 0, NULL, user_shutdown_function_dtor, 0);
1735 }
1736
1737 return zend_hash_next_index_insert_mem(BG(user_shutdown_function_names), shutdown_function_entry, sizeof(php_shutdown_function_entry)) != NULL;
1738}
1739/* }}} */
1740
1742{
1743 syntax_highlighter_ini->highlight_comment = INI_STR("highlight.comment");
1744 syntax_highlighter_ini->highlight_default = INI_STR("highlight.default");
1745 syntax_highlighter_ini->highlight_html = INI_STR("highlight.html");
1746 syntax_highlighter_ini->highlight_keyword = INI_STR("highlight.keyword");
1747 syntax_highlighter_ini->highlight_string = INI_STR("highlight.string");
1748}
1749/* }}} */
1750
1751/* {{{ Syntax highlight a source file */
1753{
1754 char *filename;
1755 size_t filename_len;
1756 int ret;
1758 bool i = 0;
1759
1761 Z_PARAM_PATH(filename, filename_len)
1763 Z_PARAM_BOOL(i)
1765
1766 if (php_check_open_basedir(filename)) {
1768 }
1769
1770 if (i) {
1772 }
1773
1775
1777
1778 if (ret == FAILURE) {
1779 if (i) {
1781 }
1783 }
1784
1785 if (i) {
1789 } else {
1791 }
1792}
1793/* }}} */
1794
1795/* {{{ Return source with stripped comments and whitespace */
1797{
1798 zend_string *filename;
1799 zend_lex_state original_lex_state;
1800 zend_file_handle file_handle;
1801
1803 Z_PARAM_PATH_STR(filename)
1805
1807
1808 zend_stream_init_filename_ex(&file_handle, filename);
1809 zend_save_lexical_state(&original_lex_state);
1810 if (open_file_for_scanning(&file_handle) == FAILURE) {
1811 zend_restore_lexical_state(&original_lex_state);
1813 zend_destroy_file_handle(&file_handle);
1815 }
1816
1817 zend_strip();
1818
1819 zend_restore_lexical_state(&original_lex_state);
1820
1823 zend_destroy_file_handle(&file_handle);
1824}
1825/* }}} */
1826
1827/* {{{ Syntax highlight a string or optionally return it */
1829{
1830 zend_string *str;
1832 char *hicompiled_string_description;
1833 bool i = 0;
1834 int old_error_reporting = EG(error_reporting);
1835
1837 Z_PARAM_STR(str)
1839 Z_PARAM_BOOL(i)
1841
1842 if (i) {
1844 }
1845
1847
1849
1850 hicompiled_string_description = zend_make_compiled_string_description("highlighted code");
1851
1852 highlight_string(str, &syntax_highlighter_ini, hicompiled_string_description);
1853 efree(hicompiled_string_description);
1854
1855 EG(error_reporting) = old_error_reporting;
1856
1857 if (i) {
1861 } else {
1862 // TODO Make this function void?
1864 }
1865}
1866/* }}} */
1867
1868/* {{{ Get interpreted size from the ini shorthand syntax */
1870{
1871 zend_string *shorthand;
1872 zend_string *errstr;
1873
1875 Z_PARAM_STR(shorthand)
1877
1878 RETVAL_LONG(zend_ini_parse_quantity(shorthand, &errstr));
1879
1880 if (errstr) {
1881 zend_error(E_WARNING, "%s", ZSTR_VAL(errstr));
1882 zend_string_release(errstr);
1883 }
1884}
1885/* }}} */
1886
1887/* {{{ Get a configuration option */
1889{
1890 zend_string *varname, *val;
1891
1893 Z_PARAM_STR(varname)
1895
1896 val = zend_ini_get_value(varname);
1897
1898 if (!val) {
1900 }
1901
1903}
1904/* }}} */
1905
1906/* {{{ Get all configuration options */
1908{
1909 char *extname = NULL;
1910 size_t extname_len = 0, module_number = 0;
1911 zend_module_entry *module;
1912 bool details = 1;
1914 zend_ini_entry *ini_entry;
1915
1916
1919 Z_PARAM_STRING_OR_NULL(extname, extname_len)
1920 Z_PARAM_BOOL(details)
1922
1924
1925 if (extname) {
1926 if ((module = zend_hash_str_find_ptr(&module_registry, extname, extname_len)) == NULL) {
1927 php_error_docref(NULL, E_WARNING, "Extension \"%s\" cannot be found", extname);
1929 }
1930 module_number = module->module_number;
1931 }
1932
1934 ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(EG(ini_directives), key, ini_entry) {
1935 zval option;
1936
1937 if (module_number != 0 && ini_entry->module_number != module_number) {
1938 continue;
1939 }
1940
1941 if (key == NULL || ZSTR_VAL(key)[0] != 0) {
1942 if (details) {
1943 array_init(&option);
1944
1945 if (ini_entry->orig_value) {
1946 add_assoc_str(&option, "global_value", zend_string_copy(ini_entry->orig_value));
1947 } else if (ini_entry->value) {
1948 add_assoc_str(&option, "global_value", zend_string_copy(ini_entry->value));
1949 } else {
1950 add_assoc_null(&option, "global_value");
1951 }
1952
1953 if (ini_entry->value) {
1954 add_assoc_str(&option, "local_value", zend_string_copy(ini_entry->value));
1955 } else {
1956 add_assoc_null(&option, "local_value");
1957 }
1958
1959 add_assoc_long(&option, "access", ini_entry->modifiable);
1960
1961 zend_symtable_update(Z_ARRVAL_P(return_value), ini_entry->name, &option);
1962 } else {
1963 if (ini_entry->value) {
1964 zval zv;
1965
1966 ZVAL_STR_COPY(&zv, ini_entry->value);
1967 zend_symtable_update(Z_ARRVAL_P(return_value), ini_entry->name, &zv);
1968 } else {
1969 zend_symtable_update(Z_ARRVAL_P(return_value), ini_entry->name, &EG(uninitialized_zval));
1970 }
1971 }
1972 }
1974}
1975/* }}} */
1976
1977static int php_ini_check_path(char *option_name, size_t option_len, char *new_option_name, size_t new_option_len) /* {{{ */
1978{
1979 if (option_len + 1 != new_option_len) {
1980 return 0;
1981 }
1982
1983 return !strncmp(option_name, new_option_name, option_len);
1984}
1985/* }}} */
1986
1987/* {{{ Set a configuration option, returns false on error and the old value of the configuration option on success */
1989{
1990 zend_string *varname;
1991 zval *new_value;
1993
1995 Z_PARAM_STR(varname)
1996 Z_PARAM_ZVAL(new_value)
1998
1999 if (Z_TYPE_P(new_value) > IS_STRING) {
2000 zend_argument_type_error(2, "must be of type string|int|float|bool|null");
2001 RETURN_THROWS();
2002 }
2003
2004 val = zend_ini_get_value(varname);
2005
2006 if (val) {
2008 } else {
2010 }
2011
2012 zend_string *new_value_tmp_str;
2013 zend_string *new_value_str = zval_get_tmp_string(new_value, &new_value_tmp_str);
2014
2015#define _CHECK_PATH(var, var_len, ini) php_ini_check_path(var, var_len, ini, sizeof(ini))
2016 /* open basedir check */
2017 if (PG(open_basedir)) {
2018 if (_CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "error_log") ||
2019 _CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "java.class.path") ||
2020 _CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "java.home") ||
2021 _CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "mail.log") ||
2022 _CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "java.library.path") ||
2023 _CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "vpopmail.directory")) {
2024 if (php_check_open_basedir(ZSTR_VAL(new_value_str))) {
2025 zval_ptr_dtor_str(return_value);
2026 zend_tmp_string_release(new_value_tmp_str);
2028 }
2029 }
2030 }
2031#undef _CHECK_PATH
2032
2033 if (zend_alter_ini_entry_ex(varname, new_value_str, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0) == FAILURE) {
2034 zval_ptr_dtor_str(return_value);
2036 }
2037 zend_tmp_string_release(new_value_tmp_str);
2038}
2039/* }}} */
2040
2041/* {{{ Restore the value of a configuration option specified by varname */
2052/* }}} */
2053
2054/* {{{ Sets the include_path configuration option */
2056{
2057 zend_string *new_value;
2058 char *old_value;
2060
2062 Z_PARAM_PATH_STR(new_value)
2064
2065 old_value = zend_ini_string("include_path", sizeof("include_path") - 1, 0);
2066 /* copy to return here, because alter might free it! */
2067 if (old_value) {
2068 RETVAL_STRING(old_value);
2069 } else {
2071 }
2072
2073 key = ZSTR_INIT_LITERAL("include_path", 0);
2076 zval_ptr_dtor_str(return_value);
2078 }
2080}
2081/* }}} */
2082
2083/* {{{ Get the current include_path configuration option */
2085{
2086 char *str;
2087
2089
2090 str = zend_ini_string("include_path", sizeof("include_path") - 1, 0);
2091
2092 if (str == NULL) {
2094 }
2095
2096 RETURN_STRING(str);
2097}
2098/* }}} */
2099
2100/* {{{ Prints out or returns information about the specified variable */
2102{
2103 zval *var;
2104 bool do_return = 0;
2105
2107 Z_PARAM_ZVAL(var)
2109 Z_PARAM_BOOL(do_return)
2111
2112 if (do_return) {
2114 } else {
2115 zend_print_zval_r(var, 0);
2117 }
2118}
2119/* }}} */
2120
2121/* {{{ Returns true if client disconnected */
2128/* }}} */
2129
2130/* {{{ Returns the connection status bitfield */
2137/* }}} */
2138
2139/* {{{ Set whether we want to ignore a user abort event or not */
2141{
2142 bool arg = 0;
2143 bool arg_is_null = 1;
2144 int old_setting;
2145
2148 Z_PARAM_BOOL_OR_NULL(arg, arg_is_null)
2150
2151 old_setting = (unsigned short)PG(ignore_user_abort);
2152
2153 if (!arg_is_null) {
2154 zend_string *key = ZSTR_INIT_LITERAL("ignore_user_abort", 0);
2157 }
2158
2159 RETURN_LONG(old_setting);
2160}
2161/* }}} */
2162
2163#ifdef HAVE_GETSERVBYNAME
2164/* {{{ Returns port associated with service. Protocol must be "tcp" or "udp" */
2166{
2168 char *proto;
2169 size_t proto_len;
2170 struct servent *serv;
2171
2174 Z_PARAM_STRING(proto, proto_len)
2176
2177
2178/* empty string behaves like NULL on windows implementation of
2179 getservbyname. Let be portable instead. */
2180#ifdef PHP_WIN32
2181 if (proto_len == 0) {
2183 }
2184#endif
2185
2186 serv = getservbyname(ZSTR_VAL(name), proto);
2187
2188#ifdef _AIX
2189 /*
2190 On AIX, imap is only known as imap2 in /etc/services, while on Linux imap is an alias for imap2.
2191 If a request for imap gives no result, we try again with imap2.
2192 */
2193 if (serv == NULL && zend_string_equals_literal(name, "imap")) {
2194 serv = getservbyname("imap2", proto);
2195 }
2196#endif
2197 if (serv == NULL) {
2199 }
2200
2201 RETURN_LONG(ntohs(serv->s_port));
2202}
2203/* }}} */
2204#endif
2205
2206#ifdef HAVE_GETSERVBYPORT
2207/* {{{ Returns service name associated with port. Protocol must be "tcp" or "udp" */
2209{
2210 char *proto;
2211 size_t proto_len;
2212 zend_long port;
2213 struct servent *serv;
2214
2216 Z_PARAM_LONG(port)
2217 Z_PARAM_STRING(proto, proto_len)
2219
2220 serv = getservbyport(htons((unsigned short) port), proto);
2221
2222 if (serv == NULL) {
2224 }
2225
2226 /* MSAN false positive, getservbyport() is not properly intercepted. */
2227#if __has_feature(memory_sanitizer)
2228 __msan_unpoison_string(serv->s_name);
2229#endif
2230 RETURN_STRING(serv->s_name);
2231}
2232/* }}} */
2233#endif
2234
2235#ifdef HAVE_GETPROTOBYNAME
2236/* {{{ Returns protocol number associated with name as per /etc/protocols */
2238{
2239 char *name;
2240 size_t name_len;
2241 struct protoent *ent;
2242
2244 Z_PARAM_STRING(name, name_len)
2246
2247 ent = getprotobyname(name);
2248
2249 if (ent == NULL) {
2251 }
2252
2253 RETURN_LONG(ent->p_proto);
2254}
2255/* }}} */
2256#endif
2257
2258#ifdef HAVE_GETPROTOBYNUMBER
2259/* {{{ Returns protocol name associated with protocol number proto */
2261{
2262 zend_long proto;
2263 struct protoent *ent;
2264
2266 Z_PARAM_LONG(proto)
2268
2269 ent = getprotobynumber((int)proto);
2270
2271 if (ent == NULL) {
2273 }
2274
2275 RETURN_STRING(ent->p_name);
2276}
2277/* }}} */
2278#endif
2279
2280/* {{{ Registers a tick callback function */
2282{
2284 zval *params = NULL;
2285 uint32_t param_count = 0;
2286
2287 if (zend_parse_parameters(ZEND_NUM_ARGS(), "f*", &tick_fe.fci, &tick_fe.fci_cache, &params, &param_count) == FAILURE) {
2288 RETURN_THROWS();
2289 }
2290
2291 tick_fe.calling = false;
2292 fci_addref(&tick_fe.fci, &tick_fe.fci_cache);
2293 zend_fcall_info_argp(&tick_fe.fci, param_count, params);
2294
2295 if (!BG(user_tick_functions)) {
2296 BG(user_tick_functions) = (zend_llist *) emalloc(sizeof(zend_llist));
2297 zend_llist_init(BG(user_tick_functions),
2299 (llist_dtor_func_t) user_tick_function_dtor, 0);
2300 php_add_tick_function(run_user_tick_functions, NULL);
2301 }
2302
2303 zend_llist_add_element(BG(user_tick_functions), &tick_fe);
2304
2306}
2307/* }}} */
2308
2309/* {{{ Unregisters a tick callback function */
2311{
2313
2315 Z_PARAM_FUNC(tick_fe.fci, tick_fe.fci_cache)
2317
2318 if (!BG(user_tick_functions)) {
2319 return;
2320 }
2321
2322 zend_llist_del_element(BG(user_tick_functions), &tick_fe, (int (*)(void *, void *)) user_tick_function_compare);
2323}
2324/* }}} */
2325
2326/* {{{ Check if file was created by rfc1867 upload */
2328{
2329 char *path;
2330 size_t path_len;
2331
2333 Z_PARAM_PATH(path, path_len)
2335
2336 if (!SG(rfc1867_uploaded_files)) {
2338 }
2339
2340 if (zend_hash_str_exists(SG(rfc1867_uploaded_files), path, path_len)) {
2342 } else {
2344 }
2345}
2346/* }}} */
2347
2348/* {{{ Move a file if and only if it was created by an upload */
2350{
2351 char *path, *new_path;
2352 size_t path_len, new_path_len;
2353 bool successful = 0;
2354
2355#ifndef PHP_WIN32
2356 int oldmask; int ret;
2357#endif
2358
2360 Z_PARAM_STRING(path, path_len)
2361 Z_PARAM_PATH(new_path, new_path_len)
2363
2364 if (!SG(rfc1867_uploaded_files)) {
2366 }
2367
2368 if (!zend_hash_str_exists(SG(rfc1867_uploaded_files), path, path_len)) {
2370 }
2371
2372 if (php_check_open_basedir(new_path)) {
2374 }
2375
2376 if (VCWD_RENAME(path, new_path) == 0) {
2377 successful = 1;
2378#ifndef PHP_WIN32
2379 oldmask = umask(077);
2380 umask(oldmask);
2381
2382 ret = VCWD_CHMOD(new_path, 0666 & ~oldmask);
2383
2384 if (ret == -1) {
2385 php_error_docref(NULL, E_WARNING, "%s", strerror(errno));
2386 }
2387#endif
2388 } else if (php_copy_file_ex(path, new_path, STREAM_DISABLE_OPEN_BASEDIR) == SUCCESS) {
2389 VCWD_UNLINK(path);
2390 successful = 1;
2391 }
2392
2393 if (successful) {
2394 zend_hash_str_del(SG(rfc1867_uploaded_files), path, path_len);
2395 } else {
2396 php_error_docref(NULL, E_WARNING, "Unable to move \"%s\" to \"%s\"", path, new_path);
2397 }
2398
2399 RETURN_BOOL(successful);
2400}
2401/* }}} */
2402
2403/* {{{ php_simple_ini_parser_cb */
2404static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_type, zval *arr)
2405{
2406 switch (callback_type) {
2407
2409 if (!arg2) {
2410 /* bare string - nothing to do */
2411 break;
2412 }
2414 zend_symtable_update(Z_ARRVAL_P(arr), Z_STR_P(arg1), arg2);
2415 break;
2416
2418 {
2420
2421 if (!arg2) {
2422 /* bare string - nothing to do */
2423 break;
2424 }
2425
2426 /* entry in the form x[a]=b where x might need to be an array index */
2427 if (!(Z_STRLEN_P(arg1) > 1 && Z_STRVAL_P(arg1)[0] == '0') && is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) == IS_LONG) {
2429 if ((find_hash = zend_hash_index_find(Z_ARRVAL_P(arr), key)) == NULL) {
2430 array_init(&hash);
2432 }
2433 } else {
2434 if ((find_hash = zend_hash_find(Z_ARRVAL_P(arr), Z_STR_P(arg1))) == NULL) {
2435 array_init(&hash);
2437 }
2438 }
2439
2440 if (Z_TYPE_P(find_hash) != IS_ARRAY) {
2441 zval_ptr_dtor_nogc(find_hash);
2443 }
2444
2445 if (!arg3 || (Z_TYPE_P(arg3) == IS_STRING && Z_STRLEN_P(arg3) == 0)) {
2447 add_next_index_zval(find_hash, arg2);
2448 } else {
2450 }
2451 }
2452 break;
2453
2455 break;
2456 }
2457}
2458/* }}} */
2459
2460/* {{{ php_ini_parser_cb_with_sections */
2461static void php_ini_parser_cb_with_sections(zval *arg1, zval *arg2, zval *arg3, int callback_type, zval *arr)
2462{
2463 if (callback_type == ZEND_INI_PARSER_SECTION) {
2464 array_init(&BG(active_ini_file_section));
2465 zend_symtable_update(Z_ARRVAL_P(arr), Z_STR_P(arg1), &BG(active_ini_file_section));
2466 } else if (arg2) {
2467 zval *active_arr;
2468
2469 if (Z_TYPE(BG(active_ini_file_section)) != IS_UNDEF) {
2470 active_arr = &BG(active_ini_file_section);
2471 } else {
2472 active_arr = arr;
2473 }
2474
2475 php_simple_ini_parser_cb(arg1, arg2, arg3, callback_type, active_arr);
2476 }
2477}
2478/* }}} */
2479
2480/* {{{ Parse configuration file */
2482{
2483 zend_string *filename = NULL;
2484 bool process_sections = 0;
2485 zend_long scanner_mode = ZEND_INI_SCANNER_NORMAL;
2487 zend_ini_parser_cb_t ini_parser_cb;
2488
2490 Z_PARAM_PATH_STR(filename)
2492 Z_PARAM_BOOL(process_sections)
2493 Z_PARAM_LONG(scanner_mode)
2495
2496 if (ZSTR_LEN(filename) == 0) {
2498 RETURN_THROWS();
2499 }
2500
2501 /* Set callback function */
2502 if (process_sections) {
2503 ZVAL_UNDEF(&BG(active_ini_file_section));
2504 ini_parser_cb = (zend_ini_parser_cb_t) php_ini_parser_cb_with_sections;
2505 } else {
2506 ini_parser_cb = (zend_ini_parser_cb_t) php_simple_ini_parser_cb;
2507 }
2508
2509 /* Setup filehandle */
2510 zend_stream_init_filename_ex(&fh, filename);
2511
2513 if (zend_parse_ini_file(&fh, 0, (int)scanner_mode, ini_parser_cb, return_value) == FAILURE) {
2516 }
2518}
2519/* }}} */
2520
2521/* {{{ Parse configuration string */
2523{
2524 char *string = NULL, *str = NULL;
2525 size_t str_len = 0;
2526 bool process_sections = 0;
2527 zend_long scanner_mode = ZEND_INI_SCANNER_NORMAL;
2528 zend_ini_parser_cb_t ini_parser_cb;
2529
2531 Z_PARAM_STRING(str, str_len)
2533 Z_PARAM_BOOL(process_sections)
2534 Z_PARAM_LONG(scanner_mode)
2536
2537 if (INT_MAX - str_len < ZEND_MMAP_AHEAD) {
2539 }
2540
2541 /* Set callback function */
2542 if (process_sections) {
2543 ZVAL_UNDEF(&BG(active_ini_file_section));
2544 ini_parser_cb = (zend_ini_parser_cb_t) php_ini_parser_cb_with_sections;
2545 } else {
2546 ini_parser_cb = (zend_ini_parser_cb_t) php_simple_ini_parser_cb;
2547 }
2548
2549 /* Setup string */
2550 string = (char *) emalloc(str_len + ZEND_MMAP_AHEAD);
2551 memcpy(string, str, str_len);
2552 memset(string + str_len, 0, ZEND_MMAP_AHEAD);
2553
2555 if (zend_parse_ini_string(string, 0, (int)scanner_mode, ini_parser_cb, return_value) == FAILURE) {
2558 }
2559 efree(string);
2560}
2561/* }}} */
2562
2563#if ZEND_DEBUG
2564/* This function returns an array of ALL valid ini options with values and
2565 * is not the same as ini_get_all() which returns only registered ini options. Only useful for devs to debug php.ini scanner/parser! */
2567{
2569
2571
2573 add_config_entries(hash, return_value);
2574}
2575/* }}} */
2576#endif
2577
2578#ifdef HAVE_GETLOADAVG
2579/* {{{ */
2581{
2582 double load[3];
2583
2585
2586 if (getloadavg(load, 3) == -1) {
2588 } else {
2590 add_index_double(return_value, 0, load[0]);
2591 add_index_double(return_value, 1, load[1]);
2592 add_index_double(return_value, 2, load[2]);
2593 }
2594}
2595/* }}} */
2596#endif
SAPI_API sapi_module_struct sapi_module
Definition SAPI.c:65
SAPI_API int sapi_flush(void)
Definition SAPI.c:1001
SAPI_API char * sapi_getenv(const char *name, size_t name_len)
Definition SAPI.c:1023
#define SG(v)
Definition SAPI.h:160
size_t len
Definition apprentice.c:174
PHPAPI zend_class_entry * assertion_error_ce
Definition assert.c:37
#define _CHECK_PATH(var, var_len, ini)
#define BASIC_MINIT_SUBMODULE(module)
PHPAPI bool remove_user_shutdown_function(const char *function_name, size_t function_len)
PHPAPI bool append_user_shutdown_function(php_shutdown_function_entry *shutdown_function_entry)
struct _user_tick_function_entry user_tick_function_entry
PHPAPI void php_call_shutdown_functions(void)
#define BASIC_RSHUTDOWN_SUBMODULE(module)
zend_module_entry basic_functions_module
struct yy_buffer_state * YY_BUFFER_STATE
PHPAPI php_basic_globals basic_globals
#define BASIC_RINIT_SUBMODULE(module)
ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highlighter_ini)
PHPAPI zend_string * php_getenv(const char *str, size_t str_len)
register_basic_functions_symbols(module_number)
PHPAPI double php_get_nan(void)
#define BASIC_MINFO_SUBMODULE(module)
PHPAPI int _php_error_log(int opt_err, const char *message, const char *opt, const char *headers)
PHPAPI int _php_error_log_ex(int opt_err, const char *message, size_t message_len, const char *opt, const char *headers)
PHPAPI double php_get_inf(void)
PHP_RINIT filestat(INIT_FUNC_ARGS_PASSTHRU)
PHPAPI bool register_user_shutdown_function(const char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry)
php_register_incomplete_class_handlers()
#define BASIC_MSHUTDOWN_SUBMODULE(module)
PHPAPI void php_free_shutdown_functions(void)
php_info_print_table_end()
Definition info.c:1074
php_unregister_url_stream_wrapper("php")
#define ZVAL_SET_INI_STR(zv, val)
php_register_url_stream_wrapper("php", &php_stream_php_wrapper)
php_ce_incomplete_class
rounding_mode_ce
struct _php_shutdown_function_entry php_shutdown_function_entry
struct _php_basic_globals php_basic_globals
#define BG(v)
proc_open(array|string $command, array $descriptor_spec, &$pipes, ?string $cwd=null, ?array $env_vars=null, ?array $options=null)
ini_set(string $option, string|int|float|bool|null $value)
inet_pton(string $ip)
getprotobynumber(int $protocol)
call_user_func_array(callable $callback, array $args)
register_shutdown_function(callable $callback, mixed ... $args)
umask(?int $mask=null)
call_user_func(callable $callback, mixed ... $args)
ignore_user_abort(?bool $enable=null)
usleep(int $microseconds)
getenv(?string $name=null, bool $local_only=false)
pack(string $format, mixed ... $values)
is_uploaded_file(string $filename)
parse_ini_string(string $ini_string, bool $process_sections=false, int $scanner_mode=INI_SCANNER_NORMAL)
ini_get(string $option)
putenv(string $assignment)
file(string $filename, int $flags=0, $context=null)
setlocale(int $category, $locales,... $rest)
ip2long(string $ip)
crypt(#[\SensitiveParameter] string $string, string $salt)
register_tick_function(callable $callback, mixed ... $args)
mail(string $to, string $subject, string $message, array|string $additional_headers=[], string $additional_params="")
forward_static_call(callable $callback, mixed ... $args)
getservbyname(string $service, string $protocol)
forward_static_call_array(callable $callback, array $args)
syslog(int $priority, string $message)
time_nanosleep(int $seconds, int $nanoseconds)
getopt(string $short_options, array $long_options=[], &$rest_index=null)
constant(string $name)
long2ip(int $ip)
gettimeofday(bool $as_float=false)
dir(string $directory, $context=null)
getprotobyname(string $protocol)
set_include_path(string $include_path)
ini_parse_quantity(string $shorthand)
error_log(string $message, int $message_type=0, ?string $destination=null, ?string $additional_headers=null)
getservbyport(int $port, string $protocol)
php_strip_whitespace(string $filename)
move_uploaded_file(string $from, string $to)
count(Countable|array $value, int $mode=COUNT_NORMAL)
time_sleep_until(float $timestamp)
print_r(mixed $value, bool $return=false)
assert(mixed $assertion, Throwable|string|null $description=null)
unregister_tick_function(callable $callback)
parse_ini_file(string $filename, bool $process_sections=false, int $scanner_mode=INI_SCANNER_NORMAL)
ini_restore(string $option)
sleep(int $seconds)
get_cfg_var(string $option)
strchr(string $haystack, string $needle, bool $before_needle=false)
ini_get_all(?string $extension=null, bool $details=true)
#define php_win32_cp_any_to_w(in)
Definition codepage.h:115
#define PHP_WIN32_CP_IGNORE_LEN_P
Definition codepage.h:31
#define php_win32_cp_w_to_any(in)
Definition codepage.h:124
dl(string $extension_filename)
Definition dl.stub.php:3
DNS_STATUS status
Definition dns_win32.c:49
#define DWORD
Definition exif.c:1762
zval * zv
Definition ffi.c:3975
new_type size
Definition ffi.c:4365
zend_string * res
Definition ffi.c:4692
void * ptr
Definition ffi.c:3814
memcpy(ptr1, ptr2, size)
zval * arg
Definition ffi.c:3975
memset(ptr, 0, type->size)
zval * val
Definition ffi.c:4262
PHPAPI zend_result php_copy_file_ex(const char *src, const char *dest, int src_flags)
Definition file.c:1490
PHPAPI int php_check_open_basedir(const char *path)
void unsetenv(const char *name)
Definition fpm_env.c:87
PHPAPI const php_stream_wrapper php_stream_ftp_wrapper
size_t filename_len
#define NULL
Definition gdcache.h:45
int find_hash(uint32_t *mask, uint32_t count)
PHPAPI int php_optidx
Definition getopt.c:53
PHPAPI int php_getopt(int argc, char *const *argv, const opt_struct opts[], char **optarg, int *optind, int show_err, int arg_start)
Definition getopt.c:55
void php_win32_core_globals_ctor(void *vg)
Definition globals.c:28
php_win32_core_globals the_php_win32_core_globals
Definition globals.c:25
void php_win32_core_globals_dtor(void *vg)
Definition globals.c:38
hash(string $algo, string $data, bool $binary=false, array $options=[])
Definition hash.stub.php:12
#define SUCCESS
Definition hash_sha3.c:261
foreach($dp as $el) foreach( $dp as $el) if( $pass2< 2) echo ""
PHPAPI const php_stream_wrapper php_stream_http_wrapper
PHPAPI bool php_mail(const char *to, const char *subject, const char *message, const char *headers, const char *extra_cmd)
Definition mail.c:439
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
Definition main.c:1173
PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int syslog_type_int)
Definition main.c:858
PHPAPI char * php_get_current_user(void)
Definition main.c:1477
inet_ntop(AF_INET, addr, addr_str, sizeof(addr_str))
PHPAPI zend_result php_output_discard(void)
Definition output.c:330
PHPAPI zend_result php_output_end(void)
Definition output.c:311
PHPAPI zend_result php_output_start_default(void)
Definition output.c:398
PHPAPI zend_result php_output_get_contents(zval *p)
Definition output.c:359
php_info_print_table_start()
Definition info.c:1064
#define PHP_FUNCTION
Definition php.h:364
#define PHP_MSHUTDOWN_FUNCTION
Definition php.h:401
#define PHP_MINFO
Definition php.h:396
#define PHP_MINIT_FUNCTION
Definition php.h:400
#define php_sleep
Definition php.h:279
#define PHP_RINIT
Definition php.h:394
#define PHP_CONNECTION_ABORTED
Definition php.h:427
#define PHP_MSHUTDOWN
Definition php.h:393
#define PHP_MINFO_FUNCTION
Definition php.h:404
#define INT_MAX
Definition php.h:237
char ** environ
#define PHP_RSHUTDOWN
Definition php.h:395
#define PHP_RINIT_FUNCTION
Definition php.h:402
#define PHP_RSHUTDOWN_FUNCTION
Definition php.h:403
#define PHP_MINIT
Definition php.h:392
#define PHPAPI
Definition php.h:71
unsigned const char * pos
Definition php_ffi.h:52
PHPAPI const php_stream_wrapper php_stream_php_wrapper
#define PHP_GETOPT_INVALID_ARG
Definition php_getopt.h:37
struct _opt_struct opt_struct
#define TRACK_VARS_SERVER
Definition php_globals.h:43
#define PG(v)
Definition php_globals.h:31
PHPAPI HashTable * php_ini_get_configuration_hash(void)
Definition php_ini.c:940
PHPAPI zval * cfg_get_entry_ex(zend_string *name)
Definition php_ini.c:885
#define PHP_INI_STAGE_RUNTIME
Definition php_ini.h:75
#define PHP_INI_USER
Definition php_ini.h:41
PHP_JSON_API size_t int options
Definition php_json.h:102
php_json_error_code error_code
Definition php_json.h:92
PHPAPI const php_stream_wrapper php_stream_rfc2397_wrapper
Definition memory.c:763
unsigned char key[REFLECTION_KEY_LEN]
#define PHP_STANDARD_VERSION
PHPAPI const php_stream_wrapper php_glob_stream_wrapper
PHPAPI php_stream_wrapper php_plain_files_wrapper
struct _php_stream php_stream
Definition php_streams.h:96
#define REPORT_ERRORS
#define php_stream_close(stream)
#define STREAM_DISABLE_OPEN_BASEDIR
PHPAPI zend_result php_register_url_stream_wrapper(const char *protocol, const php_stream_wrapper *wrapper)
Definition streams.c:1911
#define php_stream_open_wrapper(path, mode, options, opened)
#define php_stream_write(stream, buf, count)
PHPAPI void php_add_tick_function(void(*func)(int, void *), void *arg)
Definition php_ticks.c:49
PHPAPI void(* php_load_environment_variables)(zval *array_ptr)
struct _php_win32_core_globals php_win32_core_globals
char * exec
Definition phpdbg.h:263
#define zend_hash_str_add(...)
Definition phpdbg.h:77
p
Definition session.c:1105
const AF_INET
const AF_INET6
#define FG(v)
Definition file.h:117
char * opt_name
Definition php_getopt.h:27
char opt_char
Definition php_getopt.h:25
HashTable url_adapt_session_hosts_ht
url_adapt_state_ex_t url_adapt_output_ex
HashTable url_adapt_output_hosts_ht
url_adapt_state_ex_t url_adapt_session_ex
zend_fcall_info_cache fci_cache
zend_fcall_info fci
zend_fcall_info_cache fci_cache
bool calling
zend_fcall_info fci
zend_class_entry * calling_scope
Definition zend_API.h:61
zend_class_entry * called_scope
Definition zend_API.h:62
zend_object * object
Definition zend_API.h:63
HashTable * named_params
Definition zend_API.h:56
uint32_t param_count
Definition zend_API.h:51
zend_string * value
Definition zend_ini.h:53
uint8_t modifiable
Definition zend_ini.h:59
zend_string * orig_value
Definition zend_ini.h:54
int module_number
Definition zend_ini.h:57
zend_string * name
Definition zend_ini.h:48
Definition file.h:177
long tv_nsec
Definition time.h:35
time_t tv_sec
Definition time.h:34
#define LOG_NOTICE
Definition syslog.h:27
PHPAPI int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
Definition time.c:80
#define errno
ZEND_API char * zend_make_compiled_string_description(const char *name)
Definition zend.c:1980
ZEND_API zend_string * zend_print_zval_r_to_str(zval *expr, int indent)
Definition zend.c:616
ZEND_API void zend_print_zval_r(zval *expr, int indent)
Definition zend.c:625
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format,...)
Definition zend.c:1772
ZEND_API ZEND_COLD void zend_value_error(const char *format,...)
Definition zend.c:1849
ZEND_API ZEND_COLD void zend_error(int type, const char *format,...)
Definition zend.c:1666
#define zend_catch
Definition zend.h:277
#define zend_try
Definition zend.h:270
#define zend_end_try()
Definition zend.h:280
ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value)
Definition zend_API.c:2231
ZEND_API HashTable module_registry
Definition zend_API.c:41
ZEND_API void add_index_double(zval *arg, zend_ulong index, double d)
Definition zend_API.c:2069
ZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, bool free_mem)
Definition zend_API.c:4328
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
Definition zend_API.c:1300
ZEND_API void add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval *value)
Definition zend_API.c:2027
ZEND_API ZEND_COLD void zend_argument_must_not_be_empty_error(uint32_t arg_num)
Definition zend_API.c:443
ZEND_API void add_assoc_long_ex(zval *arg, const char *key, size_t key_len, zend_long n)
Definition zend_API.c:1928
ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format,...)
Definition zend_API.c:433
ZEND_API void zend_fcall_info_argp(zend_fcall_info *fci, uint32_t argc, zval *argv)
Definition zend_API.c:4403
ZEND_API ZEND_COLD void zend_argument_type_error(uint32_t arg_num, const char *format,...)
Definition zend_API.c:423
#define Z_PARAM_FUNC(dest_fci, dest_fcc)
Definition zend_API.h:1824
#define Z_PARAM_PATH_STR(dest)
Definition zend_API.h:2041
ZEND_API const zend_fcall_info empty_fcall_info
ZEND_API const zend_fcall_info_cache empty_fcall_info_cache
#define ZEND_NUM_ARGS()
Definition zend_API.h:530
struct _zend_fcall_info_cache zend_fcall_info_cache
#define Z_PARAM_PATH_OR_NULL(dest, dest_len)
Definition zend_API.h:2029
#define RETURN_STRING(s)
Definition zend_API.h:1043
#define RETURN_STRINGL(s, l)
Definition zend_API.h:1044
#define ZEND_PARSE_PARAMETERS_END()
Definition zend_API.h:1641
#define RETURN_FALSE
Definition zend_API.h:1058
#define RETVAL_STRING(s)
Definition zend_API.h:1017
#define ZEND_PARSE_PARAMETERS_NONE()
Definition zend_API.h:1623
#define ZVAL_STRING(z, s)
Definition zend_API.h:956
#define Z_PARAM_OPTIONAL
Definition zend_API.h:1667
#define Z_PARAM_STRING(dest, dest_len)
Definition zend_API.h:2071
#define Z_PARAM_STR(dest)
Definition zend_API.h:2086
#define Z_PARAM_STRING_OR_NULL(dest, dest_len)
Definition zend_API.h:2074
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
Definition zend_API.h:1620
#define Z_PARAM_BOOL_OR_NULL(dest, is_null)
Definition zend_API.h:1729
#define ZEND_TRY_ASSIGN_REF_LONG(zv, lval)
Definition zend_API.h:1205
#define Z_PARAM_LONG(dest)
Definition zend_API.h:1896
#define Z_PARAM_VARIADIC(spec, dest, dest_num)
Definition zend_API.h:2124
#define RETURN_LONG(l)
Definition zend_API.h:1037
#define RETURN_BOOL(b)
Definition zend_API.h:1035
struct _zend_fcall_info zend_fcall_info
#define RETURN_THROWS()
Definition zend_API.h:1060
#define Z_PARAM_ARRAY_HT(dest)
Definition zend_API.h:1852
#define Z_PARAM_DOUBLE(dest)
Definition zend_API.h:1803
#define RETURN_STR(s)
Definition zend_API.h:1039
#define RETVAL_LONG(l)
Definition zend_API.h:1011
#define Z_PARAM_BOOL(dest)
Definition zend_API.h:1726
#define RETURN_EMPTY_STRING()
Definition zend_API.h:1047
#define Z_PARAM_PATH(dest, dest_len)
Definition zend_API.h:2026
#define Z_PARAM_ARRAY(dest)
Definition zend_API.h:1682
#define Z_PARAM_ZVAL(dest)
Definition zend_API.h:2100
#define RETVAL_FALSE
Definition zend_API.h:1032
ZEND_API zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache)
#define RETURN_TRUE
Definition zend_API.h:1059
#define array_init(arg)
Definition zend_API.h:537
#define Z_PARAM_VARIADIC_WITH_NAMED(dest, dest_num, dest_named)
Definition zend_API.h:2127
ZEND_API char *ZEND_FASTCALL zend_strndup(const char *s, size_t length)
#define safe_erealloc(ptr, nmemb, size, offset)
Definition zend_alloc.h:161
#define efree(ptr)
Definition zend_alloc.h:155
#define estrdup(s)
Definition zend_alloc.h:164
#define FREE_HASHTABLE(ht)
Definition zend_alloc.h:234
#define erealloc(ptr, size)
Definition zend_alloc.h:159
#define safe_emalloc(nmemb, size, offset)
Definition zend_alloc.h:154
#define ALLOC_HASHTABLE(ht)
Definition zend_alloc.h:231
#define emalloc(size)
Definition zend_alloc.h:151
struct _zval_struct zval
error_reporting(?int $error_level=null)
strlen(string $string)
strncmp(string $string1, string $string2, int $length)
zend_string_release_ex(func->internal_function.function_name, 0)
execute_data func
zval * args
ZEND_API bool zend_is_auto_global(zend_string *name)
#define EX(element)
#define ZEND_FETCH_CLASS_EXCEPTION
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle)
ZEND_API zend_result open_file_for_scanning(zend_file_handle *file_handle)
#define ZEND_API
ZEND_API zval * zend_get_constant_ex(zend_string *cname, zend_class_entry *scope, uint32_t flags)
#define E_ERROR
Definition zend_errors.h:23
#define E_WARNING
Definition zend_errors.h:24
ZEND_API zend_class_entry * zend_ce_error
ZEND_API zend_class_entry * zend_get_called_scope(zend_execute_data *ex)
ZEND_API zend_class_entry * zend_get_executed_scope(void)
ZEND_API zend_result ZEND_FASTCALL zval_update_constant_ex(zval *pp, zend_class_entry *scope)
struct _zend_ini_entry zend_ini_entry
#define EG(v)
ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht)
Definition zend_hash.c:1727
ZEND_API void ZEND_FASTCALL zend_hash_apply(HashTable *ht, apply_func_t apply_func)
Definition zend_hash.c:2059
ZEND_API zval *ZEND_FASTCALL zend_hash_str_find(const HashTable *ht, const char *str, size_t len)
Definition zend_hash.c:2689
ZEND_API zval *ZEND_FASTCALL zend_hash_next_index_insert(HashTable *ht, zval *pData)
Definition zend_hash.c:1224
ZEND_API zval *ZEND_FASTCALL zend_hash_index_add_new(HashTable *ht, zend_ulong h, zval *pData)
Definition zend_hash.c:1214
ZEND_API zval *ZEND_FASTCALL zend_hash_add_new(HashTable *ht, zend_string *key, zval *pData)
Definition zend_hash.c:1007
ZEND_API zval *ZEND_FASTCALL zend_hash_index_update(HashTable *ht, zend_ulong h, zval *pData)
Definition zend_hash.c:1219
ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht)
Definition zend_hash.c:1808
ZEND_API zval *ZEND_FASTCALL zend_hash_update(HashTable *ht, zend_string *key, zval *pData)
Definition zend_hash.c:997
ZEND_API zend_result ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key)
Definition zend_hash.c:1534
ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *str, size_t len)
Definition zend_hash.c:1661
ZEND_API zval *ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key)
Definition zend_hash.c:2668
ZEND_API zval *ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h)
Definition zend_hash.c:2701
#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent)
Definition zend_hash.h:108
#define ZEND_HASH_FOREACH_KEY_VAL(ht, _h, _key, _val)
Definition zend_hash.h:1181
#define ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(ht, _key, _ptr)
Definition zend_hash.h:1433
#define ZEND_HASH_FOREACH_END()
Definition zend_hash.h:1086
#define ZEND_HASH_FOREACH_VAL(ht, _val)
Definition zend_hash.h:1102
ZEND_API void zend_strip(void)
ZEND_API zend_result highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini)
zend_syntax_highlighter_ini syntax_highlighter_ini
struct _zend_syntax_highlighter_ini zend_syntax_highlighter_ini
ZEND_API void highlight_string(zend_string *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name)
ZEND_API zend_result zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, bool force_change)
Definition zend_ini.c:356
ZEND_API zend_result zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage)
Definition zend_ini.c:332
ZEND_API zend_string * zend_ini_get_value(zend_string *name)
Definition zend_ini.c:560
ZEND_API zend_result zend_restore_ini_entry(zend_string *name, int stage)
Definition zend_ini.c:408
ZEND_API char * zend_ini_string(const char *name, size_t name_length, int orig)
Definition zend_ini.c:505
ZEND_API zend_long zend_ini_parse_quantity(zend_string *value, zend_string **errstr)
Definition zend_ini.c:857
ZEND_API void zend_ini_sort_entries(void)
Definition zend_ini.c:195
ZEND_API zend_result zend_parse_ini_file(zend_file_handle *fh, bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg)
#define ZEND_INI_PARSER_ENTRY
Definition zend_ini.h:244
void(* zend_ini_parser_cb_t)(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg)
Definition zend_ini.h:237
#define ZEND_INI_PARSER_POP_ENTRY
Definition zend_ini.h:246
ZEND_API zend_result zend_parse_ini_string(const char *str, bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg)
#define ZEND_INI_PARSER_SECTION
Definition zend_ini.h:245
#define INI_STR(name)
Definition zend_ini.h:195
struct _zend_file_handle zend_file_handle
#define ZEND_INI_SCANNER_NORMAL
ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state)
struct _zend_lex_state zend_lex_state
ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state)
ZEND_API void zend_llist_destroy(zend_llist *l)
Definition zend_llist.c:102
ZEND_API void zend_llist_del_element(zend_llist *l, void *element, int(*compare)(void *element1, void *element2))
Definition zend_llist.c:88
ZEND_API void zend_llist_add_element(zend_llist *l, const void *element)
Definition zend_llist.c:34
ZEND_API void zend_llist_init(zend_llist *l, size_t size, llist_dtor_func_t dtor, unsigned char persistent)
Definition zend_llist.c:24
ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func)
Definition zend_llist.c:179
void(* llist_dtor_func_t)(void *)
Definition zend_llist.h:31
void(* llist_apply_func_t)(void *)
Definition zend_llist.h:35
struct _zend_llist zend_llist
int32_t zend_long
Definition zend_long.h:42
uint32_t zend_ulong
Definition zend_long.h:43
#define ZEND_STRTOUL(s0, s1, base)
Definition zend_long.h:86
struct _zend_string zend_string
#define SHUTDOWN_FUNC_ARGS_PASSTHRU
#define INIT_FUNC_ARGS_PASSTHRU
#define ZEND_MOD_END
#define ZEND_MOD_OPTIONAL(name)
struct _zend_module_dep zend_module_dep
struct _zend_module_entry zend_module_entry
#define STANDARD_MODULE_PROPERTIES
#define STANDARD_MODULE_HEADER_EX
ZEND_API int ZEND_FASTCALL zend_compare_arrays(zval *a1, zval *a2)
ZEND_API void ZEND_FASTCALL convert_to_array(zval *op)
ZEND_API int ZEND_FASTCALL zend_binary_zval_strcmp(zval *s1, zval *s2)
ZEND_API void zend_reset_lc_ctype_locale(void)
ZEND_API void zend_update_current_locale(void)
ZEND_API int ZEND_FASTCALL zend_compare_objects(zval *o1, zval *o2)
#define ZEND_NAN
#define ZEND_ASSERT(c)
#define ZEND_INFINITY
#define UNEXPECTED(condition)
struct _zend_class_entry zend_class_entry
ZEND_API void zend_stream_init_filename_ex(zend_file_handle *handle, zend_string *filename)
Definition zend_stream.c:76
#define ZEND_MMAP_AHEAD
Definition zend_stream.h:37
#define ZSTR_VAL(zstr)
Definition zend_string.h:68
#define ZSTR_INIT_LITERAL(s, persistent)
#define ZSTR_KNOWN(idx)
#define zend_string_equals_literal(str, literal)
#define ZSTR_EMPTY_ALLOC()
#define ZSTR_LEN(zstr)
Definition zend_string.h:69
#define zend_string_equals_literal_ci(str, c)
#define Z_TYPE_P(zval_p)
Definition zend_types.h:660
#define ZVAL_FALSE(z)
#define Z_TRY_ADDREF_P(pz)
#define ZVAL_UNDEF(z)
#define Z_STRVAL_P(zval_p)
Definition zend_types.h:975
#define IS_UNDEF
Definition zend_types.h:600
#define Z_ARRVAL_P(zval_p)
Definition zend_types.h:987
#define ZVAL_LONG(z, l)
#define IS_STRING
Definition zend_types.h:606
#define ZVAL_STR_COPY(z, s)
struct _zend_array HashTable
Definition zend_types.h:386
#define IS_ARRAY
Definition zend_types.h:607
#define ZVAL_COPY_OR_DUP(z, v)
#define Z_STR_P(zval_p)
Definition zend_types.h:972
#define Z_PTR_P(zval_p)
#define GC_ADDREF(p)
Definition zend_types.h:709
#define Z_STRLEN_P(zval_p)
Definition zend_types.h:978
@ FAILURE
Definition zend_types.h:61
#define Z_TRY_ADDREF(z)
#define IS_OBJECT
Definition zend_types.h:608
#define IS_LONG
Definition zend_types.h:604
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64
#define IS_CONSTANT_AST
Definition zend_types.h:611
#define Z_ISREF(zval)
Definition zend_types.h:953
#define Z_TYPE(zval)
Definition zend_types.h:659
#define Z_ARR_P(zval_p)
Definition zend_types.h:984
#define ZVAL_COPY_VALUE(z, v)
ZEND_API void zval_ptr_dtor(zval *zval_ptr)
#define VCWD_RENAME(oldname, newname)
#define VCWD_UNLINK(path)
#define VCWD_CHMOD(path, mode)
zval retval
zval * return_value
zval * arg1
call prev_execute_data
zval * arg2
zend_string * name
zval * arg3
bool result
execute_data
zval * ret
value
new_op_array scope