]> granicus.if.org Git - php/commitdiff
@- Added parse_ini_file(). Currently implemented in non thread safe version
authorZeev Suraski <zeev@php.net>
Sat, 4 Mar 2000 02:59:14 +0000 (02:59 +0000)
committerZeev Suraski <zeev@php.net>
Sat, 4 Mar 2000 02:59:14 +0000 (02:59 +0000)
@  of PHP, and currently lacks section support (Zeev)
- Bring the non thread safe .dsp's uptodate

ext/standard/basic_functions.c
ext/standard/basic_functions.h
main/configuration-parser.y
php4.dsw
php4dll.dsp

index 24cd046a09a0105178aafe81eff83353a97af9bf..d42d427526378dfa169fa5f73571521b95cdf6ac 100644 (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}
 };
 
index d0026e296680dfe5ccff7c92b33131ace33b4a96..9f4ed101a6b66e2e875aa3bd676d09b61d4ff73c 100644 (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
index 49a60a75ec6a1f0a01a83265520042b0ad98a7e6..b1f466e2bd9ca1f07335d97c3e893393ba3447da 100644 (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;
-
-                                       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); }
index dd370b1780898420e6aa234fbff7d6dd9b374d5d..f96406c5c83ecba101e2ea44e8959da33ec38a9f 100644 (file)
--- 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
 }}}
 
 ###############################################################################
index ea9ca399de9912f85f19c12e79096c5138d616c6..da1fb79b0ba13d570fd9bf1852fddf5ea2a73dea 100644 (file)
@@ -54,7 +54,7 @@ BSC32=bscmake.exe
 # ADD BSC32 /nologo\r
 LINK32=link.exe\r
 # 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\r
-# 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"\r
+# 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"\r
 \r
 !ELSEIF  "$(CFG)" == "php4dll - Win32 Release"\r
 \r
@@ -80,7 +80,7 @@ BSC32=bscmake.exe
 # ADD BSC32 /nologo\r
 LINK32=link.exe\r
 # 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\r
-# 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"\r
+# 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"\r
 \r
 !ELSEIF  "$(CFG)" == "php4dll - Win32 Release_inline"\r
 \r
@@ -107,7 +107,7 @@ BSC32=bscmake.exe
 # ADD BSC32 /nologo\r
 LINK32=link.exe\r
 # 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"\r
-# 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"\r
+# 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"\r
 \r
 !ENDIF \r
 \r
@@ -183,6 +183,10 @@ SOURCE=.\php_realpath.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\php_ticks.c\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\php_variables.c\r
 # End Source File\r
 # Begin Source File\r
@@ -279,6 +283,10 @@ SOURCE=.\php_realpath.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\php_ticks.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\php_variables.h\r
 # End Source File\r
 # Begin Source File\r
@@ -443,6 +451,11 @@ SOURCE=.\ext\standard\parsedate.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\ext\mysql\php_mysql.c\r
+# ADD CPP /I "ext\mysql\libmysql"\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\ext\odbc\php_odbc.c\r
 # End Source File\r
 # Begin Source File\r
@@ -594,6 +607,10 @@ SOURCE=.\ext\standard\php_mail.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\ext\mysql\php_mysql.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\ext\odbc\php_odbc.h\r
 # End Source File\r
 # Begin Source File\r