cvs: php4 /ext/standard basic_functions.c /main configuration-parser.y php_ini.c php_ini.h

From: Date: Sun, 29 Oct 2000 22:42:02 +0000
Subject: cvs: php4 /ext/standard basic_functions.c /main configuration-parser.y php_ini.c php_ini.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-2348@lists.php.net to get a copy of this message
zeev Sun Oct 29 14:42:02 2000 EDT Modified files: /php4/ext/standard basic_functions.c /php4/main configuration-parser.y php_ini.c php_ini.h Log: Use the new INI parser for parse_ini_str() - parse_ini_str() is now thread-safe, and supported under Windows (Zeev) Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.271 php4/ext/standard/basic_functions.c:1.272 --- php4/ext/standard/basic_functions.c:1.271 Sun Oct 29 03:38:24 2000 +++ php4/ext/standard/basic_functions.c Sun Oct 29 14:42:01 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.271 2000/10/29 11:38:24 zeev Exp $ */ +/* $Id: basic_functions.c,v 1.272 2000/10/29 22:42:01 zeev Exp $ */ #include "php.h" #include "php_main.h" @@ -2314,6 +2314,49 @@ php_error(E_WARNING, "Unable to move '%s' to '%s'", Z_STRVAL_PP(path), Z_STRVAL_PP(new_path)); } RETURN_BOOL(successful); +} +/* }}} */ + + + +static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, int callback_type, zval *arr) +{ + zval *element; + + switch (callback_type) { + case ZEND_INI_PARSER_ENTRY: + ALLOC_ZVAL(element); + *element = *arg2; + zval_copy_ctor(element); + INIT_PZVAL(element); + zend_hash_update(arr->value.ht, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL); + break; + case ZEND_INI_PARSER_SECTION: + break; + } +} + + +/* {{{ proto void parse_ini_file(string filename) + Parse configuration file */ +PHP_FUNCTION(parse_ini_file) +{ + zval **filename; + zend_file_handle fh; + + if (ARG_COUNT(ht)!=1 || zend_get_parameters_ex(1, &filename)==FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_string_ex(filename); + fh.handle.fp = V_FOPEN((*filename)->value.str.val, "r"); + if (!fh.handle.fp) { + php_error(E_WARNING,"Cannot open '%s' for reading", (*filename)->value.str.val); + return; + } + fh.type = ZEND_HANDLE_FP; + array_init(return_value); + zend_parse_ini_file(&fh, (zend_ini_parser_cb_t) php_simple_ini_parser_cb, return_value); + } /* }}} */ Index: php4/main/configuration-parser.y diff -u php4/main/configuration-parser.y:1.55 php4/main/configuration-parser.y:1.56 --- php4/main/configuration-parser.y:1.55 Sun Oct 29 03:38:24 2000 +++ php4/main/configuration-parser.y Sun Oct 29 14:42:01 2000 @@ -19,7 +19,7 @@ -/* $Id: configuration-parser.y,v 1.55 2000/10/29 11:38:24 zeev Exp $ */ +/* $Id: configuration-parser.y,v 1.56 2000/10/29 22:42:01 zeev Exp $ */ #define DEBUG_CFG_PARSER 0 #include "php.h" @@ -272,36 +272,6 @@ return SUCCESS; } - -/* {{{ proto void parse_ini_file(string filename) - Parse configuration file */ -PHP_FUNCTION(parse_ini_file) -{ -#ifdef ZTS - php_error(E_WARNING, "parse_ini_file() is not supported in multithreaded PHP"); - RETURN_FALSE; -#else - zval **filename; - - if (ARG_COUNT(ht)!=1 || zend_get_parameters_ex(1, &filename)==FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_string_ex(filename); - cfgin = V_FOPEN((*filename)->value.str.val, "r"); - if (!cfgin) { - php_error(E_WARNING,"Cannot open '%s' for reading", (*filename)->value.str.val); - return; - } - array_init(return_value); - init_cfg_scanner(); - active_hash_table = return_value->value.ht; - parsing_mode = PARSING_MODE_STANDALONE; - currently_parsed_filename = (*filename)->value.str.val; - yyparse(); - fclose(cfgin); -#endif -} -/* }}} */ int php_shutdown_config(void) { Index: php4/main/php_ini.c diff -u php4/main/php_ini.c:1.41 php4/main/php_ini.c:1.42 --- php4/main/php_ini.c:1.41 Sun Oct 29 03:38:24 2000 +++ php4/main/php_ini.c Sun Oct 29 14:42:01 2000 @@ -2,17 +2,17 @@ +----------------------------------------------------------------------+ | PHP version 4.0 | +----------------------------------------------------------------------+ - | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | + | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | + | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Author: Zeev Suraski <zeev@zend.com> | + | Author: Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ Index: php4/main/php_ini.h diff -u php4/main/php_ini.h:1.27 php4/main/php_ini.h:1.28 --- php4/main/php_ini.h:1.27 Sun Oct 29 03:38:24 2000 +++ php4/main/php_ini.h Sun Oct 29 14:42:01 2000 @@ -12,7 +12,7 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Zeev Suraski <zeev@zend.com> | + | Author: Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */

« previous php.cvs (#2348) next »