@- 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
This commit is contained in:
Zeev Suraski 2000-03-04 02:59:14 +00:00
parent 0d19142fc2
commit d34b144061
5 changed files with 103 additions and 23 deletions

View file

@ -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}
};

View file

@ -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

View file

@ -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;
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);
}
}
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); }

View file

@ -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
}}}
###############################################################################

View file

@ -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