From efeaa5917ccba60850a21322846c8f72bc619c71 Mon Sep 17 00:00:00 2001 From: Stig Bakken Date: Tue, 5 Nov 2002 06:05:48 +0000 Subject: [PATCH] Added separate functions for setting include_path, for environments where ini_set has been disabled. New functions: get_include_path(), set_include_path(), restore_include_path() --- ext/standard/basic_functions.c | 65 ++++++++++++++++++++++++++++++++++ ext/standard/basic_functions.h | 3 ++ 2 files changed, 68 insertions(+) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 00adfc2a10..0208167550 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -555,6 +555,9 @@ function_entry basic_functions[] = { PHP_FE(ini_set, NULL) PHP_FALIAS(ini_alter, ini_set, NULL) PHP_FE(ini_restore, NULL) + PHP_FE(get_include_path, NULL) + PHP_FE(set_include_path, NULL) + PHP_FE(restore_include_path, NULL) PHP_FE(setcookie, NULL) PHP_FE(header, NULL) @@ -2383,6 +2386,68 @@ PHP_FUNCTION(ini_restore) } /* }}} */ +/* {{{ proto string set_include_path(string varname, string newvalue) + Sets the include_path configuration option */ + +PHP_FUNCTION(set_include_path) +{ + pval **new_value; + char *old_value; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &new_value) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_string_ex(new_value); + old_value = zend_ini_string("include_path", sizeof("include_path"), 0); + /* copy to return here, because alter might free it! */ + if (old_value) { + RETVAL_STRING(old_value, 1); + } else { + RETVAL_FALSE; + } + if (zend_alter_ini_entry("include_path", sizeof("include_path"), + Z_STRVAL_PP(new_value), Z_STRLEN_PP(new_value), + PHP_INI_USER, PHP_INI_STAGE_RUNTIME) == FAILURE) { + zval_dtor(return_value); + RETURN_FALSE; + } +} + +/* }}} */ + +/* {{{ proto string get_include_path() + Get the current include_path configuration option */ + +PHP_FUNCTION(get_include_path) +{ + char *str; + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + str = zend_ini_string("include_path", sizeof("include_path"), 0); + if (str == NULL) { + RETURN_FALSE; + } + RETURN_STRING(str, 1); +} + +/* }}} */ + +/* {{{ proto string restore_include_path() + Restore the value of the include_path configuration option */ + +PHP_FUNCTION(restore_include_path) +{ + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + zend_restore_ini_entry("include_path", sizeof("include_path"), + PHP_INI_STAGE_RUNTIME); +} + +/* }}} */ + /* {{{ proto bool print_r(mixed var [, bool return]) Prints out or returns information about the specified variable */ PHP_FUNCTION(print_r) diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index 83cc764fd6..c1e3feacf1 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -78,6 +78,9 @@ PHP_FUNCTION(ini_get); PHP_FUNCTION(ini_get_all); PHP_FUNCTION(ini_set); PHP_FUNCTION(ini_restore); +PHP_FUNCTION(get_include_path); +PHP_FUNCTION(set_include_path); +PHP_FUNCTION(restore_include_path); PHP_FUNCTION(print_r); -- 2.50.1