]> granicus.if.org Git - php/commitdiff
Added separate functions for setting include_path, for environments
authorStig Bakken <ssb@php.net>
Tue, 5 Nov 2002 06:05:48 +0000 (06:05 +0000)
committerStig Bakken <ssb@php.net>
Tue, 5 Nov 2002 06:05:48 +0000 (06:05 +0000)
where ini_set has been disabled.  New functions: get_include_path(),
set_include_path(), restore_include_path()

ext/standard/basic_functions.c
ext/standard/basic_functions.h

index 00adfc2a10bd1a992308a466ff90caa7e88d6263..02081675508f6c6c6295ed1ec9b9b4e2574f0ade 100644 (file)
@@ -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)
index 83cc764fd6b41313765b49a00028732eb1fa3795..c1e3feacf1345ea2e981dcb8a73951a519f9dcbc 100644 (file)
@@ -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);