From: Zeev Suraski Date: Sat, 4 Mar 2000 02:59:14 +0000 (+0000) Subject: @- Added parse_ini_file(). Currently implemented in non thread safe version X-Git-Tag: PHP-4.0-RC1~299 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d34b144061a115a66a047fdd9edcddb5aa5767de;p=php @- Added parse_ini_file(). Currently implemented in non thread safe version @ of PHP, and currently lacks section support (Zeev) - Bring the non thread safe .dsp's uptodate --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 24cd046a09..d42d427526 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -305,7 +305,9 @@ function_entry basic_functions[] = { PHP_FE(get_loaded_extensions, NULL) PHP_FE(extension_loaded, NULL) PHP_FE(get_extension_funcs, NULL) - + + PHP_FE(parse_ini_file, NULL) + {NULL, NULL, NULL} }; diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index d0026e2966..9f4ed101a6 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -107,6 +107,9 @@ PHP_FUNCTION(get_loaded_extensions); PHP_FUNCTION(extension_loaded); PHP_FUNCTION(get_extension_funcs); +/* From the INI parser */ +PHP_FUNCTION(parse_ini_file); + #ifdef PHP_WIN32 typedef unsigned int php_stat_len; #else diff --git a/main/configuration-parser.y b/main/configuration-parser.y index 49a60a75ec..b1f466e2bd 100644 --- a/main/configuration-parser.y +++ b/main/configuration-parser.y @@ -40,8 +40,9 @@ #define YYSTYPE zval -#define PARSING_MODE_CFG 0 -#define PARSING_MODE_BROWSCAP 1 +#define PARSING_MODE_CFG 0 +#define PARSING_MODE_BROWSCAP 1 +#define PARSING_MODE_STANDALONE 2 static HashTable configuration_hash; extern HashTable browser_hash; @@ -263,6 +264,34 @@ PHP_MINIT_FUNCTION(browscap) } +PHP_FUNCTION(parse_ini_file) +{ +#if 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 = fopen((*filename)->value.str.val, "r"); + if (!cfgin) { + php_error(E_WARNING,"Cannot open '%s' for reading", (*filename)->value.str.val); + return FAILURE; + } + 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) { zend_hash_destroy(&configuration_hash); @@ -405,24 +434,38 @@ statement: printf("'%s' = '%s'\n",$1.value.str.val,$3.value.str.val); #endif $3.type = IS_STRING; - if (parsing_mode==PARSING_MODE_CFG) { - zend_hash_update(active_hash_table, $1.value.str.val, $1.value.str.len+1, &$3, sizeof(zval), NULL); - if (active_hash_table == &configuration_hash) { - php_alter_ini_entry($1.value.str.val, $1.value.str.len+1, $3.value.str.val, $3.value.str.len+1, PHP_INI_SYSTEM, PHP_INI_STAGE_STARTUP); - } - } else if (parsing_mode==PARSING_MODE_BROWSCAP) { - if (current_section) { - zval *new_property; - - new_property = (zval *) malloc(sizeof(zval)); - INIT_PZVAL(new_property); - new_property->value.str.val = $3.value.str.val; - new_property->value.str.len = $3.value.str.len; - new_property->type = IS_STRING; - zend_str_tolower(new_property->value.str.val, new_property->value.str.len); - zend_hash_update(current_section->value.obj.properties, $1.value.str.val, $1.value.str.len+1, &new_property, sizeof(zval *), NULL); - } - } + switch (parsing_mode) { + case PARSING_MODE_CFG: + zend_hash_update(active_hash_table, $1.value.str.val, $1.value.str.len+1, &$3, sizeof(zval), NULL); + if (active_hash_table == &configuration_hash) { + php_alter_ini_entry($1.value.str.val, $1.value.str.len+1, $3.value.str.val, $3.value.str.len+1, PHP_INI_SYSTEM, PHP_INI_STAGE_STARTUP); + } + break; + case PARSING_MODE_BROWSCAP: + if (current_section) { + zval *new_property; + + new_property = (zval *) malloc(sizeof(zval)); + INIT_PZVAL(new_property); + new_property->value.str.val = $3.value.str.val; + new_property->value.str.len = $3.value.str.len; + new_property->type = IS_STRING; + zend_str_tolower(new_property->value.str.val, new_property->value.str.len); + zend_hash_update(current_section->value.obj.properties, $1.value.str.val, $1.value.str.len+1, &new_property, sizeof(zval *), NULL); + } + break; + case PARSING_MODE_STANDALONE: { + zval *entry; + + MAKE_STD_ZVAL(entry); + entry->value.str.val = estrndup($3.value.str.val, $3.value.str.len); + entry->value.str.len = $3.value.str.len; + entry->type = IS_STRING; + zend_hash_update(active_hash_table, $1.value.str.val, $1.value.str.len+1, &entry, sizeof(zval *), NULL); + pvalue_config_destructor(&$3); + } + break; + } free($1.value.str.val); } | TC_STRING { free($1.value.str.val); } diff --git a/php4.dsw b/php4.dsw index dd370b1780..f96406c5c8 100644 --- a/php4.dsw +++ b/php4.dsw @@ -15,6 +15,18 @@ Package=<4> ############################################################################### +Project: "libmysql"=.\ext\mysql\libmysql\libmysql.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + Project: "php4"=.\php4.dsp - Package Owner=<4> Package=<5> @@ -41,6 +53,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name Zend End Project Dependency + Begin Project Dependency + Project_Dep_Name libmysql + End Project Dependency }}} ############################################################################### diff --git a/php4dll.dsp b/php4dll.dsp index ea9ca399de..da1fb79b0b 100644 --- a/php4dll.dsp +++ b/php4dll.dsp @@ -54,7 +54,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Zend.lib resolv.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libcmt" /nodefaultlib:"libc" /nodefaultlib:"libcmtd" /out:"Debug/php4nts.dll" /pdbtype:sept /libpath:"TSRM\Debug" /libpath:"Zend\Debug" /libpath:"..\bindlib_w32\Debug" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Zend.lib resolv.lib libmysql.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libcmt" /nodefaultlib:"libc" /nodefaultlib:"libcmtd" /out:"Debug/php4nts.dll" /pdbtype:sept /libpath:"TSRM\Debug" /libpath:"Zend\Debug" /libpath:"..\bindlib_w32\Debug" /libpath:"ext\mysql\libmysql\Debug_TS" !ELSEIF "$(CFG)" == "php4dll - Win32 Release" @@ -80,7 +80,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Zend.lib resolv.lib /nologo /dll /machine:I386 /nodefaultlib:"libc.lib" /out:"Release/php4nts.dll" /libpath:"TSRM\Release" /libpath:"Zend\Release" /libpath:"..\bindlib_w32\Release" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Zend.lib resolv.lib libmysql.lib /nologo /dll /machine:I386 /nodefaultlib:"libc.lib" /out:"Release/php4nts.dll" /libpath:"TSRM\Release" /libpath:"Zend\Release" /libpath:"..\bindlib_w32\Release" /libpath:"ext\mysql\libmysql\Release_TS" !ELSEIF "$(CFG)" == "php4dll - Win32 Release_inline" @@ -107,7 +107,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Zend.lib resolv.lib /nologo /dll /machine:I386 /nodefaultlib:"libc.lib" /out:"Release/php4nts.dll" /libpath:"TSRM\Release" /libpath:"Zend\Release" /libpath:"..\bindlib_w32\Release" -# ADD LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Zend.lib resolv.lib /nologo /dll /machine:I386 /nodefaultlib:"libc.lib" /out:"Release/php4nts.dll" /libpath:"TSRM\Release" /libpath:"Zend\Release" /libpath:"..\bindlib_w32\Release" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Zend.lib resolv.lib libmysql.lib /nologo /dll /machine:I386 /nodefaultlib:"libc.lib" /out:"Release/php4nts.dll" /libpath:"TSRM\Release" /libpath:"Zend\Release" /libpath:"..\bindlib_w32\Release" !ENDIF @@ -183,6 +183,10 @@ SOURCE=.\php_realpath.c # End Source File # Begin Source File +SOURCE=.\php_ticks.c +# End Source File +# Begin Source File + SOURCE=.\php_variables.c # End Source File # Begin Source File @@ -279,6 +283,10 @@ SOURCE=.\php_realpath.h # End Source File # Begin Source File +SOURCE=.\php_ticks.h +# End Source File +# Begin Source File + SOURCE=.\php_variables.h # End Source File # Begin Source File @@ -443,6 +451,11 @@ SOURCE=.\ext\standard\parsedate.c # End Source File # Begin Source File +SOURCE=.\ext\mysql\php_mysql.c +# ADD CPP /I "ext\mysql\libmysql" +# End Source File +# Begin Source File + SOURCE=.\ext\odbc\php_odbc.c # End Source File # Begin Source File @@ -594,6 +607,10 @@ SOURCE=.\ext\standard\php_mail.h # End Source File # Begin Source File +SOURCE=.\ext\mysql\php_mysql.h +# End Source File +# Begin Source File + SOURCE=.\ext\odbc\php_odbc.h # End Source File # Begin Source File