summaryrefslogtreecommitdiff
path: root/sapi
diff options
context:
space:
mode:
Diffstat (limited to 'sapi')
-rw-r--r--sapi/aolserver/README2
-rw-r--r--sapi/aolserver/aolserver.c4
-rw-r--r--sapi/aolserver/php5aolserver.dsp135
-rw-r--r--sapi/apache/apMakefile.tmpl26
-rw-r--r--sapi/apache/config.m440
-rw-r--r--sapi/apache/config.w324
-rw-r--r--sapi/apache/libphp7.module.in (renamed from sapi/apache/libphp5.module.in)2
-rw-r--r--sapi/apache/libpre.c2
-rw-r--r--sapi/apache/mod_php5.exp1
-rw-r--r--sapi/apache/mod_php7.c (renamed from sapi/apache/mod_php5.c)68
-rw-r--r--sapi/apache/mod_php7.exp1
-rw-r--r--sapi/apache/mod_php7.h (renamed from sapi/apache/mod_php5.h)8
-rw-r--r--sapi/apache/php.sym2
-rw-r--r--sapi/apache/php5apache.dsp151
-rw-r--r--sapi/apache/php_apache.c36
-rw-r--r--sapi/apache/php_apache_http.h4
-rw-r--r--sapi/apache/sapi_apache.c2
-rw-r--r--sapi/apache2filter/apache_config.c6
-rw-r--r--sapi/apache2filter/config.m46
-rw-r--r--sapi/apache2filter/php.sym2
-rw-r--r--sapi/apache2filter/php_apache.h4
-rw-r--r--sapi/apache2filter/php_functions.c14
-rw-r--r--sapi/apache2filter/sapi_apache2.c11
-rw-r--r--sapi/apache2handler/apache_config.c35
-rw-r--r--sapi/apache2handler/config.m414
-rw-r--r--sapi/apache2handler/config.w326
-rw-r--r--sapi/apache2handler/mod_php7.c (renamed from sapi/apache2handler/mod_php5.c)4
-rw-r--r--sapi/apache2handler/php.sym2
-rw-r--r--sapi/apache2handler/php5apache2.dsp146
-rw-r--r--sapi/apache2handler/php_apache.h9
-rw-r--r--sapi/apache2handler/php_functions.c34
-rw-r--r--sapi/apache2handler/sapi_apache2.c49
-rw-r--r--sapi/apache_hooks/apMakefile.tmpl24
-rw-r--r--sapi/apache_hooks/config.m440
-rw-r--r--sapi/apache_hooks/config.w324
-rw-r--r--sapi/apache_hooks/libphp7.module.in (renamed from sapi/apache_hooks/libphp5.module.in)2
-rw-r--r--sapi/apache_hooks/mod_php5.exp1
-rw-r--r--sapi/apache_hooks/mod_php7.c (renamed from sapi/apache_hooks/mod_php5.c)38
-rw-r--r--sapi/apache_hooks/mod_php7.exp1
-rw-r--r--sapi/apache_hooks/mod_php7.h (renamed from sapi/apache_hooks/mod_php5.h)8
-rw-r--r--sapi/apache_hooks/php.sym2
-rwxr-xr-xsapi/apache_hooks/php5apache_hooks.dsp151
-rw-r--r--sapi/apache_hooks/php_apache.c44
-rw-r--r--sapi/apache_hooks/php_apache_http.h2
-rw-r--r--sapi/apache_hooks/sapi_apache.c2
-rw-r--r--sapi/caudium/caudium.c13
-rw-r--r--sapi/caudium/config.m44
-rwxr-xr-xsapi/cgi/CHANGES1
-rw-r--r--sapi/cgi/README.FastCGI2
-rw-r--r--sapi/cgi/cgi_main.c167
-rw-r--r--sapi/cgi/config.w322
-rw-r--r--sapi/cgi/fastcgi.c34
-rw-r--r--sapi/cgi/fastcgi.h4
-rw-r--r--sapi/cli/cli.h8
-rw-r--r--sapi/cli/config.m42
-rw-r--r--sapi/cli/config.w324
-rw-r--r--sapi/cli/generate_mime_type_map.php76
-rw-r--r--sapi/cli/mime_type_map.h1024
-rw-r--r--sapi/cli/php_cli.c146
-rw-r--r--sapi/cli/php_cli_process_title.c6
-rw-r--r--sapi/cli/php_cli_process_title.h2
-rw-r--r--sapi/cli/php_cli_server.c343
-rw-r--r--sapi/cli/php_cli_server.h2
-rw-r--r--sapi/cli/php_http_parser.c7
-rw-r--r--sapi/cli/ps_title.c4
-rw-r--r--sapi/cli/ps_title.h2
-rw-r--r--sapi/cli/tests/006.phpt3
-rw-r--r--sapi/cli/tests/bug61977.phpt2
-rw-r--r--sapi/continuity/capi.c4
-rw-r--r--sapi/embed/php5embed.dsp100
-rw-r--r--sapi/embed/php_embed.c12
-rw-r--r--sapi/embed/php_embed.h2
-rw-r--r--sapi/fpm/fpm/events/devpoll.c2
-rw-r--r--sapi/fpm/fpm/events/devpoll.h2
-rw-r--r--sapi/fpm/fpm/events/epoll.c2
-rw-r--r--sapi/fpm/fpm/events/epoll.h2
-rw-r--r--sapi/fpm/fpm/events/kqueue.c2
-rw-r--r--sapi/fpm/fpm/events/kqueue.h2
-rw-r--r--sapi/fpm/fpm/events/poll.c2
-rw-r--r--sapi/fpm/fpm/events/poll.h2
-rw-r--r--sapi/fpm/fpm/events/port.c2
-rw-r--r--sapi/fpm/fpm/events/port.h2
-rw-r--r--sapi/fpm/fpm/events/select.c2
-rw-r--r--sapi/fpm/fpm/events/select.h2
-rw-r--r--sapi/fpm/fpm/fastcgi.c97
-rw-r--r--sapi/fpm/fpm/fastcgi.h4
-rw-r--r--sapi/fpm/fpm/fpm_conf.c31
-rw-r--r--sapi/fpm/fpm/fpm_main.c98
-rw-r--r--sapi/fpm/fpm/fpm_php.c50
-rw-r--r--sapi/fpm/fpm/fpm_php.h2
-rw-r--r--sapi/fpm/fpm/fpm_php_trace.c3
-rw-r--r--sapi/fpm/fpm/fpm_status.c22
-rw-r--r--sapi/fpm/php-fpm.conf.in2
-rw-r--r--sapi/isapi/config.m42
-rw-r--r--sapi/isapi/config.w324
-rw-r--r--sapi/isapi/php5isapi.dsp165
-rw-r--r--sapi/isapi/php7isapi.c (renamed from sapi/isapi/php5isapi.c)2
-rw-r--r--sapi/isapi/php7isapi.def (renamed from sapi/isapi/php5isapi.def)0
-rw-r--r--sapi/isapi/stresstest/notes.txt2
-rw-r--r--sapi/isapi/stresstest/stresstest.cpp2
-rw-r--r--sapi/isapi/stresstest/stresstest.dsp108
-rw-r--r--sapi/litespeed/lsapi_main.c16
-rw-r--r--sapi/litespeed/lsapidef.h2
-rw-r--r--sapi/litespeed/lsapilib.c2
-rw-r--r--sapi/litespeed/lsapilib.h2
-rw-r--r--sapi/milter/php_milter.c16
-rw-r--r--sapi/nsapi/nsapi-readme.txt26
-rw-r--r--sapi/nsapi/nsapi.c45
-rw-r--r--sapi/nsapi/php5nsapi.dsp135
-rw-r--r--sapi/phpdbg/phpdbg.c205
-rw-r--r--sapi/phpdbg/phpdbg.h29
-rw-r--r--sapi/phpdbg/phpdbg_bp.c632
-rw-r--r--sapi/phpdbg/phpdbg_bp.h2
-rw-r--r--sapi/phpdbg/phpdbg_btree.c15
-rw-r--r--sapi/phpdbg/phpdbg_btree.h5
-rw-r--r--sapi/phpdbg/phpdbg_cmd.c42
-rw-r--r--sapi/phpdbg/phpdbg_frame.c112
-rw-r--r--sapi/phpdbg/phpdbg_info.c254
-rw-r--r--sapi/phpdbg/phpdbg_list.c67
-rw-r--r--sapi/phpdbg/phpdbg_list.h4
-rw-r--r--sapi/phpdbg/phpdbg_opcode.c205
-rw-r--r--sapi/phpdbg/phpdbg_out.c17
-rw-r--r--sapi/phpdbg/phpdbg_parser.c286
-rw-r--r--sapi/phpdbg/phpdbg_parser.h37
-rw-r--r--sapi/phpdbg/phpdbg_print.c70
-rw-r--r--sapi/phpdbg/phpdbg_prompt.c365
-rw-r--r--sapi/phpdbg/phpdbg_rinit_hook.c6
-rw-r--r--sapi/phpdbg/phpdbg_set.c4
-rw-r--r--sapi/phpdbg/phpdbg_sigsafe.c73
-rw-r--r--sapi/phpdbg/phpdbg_sigsafe.h9
-rw-r--r--sapi/phpdbg/phpdbg_utils.c208
-rw-r--r--sapi/phpdbg/phpdbg_utils.h30
-rw-r--r--sapi/phpdbg/phpdbg_wait.c189
-rw-r--r--sapi/phpdbg/phpdbg_watch.c445
-rw-r--r--sapi/phpdbg/phpdbg_watch.h44
-rw-r--r--sapi/phpdbg/phpdbg_webdata_transfer.c137
-rw-r--r--sapi/phpdbg/tests/run-tests.php2
-rw-r--r--sapi/phpdbg/xml.md110
-rw-r--r--sapi/phttpd/php_phttpd.h2
-rw-r--r--sapi/phttpd/phttpd.c2
-rw-r--r--sapi/pi3web/README26
-rw-r--r--sapi/pi3web/config.m42
-rw-r--r--sapi/pi3web/config.w322
-rw-r--r--sapi/pi3web/php5pi3web.dsp136
-rw-r--r--sapi/pi3web/pi3web_sapi.c10
-rw-r--r--sapi/pi3web/pi3web_sapi.h8
-rw-r--r--sapi/roxen/README4
-rw-r--r--sapi/roxen/TODO12
-rw-r--r--sapi/roxen/config.m42
-rw-r--r--sapi/roxen/roxen.c15
-rw-r--r--sapi/thttpd/config.m44
-rw-r--r--sapi/thttpd/php_thttpd.h2
-rw-r--r--sapi/thttpd/thttpd.c15
-rw-r--r--sapi/thttpd/thttpd_patch4
-rw-r--r--sapi/tux/README16
-rw-r--r--sapi/tux/config.m42
-rw-r--r--sapi/tux/php_tux.c14
-rw-r--r--sapi/webjames/README2
-rw-r--r--sapi/webjames/php_webjames.h2
-rw-r--r--sapi/webjames/webjames.c2
160 files changed, 3556 insertions, 4319 deletions
diff --git a/sapi/aolserver/README b/sapi/aolserver/README
index 80c186ea5d..86af6a54b3 100644
--- a/sapi/aolserver/README
+++ b/sapi/aolserver/README
@@ -60,7 +60,7 @@ Then enable the PHP module:
ns_section "ns/server/${servername}/modules"
...
-ns_param php ${bindir}/libphp5.so
+ns_param php ${bindir}/libphp7.so
=============================================================================
diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c
index a89b98e57a..2796dd23a5 100644
--- a/sapi/aolserver/aolserver.c
+++ b/sapi/aolserver/aolserver.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -273,7 +273,7 @@ PHP_FUNCTION(getallheaders)
char *key = Ns_SetKey(NSG(conn->headers), i);
char *value = Ns_SetValue(NSG(conn->headers), i);
- add_assoc_string(return_value, key, value, 1);
+ add_assoc_string(return_value, key, value);
}
}
diff --git a/sapi/aolserver/php5aolserver.dsp b/sapi/aolserver/php5aolserver.dsp
deleted file mode 100644
index dd6ad71c53..0000000000
--- a/sapi/aolserver/php5aolserver.dsp
+++ /dev/null
@@ -1,135 +0,0 @@
-# Microsoft Developer Studio Project File - Name="php5aolserver" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=php5aolserver - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php5aolserver.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php5aolserver.mak" CFG="php5aolserver - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php5aolserver - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php5aolserver - Win32 Release_TS_inline" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php5aolserver - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php5aolserver - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP5AOLSERVER_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "..\..\..\php_build\nsapi30\include\\" /I "..\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\tsrm" /D ZEND_DEBUG=0 /D "NDEBUG" /D "PHP5AOLSERVER_EXPORTS" /D "PHP_WIN32" /D "ZTS" /D "ZEND_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "WIN32" /D "_MBCS" /D "HAVE_AOLSERVER" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 nsd.lib php5ts.lib 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 /base:"0x62000000" /version:4.0 /dll /machine:I386 /out:"../../Release_TS/php5aolserver.so" /libpath:"..\..\..\php_build\nsapi30\lib\\" /libpath:"..\..\Release_TS" /libpath:"..\..\TSRM\Release_TS" /libpath:"..\..\Zend\Release_TS"
-
-!ELSEIF "$(CFG)" == "php5aolserver - Win32 Release_TS_inline"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS_inline"
-# PROP BASE Intermediate_Dir "Release_TS_inline"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS_inline"
-# PROP Intermediate_Dir "Release_TS_inline"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP5AOLSERVER_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "..\..\..\php_build\nsapi30\include\\" /I "..\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\tsrm" /D ZEND_DEBUG=0 /D "ZEND_WIN32_FORCE_INLINE" /D "NDEBUG" /D "PHPAOLSERVER_EXPORTS" /D "PHP_WIN32" /D "ZTS" /D "ZEND_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "WIN32" /D "_MBCS" /D "HAVE_AOLSERVER" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 nsd.lib php5ts.lib 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 /base:"0x62000000" /version:4.0 /dll /machine:I386 /out:"../../Release_TS_inline/php5aolserver.so" /libpath:"..\..\..\php_build\nsapi30\lib\\" /libpath:"..\..\Release_TS_inline" /libpath:"..\..\TSRM\Release_TS_inline" /libpath:"..\..\Zend\Release_TS_inline"
-
-!ELSEIF "$(CFG)" == "php5aolserver - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\..\Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP5AOLSERVER_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "..\..\..\php_build\nsapi30\include\\" /I "..\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\tsrm" /D "_DEBUG" /D ZEND_DEBUG=1 /D "PHP5AOLSERVER_EXPORTS" /D "PHP_WIN32" /D "ZTS" /D "ZEND_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "WIN32" /D "_MBCS" /D "HAVE_AOLSERVER" /FR /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 nsd.lib php5ts_debug.lib 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 /base:"0x62000000" /version:4.0 /dll /debug /machine:I386 /out:"..\..\Debug_TS/php5aolserver.so" /pdbtype:sept /libpath:"..\..\..\php_build\nsapi30\lib\\" /libpath:"..\..\Debug_TS" /libpath:"..\..\TSRM\Debug_TS" /libpath:"..\..\Zend\Debug_TS"
-
-!ENDIF
-
-# Begin Target
-
-# Name "php5aolserver - Win32 Release_TS"
-# Name "php5aolserver - Win32 Release_TS_inline"
-# Name "php5aolserver - Win32 Debug_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\aolserver.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/sapi/apache/apMakefile.tmpl b/sapi/apache/apMakefile.tmpl
index 5f77d9c9c9..c8b174775e 100644
--- a/sapi/apache/apMakefile.tmpl
+++ b/sapi/apache/apMakefile.tmpl
@@ -1,38 +1,38 @@
##
-## Apache 1.3 Makefile template for PHP 5.0 Module
-## [src/modules/php5/Makefile.tmpl]
+## Apache 1.3 Makefile template for PHP 7.0 Module
+## [src/modules/php7/Makefile.tmpl]
##
# the parametrized target
-LIB=libphp5.$(LIBEXT)
+LIB=libphp7.$(LIBEXT)
# objects for building the static library
-OBJS=mod_php5.o
-OBJS_LIB=libmodphp5.a
+OBJS=mod_php7.o
+OBJS_LIB=libmodphp7.a
# objects for building the shared object library
-SHLIB_OBJS=mod_php5.so-o
-SHLIB_OBJS_LIB=libmodphp5.a
+SHLIB_OBJS=mod_php7.so-o
+SHLIB_OBJS_LIB=libmodphp7.a
# the general targets
all: lib
lib: $(LIB)
# build the static library by merging the object files
-libphp5.a: $(OBJS) $(OBJS_LIB)
+libphp7.a: $(OBJS) $(OBJS_LIB)
cp $(OBJS_LIB) $@
ar r $@ $(OBJS)
$(RANLIB) $@
# ugly hack to support older Apache-1.3 betas that don't set $LIBEXT
-libphp5.: $(OBJS) $(OBJS_LIB)
+libphp7.: $(OBJS) $(OBJS_LIB)
cp $(OBJS_LIB) $@
ar r $@ $(OBJS)
$(RANLIB) $@
- cp libphp5. libphp5.a
+ cp libphp7. libphp7.a
# build the shared object library by linking the object files
-libphp5.so: $(SHLIB_OBJS) $(SHLIB_OBJS_LIB)
+libphp7.so: $(SHLIB_OBJS) $(SHLIB_OBJS_LIB)
rm -f $@
$(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $(SHLIB_OBJS) $(SHLIB_OBJS_LIB) $(LIBS) $(PHP_LIBS)
@@ -69,9 +69,9 @@ depend:
$(OBJS): Makefile
# DO NOT REMOVE
-mod_php5.o: mod_php5.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \
+mod_php7.o: mod_php7.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \
$(INCDIR)/buff.h \
$(INCDIR)/http_config.h \
$(INCDIR)/http_core.h $(INCDIR)/http_main.h \
$(INCDIR)/http_protocol.h $(INCDIR)/http_request.h \
- $(INCDIR)/http_log.h $(INCDIR)/util_script.h mod_php5.h
+ $(INCDIR)/http_log.h $(INCDIR)/util_script.h mod_php7.h
diff --git a/sapi/apache/config.m4 b/sapi/apache/config.m4
index 7b0ee562eb..f5bfde4d68 100644
--- a/sapi/apache/config.m4
+++ b/sapi/apache/config.m4
@@ -78,7 +78,7 @@ if test "$PHP_APXS" != "no"; then
*darwin*)
MH_BUNDLE_FLAGS="-dynamic -twolevel_namespace -bundle -bundle_loader $APXS_HTTPD"
PHP_SUBST(MH_BUNDLE_FLAGS)
- SAPI_SHARED=libs/libphp5.so
+ SAPI_SHARED=libs/libphp7.so
build_type=bundle
;;
*)
@@ -86,26 +86,26 @@ if test "$PHP_APXS" != "no"; then
;;
esac
- PHP_SELECT_SAPI(apache, $build_type, sapi_apache.c mod_php5.c php_apache.c, $APACHE_CPPFLAGS -I$APXS_INCLUDEDIR)
+ PHP_SELECT_SAPI(apache, $build_type, sapi_apache.c mod_php7.c php_apache.c, $APACHE_CPPFLAGS -I$APXS_INCLUDEDIR)
# Test whether apxs support -S option
$APXS -q -S CFLAGS="$APXS_CFLAGS" CFLAGS >/dev/null 2>&1
if test "$?" != "0"; then
- APACHE_INSTALL="$APXS -i -a -n php5 $SAPI_SHARED" # Old apxs does not have -S option
+ APACHE_INSTALL="$APXS -i -a -n php7 $SAPI_SHARED" # Old apxs does not have -S option
else
APXS_LIBEXECDIR='$(INSTALL_ROOT)'`$APXS -q LIBEXECDIR`
if test -z `$APXS -q SYSCONFDIR`; then
APACHE_INSTALL="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
$APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
- -i -n php5 $SAPI_SHARED"
+ -i -n php7 $SAPI_SHARED"
else
APXS_SYSCONFDIR='$(INSTALL_ROOT)'`$APXS -q SYSCONFDIR`
APACHE_INSTALL="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
\$(mkinstalldirs) '$APXS_SYSCONFDIR' && \
$APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
-S SYSCONFDIR='$APXS_SYSCONFDIR' \
- -i -a -n php5 $SAPI_SHARED"
+ -i -a -n php7 $SAPI_SHARED"
fi
fi
@@ -135,7 +135,7 @@ if test "$PHP_SAPI" != "apache" && test "$PHP_APACHE" != "no"; then
PHP_APACHE=/usr/local/apache
fi
- APACHE_INSTALL_FILES="\$(srcdir)/sapi/apache/mod_php5.* sapi/apache/libphp5.module"
+ APACHE_INSTALL_FILES="\$(srcdir)/sapi/apache/mod_php7.* sapi/apache/libphp7.module"
AC_DEFINE(HAVE_APACHE,1,[ ])
APACHE_MODULE=yes
@@ -144,7 +144,7 @@ if test "$PHP_SAPI" != "apache" && test "$PHP_APACHE" != "no"; then
if test -f $PHP_APACHE/src/httpd.h; then
APACHE_INCLUDE=-I$PHP_APACHE/src
APACHE_TARGET=$PHP_APACHE/src
- PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php5.c php_apache.c, $APACHE_INCLUDE)
+ PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_INSTALL_FILES $APACHE_TARGET"
PHP_LIBS="-L. -lphp3"
AC_MSG_RESULT([yes - Apache 1.2.x])
@@ -159,13 +159,13 @@ if test "$PHP_SAPI" != "apache" && test "$PHP_APACHE" != "no"; then
elif test -f $PHP_APACHE/src/main/httpd.h; then
APACHE_HAS_REGEX=1
APACHE_INCLUDE="-I$PHP_APACHE/src/main -I$PHP_APACHE/src/os/unix -I$PHP_APACHE/src/ap"
- APACHE_TARGET=$PHP_APACHE/src/modules/php5
+ APACHE_TARGET=$PHP_APACHE/src/modules/php7
if test ! -d $APACHE_TARGET; then
mkdir $APACHE_TARGET
fi
- PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php5.c php_apache.c, $APACHE_INCLUDE)
- APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp5.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
- PHP_LIBS="-Lmodules/php5 -L../modules/php5 -L../../modules/php5 -lmodphp5"
+ PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
+ APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp7.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
+ PHP_LIBS="-Lmodules/php7 -L../modules/php7 -L../../modules/php7 -lmodphp7"
AC_MSG_RESULT([yes - Apache 1.3.x])
STRONGHOLD=
if test -f $PHP_APACHE/src/include/ap_config.h; then
@@ -183,13 +183,13 @@ if test "$PHP_SAPI" != "apache" && test "$PHP_APACHE" != "no"; then
elif test -f $PHP_APACHE/src/include/httpd.h; then
APACHE_HAS_REGEX=1
APACHE_INCLUDE="-I$PHP_APACHE/src/include -I$PHP_APACHE/src/os/unix"
- APACHE_TARGET=$PHP_APACHE/src/modules/php5
+ APACHE_TARGET=$PHP_APACHE/src/modules/php7
if test ! -d $APACHE_TARGET; then
mkdir $APACHE_TARGET
fi
- PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php5.c php_apache.c, $APACHE_INCLUDE)
- PHP_LIBS="-Lmodules/php5 -L../modules/php5 -L../../modules/php5 -lmodphp5"
- APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp5.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
+ PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
+ PHP_LIBS="-Lmodules/php7 -L../modules/php7 -L../../modules/php7 -lmodphp7"
+ APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp7.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
AC_MSG_RESULT([yes - Apache 1.3.x])
STRONGHOLD=
if test -f $PHP_APACHE/src/include/ap_config.h; then
@@ -207,9 +207,9 @@ if test "$PHP_SAPI" != "apache" && test "$PHP_APACHE" != "no"; then
elif test -f $PHP_APACHE/apache/httpd.h; then
APACHE_INCLUDE="-I$PHP_APACHE/apache -I$PHP_APACHE/ssl/include"
APACHE_TARGET=$PHP_APACHE/apache
- PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php5.c php_apache.c, $APACHE_INCLUDE)
- PHP_LIBS="-Lmodules/php5 -L../modules/php5 -L../../modules/php5 -lmodphp5"
- APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp5.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET"
+ PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
+ PHP_LIBS="-Lmodules/php7 -L../modules/php7 -L../../modules/php7 -lmodphp7"
+ APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp7.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET"
STRONGHOLD=-DSTRONGHOLD=1
AC_MSG_RESULT([yes - StrongHold])
if test -f $PHP_APACHE/apache/ap_config.h; then
@@ -247,13 +247,13 @@ dnl Build as static module
if test "$APACHE_MODULE" = "yes"; then
PHP_TARGET_RDYNAMIC
$php_shtool mkdir -p sapi/apache
- PHP_OUTPUT(sapi/apache/libphp5.module)
+ PHP_OUTPUT(sapi/apache/libphp7.module)
fi
dnl General
if test -n "$APACHE_INSTALL"; then
if test "x$APXS" != "x" -a "`uname -sv`" = "AIX 4" -a "$GCC" != "yes"; then
- APXS_EXP=-bE:sapi/apache/mod_php5.exp
+ APXS_EXP=-bE:sapi/apache/mod_php7.exp
fi
PHP_APACHE_FD_CHECK
diff --git a/sapi/apache/config.w32 b/sapi/apache/config.w32
index e876d7500e..e5b72f1bcf 100644
--- a/sapi/apache/config.w32
+++ b/sapi/apache/config.w32
@@ -15,9 +15,9 @@ if (PHP_APACHE != "no") {
";" + PHP_PHP_BUILD + "\\apache\\src\\corer")) {
// We need to play tricks to get our readdir.h used by apache
// headers
- SAPI('apache', 'mod_php5.c sapi_apache.c php_apache.c',
+ SAPI('apache', 'mod_php7.c sapi_apache.c php_apache.c',
'php' + PHP_VERSION + 'apache.dll',
- '/D APACHEPHP5_EXPORTS /D APACHE_READDIR_H /I win32');
+ '/D APACHEPHP7_EXPORTS /D APACHE_READDIR_H /I win32');
} else {
WARNING("Could not find apache libraries/headers");
}
diff --git a/sapi/apache/libphp5.module.in b/sapi/apache/libphp7.module.in
index 00d9c49f40..892df4d5cc 100644
--- a/sapi/apache/libphp5.module.in
+++ b/sapi/apache/libphp7.module.in
@@ -1,4 +1,4 @@
-Name: php5_module
+Name: php7_module
ConfigStart
RULE_WANTHSREGEX=no
RULE_HIDE=yes
diff --git a/sapi/apache/libpre.c b/sapi/apache/libpre.c
index ca10e34cdd..f7ab68b62c 100644
--- a/sapi/apache/libpre.c
+++ b/sapi/apache/libpre.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/apache/mod_php5.exp b/sapi/apache/mod_php5.exp
deleted file mode 100644
index 9ad0f0a0ad..0000000000
--- a/sapi/apache/mod_php5.exp
+++ /dev/null
@@ -1 +0,0 @@
-php5_module
diff --git a/sapi/apache/mod_php5.c b/sapi/apache/mod_php7.c
index a1e5a70e89..687586952f 100644
--- a/sapi/apache/mod_php5.c
+++ b/sapi/apache/mod_php7.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -60,12 +60,12 @@ static CONST_PREFIX char *php_apache_flag_handler(cmd_parms *cmd, HashTable *con
static CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode);
static CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2);
-/* ### these should be defined in mod_php5.h or somewhere else */
+/* ### these should be defined in mod_php7.h or somewhere else */
#define USE_PATH 1
#define IGNORE_URL 2
#define MAX_STATUS_LENGTH sizeof("xxxx LONGEST POSSIBLE STATUS DESCRIPTION")
-module MODULE_VAR_EXPORT php5_module;
+module MODULE_VAR_EXPORT php7_module;
int saved_umask;
static unsigned char apache_php_initialized;
@@ -108,7 +108,7 @@ static int sapi_apache_ub_write(const char *str, uint str_length TSRMLS_DC)
/* {{{ sapi_apache_flush
*/
-static void sapi_apache_flush(void *server_context)
+static void sapi_apache_flush(void *server_context TSRMLS_DC)
{
if (server_context) {
#if MODULE_MAGIC_NUMBER > 19970110
@@ -256,7 +256,7 @@ static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_
register int i;
array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env);
table_entry *elts = (table_entry *) arr->elts;
- zval **path_translated;
+ zval *path_translated;
HashTable *symbol_table;
unsigned int new_val_len;
@@ -277,14 +277,14 @@ static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_
/* If PATH_TRANSLATED doesn't exist, copy it from SCRIPT_FILENAME */
if (track_vars_array) {
- symbol_table = track_vars_array->value.ht;
+ symbol_table = Z_ARRVAL_P(track_vars_array);
} else {
symbol_table = NULL;
}
if (symbol_table
- && !zend_hash_exists(symbol_table, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"))
- && zend_hash_find(symbol_table, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &path_translated)==SUCCESS) {
- php_register_variable("PATH_TRANSLATED", Z_STRVAL_PP(path_translated), track_vars_array TSRMLS_CC);
+ && !zend_hash_str_exists(symbol_table, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED")-1)
+ && (path_translated = zend_hash_str_find(symbol_table, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1)) != NULL) {
+ php_register_variable("PATH_TRANSLATED", Z_STRVAL_P(path_translated), track_vars_array TSRMLS_CC);
}
if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &((request_rec *) SG(server_context))->uri, strlen(((request_rec *) SG(server_context))->uri), &new_val_len TSRMLS_CC)) {
@@ -566,7 +566,9 @@ static void init_request_info(TSRMLS_D)
*/
static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry TSRMLS_DC)
{
- zend_alter_ini_entry(per_dir_entry->key, per_dir_entry->key_length+1, per_dir_entry->value, per_dir_entry->value_length, per_dir_entry->type, per_dir_entry->htaccess?PHP_INI_STAGE_HTACCESS:PHP_INI_STAGE_ACTIVATE);
+ zend_string *key = STR_INIT(per_dir_entry->key, per_dir_entry->key_length, 0);
+ zend_alter_ini_entry_chars(key, per_dir_entry->value, per_dir_entry->value_length, per_dir_entry->type, per_dir_entry->htaccess?PHP_INI_STAGE_HTACCESS:PHP_INI_STAGE_ACTIVATE);
+ STR_RELEASE(key);
return 0;
}
/* }}} */
@@ -620,7 +622,7 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
return DECLINED;
}
- per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php5_module);
+ per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php7_module);
if (per_dir_conf) {
zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);
}
@@ -710,36 +712,44 @@ static int send_parsed_php_source(request_rec * r)
/* {{{ destroy_per_dir_entry
*/
-static void destroy_per_dir_entry(php_per_dir_entry *per_dir_entry)
+static void destroy_per_dir_entry(zval *zv)
{
+ php_per_dir_entry *per_dir_entry = Z_PTR_P(zv);
+
free(per_dir_entry->key);
free(per_dir_entry->value);
+ free(per_dir_entry);
}
/* }}} */
/* {{{ copy_per_dir_entry
*/
-static void copy_per_dir_entry(php_per_dir_entry *per_dir_entry)
+static void copy_per_dir_entry(zval *zv)
{
- php_per_dir_entry tmp = *per_dir_entry;
+ php_per_dir_entry *old_per_dir_entry = Z_PTR_P(zv);
+ php_per_dir_entry *new_per_dir_entry = malloc(sizeof(php_per_dir_entry));
+
+ memcpy(new_per_dir_entry, old_per_dir_entry, sizeof(php_per_dir_entry));
+ Z_PTR_P(zv) = new_per_dir_entry;
- per_dir_entry->key = (char *) malloc(tmp.key_length+1);
- memcpy(per_dir_entry->key, tmp.key, tmp.key_length);
- per_dir_entry->key[per_dir_entry->key_length] = 0;
+ new_per_dir_entry->key = (char *) malloc(old_per_dir_entry->key_length+1);
+ memcpy(new_per_dir_entry->key, old_per_dir_entry->key, old_per_dir_entry->key_length);
+ new_per_dir_entry->key[new_per_dir_entry->key_length] = 0;
- per_dir_entry->value = (char *) malloc(tmp.value_length+1);
- memcpy(per_dir_entry->value, tmp.value, tmp.value_length);
- per_dir_entry->value[per_dir_entry->value_length] = 0;
+ new_per_dir_entry->value = (char *) malloc(old_per_dir_entry->value_length+1);
+ memcpy(new_per_dir_entry->value, old_per_dir_entry->value, old_per_dir_entry->value_length);
+ new_per_dir_entry->value[new_per_dir_entry->value_length] = 0;
}
/* }}} */
/* {{{ should_overwrite_per_dir_entry
*/
-static zend_bool should_overwrite_per_dir_entry(HashTable *target_ht, php_per_dir_entry *new_per_dir_entry, zend_hash_key *hash_key, void *pData)
+static zend_bool should_overwrite_per_dir_entry(HashTable *target_ht, zval *zv, zend_hash_key *hash_key, void *pData)
{
+ php_per_dir_entry *new_per_dir_entry = Z_PTR_P(zv);
php_per_dir_entry *orig_per_dir_entry;
- if (zend_hash_find(target_ht, hash_key->arKey, hash_key->nKeyLength, (void **) &orig_per_dir_entry)==FAILURE) {
+ if ((orig_per_dir_entry = zend_hash_find_ptr(target_ht, hash_key->key)) == NULL) {
return 1; /* does not exist in dest, copy from source */
}
@@ -768,7 +778,7 @@ static void *php_create_dir(pool *p, char *dummy)
HashTable *per_dir_info;
per_dir_info = (HashTable *) malloc(sizeof(HashTable));
- zend_hash_init_ex(per_dir_info, 5, NULL, (void (*)(void *)) destroy_per_dir_entry, 1, 0);
+ zend_hash_init_ex(per_dir_info, 5, NULL, destroy_per_dir_entry, 1, 0);
register_cleanup(p, (void *) per_dir_info, (void (*)(void *)) php_destroy_per_dir_info, (void (*)(void *)) zend_hash_destroy);
return per_dir_info;
@@ -784,9 +794,9 @@ static void *php_merge_dir(pool *p, void *basev, void *addv)
/* need a copy of addv to merge */
new = php_create_dir(p, "php_merge_dir");
- zend_hash_copy(new, (HashTable *) basev, (copy_ctor_func_t) copy_per_dir_entry, NULL, sizeof(php_per_dir_entry));
+ zend_hash_copy(new, (HashTable *) basev, copy_per_dir_entry);
- zend_hash_merge_ex(new, (HashTable *) addv, (copy_ctor_func_t) copy_per_dir_entry, sizeof(php_per_dir_entry), (merge_checker_func_t) should_overwrite_per_dir_entry, NULL);
+ zend_hash_merge_ex(new, (HashTable *) addv, copy_per_dir_entry, should_overwrite_per_dir_entry, NULL);
return new;
}
/* }}} */
@@ -823,7 +833,7 @@ static CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable
memcpy(per_dir_entry.value, arg2, per_dir_entry.value_length);
per_dir_entry.value[per_dir_entry.value_length] = 0;
- zend_hash_update(conf, per_dir_entry.key, per_dir_entry.key_length, &per_dir_entry, sizeof(php_per_dir_entry), NULL);
+ zend_hash_str_update_mem(conf, per_dir_entry.key, per_dir_entry.key_length, &per_dir_entry, sizeof(php_per_dir_entry));
return NULL;
}
/* }}} */
@@ -899,7 +909,7 @@ static int php_xbithack_handler(request_rec * r)
if (!(r->finfo.st_mode & S_IXUSR)) {
return DECLINED;
}
- per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php5_module);
+ per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php7_module);
if (per_dir_conf) {
zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);
}
@@ -996,9 +1006,9 @@ command_rec php_commands[] =
};
/* }}} */
-/* {{{ odule MODULE_VAR_EXPORT php5_module
+/* {{{ odule MODULE_VAR_EXPORT php7_module
*/
-module MODULE_VAR_EXPORT php5_module =
+module MODULE_VAR_EXPORT php7_module =
{
STANDARD_MODULE_STUFF,
php_init_handler, /* initializer */
diff --git a/sapi/apache/mod_php7.exp b/sapi/apache/mod_php7.exp
new file mode 100644
index 0000000000..1469b0314d
--- /dev/null
+++ b/sapi/apache/mod_php7.exp
@@ -0,0 +1 @@
+php7_module
diff --git a/sapi/apache/mod_php5.h b/sapi/apache/mod_php7.h
index 3bc7857380..947d8b44d4 100644
--- a/sapi/apache/mod_php5.h
+++ b/sapi/apache/mod_php7.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -17,8 +17,8 @@
*/
/* $Id$ */
-#ifndef MOD_PHP5_H
-#define MOD_PHP5_H
+#ifndef MOD_PHP7_H
+#define MOD_PHP7_H
#if !defined(WIN32) && !defined(WINNT)
#ifndef MODULE_VAR_EXPORT
@@ -50,7 +50,7 @@ extern php_apache_info_struct php_apache_info;
# define MODULE_VAR_EXPORT PHPAPI
#endif
-#endif /* MOD_PHP5_H */
+#endif /* MOD_PHP7_H */
/*
* Local variables:
diff --git a/sapi/apache/php.sym b/sapi/apache/php.sym
index 9ad0f0a0ad..1469b0314d 100644
--- a/sapi/apache/php.sym
+++ b/sapi/apache/php.sym
@@ -1 +1 @@
-php5_module
+php7_module
diff --git a/sapi/apache/php5apache.dsp b/sapi/apache/php5apache.dsp
deleted file mode 100644
index fbdb7612b8..0000000000
--- a/sapi/apache/php5apache.dsp
+++ /dev/null
@@ -1,151 +0,0 @@
-# Microsoft Developer Studio Project File - Name="php5apache" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=php5apache - Win32 Release_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php5apache.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php5apache.mak" CFG="php5apache - Win32 Release_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php5apache - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php5apache - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php5apache - Win32 Release_TS_inline" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php5apache - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APACHEPHP5_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\..\php_build\includes" /I "..\..\main" /I "..\..\TSRM" /I "..\..\regex" /I "C:\Program Files\Apache Group\Apache\include" /D ZEND_DEBUG=0 /D "NDEBUG" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "APACHEPHP5_EXPORTS" /D "WIN32" /D "_MBCS" /D "APACHE_READDIR_H" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 php5ts.lib ApacheCore.lib 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 /base:"0x60000000" /version:4.0 /dll /machine:I386 /libpath:"..\..\..\php_build\release" /libpath:"..\..\Release_TS" /libpath:"..\..\TSRM\Release_TS" /libpath:"..\..\Zend\Release_TS" /libpath:"C:\Program Files\Apache Group\Apache\libexec"
-
-!ELSEIF "$(CFG)" == "php5apache - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APACHEPHP5_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\..\php_build\includes" /I "..\..\main" /I "..\..\TSRM" /I "..\..\regex" /I "C:\Program Files\Apache Group\Apache\include" /D "_DEBUG" /D ZEND_DEBUG=1 /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "APACHEPHP5_EXPORTS" /D "WIN32" /D "_MBCS" /D "APACHE_READDIR_H" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 php5ts_debug.lib ApacheCore.lib 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 /base:"0x60000000" /version:4.0 /dll /incremental:yes /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\php_build\release" /libpath:"..\..\Debug_TS" /libpath:"..\..\TSRM\Debug_TS" /libpath:"..\..\Zend\Debug_TS" /libpath:"C:\Program Files\Apache Group\Apache\libexec"
-
-!ELSEIF "$(CFG)" == "php5apache - Win32 Release_TS_inline"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS_inline"
-# PROP BASE Intermediate_Dir "Release_TS_inline"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS_inline"
-# PROP Intermediate_Dir "Release_TS_inline"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APACHEPHP5_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\..\php_build\includes" /I "..\..\main" /I "..\..\TSRM" /I "..\..\regex" /I "C:\Program Files\Apache Group\Apache\include" /D ZEND_DEBUG=0 /D "ZEND_WIN32_FORCE_INLINE" /D "NDEBUG" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "APACHEPHP5_EXPORTS" /D "WIN32" /D "_MBCS" /D "APACHE_READDIR_H" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 php5ts.lib ApacheCore.lib 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 /version:4.0 /dll /machine:I386 /libpath:"..\..\..\php_build\release" /libpath:"..\..\Release_TS_inline" /libpath:"..\..\TSRM\Release_TS_inline" /libpath:"..\..\Zend\Release_TS_inline" /libpath:"C:\Program Files\Apache Group\Apache\libexec"
-
-!ENDIF
-
-# Begin Target
-
-# Name "php5apache - Win32 Release_TS"
-# Name "php5apache - Win32 Debug_TS"
-# Name "php5apache - Win32 Release_TS_inline"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\mod_php5.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_apache.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\sapi_apache.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\mod_php5.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_apache_http.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/sapi/apache/php_apache.c b/sapi/apache/php_apache.c
index 43a4c90efe..f6e9e61203 100644
--- a/sapi/apache/php_apache.c
+++ b/sapi/apache/php_apache.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -327,7 +327,7 @@ PHP_FUNCTION(apache_note)
}
if (old_val) {
- RETURN_STRING(old_val, 1);
+ RETURN_STRING(old_val);
}
RETURN_FALSE;
@@ -404,7 +404,7 @@ PHP_FUNCTION(apache_request_headers)
if (!tenv[i].key) {
continue;
}
- if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val, 1)==FAILURE) {
+ if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val)==FAILURE) {
RETURN_FALSE;
}
}
@@ -424,7 +424,7 @@ PHP_FUNCTION(apache_response_headers)
tenv = (table_entry *)env_arr->elts;
for (i = 0; i < env_arr->nelts; ++i) {
if (!tenv[i].key) continue;
- if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val, 1)==FAILURE) {
+ if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val)==FAILURE) {
RETURN_FALSE;
}
}
@@ -475,34 +475,34 @@ PHP_FUNCTION(apache_lookup_uri)
add_property_long(return_value,"status", rr->status);
if (rr->the_request) {
- add_property_string(return_value,"the_request", rr->the_request, 1);
+ add_property_string(return_value,"the_request", rr->the_request);
}
if (rr->status_line) {
- add_property_string(return_value,"status_line", (char *)rr->status_line, 1);
+ add_property_string(return_value,"status_line", (char *)rr->status_line);
}
if (rr->method) {
- add_property_string(return_value,"method", (char *)rr->method, 1);
+ add_property_string(return_value,"method", (char *)rr->method);
}
if (rr->content_type) {
- add_property_string(return_value,"content_type", (char *)rr->content_type, 1);
+ add_property_string(return_value,"content_type", (char *)rr->content_type);
}
if (rr->handler) {
- add_property_string(return_value,"handler", (char *)rr->handler, 1);
+ add_property_string(return_value,"handler", (char *)rr->handler);
}
if (rr->uri) {
- add_property_string(return_value,"uri", rr->uri, 1);
+ add_property_string(return_value,"uri", rr->uri);
}
if (rr->filename) {
- add_property_string(return_value,"filename", rr->filename, 1);
+ add_property_string(return_value,"filename", rr->filename);
}
if (rr->path_info) {
- add_property_string(return_value,"path_info", rr->path_info, 1);
+ add_property_string(return_value,"path_info", rr->path_info);
}
if (rr->args) {
- add_property_string(return_value,"args", rr->args, 1);
+ add_property_string(return_value,"args", rr->args);
}
if (rr->boundary) {
- add_property_string(return_value,"boundary", rr->boundary, 1);
+ add_property_string(return_value,"boundary", rr->boundary);
}
add_property_long(return_value,"no_cache", rr->no_cache);
@@ -515,7 +515,7 @@ PHP_FUNCTION(apache_lookup_uri)
#if MODULE_MAGIC_NUMBER >= 19980324
if (rr->unparsed_uri) {
- add_property_string(return_value,"unparsed_uri", rr->unparsed_uri, 1);
+ add_property_string(return_value,"unparsed_uri", rr->unparsed_uri);
}
if(rr->mtime) {
add_property_long(return_value,"mtime", rr->mtime);
@@ -561,7 +561,7 @@ PHP_FUNCTION(apache_get_version)
char *apv = (char *) ap_get_server_version();
if (apv && *apv) {
- RETURN_STRING(apv, 1);
+ RETURN_STRING(apv);
}
RETURN_FALSE;
@@ -580,9 +580,9 @@ PHP_FUNCTION(apache_get_modules)
for (n = 0; ap_loaded_modules[n]; ++n) {
char *s = (char *) ap_loaded_modules[n]->name;
if ((p = strchr(s, '.'))) {
- add_next_index_stringl(return_value, s, (p - s), 1);
+ add_next_index_stringl(return_value, s, (p - s));
} else {
- add_next_index_string(return_value, s, 1);
+ add_next_index_string(return_value, s);
}
}
}
diff --git a/sapi/apache/php_apache_http.h b/sapi/apache/php_apache_http.h
index a18e5dbac2..ed586372d7 100644
--- a/sapi/apache/php_apache_http.h
+++ b/sapi/apache/php_apache_http.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -67,4 +67,4 @@
#include "php_ini.h"
#include "ext/standard/php_standard.h"
-#include "mod_php5.h"
+#include "mod_php7.h"
diff --git a/sapi/apache/sapi_apache.c b/sapi/apache/sapi_apache.c
index f19586da1f..466cf6b8ff 100644
--- a/sapi/apache/sapi_apache.c
+++ b/sapi/apache/sapi_apache.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/apache2filter/apache_config.c b/sapi/apache2filter/apache_config.c
index 7c50b9e6a8..f87a04bbd1 100644
--- a/sapi/apache2filter/apache_config.c
+++ b/sapi/apache2filter/apache_config.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -137,7 +137,7 @@ void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf)
zend_hash_move_forward(&d->config)) {
pe = NULL;
zend_hash_get_current_data(&d->config, (void **) &data);
- if (zend_hash_find(&n->config, str, str_len, (void **) &pe) == SUCCESS) {
+ if ((pe = zend_hash_find(&n->config, str, str_len) != NULL) != NULL) {
if (pe->status >= data->status) continue;
}
zend_hash_update(&n->config, str, str_len, data, sizeof(*data), NULL);
@@ -152,7 +152,7 @@ char *get_php_config(void *conf, char *name, size_t name_len)
php_conf_rec *d = conf;
php_dir_entry *pe;
- if (zend_hash_find(&d->config, name, name_len, (void **) &pe) == SUCCESS) {
+ if ((pe = zend_hash_find(&d->config, name, name_len)) != NULL) {
return pe->value;
}
diff --git a/sapi/apache2filter/config.m4 b/sapi/apache2filter/config.m4
index b6524fd874..11cc051015 100644
--- a/sapi/apache2filter/config.m4
+++ b/sapi/apache2filter/config.m4
@@ -71,14 +71,14 @@ if test "$PHP_APXS2FILTER" != "no"; then
if test -z `$APXS -q SYSCONFDIR`; then
INSTALL_IT="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
$APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
- -i -n php5"
+ -i -n php7"
else
APXS_SYSCONFDIR='$(INSTALL_ROOT)'`$APXS -q SYSCONFDIR`
INSTALL_IT="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
\$(mkinstalldirs) '$APXS_SYSCONFDIR' && \
$APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
-S SYSCONFDIR='$APXS_SYSCONFDIR' \
- -i -a -n php5"
+ -i -a -n php7"
fi
case $host_alias in
@@ -101,7 +101,7 @@ if test "$PHP_APXS2FILTER" != "no"; then
MH_BUNDLE_FLAGS="-bundle -bundle_loader $APXS_HTTPD $MH_BUNDLE_FLAGS"
PHP_SUBST(MH_BUNDLE_FLAGS)
PHP_SELECT_SAPI(apache2filter, bundle, sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
- SAPI_SHARED=libs/libphp5.so
+ SAPI_SHARED=libs/libphp7.so
INSTALL_IT="$INSTALL_IT $SAPI_SHARED"
;;
*beos*)
diff --git a/sapi/apache2filter/php.sym b/sapi/apache2filter/php.sym
index 9ad0f0a0ad..1469b0314d 100644
--- a/sapi/apache2filter/php.sym
+++ b/sapi/apache2filter/php.sym
@@ -1 +1 @@
-php5_module
+php7_module
diff --git a/sapi/apache2filter/php_apache.h b/sapi/apache2filter/php_apache.h
index 8410414dc0..7918cf6de8 100644
--- a/sapi/apache2filter/php_apache.h
+++ b/sapi/apache2filter/php_apache.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -26,7 +26,7 @@
#include "http_core.h"
/* Declare this so we can get to it from outside the sapi_apache2.c file */
-extern module AP_MODULE_DECLARE_DATA php5_module;
+extern module AP_MODULE_DECLARE_DATA php7_module;
/* A way to specify the location of the php.ini dir in an apache directive */
extern char *apache2_php_ini_path_override;
diff --git a/sapi/apache2filter/php_functions.c b/sapi/apache2filter/php_functions.c
index f1ae9c974b..ea137384f2 100644
--- a/sapi/apache2filter/php_functions.c
+++ b/sapi/apache2filter/php_functions.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -22,7 +22,7 @@
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
#include "php.h"
-#include "ext/standard/php_smart_str.h"
+#include "zend_smart_str.h"
#include "ext/standard/info.h"
#include "SAPI.h"
@@ -93,7 +93,7 @@ PHP_FUNCTION(virtual)
#define ADD_TIME(name) \
add_property_long(return_value, #name, apr_time_sec(rr->name));
#define ADD_STRING(name) \
- if (rr->name) add_property_string(return_value, #name, (char *) rr->name, 1)
+ if (rr->name) add_property_string(return_value, #name, (char *) rr->name)
PHP_FUNCTION(apache_lookup_uri)
{
@@ -163,7 +163,7 @@ PHP_FUNCTION(apache_request_headers)
APR_ARRAY_FOREACH_OPEN(arr, key, val)
if (!val) val = "";
- add_assoc_string(return_value, key, val, 1);
+ add_assoc_string(return_value, key, val);
APR_ARRAY_FOREACH_CLOSE()
}
/* }}} */
@@ -183,7 +183,7 @@ PHP_FUNCTION(apache_response_headers)
APR_ARRAY_FOREACH_OPEN(arr, key, val)
if (!val) val = "";
- add_assoc_string(return_value, key, val, 1);
+ add_assoc_string(return_value, key, val);
APR_ARRAY_FOREACH_CLOSE()
}
/* }}} */
@@ -313,9 +313,9 @@ PHP_FUNCTION(apache_get_modules)
for (n = 0; ap_loaded_modules[n]; ++n) {
char *s = (char *) ap_loaded_modules[n]->name;
if ((p = strchr(s, '.'))) {
- add_next_index_stringl(return_value, s, (p - s), 1);
+ add_next_index_stringl(return_value, s, (p - s));
} else {
- add_next_index_string(return_value, s, 1);
+ add_next_index_string(return_value, s);
}
}
}
diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c
index d5bf0d8646..389686124d 100644
--- a/sapi/apache2filter/sapi_apache2.c
+++ b/sapi/apache2filter/sapi_apache2.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -30,7 +30,7 @@
#include "php_variables.h"
#include "SAPI.h"
-#include "ext/standard/php_smart_str.h"
+#include "zend_smart_str.h"
#ifndef NETWARE
#include "ext/standard/php_standard.h"
#else
@@ -248,14 +248,13 @@ php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC)
}
static void
-php_apache_sapi_flush(void *server_context)
+php_apache_sapi_flush(void *server_context TSRMLS_DC)
{
php_struct *ctx;
apr_bucket_brigade *bb;
apr_bucket_alloc_t *ba;
apr_bucket *b;
ap_filter_t *f; /* output filters */
- TSRMLS_FETCH();
ctx = server_context;
@@ -457,7 +456,7 @@ static void php_apache_request_dtor(ap_filter_t *f TSRMLS_DC)
static int php_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
{
php_struct *ctx;
- void *conf = ap_get_module_config(f->r->per_dir_config, &php5_module);
+ void *conf = ap_get_module_config(f->r->per_dir_config, &php7_module);
char *p = get_php_config(conf, "engine", sizeof("engine"));
zend_file_handle zfd;
php_apr_bucket_brigade *pbb;
@@ -741,7 +740,7 @@ static size_t php_apache_fsizer_stream(void *handle TSRMLS_DC)
return 0;
}
-AP_MODULE_DECLARE_DATA module php5_module = {
+AP_MODULE_DECLARE_DATA module php7_module = {
STANDARD20_MODULE_STUFF,
create_php_config, /* create per-directory config structure */
merge_php_config, /* merge per-directory config structures */
diff --git a/sapi/apache2handler/apache_config.c b/sapi/apache2handler/apache_config.c
index 76d3ee2264..9eed8dba0f 100644
--- a/sapi/apache2handler/apache_config.c
+++ b/sapi/apache2handler/apache_config.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -70,7 +70,7 @@ static const char *real_value_hnd(cmd_parms *cmd, void *dummy, const char *name,
e.status = status;
e.htaccess = ((cmd->override & (RSRC_CONF|ACCESS_CONF)) == 0);
- zend_hash_update(&d->config, (char *) name, strlen(name) + 1, &e, sizeof(e), NULL);
+ zend_hash_str_update_mem(&d->config, (char *) name, strlen(name), &e, sizeof(e));
return NULL;
}
@@ -117,11 +117,12 @@ static const char *php_apache_phpini_set(cmd_parms *cmd, void *mconfig, const ch
return NULL;
}
-static zend_bool should_overwrite_per_dir_entry(HashTable *target_ht, php_dir_entry *new_per_dir_entry, zend_hash_key *hash_key, void *pData)
+static zend_bool should_overwrite_per_dir_entry(HashTable *target_ht, zval *zv, zend_hash_key *hash_key, void *pData)
{
+ php_dir_entry *new_per_dir_entry = Z_PTR_P(zv);
php_dir_entry *orig_per_dir_entry;
- if (zend_hash_find(target_ht, hash_key->arKey, hash_key->nKeyLength, (void **) &orig_per_dir_entry)==FAILURE) {
+ if ((orig_per_dir_entry = zend_hash_find_ptr(target_ht, hash_key->key)) == NULL) {
return 1; /* does not exist in dest, copy from source */
}
@@ -148,10 +149,12 @@ void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf)
n = create_php_config(p, "merge_php_config");
/* copy old config */
- zend_hash_copy(&n->config, &d->config, NULL, NULL, sizeof(php_dir_entry));
+ zend_hash_copy(&n->config, &d->config, NULL);
+//??? zend_hash_copy(&n->config, &d->config, NULL, NULL, sizeof(php_dir_entry));
/* merge new config */
phpapdebug((stderr, "Merge dir (%p)+(%p)=(%p)\n", base_conf, new_conf, n));
- zend_hash_merge_ex(&n->config, &e->config, NULL, sizeof(php_dir_entry), (merge_checker_func_t) should_overwrite_per_dir_entry, NULL);
+ zend_hash_merge_ex(&n->config, &e->config, NULL, should_overwrite_per_dir_entry, NULL);
+//??? zend_hash_merge_ex(&n->config, &e->config, NULL, sizeof(php_dir_entry), (merge_checker_func_t) should_overwrite_per_dir_entry, NULL);
#if STAS_0
for (zend_hash_internal_pointer_reset(&d->config);
zend_hash_get_current_key_ex(&d->config, &str, &str_len,
@@ -174,7 +177,7 @@ char *get_php_config(void *conf, char *name, size_t name_len)
php_conf_rec *d = conf;
php_dir_entry *pe;
- if (zend_hash_find(&d->config, name, name_len, (void **) &pe) == SUCCESS) {
+ if ((pe = zend_hash_str_find_ptr(&d->config, name, name_len)) != NULL) {
return pe->value;
}
@@ -184,21 +187,15 @@ char *get_php_config(void *conf, char *name, size_t name_len)
void apply_config(void *dummy)
{
php_conf_rec *d = dummy;
- char *str;
- uint str_len;
+ zend_string *str;
php_dir_entry *data;
- for (zend_hash_internal_pointer_reset(&d->config);
- zend_hash_get_current_key_ex(&d->config, &str, &str_len, NULL, 0,
- NULL) == HASH_KEY_IS_STRING;
- zend_hash_move_forward(&d->config)) {
- if (zend_hash_get_current_data(&d->config, (void **) &data) == SUCCESS) {
- phpapdebug((stderr, "APPLYING (%s)(%s)\n", str, data->value));
- if (zend_alter_ini_entry(str, str_len, data->value, data->value_len, data->status, data->htaccess?PHP_INI_STAGE_HTACCESS:PHP_INI_STAGE_ACTIVATE) == FAILURE) {
- phpapdebug((stderr, "..FAILED\n"));
- }
+ ZEND_HASH_FOREACH_STR_KEY_PTR(&d->config, str, data) {
+ phpapdebug((stderr, "APPLYING (%s)(%s)\n", str, data->value));
+ if (zend_alter_ini_entry_chars(str, data->value, data->value_len, data->status, data->htaccess?PHP_INI_STAGE_HTACCESS:PHP_INI_STAGE_ACTIVATE) == FAILURE) {
+ phpapdebug((stderr, "..FAILED\n"));
}
- }
+ } ZEND_HASH_FOREACH_END();
}
const command_rec php_dir_cmds[] =
diff --git a/sapi/apache2handler/config.m4 b/sapi/apache2handler/config.m4
index 02f8a0b3ad..59e17393dd 100644
--- a/sapi/apache2handler/config.m4
+++ b/sapi/apache2handler/config.m4
@@ -70,20 +70,20 @@ if test "$PHP_APXS2" != "no"; then
if test -z `$APXS -q SYSCONFDIR`; then
INSTALL_IT="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
$APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
- -i -n php5"
+ -i -n php7"
else
APXS_SYSCONFDIR='$(INSTALL_ROOT)'`$APXS -q SYSCONFDIR`
INSTALL_IT="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
\$(mkinstalldirs) '$APXS_SYSCONFDIR' && \
$APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
-S SYSCONFDIR='$APXS_SYSCONFDIR' \
- -i -a -n php5"
+ -i -a -n php7"
fi
case $host_alias in
*aix*)
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-brtl -Wl,-bI:$APXS_LIBEXECDIR/httpd.exp"
- PHP_SELECT_SAPI(apache2handler, shared, mod_php5.c sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
+ PHP_SELECT_SAPI(apache2handler, shared, mod_php7.c sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL"
;;
*darwin*)
@@ -99,19 +99,19 @@ if test "$PHP_APXS2" != "no"; then
fi
MH_BUNDLE_FLAGS="-bundle -bundle_loader $APXS_HTTPD $MH_BUNDLE_FLAGS"
PHP_SUBST(MH_BUNDLE_FLAGS)
- PHP_SELECT_SAPI(apache2handler, bundle, mod_php5.c sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
- SAPI_SHARED=libs/libphp5.so
+ PHP_SELECT_SAPI(apache2handler, bundle, mod_php7.c sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
+ SAPI_SHARED=libs/libphp7.so
INSTALL_IT="$INSTALL_IT $SAPI_SHARED"
;;
*beos*)
if test -f _APP_; then `rm _APP_`; fi
`ln -s $APXS_BINDIR/httpd _APP_`
EXTRA_LIBS="$EXTRA_LIBS _APP_"
- PHP_SELECT_SAPI(apache2handler, shared, mod_php5.c sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
+ PHP_SELECT_SAPI(apache2handler, shared, mod_php7.c sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL"
;;
*)
- PHP_SELECT_SAPI(apache2handler, shared, mod_php5.c sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
+ PHP_SELECT_SAPI(apache2handler, shared, mod_php7.c sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL"
;;
esac
diff --git a/sapi/apache2handler/config.w32 b/sapi/apache2handler/config.w32
index a7547514d8..d15dcfaf03 100644
--- a/sapi/apache2handler/config.w32
+++ b/sapi/apache2handler/config.w32
@@ -11,7 +11,7 @@ if (PHP_APACHE2HANDLER != "no") {
CHECK_LIB("libapr.lib", "apache2handler", PHP_PHP_BUILD + "\\lib\\apache2") &&
CHECK_LIB("libaprutil.lib", "apache2handler", PHP_PHP_BUILD + "\\lib\\apache2")
) {
- SAPI('apache2handler', 'mod_php5.c sapi_apache2.c apache_config.c php_functions.c',
+ SAPI('apache2handler', 'mod_php7.c sapi_apache2.c apache_config.c php_functions.c',
'php' + PHP_VERSION + 'apache2.dll',
'/D PHP_APACHE2_EXPORTS /I win32');
} else {
@@ -29,7 +29,7 @@ if (PHP_APACHE2_2HANDLER != "no") {
CHECK_LIB("libapr-1.lib", "apache2_2handler", PHP_PHP_BUILD + "\\lib\\apache2_2") &&
CHECK_LIB("libaprutil-1.lib", "apache2_2handler", PHP_PHP_BUILD + "\\lib\\apache2_2")
) {
- SAPI('apache2_2handler', 'mod_php5.c sapi_apache2.c apache_config.c php_functions.c',
+ SAPI('apache2_2handler', 'mod_php7.c sapi_apache2.c apache_config.c php_functions.c',
'php' + PHP_VERSION + 'apache2_2.dll',
'/D PHP_APACHE2_EXPORTS /I win32',
'sapi\\apache2_2handler');
@@ -47,7 +47,7 @@ if (PHP_APACHE2_4HANDLER != "no") {
CHECK_LIB("libapr-1.lib", "apache2_4handler", PHP_PHP_BUILD + "\\lib\\apache2_4") &&
CHECK_LIB("libaprutil-1.lib", "apache2_4handler", PHP_PHP_BUILD + "\\lib\\apache2_4")
) {
- SAPI('apache2_4handler', 'mod_php5.c sapi_apache2.c apache_config.c php_functions.c',
+ SAPI('apache2_4handler', 'mod_php7.c sapi_apache2.c apache_config.c php_functions.c',
'php' + PHP_VERSION + 'apache2_4.dll',
'/D PHP_APACHE2_EXPORTS /I win32',
'sapi\\apache2handler');
diff --git a/sapi/apache2handler/mod_php5.c b/sapi/apache2handler/mod_php7.c
index 4a01ebfd5f..ddc98e153c 100644
--- a/sapi/apache2handler/mod_php5.c
+++ b/sapi/apache2handler/mod_php7.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -25,7 +25,7 @@
#include "php.h"
#include "php_apache.h"
-AP_MODULE_DECLARE_DATA module php5_module = {
+AP_MODULE_DECLARE_DATA module php7_module = {
STANDARD20_MODULE_STUFF,
create_php_config, /* create per-directory config structure */
merge_php_config, /* merge per-directory config structures */
diff --git a/sapi/apache2handler/php.sym b/sapi/apache2handler/php.sym
index 9ad0f0a0ad..1469b0314d 100644
--- a/sapi/apache2handler/php.sym
+++ b/sapi/apache2handler/php.sym
@@ -1 +1 @@
-php5_module
+php7_module
diff --git a/sapi/apache2handler/php5apache2.dsp b/sapi/apache2handler/php5apache2.dsp
deleted file mode 100644
index 40cd58cb92..0000000000
--- a/sapi/apache2handler/php5apache2.dsp
+++ /dev/null
@@ -1,146 +0,0 @@
-# Microsoft Developer Studio Project File - Name="php5apache2" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=php5apache2 - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php5apache2.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php5apache2.mak" CFG="php5apache2 - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php5apache2 - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php5apache2 - Win32 Release_TS_inline" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php5apache2 - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php5apache2 - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP_APACHE2_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "NDEBUG" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "WIN32" /D "_MBCS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x407 /d "NDEBUG"
-# ADD RSC /l 0x407 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 php5ts.lib libhttpd.lib libapr.lib libaprutil.lib 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 /libpath:"..\..\Release_TS" /libpath:"..\..\TSRM\Release_TS" /libpath:"..\..\Zend\Release_TS"
-
-!ELSEIF "$(CFG)" == "php5apache2 - Win32 Release_TS_inline"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS_inline"
-# PROP BASE Intermediate_Dir "Release_TS_inline"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS_inline"
-# PROP Intermediate_Dir "Release_TS_inline"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP_APACHE2_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "ZEND_WIN32_FORCE_INLINE" /D "NDEBUG" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "WIN32" /D "_MBCS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x407 /d "NDEBUG"
-# ADD RSC /l 0x407 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 php5ts.lib libhttpd.lib libapr.lib libaprutil.lib 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 /out:"..\..\Release_TS_inline/php5apache2.dll" /libpath:"..\..\Release_TS_inline" /libpath:"..\..\TSRM\Release_TS_inline" /libpath:"..\..\Zend\Release_TS_inline"
-
-!ELSEIF "$(CFG)" == "php5apache2 - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\..\Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP_APACHE2_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\TSRM" /D "_DEBUG" /D ZEND_DEBUG=1 /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "WIN32" /D "_MBCS" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x407 /d "_DEBUG"
-# ADD RSC /l 0x407 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 php5ts_debug.lib libhttpd.lib libapr.lib libaprutil.lib 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 /libpath:"..\..\Debug_TS" /libpath:"..\..\TSRM\Debug_TS" /libpath:"..\..\Zend\Debug_TS"
-
-!ENDIF
-
-# Begin Target
-
-# Name "php5apache2 - Win32 Release_TS"
-# Name "php5apache2 - Win32 Release_TS_inline"
-# Name "php5apache2 - Win32 Debug_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\apache_config.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mod_php5.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_functions.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\sapi_apache2.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\php_apache.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/sapi/apache2handler/php_apache.h b/sapi/apache2handler/php_apache.h
index 34846048b0..f6f4f7a7c9 100644
--- a/sapi/apache2handler/php_apache.h
+++ b/sapi/apache2handler/php_apache.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -25,8 +25,11 @@
#include "http_config.h"
#include "http_core.h"
+#include "php.h"
+#include "main/php_streams.h"
+
/* Declare this so we can get to it from outside the sapi_apache2.c file */
-extern module AP_MODULE_DECLARE_DATA php5_module;
+extern module AP_MODULE_DECLARE_DATA php7_module;
/* A way to specify the location of the php.ini dir in an apache directive */
extern char *apache2_php_ini_path_override;
@@ -40,7 +43,7 @@ typedef struct php_struct {
#if defined(NETWARE) && defined(CLIB_STAT_PATCH)
struct stat_libc finfo;
#else
- struct stat finfo;
+ zend_stat_t finfo;
#endif
/* Whether or not we've processed PHP in the output filters yet. */
int request_processed;
diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c
index 2c57300926..d9ae4d97ea 100644
--- a/sapi/apache2handler/php_functions.c
+++ b/sapi/apache2handler/php_functions.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -21,7 +21,7 @@
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
#include "php.h"
-#include "ext/standard/php_smart_str.h"
+#include "zend_smart_str.h"
#include "ext/standard/info.h"
#include "ext/standard/head.h"
#include "php_ini.h"
@@ -72,7 +72,7 @@ static request_rec *php_apache_lookup_uri(char *filename TSRMLS_DC)
PHP_FUNCTION(virtual)
{
char *filename;
- int filename_len;
+ size_t filename_len;
request_rec *rr;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
@@ -113,13 +113,13 @@ PHP_FUNCTION(virtual)
#define ADD_TIME(name) \
add_property_long(return_value, #name, apr_time_sec(rr->name));
#define ADD_STRING(name) \
- if (rr->name) add_property_string(return_value, #name, (char *) rr->name, 1)
+ if (rr->name) add_property_string(return_value, #name, (char *) rr->name)
PHP_FUNCTION(apache_lookup_uri)
{
request_rec *rr;
char *filename;
- int filename_len;
+ size_t filename_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
return;
@@ -187,7 +187,7 @@ PHP_FUNCTION(apache_request_headers)
APR_ARRAY_FOREACH_OPEN(arr, key, val)
if (!val) val = "";
- add_assoc_string(return_value, key, val, 1);
+ add_assoc_string(return_value, key, val);
APR_ARRAY_FOREACH_CLOSE()
}
/* }}} */
@@ -211,7 +211,7 @@ PHP_FUNCTION(apache_response_headers)
APR_ARRAY_FOREACH_OPEN(arr, key, val)
if (!val) val = "";
- add_assoc_string(return_value, key, val, 1);
+ add_assoc_string(return_value, key, val);
APR_ARRAY_FOREACH_CLOSE()
}
/* }}} */
@@ -222,7 +222,7 @@ PHP_FUNCTION(apache_note)
{
php_struct *ctx;
char *note_name, *note_val = NULL;
- int note_name_len, note_val_len;
+ size_t note_name_len, note_val_len;
char *old_note_val=NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &note_name, &note_name_len, &note_val, &note_val_len) == FAILURE) {
@@ -238,7 +238,7 @@ PHP_FUNCTION(apache_note)
}
if (old_note_val) {
- RETURN_STRING(old_note_val, 1);
+ RETURN_STRING(old_note_val);
}
RETURN_FALSE;
@@ -254,7 +254,7 @@ PHP_FUNCTION(apache_setenv)
{
php_struct *ctx;
char *variable=NULL, *string_val=NULL;
- int variable_len, string_val_len;
+ size_t variable_len, string_val_len;
zend_bool walk_to_top = 0;
int arg_count = ZEND_NUM_ARGS();
request_rec *r;
@@ -313,7 +313,7 @@ PHP_FUNCTION(apache_getenv)
env_val = (char*) apr_table_get(r->subprocess_env, variable);
if (env_val != NULL) {
- RETURN_STRING(env_val, 1);
+ RETURN_STRING(env_val);
}
RETURN_FALSE;
@@ -336,7 +336,7 @@ PHP_FUNCTION(apache_get_version)
char *apv = php_apache_get_version();
if (apv && *apv) {
- RETURN_STRING(apv, 1);
+ RETURN_STRING(apv);
} else {
RETURN_FALSE;
}
@@ -355,9 +355,9 @@ PHP_FUNCTION(apache_get_modules)
for (n = 0; ap_loaded_modules[n]; ++n) {
char *s = (char *) ap_loaded_modules[n]->name;
if ((p = strchr(s, '.'))) {
- add_next_index_stringl(return_value, s, (p - s), 1);
+ add_next_index_stringl(return_value, s, (p - s));
} else {
- add_next_index_string(return_value, s, 1);
+ add_next_index_string(return_value, s);
}
}
}
@@ -388,8 +388,8 @@ PHP_MINFO_FUNCTION(apache)
}
smart_str_appendc(&tmp1, ' ');
}
- if ((tmp1.len - 1) >= 0) {
- tmp1.c[tmp1.len - 1] = '\0';
+ if (tmp1.s && (tmp1.s->len - 1) >= 0) {
+ tmp1.s->val[tmp1.s->len - 1] = '\0';
}
php_info_print_table_start();
@@ -426,7 +426,7 @@ PHP_MINFO_FUNCTION(apache)
php_info_print_table_row(2, "Virtual Server", (serv->is_virtual ? "Yes" : "No"));
php_info_print_table_row(2, "Server Root", ap_server_root);
- php_info_print_table_row(2, "Loaded Modules", tmp1.c);
+ php_info_print_table_row(2, "Loaded Modules", tmp1.s->val);
smart_str_free(&tmp1);
php_info_print_table_end();
diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c
index a0c24bd0e3..fe200304fd 100644
--- a/sapi/apache2handler/sapi_apache2.c
+++ b/sapi/apache2handler/sapi_apache2.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -30,7 +30,7 @@
#include <fcntl.h>
-#include "ext/standard/php_smart_str.h"
+#include "zend_smart_str.h"
#ifndef NETWARE
#include "ext/standard/php_standard.h"
#else
@@ -67,13 +67,13 @@
#define PHP_MAGIC_TYPE "application/x-httpd-php"
#define PHP_SOURCE_MAGIC_TYPE "application/x-httpd-php-source"
-#define PHP_SCRIPT "php5-script"
+#define PHP_SCRIPT "php7-script"
/* A way to specify the location of the php.ini dir in an apache directive */
char *apache2_php_ini_path_override = NULL;
-static int
-php_apache_sapi_ub_write(const char *str, uint str_length TSRMLS_DC)
+static size_t
+php_apache_sapi_ub_write(const char *str, size_t str_length TSRMLS_DC)
{
request_rec *r;
php_struct *ctx;
@@ -180,8 +180,8 @@ php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
return SAPI_HEADER_SENT_SUCCESSFULLY;
}
-static int
-php_apache_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC)
+static apr_size_t
+php_apache_sapi_read_post(char *buf, size_t count_bytes TSRMLS_DC)
{
apr_size_t len, tlen=0;
php_struct *ctx = SG(server_context);
@@ -212,7 +212,7 @@ php_apache_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC)
return tlen;
}
-static struct stat*
+static zend_stat_t*
php_apache_sapi_get_stat(TSRMLS_D)
{
php_struct *ctx = SG(server_context);
@@ -270,28 +270,27 @@ php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC)
php_struct *ctx = SG(server_context);
const apr_array_header_t *arr = apr_table_elts(ctx->r->subprocess_env);
char *key, *val;
- int new_val_len;
+ size_t new_val_len;
APR_ARRAY_FOREACH_OPEN(arr, key, val)
if (!val) {
val = "";
}
- if (sapi_module.input_filter(PARSE_SERVER, key, &val, strlen(val), (unsigned int *)&new_val_len TSRMLS_CC)) {
+ if (sapi_module.input_filter(PARSE_SERVER, key, &val, strlen(val), (size_t *)&new_val_len TSRMLS_CC)) {
php_register_variable_safe(key, val, new_val_len, track_vars_array TSRMLS_CC);
}
APR_ARRAY_FOREACH_CLOSE()
- if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &ctx->r->uri, strlen(ctx->r->uri), (unsigned int *)&new_val_len TSRMLS_CC)) {
+ if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &ctx->r->uri, strlen(ctx->r->uri), (size_t *)&new_val_len TSRMLS_CC)) {
php_register_variable_safe("PHP_SELF", ctx->r->uri, new_val_len, track_vars_array TSRMLS_CC);
}
}
static void
-php_apache_sapi_flush(void *server_context)
+php_apache_sapi_flush(void *server_context TSRMLS_DC)
{
php_struct *ctx;
request_rec *r;
- TSRMLS_FETCH();
ctx = server_context;
@@ -483,7 +482,11 @@ static int php_apache_request_ctor(request_rec *r, php_struct *ctx TSRMLS_DC)
r->no_local_copy = 1;
content_length = (char *) apr_table_get(r->headers_in, "Content-Length");
- SG(request_info).content_length = (content_length ? atol(content_length) : 0);
+ if (content_length) {
+ ZEND_ATOL(SG(request_info).content_length, content_length);
+ } else {
+ SG(request_info).content_length = 0;
+ }
apr_table_unset(r->headers_out, "Content-Length");
apr_table_unset(r->headers_out, "Last-Modified");
@@ -515,16 +518,12 @@ static void php_apache_ini_dtor(request_rec *r, request_rec *p TSRMLS_DC)
typedef struct {
HashTable config;
} php_conf_rec;
- char *str;
- uint str_len;
- php_conf_rec *c = ap_get_module_config(r->per_dir_config, &php5_module);
-
- for (zend_hash_internal_pointer_reset(&c->config);
- zend_hash_get_current_key_ex(&c->config, &str, &str_len, NULL, 0, NULL) == HASH_KEY_IS_STRING;
- zend_hash_move_forward(&c->config)
- ) {
- zend_restore_ini_entry(str, str_len, ZEND_INI_STAGE_SHUTDOWN);
- }
+ zend_string *str;
+ php_conf_rec *c = ap_get_module_config(r->per_dir_config, &php7_module);
+
+ ZEND_HASH_FOREACH_STR_KEY(&c->config, str) {
+ zend_restore_ini_entry(str, ZEND_INI_STAGE_SHUTDOWN);
+ } ZEND_HASH_FOREACH_END();
}
if (p) {
((php_struct *)SG(server_context))->r = p;
@@ -545,7 +544,7 @@ static int php_handler(request_rec *r)
#define PHPAP_INI_OFF php_apache_ini_dtor(r, parent_req TSRMLS_CC);
- conf = ap_get_module_config(r->per_dir_config, &php5_module);
+ conf = ap_get_module_config(r->per_dir_config, &php7_module);
/* apply_config() needs r in some cases, so allocate server_context early */
ctx = SG(server_context);
diff --git a/sapi/apache_hooks/apMakefile.tmpl b/sapi/apache_hooks/apMakefile.tmpl
index 4054e8e119..1e5e465f65 100644
--- a/sapi/apache_hooks/apMakefile.tmpl
+++ b/sapi/apache_hooks/apMakefile.tmpl
@@ -1,38 +1,38 @@
##
## Apache 1.3 Makefile template for PHP 4.0 Module
-## [src/modules/php5/Makefile.tmpl]
+## [src/modules/php7/Makefile.tmpl]
##
# the parametrized target
-LIB=libphp5.$(LIBEXT)
+LIB=libphp7.$(LIBEXT)
# objects for building the static library
-OBJS=mod_php5.o
-OBJS_LIB=libmodphp5.a
+OBJS=mod_php7.o
+OBJS_LIB=libmodphp7.a
# objects for building the shared object library
-SHLIB_OBJS=mod_php5.so-o
-SHLIB_OBJS_LIB=libmodphp5.a
+SHLIB_OBJS=mod_php7.so-o
+SHLIB_OBJS_LIB=libmodphp7.a
# the general targets
all: lib
lib: $(LIB)
# build the static library by merging the object files
-libphp5.a: $(OBJS) $(OBJS_LIB)
+libphp7.a: $(OBJS) $(OBJS_LIB)
cp $(OBJS_LIB) $@
ar r $@ $(OBJS)
$(RANLIB) $@
# ugly hack to support older Apache-1.3 betas that don't set $LIBEXT
-libphp5.: $(OBJS) $(OBJS_LIB)
+libphp7.: $(OBJS) $(OBJS_LIB)
cp $(OBJS_LIB) $@
ar r $@ $(OBJS)
$(RANLIB) $@
- cp libphp5. libphp5.a
+ cp libphp7. libphp7.a
# build the shared object library by linking the object files
-libphp5.so: $(SHLIB_OBJS) $(SHLIB_OBJS_LIB)
+libphp7.so: $(SHLIB_OBJS) $(SHLIB_OBJS_LIB)
rm -f $@
$(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $(SHLIB_OBJS) $(SHLIB_OBJS_LIB) $(LIBS) $(PHP_LIBS)
@@ -69,9 +69,9 @@ depend:
$(OBJS): Makefile
# DO NOT REMOVE
-mod_php5.o: mod_php5.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \
+mod_php7.o: mod_php7.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \
$(INCDIR)/buff.h \
$(INCDIR)/http_config.h \
$(INCDIR)/http_core.h $(INCDIR)/http_main.h \
$(INCDIR)/http_protocol.h $(INCDIR)/http_request.h \
- $(INCDIR)/http_log.h $(INCDIR)/util_script.h mod_php5.h
+ $(INCDIR)/http_log.h $(INCDIR)/util_script.h mod_php7.h
diff --git a/sapi/apache_hooks/config.m4 b/sapi/apache_hooks/config.m4
index e2c71b4274..a1ee213492 100644
--- a/sapi/apache_hooks/config.m4
+++ b/sapi/apache_hooks/config.m4
@@ -79,7 +79,7 @@ if test "$PHP_APACHE_HOOKS" != "no"; then
*darwin*)
MH_BUNDLE_FLAGS="-dynamic -twolevel_namespace -bundle -bundle_loader $APXS_HTTPD"
PHP_SUBST(MH_BUNDLE_FLAGS)
- SAPI_SHARED=libs/libphp5.so
+ SAPI_SHARED=libs/libphp7.so
build_type=bundle
;;
*)
@@ -87,26 +87,26 @@ if test "$PHP_APACHE_HOOKS" != "no"; then
;;
esac
- PHP_SELECT_SAPI(apache_hooks, $build_type, sapi_apache.c mod_php5.c php_apache.c, $APACHE_CPPFLAGS -I$APXS_INCLUDEDIR)
+ PHP_SELECT_SAPI(apache_hooks, $build_type, sapi_apache.c mod_php7.c php_apache.c, $APACHE_CPPFLAGS -I$APXS_INCLUDEDIR)
# Test whether apxs support -S option
$APXS -q -S CFLAGS="$APXS_CFLAGS" CFLAGS >/dev/null 2>&1
if test "$?" != "0"; then
- APACHE_HOOKS_INSTALL="$APXS -i -a -n php5 $SAPI_SHARED" # Old apxs does not have -S option
+ APACHE_HOOKS_INSTALL="$APXS -i -a -n php7 $SAPI_SHARED" # Old apxs does not have -S option
else
APXS_LIBEXECDIR='$(INSTALL_ROOT)'`$APXS -q LIBEXECDIR`
if test -z `$APXS -q SYSCONFDIR`; then
APACHE_HOOKS_INSTALL="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
$APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
- -i -n php5 $SAPI_SHARED"
+ -i -n php7 $SAPI_SHARED"
else
APXS_SYSCONFDIR='$(INSTALL_ROOT)'`$APXS -q SYSCONFDIR`
APACHE_HOOKS_INSTALL="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
\$(mkinstalldirs) '$APXS_SYSCONFDIR' && \
$APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
-S SYSCONFDIR='$APXS_SYSCONFDIR' \
- -i -a -n php5 $SAPI_SHARED"
+ -i -a -n php7 $SAPI_SHARED"
fi
fi
@@ -137,7 +137,7 @@ if test "$PHP_SAPI" != "apache" && test "$PHP_SAPI" != "apache_hooks" && test "$
PHP_APACHE_HOOKS_STATIC=/usr/local/apache
fi
- APACHE_HOOKS_INSTALL_FILES="\$(srcdir)/sapi/apache_hooks/mod_php5.* sapi/apache_hooks/libphp5.module"
+ APACHE_HOOKS_INSTALL_FILES="\$(srcdir)/sapi/apache_hooks/mod_php7.* sapi/apache_hooks/libphp7.module"
AC_DEFINE(HAVE_APACHE,1,[ ])
APACHE_HOOKS_MODULE=yes
@@ -146,7 +146,7 @@ if test "$PHP_SAPI" != "apache" && test "$PHP_SAPI" != "apache_hooks" && test "$
if test -f $PHP_APACHE_HOOKS_STATIC/src/httpd.h; then
APACHE_INCLUDE=-I$PHP_APACHE_HOOKS_STATIC/src
APACHE_TARGET=$PHP_APACHE_HOOKS_STATIC/src
- PHP_SELECT_SAPI(apache_hooks, static, sapi_apache.c mod_php5.c php_apache.c, $APACHE_INCLUDE)
+ PHP_SELECT_SAPI(apache_hooks, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
APACHE_HOOKS_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_HOOKS_INSTALL_FILES $APACHE_TARGET"
PHP_LIBS="-L. -lphp3"
AC_MSG_RESULT([yes - Apache 1.2.x])
@@ -161,13 +161,13 @@ if test "$PHP_SAPI" != "apache" && test "$PHP_SAPI" != "apache_hooks" && test "$
elif test -f $PHP_APACHE_HOOKS_STATIC/src/main/httpd.h; then
APACHE_HAS_REGEX=1
APACHE_INCLUDE="-I$PHP_APACHE_HOOKS_STATIC/src/main -I$PHP_APACHE_HOOKS_STATIC/src/os/unix -I$PHP_APACHE_HOOKS_STATIC/src/ap"
- APACHE_TARGET=$PHP_APACHE_HOOKS_STATIC/src/modules/php5
+ APACHE_TARGET=$PHP_APACHE_HOOKS_STATIC/src/modules/php7
if test ! -d $APACHE_TARGET; then
mkdir $APACHE_TARGET
fi
- PHP_SELECT_SAPI(apache_hooks, static, sapi_apache.c mod_php5.c php_apache.c, $APACHE_INCLUDE)
- APACHE_HOOKS_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp5.a; cp $APACHE_HOOKS_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache_hooks/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache_hooks/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
- PHP_LIBS="-Lmodules/php5 -L../modules/php5 -L../../modules/php5 -lmodphp5"
+ PHP_SELECT_SAPI(apache_hooks, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
+ APACHE_HOOKS_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp7.a; cp $APACHE_HOOKS_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache_hooks/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache_hooks/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
+ PHP_LIBS="-Lmodules/php7 -L../modules/php7 -L../../modules/php7 -lmodphp7"
AC_MSG_RESULT([yes - Apache 1.3.x])
STRONGHOLD=
if test -f $PHP_APACHE_HOOKS_STATIC/src/include/ap_config.h; then
@@ -185,13 +185,13 @@ if test "$PHP_SAPI" != "apache" && test "$PHP_SAPI" != "apache_hooks" && test "$
elif test -f $PHP_APACHE_HOOKS_STATIC/src/include/httpd.h; then
APACHE_HAS_REGEX=1
APACHE_INCLUDE="-I$PHP_APACHE_HOOKS_STATIC/src/include -I$PHP_APACHE_HOOKS_STATIC/src/os/unix"
- APACHE_TARGET=$PHP_APACHE_HOOKS_STATIC/src/modules/php5
+ APACHE_TARGET=$PHP_APACHE_HOOKS_STATIC/src/modules/php7
if test ! -d $APACHE_TARGET; then
mkdir $APACHE_TARGET
fi
- PHP_SELECT_SAPI(apache_hooks, static, sapi_apache.c mod_php5.c php_apache.c, $APACHE_INCLUDE)
- PHP_LIBS="-Lmodules/php5 -L../modules/php5 -L../../modules/php5 -lmodphp5"
- APACHE_HOOKS_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp5.a; cp $APACHE_HOOKS_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache_hooks/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache_hooks/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
+ PHP_SELECT_SAPI(apache_hooks, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
+ PHP_LIBS="-Lmodules/php7 -L../modules/php7 -L../../modules/php7 -lmodphp7"
+ APACHE_HOOKS_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp7.a; cp $APACHE_HOOKS_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache_hooks/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache_hooks/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
AC_MSG_RESULT([yes - Apache 1.3.x])
STRONGHOLD=
if test -f $PHP_APACHE_HOOKS_STATIC/src/include/ap_config.h; then
@@ -209,9 +209,9 @@ if test "$PHP_SAPI" != "apache" && test "$PHP_SAPI" != "apache_hooks" && test "$
elif test -f $PHP_APACHE_HOOKS_STATIC/apache/httpd.h; then
APACHE_INCLUDE="-I$PHP_APACHE_HOOKS_STATIC/apache -I$PHP_APACHE_HOOKS_STATIC/ssl/include"
APACHE_TARGET=$PHP_APACHE_HOOKS_STATIC/apache
- PHP_SELECT_SAPI(apache_hooks, static, sapi_apache.c mod_php5.c php_apache.c, $APACHE_INCLUDE)
- PHP_LIBS="-Lmodules/php5 -L../modules/php5 -L../../modules/php5 -lmodphp5"
- APACHE_HOOKS_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp5.a; cp $APACHE_HOOKS_INSTALL_FILES $APACHE_TARGET"
+ PHP_SELECT_SAPI(apache_hooks, static, sapi_apache.c mod_php7.c php_apache.c, $APACHE_INCLUDE)
+ PHP_LIBS="-Lmodules/php7 -L../modules/php7 -L../../modules/php7 -lmodphp7"
+ APACHE_HOOKS_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp7.a; cp $APACHE_HOOKS_INSTALL_FILES $APACHE_TARGET"
STRONGHOLD=-DSTRONGHOLD=1
AC_MSG_RESULT([yes - StrongHold])
if test -f $PHP_APACHE_HOOKS_STATIC/apache/ap_config.h; then
@@ -249,13 +249,13 @@ dnl Build as static module
if test "$APACHE_HOOKS_MODULE" = "yes"; then
PHP_TARGET_RDYNAMIC
$php_shtool mkdir -p sapi/apache_hooks
- PHP_OUTPUT(sapi/apache_hooks/libphp5.module)
+ PHP_OUTPUT(sapi/apache_hooks/libphp7.module)
fi
dnl General
if test -n "$APACHE_HOOKS_INSTALL"; then
if test "x$APXS" != "x" -a "`uname -sv`" = "AIX 4" -a "$GCC" != "yes"; then
- APXS_EXP=-bE:sapi/apache_hooks/mod_php5.exp
+ APXS_EXP=-bE:sapi/apache_hooks/mod_php7.exp
fi
PHP_APACHE_FD_CHECK
diff --git a/sapi/apache_hooks/config.w32 b/sapi/apache_hooks/config.w32
index 85dc624d60..1c9129e615 100644
--- a/sapi/apache_hooks/config.w32
+++ b/sapi/apache_hooks/config.w32
@@ -12,9 +12,9 @@ if (PHP_APACHE_HOOKS != "no") {
";" + PHP_PHP_BUILD + "\\apache\\src\\corer")) {
// We need to play tricks to get our readdir.h used by apache
// headers
- SAPI('apache_hooks', 'mod_php5.c sapi_apache.c php_apache.c',
+ SAPI('apache_hooks', 'mod_php7.c sapi_apache.c php_apache.c',
'php' + PHP_VERSION + 'apache_hooks.dll',
- '/D APACHEPHP5_EXPORTS /D APACHE_READDIR_H /I win32');
+ '/D APACHEPHP7_EXPORTS /D APACHE_READDIR_H /I win32');
} else {
WARNING("Could not find apache libraries/headers");
}
diff --git a/sapi/apache_hooks/libphp5.module.in b/sapi/apache_hooks/libphp7.module.in
index 8488181897..5bea79ef95 100644
--- a/sapi/apache_hooks/libphp5.module.in
+++ b/sapi/apache_hooks/libphp7.module.in
@@ -1,4 +1,4 @@
-Name: php5_module
+Name: php7_module
ConfigStart
RULE_WANTHSREGEX=no
RULE_HIDE=yes
diff --git a/sapi/apache_hooks/mod_php5.exp b/sapi/apache_hooks/mod_php5.exp
deleted file mode 100644
index 9ad0f0a0ad..0000000000
--- a/sapi/apache_hooks/mod_php5.exp
+++ /dev/null
@@ -1 +0,0 @@
-php5_module
diff --git a/sapi/apache_hooks/mod_php5.c b/sapi/apache_hooks/mod_php7.c
index a069e324c1..33e0931fb6 100644
--- a/sapi/apache_hooks/mod_php5.c
+++ b/sapi/apache_hooks/mod_php7.c
@@ -84,11 +84,11 @@ static CONST_PREFIX char *php_apache_flag_handler(cmd_parms *cmd, php_per_dir_co
static CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode);
static CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1, char *arg2);
-/* ### these should be defined in mod_php5.h or somewhere else */
+/* ### these should be defined in mod_php7.h or somewhere else */
#define USE_PATH 1
#define IGNORE_URL 2
-module MODULE_VAR_EXPORT php5_module;
+module MODULE_VAR_EXPORT php7_module;
int saved_umask;
/* static int setup_env = 0; */
@@ -253,7 +253,7 @@ static int sapi_apache_ub_write(const char *str, uint str_length TSRMLS_DC)
/* {{{ sapi_apache_flush
*/
-static void sapi_apache_flush(void *server_context)
+static void sapi_apache_flush(void *server_context TSRMLS_DC)
{
if (server_context) {
#if MODULE_MAGIC_NUMBER > 19970110
@@ -667,7 +667,7 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
return DECLINED;
}
- per_dir_conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
+ per_dir_conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
if (per_dir_conf) {
zend_hash_apply((HashTable *) per_dir_conf->ini_settings, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);
}
@@ -934,7 +934,7 @@ static CONST_PREFIX char *php_set_server_handler(server_rec *s, char *arg1, long
handler->type = handler_type;
handler->stage = handler_stage;
handler->name = strdup(arg1);
- conf = get_module_config(s->module_config, &php5_module);
+ conf = get_module_config(s->module_config, &php7_module);
switch(handler_stage) {
case AP_URI_TRANS:
sapi_stack_push(&conf->uri_handlers, handler);
@@ -1184,7 +1184,7 @@ static int php_xbithack_handler(request_rec * r)
r->allowed |= (1 << METHODS) - 1;
return DECLINED;
}
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
+ conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
if (conf) {
zend_hash_apply((HashTable *) conf->ini_settings, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);
}
@@ -1266,7 +1266,7 @@ static int php_run_hook(php_handler *handler, request_rec *r)
TSRMLS_FETCH();
if(!AP(apache_config_loaded)) {
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
+ conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
if (conf)
zend_hash_apply((HashTable *)conf->ini_settings, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);
AP(apache_config_loaded) = 1;
@@ -1298,7 +1298,7 @@ static int php_uri_translation(request_rec *r)
php_per_server_config *conf;
TSRMLS_FETCH();
AP(current_hook) = AP_URI_TRANS;
- conf = (php_per_server_config *) get_module_config(r->server->module_config, &php5_module);
+ conf = (php_per_server_config *) get_module_config(r->server->module_config, &php7_module);
return sapi_stack_apply_with_argument_stop_if_equals(&conf->uri_handlers,
ZEND_STACK_APPLY_BOTTOMUP,
(int (*)(void *element, void *)) php_run_hook, r, OK);
@@ -1309,7 +1309,7 @@ static int php_header_hook(request_rec *r)
php_per_dir_config *conf;
TSRMLS_FETCH();
AP(current_hook) = AP_HEADER_PARSE;
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
+ conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
return sapi_stack_apply_with_argument_stop_if_http_error(&conf->headers_handlers,
ZEND_STACK_APPLY_BOTTOMUP,
(int (*)(void *element, void *)) php_run_hook, r);
@@ -1320,7 +1320,7 @@ static int php_auth_hook(request_rec *r)
php_per_dir_config *conf;
TSRMLS_FETCH();
AP(current_hook) = AP_AUTHENTICATION;
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
+ conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
return sapi_stack_apply_with_argument_stop_if_equals(&conf->auth_handlers,
ZEND_STACK_APPLY_BOTTOMUP,
(int (*)(void *element, void *)) php_run_hook, r, OK);
@@ -1332,7 +1332,7 @@ static int php_access_hook(request_rec *r)
int status = DECLINED;
TSRMLS_FETCH();
AP(current_hook) = AP_ACCESS_CONTROL;
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
+ conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
status = sapi_stack_apply_with_argument_stop_if_http_error(&conf->access_handlers,
ZEND_STACK_APPLY_BOTTOMUP,
(int (*)(void *element, void *)) php_run_hook, r);
@@ -1345,7 +1345,7 @@ static int php_type_hook(request_rec *r)
php_per_dir_config *conf;
TSRMLS_FETCH();
AP(current_hook) = AP_TYPE_CHECKING;
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
+ conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
return sapi_stack_apply_with_argument_stop_if_equals(&conf->type_handlers,
ZEND_STACK_APPLY_BOTTOMUP,
(int (*)(void *element, void *)) php_run_hook,
@@ -1357,7 +1357,7 @@ static int php_fixup_hook(request_rec *r)
php_per_dir_config *conf;
TSRMLS_FETCH();
AP(current_hook) = AP_FIXUP;
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
+ conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
return sapi_stack_apply_with_argument_stop_if_http_error(&conf->fixup_handlers,
ZEND_STACK_APPLY_BOTTOMUP,
(int (*)(void *element, void *)) php_run_hook,
@@ -1369,7 +1369,7 @@ static int php_logger_hook(request_rec *r)
php_per_dir_config *conf;
TSRMLS_FETCH();
AP(current_hook) = AP_LOGGING;
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
+ conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
return sapi_stack_apply_with_argument_stop_if_http_error(&conf->logger_handlers,
ZEND_STACK_APPLY_BOTTOMUP,
(int (*)(void *element, void *)) php_run_hook,
@@ -1382,11 +1382,11 @@ static int php_post_read_hook(request_rec *r)
php_per_server_config *svr;
TSRMLS_FETCH();
AP(current_hook) = AP_POST_READ;
- svr = get_module_config(r->server->module_config, &php5_module);
+ svr = get_module_config(r->server->module_config, &php7_module);
if(ap_is_initial_req(r)) {
sapi_stack_apply_with_argument_all(&svr->requires, ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_run_hook, r);
}
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
+ conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
return sapi_stack_apply_with_argument_stop_if_http_error(&conf->post_read_handlers,
ZEND_STACK_APPLY_BOTTOMUP,
(int (*)(void *element, void *)) php_run_hook, r);
@@ -1397,7 +1397,7 @@ static int php_response_handler(request_rec *r)
php_per_dir_config *conf;
TSRMLS_FETCH();
AP(current_hook) = AP_RESPONSE;
- conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
+ conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php7_module);
return sapi_stack_apply_with_argument_all(&conf->response_handlers, ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_run_hook, r);
}
@@ -1449,9 +1449,9 @@ command_rec php_commands[] =
};
/* }}} */
-/* {{{ module MODULE_VAR_EXPORT php5_module
+/* {{{ module MODULE_VAR_EXPORT php7_module
*/
-module MODULE_VAR_EXPORT php5_module =
+module MODULE_VAR_EXPORT php7_module =
{
STANDARD_MODULE_STUFF,
php_init_handler, /* initializer */
diff --git a/sapi/apache_hooks/mod_php7.exp b/sapi/apache_hooks/mod_php7.exp
new file mode 100644
index 0000000000..1469b0314d
--- /dev/null
+++ b/sapi/apache_hooks/mod_php7.exp
@@ -0,0 +1 @@
+php7_module
diff --git a/sapi/apache_hooks/mod_php5.h b/sapi/apache_hooks/mod_php7.h
index 3db828ec83..325ae1f721 100644
--- a/sapi/apache_hooks/mod_php5.h
+++ b/sapi/apache_hooks/mod_php7.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -17,8 +17,8 @@
*/
/* $Id$ */
-#ifndef MOD_PHP5_H
-#define MOD_PHP5_H
+#ifndef MOD_PHP7_H
+#define MOD_PHP7_H
#if !defined(WIN32) && !defined(WINNT)
#ifndef MODULE_VAR_EXPORT
@@ -78,7 +78,7 @@ extern php_apache_info_struct php_apache_info;
# define MODULE_VAR_EXPORT PHPAPI
#endif
-#endif /* MOD_PHP5_H */
+#endif /* MOD_PHP7_H */
/*
* Local variables:
diff --git a/sapi/apache_hooks/php.sym b/sapi/apache_hooks/php.sym
index 9ad0f0a0ad..1469b0314d 100644
--- a/sapi/apache_hooks/php.sym
+++ b/sapi/apache_hooks/php.sym
@@ -1 +1 @@
-php5_module
+php7_module
diff --git a/sapi/apache_hooks/php5apache_hooks.dsp b/sapi/apache_hooks/php5apache_hooks.dsp
deleted file mode 100755
index cc60f4b3b1..0000000000
--- a/sapi/apache_hooks/php5apache_hooks.dsp
+++ /dev/null
@@ -1,151 +0,0 @@
-# Microsoft Developer Studio Project File - Name="php5apache_hooks" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=php5apache_hooks - Win32 Release_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php5apache_hooks.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php5apache_hooks.mak" CFG="php5apache_hooks - Win32 Release_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php5apache_hooks - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php5apache_hooks - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php5apache_hooks - Win32 Release_TS_inline" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php5apache_hooks - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APACHEPHP5_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\..\regex" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\..\php_build\apache\src\include" /I "..\..\main" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "NDEBUG" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "APACHEPHP5_EXPORTS" /D "WIN32" /D "_MBCS" /D "APACHE_READDIR_H" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 php5ts.lib ApacheCore.lib 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 /base:"0x60000000" /version:4.0 /dll /machine:I386 /libpath:"..\..\..\php_build\apache\src\corer" /libpath:"..\..\Release_TS" /libpath:"..\..\TSRM\Release_TS" /libpath:"..\..\Zend\Release_TS"
-
-!ELSEIF "$(CFG)" == "php5apache_hooks - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APACHEPHP5_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\..\regex" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\..\php_build\apache\src\include" /I "..\..\main" /I "..\..\TSRM" /D "_DEBUG" /D ZEND_DEBUG=1 /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "APACHEPHP5_EXPORTS" /D "WIN32" /D "_MBCS" /D "APACHE_READDIR_H" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 php5ts_debug.lib ApacheCore.lib 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 /base:"0x60000000" /version:4.0 /dll /incremental:yes /debug /machine:I386 /out:"..\..\Debug_TS/php5apache_hooks.dll" /pdbtype:sept /libpath:"..\..\..\php_build\apache\src\cored" /libpath:"..\..\Debug_TS" /libpath:"..\..\TSRM\Debug_TS" /libpath:"..\..\Zend\Debug_TS"
-
-!ELSEIF "$(CFG)" == "php5apache_hooks - Win32 Release_TS_inline"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS_inline"
-# PROP BASE Intermediate_Dir "Release_TS_inline"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS_inline"
-# PROP Intermediate_Dir "Release_TS_inline"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APACHEPHP5_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\..\regex" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\..\php_build\apache\src\include" /I "..\..\main" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "ZEND_WIN32_FORCE_INLINE" /D "NDEBUG" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "APACHEPHP5_EXPORTS" /D "WIN32" /D "_MBCS" /D "APACHE_READDIR_H" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 php5ts.lib ApacheCore.lib 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 /version:4.0 /dll /machine:I386 /libpath:"\apache\src\corer" /libpath:"..\..\Release_TS_inline" /libpath:"..\..\TSRM\Release_TS_inline" /libpath:"..\..\Zend\Release_TS_inline"
-
-!ENDIF
-
-# Begin Target
-
-# Name "php5apache_hooks - Win32 Release_TS"
-# Name "php5apache_hooks - Win32 Debug_TS"
-# Name "php5apache_hooks - Win32 Release_TS_inline"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\mod_php5.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_apache.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\sapi_apache.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\mod_php5.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_apache_http.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/sapi/apache_hooks/php_apache.c b/sapi/apache_hooks/php_apache.c
index 6531ca20ee..e5bd3f5d61 100644
--- a/sapi/apache_hooks/php_apache.c
+++ b/sapi/apache_hooks/php_apache.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -155,15 +155,13 @@ static request_rec *get_apache_request(zval *z TSRMLS_DC)
return r;
}
-/* {{{ php_apache_request_new(request_rec *r)
+/* {{{ php_apache_request_new(request_rec *r TSRMLS_DC)
* create a new zval-instance for ApacheRequest that wraps request_rec
*/
-zval *php_apache_request_new(request_rec *r)
+zval *php_apache_request_new(request_rec *r TSRMLS_DC)
{
zval *req;
zval *addr;
-
- TSRMLS_FETCH();
MAKE_STD_ZVAL(addr);
Z_TYPE_P(addr) = IS_LONG;
@@ -1170,7 +1168,7 @@ PHP_FUNCTION(apache_request_sub_req_lookup_uri)
if (!sub_r) {
RETURN_FALSE;
}
- return_value = php_apache_request_new(sub_r);
+ return_value = php_apache_request_new(sub_r TSRMLS_CC);
}
/* }}} */
@@ -1196,7 +1194,7 @@ PHP_FUNCTION(apache_request_sub_req_lookup_file)
if (!sub_r) {
RETURN_FALSE;
}
- return_value = php_apache_request_new(sub_r);
+ return_value = php_apache_request_new(sub_r TSRMLS_CC);
}
/* }}} */
@@ -1222,7 +1220,7 @@ PHP_FUNCTION(apache_request_sub_req_method_uri)
if (!sub_r) {
RETURN_FALSE;
}
- return_value = php_apache_request_new(sub_r);
+ return_value = php_apache_request_new(sub_r TSRMLS_CC);
}
/* }}} */
@@ -1403,7 +1401,7 @@ static PHP_MINIT_FUNCTION(apache)
le_apachereq = zend_register_list_destructors_ex(php_apache_request_free, NULL, "ApacheRequest", module_number);
INIT_OVERLOADED_CLASS_ENTRY(ce, "ApacheRequest", php_apache_request_class_functions, NULL, NULL, NULL);
- apacherequest_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC);
+ apacherequest_class_entry = zend_register_internal_class_ex(&ce, NULL TSRMLS_CC);
REGISTER_LONG_CONSTANT("OK", OK, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("DECLINED", DECLINED, CONST_CS | CONST_PERSISTENT);
@@ -1766,7 +1764,7 @@ static void apache_table_to_zval(table *t, zval *return_value)
if (!tenv[i].key) {
continue;
}
- if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val, 1)==FAILURE) {
+ if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val)==FAILURE) {
RETURN_FALSE;
}
}
@@ -1850,34 +1848,34 @@ PHP_FUNCTION(apache_lookup_uri)
add_property_long(return_value,"status", rr->status);
if (rr->the_request) {
- add_property_string(return_value,"the_request", rr->the_request, 1);
+ add_property_string(return_value,"the_request", rr->the_request);
}
if (rr->status_line) {
- add_property_string(return_value,"status_line", (char *)rr->status_line, 1);
+ add_property_string(return_value,"status_line", (char *)rr->status_line);
}
if (rr->method) {
- add_property_string(return_value,"method", (char *)rr->method, 1);
+ add_property_string(return_value,"method", (char *)rr->method);
}
if (rr->content_type) {
- add_property_string(return_value,"content_type", (char *)rr->content_type, 1);
+ add_property_string(return_value,"content_type", (char *)rr->content_type);
}
if (rr->handler) {
- add_property_string(return_value,"handler", (char *)rr->handler, 1);
+ add_property_string(return_value,"handler", (char *)rr->handler);
}
if (rr->uri) {
- add_property_string(return_value,"uri", rr->uri, 1);
+ add_property_string(return_value,"uri", rr->uri);
}
if (rr->filename) {
- add_property_string(return_value,"filename", rr->filename, 1);
+ add_property_string(return_value,"filename", rr->filename);
}
if (rr->path_info) {
- add_property_string(return_value,"path_info", rr->path_info, 1);
+ add_property_string(return_value,"path_info", rr->path_info);
}
if (rr->args) {
- add_property_string(return_value,"args", rr->args, 1);
+ add_property_string(return_value,"args", rr->args);
}
if (rr->boundary) {
- add_property_string(return_value,"boundary", rr->boundary, 1);
+ add_property_string(return_value,"boundary", rr->boundary);
}
add_property_long(return_value,"no_cache", rr->no_cache);
add_property_long(return_value,"no_local_copy", rr->no_local_copy);
@@ -1889,7 +1887,7 @@ PHP_FUNCTION(apache_lookup_uri)
#if MODULE_MAGIC_NUMBER >= 19980324
if (rr->unparsed_uri) {
- add_property_string(return_value,"unparsed_uri", rr->unparsed_uri, 1);
+ add_property_string(return_value,"unparsed_uri", rr->unparsed_uri);
}
if(rr->mtime) {
add_property_long(return_value,"mtime", rr->mtime);
@@ -1954,9 +1952,9 @@ PHP_FUNCTION(apache_get_modules)
for (n = 0; ap_loaded_modules[n]; ++n) {
char *s = (char *) ap_loaded_modules[n]->name;
if ((p = strchr(s, '.'))) {
- add_next_index_stringl(return_value, s, (p - s), 1);
+ add_next_index_stringl(return_value, s, (p - s));
} else {
- add_next_index_string(return_value, s, 1);
+ add_next_index_string(return_value, s);
}
}
}
diff --git a/sapi/apache_hooks/php_apache_http.h b/sapi/apache_hooks/php_apache_http.h
index 23cf7fea69..e6610741c7 100644
--- a/sapi/apache_hooks/php_apache_http.h
+++ b/sapi/apache_hooks/php_apache_http.h
@@ -36,7 +36,7 @@
#include "php_ini.h"
#include "ext/standard/php_standard.h"
-#include "mod_php5.h"
+#include "mod_php7.h"
zval *php_apache_request_new(request_rec *r);
diff --git a/sapi/apache_hooks/sapi_apache.c b/sapi/apache_hooks/sapi_apache.c
index 9ed93aea6d..daaad4e39d 100644
--- a/sapi/apache_hooks/sapi_apache.c
+++ b/sapi/apache_hooks/sapi_apache.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/caudium/caudium.c b/sapi/caudium/caudium.c
index e707f3576e..b1ffddb460 100644
--- a/sapi/caudium/caudium.c
+++ b/sapi/caudium/caudium.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -38,7 +38,7 @@
*/
#define NO_PIKE_SHORTHAND
-/* Ok, we are now using Pike level threads to handle PHP5 since
+/* Ok, we are now using Pike level threads to handle PHP7 since
* the nice th_farm threads aren't working on Linux with glibc 2.2
* (why this is I don't know).
*/
@@ -79,7 +79,7 @@
#endif
#ifndef PIKE_THREADS
-#error The PHP5 module requires that your Pike has thread support.
+#error The PHP7 module requires that your Pike has thread support.
#endif
#undef HIDE_GLOBAL_VARIABLES
@@ -395,11 +395,10 @@ php_caudium_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
* the client. Used for POST/PUT requests.
*/
-INLINE static int php_caudium_low_read_post(char *buf, uint count_bytes)
+INLINE static int php_caudium_low_read_post(char *buf, uint count_bytes TSRMLS_DC)
{
uint total_read = 0;
GET_THIS();
- TSRMLS_FETCH();
if(!MY_FD_OBJ->prog)
{
@@ -423,7 +422,7 @@ static int
php_caudium_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC)
{
uint total_read = 0;
- THREAD_SAFE_RUN(total_read = php_caudium_low_read_post(buf, count_bytes), "read post");
+ THREAD_SAFE_RUN(total_read = php_caudium_low_read_post(buf, count_bytes TSRMLS_CC), "read post");
return total_read;
}
@@ -626,7 +625,7 @@ static void php_caudium_module_main(php_caudium_request *ureq)
SG(request_info).headers_only = 0;
}
- /* Let PHP5 handle the deconding of the AUTH */
+ /* Let PHP7 handle the deconding of the AUTH */
php_handle_auth_data(lookup_string_header("HTTP_AUTHORIZATION", NULL), TSRMLS_C);
/* Swap out this thread and release the interpreter lock to allow
* Pike threads to run. We wait since the above would otherwise require
diff --git a/sapi/caudium/config.m4 b/sapi/caudium/config.m4
index 5ce55f3f01..13a6b2943e 100644
--- a/sapi/caudium/config.m4
+++ b/sapi/caudium/config.m4
@@ -79,12 +79,12 @@ if test "$PHP_CAUDIUM" != "no"; then
AC_MSG_RESULT(not found)
fi
else
- AC_MSG_ERROR([Caudium PHP5 requires Pike 7.0 or newer])
+ AC_MSG_ERROR([Caudium PHP7 requires Pike 7.0 or newer])
fi
PIKE_VERSION=`$PIKE -e 'string v; int rel;sscanf(version(), "Pike v%s release %d", v, rel); write(v+"."+rel);'`
AC_DEFINE(HAVE_CAUDIUM,1,[Whether to compile with Caudium support])
PHP_SELECT_SAPI(caudium, shared, caudium.c)
- INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $PHP_CAUDIUM/lib/$PIKE_VERSION/PHP5.so"
+ INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $PHP_CAUDIUM/lib/$PIKE_VERSION/PHP7.so"
RESULT=" *** Pike binary used: $PIKE
*** Pike include dir(s) used: $PIKE_INCLUDE_DIR
*** Pike version: $PIKE_VERSION"
diff --git a/sapi/cgi/CHANGES b/sapi/cgi/CHANGES
index de029474e5..b7cf41cf5e 100755
--- a/sapi/cgi/CHANGES
+++ b/sapi/cgi/CHANGES
@@ -31,4 +31,3 @@ In PHP5.3 all additional configure options (except --enable-cgi) are removed:
Now it is disabled by default, but can be enabled
with ini directive "cgi.discard_path=1".
-
diff --git a/sapi/cgi/README.FastCGI b/sapi/cgi/README.FastCGI
index 3dda295d84..f0f11e102d 100644
--- a/sapi/cgi/README.FastCGI
+++ b/sapi/cgi/README.FastCGI
@@ -69,7 +69,7 @@ a line in your config like:
Don't load mod_php, by the way. Make sure it is commented out!
- #LoadModule php5_module /usr/lib/apache/2.0/libphp5.so
+ #LoadModule php7_module /usr/lib/apache/2.0/libphp7.so
Now, we'll create a fcgi-bin directory, just like you would do with normal
CGI scripts. You'll need to create a directory somewhere to store your
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 437d09cf32..f06787543e 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -159,6 +159,8 @@ static const opt_struct OPTIONS[] = {
};
typedef struct _php_cgi_globals_struct {
+ HashTable user_config_cache;
+ char *redirect_status_env;
zend_bool rfc2616_headers;
zend_bool nph;
zend_bool check_shebang_line;
@@ -166,11 +168,9 @@ typedef struct _php_cgi_globals_struct {
zend_bool force_redirect;
zend_bool discard_path;
zend_bool fcgi_logging;
- char *redirect_status_env;
#ifdef PHP_WIN32
zend_bool impersonate;
#endif
- HashTable user_config_cache;
} php_cgi_globals_struct;
/* {{{ user_config_cache
@@ -187,10 +187,12 @@ typedef struct _user_config_cache_entry {
HashTable *user_config;
} user_config_cache_entry;
-static void user_config_cache_entry_dtor(user_config_cache_entry *entry)
+static void user_config_cache_entry_dtor(zval *el)
{
+ user_config_cache_entry *entry = (user_config_cache_entry *)Z_PTR_P(el);
zend_hash_destroy(entry->user_config);
free(entry->user_config);
+ free(entry);
}
/* }}} */
@@ -215,30 +217,30 @@ static php_cgi_globals_struct php_cgi_globals;
#define TRANSLATE_SLASHES(path)
#endif
-static int print_module_info(zend_module_entry *module, void *arg TSRMLS_DC)
+static int print_module_info(zval *element TSRMLS_DC)
{
+ zend_module_entry *module = Z_PTR_P(element);
php_printf("%s\n", module->name);
- return 0;
+ return ZEND_HASH_APPLY_KEEP;
}
static int module_name_cmp(const void *a, const void *b TSRMLS_DC)
{
- Bucket *f = *((Bucket **) a);
- Bucket *s = *((Bucket **) b);
+ Bucket *f = (Bucket *) a;
+ Bucket *s = (Bucket *) b;
- return strcasecmp( ((zend_module_entry *)f->pData)->name,
- ((zend_module_entry *)s->pData)->name);
+ return strcasecmp( ((zend_module_entry *)Z_PTR(f->val))->name,
+ ((zend_module_entry *)Z_PTR(s->val))->name);
}
static void print_modules(TSRMLS_D)
{
HashTable sorted_registry;
- zend_module_entry tmp;
- zend_hash_init(&sorted_registry, 50, NULL, NULL, 1);
- zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry));
+ zend_hash_init(&sorted_registry, 64, NULL, NULL, 1);
+ zend_hash_copy(&sorted_registry, &module_registry, NULL);
zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC);
- zend_hash_apply_with_argument(&sorted_registry, (apply_func_arg_t) print_module_info, NULL TSRMLS_CC);
+ zend_hash_apply(&sorted_registry, print_module_info TSRMLS_CC);
zend_hash_destroy(&sorted_registry);
}
@@ -272,7 +274,7 @@ static void print_extensions(TSRMLS_D)
static inline size_t sapi_cgi_single_write(const char *str, uint str_length TSRMLS_DC)
{
#ifdef PHP_WRITE_STDOUT
- long ret;
+ int ret;
ret = write(STDOUT_FILENO, str, str_length);
if (ret <= 0) return 0;
@@ -285,10 +287,10 @@ static inline size_t sapi_cgi_single_write(const char *str, uint str_length TSRM
#endif
}
-static int sapi_cgi_ub_write(const char *str, uint str_length TSRMLS_DC)
+static size_t sapi_cgi_ub_write(const char *str, size_t str_length TSRMLS_DC)
{
const char *ptr = str;
- uint remaining = str_length;
+ size_t remaining = str_length;
size_t ret;
while (remaining > 0) {
@@ -304,14 +306,14 @@ static int sapi_cgi_ub_write(const char *str, uint str_length TSRMLS_DC)
return str_length;
}
-static int sapi_fcgi_ub_write(const char *str, uint str_length TSRMLS_DC)
+static size_t sapi_fcgi_ub_write(const char *str, size_t str_length TSRMLS_DC)
{
const char *ptr = str;
- uint remaining = str_length;
+ size_t remaining = str_length;
fcgi_request *request = (fcgi_request*) SG(server_context);
while (remaining > 0) {
- long ret = fcgi_write(request, FCGI_STDOUT, ptr, remaining);
+ zend_long ret = fcgi_write(request, FCGI_STDOUT, ptr, remaining);
if (ret <= 0) {
php_handle_aborted_connection();
@@ -324,14 +326,14 @@ static int sapi_fcgi_ub_write(const char *str, uint str_length TSRMLS_DC)
return str_length;
}
-static void sapi_cgi_flush(void *server_context)
+static void sapi_cgi_flush(void *server_context TSRMLS_DC)
{
if (fflush(stdout) == EOF) {
php_handle_aborted_connection();
}
}
-static void sapi_fcgi_flush(void *server_context)
+static void sapi_fcgi_flush(void *server_context TSRMLS_DC)
{
fcgi_request *request = (fcgi_request*) server_context;
@@ -503,12 +505,17 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
# define STDIN_FILENO 0
#endif
-static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC)
+static size_t sapi_cgi_read_post(char *buffer, size_t count_bytes TSRMLS_DC)
{
- uint read_bytes = 0;
+ size_t read_bytes = 0;
int tmp_read_bytes;
+ size_t remaining_bytes;
- count_bytes = MIN(count_bytes, SG(request_info).content_length - SG(read_post_bytes));
+ assert(SG(request_info).content_length >= SG(read_post_bytes));
+
+ remaining_bytes = (size_t)(SG(request_info).content_length - SG(read_post_bytes));
+
+ count_bytes = MIN(count_bytes, remaining_bytes);
while (read_bytes < count_bytes) {
tmp_read_bytes = read(STDIN_FILENO, buffer + read_bytes, count_bytes - read_bytes);
if (tmp_read_bytes <= 0) {
@@ -519,9 +526,9 @@ static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC)
return read_bytes;
}
-static int sapi_fcgi_read_post(char *buffer, uint count_bytes TSRMLS_DC)
+static size_t sapi_fcgi_read_post(char *buffer, size_t count_bytes TSRMLS_DC)
{
- uint read_bytes = 0;
+ size_t read_bytes = 0;
int tmp_read_bytes;
fcgi_request *request = (fcgi_request*) SG(server_context);
size_t remaining = SG(request_info).content_length - SG(read_post_bytes);
@@ -619,8 +626,8 @@ static char *sapi_fcgi_read_cookies(TSRMLS_D)
static void cgi_php_load_env_var(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg TSRMLS_DC)
{
zval *array_ptr = (zval*)arg;
- int filter_arg = (array_ptr == PG(http_globals)[TRACK_VARS_ENV])?PARSE_ENV:PARSE_SERVER;
- unsigned int new_val_len;
+ int filter_arg = (Z_ARR_P(array_ptr) == Z_ARR(PG(http_globals)[TRACK_VARS_ENV]))?PARSE_ENV:PARSE_SERVER;
+ size_t new_val_len;
if (sapi_module.input_filter(filter_arg, var, &val, strlen(val), &new_val_len TSRMLS_CC)) {
php_register_variable_safe(var, val, new_val_len, array_ptr TSRMLS_CC);
@@ -629,25 +636,19 @@ static void cgi_php_load_env_var(char *var, unsigned int var_len, char *val, uns
static void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC)
{
- if (PG(http_globals)[TRACK_VARS_ENV] &&
- array_ptr != PG(http_globals)[TRACK_VARS_ENV] &&
- Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY &&
- zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV])) > 0
+ if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY &&
+ Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV]) &&
+ zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_ENV])) > 0
) {
zval_dtor(array_ptr);
- *array_ptr = *PG(http_globals)[TRACK_VARS_ENV];
- INIT_PZVAL(array_ptr);
- zval_copy_ctor(array_ptr);
+ ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_ENV]);
return;
- } else if (PG(http_globals)[TRACK_VARS_SERVER] &&
- array_ptr != PG(http_globals)[TRACK_VARS_SERVER] &&
- Z_TYPE_P(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY &&
- zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])) > 0
+ } else if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY &&
+ Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_SERVER]) &&
+ zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER])) > 0
) {
zval_dtor(array_ptr);
- *array_ptr = *PG(http_globals)[TRACK_VARS_SERVER];
- INIT_PZVAL(array_ptr);
- zval_copy_ctor(array_ptr);
+ ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_SERVER]);
return;
}
@@ -662,7 +663,7 @@ static void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC)
static void sapi_cgi_register_variables(zval *track_vars_array TSRMLS_DC)
{
- unsigned int php_self_len;
+ size_t php_self_len;
char *php_self;
/* In CGI mode, we consider the environment to be a part of the server
@@ -758,13 +759,12 @@ static void php_cgi_ini_activate_user_config(char *path, int path_len, const cha
time_t request_time = sapi_get_request_time(TSRMLS_C);
/* Find cached config entry: If not found, create one */
- if (zend_hash_find(&CGIG(user_config_cache), path, path_len + 1, (void **) &entry) == FAILURE) {
+ if ((entry = zend_hash_str_find_ptr(&CGIG(user_config_cache), path, path_len)) == NULL) {
new_entry = pemalloc(sizeof(user_config_cache_entry), 1);
new_entry->expires = 0;
new_entry->user_config = (HashTable *) pemalloc(sizeof(HashTable), 1);
- zend_hash_init(new_entry->user_config, 0, NULL, (dtor_func_t) config_zval_dtor, 1);
- zend_hash_update(&CGIG(user_config_cache), path, path_len + 1, new_entry, sizeof(user_config_cache_entry), (void **) &entry);
- free(new_entry);
+ zend_hash_init(new_entry->user_config, 8, NULL, (dtor_func_t) config_zval_dtor, 1);
+ entry = zend_hash_str_update_ptr(&CGIG(user_config_cache), path, path_len, new_entry);
}
/* Check whether cache entry has expired and rescan if it is */
@@ -852,7 +852,7 @@ static int sapi_cgi_activate(TSRMLS_D)
server_name_len = strlen(server_name);
server_name = estrndup(server_name, server_name_len);
zend_str_tolower(server_name, server_name_len);
- php_ini_activate_per_host_config(server_name, server_name_len + 1 TSRMLS_CC);
+ php_ini_activate_per_host_config(server_name, server_name_len TSRMLS_CC);
efree(server_name);
}
}
@@ -928,7 +928,7 @@ static int sapi_cgi_deactivate(TSRMLS_D)
php_handle_aborted_connection();
}
} else {
- sapi_cgi_flush(SG(server_context));
+ sapi_cgi_flush(SG(server_context) TSRMLS_CC);
}
}
return SUCCESS;
@@ -1189,7 +1189,7 @@ static void init_request_info(fcgi_request *request TSRMLS_DC)
#endif
if (CGIG(fix_pathinfo)) {
- struct stat st;
+ zend_stat_t st;
char *real_path = NULL;
char *env_redirect_url = CGI_GETENV("REDIRECT_URL");
char *env_document_root = CGI_GETENV("DOCUMENT_ROOT");
@@ -1243,7 +1243,7 @@ static void init_request_info(fcgi_request *request TSRMLS_DC)
while ((ptr = strrchr(pt, '/')) || (ptr = strrchr(pt, '\\'))) {
*ptr = 0;
- if (stat(pt, &st) == 0 && S_ISREG(st.st_mode)) {
+ if (zend_stat(pt, &st) == 0 && S_ISREG(st.st_mode)) {
/*
* okay, we found the base script!
* work out how many chars we had to strip off;
@@ -1482,7 +1482,7 @@ static void php_cgi_globals_ctor(php_cgi_globals_struct *php_cgi_globals TSRMLS_
#ifdef PHP_WIN32
php_cgi_globals->impersonate = 0;
#endif
- zend_hash_init(&php_cgi_globals->user_config_cache, 0, NULL, (dtor_func_t) user_config_cache_entry_dtor, 1);
+ zend_hash_init(&php_cgi_globals->user_config_cache, 8, NULL, user_config_cache_entry_dtor, 1);
}
/* }}} */
@@ -1571,7 +1571,7 @@ static void add_request_header(char *var, unsigned int var_len, char *val, unsig
} else {
return;
}
- add_assoc_stringl_ex(return_value, var, var_len+1, val, val_len, 1);
+ add_assoc_stringl_ex(return_value, var, var_len+1, val, val_len);
if (str) {
free_alloca(var, use_heap);
}
@@ -1592,7 +1592,7 @@ PHP_FUNCTION(apache_request_headers) /* {{{ */
char buf[128];
char **env, *p, *q, *var, *val, *t = buf;
size_t alloc_size = sizeof(buf);
- unsigned long var_len;
+ zend_ulong var_len;
for (env = environ; env != NULL && *env != NULL; env++) {
val = strchr(*env, '=');
@@ -1652,7 +1652,7 @@ PHP_FUNCTION(apache_request_headers) /* {{{ */
continue;
}
val++;
- add_assoc_string_ex(return_value, var, var_len+1, val, 1);
+ add_assoc_string_ex(return_value, var, var_len, val);
}
if (t != buf && t != NULL) {
efree(t);
@@ -1681,7 +1681,7 @@ static void add_response_header(sapi_header_struct *h, zval *return_value TSRMLS
do {
p++;
} while (*p == ' ' || *p == '\t');
- add_assoc_stringl_ex(return_value, s, len+1, p, h->header_len - (p - h->header), 1);
+ add_assoc_stringl_ex(return_value, s, len, p, h->header_len - (p - h->header));
free_alloca(s, use_heap);
}
}
@@ -1756,6 +1756,7 @@ int main(int argc, char *argv[])
char *bindpath = NULL;
int fcgi_fd = 0;
fcgi_request *request = NULL;
+ int warmup_repeats = 0;
int repeats = 1;
int benchmark = 0;
#if HAVE_GETTIMEOFDAY
@@ -2099,7 +2100,15 @@ consult the installation file that came with this distribution, or visit \n\
switch (c) {
case 'T':
benchmark = 1;
- repeats = atoi(php_optarg);
+ {
+ char *comma = strchr(php_optarg, ',');
+ if (comma) {
+ warmup_repeats = atoi(php_optarg);
+ repeats = atoi(comma + 1);
+ } else {
+ repeats = atoi(php_optarg);
+ }
+ }
#ifdef HAVE_GETTIMEOFDAY
gettimeofday(&start, NULL);
#else
@@ -2135,7 +2144,6 @@ consult the installation file that came with this distribution, or visit \n\
while (!fastcgi || fcgi_accept_request(request) >= 0) {
SG(server_context) = fastcgi ? (void *) request : (void *) 1;
init_request_info(request TSRMLS_CC);
- CG(interactive) = 0;
if (!cgi && !fastcgi) {
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
@@ -2143,7 +2151,6 @@ consult the installation file that came with this distribution, or visit \n\
case 'a': /* interactive mode */
printf("Interactive mode enabled\n\n");
- CG(interactive) = 1;
break;
case 'C': /* don't chdir to the script directory */
@@ -2240,7 +2247,7 @@ consult the installation file that came with this distribution, or visit \n\
break;
case 'z': /* load extension file */
- zend_load_extension(php_optarg);
+ zend_load_extension(php_optarg TSRMLS_CC);
break;
default:
@@ -2250,7 +2257,7 @@ consult the installation file that came with this distribution, or visit \n\
if (script_file) {
/* override path_translated if -f on command line */
- STR_FREE(SG(request_info).path_translated);
+ if (SG(request_info).path_translated) efree(SG(request_info).path_translated);
SG(request_info).path_translated = script_file;
/* before registering argv to module exchange the *new* argv[0] */
/* we can achieve this without allocating more memory */
@@ -2259,7 +2266,7 @@ consult the installation file that came with this distribution, or visit \n\
SG(request_info).argv[0] = script_file;
} else if (argc > php_optind) {
/* file is on command line, but not in -f opt */
- STR_FREE(SG(request_info).path_translated);
+ if (SG(request_info).path_translated) efree(SG(request_info).path_translated);
SG(request_info).path_translated = estrdup(argv[php_optind]);
/* arguments after the file are considered script args */
SG(request_info).argc = argc - php_optind;
@@ -2362,7 +2369,7 @@ consult the installation file that came with this distribution, or visit \n\
goto fastcgi_request_done;
}
- STR_FREE(SG(request_info).path_translated);
+ if (SG(request_info).path_translated) efree(SG(request_info).path_translated);
if (free_query_string && SG(request_info).query_string) {
free(SG(request_info).query_string);
@@ -2403,8 +2410,8 @@ consult the installation file that came with this distribution, or visit \n\
/* handle situations where line is terminated by \r\n */
if (c == '\r') {
if (fgetc(file_handle.handle.fp) != '\n') {
- long pos = ftell(file_handle.handle.fp);
- fseek(file_handle.handle.fp, pos - 1, SEEK_SET);
+ zend_long pos = zend_ftell(file_handle.handle.fp);
+ zend_fseek(file_handle.handle.fp, pos - 1, SEEK_SET);
}
}
CG(start_lineno) = 2;
@@ -2421,7 +2428,7 @@ consult the installation file that came with this distribution, or visit \n\
/* handle situations where line is terminated by \r\n */
if (c == '\r') {
if (php_stream_getc((php_stream*)file_handle.handle.stream.handle) != '\n') {
- long pos = php_stream_tell((php_stream*)file_handle.handle.stream.handle);
+ zend_off_t pos = php_stream_tell((php_stream*)file_handle.handle.stream.handle);
php_stream_seek((php_stream*)file_handle.handle.stream.handle, pos - 1, SEEK_SET);
}
}
@@ -2493,7 +2500,7 @@ consult the installation file that came with this distribution, or visit \n\
/* Zeev might want to do something with this one day */
case PHP_MODE_INDENT:
open_file_for_scanning(&file_handle TSRMLS_CC);
- zend_indent();
+ zend_indent(TSRMLS_C);
zend_file_handle_dtor(&file_handle TSRMLS_CC);
php_output_teardown();
return SUCCESS;
@@ -2503,7 +2510,7 @@ consult the installation file that came with this distribution, or visit \n\
fastcgi_request_done:
{
- STR_FREE(SG(request_info).path_translated);
+ if (SG(request_info).path_translated) efree(SG(request_info).path_translated);
php_request_shutdown((void *) 0);
@@ -2519,12 +2526,24 @@ fastcgi_request_done:
if (!fastcgi) {
if (benchmark) {
- repeats--;
- if (repeats > 0) {
- script_file = NULL;
- php_optind = orig_optind;
- php_optarg = orig_optarg;
+ if (warmup_repeats) {
+ warmup_repeats--;
+ if (!warmup_repeats) {
+#ifdef HAVE_GETTIMEOFDAY
+ gettimeofday(&start, NULL);
+#else
+ time(&start);
+#endif
+ }
continue;
+ } else {
+ repeats--;
+ if (repeats > 0) {
+ script_file = NULL;
+ php_optind = orig_optind;
+ php_optarg = orig_optarg;
+ continue;
+ }
}
}
break;
diff --git a/sapi/cgi/config.w32 b/sapi/cgi/config.w32
index 8d1d431da4..55a2fba48f 100644
--- a/sapi/cgi/config.w32
+++ b/sapi/cgi/config.w32
@@ -4,7 +4,7 @@
ARG_ENABLE('cgi', 'Build CGI version of PHP', 'yes');
if (PHP_CGI == "yes") {
- ADD_FLAG("LDFLAGS_CGI", "/stack:8388608");
+ ADD_FLAG("LDFLAGS_CGI", "/stack:67108864");
SAPI('cgi', 'cgi_main.c fastcgi.c', 'php-cgi.exe');
ADD_FLAG('LIBS_CGI', 'ws2_32.lib kernel32.lib advapi32.lib');
}
diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c
index 6133668306..0cd3096e4d 100644
--- a/sapi/cgi/fastcgi.c
+++ b/sapi/cgi/fastcgi.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -19,6 +19,7 @@
/* $Id$ */
#include "php.h"
+#include "php_network.h"
#include "fastcgi.h"
#include <string.h>
@@ -72,8 +73,6 @@
# include <netdb.h>
# include <signal.h>
-# define closesocket(s) close(s)
-
# if defined(HAVE_SYS_POLL_H) && defined(HAVE_POLL)
# include <sys/poll.h>
# endif
@@ -411,7 +410,7 @@ int fcgi_init(void)
sa_t sa;
socklen_t len = sizeof(sa);
#endif
- zend_hash_init(&fcgi_mgmt_vars, 0, NULL, fcgi_free_mgmt_var_cb, 1);
+ zend_hash_init(&fcgi_mgmt_vars, 8, NULL, fcgi_free_mgmt_var_cb, 1);
fcgi_set_mgmt_var("FCGI_MPXS_CONNS", sizeof("FCGI_MPXS_CONNS")-1, "0", sizeof("0")-1);
is_initialized = 1;
@@ -642,7 +641,7 @@ int fcgi_listen(const char *path, int backlog)
if (namedPipe == INVALID_HANDLE_VALUE) {
return -1;
}
- listen_socket = _open_osfhandle((long)namedPipe, 0);
+ listen_socket = _open_osfhandle((intptr_t)namedPipe, 0);
if (!is_initialized) {
fcgi_init();
}
@@ -723,7 +722,7 @@ int fcgi_listen(const char *path, int backlog)
#ifdef _WIN32
if (tcp) {
- listen_socket = _open_osfhandle((long)listen_socket, 0);
+ listen_socket = _open_osfhandle((intptr_t)listen_socket, 0);
}
#else
fcgi_setup_signals();
@@ -973,7 +972,7 @@ static int fcgi_read_request(fcgi_request *req)
}
} else if (hdr.type == FCGI_GET_VALUES) {
unsigned char *p = buf + sizeof(fcgi_header);
- zval ** value;
+ zval *value;
unsigned int zlen;
fcgi_hash_bucket *q;
@@ -989,10 +988,10 @@ static int fcgi_read_request(fcgi_request *req)
q = req->env.list;
while (q != NULL) {
- if (zend_hash_find(&fcgi_mgmt_vars, q->var, q->var_len, (void**) &value) != SUCCESS) {
+ if ((value = zend_hash_str_find(&fcgi_mgmt_vars, q->var, q->var_len)) == NULL) {
continue;
}
- zlen = Z_STRLEN_PP(value);
+ zlen = Z_STRLEN_P(value);
if ((p + 4 + 4 + q->var_len + zlen) >= (buf + sizeof(buf))) {
break;
}
@@ -1014,7 +1013,7 @@ static int fcgi_read_request(fcgi_request *req)
}
memcpy(p, q->var, q->var_len);
p += q->var_len;
- memcpy(p, Z_STRVAL_PP(value), zlen);
+ memcpy(p, Z_STRVAL_P(value), zlen);
p += zlen;
}
len = p - buf - sizeof(fcgi_header);
@@ -1510,19 +1509,14 @@ void fcgi_impersonate(void)
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len)
{
- zval * zvalue;
- zvalue = pemalloc(sizeof(*zvalue), 1);
- Z_TYPE_P(zvalue) = IS_STRING;
- Z_STRVAL_P(zvalue) = pestrndup(value, value_len, 1);
- Z_STRLEN_P(zvalue) = value_len;
- zend_hash_add(&fcgi_mgmt_vars, name, name_len, &zvalue, sizeof(zvalue), NULL);
+ zval zvalue;
+ ZVAL_NEW_STR(&zvalue, zend_string_init(value, value_len, 1));
+ zend_hash_str_add(&fcgi_mgmt_vars, name, name_len, &zvalue);
}
-void fcgi_free_mgmt_var_cb(void * ptr)
+void fcgi_free_mgmt_var_cb(zval *zv)
{
- zval ** var = (zval **)ptr;
- pefree(Z_STRVAL_PP(var), 1);
- pefree(*var, 1);
+ pefree(Z_STR_P(zv), 1);
}
/*
diff --git a/sapi/cgi/fastcgi.h b/sapi/cgi/fastcgi.h
index 702f51df6b..4a30a207b1 100644
--- a/sapi/cgi/fastcgi.h
+++ b/sapi/cgi/fastcgi.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -139,7 +139,7 @@ void fcgi_impersonate(void);
#endif
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len);
-void fcgi_free_mgmt_var_cb(void * ptr);
+void fcgi_free_mgmt_var_cb(zval *zv);
/*
* Local variables:
diff --git a/sapi/cli/cli.h b/sapi/cli/cli.h
index dc85893a0b..e49a203821 100644
--- a/sapi/cli/cli.h
+++ b/sapi/cli/cli.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -30,11 +30,11 @@
#endif
-extern PHP_CLI_API size_t sapi_cli_single_write(const char *str, uint str_length TSRMLS_DC);
+extern PHP_CLI_API size_t sapi_cli_single_write(const char *str, size_t str_length TSRMLS_DC);
typedef struct {
- size_t (*cli_shell_write)(const char *str, uint str_length TSRMLS_DC);
- int (*cli_shell_ub_write)(const char *str, uint str_length TSRMLS_DC);
+ size_t (*cli_shell_write)(const char *str, size_t str_length TSRMLS_DC);
+ size_t (*cli_shell_ub_write)(const char *str, size_t str_length TSRMLS_DC);
int (*cli_shell_run)(TSRMLS_D);
} cli_shell_callbacks_t;
diff --git a/sapi/cli/config.m4 b/sapi/cli/config.m4
index 9a1b98da46..090574a007 100644
--- a/sapi/cli/config.m4
+++ b/sapi/cli/config.m4
@@ -45,7 +45,7 @@ if test "$PHP_CLI" != "no"; then
BUILD_CLI="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_BINARY_OBJS:.lo=.o) \$(PHP_CLI_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)"
;;
*netware*)
- BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_BINARY_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -Lnetware -lphp5lib -o \$(SAPI_CLI_PATH)"
+ BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_BINARY_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -Lnetware -lphp7lib -o \$(SAPI_CLI_PATH)"
;;
*)
BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)"
diff --git a/sapi/cli/config.w32 b/sapi/cli/config.w32
index adcbb2b496..438c9e6d62 100644
--- a/sapi/cli/config.w32
+++ b/sapi/cli/config.w32
@@ -11,11 +11,11 @@ if (PHP_CLI == "yes") {
if (PHP_CRT_DEBUG == "yes") {
ADD_FLAG("CFLAGS_CLI", "/D PHP_WIN32_DEBUG_HEAP");
}
- ADD_FLAG("LDFLAGS_CLI", "/stack:8388608");
+ ADD_FLAG("LDFLAGS_CLI", "/stack:67108864");
}
if (PHP_CLI_WIN32 == "yes") {
SAPI('cli_win32', 'cli_win32.c php_cli_process_title.c ps_title.c', 'php-win.exe');
- ADD_FLAG("LDFLAGS_CLI_WIN32", "/stack:8388608");
+ ADD_FLAG("LDFLAGS_CLI_WIN32", "/stack:67108864");
}
diff --git a/sapi/cli/generate_mime_type_map.php b/sapi/cli/generate_mime_type_map.php
new file mode 100644
index 0000000000..772569a426
--- /dev/null
+++ b/sapi/cli/generate_mime_type_map.php
@@ -0,0 +1,76 @@
+#!/usr/bin/env php
+<?php
+
+// Check if we are being given a mime.types file or if we should use the
+// default URL.
+$source = count($_SERVER['argv']) > 1 ? $_SERVER['argv'][1] : 'https://raw.githubusercontent.com/apache/httpd/trunk/docs/conf/mime.types';
+
+// See if we can actually load it.
+$types = @file($source);
+if ($types === false) {
+ fprintf(STDERR, "Error: unable to read $source\n");
+ exit(1);
+}
+
+// Remove comments and flip into an extensions array.
+$extensions = [];
+array_walk($types, function ($line) use (&$extensions) {
+ $line = trim($line);
+ if ($line && $line[0] != '#') {
+ $fields = preg_split('/\s+/', $line);
+ if (count($fields) > 1) {
+ $mime = array_shift($fields);
+ foreach ($fields as $extension) {
+ $extensions[$extension] = $mime;
+ }
+ }
+ }
+});
+
+?>
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 7 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2014 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.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. |
+ +----------------------------------------------------------------------+
+ | Author: Moriyoshi Koizumi <moriyoshi@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* This is a generated file. Rather than modifying it, please run
+ * "php generate_mime_type_map.php > mime_type_map.h" to regenerate the file. */
+
+#ifndef PHP_CLI_SERVER_MIME_TYPE_MAP_H
+#define PHP_CLI_SERVER_MIME_TYPE_MAP_H
+
+typedef struct php_cli_server_ext_mime_type_pair {
+ const char *ext;
+ const char *mime_type;
+} php_cli_server_ext_mime_type_pair;
+
+static php_cli_server_ext_mime_type_pair mime_type_map[] = {
+<?php foreach ($extensions as $extension => $mime): ?>
+ { "<?= addcslashes($extension, "\0..\37!@\@\177..\377") ?>", "<?= addcslashes($mime, "\0..\37!@\@\177..\377") ?>" },
+<?php endforeach ?>
+ { NULL, NULL }
+};
+
+#endif /* PHP_CLI_SERVER_MIME_TYPE_MAP_H */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/sapi/cli/mime_type_map.h b/sapi/cli/mime_type_map.h
new file mode 100644
index 0000000000..16f9b7f3ff
--- /dev/null
+++ b/sapi/cli/mime_type_map.h
@@ -0,0 +1,1024 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 7 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2014 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.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. |
+ +----------------------------------------------------------------------+
+ | Author: Moriyoshi Koizumi <moriyoshi@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* This is a generated file. Rather than modifying it, please run
+ * "php generate_mime_type_map.php > mime_type_map.h" to regenerate the file. */
+
+#ifndef PHP_CLI_SERVER_MIME_TYPE_MAP_H
+#define PHP_CLI_SERVER_MIME_TYPE_MAP_H
+
+typedef struct php_cli_server_ext_mime_type_pair {
+ const char *ext;
+ const char *mime_type;
+} php_cli_server_ext_mime_type_pair;
+
+static php_cli_server_ext_mime_type_pair mime_type_map[] = {
+ { "ez", "application/andrew-inset" },
+ { "aw", "application/applixware" },
+ { "atom", "application/atom+xml" },
+ { "atomcat", "application/atomcat+xml" },
+ { "atomsvc", "application/atomsvc+xml" },
+ { "ccxml", "application/ccxml+xml" },
+ { "cdmia", "application/cdmi-capability" },
+ { "cdmic", "application/cdmi-container" },
+ { "cdmid", "application/cdmi-domain" },
+ { "cdmio", "application/cdmi-object" },
+ { "cdmiq", "application/cdmi-queue" },
+ { "cu", "application/cu-seeme" },
+ { "davmount", "application/davmount+xml" },
+ { "dbk", "application/docbook+xml" },
+ { "dssc", "application/dssc+der" },
+ { "xdssc", "application/dssc+xml" },
+ { "ecma", "application/ecmascript" },
+ { "emma", "application/emma+xml" },
+ { "epub", "application/epub+zip" },
+ { "exi", "application/exi" },
+ { "pfr", "application/font-tdpfr" },
+ { "gml", "application/gml+xml" },
+ { "gpx", "application/gpx+xml" },
+ { "gxf", "application/gxf" },
+ { "stk", "application/hyperstudio" },
+ { "ink", "application/inkml+xml" },
+ { "inkml", "application/inkml+xml" },
+ { "ipfix", "application/ipfix" },
+ { "jar", "application/java-archive" },
+ { "ser", "application/java-serialized-object" },
+ { "class", "application/java-vm" },
+ { "js", "application/javascript" },
+ { "json", "application/json" },
+ { "jsonml", "application/jsonml+json" },
+ { "lostxml", "application/lost+xml" },
+ { "hqx", "application/mac-binhex40" },
+ { "cpt", "application/mac-compactpro" },
+ { "mads", "application/mads+xml" },
+ { "mrc", "application/marc" },
+ { "mrcx", "application/marcxml+xml" },
+ { "ma", "application/mathematica" },
+ { "nb", "application/mathematica" },
+ { "mb", "application/mathematica" },
+ { "mathml", "application/mathml+xml" },
+ { "mbox", "application/mbox" },
+ { "mscml", "application/mediaservercontrol+xml" },
+ { "metalink", "application/metalink+xml" },
+ { "meta4", "application/metalink4+xml" },
+ { "mets", "application/mets+xml" },
+ { "mods", "application/mods+xml" },
+ { "m21", "application/mp21" },
+ { "mp21", "application/mp21" },
+ { "mp4s", "application/mp4" },
+ { "doc", "application/msword" },
+ { "dot", "application/msword" },
+ { "mxf", "application/mxf" },
+ { "bin", "application/octet-stream" },
+ { "dms", "application/octet-stream" },
+ { "lrf", "application/octet-stream" },
+ { "mar", "application/octet-stream" },
+ { "so", "application/octet-stream" },
+ { "dist", "application/octet-stream" },
+ { "distz", "application/octet-stream" },
+ { "pkg", "application/octet-stream" },
+ { "bpk", "application/octet-stream" },
+ { "dump", "application/octet-stream" },
+ { "elc", "application/octet-stream" },
+ { "deploy", "application/octet-stream" },
+ { "oda", "application/oda" },
+ { "opf", "application/oebps-package+xml" },
+ { "ogx", "application/ogg" },
+ { "omdoc", "application/omdoc+xml" },
+ { "onetoc", "application/onenote" },
+ { "onetoc2", "application/onenote" },
+ { "onetmp", "application/onenote" },
+ { "onepkg", "application/onenote" },
+ { "oxps", "application/oxps" },
+ { "xer", "application/patch-ops-error+xml" },
+ { "pdf", "application/pdf" },
+ { "pgp", "application/pgp-encrypted" },
+ { "asc", "application/pgp-signature" },
+ { "sig", "application/pgp-signature" },
+ { "prf", "application/pics-rules" },
+ { "p10", "application/pkcs10" },
+ { "p7m", "application/pkcs7-mime" },
+ { "p7c", "application/pkcs7-mime" },
+ { "p7s", "application/pkcs7-signature" },
+ { "p8", "application/pkcs8" },
+ { "ac", "application/pkix-attr-cert" },
+ { "cer", "application/pkix-cert" },
+ { "crl", "application/pkix-crl" },
+ { "pkipath", "application/pkix-pkipath" },
+ { "pki", "application/pkixcmp" },
+ { "pls", "application/pls+xml" },
+ { "ai", "application/postscript" },
+ { "eps", "application/postscript" },
+ { "ps", "application/postscript" },
+ { "cww", "application/prs.cww" },
+ { "pskcxml", "application/pskc+xml" },
+ { "rdf", "application/rdf+xml" },
+ { "rif", "application/reginfo+xml" },
+ { "rnc", "application/relax-ng-compact-syntax" },
+ { "rl", "application/resource-lists+xml" },
+ { "rld", "application/resource-lists-diff+xml" },
+ { "rs", "application/rls-services+xml" },
+ { "gbr", "application/rpki-ghostbusters" },
+ { "mft", "application/rpki-manifest" },
+ { "roa", "application/rpki-roa" },
+ { "rsd", "application/rsd+xml" },
+ { "rss", "application/rss+xml" },
+ { "rtf", "application/rtf" },
+ { "sbml", "application/sbml+xml" },
+ { "scq", "application/scvp-cv-request" },
+ { "scs", "application/scvp-cv-response" },
+ { "spq", "application/scvp-vp-request" },
+ { "spp", "application/scvp-vp-response" },
+ { "sdp", "application/sdp" },
+ { "setpay", "application/set-payment-initiation" },
+ { "setreg", "application/set-registration-initiation" },
+ { "shf", "application/shf+xml" },
+ { "smi", "application/smil+xml" },
+ { "smil", "application/smil+xml" },
+ { "rq", "application/sparql-query" },
+ { "srx", "application/sparql-results+xml" },
+ { "gram", "application/srgs" },
+ { "grxml", "application/srgs+xml" },
+ { "sru", "application/sru+xml" },
+ { "ssdl", "application/ssdl+xml" },
+ { "ssml", "application/ssml+xml" },
+ { "tei", "application/tei+xml" },
+ { "teicorpus", "application/tei+xml" },
+ { "tfi", "application/thraud+xml" },
+ { "tsd", "application/timestamped-data" },
+ { "plb", "application/vnd.3gpp.pic-bw-large" },
+ { "psb", "application/vnd.3gpp.pic-bw-small" },
+ { "pvb", "application/vnd.3gpp.pic-bw-var" },
+ { "tcap", "application/vnd.3gpp2.tcap" },
+ { "pwn", "application/vnd.3m.post-it-notes" },
+ { "aso", "application/vnd.accpac.simply.aso" },
+ { "imp", "application/vnd.accpac.simply.imp" },
+ { "acu", "application/vnd.acucobol" },
+ { "atc", "application/vnd.acucorp" },
+ { "acutc", "application/vnd.acucorp" },
+ { "air", "application/vnd.adobe.air-application-installer-package+zip" },
+ { "fcdt", "application/vnd.adobe.formscentral.fcdt" },
+ { "fxp", "application/vnd.adobe.fxp" },
+ { "fxpl", "application/vnd.adobe.fxp" },
+ { "xdp", "application/vnd.adobe.xdp+xml" },
+ { "xfdf", "application/vnd.adobe.xfdf" },
+ { "ahead", "application/vnd.ahead.space" },
+ { "azf", "application/vnd.airzip.filesecure.azf" },
+ { "azs", "application/vnd.airzip.filesecure.azs" },
+ { "azw", "application/vnd.amazon.ebook" },
+ { "acc", "application/vnd.americandynamics.acc" },
+ { "ami", "application/vnd.amiga.ami" },
+ { "apk", "application/vnd.android.package-archive" },
+ { "cii", "application/vnd.anser-web-certificate-issue-initiation" },
+ { "fti", "application/vnd.anser-web-funds-transfer-initiation" },
+ { "atx", "application/vnd.antix.game-component" },
+ { "mpkg", "application/vnd.apple.installer+xml" },
+ { "m3u8", "application/vnd.apple.mpegurl" },
+ { "swi", "application/vnd.aristanetworks.swi" },
+ { "iota", "application/vnd.astraea-software.iota" },
+ { "aep", "application/vnd.audiograph" },
+ { "mpm", "application/vnd.blueice.multipass" },
+ { "bmi", "application/vnd.bmi" },
+ { "rep", "application/vnd.businessobjects" },
+ { "cdxml", "application/vnd.chemdraw+xml" },
+ { "mmd", "application/vnd.chipnuts.karaoke-mmd" },
+ { "cdy", "application/vnd.cinderella" },
+ { "cla", "application/vnd.claymore" },
+ { "rp9", "application/vnd.cloanto.rp9" },
+ { "c4g", "application/vnd.clonk.c4group" },
+ { "c4d", "application/vnd.clonk.c4group" },
+ { "c4f", "application/vnd.clonk.c4group" },
+ { "c4p", "application/vnd.clonk.c4group" },
+ { "c4u", "application/vnd.clonk.c4group" },
+ { "c11amc", "application/vnd.cluetrust.cartomobile-config" },
+ { "c11amz", "application/vnd.cluetrust.cartomobile-config-pkg" },
+ { "csp", "application/vnd.commonspace" },
+ { "cdbcmsg", "application/vnd.contact.cmsg" },
+ { "cmc", "application/vnd.cosmocaller" },
+ { "clkx", "application/vnd.crick.clicker" },
+ { "clkk", "application/vnd.crick.clicker.keyboard" },
+ { "clkp", "application/vnd.crick.clicker.palette" },
+ { "clkt", "application/vnd.crick.clicker.template" },
+ { "clkw", "application/vnd.crick.clicker.wordbank" },
+ { "wbs", "application/vnd.criticaltools.wbs+xml" },
+ { "pml", "application/vnd.ctc-posml" },
+ { "ppd", "application/vnd.cups-ppd" },
+ { "car", "application/vnd.curl.car" },
+ { "pcurl", "application/vnd.curl.pcurl" },
+ { "dart", "application/vnd.dart" },
+ { "rdz", "application/vnd.data-vision.rdz" },
+ { "uvf", "application/vnd.dece.data" },
+ { "uvvf", "application/vnd.dece.data" },
+ { "uvd", "application/vnd.dece.data" },
+ { "uvvd", "application/vnd.dece.data" },
+ { "uvt", "application/vnd.dece.ttml+xml" },
+ { "uvvt", "application/vnd.dece.ttml+xml" },
+ { "uvx", "application/vnd.dece.unspecified" },
+ { "uvvx", "application/vnd.dece.unspecified" },
+ { "uvz", "application/vnd.dece.zip" },
+ { "uvvz", "application/vnd.dece.zip" },
+ { "fe_launch", "application/vnd.denovo.fcselayout-link" },
+ { "dna", "application/vnd.dna" },
+ { "mlp", "application/vnd.dolby.mlp" },
+ { "dpg", "application/vnd.dpgraph" },
+ { "dfac", "application/vnd.dreamfactory" },
+ { "kpxx", "application/vnd.ds-keypoint" },
+ { "ait", "application/vnd.dvb.ait" },
+ { "svc", "application/vnd.dvb.service" },
+ { "geo", "application/vnd.dynageo" },
+ { "mag", "application/vnd.ecowin.chart" },
+ { "nml", "application/vnd.enliven" },
+ { "esf", "application/vnd.epson.esf" },
+ { "msf", "application/vnd.epson.msf" },
+ { "qam", "application/vnd.epson.quickanime" },
+ { "slt", "application/vnd.epson.salt" },
+ { "ssf", "application/vnd.epson.ssf" },
+ { "es3", "application/vnd.eszigno3+xml" },
+ { "et3", "application/vnd.eszigno3+xml" },
+ { "ez2", "application/vnd.ezpix-album" },
+ { "ez3", "application/vnd.ezpix-package" },
+ { "fdf", "application/vnd.fdf" },
+ { "mseed", "application/vnd.fdsn.mseed" },
+ { "seed", "application/vnd.fdsn.seed" },
+ { "dataless", "application/vnd.fdsn.seed" },
+ { "gph", "application/vnd.flographit" },
+ { "ftc", "application/vnd.fluxtime.clip" },
+ { "fm", "application/vnd.framemaker" },
+ { "frame", "application/vnd.framemaker" },
+ { "maker", "application/vnd.framemaker" },
+ { "book", "application/vnd.framemaker" },
+ { "fnc", "application/vnd.frogans.fnc" },
+ { "ltf", "application/vnd.frogans.ltf" },
+ { "fsc", "application/vnd.fsc.weblaunch" },
+ { "oas", "application/vnd.fujitsu.oasys" },
+ { "oa2", "application/vnd.fujitsu.oasys2" },
+ { "oa3", "application/vnd.fujitsu.oasys3" },
+ { "fg5", "application/vnd.fujitsu.oasysgp" },
+ { "bh2", "application/vnd.fujitsu.oasysprs" },
+ { "ddd", "application/vnd.fujixerox.ddd" },
+ { "xdw", "application/vnd.fujixerox.docuworks" },
+ { "xbd", "application/vnd.fujixerox.docuworks.binder" },
+ { "fzs", "application/vnd.fuzzysheet" },
+ { "txd", "application/vnd.genomatix.tuxedo" },
+ { "ggb", "application/vnd.geogebra.file" },
+ { "ggt", "application/vnd.geogebra.tool" },
+ { "gex", "application/vnd.geometry-explorer" },
+ { "gre", "application/vnd.geometry-explorer" },
+ { "gxt", "application/vnd.geonext" },
+ { "g2w", "application/vnd.geoplan" },
+ { "g3w", "application/vnd.geospace" },
+ { "gmx", "application/vnd.gmx" },
+ { "kml", "application/vnd.google-earth.kml+xml" },
+ { "kmz", "application/vnd.google-earth.kmz" },
+ { "gqf", "application/vnd.grafeq" },
+ { "gqs", "application/vnd.grafeq" },
+ { "gac", "application/vnd.groove-account" },
+ { "ghf", "application/vnd.groove-help" },
+ { "gim", "application/vnd.groove-identity-message" },
+ { "grv", "application/vnd.groove-injector" },
+ { "gtm", "application/vnd.groove-tool-message" },
+ { "tpl", "application/vnd.groove-tool-template" },
+ { "vcg", "application/vnd.groove-vcard" },
+ { "hal", "application/vnd.hal+xml" },
+ { "zmm", "application/vnd.handheld-entertainment+xml" },
+ { "hbci", "application/vnd.hbci" },
+ { "les", "application/vnd.hhe.lesson-player" },
+ { "hpgl", "application/vnd.hp-hpgl" },
+ { "hpid", "application/vnd.hp-hpid" },
+ { "hps", "application/vnd.hp-hps" },
+ { "jlt", "application/vnd.hp-jlyt" },
+ { "pcl", "application/vnd.hp-pcl" },
+ { "pclxl", "application/vnd.hp-pclxl" },
+ { "sfd-hdstx", "application/vnd.hydrostatix.sof-data" },
+ { "mpy", "application/vnd.ibm.minipay" },
+ { "afp", "application/vnd.ibm.modcap" },
+ { "listafp", "application/vnd.ibm.modcap" },
+ { "list3820", "application/vnd.ibm.modcap" },
+ { "irm", "application/vnd.ibm.rights-management" },
+ { "sc", "application/vnd.ibm.secure-container" },
+ { "icc", "application/vnd.iccprofile" },
+ { "icm", "application/vnd.iccprofile" },
+ { "igl", "application/vnd.igloader" },
+ { "ivp", "application/vnd.immervision-ivp" },
+ { "ivu", "application/vnd.immervision-ivu" },
+ { "igm", "application/vnd.insors.igm" },
+ { "xpw", "application/vnd.intercon.formnet" },
+ { "xpx", "application/vnd.intercon.formnet" },
+ { "i2g", "application/vnd.intergeo" },
+ { "qbo", "application/vnd.intu.qbo" },
+ { "qfx", "application/vnd.intu.qfx" },
+ { "rcprofile", "application/vnd.ipunplugged.rcprofile" },
+ { "irp", "application/vnd.irepository.package+xml" },
+ { "xpr", "application/vnd.is-xpr" },
+ { "fcs", "application/vnd.isac.fcs" },
+ { "jam", "application/vnd.jam" },
+ { "rms", "application/vnd.jcp.javame.midlet-rms" },
+ { "jisp", "application/vnd.jisp" },
+ { "joda", "application/vnd.joost.joda-archive" },
+ { "ktz", "application/vnd.kahootz" },
+ { "ktr", "application/vnd.kahootz" },
+ { "karbon", "application/vnd.kde.karbon" },
+ { "chrt", "application/vnd.kde.kchart" },
+ { "kfo", "application/vnd.kde.kformula" },
+ { "flw", "application/vnd.kde.kivio" },
+ { "kon", "application/vnd.kde.kontour" },
+ { "kpr", "application/vnd.kde.kpresenter" },
+ { "kpt", "application/vnd.kde.kpresenter" },
+ { "ksp", "application/vnd.kde.kspread" },
+ { "kwd", "application/vnd.kde.kword" },
+ { "kwt", "application/vnd.kde.kword" },
+ { "htke", "application/vnd.kenameaapp" },
+ { "kia", "application/vnd.kidspiration" },
+ { "kne", "application/vnd.kinar" },
+ { "knp", "application/vnd.kinar" },
+ { "skp", "application/vnd.koan" },
+ { "skd", "application/vnd.koan" },
+ { "skt", "application/vnd.koan" },
+ { "skm", "application/vnd.koan" },
+ { "sse", "application/vnd.kodak-descriptor" },
+ { "lasxml", "application/vnd.las.las+xml" },
+ { "lbd", "application/vnd.llamagraphics.life-balance.desktop" },
+ { "lbe", "application/vnd.llamagraphics.life-balance.exchange+xml" },
+ { "123", "application/vnd.lotus-1-2-3" },
+ { "apr", "application/vnd.lotus-approach" },
+ { "pre", "application/vnd.lotus-freelance" },
+ { "nsf", "application/vnd.lotus-notes" },
+ { "org", "application/vnd.lotus-organizer" },
+ { "scm", "application/vnd.lotus-screencam" },
+ { "lwp", "application/vnd.lotus-wordpro" },
+ { "portpkg", "application/vnd.macports.portpkg" },
+ { "mcd", "application/vnd.mcd" },
+ { "mc1", "application/vnd.medcalcdata" },
+ { "cdkey", "application/vnd.mediastation.cdkey" },
+ { "mwf", "application/vnd.mfer" },
+ { "mfm", "application/vnd.mfmp" },
+ { "flo", "application/vnd.micrografx.flo" },
+ { "igx", "application/vnd.micrografx.igx" },
+ { "mif", "application/vnd.mif" },
+ { "daf", "application/vnd.mobius.daf" },
+ { "dis", "application/vnd.mobius.dis" },
+ { "mbk", "application/vnd.mobius.mbk" },
+ { "mqy", "application/vnd.mobius.mqy" },
+ { "msl", "application/vnd.mobius.msl" },
+ { "plc", "application/vnd.mobius.plc" },
+ { "txf", "application/vnd.mobius.txf" },
+ { "mpn", "application/vnd.mophun.application" },
+ { "mpc", "application/vnd.mophun.certificate" },
+ { "xul", "application/vnd.mozilla.xul+xml" },
+ { "cil", "application/vnd.ms-artgalry" },
+ { "cab", "application/vnd.ms-cab-compressed" },
+ { "xls", "application/vnd.ms-excel" },
+ { "xlm", "application/vnd.ms-excel" },
+ { "xla", "application/vnd.ms-excel" },
+ { "xlc", "application/vnd.ms-excel" },
+ { "xlt", "application/vnd.ms-excel" },
+ { "xlw", "application/vnd.ms-excel" },
+ { "xlam", "application/vnd.ms-excel.addin.macroenabled.12" },
+ { "xlsb", "application/vnd.ms-excel.sheet.binary.macroenabled.12" },
+ { "xlsm", "application/vnd.ms-excel.sheet.macroenabled.12" },
+ { "xltm", "application/vnd.ms-excel.template.macroenabled.12" },
+ { "eot", "application/vnd.ms-fontobject" },
+ { "chm", "application/vnd.ms-htmlhelp" },
+ { "ims", "application/vnd.ms-ims" },
+ { "lrm", "application/vnd.ms-lrm" },
+ { "thmx", "application/vnd.ms-officetheme" },
+ { "cat", "application/vnd.ms-pki.seccat" },
+ { "stl", "application/vnd.ms-pki.stl" },
+ { "ppt", "application/vnd.ms-powerpoint" },
+ { "pps", "application/vnd.ms-powerpoint" },
+ { "pot", "application/vnd.ms-powerpoint" },
+ { "ppam", "application/vnd.ms-powerpoint.addin.macroenabled.12" },
+ { "pptm", "application/vnd.ms-powerpoint.presentation.macroenabled.12" },
+ { "sldm", "application/vnd.ms-powerpoint.slide.macroenabled.12" },
+ { "ppsm", "application/vnd.ms-powerpoint.slideshow.macroenabled.12" },
+ { "potm", "application/vnd.ms-powerpoint.template.macroenabled.12" },
+ { "mpp", "application/vnd.ms-project" },
+ { "mpt", "application/vnd.ms-project" },
+ { "docm", "application/vnd.ms-word.document.macroenabled.12" },
+ { "dotm", "application/vnd.ms-word.template.macroenabled.12" },
+ { "wps", "application/vnd.ms-works" },
+ { "wks", "application/vnd.ms-works" },
+ { "wcm", "application/vnd.ms-works" },
+ { "wdb", "application/vnd.ms-works" },
+ { "wpl", "application/vnd.ms-wpl" },
+ { "xps", "application/vnd.ms-xpsdocument" },
+ { "mseq", "application/vnd.mseq" },
+ { "mus", "application/vnd.musician" },
+ { "msty", "application/vnd.muvee.style" },
+ { "taglet", "application/vnd.mynfc" },
+ { "nlu", "application/vnd.neurolanguage.nlu" },
+ { "ntf", "application/vnd.nitf" },
+ { "nitf", "application/vnd.nitf" },
+ { "nnd", "application/vnd.noblenet-directory" },
+ { "nns", "application/vnd.noblenet-sealer" },
+ { "nnw", "application/vnd.noblenet-web" },
+ { "ngdat", "application/vnd.nokia.n-gage.data" },
+ { "n-gage", "application/vnd.nokia.n-gage.symbian.install" },
+ { "rpst", "application/vnd.nokia.radio-preset" },
+ { "rpss", "application/vnd.nokia.radio-presets" },
+ { "edm", "application/vnd.novadigm.edm" },
+ { "edx", "application/vnd.novadigm.edx" },
+ { "ext", "application/vnd.novadigm.ext" },
+ { "odc", "application/vnd.oasis.opendocument.chart" },
+ { "otc", "application/vnd.oasis.opendocument.chart-template" },
+ { "odb", "application/vnd.oasis.opendocument.database" },
+ { "odf", "application/vnd.oasis.opendocument.formula" },
+ { "odft", "application/vnd.oasis.opendocument.formula-template" },
+ { "odg", "application/vnd.oasis.opendocument.graphics" },
+ { "otg", "application/vnd.oasis.opendocument.graphics-template" },
+ { "odi", "application/vnd.oasis.opendocument.image" },
+ { "oti", "application/vnd.oasis.opendocument.image-template" },
+ { "odp", "application/vnd.oasis.opendocument.presentation" },
+ { "otp", "application/vnd.oasis.opendocument.presentation-template" },
+ { "ods", "application/vnd.oasis.opendocument.spreadsheet" },
+ { "ots", "application/vnd.oasis.opendocument.spreadsheet-template" },
+ { "odt", "application/vnd.oasis.opendocument.text" },
+ { "odm", "application/vnd.oasis.opendocument.text-master" },
+ { "ott", "application/vnd.oasis.opendocument.text-template" },
+ { "oth", "application/vnd.oasis.opendocument.text-web" },
+ { "xo", "application/vnd.olpc-sugar" },
+ { "dd2", "application/vnd.oma.dd2+xml" },
+ { "oxt", "application/vnd.openofficeorg.extension" },
+ { "pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation" },
+ { "sldx", "application/vnd.openxmlformats-officedocument.presentationml.slide" },
+ { "ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow" },
+ { "potx", "application/vnd.openxmlformats-officedocument.presentationml.template" },
+ { "xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" },
+ { "xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template" },
+ { "docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document" },
+ { "dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template" },
+ { "mgp", "application/vnd.osgeo.mapguide.package" },
+ { "dp", "application/vnd.osgi.dp" },
+ { "esa", "application/vnd.osgi.subsystem" },
+ { "pdb", "application/vnd.palm" },
+ { "pqa", "application/vnd.palm" },
+ { "oprc", "application/vnd.palm" },
+ { "paw", "application/vnd.pawaafile" },
+ { "str", "application/vnd.pg.format" },
+ { "ei6", "application/vnd.pg.osasli" },
+ { "efif", "application/vnd.picsel" },
+ { "wg", "application/vnd.pmi.widget" },
+ { "plf", "application/vnd.pocketlearn" },
+ { "pbd", "application/vnd.powerbuilder6" },
+ { "box", "application/vnd.previewsystems.box" },
+ { "mgz", "application/vnd.proteus.magazine" },
+ { "qps", "application/vnd.publishare-delta-tree" },
+ { "ptid", "application/vnd.pvi.ptid1" },
+ { "qxd", "application/vnd.quark.quarkxpress" },
+ { "qxt", "application/vnd.quark.quarkxpress" },
+ { "qwd", "application/vnd.quark.quarkxpress" },
+ { "qwt", "application/vnd.quark.quarkxpress" },
+ { "qxl", "application/vnd.quark.quarkxpress" },
+ { "qxb", "application/vnd.quark.quarkxpress" },
+ { "bed", "application/vnd.realvnc.bed" },
+ { "mxl", "application/vnd.recordare.musicxml" },
+ { "musicxml", "application/vnd.recordare.musicxml+xml" },
+ { "cryptonote", "application/vnd.rig.cryptonote" },
+ { "cod", "application/vnd.rim.cod" },
+ { "rm", "application/vnd.rn-realmedia" },
+ { "rmvb", "application/vnd.rn-realmedia-vbr" },
+ { "link66", "application/vnd.route66.link66+xml" },
+ { "st", "application/vnd.sailingtracker.track" },
+ { "see", "application/vnd.seemail" },
+ { "sema", "application/vnd.sema" },
+ { "semd", "application/vnd.semd" },
+ { "semf", "application/vnd.semf" },
+ { "ifm", "application/vnd.shana.informed.formdata" },
+ { "itp", "application/vnd.shana.informed.formtemplate" },
+ { "iif", "application/vnd.shana.informed.interchange" },
+ { "ipk", "application/vnd.shana.informed.package" },
+ { "twd", "application/vnd.simtech-mindmapper" },
+ { "twds", "application/vnd.simtech-mindmapper" },
+ { "mmf", "application/vnd.smaf" },
+ { "teacher", "application/vnd.smart.teacher" },
+ { "sdkm", "application/vnd.solent.sdkm+xml" },
+ { "sdkd", "application/vnd.solent.sdkm+xml" },
+ { "dxp", "application/vnd.spotfire.dxp" },
+ { "sfs", "application/vnd.spotfire.sfs" },
+ { "sdc", "application/vnd.stardivision.calc" },
+ { "sda", "application/vnd.stardivision.draw" },
+ { "sdd", "application/vnd.stardivision.impress" },
+ { "smf", "application/vnd.stardivision.math" },
+ { "sdw", "application/vnd.stardivision.writer" },
+ { "vor", "application/vnd.stardivision.writer" },
+ { "sgl", "application/vnd.stardivision.writer-global" },
+ { "smzip", "application/vnd.stepmania.package" },
+ { "sm", "application/vnd.stepmania.stepchart" },
+ { "sxc", "application/vnd.sun.xml.calc" },
+ { "stc", "application/vnd.sun.xml.calc.template" },
+ { "sxd", "application/vnd.sun.xml.draw" },
+ { "std", "application/vnd.sun.xml.draw.template" },
+ { "sxi", "application/vnd.sun.xml.impress" },
+ { "sti", "application/vnd.sun.xml.impress.template" },
+ { "sxm", "application/vnd.sun.xml.math" },
+ { "sxw", "application/vnd.sun.xml.writer" },
+ { "sxg", "application/vnd.sun.xml.writer.global" },
+ { "stw", "application/vnd.sun.xml.writer.template" },
+ { "sus", "application/vnd.sus-calendar" },
+ { "susp", "application/vnd.sus-calendar" },
+ { "svd", "application/vnd.svd" },
+ { "sis", "application/vnd.symbian.install" },
+ { "sisx", "application/vnd.symbian.install" },
+ { "xsm", "application/vnd.syncml+xml" },
+ { "bdm", "application/vnd.syncml.dm+wbxml" },
+ { "xdm", "application/vnd.syncml.dm+xml" },
+ { "tao", "application/vnd.tao.intent-module-archive" },
+ { "pcap", "application/vnd.tcpdump.pcap" },
+ { "cap", "application/vnd.tcpdump.pcap" },
+ { "dmp", "application/vnd.tcpdump.pcap" },
+ { "tmo", "application/vnd.tmobile-livetv" },
+ { "tpt", "application/vnd.trid.tpt" },
+ { "mxs", "application/vnd.triscape.mxs" },
+ { "tra", "application/vnd.trueapp" },
+ { "ufd", "application/vnd.ufdl" },
+ { "ufdl", "application/vnd.ufdl" },
+ { "utz", "application/vnd.uiq.theme" },
+ { "umj", "application/vnd.umajin" },
+ { "unityweb", "application/vnd.unity" },
+ { "uoml", "application/vnd.uoml+xml" },
+ { "vcx", "application/vnd.vcx" },
+ { "vsd", "application/vnd.visio" },
+ { "vst", "application/vnd.visio" },
+ { "vss", "application/vnd.visio" },
+ { "vsw", "application/vnd.visio" },
+ { "vis", "application/vnd.visionary" },
+ { "vsf", "application/vnd.vsf" },
+ { "wbxml", "application/vnd.wap.wbxml" },
+ { "wmlc", "application/vnd.wap.wmlc" },
+ { "wmlsc", "application/vnd.wap.wmlscriptc" },
+ { "wtb", "application/vnd.webturbo" },
+ { "nbp", "application/vnd.wolfram.player" },
+ { "wpd", "application/vnd.wordperfect" },
+ { "wqd", "application/vnd.wqd" },
+ { "stf", "application/vnd.wt.stf" },
+ { "xar", "application/vnd.xara" },
+ { "xfdl", "application/vnd.xfdl" },
+ { "hvd", "application/vnd.yamaha.hv-dic" },
+ { "hvs", "application/vnd.yamaha.hv-script" },
+ { "hvp", "application/vnd.yamaha.hv-voice" },
+ { "osf", "application/vnd.yamaha.openscoreformat" },
+ { "osfpvg", "application/vnd.yamaha.openscoreformat.osfpvg+xml" },
+ { "saf", "application/vnd.yamaha.smaf-audio" },
+ { "spf", "application/vnd.yamaha.smaf-phrase" },
+ { "cmp", "application/vnd.yellowriver-custom-menu" },
+ { "zir", "application/vnd.zul" },
+ { "zirz", "application/vnd.zul" },
+ { "zaz", "application/vnd.zzazz.deck+xml" },
+ { "vxml", "application/voicexml+xml" },
+ { "wgt", "application/widget" },
+ { "hlp", "application/winhlp" },
+ { "wsdl", "application/wsdl+xml" },
+ { "wspolicy", "application/wspolicy+xml" },
+ { "7z", "application/x-7z-compressed" },
+ { "abw", "application/x-abiword" },
+ { "ace", "application/x-ace-compressed" },
+ { "dmg", "application/x-apple-diskimage" },
+ { "aab", "application/x-authorware-bin" },
+ { "x32", "application/x-authorware-bin" },
+ { "u32", "application/x-authorware-bin" },
+ { "vox", "application/x-authorware-bin" },
+ { "aam", "application/x-authorware-map" },
+ { "aas", "application/x-authorware-seg" },
+ { "bcpio", "application/x-bcpio" },
+ { "torrent", "application/x-bittorrent" },
+ { "blb", "application/x-blorb" },
+ { "blorb", "application/x-blorb" },
+ { "bz", "application/x-bzip" },
+ { "bz2", "application/x-bzip2" },
+ { "boz", "application/x-bzip2" },
+ { "cbr", "application/x-cbr" },
+ { "cba", "application/x-cbr" },
+ { "cbt", "application/x-cbr" },
+ { "cbz", "application/x-cbr" },
+ { "cb7", "application/x-cbr" },
+ { "vcd", "application/x-cdlink" },
+ { "cfs", "application/x-cfs-compressed" },
+ { "chat", "application/x-chat" },
+ { "pgn", "application/x-chess-pgn" },
+ { "nsc", "application/x-conference" },
+ { "cpio", "application/x-cpio" },
+ { "csh", "application/x-csh" },
+ { "deb", "application/x-debian-package" },
+ { "udeb", "application/x-debian-package" },
+ { "dgc", "application/x-dgc-compressed" },
+ { "dir", "application/x-director" },
+ { "dcr", "application/x-director" },
+ { "dxr", "application/x-director" },
+ { "cst", "application/x-director" },
+ { "cct", "application/x-director" },
+ { "cxt", "application/x-director" },
+ { "w3d", "application/x-director" },
+ { "fgd", "application/x-director" },
+ { "swa", "application/x-director" },
+ { "wad", "application/x-doom" },
+ { "ncx", "application/x-dtbncx+xml" },
+ { "dtb", "application/x-dtbook+xml" },
+ { "res", "application/x-dtbresource+xml" },
+ { "dvi", "application/x-dvi" },
+ { "evy", "application/x-envoy" },
+ { "eva", "application/x-eva" },
+ { "bdf", "application/x-font-bdf" },
+ { "gsf", "application/x-font-ghostscript" },
+ { "psf", "application/x-font-linux-psf" },
+ { "otf", "application/x-font-otf" },
+ { "pcf", "application/x-font-pcf" },
+ { "snf", "application/x-font-snf" },
+ { "ttf", "application/x-font-ttf" },
+ { "ttc", "application/x-font-ttf" },
+ { "pfa", "application/x-font-type1" },
+ { "pfb", "application/x-font-type1" },
+ { "pfm", "application/x-font-type1" },
+ { "afm", "application/x-font-type1" },
+ { "woff", "application/font-woff" },
+ { "arc", "application/x-freearc" },
+ { "spl", "application/x-futuresplash" },
+ { "gca", "application/x-gca-compressed" },
+ { "ulx", "application/x-glulx" },
+ { "gnumeric", "application/x-gnumeric" },
+ { "gramps", "application/x-gramps-xml" },
+ { "gtar", "application/x-gtar" },
+ { "hdf", "application/x-hdf" },
+ { "install", "application/x-install-instructions" },
+ { "iso", "application/x-iso9660-image" },
+ { "jnlp", "application/x-java-jnlp-file" },
+ { "latex", "application/x-latex" },
+ { "lzh", "application/x-lzh-compressed" },
+ { "lha", "application/x-lzh-compressed" },
+ { "mie", "application/x-mie" },
+ { "prc", "application/x-mobipocket-ebook" },
+ { "mobi", "application/x-mobipocket-ebook" },
+ { "application", "application/x-ms-application" },
+ { "lnk", "application/x-ms-shortcut" },
+ { "wmd", "application/x-ms-wmd" },
+ { "wmz", "application/x-msmetafile" },
+ { "xbap", "application/x-ms-xbap" },
+ { "mdb", "application/x-msaccess" },
+ { "obd", "application/x-msbinder" },
+ { "crd", "application/x-mscardfile" },
+ { "clp", "application/x-msclip" },
+ { "exe", "application/x-msdownload" },
+ { "dll", "application/x-msdownload" },
+ { "com", "application/x-msdownload" },
+ { "bat", "application/x-msdownload" },
+ { "msi", "application/x-msdownload" },
+ { "mvb", "application/x-msmediaview" },
+ { "m13", "application/x-msmediaview" },
+ { "m14", "application/x-msmediaview" },
+ { "wmf", "application/x-msmetafile" },
+ { "emf", "application/x-msmetafile" },
+ { "emz", "application/x-msmetafile" },
+ { "mny", "application/x-msmoney" },
+ { "pub", "application/x-mspublisher" },
+ { "scd", "application/x-msschedule" },
+ { "trm", "application/x-msterminal" },
+ { "wri", "application/x-mswrite" },
+ { "nc", "application/x-netcdf" },
+ { "cdf", "application/x-netcdf" },
+ { "nzb", "application/x-nzb" },
+ { "p12", "application/x-pkcs12" },
+ { "pfx", "application/x-pkcs12" },
+ { "p7b", "application/x-pkcs7-certificates" },
+ { "spc", "application/x-pkcs7-certificates" },
+ { "p7r", "application/x-pkcs7-certreqresp" },
+ { "rar", "application/x-rar-compressed" },
+ { "ris", "application/x-research-info-systems" },
+ { "sh", "application/x-sh" },
+ { "shar", "application/x-shar" },
+ { "swf", "application/x-shockwave-flash" },
+ { "xap", "application/x-silverlight-app" },
+ { "sql", "application/x-sql" },
+ { "sit", "application/x-stuffit" },
+ { "sitx", "application/x-stuffitx" },
+ { "srt", "application/x-subrip" },
+ { "sv4cpio", "application/x-sv4cpio" },
+ { "sv4crc", "application/x-sv4crc" },
+ { "t3", "application/x-t3vm-image" },
+ { "gam", "application/x-tads" },
+ { "tar", "application/x-tar" },
+ { "tcl", "application/x-tcl" },
+ { "tex", "application/x-tex" },
+ { "tfm", "application/x-tex-tfm" },
+ { "texinfo", "application/x-texinfo" },
+ { "texi", "application/x-texinfo" },
+ { "obj", "application/x-tgif" },
+ { "ustar", "application/x-ustar" },
+ { "src", "application/x-wais-source" },
+ { "der", "application/x-x509-ca-cert" },
+ { "crt", "application/x-x509-ca-cert" },
+ { "fig", "application/x-xfig" },
+ { "xlf", "application/x-xliff+xml" },
+ { "xpi", "application/x-xpinstall" },
+ { "xz", "application/x-xz" },
+ { "z1", "application/x-zmachine" },
+ { "z2", "application/x-zmachine" },
+ { "z3", "application/x-zmachine" },
+ { "z4", "application/x-zmachine" },
+ { "z5", "application/x-zmachine" },
+ { "z6", "application/x-zmachine" },
+ { "z7", "application/x-zmachine" },
+ { "z8", "application/x-zmachine" },
+ { "xaml", "application/xaml+xml" },
+ { "xdf", "application/xcap-diff+xml" },
+ { "xenc", "application/xenc+xml" },
+ { "xhtml", "application/xhtml+xml" },
+ { "xht", "application/xhtml+xml" },
+ { "xml", "application/xml" },
+ { "xsl", "application/xml" },
+ { "dtd", "application/xml-dtd" },
+ { "xop", "application/xop+xml" },
+ { "xpl", "application/xproc+xml" },
+ { "xslt", "application/xslt+xml" },
+ { "xspf", "application/xspf+xml" },
+ { "mxml", "application/xv+xml" },
+ { "xhvml", "application/xv+xml" },
+ { "xvml", "application/xv+xml" },
+ { "xvm", "application/xv+xml" },
+ { "yang", "application/yang" },
+ { "yin", "application/yin+xml" },
+ { "zip", "application/zip" },
+ { "adp", "audio/adpcm" },
+ { "au", "audio/basic" },
+ { "snd", "audio/basic" },
+ { "mid", "audio/midi" },
+ { "midi", "audio/midi" },
+ { "kar", "audio/midi" },
+ { "rmi", "audio/midi" },
+ { "mp4a", "audio/mp4" },
+ { "mpga", "audio/mpeg" },
+ { "mp2", "audio/mpeg" },
+ { "mp2a", "audio/mpeg" },
+ { "mp3", "audio/mpeg" },
+ { "m2a", "audio/mpeg" },
+ { "m3a", "audio/mpeg" },
+ { "oga", "audio/ogg" },
+ { "ogg", "audio/ogg" },
+ { "spx", "audio/ogg" },
+ { "s3m", "audio/s3m" },
+ { "sil", "audio/silk" },
+ { "uva", "audio/vnd.dece.audio" },
+ { "uvva", "audio/vnd.dece.audio" },
+ { "eol", "audio/vnd.digital-winds" },
+ { "dra", "audio/vnd.dra" },
+ { "dts", "audio/vnd.dts" },
+ { "dtshd", "audio/vnd.dts.hd" },
+ { "lvp", "audio/vnd.lucent.voice" },
+ { "pya", "audio/vnd.ms-playready.media.pya" },
+ { "ecelp4800", "audio/vnd.nuera.ecelp4800" },
+ { "ecelp7470", "audio/vnd.nuera.ecelp7470" },
+ { "ecelp9600", "audio/vnd.nuera.ecelp9600" },
+ { "rip", "audio/vnd.rip" },
+ { "weba", "audio/webm" },
+ { "aac", "audio/x-aac" },
+ { "aif", "audio/x-aiff" },
+ { "aiff", "audio/x-aiff" },
+ { "aifc", "audio/x-aiff" },
+ { "caf", "audio/x-caf" },
+ { "flac", "audio/x-flac" },
+ { "mka", "audio/x-matroska" },
+ { "m3u", "audio/x-mpegurl" },
+ { "wax", "audio/x-ms-wax" },
+ { "wma", "audio/x-ms-wma" },
+ { "ram", "audio/x-pn-realaudio" },
+ { "ra", "audio/x-pn-realaudio" },
+ { "rmp", "audio/x-pn-realaudio-plugin" },
+ { "wav", "audio/x-wav" },
+ { "xm", "audio/xm" },
+ { "cdx", "chemical/x-cdx" },
+ { "cif", "chemical/x-cif" },
+ { "cmdf", "chemical/x-cmdf" },
+ { "cml", "chemical/x-cml" },
+ { "csml", "chemical/x-csml" },
+ { "xyz", "chemical/x-xyz" },
+ { "bmp", "image/bmp" },
+ { "cgm", "image/cgm" },
+ { "g3", "image/g3fax" },
+ { "gif", "image/gif" },
+ { "ief", "image/ief" },
+ { "jpeg", "image/jpeg" },
+ { "jpg", "image/jpeg" },
+ { "jpe", "image/jpeg" },
+ { "ktx", "image/ktx" },
+ { "png", "image/png" },
+ { "btif", "image/prs.btif" },
+ { "sgi", "image/sgi" },
+ { "svg", "image/svg+xml" },
+ { "svgz", "image/svg+xml" },
+ { "tiff", "image/tiff" },
+ { "tif", "image/tiff" },
+ { "psd", "image/vnd.adobe.photoshop" },
+ { "uvi", "image/vnd.dece.graphic" },
+ { "uvvi", "image/vnd.dece.graphic" },
+ { "uvg", "image/vnd.dece.graphic" },
+ { "uvvg", "image/vnd.dece.graphic" },
+ { "sub", "text/vnd.dvb.subtitle" },
+ { "djvu", "image/vnd.djvu" },
+ { "djv", "image/vnd.djvu" },
+ { "dwg", "image/vnd.dwg" },
+ { "dxf", "image/vnd.dxf" },
+ { "fbs", "image/vnd.fastbidsheet" },
+ { "fpx", "image/vnd.fpx" },
+ { "fst", "image/vnd.fst" },
+ { "mmr", "image/vnd.fujixerox.edmics-mmr" },
+ { "rlc", "image/vnd.fujixerox.edmics-rlc" },
+ { "mdi", "image/vnd.ms-modi" },
+ { "wdp", "image/vnd.ms-photo" },
+ { "npx", "image/vnd.net-fpx" },
+ { "wbmp", "image/vnd.wap.wbmp" },
+ { "xif", "image/vnd.xiff" },
+ { "webp", "image/webp" },
+ { "3ds", "image/x-3ds" },
+ { "ras", "image/x-cmu-raster" },
+ { "cmx", "image/x-cmx" },
+ { "fh", "image/x-freehand" },
+ { "fhc", "image/x-freehand" },
+ { "fh4", "image/x-freehand" },
+ { "fh5", "image/x-freehand" },
+ { "fh7", "image/x-freehand" },
+ { "ico", "image/x-icon" },
+ { "sid", "image/x-mrsid-image" },
+ { "pcx", "image/x-pcx" },
+ { "pic", "image/x-pict" },
+ { "pct", "image/x-pict" },
+ { "pnm", "image/x-portable-anymap" },
+ { "pbm", "image/x-portable-bitmap" },
+ { "pgm", "image/x-portable-graymap" },
+ { "ppm", "image/x-portable-pixmap" },
+ { "rgb", "image/x-rgb" },
+ { "tga", "image/x-tga" },
+ { "xbm", "image/x-xbitmap" },
+ { "xpm", "image/x-xpixmap" },
+ { "xwd", "image/x-xwindowdump" },
+ { "eml", "message/rfc822" },
+ { "mime", "message/rfc822" },
+ { "igs", "model/iges" },
+ { "iges", "model/iges" },
+ { "msh", "model/mesh" },
+ { "mesh", "model/mesh" },
+ { "silo", "model/mesh" },
+ { "dae", "model/vnd.collada+xml" },
+ { "dwf", "model/vnd.dwf" },
+ { "gdl", "model/vnd.gdl" },
+ { "gtw", "model/vnd.gtw" },
+ { "mts", "model/vnd.mts" },
+ { "vtu", "model/vnd.vtu" },
+ { "wrl", "model/vrml" },
+ { "vrml", "model/vrml" },
+ { "x3db", "model/x3d+binary" },
+ { "x3dbz", "model/x3d+binary" },
+ { "x3dv", "model/x3d+vrml" },
+ { "x3dvz", "model/x3d+vrml" },
+ { "x3d", "model/x3d+xml" },
+ { "x3dz", "model/x3d+xml" },
+ { "appcache", "text/cache-manifest" },
+ { "ics", "text/calendar" },
+ { "ifb", "text/calendar" },
+ { "css", "text/css" },
+ { "csv", "text/csv" },
+ { "html", "text/html" },
+ { "htm", "text/html" },
+ { "n3", "text/n3" },
+ { "txt", "text/plain" },
+ { "text", "text/plain" },
+ { "conf", "text/plain" },
+ { "def", "text/plain" },
+ { "list", "text/plain" },
+ { "log", "text/plain" },
+ { "in", "text/plain" },
+ { "dsc", "text/prs.lines.tag" },
+ { "rtx", "text/richtext" },
+ { "sgml", "text/sgml" },
+ { "sgm", "text/sgml" },
+ { "tsv", "text/tab-separated-values" },
+ { "t", "text/troff" },
+ { "tr", "text/troff" },
+ { "roff", "text/troff" },
+ { "man", "text/troff" },
+ { "me", "text/troff" },
+ { "ms", "text/troff" },
+ { "ttl", "text/turtle" },
+ { "uri", "text/uri-list" },
+ { "uris", "text/uri-list" },
+ { "urls", "text/uri-list" },
+ { "vcard", "text/vcard" },
+ { "curl", "text/vnd.curl" },
+ { "dcurl", "text/vnd.curl.dcurl" },
+ { "scurl", "text/vnd.curl.scurl" },
+ { "mcurl", "text/vnd.curl.mcurl" },
+ { "fly", "text/vnd.fly" },
+ { "flx", "text/vnd.fmi.flexstor" },
+ { "gv", "text/vnd.graphviz" },
+ { "3dml", "text/vnd.in3d.3dml" },
+ { "spot", "text/vnd.in3d.spot" },
+ { "jad", "text/vnd.sun.j2me.app-descriptor" },
+ { "wml", "text/vnd.wap.wml" },
+ { "wmls", "text/vnd.wap.wmlscript" },
+ { "s", "text/x-asm" },
+ { "asm", "text/x-asm" },
+ { "c", "text/x-c" },
+ { "cc", "text/x-c" },
+ { "cxx", "text/x-c" },
+ { "cpp", "text/x-c" },
+ { "h", "text/x-c" },
+ { "hh", "text/x-c" },
+ { "dic", "text/x-c" },
+ { "f", "text/x-fortran" },
+ { "for", "text/x-fortran" },
+ { "f77", "text/x-fortran" },
+ { "f90", "text/x-fortran" },
+ { "java", "text/x-java-source" },
+ { "opml", "text/x-opml" },
+ { "p", "text/x-pascal" },
+ { "pas", "text/x-pascal" },
+ { "nfo", "text/x-nfo" },
+ { "etx", "text/x-setext" },
+ { "sfv", "text/x-sfv" },
+ { "uu", "text/x-uuencode" },
+ { "vcs", "text/x-vcalendar" },
+ { "vcf", "text/x-vcard" },
+ { "3gp", "video/3gpp" },
+ { "3g2", "video/3gpp2" },
+ { "h261", "video/h261" },
+ { "h263", "video/h263" },
+ { "h264", "video/h264" },
+ { "jpgv", "video/jpeg" },
+ { "jpm", "video/jpm" },
+ { "jpgm", "video/jpm" },
+ { "mj2", "video/mj2" },
+ { "mjp2", "video/mj2" },
+ { "mp4", "video/mp4" },
+ { "mp4v", "video/mp4" },
+ { "mpg4", "video/mp4" },
+ { "mpeg", "video/mpeg" },
+ { "mpg", "video/mpeg" },
+ { "mpe", "video/mpeg" },
+ { "m1v", "video/mpeg" },
+ { "m2v", "video/mpeg" },
+ { "ogv", "video/ogg" },
+ { "qt", "video/quicktime" },
+ { "mov", "video/quicktime" },
+ { "uvh", "video/vnd.dece.hd" },
+ { "uvvh", "video/vnd.dece.hd" },
+ { "uvm", "video/vnd.dece.mobile" },
+ { "uvvm", "video/vnd.dece.mobile" },
+ { "uvp", "video/vnd.dece.pd" },
+ { "uvvp", "video/vnd.dece.pd" },
+ { "uvs", "video/vnd.dece.sd" },
+ { "uvvs", "video/vnd.dece.sd" },
+ { "uvv", "video/vnd.dece.video" },
+ { "uvvv", "video/vnd.dece.video" },
+ { "dvb", "video/vnd.dvb.file" },
+ { "fvt", "video/vnd.fvt" },
+ { "mxu", "video/vnd.mpegurl" },
+ { "m4u", "video/vnd.mpegurl" },
+ { "pyv", "video/vnd.ms-playready.media.pyv" },
+ { "uvu", "video/vnd.uvvu.mp4" },
+ { "uvvu", "video/vnd.uvvu.mp4" },
+ { "viv", "video/vnd.vivo" },
+ { "webm", "video/webm" },
+ { "f4v", "video/x-f4v" },
+ { "fli", "video/x-fli" },
+ { "flv", "video/x-flv" },
+ { "m4v", "video/x-m4v" },
+ { "mkv", "video/x-matroska" },
+ { "mk3d", "video/x-matroska" },
+ { "mks", "video/x-matroska" },
+ { "mng", "video/x-mng" },
+ { "asf", "video/x-ms-asf" },
+ { "asx", "video/x-ms-asf" },
+ { "vob", "video/x-ms-vob" },
+ { "wm", "video/x-ms-wm" },
+ { "wmv", "video/x-ms-wmv" },
+ { "wmx", "video/x-ms-wmx" },
+ { "wvx", "video/x-ms-wvx" },
+ { "avi", "video/x-msvideo" },
+ { "movie", "video/x-sgi-movie" },
+ { "smv", "video/x-smv" },
+ { "ice", "x-conference/x-cooltalk" },
+ { NULL, NULL }
+};
+
+#endif /* PHP_CLI_SERVER_MIME_TYPE_MAP_H */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index 9daa382eec..ef45ef6ef9 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -173,8 +173,9 @@ const opt_struct OPTIONS[] = {
{'-', 0, NULL} /* end of args */
};
-static int print_module_info(zend_module_entry *module TSRMLS_DC) /* {{{ */
+static int print_module_info(zval *element TSRMLS_DC) /* {{{ */
{
+ zend_module_entry *module = (zend_module_entry*)Z_PTR_P(element);
php_printf("%s\n", module->name);
return ZEND_HASH_APPLY_KEEP;
}
@@ -182,23 +183,22 @@ static int print_module_info(zend_module_entry *module TSRMLS_DC) /* {{{ */
static int module_name_cmp(const void *a, const void *b TSRMLS_DC) /* {{{ */
{
- Bucket *f = *((Bucket **) a);
- Bucket *s = *((Bucket **) b);
+ Bucket *f = (Bucket *) a;
+ Bucket *s = (Bucket *) b;
- return strcasecmp(((zend_module_entry *)f->pData)->name,
- ((zend_module_entry *)s->pData)->name);
+ return strcasecmp(((zend_module_entry *)Z_PTR(f->val))->name,
+ ((zend_module_entry *)Z_PTR(s->val))->name);
}
/* }}} */
static void print_modules(TSRMLS_D) /* {{{ */
{
HashTable sorted_registry;
- zend_module_entry tmp;
- zend_hash_init(&sorted_registry, 50, NULL, NULL, 1);
- zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry));
+ zend_hash_init(&sorted_registry, 50, NULL, NULL, 0);
+ zend_hash_copy(&sorted_registry, &module_registry, NULL);
zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC);
- zend_hash_apply(&sorted_registry, (apply_func_t) print_module_info TSRMLS_CC);
+ zend_hash_apply(&sorted_registry, print_module_info TSRMLS_CC);
zend_hash_destroy(&sorted_registry);
}
/* }}} */
@@ -244,7 +244,7 @@ static inline int sapi_cli_select(int fd TSRMLS_DC)
PHP_SAFE_FD_SET(fd, &wfd);
- tv.tv_sec = FG(default_socket_timeout);
+ tv.tv_sec = (long)FG(default_socket_timeout);
tv.tv_usec = 0;
ret = php_select(fd+1, &dfd, &wfd, &dfd, &tv);
@@ -252,10 +252,10 @@ static inline int sapi_cli_select(int fd TSRMLS_DC)
return ret != -1;
}
-PHP_CLI_API size_t sapi_cli_single_write(const char *str, uint str_length TSRMLS_DC) /* {{{ */
+PHP_CLI_API size_t sapi_cli_single_write(const char *str, size_t str_length TSRMLS_DC) /* {{{ */
{
#ifdef PHP_WRITE_STDOUT
- long ret;
+ zend_long ret;
#else
size_t ret;
#endif
@@ -285,10 +285,10 @@ PHP_CLI_API size_t sapi_cli_single_write(const char *str, uint str_length TSRMLS
}
/* }}} */
-static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ */
+static size_t sapi_cli_ub_write(const char *str, size_t str_length TSRMLS_DC) /* {{{ */
{
const char *ptr = str;
- uint remaining = str_length;
+ size_t remaining = str_length;
size_t ret;
if (!str_length) {
@@ -296,7 +296,7 @@ static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{
}
if (cli_shell_callbacks.cli_shell_ub_write) {
- int ub_wrote;
+ size_t ub_wrote;
ub_wrote = cli_shell_callbacks.cli_shell_ub_write(str, str_length TSRMLS_CC);
if (ub_wrote > -1) {
return ub_wrote;
@@ -320,7 +320,7 @@ static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{
}
/* }}} */
-static void sapi_cli_flush(void *server_context) /* {{{ */
+static void sapi_cli_flush(void *server_context TSRMLS_DC) /* {{{ */
{
/* Ignore EBADF here, it's caused by the fact that STDIN/STDOUT/STDERR streams
* are/could be closed before fflush() is called.
@@ -338,7 +338,7 @@ static char *script_filename = "";
static void sapi_cli_register_variables(zval *track_vars_array TSRMLS_DC) /* {{{ */
{
- unsigned int len;
+ size_t len;
char *docroot = "";
/* In CGI mode, we consider the environment to be a part of the server
@@ -425,10 +425,8 @@ static int php_cli_startup(sapi_module_struct *sapi_module) /* {{{ */
/* overwriteable ini defaults must be set in sapi_cli_ini_defaults() */
#define INI_DEFAULT(name,value)\
- Z_SET_REFCOUNT(tmp, 0);\
- Z_UNSET_ISREF(tmp); \
- ZVAL_STRINGL(&tmp, zend_strndup(value, sizeof(value)-1), sizeof(value)-1, 0);\
- zend_hash_update(configuration_hash, name, sizeof(name), &tmp, sizeof(zval), NULL);\
+ ZVAL_NEW_STR(&tmp, zend_string_init(value, sizeof(value)-1, 1));\
+ zend_hash_str_update(configuration_hash, name, sizeof(name)-1, &tmp);\
static void sapi_cli_ini_defaults(HashTable *configuration_hash)
{
@@ -553,23 +551,16 @@ static php_stream *s_in_process = NULL;
static void cli_register_file_handles(TSRMLS_D) /* {{{ */
{
- zval *zin, *zout, *zerr;
+ zval zin, zout, zerr;
php_stream *s_in, *s_out, *s_err;
php_stream_context *sc_in=NULL, *sc_out=NULL, *sc_err=NULL;
zend_constant ic, oc, ec;
- MAKE_STD_ZVAL(zin);
- MAKE_STD_ZVAL(zout);
- MAKE_STD_ZVAL(zerr);
-
s_in = php_stream_open_wrapper_ex("php://stdin", "rb", 0, NULL, sc_in);
s_out = php_stream_open_wrapper_ex("php://stdout", "wb", 0, NULL, sc_out);
s_err = php_stream_open_wrapper_ex("php://stderr", "wb", 0, NULL, sc_err);
if (s_in==NULL || s_out==NULL || s_err==NULL) {
- FREE_ZVAL(zin);
- FREE_ZVAL(zout);
- FREE_ZVAL(zerr);
if (s_in) php_stream_close(s_in);
if (s_out) php_stream_close(s_out);
if (s_err) php_stream_close(s_err);
@@ -584,34 +575,27 @@ static void cli_register_file_handles(TSRMLS_D) /* {{{ */
s_in_process = s_in;
- php_stream_to_zval(s_in, zin);
- php_stream_to_zval(s_out, zout);
- php_stream_to_zval(s_err, zerr);
+ php_stream_to_zval(s_in, &zin);
+ php_stream_to_zval(s_out, &zout);
+ php_stream_to_zval(s_err, &zerr);
- ic.value = *zin;
+ ZVAL_COPY_VALUE(&ic.value, &zin);
ic.flags = CONST_CS;
- ic.name = zend_strndup(ZEND_STRL("STDIN"));
- ic.name_len = sizeof("STDIN");
+ ic.name = zend_string_init("STDIN", sizeof("STDIN")-1, 1);
ic.module_number = 0;
zend_register_constant(&ic TSRMLS_CC);
- oc.value = *zout;
+ ZVAL_COPY_VALUE(&oc.value, &zout);
oc.flags = CONST_CS;
- oc.name = zend_strndup(ZEND_STRL("STDOUT"));
- oc.name_len = sizeof("STDOUT");
+ oc.name = zend_string_init("STDOUT", sizeof("STDOUT")-1, 1);
oc.module_number = 0;
zend_register_constant(&oc TSRMLS_CC);
- ec.value = *zerr;
+ ZVAL_COPY_VALUE(&ec.value, &zerr);
ec.flags = CONST_CS;
- ec.name = zend_strndup(ZEND_STRL("STDERR"));
- ec.name_len = sizeof("STDERR");
+ ec.name = zend_string_init("STDERR", sizeof("STDERR")-1, 1);
ec.module_number = 0;
zend_register_constant(&ec TSRMLS_CC);
-
- FREE_ZVAL(zin);
- FREE_ZVAL(zout);
- FREE_ZVAL(zerr);
}
/* }}} */
@@ -643,8 +627,8 @@ static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file,
/* handle situations where line is terminated by \r\n */
if (c == '\r') {
if (fgetc(file_handle->handle.fp) != '\n') {
- long pos = ftell(file_handle->handle.fp);
- fseek(file_handle->handle.fp, pos - 1, SEEK_SET);
+ zend_long pos = zend_ftell(file_handle->handle.fp);
+ zend_fseek(file_handle->handle.fp, pos - 1, SEEK_SET);
}
}
*lineno = 2;
@@ -673,11 +657,11 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
int lineno = 0;
const char *param_error=NULL;
int hide_argv = 0;
+ zend_string *key;
zend_try {
CG(in_compilation) = 0; /* not initialized but needed for several options */
- EG(uninitialized_zval_ptr) = NULL;
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
switch (c) {
@@ -870,7 +854,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
break;
case 'z': /* load extension file */
- zend_load_extension(php_optarg);
+ zend_load_extension(php_optarg TSRMLS_CC);
break;
case 'H':
hide_argv = 1;
@@ -918,8 +902,6 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
fflush(stdout);
}
- CG(interactive) = interactive;
-
/* only set script_file if not set already and not in direct mode and not at end of parameter list */
if (argc > php_optind
&& !script_file
@@ -979,7 +961,9 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
}
}
- zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
+ key = zend_string_init("_SERVER", sizeof("_SERVER")-1, 0);
+ zend_is_auto_global(key TSRMLS_CC);
+ zend_string_release(key);
PG(during_request_startup) = 0;
switch (behavior) {
@@ -1024,7 +1008,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
/* Zeev might want to do something with this one day */
case PHP_MODE_INDENT:
open_file_for_scanning(&file_handle TSRMLS_CC);
- zend_indent();
+ zend_indent(TSRMLS_C);
zend_file_handle_dtor(file_handle.handle TSRMLS_CC);
goto out;
break;
@@ -1040,30 +1024,23 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
{
char *input;
size_t len, index = 0;
- zval *argn, *argi;
+ zval argn, argi;
cli_register_file_handles(TSRMLS_C);
if (exec_begin && zend_eval_string_ex(exec_begin, NULL, "Command line begin code", 1 TSRMLS_CC) == FAILURE) {
exit_status=254;
}
- ALLOC_ZVAL(argi);
- Z_TYPE_P(argi) = IS_LONG;
- Z_LVAL_P(argi) = index;
- INIT_PZVAL(argi);
- zend_hash_update(&EG(symbol_table), "argi", sizeof("argi"), &argi, sizeof(zval *), NULL);
+ ZVAL_LONG(&argi, index);
+ zend_hash_str_update(&EG(symbol_table).ht, "argi", sizeof("argi")-1, &argi);
while (exit_status == SUCCESS && (input=php_stream_gets(s_in_process, NULL, 0)) != NULL) {
len = strlen(input);
- while (len-- && (input[len]=='\n' || input[len]=='\r')) {
+ while (len > 0 && len-- && (input[len]=='\n' || input[len]=='\r')) {
input[len] = '\0';
}
- ALLOC_ZVAL(argn);
- Z_TYPE_P(argn) = IS_STRING;
- Z_STRLEN_P(argn) = ++len;
- Z_STRVAL_P(argn) = estrndup(input, len);
- INIT_PZVAL(argn);
- zend_hash_update(&EG(symbol_table), "argn", sizeof("argn"), &argn, sizeof(zval *), NULL);
- Z_LVAL_P(argi) = ++index;
+ ZVAL_STRINGL(&argn, input, len);
+ zend_hash_str_update(&EG(symbol_table).ht, "argn", sizeof("argn")-1, &argn);
+ Z_LVAL(argi) = ++index;
if (exec_run) {
if (zend_eval_string_ex(exec_run, NULL, "Command line run code", 1 TSRMLS_CC) == FAILURE) {
exit_status=254;
@@ -1087,13 +1064,14 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
break;
}
+
case PHP_MODE_REFLECTION_FUNCTION:
case PHP_MODE_REFLECTION_CLASS:
case PHP_MODE_REFLECTION_EXTENSION:
case PHP_MODE_REFLECTION_ZEND_EXTENSION:
{
zend_class_entry *pce = NULL;
- zval *arg, *ref;
+ zval arg, ref;
zend_execute_data execute_data;
switch (behavior) {
@@ -1117,24 +1095,23 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
break;
}
- MAKE_STD_ZVAL(arg);
- ZVAL_STRING(arg, reflection_what, 1);
- ALLOC_ZVAL(ref);
- object_init_ex(ref, pce);
- INIT_PZVAL(ref);
+ ZVAL_STRING(&arg, reflection_what);
+ object_init_ex(&ref, pce);
memset(&execute_data, 0, sizeof(zend_execute_data));
EG(current_execute_data) = &execute_data;
- EX(function_state).function = pce->constructor;
- zend_call_method_with_1_params(&ref, pce, &pce->constructor, "__construct", NULL, arg);
+ zend_call_method_with_1_params(&ref, pce, &pce->constructor, "__construct", NULL, &arg);
if (EG(exception)) {
- zval *msg = zend_read_property(zend_exception_get_default(TSRMLS_C), EG(exception), "message", sizeof("message")-1, 0 TSRMLS_CC);
+ zval tmp, *msg;
+
+ ZVAL_OBJ(&tmp, EG(exception));
+ msg = zend_read_property(zend_exception_get_default(TSRMLS_C), &tmp, "message", sizeof("message")-1, 0 TSRMLS_CC);
zend_printf("Exception: %s\n", Z_STRVAL_P(msg));
- zval_ptr_dtor(&EG(exception));
+ zval_ptr_dtor(&tmp);
EG(exception) = NULL;
} else {
- zend_call_method_with_1_params(NULL, reflection_ptr, NULL, "export", NULL, ref);
+ zend_call_method_with_1_params(NULL, reflection_ptr, NULL, "export", NULL, &ref);
}
zval_ptr_dtor(&ref);
zval_ptr_dtor(&arg);
@@ -1143,11 +1120,11 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
}
case PHP_MODE_REFLECTION_EXT_INFO:
{
- int len = strlen(reflection_what);
+ int len = (int)strlen(reflection_what);
char *lcname = zend_str_tolower_dup(reflection_what, len);
zend_module_entry *module;
- if (zend_hash_find(&module_registry, lcname, len+1, (void**)&module) == FAILURE) {
+ if ((module = zend_hash_str_find_ptr(&module_registry, lcname, len)) == NULL) {
if (!strcmp(reflection_what, "main")) {
display_ini_entries(NULL);
} else {
@@ -1161,6 +1138,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
efree(lcname);
break;
}
+
case PHP_MODE_SHOW_INI_CONFIG:
{
zend_printf("Configuration File (php.ini) Path: %s\n", PHP_CONFIG_FILE_PATH);
@@ -1280,7 +1258,7 @@ int main(int argc, char *argv[])
break;
case 'd': {
/* define ini entries on command line */
- int len = strlen(php_optarg);
+ int len = (int)strlen(php_optarg);
char *val;
if ((val = strchr(php_optarg, '='))) {
@@ -1288,11 +1266,11 @@ int main(int argc, char *argv[])
if (!isalnum(*val) && *val != '"' && *val != '\'' && *val != '\0') {
ini_entries = realloc(ini_entries, ini_entries_len + len + sizeof("\"\"\n\0"));
memcpy(ini_entries + ini_entries_len, php_optarg, (val - php_optarg));
- ini_entries_len += (val - php_optarg);
+ ini_entries_len += (int)(val - php_optarg);
memcpy(ini_entries + ini_entries_len, "\"", 1);
ini_entries_len++;
memcpy(ini_entries + ini_entries_len, val, len - (val - php_optarg));
- ini_entries_len += len - (val - php_optarg);
+ ini_entries_len += len - (int)(val - php_optarg);
memcpy(ini_entries + ini_entries_len, "\"\n\0", sizeof("\"\n\0"));
ini_entries_len += sizeof("\n\0\"") - 2;
} else {
diff --git a/sapi/cli/php_cli_process_title.c b/sapi/cli/php_cli_process_title.c
index dec5613670..28fbdfb518 100644
--- a/sapi/cli/php_cli_process_title.c
+++ b/sapi/cli/php_cli_process_title.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -31,7 +31,7 @@
PHP_FUNCTION(cli_set_process_title)
{
char *title = NULL;
- int title_len;
+ size_t title_len;
int rc;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &title, &title_len) == FAILURE) {
@@ -66,7 +66,7 @@ PHP_FUNCTION(cli_get_process_title)
RETURN_NULL();
}
- RETURN_STRINGL(title, length, 1);
+ RETURN_STRINGL(title, length);
}
/* }}} */
diff --git a/sapi/cli/php_cli_process_title.h b/sapi/cli/php_cli_process_title.h
index bd44d99111..b93947a81f 100644
--- a/sapi/cli/php_cli_process_title.h
+++ b/sapi/cli/php_cli_process_title.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index f333addafd..19a94218ff 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -96,7 +96,7 @@
#endif
#include "ext/standard/file.h" /* for php_set_sock_blocking() :-( */
-#include "ext/standard/php_smart_str.h"
+#include "zend_smart_str.h"
#include "ext/standard/html.h"
#include "ext/standard/url.h" /* for php_url_decode() */
#include "ext/standard/php_string.h" /* for php_dirname() */
@@ -104,6 +104,7 @@
#include "php_http_parser.h"
#include "php_cli_server.h"
+#include "mime_type_map.h"
#include "php_cli_process_title.h"
@@ -138,7 +139,7 @@ typedef struct php_cli_server_request {
size_t content_len;
const char *ext;
size_t ext_len;
- struct stat sb;
+ zend_stat_t sb;
} php_cli_server_request;
typedef struct php_cli_server_chunk {
@@ -194,6 +195,7 @@ typedef struct php_cli_server {
size_t router_len;
socklen_t socklen;
HashTable clients;
+ HashTable extension_mime_types;
} php_cli_server;
typedef struct php_cli_server_http_response_status_code_pair {
@@ -201,11 +203,6 @@ typedef struct php_cli_server_http_response_status_code_pair {
const char *str;
} php_cli_server_http_response_status_code_pair;
-typedef struct php_cli_server_ext_mime_type_pair {
- const char *ext;
- const char *mime_type;
-} php_cli_server_ext_mime_type_pair;
-
static php_cli_server_http_response_status_code_pair status_map[] = {
{ 100, "Continue" },
{ 101, "Switching Protocols" },
@@ -262,64 +259,6 @@ static php_cli_server_http_response_status_code_pair template_map[] = {
{ 501, "<h1>%s</h1><p>Request method not supported.</p>" }
};
-static php_cli_server_ext_mime_type_pair mime_type_map[] = {
- { "html", "text/html" },
- { "htm", "text/html" },
- { "js", "text/javascript" },
- { "css", "text/css" },
- { "gif", "image/gif" },
- { "jpg", "image/jpeg" },
- { "jpeg", "image/jpeg" },
- { "jpe", "image/jpeg" },
- { "pdf", "application/pdf" },
- { "png", "image/png" },
- { "svg", "image/svg+xml" },
- { "txt", "text/plain" },
- { "webm", "video/webm" },
- { "ogv", "video/ogg" },
- { "ogg", "audio/ogg" },
- { "3gp", "video/3gpp" }, /* This is standard video format used for MMS in phones */
- { "apk", "application/vnd.android.package-archive" },
- { "avi", "video/x-msvideo" },
- { "bmp", "image/x-ms-bmp" },
- { "csv", "text/comma-separated-values" },
- { "doc", "application/msword" },
- { "docx", "application/msword" },
- { "flac", "audio/flac" },
- { "gz", "application/x-gzip" },
- { "gzip", "application/x-gzip" },
- { "ics", "text/calendar" },
- { "kml", "application/vnd.google-earth.kml+xml" },
- { "kmz", "application/vnd.google-earth.kmz" },
- { "m4a", "audio/mp4" },
- { "mp3", "audio/mpeg" },
- { "mp4", "video/mp4" },
- { "mpg", "video/mpeg" },
- { "mpeg", "video/mpeg" },
- { "mov", "video/quicktime" },
- { "odp", "application/vnd.oasis.opendocument.presentation" },
- { "ods", "application/vnd.oasis.opendocument.spreadsheet" },
- { "odt", "application/vnd.oasis.opendocument.text" },
- { "oga", "audio/ogg" },
- { "pdf", "application/pdf" },
- { "pptx", "application/vnd.ms-powerpoint" },
- { "pps", "application/vnd.ms-powerpoint" },
- { "qt", "video/quicktime" },
- { "swf", "application/x-shockwave-flash" },
- { "tar", "application/x-tar" },
- { "text", "text/plain" },
- { "tif", "image/tiff" },
- { "wav", "audio/wav" },
- { "wmv", "video/x-ms-wmv" },
- { "xls", "application/vnd.ms-excel" },
- { "xlsx", "application/vnd.ms-excel" },
- { "zip", "application/x-zip-compressed" },
- { "xml", "application/xml" },
- { "xsl", "application/xml" },
- { "xsd", "application/xml" },
- { NULL, NULL }
-};
-
static int php_cli_output_is_tty = OUTPUT_NOT_CHECKED;
static size_t php_cli_server_client_send_through(php_cli_server_client *client, const char *str, size_t str_len);
@@ -371,9 +310,9 @@ int php_cli_server_get_system_time(char *buf) {
}
#endif
-static void char_ptr_dtor_p(char **p) /* {{{ */
-{
- pefree(*p, 1);
+static void char_ptr_dtor_p(zval *zv) /* {{{ */
+{
+ pefree(Z_PTR_P(zv), 1);
} /* }}} */
static char *get_last_error() /* {{{ */
@@ -441,11 +380,11 @@ static void append_http_status_line(smart_str *buffer, int protocol_version, int
}
smart_str_appendl_ex(buffer, "HTTP", 4, persistent);
smart_str_appendc_ex(buffer, '/', persistent);
- smart_str_append_generic_ex(buffer, protocol_version / 100, persistent, int, _unsigned);
+ smart_str_append_long_ex(buffer, protocol_version / 100, persistent);
smart_str_appendc_ex(buffer, '.', persistent);
- smart_str_append_generic_ex(buffer, protocol_version % 100, persistent, int, _unsigned);
+ smart_str_append_long_ex(buffer, protocol_version % 100, persistent);
smart_str_appendc_ex(buffer, ' ', persistent);
- smart_str_append_generic_ex(buffer, response_code, persistent, int, _unsigned);
+ smart_str_append_long_ex(buffer, response_code, persistent);
smart_str_appendc_ex(buffer, ' ', persistent);
smart_str_appends_ex(buffer, get_status_string(response_code), persistent);
smart_str_appendl_ex(buffer, "\r\n", 2, persistent);
@@ -454,37 +393,29 @@ static void append_http_status_line(smart_str *buffer, int protocol_version, int
static void append_essential_headers(smart_str* buffer, php_cli_server_client *client, int persistent) /* {{{ */
{
{
- char **val;
- if (SUCCESS == zend_hash_find(&client->request.headers, "host", sizeof("host"), (void**)&val)) {
+ char *val;
+ if (NULL != (val = zend_hash_str_find_ptr(&client->request.headers, "host", sizeof("host")-1))) {
smart_str_appendl_ex(buffer, "Host", sizeof("Host") - 1, persistent);
smart_str_appendl_ex(buffer, ": ", sizeof(": ") - 1, persistent);
- smart_str_appends_ex(buffer, *val, persistent);
+ smart_str_appends_ex(buffer, val, persistent);
smart_str_appendl_ex(buffer, "\r\n", 2, persistent);
}
}
smart_str_appendl_ex(buffer, "Connection: close\r\n", sizeof("Connection: close\r\n") - 1, persistent);
} /* }}} */
-static const char *get_mime_type(const char *ext, size_t ext_len) /* {{{ */
+static const char *get_mime_type(const php_cli_server *server, const char *ext, size_t ext_len) /* {{{ */
{
- php_cli_server_ext_mime_type_pair *pair;
- for (pair = mime_type_map; pair->ext; pair++) {
- size_t len = strlen(pair->ext);
- if (len == ext_len && memcmp(pair->ext, ext, len) == 0) {
- return pair->mime_type;
- }
- }
- return NULL;
+ return (const char*)zend_hash_str_find_ptr(&server->extension_mime_types, ext, ext_len);
} /* }}} */
PHP_FUNCTION(apache_request_headers) /* {{{ */
{
php_cli_server_client *client;
HashTable *headers;
- char *key;
- uint key_len;
- char **value_pointer;
- HashPosition pos;
+ zend_string *key;
+ char *value;
+ zval tmp;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -495,19 +426,17 @@ PHP_FUNCTION(apache_request_headers) /* {{{ */
array_init_size(return_value, zend_hash_num_elements(headers));
- zend_hash_internal_pointer_reset_ex(headers, &pos);
- while (zend_hash_get_current_data_ex(headers, (void **)&value_pointer, &pos) == SUCCESS) {
- zend_hash_get_current_key_ex(headers, &key, &key_len, NULL, 0, &pos);
- add_assoc_string_ex(return_value, key, key_len, *value_pointer, 1);
- zend_hash_move_forward_ex(headers, &pos);
- }
+ ZEND_HASH_FOREACH_STR_KEY_PTR(headers, key, value) {
+ ZVAL_STRING(&tmp, value);
+ zend_symtable_update(Z_ARRVAL_P(return_value), key, &tmp);
+ } ZEND_HASH_FOREACH_END();
}
/* }}} */
static void add_response_header(sapi_header_struct *h, zval *return_value TSRMLS_DC) /* {{{ */
{
char *s, *p;
- int len;
+ ptrdiff_t len;
ALLOCA_FLAG(use_heap)
if (h->header_len > 0) {
@@ -524,7 +453,7 @@ static void add_response_header(sapi_header_struct *h, zval *return_value TSRMLS
do {
p++;
} while (*p == ' ' || *p == '\t');
- add_assoc_stringl_ex(return_value, s, len+1, p, h->header_len - (p - h->header), 1);
+ add_assoc_stringl_ex(return_value, s, (uint)len, p, h->header_len - (p - h->header));
free_alloca(s, use_heap);
}
}
@@ -610,7 +539,7 @@ static int sapi_cli_server_startup(sapi_module_struct *sapi_module) /* {{{ */
return SUCCESS;
} /* }}} */
-static int sapi_cli_server_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ */
+static size_t sapi_cli_server_ub_write(const char *str, size_t str_length TSRMLS_DC) /* {{{ */
{
php_cli_server_client *client = SG(server_context);
if (!client) {
@@ -619,10 +548,9 @@ static int sapi_cli_server_ub_write(const char *str, uint str_length TSRMLS_DC)
return php_cli_server_client_send_through(client, str, str_length);
} /* }}} */
-static void sapi_cli_server_flush(void *server_context) /* {{{ */
+static void sapi_cli_server_flush(void *server_context TSRMLS_DC) /* {{{ */
{
php_cli_server_client *client = server_context;
- TSRMLS_FETCH();
if (!client) {
return;
@@ -674,7 +602,7 @@ static int sapi_cli_server_send_headers(sapi_headers_struct *sapi_headers TSRMLS
}
smart_str_appendl(&buffer, "\r\n", 2);
- php_cli_server_client_send_through(client, buffer.c, buffer.len);
+ php_cli_server_client_send_through(client, buffer.s->val, buffer.s->len);
smart_str_free(&buffer);
return SAPI_HEADER_SENT_SUCCESSFULLY;
@@ -684,14 +612,14 @@ static int sapi_cli_server_send_headers(sapi_headers_struct *sapi_headers TSRMLS
static char *sapi_cli_server_read_cookies(TSRMLS_D) /* {{{ */
{
php_cli_server_client *client = SG(server_context);
- char **val;
- if (FAILURE == zend_hash_find(&client->request.headers, "cookie", sizeof("cookie"), (void**)&val)) {
+ char *val;
+ if (NULL == (val = zend_hash_str_find_ptr(&client->request.headers, "cookie", sizeof("cookie")-1))) {
return NULL;
}
- return *val;
+ return val;
} /* }}} */
-static int sapi_cli_server_read_post(char *buf, uint count_bytes TSRMLS_DC) /* {{{ */
+static size_t sapi_cli_server_read_post(char *buf, size_t count_bytes TSRMLS_DC) /* {{{ */
{
php_cli_server_client *client = SG(server_context);
if (client->request.content) {
@@ -707,7 +635,7 @@ static int sapi_cli_server_read_post(char *buf, uint count_bytes TSRMLS_DC) /* {
static void sapi_cli_server_register_variable(zval *track_vars_array, const char *key, const char *val TSRMLS_DC) /* {{{ */
{
char *new_val = (char *)val;
- uint new_val_len;
+ size_t new_val_len;
if (sapi_module.input_filter(PARSE_SERVER, (char*)key, &new_val, strlen(val), &new_val_len TSRMLS_CC)) {
php_register_variable_safe((char *)key, new_val, new_val_len, track_vars_array TSRMLS_CC);
}
@@ -715,11 +643,11 @@ static void sapi_cli_server_register_variable(zval *track_vars_array, const char
static int sapi_cli_server_register_entry_cb(char **entry TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ {
zval *track_vars_array = va_arg(args, zval *);
- if (hash_key->nKeyLength) {
+ if (hash_key->key) {
char *real_key, *key;
uint i;
- key = estrndup(hash_key->arKey, hash_key->nKeyLength);
- for(i=0; i<hash_key->nKeyLength; i++) {
+ key = estrndup(hash_key->key->val, hash_key->key->len);
+ for(i=0; i<hash_key->key->len; i++) {
if (key[i] == '-') {
key[i] = '_';
} else {
@@ -861,7 +789,7 @@ static int php_cli_server_poller_ctor(php_cli_server_poller *poller) /* {{{ */
return SUCCESS;
} /* }}} */
-static void php_cli_server_poller_add(php_cli_server_poller *poller, int mode, int fd) /* {{{ */
+static void php_cli_server_poller_add(php_cli_server_poller *poller, int mode, php_socket_t fd) /* {{{ */
{
if (mode & POLLIN) {
PHP_SAFE_FD_SET(fd, &poller->rfds);
@@ -874,7 +802,7 @@ static void php_cli_server_poller_add(php_cli_server_poller *poller, int mode, i
}
} /* }}} */
-static void php_cli_server_poller_remove(php_cli_server_poller *poller, int mode, int fd) /* {{{ */
+static void php_cli_server_poller_remove(php_cli_server_poller *poller, int mode, php_socket_t fd) /* {{{ */
{
if (mode & POLLIN) {
PHP_SAFE_FD_CLR(fd, &poller->rfds);
@@ -902,7 +830,7 @@ static int php_cli_server_poller_poll(php_cli_server_poller *poller, struct time
return php_select(poller->max_fd + 1, &poller->active.rfds, &poller->active.wfds, NULL, tv);
} /* }}} */
-static int php_cli_server_poller_iter_on_active(php_cli_server_poller *poller, void *opaque, int(*callback)(void *, int fd, int events)) /* {{{ */
+static int php_cli_server_poller_iter_on_active(php_cli_server_poller *poller, void *opaque, int(*callback)(void *, php_socket_t fd, int events)) /* {{{ */
{
int retval = SUCCESS;
#ifdef PHP_WIN32
@@ -1053,7 +981,7 @@ static php_cli_server_chunk *php_cli_server_chunk_immortal_new(const char *buf,
return chunk;
} /* }}} */
-static php_cli_server_chunk *php_cli_server_chunk_heap_new(char *block, char *buf, size_t len) /* {{{ */
+static php_cli_server_chunk *php_cli_server_chunk_heap_new(void *block, char *buf, size_t len) /* {{{ */
{
php_cli_server_chunk *chunk = pemalloc(sizeof(php_cli_server_chunk), 1);
if (!chunk) {
@@ -1099,12 +1027,20 @@ static int php_cli_server_content_sender_send(php_cli_server_content_sender *sen
size_t _nbytes_sent_total = 0;
for (chunk = sender->buffer.first; chunk; chunk = next) {
+#ifdef PHP_WIN32
+ int nbytes_sent;
+#else
ssize_t nbytes_sent;
+#endif
next = chunk->next;
switch (chunk->type) {
case PHP_CLI_SERVER_CHUNK_HEAP:
+#ifdef PHP_WIN32
+ nbytes_sent = send(fd, chunk->data.heap.p, (int)chunk->data.heap.len, 0);
+#else
nbytes_sent = send(fd, chunk->data.heap.p, chunk->data.heap.len, 0);
+#endif
if (nbytes_sent < 0) {
*nbytes_sent_total = _nbytes_sent_total;
return php_socket_errno();
@@ -1123,7 +1059,11 @@ static int php_cli_server_content_sender_send(php_cli_server_content_sender *sen
break;
case PHP_CLI_SERVER_CHUNK_IMMORTAL:
+#ifdef PHP_WIN32
+ nbytes_sent = send(fd, chunk->data.immortal.p, (int)chunk->data.immortal.len, 0);
+#else
nbytes_sent = send(fd, chunk->data.immortal.p, chunk->data.immortal.len, 0);
+#endif
if (nbytes_sent < 0) {
*nbytes_sent_total = _nbytes_sent_total;
return php_socket_errno();
@@ -1146,15 +1086,22 @@ static int php_cli_server_content_sender_send(php_cli_server_content_sender *sen
return 0;
} /* }}} */
-static int php_cli_server_content_sender_pull(php_cli_server_content_sender *sender, int fd, size_t *nbytes_read) /* {{{ */
+static int php_cli_server_content_sender_pull(php_cli_server_content_sender *sender, int fd, size_t *nbytes_read TSRMLS_DC) /* {{{ */
{
+#ifdef PHP_WIN32
+ int _nbytes_read;
+#else
ssize_t _nbytes_read;
+#endif
php_cli_server_chunk *chunk = php_cli_server_chunk_heap_new_self_contained(131072);
+#ifdef PHP_WIN32
+ _nbytes_read = read(fd, chunk->data.heap.p, (unsigned int)chunk->data.heap.len);
+#else
_nbytes_read = read(fd, chunk->data.heap.p, chunk->data.heap.len);
+#endif
if (_nbytes_read < 0) {
char *errstr = get_last_error();
- TSRMLS_FETCH();
php_cli_server_logf("%s" TSRMLS_CC, errstr);
pefree(errstr, 1);
php_cli_server_chunk_dtor(chunk);
@@ -1280,9 +1227,9 @@ static void php_cli_server_logf(const char *format TSRMLS_DC, ...) /* {{{ */
efree(buf);
} /* }}} */
-static int php_network_listen_socket(const char *host, int *port, int socktype, int *af, socklen_t *socklen, char **errstr TSRMLS_DC) /* {{{ */
+static php_socket_t php_network_listen_socket(const char *host, int *port, int socktype, int *af, socklen_t *socklen, zend_string **errstr TSRMLS_DC) /* {{{ */
{
- int retval = SOCK_ERR;
+ php_socket_t retval = SOCK_ERR;
int err = 0;
struct sockaddr *sa = NULL, **p, **sal;
@@ -1395,7 +1342,7 @@ out:
closesocket(retval);
}
if (errstr) {
- *errstr = php_socket_strerror(err, NULL, 0);
+ *errstr = php_socket_error_str(err);
}
return SOCK_ERR;
}
@@ -1415,7 +1362,7 @@ static int php_cli_server_request_ctor(php_cli_server_request *req) /* {{{ */
req->path_info_len = 0;
req->query_string = NULL;
req->query_string_len = 0;
- zend_hash_init(&req->headers, 0, NULL, (void(*)(void*))char_ptr_dtor_p, 1);
+ zend_hash_init(&req->headers, 0, NULL, char_ptr_dtor_p, 1);
zend_hash_init(&req->headers_original_case, 0, NULL, NULL, 1);
req->content = NULL;
req->content_len = 0;
@@ -1450,7 +1397,7 @@ static void php_cli_server_request_dtor(php_cli_server_request *req) /* {{{ */
static void php_cli_server_request_translate_vpath(php_cli_server_request *request, const char *document_root, size_t document_root_len) /* {{{ */
{
- struct stat sb;
+ zend_stat_t sb;
static const char *index_files[] = { "index.php", "index.html", NULL };
char *buf = safe_pemalloc(1, request->vpath_len, 1 + document_root_len + 1 + sizeof("index.html"), 1);
char *p = buf, *prev_path = NULL, *q, *vpath;
@@ -1487,7 +1434,7 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque
*p = '\0';
q = p;
while (q > buf) {
- if (!stat(buf, &sb)) {
+ if (!zend_stat(buf, &sb)) {
if (sb.st_mode & S_IFDIR) {
const char **file = index_files;
if (q[-1] != DEFAULT_SLASH) {
@@ -1496,7 +1443,7 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque
while (*file) {
size_t l = strlen(*file);
memmove(q, *file, l + 1);
- if (!stat(buf, &sb) && (sb.st_mode & S_IFREG)) {
+ if (!zend_stat(buf, &sb) && (sb.st_mode & S_IFREG)) {
q += l;
break;
}
@@ -1569,7 +1516,7 @@ static void normalize_vpath(char **retval, size_t *retval_len, const char *vpath
return;
}
- decoded_vpath_end = decoded_vpath + php_url_decode(decoded_vpath, vpath_len);
+ decoded_vpath_end = decoded_vpath + php_url_decode(decoded_vpath, (int)vpath_len);
p = decoded_vpath;
@@ -1686,13 +1633,12 @@ static int php_cli_server_client_read_request_on_header_value(php_http_parser *p
}
{
/* strip off the colon */
- char *orig_header_name = estrndup(client->current_header_name, client->current_header_name_len);
+ zend_string *orig_header_name = zend_string_init(client->current_header_name, client->current_header_name_len, 1);
char *lc_header_name = zend_str_tolower_dup(client->current_header_name, client->current_header_name_len);
-
- zend_hash_add(&client->request.headers, lc_header_name, client->current_header_name_len + 1, &value, sizeof(char *), NULL);
- zend_hash_add(&client->request.headers_original_case, orig_header_name, client->current_header_name_len + 1, &value, sizeof(char *), NULL);
+ zend_hash_str_add_ptr(&client->request.headers, lc_header_name, client->current_header_name_len, value);
+ zend_hash_add_ptr(&client->request.headers_original_case, orig_header_name, value);
efree(lc_header_name);
- efree(orig_header_name);
+ zend_string_release(orig_header_name);
}
if (client->current_header_name_allocated) {
@@ -1810,9 +1756,19 @@ static int php_cli_server_client_read_request(php_cli_server_client *client, cha
static size_t php_cli_server_client_send_through(php_cli_server_client *client, const char *str, size_t str_len) /* {{{ */
{
struct timeval tv = { 10, 0 };
- ssize_t nbytes_left = str_len;
+#ifdef PHP_WIN32
+ int nbytes_left = (int)str_len;
+#else
+ ssize_t nbytes_left = (ssize_t)str_len;
+#endif
do {
- ssize_t nbytes_sent = send(client->sock, str + str_len - nbytes_left, nbytes_left, 0);
+#ifdef PHP_WIN32
+ int nbytes_sent;
+#else
+ ssize_t nbytes_sent;
+#endif
+
+ nbytes_sent = send(client->sock, str + str_len - nbytes_left, nbytes_left, 0);
if (nbytes_sent < 0) {
int err = php_socket_errno();
if (err == SOCK_EAGAIN) {
@@ -1841,7 +1797,7 @@ static size_t php_cli_server_client_send_through(php_cli_server_client *client,
static void php_cli_server_client_populate_request_info(const php_cli_server_client *client, sapi_request_info *request_info) /* {{{ */
{
- char **val;
+ char *val;
request_info->request_method = php_http_method_str(client->request.request_method);
request_info->proto_num = client->request.protocol_version;
@@ -1850,8 +1806,8 @@ static void php_cli_server_client_populate_request_info(const php_cli_server_cli
request_info->query_string = client->request.query_string;
request_info->content_length = client->request.content_len;
request_info->auth_user = request_info->auth_password = request_info->auth_digest = NULL;
- if (SUCCESS == zend_hash_find(&client->request.headers, "content-type", sizeof("content-type"), (void**)&val)) {
- request_info->content_type = *val;
+ if (NULL != (val = zend_hash_str_find_ptr(&client->request.headers, "content-type", sizeof("content-type")-1))) {
+ request_info->content_type = val;
}
} /* }}} */
@@ -1859,19 +1815,19 @@ static void destroy_request_info(sapi_request_info *request_info) /* {{{ */
{
} /* }}} */
-static int php_cli_server_client_ctor(php_cli_server_client *client, php_cli_server *server, int client_sock, struct sockaddr *addr, socklen_t addr_len TSRMLS_DC) /* {{{ */
+static int php_cli_server_client_ctor(php_cli_server_client *client, php_cli_server *server, php_socket_t client_sock, struct sockaddr *addr, socklen_t addr_len TSRMLS_DC) /* {{{ */
{
client->server = server;
client->sock = client_sock;
client->addr = addr;
client->addr_len = addr_len;
{
- char *addr_str = 0;
- long addr_str_len = 0;
- php_network_populate_name_from_sockaddr(addr, addr_len, &addr_str, &addr_str_len, NULL, 0 TSRMLS_CC);
- client->addr_str = pestrndup(addr_str, addr_str_len, 1);
- client->addr_str_len = addr_str_len;
- efree(addr_str);
+ zend_string *addr_str = 0;
+
+ php_network_populate_name_from_sockaddr(addr, addr_len, &addr_str, NULL, 0 TSRMLS_CC);
+ client->addr_str = pestrndup(addr_str->val, addr_str->len, 1);
+ client->addr_str_len = addr_str->len;
+ zend_string_release(addr_str);
}
php_http_parser_init(&client->parser, PHP_HTTP_REQUEST);
client->request_read = 0;
@@ -1911,8 +1867,7 @@ static void php_cli_server_close_connection(php_cli_server *server, php_cli_serv
static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server_client *client, int status TSRMLS_DC) /* {{{ */
{
- char *escaped_request_uri = NULL;
- size_t escaped_request_uri_len;
+ zend_string *escaped_request_uri = NULL;
const char *status_string = get_status_string(status);
const char *content_template = get_template_string(status);
char *errstr = get_last_error();
@@ -1921,7 +1876,7 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server
php_cli_server_content_sender_ctor(&client->content_sender);
client->content_sender_initialized = 1;
- escaped_request_uri = php_escape_html_entities_ex((unsigned char *)client->request.request_uri, client->request.request_uri_len, &escaped_request_uri_len, 0, ENT_QUOTES, NULL, 0 TSRMLS_CC);
+ escaped_request_uri = php_escape_html_entities_ex((unsigned char *)client->request.request_uri, client->request.request_uri_len, 0, ENT_QUOTES, NULL, 0 TSRMLS_CC);
{
static const char prologue_template[] = "<!doctype html><html><head><title>%d %s</title>";
@@ -1929,7 +1884,7 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server
if (!chunk) {
goto fail;
}
- snprintf(chunk->data.heap.p, chunk->data.heap.len, prologue_template, status, status_string, escaped_request_uri);
+ snprintf(chunk->data.heap.p, chunk->data.heap.len, prologue_template, status, status_string, escaped_request_uri->val);
chunk->data.heap.len = strlen(chunk->data.heap.p);
php_cli_server_buffer_append(&client->content_sender.buffer, chunk);
}
@@ -1949,11 +1904,11 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server
php_cli_server_buffer_append(&client->content_sender.buffer, chunk);
}
{
- php_cli_server_chunk *chunk = php_cli_server_chunk_heap_new_self_contained(strlen(content_template) + escaped_request_uri_len + 3 + strlen(status_string) + 1);
+ php_cli_server_chunk *chunk = php_cli_server_chunk_heap_new_self_contained(strlen(content_template) + escaped_request_uri->len + 3 + strlen(status_string) + 1);
if (!chunk) {
goto fail;
}
- snprintf(chunk->data.heap.p, chunk->data.heap.len, content_template, status_string, escaped_request_uri);
+ snprintf(chunk->data.heap.p, chunk->data.heap.len, content_template, status_string, escaped_request_uri->val);
chunk->data.heap.len = strlen(chunk->data.heap.p);
php_cli_server_buffer_append(&client->content_sender.buffer, chunk);
}
@@ -1970,20 +1925,20 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server
php_cli_server_chunk *chunk;
smart_str buffer = { 0 };
append_http_status_line(&buffer, client->request.protocol_version, status, 1);
- if (!buffer.c) {
+ if (!buffer.s) {
/* out of memory */
goto fail;
}
append_essential_headers(&buffer, client, 1);
smart_str_appends_ex(&buffer, "Content-Type: text/html; charset=UTF-8\r\n", 1);
smart_str_appends_ex(&buffer, "Content-Length: ", 1);
- smart_str_append_generic_ex(&buffer, php_cli_server_buffer_size(&client->content_sender.buffer), 1, size_t, _unsigned);
+ smart_str_append_unsigned_ex(&buffer, php_cli_server_buffer_size(&client->content_sender.buffer), 1);
smart_str_appendl_ex(&buffer, "\r\n", 2, 1);
smart_str_appendl_ex(&buffer, "\r\n", 2, 1);
- chunk = php_cli_server_chunk_heap_new(buffer.c, buffer.c, buffer.len);
+ chunk = php_cli_server_chunk_heap_new(buffer.s, buffer.s->val, buffer.s->len);
if (!chunk) {
- smart_str_free_ex(&buffer, 1);
+ smart_str_free(&buffer);
goto fail;
}
php_cli_server_buffer_prepend(&client->content_sender.buffer, chunk);
@@ -1994,14 +1949,14 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server
if (errstr) {
pefree(errstr, 1);
}
- efree(escaped_request_uri);
+ zend_string_free(escaped_request_uri);
return SUCCESS;
fail:
if (errstr) {
pefree(errstr, 1);
}
- efree(escaped_request_uri);
+ zend_string_free(escaped_request_uri);
return FAILURE;
} /* }}} */
@@ -2049,13 +2004,13 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv
{
php_cli_server_chunk *chunk;
smart_str buffer = { 0 };
- const char *mime_type = get_mime_type(client->request.ext, client->request.ext_len);
+ const char *mime_type = get_mime_type(server, client->request.ext, client->request.ext_len);
if (!mime_type) {
mime_type = "application/octet-stream";
}
append_http_status_line(&buffer, client->request.protocol_version, status, 1);
- if (!buffer.c) {
+ if (!buffer.s) {
/* out of memory */
php_cli_server_log_response(client, 500, NULL TSRMLS_CC);
return FAILURE;
@@ -2068,12 +2023,12 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv
}
smart_str_appendl_ex(&buffer, "\r\n", 2, 1);
smart_str_appends_ex(&buffer, "Content-Length: ", 1);
- smart_str_append_generic_ex(&buffer, client->request.sb.st_size, 1, size_t, _unsigned);
+ smart_str_append_unsigned_ex(&buffer, client->request.sb.st_size, 1);
smart_str_appendl_ex(&buffer, "\r\n", 2, 1);
smart_str_appendl_ex(&buffer, "\r\n", 2, 1);
- chunk = php_cli_server_chunk_heap_new(buffer.c, buffer.c, buffer.len);
+ chunk = php_cli_server_chunk_heap_new(buffer.s, buffer.s->val, buffer.s->len);
if (!chunk) {
- smart_str_free_ex(&buffer, 1);
+ smart_str_free(&buffer);
php_cli_server_log_response(client, 500, NULL TSRMLS_CC);
return FAILURE;
}
@@ -2086,10 +2041,10 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv
/* }}} */
static int php_cli_server_request_startup(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) { /* {{{ */
- char **auth;
+ char *auth;
php_cli_server_client_populate_request_info(client, &SG(request_info));
- if (SUCCESS == zend_hash_find(&client->request.headers, "authorization", sizeof("authorization"), (void**)&auth)) {
- php_handle_auth_data(*auth TSRMLS_CC);
+ if (NULL != (auth = zend_hash_str_find_ptr(&client->request.headers, "authorization", sizeof("authorization")-1))) {
+ php_handle_auth_data(auth TSRMLS_CC);
}
SG(sapi_headers).http_response_code = 200;
if (FAILURE == php_request_startup(TSRMLS_C)) {
@@ -2131,10 +2086,10 @@ static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server
zfd.opened_path = NULL;
zend_try {
- zval *retval = NULL;
+ zval retval;
if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, &retval, 1, &zfd)) {
- if (retval) {
- decline = Z_TYPE_P(retval) == IS_BOOL && !Z_LVAL_P(retval);
+ if (Z_TYPE(retval) != IS_UNDEF) {
+ decline = Z_TYPE(retval) == IS_FALSE;
zval_ptr_dtor(&retval);
}
} else {
@@ -2209,9 +2164,28 @@ static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client
}
/* }}} */
+static int php_cli_server_mime_type_ctor(php_cli_server *server, const php_cli_server_ext_mime_type_pair *mime_type_map) /* {{{ */
+{
+ const php_cli_server_ext_mime_type_pair *pair;
+
+ zend_hash_init(&server->extension_mime_types, 0, NULL, NULL, 1);
+
+ for (pair = mime_type_map; pair->ext; pair++) {
+ size_t ext_len = 0, mime_type_len = 0;
+
+ ext_len = strlen(pair->ext);
+ mime_type_len = strlen(pair->mime_type);
+
+ zend_hash_str_add_mem(&server->extension_mime_types, pair->ext, ext_len, (void*)pair->mime_type, mime_type_len + 1);
+ }
+
+ return SUCCESS;
+} /* }}} */
+
static void php_cli_server_dtor(php_cli_server *server TSRMLS_DC) /* {{{ */
{
zend_hash_destroy(&server->clients);
+ zend_hash_destroy(&server->extension_mime_types);
if (server->server_sock >= 0) {
closesocket(server->server_sock);
}
@@ -2226,19 +2200,21 @@ static void php_cli_server_dtor(php_cli_server *server TSRMLS_DC) /* {{{ */
}
} /* }}} */
-static void php_cli_server_client_dtor_wrapper(php_cli_server_client **p) /* {{{ */
+static void php_cli_server_client_dtor_wrapper(zval *zv) /* {{{ */
{
- closesocket((*p)->sock);
- php_cli_server_poller_remove(&(*p)->server->poller, POLLIN | POLLOUT, (*p)->sock);
- php_cli_server_client_dtor(*p);
- pefree(*p, 1);
+ php_cli_server_client *p = Z_PTR_P(zv);
+
+ closesocket(p->sock);
+ php_cli_server_poller_remove(&p->server->poller, POLLIN | POLLOUT, p->sock);
+ php_cli_server_client_dtor(p);
+ pefree(p, 1);
} /* }}} */
static int php_cli_server_ctor(php_cli_server *server, const char *addr, const char *document_root, const char *router TSRMLS_DC) /* {{{ */
{
int retval = SUCCESS;
char *host = NULL;
- char *errstr = NULL;
+ zend_string *errstr = NULL;
char *_document_root = NULL;
char *_router = NULL;
int err = 0;
@@ -2285,8 +2261,10 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const c
server_sock = php_network_listen_socket(host, &port, SOCK_STREAM, &server->address_family, &server->socklen, &errstr TSRMLS_CC);
if (server_sock == SOCK_ERR) {
- php_cli_server_logf("Failed to listen on %s:%d (reason: %s)" TSRMLS_CC, host, port, errstr ? errstr: "?");
- efree(errstr);
+ php_cli_server_logf("Failed to listen on %s:%d (reason: %s)" TSRMLS_CC, host, port, errstr ? errstr->val : "?");
+ if (errstr) {
+ zend_string_release(errstr);
+ }
retval = FAILURE;
goto out;
}
@@ -2302,7 +2280,7 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const c
server->host = host;
server->port = port;
- zend_hash_init(&server->clients, 0, NULL, (void(*)(void*))php_cli_server_client_dtor_wrapper, 1);
+ zend_hash_init(&server->clients, 0, NULL, php_cli_server_client_dtor_wrapper, 1);
{
size_t document_root_len = strlen(document_root);
@@ -2329,6 +2307,11 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const c
server->router_len = 0;
}
+ if (php_cli_server_mime_type_ctor(server, mime_type_map) == FAILURE) {
+ retval = FAILURE;
+ goto out;
+ }
+
server->is_running = 1;
out:
if (retval != SUCCESS) {
@@ -2374,7 +2357,7 @@ static int php_cli_server_send_event(php_cli_server *server, php_cli_server_clie
if (client->content_sender_initialized) {
if (client->file_fd >= 0 && !client->content_sender.buffer.first) {
size_t nbytes_read;
- if (php_cli_server_content_sender_pull(&client->content_sender, client->file_fd, &nbytes_read)) {
+ if (php_cli_server_content_sender_pull(&client->content_sender, client->file_fd, &nbytes_read TSRMLS_CC)) {
php_cli_server_close_connection(server, client TSRMLS_CC);
return FAILURE;
}
@@ -2408,7 +2391,7 @@ typedef struct php_cli_server_do_event_for_each_fd_callback_params {
int(*whandler)(php_cli_server*, php_cli_server_client* TSRMLS_DC);
} php_cli_server_do_event_for_each_fd_callback_params;
-static int php_cli_server_do_event_for_each_fd_callback(void *_params, int fd, int event) /* {{{ */
+static int php_cli_server_do_event_for_each_fd_callback(void *_params, php_socket_t fd, int event) /* {{{ */
{
php_cli_server_do_event_for_each_fd_callback_params *params = _params;
#ifdef ZTS
@@ -2446,16 +2429,16 @@ static int php_cli_server_do_event_for_each_fd_callback(void *_params, int fd, i
#ifdef DEBUG
php_cli_server_logf("%s Accepted" TSRMLS_CC, client->addr_str);
#endif
- zend_hash_index_update(&server->clients, client_sock, &client, sizeof(client), NULL);
+ zend_hash_index_update_ptr(&server->clients, client_sock, client);
php_cli_server_recv_event_read_request(server, client TSRMLS_CC);
} else {
- php_cli_server_client **client;
- if (SUCCESS == zend_hash_index_find(&server->clients, fd, (void **)&client)) {
+ php_cli_server_client *client;
+ if (NULL != (client = zend_hash_index_find_ptr(&server->clients, fd))) {
if (event & POLLIN) {
- params->rhandler(server, *client TSRMLS_CC);
+ params->rhandler(server, client TSRMLS_CC);
}
if (event & POLLOUT) {
- params->whandler(server, *client TSRMLS_CC);
+ params->whandler(server, client TSRMLS_CC);
}
}
}
@@ -2534,9 +2517,9 @@ int do_cli_server(int argc, char **argv TSRMLS_DC) /* {{{ */
}
if (document_root) {
- struct stat sb;
+ zend_stat_t sb;
- if (stat(document_root, &sb)) {
+ if (zend_stat(document_root, &sb)) {
fprintf(stderr, "Directory %s does not exist.\n", document_root);
return 1;
}
diff --git a/sapi/cli/php_cli_server.h b/sapi/cli/php_cli_server.h
index a8d7f46e7c..476ee2919c 100644
--- a/sapi/cli/php_cli_server.h
+++ b/sapi/cli/php_cli_server.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/cli/php_http_parser.c b/sapi/cli/php_http_parser.c
index d3bc496f4e..cc649af79a 100644
--- a/sapi/cli/php_http_parser.c
+++ b/sapi/cli/php_http_parser.c
@@ -1431,7 +1431,9 @@ size_t php_http_parser_execute (php_http_parser *parser,
}
case s_body_identity:
- to_read = MIN(pe - p, (size_t)parser->content_length);
+ assert(pe >= p);
+
+ to_read = MIN((size_t)(pe - p), (size_t)parser->content_length);
if (to_read > 0) {
if (settings->on_body) settings->on_body(parser, p, to_read);
p += to_read - 1;
@@ -1515,8 +1517,9 @@ size_t php_http_parser_execute (php_http_parser *parser,
case s_chunk_data:
{
assert(parser->flags & F_CHUNKED);
+ assert(pe >= p);
- to_read = MIN(pe - p, (size_t)(parser->content_length));
+ to_read = MIN((size_t)(pe - p), (size_t)(parser->content_length));
if (to_read > 0) {
if (settings->on_body) settings->on_body(parser, p, to_read);
diff --git a/sapi/cli/ps_title.c b/sapi/cli/ps_title.c
index 53cd5fc9a0..97eec86e5b 100644
--- a/sapi/cli/ps_title.c
+++ b/sapi/cli/ps_title.c
@@ -311,7 +311,7 @@ const char* ps_title_errno(int rc)
#ifdef PS_USE_WIN32
case PS_TITLE_WINDOWS_ERROR:
- sprintf(windows_error_details, "Windows error code: %d", GetLastError());
+ sprintf(windows_error_details, "Windows error code: %u", GetLastError());
return windows_error_details;
#endif
}
@@ -386,7 +386,7 @@ int get_ps_title(int *displen, const char** string)
return rc;
#ifdef PS_USE_WIN32
- if (!(ps_buffer_cur_len = GetConsoleTitle(ps_buffer, ps_buffer_size)))
+ if (!(ps_buffer_cur_len = GetConsoleTitle(ps_buffer, (DWORD)ps_buffer_size)))
return PS_TITLE_WINDOWS_ERROR;
#endif
*displen = (int)ps_buffer_cur_len;
diff --git a/sapi/cli/ps_title.h b/sapi/cli/ps_title.h
index 09650fed08..30a16b5a0c 100644
--- a/sapi/cli/ps_title.h
+++ b/sapi/cli/ps_title.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/cli/tests/006.phpt b/sapi/cli/tests/006.phpt
index 3d5c916e9c..e9e8b7e219 100644
--- a/sapi/cli/tests/006.phpt
+++ b/sapi/cli/tests/006.phpt
@@ -34,6 +34,9 @@ string(%d) "Extension [ <persistent> extension #%d pcre version <no_version> ] {
Entry [ pcre.recursion_limit <ALL> ]
Current = '%d'
}
+ Entry [ pcre.jit <ALL> ]
+ Current = '%d'
+ }
}
- Constants [14] {
diff --git a/sapi/cli/tests/bug61977.phpt b/sapi/cli/tests/bug61977.phpt
index 09a6ba6d23..6250c9aec0 100644
--- a/sapi/cli/tests/bug61977.phpt
+++ b/sapi/cli/tests/bug61977.phpt
@@ -48,7 +48,7 @@ foo.html => Content-Type: text/html; charset=UTF-8
foo.htm => Content-Type: text/html; charset=UTF-8
foo.svg => Content-Type: image/svg+xml
foo.css => Content-Type: text/css; charset=UTF-8
-foo.js => Content-Type: text/javascript; charset=UTF-8
+foo.js => Content-Type: application/javascript
foo.png => Content-Type: image/png
foo.webm => Content-Type: video/webm
foo.ogv => Content-Type: video/ogg
diff --git a/sapi/continuity/capi.c b/sapi/continuity/capi.c
index 953991474d..aebfb9f671 100644
--- a/sapi/continuity/capi.c
+++ b/sapi/continuity/capi.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -462,7 +462,7 @@ int phpFinit(lstTset * opt)
core_globals = ts_resource(core_globals_id);
logFmsg(0, "mod/php: PHP Interface v3 (module)");
- logFmsg(0, "mod/php: Copyright (c) 1999-2005 The PHP Group. All rights reserved.");
+ logFmsg(0, "mod/php: Copyright (c) 1999-2014 The PHP Group. All rights reserved.");
sapi_startup(&capi_sapi_module);
capi_sapi_module.startup(&capi_sapi_module);
diff --git a/sapi/embed/php5embed.dsp b/sapi/embed/php5embed.dsp
deleted file mode 100644
index 8564b11797..0000000000
--- a/sapi/embed/php5embed.dsp
+++ /dev/null
@@ -1,100 +0,0 @@
-# Microsoft Developer Studio Project File - Name="php5embed" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=php5embed - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php5embed.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php5embed.mak" CFG="php5embed - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php5embed - Win32 Debug_TS" (based on "Win32 (x86) Static Library")
-!MESSAGE "php5embed - Win32 Release_TS" (based on "Win32 (x86) Static Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php5embed - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D ZEND_DEBUG=1 /YX /FD /GZ /c
-# ADD BASE RSC /l 0x406 /d "_DEBUG"
-# ADD RSC /l 0x406 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"..\..\Debug_TS\php5embed.lib"
-
-!ELSEIF "$(CFG)" == "php5embed - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D ZEND_DEBUG=0 /YX /FD /c
-# ADD BASE RSC /l 0x406 /d "NDEBUG"
-# ADD RSC /l 0x406 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"..\..\Release_TS\php5embed.lib"
-
-!ENDIF
-
-# Begin Target
-
-# Name "php5embed - Win32 Debug_TS"
-# Name "php5embed - Win32 Release_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=php_embed.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=php_embed.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c
index dad54de1ae..e0df666108 100644
--- a/sapi/embed/php_embed.c
+++ b/sapi/embed/php_embed.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -44,10 +44,10 @@ static int php_embed_deactivate(TSRMLS_D)
return SUCCESS;
}
-static inline size_t php_embed_single_write(const char *str, uint str_length)
+static inline size_t php_embed_single_write(const char *str, size_t str_length)
{
#ifdef PHP_WRITE_STDOUT
- long ret;
+ zend_long ret;
ret = write(STDOUT_FILENO, str, str_length);
if (ret <= 0) return 0;
@@ -61,10 +61,10 @@ static inline size_t php_embed_single_write(const char *str, uint str_length)
}
-static int php_embed_ub_write(const char *str, uint str_length TSRMLS_DC)
+static size_t php_embed_ub_write(const char *str, size_t str_length TSRMLS_DC)
{
const char *ptr = str;
- uint remaining = str_length;
+ size_t remaining = str_length;
size_t ret;
while (remaining > 0) {
@@ -79,7 +79,7 @@ static int php_embed_ub_write(const char *str, uint str_length TSRMLS_DC)
return str_length;
}
-static void php_embed_flush(void *server_context)
+static void php_embed_flush(void *server_context TSRMLS_DC)
{
if (fflush(stdout)==EOF) {
php_handle_aborted_connection();
diff --git a/sapi/embed/php_embed.h b/sapi/embed/php_embed.h
index 84c0e36336..b62fd9fe24 100644
--- a/sapi/embed/php_embed.h
+++ b/sapi/embed/php_embed.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/fpm/fpm/events/devpoll.c b/sapi/fpm/fpm/events/devpoll.c
index 3fa7cd4545..c843940638 100644
--- a/sapi/fpm/fpm/events/devpoll.c
+++ b/sapi/fpm/fpm/events/devpoll.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/fpm/fpm/events/devpoll.h b/sapi/fpm/fpm/events/devpoll.h
index 2753cb5abe..3cb744c023 100644
--- a/sapi/fpm/fpm/events/devpoll.h
+++ b/sapi/fpm/fpm/events/devpoll.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/fpm/fpm/events/epoll.c b/sapi/fpm/fpm/events/epoll.c
index b55cb44b15..aa4881649b 100644
--- a/sapi/fpm/fpm/events/epoll.c
+++ b/sapi/fpm/fpm/events/epoll.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/fpm/fpm/events/epoll.h b/sapi/fpm/fpm/events/epoll.h
index f89e59a5f5..965fe4dc4e 100644
--- a/sapi/fpm/fpm/events/epoll.h
+++ b/sapi/fpm/fpm/events/epoll.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/fpm/fpm/events/kqueue.c b/sapi/fpm/fpm/events/kqueue.c
index 9fde33842b..df0724c3d4 100644
--- a/sapi/fpm/fpm/events/kqueue.c
+++ b/sapi/fpm/fpm/events/kqueue.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/fpm/fpm/events/kqueue.h b/sapi/fpm/fpm/events/kqueue.h
index 16f8046529..4b52faba21 100644
--- a/sapi/fpm/fpm/events/kqueue.h
+++ b/sapi/fpm/fpm/events/kqueue.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/fpm/fpm/events/poll.c b/sapi/fpm/fpm/events/poll.c
index d49661413c..a97c64c2d0 100644
--- a/sapi/fpm/fpm/events/poll.c
+++ b/sapi/fpm/fpm/events/poll.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/fpm/fpm/events/poll.h b/sapi/fpm/fpm/events/poll.h
index 4a05755d07..6378074a14 100644
--- a/sapi/fpm/fpm/events/poll.h
+++ b/sapi/fpm/fpm/events/poll.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/fpm/fpm/events/port.c b/sapi/fpm/fpm/events/port.c
index 0e6a880554..faf67343c7 100644
--- a/sapi/fpm/fpm/events/port.c
+++ b/sapi/fpm/fpm/events/port.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/fpm/fpm/events/port.h b/sapi/fpm/fpm/events/port.h
index f127b8cdad..1e57feb194 100644
--- a/sapi/fpm/fpm/events/port.h
+++ b/sapi/fpm/fpm/events/port.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/fpm/fpm/events/select.c b/sapi/fpm/fpm/events/select.c
index cf3331c04b..1be074c43c 100644
--- a/sapi/fpm/fpm/events/select.c
+++ b/sapi/fpm/fpm/events/select.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/fpm/fpm/events/select.h b/sapi/fpm/fpm/events/select.h
index 74f7be2bc1..cd3652e4bd 100644
--- a/sapi/fpm/fpm/events/select.h
+++ b/sapi/fpm/fpm/events/select.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/fpm/fpm/fastcgi.c b/sapi/fpm/fpm/fastcgi.c
index d77b6f8ca7..4f7f5eab9c 100644
--- a/sapi/fpm/fpm/fastcgi.c
+++ b/sapi/fpm/fpm/fastcgi.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -479,11 +479,7 @@ static int fcgi_get_params(fcgi_request *req, unsigned char *p, unsigned char *e
memcpy(tmp, p, eff_name_len);
tmp[eff_name_len] = 0;
s = estrndup((char*)p + name_len, val_len);
- if (s == NULL) {
- ret = 0;
- break;
- }
- zend_hash_update(req->env, tmp, eff_name_len+1, &s, sizeof(char*), NULL);
+ zend_hash_str_update_ptr(req->env, tmp, eff_name_len, s);
p += name_len + val_len;
}
if (tmp != buf && tmp != NULL) {
@@ -492,9 +488,9 @@ static int fcgi_get_params(fcgi_request *req, unsigned char *p, unsigned char *e
return ret;
}
-static void fcgi_free_var(char **s)
+static void fcgi_free_var(zval *zv)
{
- efree(*s);
+ efree(Z_PTR_P(zv));
}
static int fcgi_read_request(fcgi_request *req)
@@ -509,7 +505,7 @@ static int fcgi_read_request(fcgi_request *req)
req->out_hdr = NULL;
req->out_pos = req->out_buf;
ALLOC_HASHTABLE(req->env);
- zend_hash_init(req->env, 0, NULL, (void (*)(void *)) fcgi_free_var, 0);
+ zend_hash_init(req->env, 0, NULL, fcgi_free_var, 0);
if (safe_read(req, &hdr, sizeof(fcgi_header)) != sizeof(fcgi_header) ||
hdr.version < FCGI_VERSION_1) {
@@ -546,15 +542,15 @@ static int fcgi_read_request(fcgi_request *req)
switch ((((fcgi_begin_request*)buf)->roleB1 << 8) + ((fcgi_begin_request*)buf)->roleB0) {
case FCGI_RESPONDER:
val = estrdup("RESPONDER");
- zend_hash_update(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), &val, sizeof(char*), NULL);
+ zend_hash_str_update_ptr(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), val);
break;
case FCGI_AUTHORIZER:
val = estrdup("AUTHORIZER");
- zend_hash_update(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), &val, sizeof(char*), NULL);
+ zend_hash_str_update_ptr(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), val);
break;
case FCGI_FILTER:
val = estrdup("FILTER");
- zend_hash_update(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), &val, sizeof(char*), NULL);
+ zend_hash_str_update_ptr(req->env, "FCGI_ROLE", sizeof("FCGI_ROLE"), val);
break;
default:
return 0;
@@ -593,12 +589,8 @@ static int fcgi_read_request(fcgi_request *req)
}
} else if (hdr.type == FCGI_GET_VALUES) {
unsigned char *p = buf + sizeof(fcgi_header);
- HashPosition pos;
- char * str_index;
- uint str_length;
- ulong num_index;
- int key_type;
- zval ** value;
+ zend_string *key;
+ zval *value;
if (safe_read(req, buf, len+padding) != len+padding) {
req->keep = 0;
@@ -610,28 +602,26 @@ static int fcgi_read_request(fcgi_request *req)
return 0;
}
- zend_hash_internal_pointer_reset_ex(req->env, &pos);
- while ((key_type = zend_hash_get_current_key_ex(req->env, &str_index, &str_length, &num_index, 0, &pos)) != HASH_KEY_NON_EXISTENT) {
+ ZEND_HASH_FOREACH_STR_KEY(req->env, key) {
int zlen;
- zend_hash_move_forward_ex(req->env, &pos);
- if (key_type != HASH_KEY_IS_STRING) {
+ if (!key) {
continue;
}
- if (zend_hash_find(&fcgi_mgmt_vars, str_index, str_length, (void**) &value) != SUCCESS) {
+ value = zend_hash_find(&fcgi_mgmt_vars, key);
+ if (!value) {
continue;
}
- --str_length;
- zlen = Z_STRLEN_PP(value);
- if ((p + 4 + 4 + str_length + zlen) >= (buf + sizeof(buf))) {
+ zlen = Z_STRLEN_P(value);
+ if ((p + 4 + 4 + key->len + zlen) >= (buf + sizeof(buf))) {
break;
}
- if (str_length < 0x80) {
- *p++ = str_length;
+ if (key->len < 0x80) {
+ *p++ = key->len;
} else {
- *p++ = ((str_length >> 24) & 0xff) | 0x80;
- *p++ = (str_length >> 16) & 0xff;
- *p++ = (str_length >> 8) & 0xff;
- *p++ = str_length & 0xff;
+ *p++ = ((key->len >> 24) & 0xff) | 0x80;
+ *p++ = (key->len >> 16) & 0xff;
+ *p++ = (key->len >> 8) & 0xff;
+ *p++ = key->len & 0xff;
}
if (zlen < 0x80) {
*p++ = zlen;
@@ -641,11 +631,11 @@ static int fcgi_read_request(fcgi_request *req)
*p++ = (zlen >> 8) & 0xff;
*p++ = zlen & 0xff;
}
- memcpy(p, str_index, str_length);
- p += str_length;
- memcpy(p, Z_STRVAL_PP(value), zlen);
+ memcpy(p, key->val, key->len);
+ p += key->len;
+ memcpy(p, Z_STRVAL_P(value), zlen);
p += zlen;
- }
+ } ZEND_HASH_FOREACH_END();
len = p - buf - sizeof(fcgi_header);
len += fcgi_make_header((fcgi_header*)buf, FCGI_GET_VALUES_RESULT, 0, len);
if (safe_write(req, buf, sizeof(fcgi_header)+len) != (int)sizeof(fcgi_header)+len) {
@@ -1050,28 +1040,22 @@ int fcgi_finish_request(fcgi_request *req, int force_close)
char* fcgi_getenv(fcgi_request *req, const char* var, int var_len)
{
- char **val;
-
- if (!req) return NULL;
-
- if (zend_hash_find(req->env, (char*)var, var_len+1, (void**)&val) == SUCCESS) {
- return *val;
+ if (!req) {
+ return NULL;
}
- return NULL;
+
+ return zend_hash_str_find_ptr(req->env, var, var_len);
}
char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val)
{
if (var && req) {
if (val == NULL) {
- zend_hash_del(req->env, var, var_len+1);
+ zend_hash_str_del(req->env, var, var_len);
} else {
- char **ret;
-
val = estrdup(val);
- if (zend_hash_update(req->env, var, var_len+1, &val, sizeof(char*), (void**)&ret) == SUCCESS) {
- return *ret;
- }
+ zend_hash_str_update_ptr(req->env, var, var_len, val);
+ return val;
}
}
return NULL;
@@ -1079,19 +1063,14 @@ char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val)
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len)
{
- zval * zvalue;
- zvalue = pemalloc(sizeof(*zvalue), 1);
- Z_TYPE_P(zvalue) = IS_STRING;
- Z_STRVAL_P(zvalue) = pestrndup(value, value_len, 1);
- Z_STRLEN_P(zvalue) = value_len;
- zend_hash_add(&fcgi_mgmt_vars, name, name_len + 1, &zvalue, sizeof(zvalue), NULL);
+ zval zvalue;
+ ZVAL_NEW_STR(&zvalue, zend_string_init(value, value_len, 1));
+ zend_hash_str_add(&fcgi_mgmt_vars, name, name_len, &zvalue);
}
-void fcgi_free_mgmt_var_cb(void * ptr)
+void fcgi_free_mgmt_var_cb(zval *zv)
{
- zval ** var = (zval **)ptr;
- pefree(Z_STRVAL_PP(var), 1);
- pefree(*var, 1);
+ zend_string_free(Z_STR_P(zv));
}
char *fcgi_get_last_client_ip() /* {{{ */
diff --git a/sapi/fpm/fpm/fastcgi.h b/sapi/fpm/fpm/fastcgi.h
index 34f9eef9da..6d1bb38dba 100644
--- a/sapi/fpm/fpm/fastcgi.h
+++ b/sapi/fpm/fpm/fastcgi.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -131,7 +131,7 @@ ssize_t fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, i
int fcgi_flush(fcgi_request *req, int close);
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len);
-void fcgi_free_mgmt_var_cb(void * ptr);
+void fcgi_free_mgmt_var_cb(zval *ptr);
char *fcgi_get_last_client_ip();
diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c
index 34e0480101..18ddccb300 100644
--- a/sapi/fpm/fpm/fpm_conf.c
+++ b/sapi/fpm/fpm/fpm_conf.c
@@ -1476,7 +1476,8 @@ static void fpm_conf_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback
int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */
{
int error = 0;
- char buf[1024+1];
+ char *buf = NULL, *newbuf = NULL;
+ int bufsize = 0;
int fd, n;
int nb_read = 1;
char c = '*';
@@ -1503,19 +1504,36 @@ int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */
ini_lineno = 0;
while (nb_read > 0) {
int tmp;
- memset(buf, 0, sizeof(char) * (1024 + 1));
- for (n = 0; n < 1024 && (nb_read = read(fd, &c, sizeof(char))) == sizeof(char) && c != '\n'; n++) {
+ ini_lineno++;
+ ini_filename = filename;
+ for (n = 0; (nb_read = read(fd, &c, sizeof(char))) == sizeof(char) && c != '\n'; n++) {
+ if (n == bufsize) {
+ bufsize += 1024;
+ newbuf = (char*) realloc(buf, sizeof(char) * (bufsize + 2));
+ if (newbuf == NULL) {
+ ini_recursion--;
+ close(fd);
+ free(buf);
+ return -1;
+ }
+ buf = newbuf;
+ }
+
buf[n] = c;
}
+ if (n == 0) {
+ continue;
+ }
+ /* always append newline and null terminate */
buf[n++] = '\n';
- ini_lineno++;
- ini_filename = filename;
+ buf[n] = '\0';
tmp = zend_parse_ini_string(buf, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t)fpm_conf_ini_parser, &error TSRMLS_CC);
ini_filename = filename;
if (error || tmp == FAILURE) {
if (ini_include) free(ini_include);
ini_recursion--;
close(fd);
+ free(buf);
return -1;
}
if (ini_include) {
@@ -1527,16 +1545,17 @@ int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */
free(tmp);
ini_recursion--;
close(fd);
+ free(buf);
return -1;
}
free(tmp);
}
}
+ free(buf);
ini_recursion--;
close(fd);
return ret;
-
}
/* }}} */
diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c
index 5b96dee038..2552f9afe0 100644
--- a/sapi/fpm/fpm/fpm_main.c
+++ b/sapi/fpm/fpm/fpm_main.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -188,10 +188,12 @@ typedef struct _user_config_cache_entry {
HashTable *user_config;
} user_config_cache_entry;
-static void user_config_cache_entry_dtor(user_config_cache_entry *entry)
+static void user_config_cache_entry_dtor(zval *el)
{
+ user_config_cache_entry *entry = (user_config_cache_entry *)Z_PTR_P(el);
zend_hash_destroy(entry->user_config);
free(entry->user_config);
+ free(entry);
}
/* }}} */
@@ -216,30 +218,30 @@ static php_cgi_globals_struct php_cgi_globals;
#define TRANSLATE_SLASHES(path)
#endif
-static int print_module_info(zend_module_entry *module, void *arg TSRMLS_DC)
+static int print_module_info(zval *zv TSRMLS_DC)
{
+ zend_module_entry *module = Z_PTR_P(zv);
php_printf("%s\n", module->name);
return 0;
}
static int module_name_cmp(const void *a, const void *b TSRMLS_DC)
{
- Bucket *f = *((Bucket **) a);
- Bucket *s = *((Bucket **) b);
+ Bucket *f = (Bucket *) a;
+ Bucket *s = (Bucket *) b;
- return strcasecmp( ((zend_module_entry *)f->pData)->name,
- ((zend_module_entry *)s->pData)->name);
+ return strcasecmp( ((zend_module_entry *) Z_PTR(f->val))->name,
+ ((zend_module_entry *) Z_PTR(s->val))->name);
}
static void print_modules(TSRMLS_D)
{
HashTable sorted_registry;
- zend_module_entry tmp;
zend_hash_init(&sorted_registry, 50, NULL, NULL, 1);
- zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry));
+ zend_hash_copy(&sorted_registry, &module_registry, NULL);
zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC);
- zend_hash_apply_with_argument(&sorted_registry, (apply_func_arg_t) print_module_info, NULL TSRMLS_CC);
+ zend_hash_apply(&sorted_registry, print_module_info TSRMLS_CC);
zend_hash_destroy(&sorted_registry);
}
@@ -296,7 +298,7 @@ static inline size_t sapi_cgibin_single_write(const char *str, uint str_length T
#endif
}
-static int sapi_cgibin_ub_write(const char *str, uint str_length TSRMLS_DC)
+static size_t sapi_cgibin_ub_write(const char *str, size_t str_length TSRMLS_DC)
{
const char *ptr = str;
uint remaining = str_length;
@@ -316,7 +318,7 @@ static int sapi_cgibin_ub_write(const char *str, uint str_length TSRMLS_DC)
}
-static void sapi_cgibin_flush(void *server_context)
+static void sapi_cgibin_flush(void *server_context TSRMLS_DC)
{
/* fpm has started, let use fcgi instead of stdout */
if (fpm_is_running) {
@@ -495,7 +497,7 @@ static int sapi_cgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
# define STDIN_FILENO 0
#endif
-static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC)
+static size_t sapi_cgi_read_post(char *buffer, size_t count_bytes TSRMLS_DC)
{
uint read_bytes = 0;
int tmp_read_bytes;
@@ -568,32 +570,23 @@ static char *sapi_cgi_read_cookies(TSRMLS_D)
void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC)
{
fcgi_request *request;
- HashPosition pos;
- char *var, **val;
- uint var_len;
- ulong idx;
+ zend_string *var;
+ char *val;
int filter_arg;
-
- if (PG(http_globals)[TRACK_VARS_ENV] &&
- array_ptr != PG(http_globals)[TRACK_VARS_ENV] &&
- Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY &&
- zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV])) > 0
+ if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY &&
+ Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV]) &&
+ zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_ENV])) > 0
) {
zval_dtor(array_ptr);
- *array_ptr = *PG(http_globals)[TRACK_VARS_ENV];
- INIT_PZVAL(array_ptr);
- zval_copy_ctor(array_ptr);
+ ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_ENV]);
return;
- } else if (PG(http_globals)[TRACK_VARS_SERVER] &&
- array_ptr != PG(http_globals)[TRACK_VARS_SERVER] &&
- Z_TYPE_P(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY &&
- zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])) > 0
+ } else if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY &&
+ Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_SERVER]) &&
+ zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER])) > 0
) {
zval_dtor(array_ptr);
- *array_ptr = *PG(http_globals)[TRACK_VARS_SERVER];
- INIT_PZVAL(array_ptr);
- zval_copy_ctor(array_ptr);
+ ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_SERVER]);
return;
}
@@ -601,24 +594,21 @@ void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC)
php_php_import_environment_variables(array_ptr TSRMLS_CC);
request = (fcgi_request*) SG(server_context);
- filter_arg = (array_ptr == PG(http_globals)[TRACK_VARS_ENV])?PARSE_ENV:PARSE_SERVER;
+ filter_arg = Z_ARR_P(array_ptr) == Z_ARR(PG(http_globals)[TRACK_VARS_ENV])
+ ? PARSE_ENV : PARSE_SERVER;
- for (zend_hash_internal_pointer_reset_ex(request->env, &pos);
- zend_hash_get_current_key_ex(request->env, &var, &var_len, &idx, 0, &pos) == HASH_KEY_IS_STRING &&
- zend_hash_get_current_data_ex(request->env, (void **) &val, &pos) == SUCCESS;
- zend_hash_move_forward_ex(request->env, &pos)
- ) {
- unsigned int new_val_len;
+ ZEND_HASH_FOREACH_STR_KEY_PTR(request->env, var, val) {
+ size_t new_val_len;
- if (sapi_module.input_filter(filter_arg, var, val, strlen(*val), &new_val_len TSRMLS_CC)) {
- php_register_variable_safe(var, *val, new_val_len, array_ptr TSRMLS_CC);
+ if (var && sapi_module.input_filter(filter_arg, var->val, &val, strlen(val), &new_val_len TSRMLS_CC)) {
+ php_register_variable_safe(var->val, val, new_val_len, array_ptr TSRMLS_CC);
}
- }
+ } ZEND_HASH_FOREACH_END();
}
static void sapi_cgi_register_variables(zval *track_vars_array TSRMLS_DC)
{
- unsigned int php_self_len;
+ size_t php_self_len;
char *php_self;
/* In CGI mode, we consider the environment to be a part of the server
@@ -695,17 +685,16 @@ static void sapi_cgi_log_message(char *message)
static void php_cgi_ini_activate_user_config(char *path, int path_len, const char *doc_root, int doc_root_len, int start TSRMLS_DC)
{
char *ptr;
- user_config_cache_entry *new_entry, *entry;
time_t request_time = sapi_get_request_time(TSRMLS_C);
+ user_config_cache_entry *entry = zend_hash_str_find_ptr(&CGIG(user_config_cache), path, path_len);
/* Find cached config entry: If not found, create one */
- if (zend_hash_find(&CGIG(user_config_cache), path, path_len + 1, (void **) &entry) == FAILURE) {
- new_entry = pemalloc(sizeof(user_config_cache_entry), 1);
- new_entry->expires = 0;
- new_entry->user_config = (HashTable *) pemalloc(sizeof(HashTable), 1);
- zend_hash_init(new_entry->user_config, 0, NULL, (dtor_func_t) config_zval_dtor, 1);
- zend_hash_update(&CGIG(user_config_cache), path, path_len + 1, new_entry, sizeof(user_config_cache_entry), (void **) &entry);
- free(new_entry);
+ if (!entry) {
+ entry = pemalloc(sizeof(user_config_cache_entry), 1);
+ entry->expires = 0;
+ entry->user_config = (HashTable *) pemalloc(sizeof(HashTable), 1);
+ zend_hash_init(entry->user_config, 0, NULL, config_zval_dtor, 1);
+ zend_hash_str_update_ptr(&CGIG(user_config_cache), path, path_len, entry);
}
/* Check whether cache entry has expired and rescan if it is */
@@ -784,7 +773,7 @@ static int sapi_cgi_activate(TSRMLS_D)
server_name_len = strlen(server_name);
server_name = estrndup(server_name, server_name_len);
zend_str_tolower(server_name, server_name_len);
- php_ini_activate_per_host_config(server_name, server_name_len + 1 TSRMLS_CC);
+ php_ini_activate_per_host_config(server_name, server_name_len TSRMLS_CC);
efree(server_name);
}
}
@@ -1484,7 +1473,7 @@ static void php_cgi_globals_ctor(php_cgi_globals_struct *php_cgi_globals TSRMLS_
php_cgi_globals->fix_pathinfo = 1;
php_cgi_globals->discard_path = 0;
php_cgi_globals->fcgi_logging = 1;
- zend_hash_init(&php_cgi_globals->user_config_cache, 0, NULL, (dtor_func_t) user_config_cache_entry_dtor, 1);
+ zend_hash_init(&php_cgi_globals->user_config_cache, 0, NULL, user_config_cache_entry_dtor, 1);
php_cgi_globals->error_header = NULL;
php_cgi_globals->fpm_config = NULL;
}
@@ -1888,7 +1877,6 @@ consult the installation file that came with this distribution, or visit \n\
request_body_fd = -1;
SG(server_context) = (void *) &request;
init_request_info(TSRMLS_C);
- CG(interactive) = 0;
char *primary_script = NULL;
fpm_request_info();
@@ -1982,7 +1970,7 @@ fastcgi_request_done:
fpm_request_end(TSRMLS_C);
fpm_log_write(NULL TSRMLS_CC);
- STR_FREE(SG(request_info).path_translated);
+ efree(SG(request_info).path_translated);
SG(request_info).path_translated = NULL;
php_request_shutdown((void *) 0);
diff --git a/sapi/fpm/fpm/fpm_php.c b/sapi/fpm/fpm/fpm_php.c
index cd4d3aef3a..e0de217c00 100644
--- a/sapi/fpm/fpm/fpm_php.c
+++ b/sapi/fpm/fpm/fpm_php.c
@@ -26,22 +26,21 @@ static char **limit_extensions = NULL;
static int fpm_php_zend_ini_alter_master(char *name, int name_length, char *new_value, int new_value_length, int mode, int stage TSRMLS_DC) /* {{{ */
{
zend_ini_entry *ini_entry;
- char *duplicate;
+ zend_string *duplicate;
- if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == FAILURE) {
+ if ((ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length))) {
return FAILURE;
}
- duplicate = strdup(new_value);
+ duplicate = zend_string_init(new_value, new_value_length, 1);
if (!ini_entry->on_modify
- || ini_entry->on_modify(ini_entry, duplicate, new_value_length,
+ || ini_entry->on_modify(ini_entry, duplicate,
ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC) == SUCCESS) {
ini_entry->value = duplicate;
- ini_entry->value_length = new_value_length;
ini_entry->modifiable = mode;
} else {
- free(duplicate);
+ zend_string_release(duplicate);
}
return SUCCESS;
@@ -89,10 +88,10 @@ int fpm_php_apply_defines_ex(struct key_value_s *kv, int mode) /* {{{ */
if (!strcmp(name, "extension") && *value) {
zval zv;
php_dl(value, MODULE_PERSISTENT, &zv, 1 TSRMLS_CC);
- return Z_BVAL(zv) ? 1 : -1;
+ return Z_TYPE(zv) == IS_TRUE;
}
- if (fpm_php_zend_ini_alter_master(name, name_len+1, value, value_len, mode, PHP_INI_STAGE_ACTIVATE TSRMLS_CC) == FAILURE) {
+ if (fpm_php_zend_ini_alter_master(name, name_len, value, value_len, mode, PHP_INI_STAGE_ACTIVATE TSRMLS_CC) == FAILURE) {
return -1;
}
@@ -258,39 +257,30 @@ int fpm_php_limit_extensions(char *path) /* {{{ */
}
/* }}} */
-char* fpm_php_get_string_from_table(char *table, char *key TSRMLS_DC) /* {{{ */
+char* fpm_php_get_string_from_table(zend_string *table, char *key TSRMLS_DC) /* {{{ */
{
- zval **data, **tmp;
- char *string_key;
- uint string_len;
- ulong num_key;
+ zval *data, *tmp;
+ zend_string *str;
if (!table || !key) {
return NULL;
}
/* inspired from ext/standard/info.c */
- zend_is_auto_global(table, strlen(table) TSRMLS_CC);
+ zend_is_auto_global(table TSRMLS_CC);
/* find the table and ensure it's an array */
- if (zend_hash_find(&EG(symbol_table), table, strlen(table) + 1, (void **) &data) == SUCCESS && Z_TYPE_PP(data) == IS_ARRAY) {
-
- /* reset the internal pointer */
- zend_hash_internal_pointer_reset(Z_ARRVAL_PP(data));
-
- /* parse the array to look for our key */
- while (zend_hash_get_current_data(Z_ARRVAL_PP(data), (void **) &tmp) == SUCCESS) {
- /* ensure the key is a string */
- if (zend_hash_get_current_key_ex(Z_ARRVAL_PP(data), &string_key, &string_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING) {
- /* compare to our key */
- if (!strncmp(string_key, key, string_len)) {
- return Z_STRVAL_PP(tmp);
- }
- }
- zend_hash_move_forward(Z_ARRVAL_PP(data));
- }
+ data = zend_hash_find(&EG(symbol_table).ht, table);
+ if (!data || Z_TYPE_P(data) != IS_ARRAY) {
+ return NULL;
}
+ ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(data), str, tmp) {
+ if (str && !strncmp(str->val, key, str->len)) {
+ return Z_STRVAL_P(tmp);
+ }
+ } ZEND_HASH_FOREACH_END();
+
return NULL;
}
/* }}} */
diff --git a/sapi/fpm/fpm/fpm_php.h b/sapi/fpm/fpm/fpm_php.h
index d6054737d6..20f5a9454b 100644
--- a/sapi/fpm/fpm/fpm_php.h
+++ b/sapi/fpm/fpm/fpm_php.h
@@ -44,7 +44,7 @@ void fpm_php_soft_quit();
int fpm_php_init_main();
int fpm_php_apply_defines_ex(struct key_value_s *kv, int mode);
int fpm_php_limit_extensions(char *path);
-char* fpm_php_get_string_from_table(char *table, char *key TSRMLS_DC);
+char* fpm_php_get_string_from_table(zend_string *table, char *key TSRMLS_DC);
#endif
diff --git a/sapi/fpm/fpm/fpm_php_trace.c b/sapi/fpm/fpm/fpm_php_trace.c
index 925f2de64e..d5b4242fc3 100644
--- a/sapi/fpm/fpm/fpm_php_trace.c
+++ b/sapi/fpm/fpm/fpm_php_trace.c
@@ -42,6 +42,8 @@
static int fpm_php_trace_dump(struct fpm_child_s *child, FILE *slowlog TSRMLS_DC) /* {{{ */
{
+// TODO: fpm_php_trace_dump() has to be reimplemented ???
+#if 0
int callers_limit = 20;
pid_t pid = child->pid;
struct timeval tv;
@@ -131,6 +133,7 @@ static int fpm_php_trace_dump(struct fpm_child_s *child, FILE *slowlog TSRMLS_DC
break;
}
}
+#endif
return 0;
}
/* }}} */
diff --git a/sapi/fpm/fpm/fpm_status.c b/sapi/fpm/fpm/fpm_status.c
index 2363b57f80..fa3fc763a5 100644
--- a/sapi/fpm/fpm/fpm_status.c
+++ b/sapi/fpm/fpm/fpm_status.c
@@ -55,6 +55,7 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */
int full, encode;
char *short_syntax, *short_post;
char *full_pre, *full_syntax, *full_post, *full_separator;
+ zend_string *_GET_str;
if (!SG(request_info).request_uri) {
return 0;
@@ -126,13 +127,14 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */
}
/* full status ? */
- full = (fpm_php_get_string_from_table("_GET", "full" TSRMLS_CC) != NULL);
+ _GET_str = zend_string_init("_GET", sizeof("_GET")-1, 0);
+ full = (fpm_php_get_string_from_table(_GET_str, "full" TSRMLS_CC) != NULL);
short_syntax = short_post = NULL;
full_separator = full_pre = full_syntax = full_post = NULL;
encode = 0;
/* HTML */
- if (fpm_php_get_string_from_table("_GET", "html" TSRMLS_CC)) {
+ if (fpm_php_get_string_from_table(_GET_str, "html" TSRMLS_CC)) {
sapi_add_header_ex(ZEND_STRL("Content-Type: text/html"), 1, 1 TSRMLS_CC);
time_format = "%d/%b/%Y:%H:%M:%S %z";
encode = 1;
@@ -207,7 +209,7 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */
}
/* XML */
- } else if (fpm_php_get_string_from_table("_GET", "xml" TSRMLS_CC)) {
+ } else if (fpm_php_get_string_from_table(_GET_str, "xml" TSRMLS_CC)) {
sapi_add_header_ex(ZEND_STRL("Content-Type: text/xml"), 1, 1 TSRMLS_CC);
time_format = "%s";
encode = 1;
@@ -259,7 +261,7 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */
}
/* JSON */
- } else if (fpm_php_get_string_from_table("_GET", "json" TSRMLS_CC)) {
+ } else if (fpm_php_get_string_from_table(_GET_str, "json" TSRMLS_CC)) {
sapi_add_header_ex(ZEND_STRL("Content-Type: application/json"), 1, 1 TSRMLS_CC);
time_format = "%s";
@@ -376,6 +378,7 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */
PUTS(buffer);
efree(buffer);
+ zend_string_release(_GET_str);
if (short_post) {
PUTS(short_post);
@@ -384,7 +387,7 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */
/* no need to test the var 'full' */
if (full_syntax) {
int i, first;
- size_t len;
+ zend_string *tmp_query_string;
char *query_string;
struct timeval duration, now;
#ifdef HAVE_FPM_LQ
@@ -413,12 +416,13 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */
}
query_string = NULL;
- len = 0;
+ tmp_query_string = NULL;
if (proc.query_string[0] != '\0') {
if (!encode) {
query_string = proc.query_string;
} else {
- query_string = php_escape_html_entities_ex((unsigned char *)proc.query_string, strlen(proc.query_string), &len, 1, ENT_HTML_IGNORE_ERRORS & ENT_COMPAT, NULL, 1 TSRMLS_CC);
+ tmp_query_string = php_escape_html_entities_ex((unsigned char *)proc.query_string, strlen(proc.query_string), 1, ENT_HTML_IGNORE_ERRORS & ENT_COMPAT, NULL, 1 TSRMLS_CC);
+ query_string = tmp_query_string->val;
}
}
@@ -458,8 +462,8 @@ int fpm_status_handle_request(TSRMLS_D) /* {{{ */
PUTS(buffer);
efree(buffer);
- if (len > 0 && query_string) {
- efree(query_string);
+ if (tmp_query_string) {
+ zend_string_free(tmp_query_string);
}
}
diff --git a/sapi/fpm/php-fpm.conf.in b/sapi/fpm/php-fpm.conf.in
index 631bc46f42..106689f0a7 100644
--- a/sapi/fpm/php-fpm.conf.in
+++ b/sapi/fpm/php-fpm.conf.in
@@ -492,7 +492,7 @@ pm.max_spare_servers = 3
; exectute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
-;security.limit_extensions = .php .php3 .php4 .php5
+;security.limit_extensions = .php .php3 .php4 .php5 .php7
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
diff --git a/sapi/isapi/config.m4 b/sapi/isapi/config.m4
index 6014bab09f..4073173eaf 100644
--- a/sapi/isapi/config.m4
+++ b/sapi/isapi/config.m4
@@ -15,7 +15,7 @@ if test "$PHP_ISAPI" != "no"; then
PHP_BUILD_THREAD_SAFE
AC_DEFINE(WITH_ZEUS, 1, [ ])
PHP_ADD_INCLUDE($ZEUSPATH/web/include)
- PHP_SELECT_SAPI(isapi, shared, php5isapi.c)
+ PHP_SELECT_SAPI(isapi, shared, php7isapi.c)
INSTALL_IT="\$(SHELL) \$(srcdir)/install-sh -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)$ZEUSPATH/web/bin/"
fi
diff --git a/sapi/isapi/config.w32 b/sapi/isapi/config.w32
index 8012352744..5a359f11b2 100644
--- a/sapi/isapi/config.w32
+++ b/sapi/isapi/config.w32
@@ -7,7 +7,7 @@ if (PHP_ISAPI == "yes") {
if (PHP_ZTS == "no") {
WARNING("ISAPI module requires an --enable-zts build of PHP");
} else {
- SAPI('isapi', 'php5isapi.c', 'php' + PHP_VERSION + 'isapi.dll', '/D PHP5ISAPI_EXPORTS');
- ADD_FLAG('LDFLAGS_ISAPI', '/DEF:sapi\\isapi\\php5isapi.def');
+ SAPI('isapi', 'php7isapi.c', 'php' + PHP_VERSION + 'isapi.dll', '/D PHP7ISAPI_EXPORTS');
+ ADD_FLAG('LDFLAGS_ISAPI', '/DEF:sapi\\isapi\\php7isapi.def');
}
}
diff --git a/sapi/isapi/php5isapi.dsp b/sapi/isapi/php5isapi.dsp
deleted file mode 100644
index 3dbab11eff..0000000000
--- a/sapi/isapi/php5isapi.dsp
+++ /dev/null
@@ -1,165 +0,0 @@
-# Microsoft Developer Studio Project File - Name="php5isapi" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=php5isapi - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php5isapi.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php5isapi.mak" CFG="php5isapi - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php5isapi - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php5isapi - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php5isapi - Win32 Release_TS_inline" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php5isapi - Win32 Release_TSDbg" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php5isapi - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\..\Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP5ISAPI_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /D "_DEBUG" /D "COMPILE_LIBZEND" /D ZEND_DEBUG=1 /D "_WINDOWS" /D "_USRDLL" /D "PHP5ISAPI_EXPORTS" /D "MSVC5" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "_DEBUG"
-# ADD RSC /l 0x40d /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts_debug.lib /nologo /version:4.0 /dll /debug /machine:I386 /nodefaultlib:"libcmt" /pdbtype:sept /libpath:"..\..\Debug_TS"
-
-!ELSEIF "$(CFG)" == "php5isapi - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP5ISAPI_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "_WINDOWS" /D "_USRDLL" /D "PHP5ISAPI_EXPORTS" /D "MSVC5" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "NDEBUG"
-# ADD RSC /l 0x40d /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 php5ts.lib /nologo /version:4.0 /dll /machine:I386 /libpath:"..\..\Release_TS"
-
-!ELSEIF "$(CFG)" == "php5isapi - Win32 Release_TS_inline"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "php5isapi___Win32_Release_TS_inline"
-# PROP BASE Intermediate_Dir "php5isapi___Win32_Release_TS_inline"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS_inline"
-# PROP Intermediate_Dir "Release_TS_inline"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "PHP5ISAPI_EXPORTS" /D "MSVC5" /D "ZTS" /D "WIN32" /D "_MBCS" /D ZEND_DEBUG=0 /FR /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "ZEND_WIN32_FORCE_INLINE" /D "_WINDOWS" /D "_USRDLL" /D "PHP5ISAPI_EXPORTS" /D "MSVC5" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "NDEBUG"
-# ADD RSC /l 0x40d /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 php5ts.lib /nologo /dll /machine:I386 /libpath:"..\..\Release_TS"
-# 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 php5ts.lib /nologo /version:4.0 /dll /machine:I386 /libpath:"..\..\Release_TS_inline"
-
-!ELSEIF "$(CFG)" == "php5isapi - Win32 Release_TSDbg"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "php5isapi___Win32_Release_TSDbg"
-# PROP BASE Intermediate_Dir "php5isapi___Win32_Release_TSDbg"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TSDbg"
-# PROP Intermediate_Dir "Release_TSDbg"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "_WINDOWS" /D "_USRDLL" /D "PHP5ISAPI_EXPORTS" /D "MSVC5" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /Zi /Od /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "_WINDOWS" /D "_USRDLL" /D "PHP5ISAPI_EXPORTS" /D "MSVC5" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "NDEBUG"
-# ADD RSC /l 0x40d /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 php5ts.lib /nologo /version:4.0 /dll /machine:I386 /libpath:"..\..\Release_TS"
-# 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 php5ts.lib /nologo /version:4.0 /dll /debug /machine:I386 /libpath:"..\..\Release_TSDbg"
-
-!ENDIF
-
-# Begin Target
-
-# Name "php5isapi - Win32 Debug_TS"
-# Name "php5isapi - Win32 Release_TS"
-# Name "php5isapi - Win32 Release_TS_inline"
-# Name "php5isapi - Win32 Release_TSDbg"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\php5isapi.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php5isapi.def
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# End Target
-# End Project
diff --git a/sapi/isapi/php5isapi.c b/sapi/isapi/php7isapi.c
index d83c81ad9e..27eb1c9353 100644
--- a/sapi/isapi/php5isapi.c
+++ b/sapi/isapi/php7isapi.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/isapi/php5isapi.def b/sapi/isapi/php7isapi.def
index 596023ef55..596023ef55 100644
--- a/sapi/isapi/php5isapi.def
+++ b/sapi/isapi/php7isapi.def
diff --git a/sapi/isapi/stresstest/notes.txt b/sapi/isapi/stresstest/notes.txt
index f58ab3c0e9..e6d10dd486 100644
--- a/sapi/isapi/stresstest/notes.txt
+++ b/sapi/isapi/stresstest/notes.txt
@@ -44,7 +44,7 @@ Run: stresstest L files.txt
supply the path to the parent of the "tests" directory (expect a couple
long pauses for a couple of the larger tests)
-Run: stresstest T c:\php5-source
+Run: stresstest T c:\php7-source
diff --git a/sapi/isapi/stresstest/stresstest.cpp b/sapi/isapi/stresstest/stresstest.cpp
index 9a5964a6ba..8ad414fab6 100644
--- a/sapi/isapi/stresstest/stresstest.cpp
+++ b/sapi/isapi/stresstest/stresstest.cpp
@@ -529,7 +529,7 @@ int main(int argc, char* argv[])
0,
NULL
);
- fprintf(stderr,"Error: Dll 'php5isapi.dll' not found -%d\n%s\n", GetLastError(), lpMsgBuf);
+ fprintf(stderr,"Error: Dll 'php7isapi.dll' not found -%d\n%s\n", GetLastError(), lpMsgBuf);
free (module);
free(filelist);
LocalFree( lpMsgBuf );
diff --git a/sapi/isapi/stresstest/stresstest.dsp b/sapi/isapi/stresstest/stresstest.dsp
deleted file mode 100644
index fb82303e3d..0000000000
--- a/sapi/isapi/stresstest/stresstest.dsp
+++ /dev/null
@@ -1,108 +0,0 @@
-# Microsoft Developer Studio Project File - Name="stresstest" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=stresstest - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "stresstest.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "stresstest.mak" CFG="stresstest - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "stresstest - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "stresstest - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "stresstest - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 2
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_AFXDLL" /FD /c
-# SUBTRACT CPP /YX /Yc /Yu
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 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 /subsystem:console /machine:I386
-# ADD LINK32 /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "stresstest - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 2
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "c:\php-fcgi"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_AFXDLL" /FD /GZ /c
-# SUBTRACT CPP /YX /Yc /Yu
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 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 /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "stresstest - Win32 Release"
-# Name "stresstest - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\getopt.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\getopt.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\stresstest.cpp
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=.\notes.txt
-# End Source File
-# End Target
-# End Project
diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c
index 425d638f9e..13439460ae 100644
--- a/sapi/litespeed/lsapi_main.c
+++ b/sapi/litespeed/lsapi_main.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -155,7 +155,7 @@ static int sapi_lsapi_ub_write(const char *str, uint str_length TSRMLS_DC)
/* {{{ sapi_lsapi_flush
*/
-static void sapi_lsapi_flush( void * server_context )
+static void sapi_lsapi_flush( void * server_context TSRMLS_DC )
{
if ( lsapi_mode ) {
if ( LSAPI_Flush() == -1) {
@@ -1148,7 +1148,7 @@ zend_module_entry litespeed_module_entry = {
static int add_associate_array( const char * pKey, int keyLen, const char * pValue, int valLen,
void * arg )
{
- add_assoc_string_ex( (zval *)arg, (char *)pKey, keyLen+1, (char *)pValue, 1 );
+ add_assoc_string_ex( (zval *)arg, (char *)pKey, keyLen+1, (char *)pValue);
return 1;
}
@@ -1202,7 +1202,7 @@ PHP_FUNCTION(litespeed_response_headers)
headerBuf[len] = 0;
if ( len ) {
while( isspace(*++p));
- add_assoc_string_ex(return_value, headerBuf, len+1, p, 1 );
+ add_assoc_string_ex(return_value, headerBuf, len+1, p);
}
}
}
@@ -1222,10 +1222,10 @@ PHP_FUNCTION(apache_get_modules)
WRONG_PARAM_COUNT;
}
array_init(return_value);
- add_next_index_string(return_value, "mod_rewrite", 1);
- add_next_index_string(return_value, "mod_mime", 1);
- add_next_index_string(return_value, "mod_headers", 1);
- add_next_index_string(return_value, "mod_expires", 1);
+ add_next_index_string(return_value, "mod_rewrite");
+ add_next_index_string(return_value, "mod_mime");
+ add_next_index_string(return_value, "mod_headers");
+ add_next_index_string(return_value, "mod_expires");
}
/* }}} */
diff --git a/sapi/litespeed/lsapidef.h b/sapi/litespeed/lsapidef.h
index fb75d01a17..5c604a57c4 100644
--- a/sapi/litespeed/lsapidef.h
+++ b/sapi/litespeed/lsapidef.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c
index aac823fc1c..cf63f6ab1c 100644
--- a/sapi/litespeed/lsapilib.c
+++ b/sapi/litespeed/lsapilib.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/litespeed/lsapilib.h b/sapi/litespeed/lsapilib.h
index cae1863c79..cacf7d97b8 100644
--- a/sapi/litespeed/lsapilib.h
+++ b/sapi/litespeed/lsapilib.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/milter/php_milter.c b/sapi/milter/php_milter.c
index 4a11707239..d82089ca1f 100644
--- a/sapi/milter/php_milter.c
+++ b/sapi/milter/php_milter.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -290,7 +290,7 @@ static sfsistat mlfi_envfrom(SMFICTX *ctx, char **argv)
array_init(param[0]);
while (*argv) {
- add_next_index_string(param[0], *argv, 1);
+ add_next_index_string(param[0], *argv);
argv++;
}
@@ -330,7 +330,7 @@ static sfsistat mlfi_envrcpt(SMFICTX *ctx, char **argv)
array_init(param[0]);
while (*argv) {
- add_next_index_string(param[0], *argv, 1);
+ add_next_index_string(param[0], *argv);
argv++;
}
@@ -864,10 +864,6 @@ static int sapi_milter_ub_write(const char *str, uint str_length TSRMLS_DC)
return str_length;
}
-static void sapi_milter_flush(void *server_context)
-{
-}
-
static void sapi_milter_register_variables(zval *track_vars_array TSRMLS_DC)
{
php_register_variable ("SERVER_SOFTWARE", "Sendmail Milter", track_vars_array TSRMLS_CC);
@@ -910,7 +906,7 @@ static sapi_module_struct milter_sapi_module = {
NULL, /* deactivate */
sapi_milter_ub_write, /* unbuffered write */
- sapi_milter_flush, /* flush */
+ NULL, /* flush */
NULL, /* get uid */
NULL, /* getenv */
@@ -1123,7 +1119,7 @@ int main(int argc, char *argv[])
break;
case 'z': /* load extension file */
- zend_load_extension(ap_php_optarg);
+ zend_load_extension(ap_php_optarg TSRMLS_CC);
break;
default:
@@ -1138,8 +1134,6 @@ int main(int argc, char *argv[])
exit(1);
}
- CG(interactive) = interactive;
-
/* only set script_file if not set already and not in direct mode and not at end of parameter list */
if (argc > ap_php_optind && !filename) {
filename=argv[ap_php_optind];
diff --git a/sapi/nsapi/nsapi-readme.txt b/sapi/nsapi/nsapi-readme.txt
index 54980bf0e0..812507957e 100644
--- a/sapi/nsapi/nsapi-readme.txt
+++ b/sapi/nsapi/nsapi-readme.txt
@@ -1,4 +1,4 @@
-Configuration of your Netscape/iPlanet/Sun Webserver for PHP5
+Configuration of your Netscape/iPlanet/Sun Webserver for PHP7
-----------------------------------------------------------------
These instructions are targetted at Netscape Enterprise Web Server and
@@ -28,13 +28,13 @@ Place the following two lines after mime.types init in
for iPlanet/Sun Webserver 6.0 and above however at the end of the
<path-to-server>/https-servername/config/magnus.conf file:
- Init fn="load-modules" funcs="php5_init,php5_execute,php5_auth_trans" shlib="/path/to/phplibrary"
- Init fn=php5_init errorString="Failed to initialize PHP!" [php_ini="/path/to/php.ini"]
+ Init fn="load-modules" funcs="php7_init,php7_execute,php7_auth_trans" shlib="/path/to/phplibrary"
+ Init fn=php7_init errorString="Failed to initialize PHP!" [php_ini="/path/to/php.ini"]
The "shlib" will vary depending on your OS:
- Unix: "<path-to-server>/bin/libphp5.so".
- Windows: "c:/path/to/php5/php5nsapi.dll"
+ Unix: "<path-to-server>/bin/libphp7.so".
+ Windows: "c:/path/to/php7/php7nsapi.dll"
In obj.conf (for virtual server classes [Sun 6.0+] in their vserver.obj.conf):
@@ -50,7 +50,7 @@ In obj.conf (for virtual server classes [Sun 6.0+] in their vserver.obj.conf):
# For boolean ini-keys please use 0/1 as value, NOT "On","Off",... (this will not work
# correctly), e.g. zlib.output_compression=1 instead of zlib.output_compression="On"
- Service fn="php5_execute" type="magnus-internal/x-httpd-php" [inikey=value ...]
+ Service fn="php7_execute" type="magnus-internal/x-httpd-php" [inikey=value ...]
.
.
.
@@ -61,7 +61,7 @@ PHP scripts (same like a cgi-bin directory):
<Object name="x-httpd-php">
ObjectType fn="force-type" type="magnus-internal/x-httpd-php"
- Service fn="php5_execute" [inikey=value ...]
+ Service fn="php7_execute" [inikey=value ...]
</Object>
After that you can configure a directory in the Administration server and assign it
@@ -81,7 +81,7 @@ AUTHENTICATION IS PASSED TO YOUR PHP SCRIPT. To configure PHP
Authentication for the entire server, add the following line:
<Object name="default">
- AuthTrans fn=php5_auth_trans
+ AuthTrans fn=php7_auth_trans
.
.
.
@@ -92,7 +92,7 @@ Authentication for the entire server, add the following line:
To use PHP Authentication on a single directory, add the following:
<Object ppath="d:\path\to\authenticated\dir\*">
- AuthTrans fn=php5_auth_trans
+ AuthTrans fn=php7_auth_trans
</Object>
@@ -103,7 +103,7 @@ You can use PHP to generate the error pages for "404 Not Found"
or similar. Add the following line to the object in obj.conf for
every error page you want to overwrite:
- Error fn="php5_execute" code=XXX script="/path/to/script.php" [inikey=value inikey=value...]
+ Error fn="php7_execute" code=XXX script="/path/to/script.php" [inikey=value inikey=value...]
where XXX ist the HTTP error code. Please delete any other Error
directives which could interfere with yours.
@@ -116,7 +116,7 @@ Just generate a PHP script which displays a directory listing and
replace the corresponding default Service line for
type="magnus-internal/directory" in obj.conf with the following:
- Service fn="php5_execute" type="magnus-internal/directory" script="/path/to/script.php" [inikey=value inikey=value...]
+ Service fn="php7_execute" type="magnus-internal/directory" script="/path/to/script.php" [inikey=value inikey=value...]
For both error and directory listing pages the original URI and
translated URI are in the variables $_SERVER['PATH_INFO'] and
@@ -141,9 +141,9 @@ till version 6.1. If a newer version of the Sun server is used, the detection
fails and nsapi_virtual() is disabled.
If this is the case, try the following:
-Add the following parameter to php5_init in magnus.conf:
+Add the following parameter to php7_init in magnus.conf:
- Init fn=php5_init ... server_lib="ns-httpdXX.dll"
+ Init fn=php7_init ... server_lib="ns-httpdXX.dll"
where XX is the correct DLL version number. To get it, look in the server-root
for the correct DLL name. The DLL with the biggest filesize is the right one.
diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c
index ec3137ca51..bb99c31652 100644
--- a/sapi/nsapi/nsapi.c
+++ b/sapi/nsapi/nsapi.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -251,7 +251,7 @@ static void php_nsapi_init_dynamic_symbols(void)
/* try user specified server_lib */
module = GetModuleHandle(nsapi_dll);
if (!module) {
- log_error(LOG_WARN, "php5_init", NULL, NULL, "Cannot find DLL specified by server_lib parameter: %s", nsapi_dll);
+ log_error(LOG_WARN, "php7_init", NULL, NULL, "Cannot find DLL specified by server_lib parameter: %s", nsapi_dll);
}
} else {
/* find a LOADED dll module from nsapi_dlls */
@@ -414,7 +414,7 @@ PHP_FUNCTION(nsapi_request_headers)
for (i=0; i < rc->rq->headers->hsize; i++) {
entry=rc->rq->headers->ht[i];
while (entry) {
- add_assoc_string(return_value, entry->param->name, entry->param->value, 1);
+ add_assoc_string(return_value, entry->param->name, entry->param->value);
entry=entry->next;
}
}
@@ -438,7 +438,7 @@ PHP_FUNCTION(nsapi_response_headers)
for (i=0; i < rc->rq->srvhdrs->hsize; i++) {
entry=rc->rq->srvhdrs->ht[i];
while (entry) {
- add_assoc_string(return_value, entry->param->name, entry->param->value, 1);
+ add_assoc_string(return_value, entry->param->name, entry->param->value);
entry=entry->next;
}
}
@@ -467,10 +467,9 @@ static int sapi_nsapi_ub_write(const char *str, unsigned int str_length TSRMLS_D
}
/* modified version of apache2 */
-static void sapi_nsapi_flush(void *server_context)
+static void sapi_nsapi_flush(void *server_context TSRMLS_DC)
{
nsapi_request_context *rc = (nsapi_request_context *)server_context;
- TSRMLS_FETCH();
if (!rc) {
/* we have no context, so no flushing needed. This fixes a SIGSEGV on shutdown */
@@ -782,7 +781,7 @@ static void nsapi_log_message(char *message TSRMLS_DC)
if (rc) {
log_error(LOG_INFORM, pblock_findval("fn", rc->pb), rc->sn, rc->rq, "%s", message);
} else {
- log_error(LOG_INFORM, "php5", NULL, NULL, "%s", message);
+ log_error(LOG_INFORM, "php7", NULL, NULL, "%s", message);
}
}
@@ -869,7 +868,7 @@ static void nsapi_php_ini_entries(NSLS_D TSRMLS_DC)
}
}
-void NSAPI_PUBLIC php5_close(void *vparam)
+void NSAPI_PUBLIC php7_close(void *vparam)
{
if (nsapi_sapi_module.shutdown) {
nsapi_sapi_module.shutdown(&nsapi_sapi_module);
@@ -889,13 +888,13 @@ void NSAPI_PUBLIC php5_close(void *vparam)
sapi_shutdown();
tsrm_shutdown();
- log_error(LOG_INFORM, "php5_close", NULL, NULL, "Shutdown PHP Module");
+ log_error(LOG_INFORM, "php7_close", NULL, NULL, "Shutdown PHP Module");
}
/*********************************************************
/ init SAF
/
-/ Init fn="php5_init" [php_ini="/path/to/php.ini"] [server_lib="ns-httpdXX.dll"]
+/ Init fn="php7_init" [php_ini="/path/to/php.ini"] [server_lib="ns-httpdXX.dll"]
/ Initialize the NSAPI module in magnus.conf
/
/ php_ini: gives path to php.ini file
@@ -903,7 +902,7 @@ void NSAPI_PUBLIC php5_close(void *vparam)
/ servact_* functions
/
/*********************************************************/
-int NSAPI_PUBLIC php5_init(pblock *pb, Session *sn, Request *rq)
+int NSAPI_PUBLIC php7_init(pblock *pb, Session *sn, Request *rq)
{
php_core_globals *core_globals;
char *strval;
@@ -918,13 +917,13 @@ int NSAPI_PUBLIC php5_init(pblock *pb, Session *sn, Request *rq)
core_globals = ts_resource(core_globals_id);
- /* look if php_ini parameter is given to php5_init */
+ /* look if php_ini parameter is given to php7_init */
if (strval = pblock_findval("php_ini", pb)) {
nsapi_sapi_module.php_ini_path_override = strdup(strval);
}
#ifdef PHP_WIN32
- /* look if server_lib parameter is given to php5_init
+ /* look if server_lib parameter is given to php7_init
* (this disables the automatic search for the newest ns-httpdXX.dll) */
if (strval = pblock_findval("server_lib", pb)) {
nsapi_dll = strdup(strval);
@@ -935,7 +934,7 @@ int NSAPI_PUBLIC php5_init(pblock *pb, Session *sn, Request *rq)
sapi_startup(&nsapi_sapi_module);
nsapi_sapi_module.startup(&nsapi_sapi_module);
- daemon_atrestart(&php5_close, NULL);
+ daemon_atrestart(&php7_close, NULL);
log_error(LOG_INFORM, pblock_findval("fn", pb), sn, rq, "Initialized PHP Module (%d threads expected)", threads);
return REQ_PROCEED;
@@ -944,19 +943,19 @@ int NSAPI_PUBLIC php5_init(pblock *pb, Session *sn, Request *rq)
/*********************************************************
/ normal use in Service directive:
/
-/ Service fn="php5_execute" type=... method=... [inikey=inivalue inikey=inivalue...]
+/ Service fn="php7_execute" type=... method=... [inikey=inivalue inikey=inivalue...]
/
/ use in Service for a directory to supply a php-made directory listing instead of server default:
/
-/ Service fn="php5_execute" type="magnus-internal/directory" script="/path/to/script.php" [inikey=inivalue inikey=inivalue...]
+/ Service fn="php7_execute" type="magnus-internal/directory" script="/path/to/script.php" [inikey=inivalue inikey=inivalue...]
/
/ use in Error SAF to display php script as error page:
/
-/ Error fn="php5_execute" code=XXX script="/path/to/script.php" [inikey=inivalue inikey=inivalue...]
-/ Error fn="php5_execute" reason="Reason" script="/path/to/script.php" [inikey=inivalue inikey=inivalue...]
+/ Error fn="php7_execute" code=XXX script="/path/to/script.php" [inikey=inivalue inikey=inivalue...]
+/ Error fn="php7_execute" reason="Reason" script="/path/to/script.php" [inikey=inivalue inikey=inivalue...]
/
/*********************************************************/
-int NSAPI_PUBLIC php5_execute(pblock *pb, Session *sn, Request *rq)
+int NSAPI_PUBLIC php7_execute(pblock *pb, Session *sn, Request *rq)
{
int retval;
nsapi_request_context *request_context;
@@ -1077,15 +1076,15 @@ int NSAPI_PUBLIC php5_execute(pblock *pb, Session *sn, Request *rq)
/ will pass authentication through to php, and allow us to
/ check authentication with our scripts.
/
-/ php5_auth_trans
+/ php7_auth_trans
/ main function called from netscape server to authenticate
/ a line in obj.conf:
-/ funcs=php5_auth_trans shlib="path/to/this/phpnsapi.dll"
+/ funcs=php7_auth_trans shlib="path/to/this/phpnsapi.dll"
/ and:
/ <Object ppath="path/to/be/authenticated/by/php/*">
-/ AuthTrans fn="php5_auth_trans"
+/ AuthTrans fn="php7_auth_trans"
/*********************************************************/
-int NSAPI_PUBLIC php5_auth_trans(pblock * pb, Session * sn, Request * rq)
+int NSAPI_PUBLIC php7_auth_trans(pblock * pb, Session * sn, Request * rq)
{
/* This is a DO NOTHING function that allows authentication
* information
diff --git a/sapi/nsapi/php5nsapi.dsp b/sapi/nsapi/php5nsapi.dsp
deleted file mode 100644
index 6cd0079b43..0000000000
--- a/sapi/nsapi/php5nsapi.dsp
+++ /dev/null
@@ -1,135 +0,0 @@
-# Microsoft Developer Studio Project File - Name="php5nsapi" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=php5nsapi - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php5nsapi.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php5nsapi.mak" CFG="php5nsapi - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php5nsapi - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php5nsapi - Win32 Release_TS_inline" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php5nsapi - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php5nsapi - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "php5nsapi___Win32_Release_TS"
-# PROP BASE Intermediate_Dir "php5nsapi___Win32_Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "php5nsapi_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "..\..\..\php_build\nsapi30\include\\" /I "..\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\tsrm" /D ZEND_DEBUG=0 /D "NDEBUG" /D "XP_WIN32" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "php5nsapi_EXPORTS" /D "WIN32" /D "_MBCS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 ns-httpd30.lib php5ts.lib 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 /base:"0x62000000" /version:4.0 /dll /machine:I386 /libpath:"..\..\..\php_build\nsapi30\lib\\" /libpath:"..\..\Release_TS" /libpath:"..\..\TSRM\Release_TS" /libpath:"..\..\Zend\Release_TS"
-
-!ELSEIF "$(CFG)" == "php5nsapi - Win32 Release_TS_inline"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "php5nsapi___Win32_Release_TS_inline"
-# PROP BASE Intermediate_Dir "php5nsapi___Win32_Release_TS_inline"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS_inline"
-# PROP Intermediate_Dir "Release_TS_inline"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "php5nsapi_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "..\..\..\php_build\nsapi30\include\\" /I "..\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\tsrm" /D ZEND_DEBUG=0 /D "ZEND_WIN32_FORCE_INLINE" /D "NDEBUG" /D "XP_WIN32" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "php5nsapi_EXPORTS" /D "WIN32" /D "_MBCS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 ns-httpd30.lib php5ts.lib 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 /base:"0x62000000" /version:4.0 /dll /machine:I386 /libpath:"..\..\..\php_build\nsapi30\lib\\" /libpath:"..\..\Release_TS_inline" /libpath:"..\..\TSRM\Release_TS_inline" /libpath:"..\..\Zend\Release_TS_inline"
-
-!ELSEIF "$(CFG)" == "php5nsapi - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "php5nsapi___Win32_Debug_TS"
-# PROP BASE Intermediate_Dir "php5nsapi___Win32_Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\..\Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "php5nsapi_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "..\..\..\php_build\nsapi30\include\\" /I "..\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\tsrm" /D "_Debug_TS" /D ZEND_DEBUG=1 /D "_DEBUG" /D "XP_WIN32" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "php5nsapi_EXPORTS" /D "WIN32" /D "_MBCS" /FR /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 ns-httpd30.lib php5ts_debug.lib 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 /base:"0x62000000" /version:4.0 /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\php_build\nsapi30\lib\\" /libpath:"..\..\Debug_TS" /libpath:"..\..\TSRM\Debug_TS" /libpath:"..\..\Zend\Debug_TS"
-
-!ENDIF
-
-# Begin Target
-
-# Name "php5nsapi - Win32 Release_TS"
-# Name "php5nsapi - Win32 Release_TS_inline"
-# Name "php5nsapi - Win32 Debug_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\nsapi.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index f09dc4ee13..d70e512751 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -52,7 +52,7 @@ static PHP_INI_MH(OnUpdateEol)
return FAILURE;
}
- return phpdbg_eol_global_update(new_value TSRMLS_CC);
+ return phpdbg_eol_global_update(new_value->val TSRMLS_CC);
}
PHP_INI_BEGIN()
@@ -83,6 +83,7 @@ static inline void php_phpdbg_globals_ctor(zend_phpdbg_globals *pg) /* {{{ */
pg->last_was_newline = 1;
pg->ops = NULL;
pg->vmret = 0;
+ pg->in_execution = 0;
pg->bp_count = 0;
pg->flags = PHPDBG_DEFAULT_FLAGS;
pg->oplog = NULL;
@@ -135,50 +136,49 @@ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */
return SUCCESS;
} /* }}} */
-static void php_phpdbg_destroy_bp_file(void *brake) /* {{{ */
+static void php_phpdbg_destroy_bp_file(zval *brake) /* {{{ */
{
- zend_hash_destroy((HashTable*)brake);
+ zend_hash_destroy(Z_ARRVAL_P(brake));
} /* }}} */
-static void php_phpdbg_destroy_bp_symbol(void *brake) /* {{{ */
+static void php_phpdbg_destroy_bp_symbol(zval *brake) /* {{{ */
{
- efree((char*)((phpdbg_breaksymbol_t*)brake)->symbol);
+ efree((char *) ((phpdbg_breaksymbol_t *) Z_PTR_P(brake))->symbol);
} /* }}} */
-static void php_phpdbg_destroy_bp_opcode(void *brake) /* {{{ */
+static void php_phpdbg_destroy_bp_opcode(zval *brake) /* {{{ */
{
- efree((char*)((phpdbg_breakop_t*)brake)->name);
+ efree((char *) ((phpdbg_breakop_t *) Z_PTR_P(brake))->name);
} /* }}} */
-static void php_phpdbg_destroy_bp_methods(void *brake) /* {{{ */
+static void php_phpdbg_destroy_bp_methods(zval *brake) /* {{{ */
{
- zend_hash_destroy((HashTable*)brake);
+ zend_hash_destroy(Z_ARRVAL_P(brake));
} /* }}} */
-static void php_phpdbg_destroy_bp_condition(void *data) /* {{{ */
+static void php_phpdbg_destroy_bp_condition(zval *data) /* {{{ */
{
- phpdbg_breakcond_t *brake = (phpdbg_breakcond_t*) data;
+ phpdbg_breakcond_t *brake = (phpdbg_breakcond_t *) Z_PTR_P(data);
if (brake) {
if (brake->ops) {
TSRMLS_FETCH();
- destroy_op_array(
- brake->ops TSRMLS_CC);
+ destroy_op_array(brake->ops TSRMLS_CC);
efree(brake->ops);
}
- efree((char*)brake->code);
+ efree((char*) brake->code);
}
} /* }}} */
-static void php_phpdbg_destroy_registered(void *data) /* {{{ */
+static void php_phpdbg_destroy_registered(zval *data) /* {{{ */
{
- zend_function *function = (zend_function*) data;
+ zend_function *function = (zend_function *) Z_PTR_P(data);
+
TSRMLS_FETCH();
- destroy_zend_function(
- function TSRMLS_CC);
+ destroy_zend_function(function TSRMLS_CC);
} /* }}} */
@@ -261,10 +261,9 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
If the request to set the context fails, boolean false is returned, and an E_WARNING raised */
static PHP_FUNCTION(phpdbg_exec)
{
- char *exec = NULL;
- int exec_len = 0;
+ zend_string *exec;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &exec, &exec_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &exec) == FAILURE) {
return;
}
@@ -272,27 +271,26 @@ static PHP_FUNCTION(phpdbg_exec)
struct stat sb;
zend_bool result = 1;
- if (VCWD_STAT(exec, &sb) != FAILURE) {
+ if (VCWD_STAT(exec->val, &sb) != FAILURE) {
if (sb.st_mode & (S_IFREG|S_IFLNK)) {
if (PHPDBG_G(exec)) {
- ZVAL_STRINGL(return_value, PHPDBG_G(exec), PHPDBG_G(exec_len), 1);
+ ZVAL_STRINGL(return_value, PHPDBG_G(exec), PHPDBG_G(exec_len));
efree(PHPDBG_G(exec));
result = 0;
}
- PHPDBG_G(exec) = estrndup(exec, exec_len);
- PHPDBG_G(exec_len) = exec_len;
+ PHPDBG_G(exec) = estrndup(exec->val, exec->len);
+ PHPDBG_G(exec_len) = exec->len;
- if (result)
+ if (result) {
ZVAL_BOOL(return_value, 1);
+ }
} else {
- zend_error(
- E_WARNING, "Failed to set execution context (%s), not a regular file or symlink", exec);
+ zend_error(E_WARNING, "Failed to set execution context (%s), not a regular file or symlink", exec);
ZVAL_BOOL(return_value, 0);
}
} else {
- zend_error(
- E_WARNING, "Failed to set execution context (%s) the file does not exist", exec);
+ zend_error(E_WARNING, "Failed to set execution context (%s) the file does not exist", exec);
ZVAL_BOOL(return_value, 0);
}
@@ -316,13 +314,8 @@ static PHP_FUNCTION(phpdbg_break)
phpdbg_parse_param(expr, expr_len, &param TSRMLS_CC);
phpdbg_do_break(&param TSRMLS_CC);
phpdbg_clear_param(&param TSRMLS_CC);
-
- } else if (EG(current_execute_data) && EG(active_op_array)) {
- zend_ulong opline_num = (EG(current_execute_data)->opline -
- EG(active_op_array)->opcodes);
-
- phpdbg_set_breakpoint_opline_ex(
- &EG(active_op_array)->opcodes[opline_num+1] TSRMLS_CC);
+ } else if (EG(current_execute_data) && EG(current_execute_data)->func->type != ZEND_INTERNAL_FUNCTION) {
+ phpdbg_set_breakpoint_opline_ex((phpdbg_opline_ptr_t) EG(current_execute_data)->opline + 1 TSRMLS_CC);
}
} /* }}} */
@@ -478,13 +471,10 @@ static void php_sapi_phpdbg_log_message(char *message TSRMLS_DC) /* {{{ */
case E_PARSE:
case E_RECOVERABLE_ERROR:
if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) {
- phpdbg_list_file(
- zend_get_executed_filename(TSRMLS_C),
- 3,
- zend_get_executed_lineno(TSRMLS_C)-1,
- zend_get_executed_lineno(TSRMLS_C)
- TSRMLS_CC
- );
+ const char *file_char = zend_get_executed_filename(TSRMLS_C);
+ zend_string *file = zend_string_init(file_char, strlen(file_char), 0);
+ phpdbg_list_file(file, 3, zend_get_executed_lineno(TSRMLS_C) - 1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC);
+ efree(file);
}
do {
@@ -515,8 +505,8 @@ static int php_sapi_phpdbg_deactivate(TSRMLS_D) /* {{{ */
static void php_sapi_phpdbg_register_vars(zval *track_vars_array TSRMLS_DC) /* {{{ */
{
- unsigned int len;
- char *docroot = "";
+ size_t len;
+ char *docroot = "";
/* In phpdbg mode, we consider the environment to be a part of the server variables
*/
@@ -524,39 +514,30 @@ static void php_sapi_phpdbg_register_vars(zval *track_vars_array TSRMLS_DC) /* {
if (PHPDBG_G(exec)) {
len = PHPDBG_G(exec_len);
- if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF",
- &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) {
- php_register_variable("PHP_SELF", PHPDBG_G(exec),
- track_vars_array TSRMLS_CC);
+ if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) {
+ php_register_variable("PHP_SELF", PHPDBG_G(exec), track_vars_array TSRMLS_CC);
}
- if (sapi_module.input_filter(PARSE_SERVER, "SCRIPT_NAME",
- &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) {
- php_register_variable("SCRIPT_NAME", PHPDBG_G(exec),
- track_vars_array TSRMLS_CC);
+ if (sapi_module.input_filter(PARSE_SERVER, "SCRIPT_NAME", &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) {
+ php_register_variable("SCRIPT_NAME", PHPDBG_G(exec), track_vars_array TSRMLS_CC);
}
- if (sapi_module.input_filter(PARSE_SERVER, "SCRIPT_FILENAME",
- &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) {
- php_register_variable("SCRIPT_FILENAME", PHPDBG_G(exec),
- track_vars_array TSRMLS_CC);
+ if (sapi_module.input_filter(PARSE_SERVER, "SCRIPT_FILENAME", &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) {
+ php_register_variable("SCRIPT_FILENAME", PHPDBG_G(exec), track_vars_array TSRMLS_CC);
}
- if (sapi_module.input_filter(PARSE_SERVER, "PATH_TRANSLATED",
- &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) {
- php_register_variable("PATH_TRANSLATED", PHPDBG_G(exec),
- track_vars_array TSRMLS_CC);
+ if (sapi_module.input_filter(PARSE_SERVER, "PATH_TRANSLATED", &PHPDBG_G(exec), PHPDBG_G(exec_len), &len TSRMLS_CC)) {
+ php_register_variable("PATH_TRANSLATED", PHPDBG_G(exec), track_vars_array TSRMLS_CC);
}
}
- /* any old docroot will doo */
- len = 0U;
- if (sapi_module.input_filter(PARSE_SERVER, "DOCUMENT_ROOT",
- &docroot, len, &len TSRMLS_CC)) {
+ /* any old docroot will do */
+ len = 0;
+ if (sapi_module.input_filter(PARSE_SERVER, "DOCUMENT_ROOT", &docroot, len, &len TSRMLS_CC)) {
php_register_variable("DOCUMENT_ROOT", docroot, track_vars_array TSRMLS_CC);
}
}
/* }}} */
-static inline int php_sapi_phpdbg_ub_write(const char *message, unsigned int length TSRMLS_DC) /* {{{ */
+static inline size_t php_sapi_phpdbg_ub_write(const char *message, size_t length TSRMLS_DC) /* {{{ */
{
if (PHPDBG_G(socket_fd) != -1 && !(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) {
send(PHPDBG_G(socket_fd), message, length, 0);
@@ -611,23 +592,16 @@ static inline void php_sapi_phpdbg_flush(void *context) /* {{{ */
/* copied from sapi/cli/php_cli.c cli_register_file_handles */
static void phpdbg_register_file_handles(TSRMLS_D) /* {{{ */
{
- zval *zin, *zout, *zerr;
+ zval zin, zout, zerr;
php_stream *s_in, *s_out, *s_err;
php_stream_context *sc_in=NULL, *sc_out=NULL, *sc_err=NULL;
zend_constant ic, oc, ec;
- MAKE_STD_ZVAL(zin);
- MAKE_STD_ZVAL(zout);
- MAKE_STD_ZVAL(zerr);
-
s_in = php_stream_open_wrapper_ex("php://stdin", "rb", 0, NULL, sc_in);
s_out = php_stream_open_wrapper_ex("php://stdout", "wb", 0, NULL, sc_out);
s_err = php_stream_open_wrapper_ex("php://stderr", "wb", 0, NULL, sc_err);
if (s_in==NULL || s_out==NULL || s_err==NULL) {
- FREE_ZVAL(zin);
- FREE_ZVAL(zout);
- FREE_ZVAL(zerr);
if (s_in) php_stream_close(s_in);
if (s_out) php_stream_close(s_out);
if (s_err) php_stream_close(s_err);
@@ -640,34 +614,27 @@ static void phpdbg_register_file_handles(TSRMLS_D) /* {{{ */
s_err->flags |= PHP_STREAM_FLAG_NO_CLOSE;
#endif
- php_stream_to_zval(s_in, zin);
- php_stream_to_zval(s_out, zout);
- php_stream_to_zval(s_err, zerr);
+ php_stream_to_zval(s_in, &zin);
+ php_stream_to_zval(s_out, &zout);
+ php_stream_to_zval(s_err, &zerr);
- ic.value = *zin;
+ ic.value = zin;
ic.flags = CONST_CS;
- ic.name = zend_strndup(ZEND_STRL("STDIN"));
- ic.name_len = sizeof("STDIN");
+ ic.name = zend_string_init(ZEND_STRL("STDIN"), 0);
ic.module_number = 0;
zend_register_constant(&ic TSRMLS_CC);
- oc.value = *zout;
+ oc.value = zout;
oc.flags = CONST_CS;
- oc.name = zend_strndup(ZEND_STRL("STDOUT"));
- oc.name_len = sizeof("STDOUT");
+ oc.name = zend_string_init(ZEND_STRL("STDOUT"), 0);
oc.module_number = 0;
zend_register_constant(&oc TSRMLS_CC);
- ec.value = *zerr;
+ ec.value = zerr;
ec.flags = CONST_CS;
- ec.name = zend_strndup(ZEND_STRL("STDERR"));
- ec.name_len = sizeof("STDERR");
+ ec.name = zend_string_init(ZEND_STRL("STDERR"), 0);
ec.module_number = 0;
zend_register_constant(&ec TSRMLS_CC);
-
- FREE_ZVAL(zin);
- FREE_ZVAL(zout);
- FREE_ZVAL(zerr);
}
/* }}} */
@@ -721,8 +688,10 @@ const opt_struct OPTIONS[] = { /* {{{ */
{'r', 0, "run"},
{'E', 0, "step-through-eval"},
{'S', 1, "sapi-name"},
+#ifndef _WIN32
{'l', 1, "listen"},
{'a', 1, "address-or-any"},
+#endif
{'x', 0, "xml output"},
{'V', 0, "version"},
{'-', 0, NULL}
@@ -740,10 +709,9 @@ const char phpdbg_ini_hardcoded[] =
/* overwriteable ini defaults must be set in phpdbg_ini_defaults() */
#define INI_DEFAULT(name, value) \
+ ZVAL_STRINGL(&tmp, value, sizeof(value) - 1); \
Z_SET_REFCOUNT(tmp, 0); \
- Z_UNSET_ISREF(tmp); \
- ZVAL_STRINGL(&tmp, zend_strndup(value, sizeof(value)-1), sizeof(value)-1, 0); \
- zend_hash_update(configuration_hash, name, sizeof(name), &tmp, sizeof(zval), NULL);
+ zend_hash_str_update(configuration_hash, name, sizeof(name) - 1, &tmp);
void phpdbg_ini_defaults(HashTable *configuration_hash) /* {{{ */
{
@@ -805,7 +773,6 @@ static inline void phpdbg_sigint_handler(int signo) /* {{{ */
}
} /* }}} */
-
static void phpdbg_remote_close(int socket, FILE *stream) {
if (socket >= 0) {
phpdbg_close_socket(socket);
@@ -990,11 +957,13 @@ int main(int argc, char **argv) /* {{{ */
char bp_tmp_file[] = "/tmp/phpdbg.XXXXXX";
#endif
+#ifndef _WIN32
char *address;
int listen = -1;
int server = -1;
int socket = -1;
FILE* stream = NULL;
+#endif
#ifdef ZTS
void ***tsrm_ls;
@@ -1007,9 +976,10 @@ int main(int argc, char **argv) /* {{{ */
signal_struct.sa_flags = SA_SIGINFO | SA_NODEFER;
sigio_struct.sa_sigaction = phpdbg_sigio_handler;
sigio_struct.sa_flags = SA_SIGINFO;
-#endif
+
address = strdup("127.0.0.1");
+#endif
#ifdef PHP_WIN32
_fmode = _O_BINARY; /* sets default for file streams to binary */
@@ -1172,6 +1142,7 @@ phpdbg_main:
show_banner = 0;
break;
+#ifndef _WIN32
/* if you pass a listen port, we will read and write on listen port */
case 'l': /* set listen ports */
if (sscanf(php_optarg, "%d", &listen) != 1) {
@@ -1185,6 +1156,7 @@ phpdbg_main:
address = strdup("*");
} else address = strdup(php_optarg);
} break;
+#endif
case 'x':
flags |= PHPDBG_WRITE_XML;
@@ -1276,7 +1248,11 @@ phpdbg_main:
__try {
#endif
zend_mm_heap *mm_heap;
+ void* (*_malloc)(size_t);
+ void (*_free)(void*);
+ void* (*_realloc)(void*, size_t);
+#ifndef _WIN32
/* setup remote server if necessary */
if (!cleaning && listen > 0) {
server = phpdbg_open_socket(address, listen TSRMLS_CC);
@@ -1284,29 +1260,34 @@ phpdbg_main:
exit(0);
}
-#ifndef _WIN32
sigaction(SIGIO, &sigio_struct, NULL);
-#endif
/* set remote flag to stop service shutting down upon quit */
remote = 1;
}
+#endif
mm_heap = phpdbg_mm_get_heap();
+ zend_mm_get_custom_handlers(mm_heap, &_malloc, &_free, &_realloc);
- if (mm_heap->use_zend_alloc) {
- mm_heap->_malloc = phpdbg_malloc_wrapper;
- mm_heap->_realloc = phpdbg_realloc_wrapper;
- mm_heap->_free = phpdbg_free_wrapper;
- mm_heap->use_zend_alloc = 0;
+ if (!_malloc) {
+ _malloc = phpdbg_malloc_wrapper;
+ }
+ if (!_realloc) {
+ _realloc = phpdbg_realloc_wrapper;
+ }
+ if (!_free) {
+ _free = phpdbg_free_wrapper;
}
zend_activate(TSRMLS_C);
phpdbg_init_list(TSRMLS_C);
- PHPDBG_G(original_free_function) = mm_heap->_free;
- mm_heap->_free = phpdbg_watch_efree;
+ PHPDBG_G(original_free_function) = _free;
+ _free = phpdbg_watch_efree;
+
+ zend_mm_set_custom_handlers(mm_heap, _malloc, _free, _realloc);
phpdbg_setup_watchpoints(TSRMLS_C);
@@ -1363,13 +1344,14 @@ phpdbg_main:
/* set flags from command line */
PHPDBG_G(flags) = flags;
+#ifndef _WIN32
/* setup io here */
if (remote) {
PHPDBG_G(flags) |= PHPDBG_IS_REMOTE;
-#ifndef _WIN32
+
signal(SIGPIPE, SIG_IGN);
-#endif
}
+#endif
#ifndef _WIN32
PHPDBG_G(io)[PHPDBG_STDIN].ptr = stdin;
@@ -1465,7 +1447,10 @@ phpdbg_main:
}
}
+/* #ifndef for making compiler shutting up */
+#ifndef _WIN32
phpdbg_interact:
+#endif
/* phpdbg main() */
do {
zend_try {
@@ -1480,6 +1465,7 @@ phpdbg_interact:
cleaning = 0;
}
+#ifndef _WIN32
if (!cleaning) {
/* remote client disconnected */
if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) {
@@ -1501,6 +1487,7 @@ phpdbg_interact:
}
}
}
+#endif
} zend_end_try();
} while(!cleaning && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING));
@@ -1510,17 +1497,19 @@ phpdbg_interact:
/* this is just helpful */
PG(report_memleaks) = 0;
+#ifndef _WIN32
phpdbg_out:
if ((PHPDBG_G(flags) & PHPDBG_IS_DISCONNECTED)) {
PHPDBG_G(flags) &= ~PHPDBG_IS_DISCONNECTED;
goto phpdbg_interact;
}
+#endif
#ifdef _WIN32
} __except(phpdbg_exception_handler_win32(xp = GetExceptionInformation())) {
phpdbg_error("segfault", "", "Access violation (Segementation fault) encountered\ntrying to abort cleanly...");
}
-/* phpdbg_out: */
+phpdbg_out:
#endif
{
diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h
index 8c0dbb4afa..f3e8ba3107 100644
--- a/sapi/phpdbg/phpdbg.h
+++ b/sapi/phpdbg/phpdbg.h
@@ -67,6 +67,29 @@
# include "TSRM.h"
#endif
+#define ZEND_HASH_FOREACH_NUM_KEY_PTR(ht, _h, _ptr) \
+ ZEND_HASH_FOREACH(ht, 0); \
+ _h = _p->h; \
+ _ptr = Z_PTR_P(_z);
+
+#undef zend_hash_str_add
+#define zend_hash_str_add_tmp(ht, key, len, pData) \
+ _zend_hash_str_add(ht, key, len, pData ZEND_FILE_LINE_CC)
+#define zend_hash_str_add(...) zend_hash_str_add_tmp(__VA_ARGS__)
+
+static zend_always_inline void *zend_hash_index_add_mem(HashTable *ht, zend_ulong h, void *pData, size_t size)
+{
+ zval tmp, *zv;
+
+ ZVAL_PTR(&tmp, NULL);
+ if ((zv = zend_hash_index_add(ht, h, &tmp))) {
+ Z_PTR_P(zv) = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT);
+ memcpy(Z_PTR_P(zv), pData, size);
+ return Z_PTR_P(zv);
+ }
+ return NULL;
+}
+
#ifdef HAVE_LIBREADLINE
# include <readline/readline.h>
# include <readline/history.h>
@@ -225,7 +248,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
HashTable registered; /* registered */
HashTable seek; /* seek oplines */
phpdbg_frame_t frame; /* frame */
- zend_uint last_line; /* last executed line */
+ uint32_t last_line; /* last executed line */
phpdbg_lexer_data lexer; /* lexer data */
phpdbg_param_t *parser_stack; /* param stack during lexer / parser phase */
@@ -236,6 +259,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
phpdbg_btree watchpoint_tree; /* tree with watchpoints */
phpdbg_btree watch_HashTables; /* tree with original dtors of watchpoints */
HashTable watchpoints; /* watchpoints */
+ HashTable watch_collisions; /* collision table to check if multiple watches share the same recursive watchpoint */
zend_llist watchlist_mem; /* triggered watchpoints */
zend_bool watchpoint_hit; /* a watchpoint was hit */
void (*original_free_function)(void *); /* the original AG(mm_heap)->_free function */
@@ -243,9 +267,10 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
char *exec; /* file to execute */
size_t exec_len; /* size of exec */
zend_op_array *ops; /* op_array */
- zval *retval; /* return value */
+ zval retval; /* return value */
int bp_count; /* breakpoint count */
int vmret; /* return from last opcode handler execution */
+ zend_bool in_execution; /* in execution? */
zend_op_array *(*compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
HashTable file_sources;
diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c
index 81674a0daf..aaeaee13fd 100644
--- a/sapi/phpdbg/phpdbg_bp.c
+++ b/sapi/phpdbg/phpdbg_bp.c
@@ -43,7 +43,7 @@ static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execut
*/
static inline void _phpdbg_break_mapping(int id, HashTable *table TSRMLS_DC)
{
- zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], (id), (void**) &table, sizeof(void*), NULL);
+ zend_hash_index_update_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], id, table);
}
#define PHPDBG_BREAK_MAPPING(id, table) _phpdbg_break_mapping(id, table TSRMLS_CC)
@@ -57,29 +57,29 @@ static inline void _phpdbg_break_mapping(int id, HashTable *table TSRMLS_DC)
b.hits = 0; \
} while(0)
-static void phpdbg_file_breaks_dtor(void *data) /* {{{ */
+static void phpdbg_file_breaks_dtor(zval *data) /* {{{ */
{
- phpdbg_breakfile_t *bp = (phpdbg_breakfile_t*) data;
+ phpdbg_breakfile_t *bp = (phpdbg_breakfile_t*) Z_PTR_P(data);
efree((char*)bp->filename);
} /* }}} */
-static void phpdbg_class_breaks_dtor(void *data) /* {{{ */
+static void phpdbg_class_breaks_dtor(zval *data) /* {{{ */
{
- phpdbg_breakmethod_t *bp = (phpdbg_breakmethod_t*) data;
+ phpdbg_breakmethod_t *bp = (phpdbg_breakmethod_t *) Z_PTR_P(data);
efree((char*)bp->class_name);
efree((char*)bp->func_name);
} /* }}} */
-static void phpdbg_opline_class_breaks_dtor(void *data) /* {{{ */
+static void phpdbg_opline_class_breaks_dtor(zval *data) /* {{{ */
{
- zend_hash_destroy((HashTable *)data);
+ zend_hash_destroy((HashTable *) Z_PTR_P(data));
} /* }}} */
-static void phpdbg_opline_breaks_dtor(void *data) /* {{{ */
+static void phpdbg_opline_breaks_dtor(zval *data) /* {{{ */
{
- phpdbg_breakopline_t *bp = (phpdbg_breakopline_t *) data;
+ phpdbg_breakopline_t *bp = (phpdbg_breakopline_t *) Z_PTR_P(data);
if (bp->class_name) {
efree((char*)bp->class_name);
@@ -91,43 +91,30 @@ static void phpdbg_opline_breaks_dtor(void *data) /* {{{ */
PHPDBG_API void phpdbg_reset_breakpoints(TSRMLS_D) /* {{{ */
{
- if (zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])) {
- HashPosition position[2];
- HashTable **table = NULL;
+ HashTable *table;
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0]);
- zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], (void **) &table, &position[0]) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0])) {
- phpdbg_breakbase_t *brake;
+ ZEND_HASH_FOREACH_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], table) {
+ phpdbg_breakbase_t *brake;
- for (zend_hash_internal_pointer_reset_ex((*table), &position[1]);
- zend_hash_get_current_data_ex((*table), (void**)&brake, &position[1]) == SUCCESS;
- zend_hash_move_forward_ex((*table), &position[1])) {
- brake->hits = 0;
- }
- }
- }
+ ZEND_HASH_FOREACH_PTR(table, brake) {
+ brake->hits = 0;
+ } ZEND_HASH_FOREACH_END();
+ } ZEND_HASH_FOREACH_END();
} /* }}} */
PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */
{
- HashPosition position[2];
- HashTable **table = NULL;
+ HashTable *table;
zend_ulong id = 0L;
if (zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])) {
phpdbg_notice("exportbreakpoint", "count=\"%d\"", "Exporting %d breakpoints", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP]));
+
/* this only looks like magic, it isn't */
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0]);
- zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], (void **) &table, &position[0]) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0])) {
+ ZEND_HASH_FOREACH_NUM_KEY_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], id, table) {
phpdbg_breakbase_t *brake;
- zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], NULL, NULL, &id, 0, &position[0]);
-
- for (zend_hash_internal_pointer_reset_ex((*table), &position[1]);
- zend_hash_get_current_data_ex((*table), (void**)&brake, &position[1]) == SUCCESS;
- zend_hash_move_forward_ex((*table), &position[1])) {
+ ZEND_HASH_FOREACH_PTR(table, brake) {
if (brake->id == id) {
switch (brake->type) {
case PHPDBG_BREAK_FILE: {
@@ -152,7 +139,7 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */
case PHPDBG_BREAK_METHOD_OPLINE: {
fprintf(handle,
- "break %s::%s#%ld\n",
+ "break %s::%s#%llu\n",
((phpdbg_breakopline_t*)brake)->class_name,
((phpdbg_breakopline_t*)brake)->func_name,
((phpdbg_breakopline_t*)brake)->opline_num);
@@ -160,14 +147,14 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */
case PHPDBG_BREAK_FUNCTION_OPLINE: {
fprintf(handle,
- "break %s#%ld\n",
+ "break %s#%llu\n",
((phpdbg_breakopline_t*)brake)->func_name,
((phpdbg_breakopline_t*)brake)->opline_num);
} break;
case PHPDBG_BREAK_FILE_OPLINE: {
fprintf(handle,
- "break %s:#%ld\n",
+ "break %s:#%llu\n",
((phpdbg_breakopline_t*)brake)->class_name,
((phpdbg_breakopline_t*)brake)->opline_num);
} break;
@@ -211,8 +198,8 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */
} break;
}
}
- }
- }
+ } ZEND_HASH_FOREACH_END();
+ } ZEND_HASH_FOREACH_END();
}
} /* }}} */
@@ -232,15 +219,12 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML
}
path_len = strlen(path);
- if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE],
- path, path_len, (void**)&broken) == FAILURE) {
+ if (!(broken = zend_hash_str_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], path, path_len))) {
HashTable breaks;
zend_hash_init(&breaks, 8, NULL, phpdbg_file_breaks_dtor, 0);
- zend_hash_update(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE],
- path, path_len, &breaks, sizeof(HashTable),
- (void**)&broken);
+ broken = zend_hash_str_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], path, path_len, &breaks, sizeof(HashTable));
}
if (!zend_hash_index_exists(broken, line_num)) {
@@ -250,10 +234,9 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML
new_break.filename = estrndup(path, path_len);
new_break.line = line_num;
- zend_hash_index_update( broken, line_num, (void**)&new_break, sizeof(phpdbg_breakfile_t), NULL);
+ zend_hash_index_update_mem(broken, line_num, &new_break, sizeof(phpdbg_breakfile_t));
- phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" file=\"%s\" line=\"%ld\"", "Breakpoint #%d added at %s:%ld",
- new_break.id, new_break.filename, new_break.line);
+ phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" file=\"%s\" line=\"%ld\"", "Breakpoint #%d added at %s:%ld", new_break.id, new_break.filename, new_break.line);
PHPDBG_BREAK_MAPPING(new_break.id, broken);
} else {
@@ -270,7 +253,7 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRML
PHPDBG_API void phpdbg_set_breakpoint_symbol(const char *name, size_t name_len TSRMLS_DC) /* {{{ */
{
- if (!zend_hash_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], name, name_len)) {
+ if (!zend_hash_str_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], name, name_len)) {
phpdbg_breaksymbol_t new_break;
PHPDBG_G(flags) |= PHPDBG_HAS_SYM_BP;
@@ -278,11 +261,9 @@ PHPDBG_API void phpdbg_set_breakpoint_symbol(const char *name, size_t name_len T
PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_SYM);
new_break.symbol = estrndup(name, name_len);
- zend_hash_update(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], new_break.symbol,
- name_len, &new_break, sizeof(phpdbg_breaksymbol_t), NULL);
+ zend_hash_str_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], new_break.symbol, name_len, &new_break, sizeof(phpdbg_breaksymbol_t));
- phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" function=\"%s\"", "Breakpoint #%d added at %s",
- new_break.id, new_break.symbol);
+ phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" function=\"%s\"", "Breakpoint #%d added at %s", new_break.id, new_break.symbol);
PHPDBG_BREAK_MAPPING(new_break.id, &PHPDBG_G(bp)[PHPDBG_BREAK_SYM]);
} else {
@@ -297,16 +278,12 @@ PHPDBG_API void phpdbg_set_breakpoint_method(const char *class_name, const char
size_t func_len = strlen(func_name);
char *lcname = zend_str_tolower_dup(func_name, func_len);
- if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], class_name,
- class_len, (void**)&class_table) != SUCCESS) {
+ if (!(class_table = zend_hash_str_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], class_name, class_len))) {
zend_hash_init(&class_breaks, 8, NULL, phpdbg_class_breaks_dtor, 0);
- zend_hash_update(
- &PHPDBG_G(bp)[PHPDBG_BREAK_METHOD],
- class_name, class_len,
- (void**)&class_breaks, sizeof(HashTable), (void**)&class_table);
+ class_table = zend_hash_str_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], class_name, class_len, &class_breaks, sizeof(HashTable));
}
- if (!zend_hash_exists(class_table, lcname, func_len)) {
+ if (!zend_hash_str_exists(class_table, lcname, func_len)) {
phpdbg_breakmethod_t new_break;
PHPDBG_G(flags) |= PHPDBG_HAS_METHOD_BP;
@@ -317,11 +294,9 @@ PHPDBG_API void phpdbg_set_breakpoint_method(const char *class_name, const char
new_break.func_name = estrndup(func_name, func_len);
new_break.func_len = func_len;
- zend_hash_update(class_table, lcname, func_len,
- &new_break, sizeof(phpdbg_breakmethod_t), NULL);
+ zend_hash_str_update_mem(class_table, lcname, func_len, &new_break, sizeof(phpdbg_breakmethod_t));
- phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" method=\"%s::%s\"", "Breakpoint #%d added at %s::%s",
- new_break.id, class_name, func_name);
+ phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" method=\"%s::%s\"", "Breakpoint #%d added at %s::%s", new_break.id, class_name, func_name);
PHPDBG_BREAK_MAPPING(new_break.id, class_table);
} else {
@@ -343,11 +318,9 @@ PHPDBG_API void phpdbg_set_breakpoint_opline(zend_ulong opline TSRMLS_DC) /* {{{
new_break.opline = opline;
new_break.base = NULL;
- zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], opline,
- &new_break, sizeof(phpdbg_breakline_t), NULL);
+ zend_hash_index_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], opline, &new_break, sizeof(phpdbg_breakline_t));
- phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" opline=\"%#lx\"", "Breakpoint #%d added at %#lx",
- new_break.id, new_break.opline);
+ phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" opline=\"%#lx\"", "Breakpoint #%d added at %#lx", new_break.id, new_break.opline);
PHPDBG_BREAK_MAPPING(new_break.id, &PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]);
} else {
phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" opline=\"%#lx\"", "Breakpoint exists at %#lx", opline);
@@ -385,7 +358,7 @@ PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_o
PHPDBG_G(flags) |= PHPDBG_HAS_OPLINE_BP;
- zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], opline_break.opline, &opline_break, sizeof(phpdbg_breakline_t), NULL);
+ zend_hash_index_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], opline_break.opline, &opline_break, sizeof(phpdbg_breakline_t));
return SUCCESS;
} /* }}} */
@@ -394,40 +367,36 @@ PHPDBG_API void phpdbg_resolve_op_array_breaks(zend_op_array *op_array TSRMLS_DC
{
HashTable *func_table = &PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE];
HashTable *oplines_table;
- HashPosition position;
phpdbg_breakopline_t *brake;
- if (op_array->scope != NULL &&
- zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], op_array->scope->name, op_array->scope->name_length, (void **)&func_table) == FAILURE) {
+ if (op_array->scope != NULL && !(func_table = zend_hash_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], op_array->scope->name))) {
return;
}
if (op_array->function_name == NULL) {
- if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], op_array->filename, strlen(op_array->filename), (void **)&oplines_table) == FAILURE) {
+ if (!(oplines_table = zend_hash_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], op_array->filename))) {
return;
}
- } else if (zend_hash_find(func_table, op_array->function_name?op_array->function_name:"", op_array->function_name?strlen(op_array->function_name):0, (void **)&oplines_table) == FAILURE) {
+ } else if (!op_array->function_name || !(oplines_table = zend_hash_find_ptr(func_table, op_array->function_name))) {
return;
}
- for (zend_hash_internal_pointer_reset_ex(oplines_table, &position);
- zend_hash_get_current_data_ex(oplines_table, (void**) &brake, &position) == SUCCESS;
- zend_hash_move_forward_ex(oplines_table, &position)) {
+ ZEND_HASH_FOREACH_PTR(oplines_table, brake) {
if (phpdbg_resolve_op_array_break(brake, op_array TSRMLS_CC) == SUCCESS) {
phpdbg_breakline_t *opline_break;
zend_hash_internal_pointer_end(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]);
- zend_hash_get_current_data(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (void **)&opline_break);
+ opline_break = zend_hash_get_current_data_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]);
phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" symbol=\"%s\" num=\"%ld\" opline=\"%#lx\"", "Breakpoint #%d resolved at %s%s%s#%ld (opline %#lx)",
brake->id,
- brake->class_name?brake->class_name:"",
- brake->class_name&&brake->func_name?"::":"",
- brake->func_name?brake->func_name:"",
+ brake->class_name ? brake->class_name : "",
+ brake->class_name && brake->func_name ? "::" : "",
+ brake->func_name ? brake->func_name : "",
brake->opline_num,
brake->opline);
}
- }
+ } ZEND_HASH_FOREACH_END();
} /* }}} */
PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRMLS_DC) /* {{{ */
@@ -448,8 +417,9 @@ PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRML
} else {
zend_execute_data *execute_data = EG(current_execute_data);
do {
- if (execute_data->op_array->function_name == NULL && execute_data->op_array->scope == NULL && !memcmp(execute_data->op_array->filename, new_break->class_name, new_break->class_len)) {
- if (phpdbg_resolve_op_array_break(new_break, execute_data->op_array TSRMLS_CC) == SUCCESS) {
+ zend_op_array *op_array = &execute_data->func->op_array;
+ if (op_array->function_name == NULL && op_array->scope == NULL && new_break->class_len == op_array->filename->len && !memcmp(op_array->filename->val, new_break->class_name, new_break->class_len)) {
+ if (phpdbg_resolve_op_array_break(new_break, op_array TSRMLS_CC) == SUCCESS) {
return SUCCESS;
} else {
return 2;
@@ -461,14 +431,14 @@ PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break TSRML
}
if (new_break->class_name != NULL) {
- zend_class_entry **ce;
- if (zend_hash_find(EG(class_table), zend_str_tolower_dup(new_break->class_name, new_break->class_len), new_break->class_len + 1, (void **)&ce) == FAILURE) {
+ zend_class_entry *ce;
+ if (!(ce = zend_hash_str_find_ptr(EG(class_table), zend_str_tolower_dup(new_break->class_name, new_break->class_len), new_break->class_len))) {
return FAILURE;
}
- func_table = &(*ce)->function_table;
+ func_table = &ce->function_table;
}
- if (zend_hash_find(func_table, zend_str_tolower_dup(new_break->func_name, new_break->func_len), new_break->func_len + 1, (void **)&func) == FAILURE) {
+ if (!(func = zend_hash_str_find_ptr(func_table, zend_str_tolower_dup(new_break->func_name, new_break->func_len), new_break->func_len))) {
if (new_break->class_name != NULL && new_break->func_name != NULL) {
phpdbg_error("breakpoint", "type=\"nomethod\" method=\"%s::%s\"", "Method %s doesn't exist in class %s", new_break->func_name, new_break->class_name);
return 2;
@@ -519,22 +489,14 @@ PHPDBG_API void phpdbg_set_breakpoint_method_opline(const char *class, const cha
return;
}
- if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], new_break.class_name, new_break.class_len, (void **)&class_table) == FAILURE) {
+ if (!(class_table = zend_hash_str_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], new_break.class_name, new_break.class_len))) {
zend_hash_init(&class_breaks, 8, NULL, phpdbg_opline_class_breaks_dtor, 0);
- zend_hash_update(
- &PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE],
- new_break.class_name,
- new_break.class_len,
- (void **)&class_breaks, sizeof(HashTable), (void **)&class_table);
+ class_table = zend_hash_str_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], new_break.class_name, new_break.class_len, &class_breaks, sizeof(HashTable));
}
- if (zend_hash_find(class_table, new_break.func_name, new_break.func_len, (void **)&method_table) == FAILURE) {
+ if (!(method_table = zend_hash_str_find_ptr(class_table, new_break.func_name, new_break.func_len))) {
zend_hash_init(&method_breaks, 8, NULL, phpdbg_opline_breaks_dtor, 0);
- zend_hash_update(
- class_table,
- new_break.func_name,
- new_break.func_len,
- (void **)&method_breaks, sizeof(HashTable), (void **)&method_table);
+ method_table = zend_hash_str_update_mem(class_table, new_break.func_name, new_break.func_len, &method_breaks, sizeof(HashTable));
}
if (zend_hash_index_exists(method_table, opline)) {
@@ -549,7 +511,7 @@ PHPDBG_API void phpdbg_set_breakpoint_method_opline(const char *class, const cha
PHPDBG_BREAK_MAPPING(new_break.id, method_table);
- zend_hash_index_update(method_table, opline, &new_break, sizeof(phpdbg_breakopline_t), NULL);
+ zend_hash_index_update_mem(method_table, opline, &new_break, sizeof(phpdbg_breakopline_t));
}
PHPDBG_API void phpdbg_set_breakpoint_function_opline(const char *function, zend_ulong opline TSRMLS_DC) /* {{{ */
@@ -578,13 +540,9 @@ PHPDBG_API void phpdbg_set_breakpoint_function_opline(const char *function, zend
return;
}
- if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], new_break.func_name, new_break.func_len, (void **)&func_table) == FAILURE) {
+ if (!(func_table = zend_hash_str_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], new_break.func_name, new_break.func_len))) {
zend_hash_init(&func_breaks, 8, NULL, phpdbg_opline_breaks_dtor, 0);
- zend_hash_update(
- &PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE],
- new_break.func_name,
- new_break.func_len,
- (void **)&func_breaks, sizeof(HashTable), (void **)&func_table);
+ func_table = zend_hash_str_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], new_break.func_name, new_break.func_len, &func_breaks, sizeof(HashTable));
}
if (zend_hash_index_exists(func_table, opline)) {
@@ -598,7 +556,7 @@ PHPDBG_API void phpdbg_set_breakpoint_function_opline(const char *function, zend
PHPDBG_G(flags) |= PHPDBG_HAS_FUNCTION_OPLINE_BP;
- zend_hash_index_update(func_table, opline, &new_break, sizeof(phpdbg_breakopline_t), NULL);
+ zend_hash_index_update_mem(func_table, opline, &new_break, sizeof(phpdbg_breakopline_t));
}
PHPDBG_API void phpdbg_set_breakpoint_file_opline(const char *file, zend_ulong opline TSRMLS_DC) /* {{{ */
@@ -627,13 +585,9 @@ PHPDBG_API void phpdbg_set_breakpoint_file_opline(const char *file, zend_ulong o
return;
}
- if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], new_break.class_name, new_break.class_len, (void **)&file_table) == FAILURE) {
+ if (!(file_table = zend_hash_str_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], new_break.class_name, new_break.class_len))) {
zend_hash_init(&file_breaks, 8, NULL, phpdbg_opline_breaks_dtor, 0);
- zend_hash_update(
- &PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE],
- new_break.class_name,
- new_break.class_len,
- (void **)&file_breaks, sizeof(HashTable), (void **)&file_table);
+ file_table = zend_hash_str_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], new_break.class_name, new_break.class_len, &file_breaks, sizeof(HashTable));
}
if (zend_hash_index_exists(file_table, opline)) {
@@ -647,7 +601,7 @@ PHPDBG_API void phpdbg_set_breakpoint_file_opline(const char *file, zend_ulong o
PHPDBG_G(flags) |= PHPDBG_HAS_FILE_OPLINE_BP;
- zend_hash_index_update(file_table, opline, &new_break, sizeof(phpdbg_breakopline_t), NULL);
+ zend_hash_index_update_mem(file_table, opline, &new_break, sizeof(phpdbg_breakopline_t));
}
PHPDBG_API void phpdbg_set_breakpoint_opcode(const char *name, size_t name_len TSRMLS_DC) /* {{{ */
@@ -664,8 +618,7 @@ PHPDBG_API void phpdbg_set_breakpoint_opcode(const char *name, size_t name_len T
new_break.hash = hash;
new_break.name = estrndup(name, name_len);
- zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], hash,
- &new_break, sizeof(phpdbg_breakop_t), NULL);
+ zend_hash_index_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], hash, &new_break, sizeof(phpdbg_breakop_t));
PHPDBG_G(flags) |= PHPDBG_HAS_OPCODE_BP;
@@ -683,8 +636,7 @@ PHPDBG_API void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline TSRML
PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_OPLINE);
new_break.opline = (zend_ulong) opline;
- zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE],
- (zend_ulong) opline, &new_break, sizeof(phpdbg_breakline_t), NULL);
+ zend_hash_index_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (zend_ulong) opline, &new_break, sizeof(phpdbg_breakline_t));
phpdbg_notice("breakpoint", "id=\"%d\" opline=\"%#lx\"", "Breakpoint #%d added at %#lx", new_break.id, new_break.opline);
PHPDBG_BREAK_MAPPING(new_break.id, &PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]);
@@ -696,7 +648,7 @@ PHPDBG_API void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline TSRML
static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, const phpdbg_param_t *param, const char *expr, size_t expr_len, zend_ulong hash TSRMLS_DC) /* {{{ */
{
phpdbg_breakcond_t new_break;
- zend_uint cops = CG(compiler_options);
+ uint32_t cops = CG(compiler_options);
zval pv;
PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_COND);
@@ -717,22 +669,19 @@ static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, co
new_break.code = estrndup(expr, expr_len);
new_break.code_len = expr_len;
- Z_STRLEN(pv) = expr_len + sizeof("return ;") - 1;
- Z_STRVAL(pv) = emalloc(Z_STRLEN(pv) + 1);
+ Z_STR(pv) = zend_string_alloc(expr_len + sizeof("return ;") - 1, 0);
memcpy(Z_STRVAL(pv), "return ", sizeof("return ") - 1);
memcpy(Z_STRVAL(pv) + sizeof("return ") - 1, expr, expr_len);
Z_STRVAL(pv)[Z_STRLEN(pv) - 1] = ';';
Z_STRVAL(pv)[Z_STRLEN(pv)] = '\0';
- Z_TYPE(pv) = IS_STRING;
+ Z_TYPE_INFO(pv) = IS_STRING;
new_break.ops = zend_compile_string(&pv, "Conditional Breakpoint Code" TSRMLS_CC);
zval_dtor(&pv);
if (new_break.ops) {
- zend_hash_index_update(
- &PHPDBG_G(bp)[PHPDBG_BREAK_COND], hash, &new_break,
- sizeof(phpdbg_breakcond_t), (void**)&brake);
+ brake = zend_hash_index_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], hash, &new_break, sizeof(phpdbg_breakcond_t));
phpdbg_notice("breakpoint", "id=\"%d\" expression=\"%s\" ptr=\"%p\"", "Conditional breakpoint #%d added %s/%p", brake->id, brake->code, brake->ops);
@@ -743,6 +692,7 @@ static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, co
efree((char*)new_break.code);
PHPDBG_G(bp_count)--;
}
+
CG(compiler_options) = cops;
} /* }}} */
@@ -782,14 +732,12 @@ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_file(zend_op_array *op_
{
HashTable *breaks;
phpdbg_breakbase_t *brake;
- size_t name_len = strlen(op_array->filename);
- if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], op_array->filename,
- name_len, (void**)&breaks) == FAILURE) {
+ if (!(breaks = zend_hash_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], op_array->filename))) {
return NULL;
}
- if (zend_hash_index_find(breaks, (*EG(opline_ptr))->lineno, (void**)&brake) == SUCCESS) {
+ if (EG(current_execute_data) && (brake = zend_hash_index_find_ptr(breaks, EG(current_execute_data)->opline->lineno))) {
return brake;
}
@@ -799,88 +747,73 @@ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_file(zend_op_array *op_
static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_symbol(zend_function *fbc TSRMLS_DC) /* {{{ */
{
const char *fname;
+ size_t flen;
zend_op_array *ops;
- phpdbg_breakbase_t *brake;
if (fbc->type != ZEND_USER_FUNCTION) {
return NULL;
}
- ops = (zend_op_array*)fbc;
+ ops = (zend_op_array *) fbc;
if (ops->scope) {
/* find method breaks here */
return phpdbg_find_breakpoint_method(ops TSRMLS_CC);
}
- fname = ops->function_name;
-
- if (!fname) {
+ if (ops->function_name) {
+ fname = ops->function_name->val;
+ flen = ops->function_name->len;
+ } else {
fname = "main";
+ flen = 4;
}
- if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], fname, strlen(fname), (void**)&brake) == SUCCESS) {
- return brake;
- }
-
- return NULL;
+ return zend_hash_str_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], fname, flen);
} /* }}} */
static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_method(zend_op_array *ops TSRMLS_DC) /* {{{ */
{
HashTable *class_table;
- phpdbg_breakbase_t *brake;
+ phpdbg_breakbase_t *brake = NULL;
- if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], ops->scope->name,
- ops->scope->name_length, (void**)&class_table) == SUCCESS) {
- char *lcname = zend_str_tolower_dup(ops->function_name, strlen(ops->function_name));
- size_t lcname_len = strlen(lcname);
-
- if (zend_hash_find(
- class_table,
- lcname,
- lcname_len, (void**)&brake) == SUCCESS) {
- efree(lcname);
- return brake;
- }
+ if ((class_table = zend_hash_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], ops->scope->name))) {
+ size_t lcname_len = ops->function_name->len;
+ char *lcname = zend_str_tolower_dup(ops->function_name->val, lcname_len);
+
+ brake = zend_hash_str_find_ptr(class_table, lcname, lcname_len);
efree(lcname);
}
- return NULL;
+ return brake;
} /* }}} */
static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_opline(phpdbg_opline_ptr_t opline TSRMLS_DC) /* {{{ */
{
phpdbg_breakline_t *brake;
- if (zend_hash_index_find(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE],
- (zend_ulong) opline, (void**)&brake) == SUCCESS) {
- return (brake->base?(phpdbg_breakbase_t *)brake->base:(phpdbg_breakbase_t *)brake);
+ if ((brake = zend_hash_index_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (zend_ulong) opline)) && brake->base) {
+ return (phpdbg_breakbase_t *)brake->base;
}
- return NULL;
+ return (phpdbg_breakbase_t *) brake;
} /* }}} */
static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_opcode(zend_uchar opcode TSRMLS_DC) /* {{{ */
{
- phpdbg_breakbase_t *brake;
const char *opname = phpdbg_decode_opcode(opcode);
if (memcmp(opname, PHPDBG_STRL("UNKNOWN")) == 0) {
return NULL;
}
- if (zend_hash_index_find(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE],
- zend_hash_func(opname, strlen(opname)), (void**)&brake) == SUCCESS) {
- return brake;
- }
- return NULL;
+ return zend_hash_index_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], zend_hash_func(opname, strlen(opname)));
} /* }}} */
static inline zend_bool phpdbg_find_breakpoint_param(phpdbg_param_t *param, zend_execute_data *execute_data TSRMLS_DC) /* {{{ */
{
- zend_function *function = (zend_function*) execute_data->function_state.function;
+ zend_function *function = execute_data->func;
switch (param->type) {
case NUMERIC_FUNCTION_PARAM:
@@ -895,8 +828,8 @@ static inline zend_bool phpdbg_find_breakpoint_param(phpdbg_param_t *param, zend
const char *str = NULL;
size_t len = 0L;
zend_op_array *ops = (zend_op_array*)function;
- str = ops->function_name ? ops->function_name : "main";
- len = strlen(str);
+ str = ops->function_name ? ops->function_name->val : "main";
+ len = ops->function_name ? ops->function_name->len : strlen(str);
if (len == param->len && memcmp(param->str, str, len) == SUCCESS) {
return param->type == STR_PARAM || execute_data->opline - ops->opcodes == param->num;
@@ -926,10 +859,10 @@ static inline zend_bool phpdbg_find_breakpoint_param(phpdbg_param_t *param, zend
zend_op_array *ops = (zend_op_array*) function;
if (ops->scope) {
- size_t lengths[2] = {strlen(param->method.class), ops->scope->name_length};
+ size_t lengths[2] = { strlen(param->method.class), ops->scope->name->len };
if (lengths[0] == lengths[1] && memcmp(param->method.class, ops->scope->name, lengths[0]) == SUCCESS) {
lengths[0] = strlen(param->method.name);
- lengths[1] = strlen(ops->function_name);
+ lengths[1] = ops->function_name->len;
if (lengths[0] == lengths[1] && memcmp(param->method.name, ops->function_name, lengths[0]) == SUCCESS) {
return param->type == METHOD_PARAM || (execute_data->opline - ops->opcodes) == param->num;
@@ -953,16 +886,13 @@ static inline zend_bool phpdbg_find_breakpoint_param(phpdbg_param_t *param, zend
static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */
{
phpdbg_breakcond_t *bp;
- HashPosition position;
int breakpoint = FAILURE;
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position);
- zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], (void*)&bp, &position) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position)) {
- zval *retval = NULL;
- zval **orig_retval = EG(return_value_ptr_ptr);
- zend_op_array *orig_ops = EG(active_op_array);
- zend_op **orig_opline = EG(opline_ptr);
+ ZEND_HASH_FOREACH_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], bp) {
+ zval retval;
+ const zend_op *orig_opline = EG(current_execute_data)->opline;
+ zend_function *orig_func = EG(current_execute_data)->func;
+ zval *orig_retval = EG(current_execute_data)->return_value;
if (((phpdbg_breakbase_t*)bp)->disabled) {
continue;
@@ -974,49 +904,37 @@ static inline phpdbg_breakbase_t *phpdbg_find_conditional_breakpoint(zend_execut
}
}
- ALLOC_INIT_ZVAL(retval);
-
- EG(return_value_ptr_ptr) = &retval;
- EG(active_op_array) = bp->ops;
EG(no_extensions) = 1;
- if (!EG(active_symbol_table)) {
- zend_rebuild_symbol_table(TSRMLS_C);
- }
+ zend_rebuild_symbol_table(TSRMLS_C);
zend_try {
PHPDBG_G(flags) |= PHPDBG_IN_COND_BP;
- zend_execute(EG(active_op_array) TSRMLS_CC);
+ zend_execute(bp->ops, &retval TSRMLS_CC);
#if PHP_VERSION_ID >= 50700
- if (zend_is_true(retval TSRMLS_CC)) {
+ if (zend_is_true(&retval TSRMLS_CC)) {
#else
- if (zend_is_true(retval)) {
+ if (zend_is_true(&retval)) {
#endif
breakpoint = SUCCESS;
}
- } zend_catch {
- EG(no_extensions)=1;
- EG(return_value_ptr_ptr) = orig_retval;
- EG(active_op_array) = orig_ops;
- EG(opline_ptr) = orig_opline;
- PHPDBG_G(flags) &= ~PHPDBG_IN_COND_BP;
} zend_end_try();
- EG(no_extensions)=1;
- EG(return_value_ptr_ptr) = orig_retval;
- EG(active_op_array) = orig_ops;
- EG(opline_ptr) = orig_opline;
+ EG(no_extensions) = 1;
+ EG(current_execute_data)->opline = orig_opline;
+ EG(current_execute_data)->func = orig_func;
+ EG(current_execute_data)->return_value = orig_retval;
PHPDBG_G(flags) &= ~PHPDBG_IN_COND_BP;
if (breakpoint == SUCCESS) {
break;
}
- }
+ } ZEND_HASH_FOREACH_END();
- return (breakpoint == SUCCESS) ? ((phpdbg_breakbase_t*)bp) : NULL;
+ return (breakpoint == SUCCESS) ? ((phpdbg_breakbase_t *) bp) : NULL;
} /* }}} */
-PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakpoint(zend_execute_data* execute_data TSRMLS_DC) /* {{{ */
+PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakpoint(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */
{
phpdbg_breakbase_t *base = NULL;
@@ -1031,28 +949,24 @@ PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakpoint(zend_execute_data* execute
goto result;
}
- if ((PHPDBG_G(flags) & PHPDBG_HAS_FILE_BP) &&
- (base = phpdbg_find_breakpoint_file(execute_data->op_array TSRMLS_CC))) {
+ if ((PHPDBG_G(flags) & PHPDBG_HAS_FILE_BP) && (base = phpdbg_find_breakpoint_file(&execute_data->func->op_array TSRMLS_CC))) {
goto result;
}
if (PHPDBG_G(flags) & (PHPDBG_HAS_METHOD_BP|PHPDBG_HAS_SYM_BP)) {
/* check we are at the beginning of the stack */
- if (execute_data->opline == EG(active_op_array)->opcodes) {
- if ((base = phpdbg_find_breakpoint_symbol(
- execute_data->function_state.function TSRMLS_CC))) {
+ if (execute_data->opline == execute_data->func->op_array.opcodes) {
+ if ((base = phpdbg_find_breakpoint_symbol(execute_data->func TSRMLS_CC))) {
goto result;
}
}
}
- if ((PHPDBG_G(flags) & PHPDBG_HAS_OPLINE_BP) &&
- (base = phpdbg_find_breakpoint_opline(execute_data->opline TSRMLS_CC))) {
+ if ((PHPDBG_G(flags) & PHPDBG_HAS_OPLINE_BP) && (base = phpdbg_find_breakpoint_opline((phpdbg_opline_ptr_t) execute_data->opline TSRMLS_CC))) {
goto result;
}
- if ((PHPDBG_G(flags) & PHPDBG_HAS_OPCODE_BP) &&
- (base = phpdbg_find_breakpoint_opcode(execute_data->opline->opcode TSRMLS_CC))) {
+ if ((PHPDBG_G(flags) & PHPDBG_HAS_OPCODE_BP) && (base = phpdbg_find_breakpoint_opcode(execute_data->opline->opcode TSRMLS_CC))) {
goto result;
}
@@ -1069,14 +983,12 @@ result:
PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num TSRMLS_DC) /* {{{ */
{
- HashTable **table;
- HashPosition position;
+ HashTable *table;
phpdbg_breakbase_t *brake;
+ zend_string *strkey;
+ zend_ulong numkey;
- if ((brake = phpdbg_find_breakbase_ex(num, &table, &position TSRMLS_CC))) {
- char *key;
- zend_uint klen;
- zend_ulong idx;
+ if ((brake = phpdbg_find_breakbase_ex(num, &table, &numkey, &strkey TSRMLS_CC))) {
int type = brake->type;
char *name = NULL;
size_t name_len = 0L;
@@ -1084,7 +996,7 @@ PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num TSRMLS_DC) /* {{{ */
switch (type) {
case PHPDBG_BREAK_FILE:
case PHPDBG_BREAK_METHOD:
- if (zend_hash_num_elements((*table)) == 1) {
+ if (zend_hash_num_elements(table) == 1) {
name = estrdup(brake->name);
name_len = strlen(name);
if (zend_hash_num_elements(&PHPDBG_G(bp)[type]) == 1) {
@@ -1094,7 +1006,7 @@ PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num TSRMLS_DC) /* {{{ */
break;
default: {
- if (zend_hash_num_elements((*table)) == 1) {
+ if (zend_hash_num_elements(table) == 1) {
PHPDBG_G(flags) &= ~(1<<(brake->type+1));
}
}
@@ -1107,25 +1019,20 @@ PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num TSRMLS_DC) /* {{{ */
if (zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]) == 1) {
PHPDBG_G(flags) &= PHPDBG_HAS_OPLINE_BP;
}
- zend_hash_index_del(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], ((phpdbg_breakopline_t*)brake)->opline);
+ zend_hash_index_del(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], ((phpdbg_breakopline_t *) brake)->opline);
}
- switch (zend_hash_get_current_key_ex(
- (*table), &key, &klen, &idx, 0, &position)) {
-
- case HASH_KEY_IS_STRING:
- zend_hash_del((*table), key, klen);
- break;
-
- default:
- zend_hash_index_del((*table), idx);
+ if (strkey) {
+ zend_hash_del(table, strkey);
+ } else {
+ zend_hash_index_del(table, numkey);
}
switch (type) {
case PHPDBG_BREAK_FILE:
case PHPDBG_BREAK_METHOD:
if (name) {
- zend_hash_del(&PHPDBG_G(bp)[type], name, name_len);
+ zend_hash_str_del(&PHPDBG_G(bp)[type], name, name_len);
efree(name);
}
break;
@@ -1307,26 +1214,25 @@ PHPDBG_API void phpdbg_disable_breakpoints(TSRMLS_D) { /* {{{ */
PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase(zend_ulong id TSRMLS_DC) /* {{{ */
{
- HashTable **table;
- HashPosition position;
+ HashTable *table;
+ zend_string *strkey;
+ zend_ulong numkey;
- return phpdbg_find_breakbase_ex(id, &table, &position TSRMLS_CC);
+ return phpdbg_find_breakbase_ex(id, &table, &numkey, &strkey TSRMLS_CC);
} /* }}} */
-PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable ***table, HashPosition *position TSRMLS_DC) /* {{{ */
+PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable **table, zend_ulong *numkey, zend_string **strkey TSRMLS_DC) /* {{{ */
{
- if (zend_hash_index_find(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], id, (void**)table) == SUCCESS) {
+ if ((*table = zend_hash_index_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], id))) {
phpdbg_breakbase_t *brake;
- for (zend_hash_internal_pointer_reset_ex((**table), position);
- zend_hash_get_current_data_ex((**table), (void**)&brake, position) == SUCCESS;
- zend_hash_move_forward_ex((**table), position)) {
-
+ ZEND_HASH_FOREACH_KEY_PTR(*table, *numkey, *strkey, brake) {
if (brake->id == id) {
return brake;
}
- }
+ } ZEND_HASH_FOREACH_END();
}
+
return NULL;
} /* }}} */
@@ -1336,259 +1242,182 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */
switch (type) {
case PHPDBG_BREAK_SYM: if ((PHPDBG_G(flags) & PHPDBG_HAS_SYM_BP)) {
- HashPosition position;
phpdbg_breaksymbol_t *brake;
phpdbg_out(SEPARATE "\n");
phpdbg_out("Function Breakpoints:\n");
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], &position);
- zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], (void**) &brake, &position) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], &position)) {
+ ZEND_HASH_FOREACH_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], brake) {
phpdbg_writeln("function", "id=\"%d\" name=\"%s\" disabled=\"%s\"", "#%d\t\t%s%s",
brake->id, brake->symbol,
- ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
- }
+ ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : "");
+ } ZEND_HASH_FOREACH_END();
} break;
case PHPDBG_BREAK_METHOD: if ((PHPDBG_G(flags) & PHPDBG_HAS_METHOD_BP)) {
- HashPosition position[2];
HashTable *class_table;
- char *class_name = NULL;
- zend_uint class_len = 0;
- zend_ulong class_idx = 0L;
phpdbg_out(SEPARATE "\n");
phpdbg_out("Method Breakpoints:\n");
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], &position[0]);
- zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], (void**) &class_table, &position[0]) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], &position[0])) {
-
- if (zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD],
- &class_name, &class_len, &class_idx, 0, &position[0]) == HASH_KEY_IS_STRING) {
- phpdbg_breakmethod_t *brake;
-
- for (zend_hash_internal_pointer_reset_ex(class_table, &position[1]);
- zend_hash_get_current_data_ex(class_table, (void**)&brake, &position[1]) == SUCCESS;
- zend_hash_move_forward_ex(class_table, &position[1])) {
- phpdbg_writeln("method", "id=\"%d\" name=\"%s::%s\" disabled=\"%s\"", "#%d\t\t%s::%s%s",
- brake->id, brake->class_name, brake->func_name,
- ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
- }
- }
-
- }
+ ZEND_HASH_FOREACH_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], class_table) {
+ phpdbg_breakmethod_t *brake;
+
+ ZEND_HASH_FOREACH_PTR(class_table, brake) {
+ phpdbg_writeln("method", "id=\"%d\" name=\"%s::%s\" disabled=\"%s\"", "#%d\t\t%s::%s%s",
+ brake->id, brake->class_name, brake->func_name,
+ ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : "");
+ } ZEND_HASH_FOREACH_END();
+ } ZEND_HASH_FOREACH_END();
} break;
case PHPDBG_BREAK_FILE: if ((PHPDBG_G(flags) & PHPDBG_HAS_FILE_BP)) {
- HashPosition position[2];
HashTable *points;
phpdbg_out(SEPARATE "\n");
phpdbg_out("File Breakpoints:\n");
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position[0]);
- zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], (void**) &points, &position[0]) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position[0])) {
+ ZEND_HASH_FOREACH_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], points) {
phpdbg_breakfile_t *brake;
- for (zend_hash_internal_pointer_reset_ex(points, &position[1]);
- zend_hash_get_current_data_ex(points, (void**)&brake, &position[1]) == SUCCESS;
- zend_hash_move_forward_ex(points, &position[1])) {
+ ZEND_HASH_FOREACH_PTR(points, brake) {
phpdbg_writeln("file", "id=\"%d\" name=\"%s\" line=\"%lu\" disabled=\"%s\"", "#%d\t\t%s:%lu%s",
brake->id, brake->filename, brake->line,
- ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
- }
- }
+ ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : "");
+ } ZEND_HASH_FOREACH_END();
+ } ZEND_HASH_FOREACH_END();
} break;
case PHPDBG_BREAK_OPLINE: if ((PHPDBG_G(flags) & PHPDBG_HAS_OPLINE_BP)) {
- HashPosition position;
phpdbg_breakline_t *brake;
phpdbg_out(SEPARATE "\n");
phpdbg_out("Opline Breakpoints:\n");
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], &position);
- zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (void**) &brake, &position) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], &position)) {
+ ZEND_HASH_FOREACH_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], brake) {
+ const char *type;
switch (brake->type) {
case PHPDBG_BREAK_METHOD_OPLINE:
+ type = "method";
+ goto print_opline;
case PHPDBG_BREAK_FUNCTION_OPLINE:
+ type = "function";
+ goto print_opline;
case PHPDBG_BREAK_FILE_OPLINE:
- phpdbg_writeln("opline", "id=\"%d\" num=\"%#lx\" type=\"%s\" disabled=\"%s\"", "#%d\t\t%#lx\t\t(%s breakpoint)%s", brake->id, brake->opline,
- brake->type == PHPDBG_BREAK_METHOD_OPLINE ? "method" :
- brake->type == PHPDBG_BREAK_FUNCTION_OPLINE ? "function" :
- brake->type == PHPDBG_BREAK_FILE_OPLINE ? "file" :
- "--- error ---",
- ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
- break;
+ type = "method";
+
+ print_opline: {
+ if (brake->type == PHPDBG_BREAK_METHOD_OPLINE) {
+ type = "method";
+ } else if (brake->type == PHPDBG_BREAK_FUNCTION_OPLINE) {
+ type = "function";
+ } else if (brake->type == PHPDBG_BREAK_FILE_OPLINE) {
+ type = "file";
+ }
+
+ phpdbg_writeln("opline", "id=\"%d\" num=\"%#lx\" type=\"%s\" disabled=\"%s\"", "#%d\t\t%#lx\t\t(%s breakpoint)%s",
+ brake->id, brake->opline, type,
+ ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : "");
+ } break;
default:
- phpdbg_writeln("opline", "id=\"%d\" num=\"%#lx\" disabled=\"%s\"", "#%d\t\t%#lx%s", brake->id, brake->opline, ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
+ phpdbg_writeln("opline", "id=\"%d\" num=\"%#lx\" disabled=\"%s\"", "#%d\t\t%#lx%s",
+ brake->id, brake->opline,
+ ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : "");
break;
}
- }
+ } ZEND_HASH_FOREACH_END();
} break;
case PHPDBG_BREAK_METHOD_OPLINE: if ((PHPDBG_G(flags) & PHPDBG_HAS_METHOD_OPLINE_BP)) {
- HashPosition position[3];
HashTable *class_table, *method_table;
- char *class_name = NULL, *method_name = NULL;
- zend_uint class_len = 0, method_len = 0;
- zend_ulong class_idx = 0L, method_idx = 0L;
phpdbg_out(SEPARATE "\n");
phpdbg_out("Method opline Breakpoints:\n");
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], &position[0]);
- zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], (void**) &class_table, &position[0]) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], &position[0])) {
-
- if (zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE],
- &class_name, &class_len, &class_idx, 0, &position[0]) == HASH_KEY_IS_STRING) {
-
- for (zend_hash_internal_pointer_reset_ex(class_table, &position[1]);
- zend_hash_get_current_data_ex(class_table, (void**) &method_table, &position[1]) == SUCCESS;
- zend_hash_move_forward_ex(class_table, &position[1])) {
-
- if (zend_hash_get_current_key_ex(class_table,
- &method_name, &method_len, &method_idx, 0, &position[0]) == HASH_KEY_IS_STRING) {
-
- phpdbg_breakopline_t *brake;
-
- for (zend_hash_internal_pointer_reset_ex(method_table, &position[2]);
- zend_hash_get_current_data_ex(method_table, (void**)&brake, &position[2]) == SUCCESS;
- zend_hash_move_forward_ex(method_table, &position[2])) {
- phpdbg_writeln("methodopline", "id=\"%d\" name=\"%s::%s\" num=\"%ld\" disabled=\"%s\"", "#%d\t\t%s::%s opline %ld%s",
- brake->id, brake->class_name, brake->func_name, brake->opline_num,
- ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
- }
- }
- }
- }
+ ZEND_HASH_FOREACH_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], class_table) {
+ ZEND_HASH_FOREACH_PTR(class_table, method_table) {
+ phpdbg_breakopline_t *brake;
- }
+ ZEND_HASH_FOREACH_PTR(method_table, brake) {
+ phpdbg_writeln("methodopline", "id=\"%d\" name=\"%s::%s\" num=\"%ld\" disabled=\"%s\"", "#%d\t\t%s::%s opline %ld%s",
+ brake->id, brake->class_name, brake->func_name, brake->opline_num,
+ ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : "");
+ } ZEND_HASH_FOREACH_END();
+ } ZEND_HASH_FOREACH_END();
+ } ZEND_HASH_FOREACH_END();
} break;
case PHPDBG_BREAK_FUNCTION_OPLINE: if ((PHPDBG_G(flags) & PHPDBG_HAS_FUNCTION_OPLINE_BP)) {
- HashPosition position[2];
HashTable *function_table;
- char *function_name = NULL;
- zend_uint function_len = 0;
- zend_ulong function_idx = 0L;
phpdbg_out(SEPARATE "\n");
phpdbg_out("Function opline Breakpoints:\n");
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], &position[0]);
- zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], (void**) &function_table, &position[0]) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], &position[0])) {
-
- if (zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE],
- &function_name, &function_len, &function_idx, 0, &position[0]) == HASH_KEY_IS_STRING) {
-
- phpdbg_breakopline_t *brake;
-
- for (zend_hash_internal_pointer_reset_ex(function_table, &position[1]);
- zend_hash_get_current_data_ex(function_table, (void**)&brake, &position[1]) == SUCCESS;
- zend_hash_move_forward_ex(function_table, &position[1])) {
- phpdbg_writeln("functionopline", "id=\"%d\" name=\"%s\" num=\"%ld\" disabled=\"%s\"", "#%d\t\t%s opline %ld%s",
- brake->id, brake->func_name, brake->opline_num,
- ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
- }
- }
-
- }
+ ZEND_HASH_FOREACH_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], function_table) {
+ phpdbg_breakopline_t *brake;
+
+ ZEND_HASH_FOREACH_PTR(function_table, brake) {
+ phpdbg_writeln("functionopline", "id=\"%d\" name=\"%s\" num=\"%ld\" disabled=\"%s\"", "#%d\t\t%s opline %ld%s",
+ brake->id, brake->func_name, brake->opline_num,
+ ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : "");
+ } ZEND_HASH_FOREACH_END();
+ } ZEND_HASH_FOREACH_END();
} break;
case PHPDBG_BREAK_FILE_OPLINE: if ((PHPDBG_G(flags) & PHPDBG_HAS_FILE_OPLINE_BP)) {
- HashPosition position[2];
HashTable *file_table;
- char *file_name = NULL;
- zend_uint file_len = 0;
- zend_ulong file_idx = 0L;
phpdbg_out(SEPARATE "\n");
phpdbg_out("File opline Breakpoints:\n");
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], &position[0]);
- zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], (void**) &file_table, &position[0]) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], &position[0])) {
-
- if (zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE],
- &file_name, &file_len, &file_idx, 0, &position[0]) == HASH_KEY_IS_STRING) {
-
- phpdbg_breakopline_t *brake;
-
- for (zend_hash_internal_pointer_reset_ex(file_table, &position[1]);
- zend_hash_get_current_data_ex(file_table, (void**)&brake, &position[1]) == SUCCESS;
- zend_hash_move_forward_ex(file_table, &position[1])) {
- phpdbg_writeln("fileopline", "id=\"%d\" name=\"%s\" num=\"%ld\" disabled=\"%s\"", "#%d\t\t%s opline %ld%s",
- brake->id, brake->class_name, brake->opline_num,
- ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
- }
- }
- }
+ ZEND_HASH_FOREACH_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], file_table) {
+ phpdbg_breakopline_t *brake;
+
+ ZEND_HASH_FOREACH_PTR(file_table, brake) {
+ phpdbg_writeln("fileopline", "id=\"%d\" name=\"%s\" num=\"%ld\" disabled=\"%s\"", "#%d\t\t%s opline %ld%s",
+ brake->id, brake->class_name, brake->opline_num,
+ ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : "");
+ } ZEND_HASH_FOREACH_END();
+ } ZEND_HASH_FOREACH_END();
} break;
case PHPDBG_BREAK_COND: if ((PHPDBG_G(flags) & PHPDBG_HAS_COND_BP)) {
- HashPosition position;
phpdbg_breakcond_t *brake;
phpdbg_out(SEPARATE "\n");
phpdbg_out("Conditional Breakpoints:\n");
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position);
- zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], (void**) &brake, &position) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position)) {
+ ZEND_HASH_FOREACH_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], brake) {
if (brake->paramed) {
switch (brake->param.type) {
case STR_PARAM:
phpdbg_writeln("evalfunction", "id=\"%d\" name=\"%s\" eval=\"%s\" disabled=\"%s\"", "#%d\t\tat %s if %s%s",
- brake->id,
- brake->param.str,
- brake->code,
- ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
+ brake->id, brake->param.str, brake->code,
+ ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : "");
break;
case NUMERIC_FUNCTION_PARAM:
phpdbg_writeln("evalfunctionopline", "id=\"%d\" name=\"%s\" num=\"%ld\" eval=\"%s\" disabled=\"%s\"", "#%d\t\tat %s#%ld if %s%s",
- brake->id,
- brake->param.str,
- brake->param.num,
- brake->code,
- ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
+ brake->id, brake->param.str, brake->param.num, brake->code,
+ ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : "");
break;
case METHOD_PARAM:
phpdbg_writeln("evalmethod", "id=\"%d\" name=\"%s::%s\" eval=\"%s\" disabled=\"%s\"", "#%d\t\tat %s::%s if %s%s",
- brake->id,
- brake->param.method.class,
- brake->param.method.name,
- brake->code,
+ brake->id, brake->param.method.class, brake->param.method.name, brake->code,
((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
break;
case NUMERIC_METHOD_PARAM:
phpdbg_writeln("evalmethodopline", "id=\"%d\" name=\"%s::%s\" num=\"%d\" eval=\"%s\" disabled=\"%s\"", "#%d\t\tat %s::%s#%ld if %s%s",
- brake->id,
- brake->param.method.class,
- brake->param.method.name,
- brake->param.num,
- brake->code,
- ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
+ brake->id, brake->param.method.class, brake->param.method.name, brake->param.num, brake->code,
+ ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : "");
break;
case FILE_PARAM:
phpdbg_writeln("evalfile", "id=\"%d\" name=\"%s\" line=\"%d\" eval=\"%s\" disabled=\"%s\"", "#%d\t\tat %s:%lu if %s%s",
- brake->id,
- brake->param.file.name,
- brake->param.file.line,
- brake->code,
- ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
+ brake->id, brake->param.file.name, brake->param.file.line, brake->code,
+ ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : "");
break;
case ADDR_PARAM:
phpdbg_writeln("evalopline", "id=\"%d\" opline=\"%#lx\" eval=\"%s\" disabled=\"%s\"", "#%d\t\tat #%lx if %s%s",
- brake->id,
- brake->param.addr,
- brake->code,
- ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
+ brake->id, brake->param.addr, brake->code,
+ ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : "");
break;
default:
@@ -1598,24 +1427,21 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */
} else {
phpdbg_writeln("eval", "id=\"%d\" eval=\"%s\" disabled=\"%s\"", "#%d\t\tif %s%s",
brake->id, brake->code,
- ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
+ ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : "");
}
- }
+ } ZEND_HASH_FOREACH_END();
} break;
case PHPDBG_BREAK_OPCODE: if (PHPDBG_G(flags) & PHPDBG_HAS_OPCODE_BP) {
- HashPosition position;
phpdbg_breakop_t *brake;
phpdbg_out(SEPARATE "\n");
phpdbg_out("Opcode Breakpoints:\n");
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], &position);
- zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], (void**) &brake, &position) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], &position)) {
+ ZEND_HASH_FOREACH_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], brake) {
phpdbg_writeln("opcode", "id=\"%d\" name=\"%s\" disabled=\"%s\"", "#%d\t\t%s%s",
brake->id, brake->name,
- ((phpdbg_breakbase_t*)brake)->disabled ? " [disabled]" : "");
- }
+ ((phpdbg_breakbase_t *) brake)->disabled ? " [disabled]" : "");
+ } ZEND_HASH_FOREACH_END();
} break;
}
diff --git a/sapi/phpdbg/phpdbg_bp.h b/sapi/phpdbg/phpdbg_bp.h
index a6227cba6c..4090d90f91 100644
--- a/sapi/phpdbg/phpdbg_bp.h
+++ b/sapi/phpdbg/phpdbg_bp.h
@@ -151,7 +151,7 @@ PHPDBG_API void phpdbg_disable_breakpoints(TSRMLS_D); /* }}} */
/* {{{ Breakbase API */
PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase(zend_ulong id TSRMLS_DC);
-PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable ***table, HashPosition *position TSRMLS_DC); /* }}} */
+PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable **table, zend_ulong *numkey, zend_string **strkey TSRMLS_DC); /* }}} */
/* {{{ Breakpoint Exportation API */
PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC); /* }}} */
diff --git a/sapi/phpdbg/phpdbg_btree.c b/sapi/phpdbg/phpdbg_btree.c
index 491445399b..918bc0d68f 100644
--- a/sapi/phpdbg/phpdbg_btree.c
+++ b/sapi/phpdbg/phpdbg_btree.c
@@ -219,3 +219,18 @@ check_branch_existence:
return SUCCESS;
}
+
+void phpdbg_btree_branch_dump(phpdbg_btree_branch *branch, zend_ulong depth) {
+ if (branch) {
+ if (depth--) {
+ phpdbg_btree_branch_dump(branch->branches[0], depth);
+ phpdbg_btree_branch_dump(branch->branches[1], depth);
+ } else {
+ fprintf(stderr, "%p: %p\n", (void *) branch->result.idx, branch->result.ptr);
+ }
+ }
+}
+
+void phpdbg_btree_dump(phpdbg_btree *tree) {
+ phpdbg_btree_branch_dump(tree->branch, tree->depth);
+}
diff --git a/sapi/phpdbg/phpdbg_btree.h b/sapi/phpdbg/phpdbg_btree.h
index af2a6ac314..27230572f7 100644
--- a/sapi/phpdbg/phpdbg_btree.h
+++ b/sapi/phpdbg/phpdbg_btree.h
@@ -62,4 +62,9 @@ int phpdbg_btree_insert_or_update(phpdbg_btree *tree, zend_ulong idx, void *ptr,
#define phpdbg_btree_update(tree, idx, ptr) phpdbg_btree_insert_or_update(tree, idx, ptr, PHPDBG_BTREE_UPDATE)
#define phpdbg_btree_overwrite(tree, idx, ptr) phpdbg_btree_insert_or_update(tree, idx, ptr, PHPDBG_BTREE_OWERWRITE)
+
+/* debugging functions */
+void phpdbg_btree_branch_dump(phpdbg_btree_branch *branch, zend_ulong depth);
+void phpdbg_btree_dump(phpdbg_btree *tree);
+
#endif
diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c
index 30ea48cfbe..729babefca 100644
--- a/sapi/phpdbg/phpdbg_cmd.c
+++ b/sapi/phpdbg/phpdbg_cmd.c
@@ -168,59 +168,39 @@ PHPDBG_API char* phpdbg_param_tostring(const phpdbg_param_t *param, char **point
{
switch (param->type) {
case STR_PARAM:
- asprintf(pointer,
- "%s", param->str);
+ asprintf(pointer, "%s", param->str);
break;
case ADDR_PARAM:
- asprintf(pointer,
- "%#lx", param->addr);
+ asprintf(pointer, "%#llx", param->addr);
break;
case NUMERIC_PARAM:
- asprintf(pointer,
- "%li",
- param->num);
+ asprintf(pointer, "%li", param->num);
break;
case METHOD_PARAM:
- asprintf(pointer,
- "%s::%s",
- param->method.class,
- param->method.name);
+ asprintf(pointer, "%s::%s", param->method.class, param->method.name);
break;
case FILE_PARAM:
if (param->num) {
- asprintf(pointer,
- "%s:%lu#%lu",
- param->file.name,
- param->file.line,
- param->num);
+ asprintf(pointer, "%s:%lu#%lu", param->file.name, param->file.line, param->num);
} else {
- asprintf(pointer,
- "%s:%lu",
- param->file.name,
- param->file.line);
+ asprintf(pointer, "%s:%lu", param->file.name, param->file.line);
}
break;
case NUMERIC_FUNCTION_PARAM:
- asprintf(pointer,
- "%s#%lu", param->str, param->num);
+ asprintf(pointer, "%s#%lu", param->str, param->num);
break;
case NUMERIC_METHOD_PARAM:
- asprintf(pointer,
- "%s::%s#%lu",
- param->method.class,
- param->method.name,
- param->num);
+ asprintf(pointer, "%s::%s#%lu", param->method.class, param->method.name, param->num);
break;
default:
- asprintf(pointer,
- "%s", "unknown");
+ *pointer = strdup("unknown");
}
return *pointer;
@@ -422,7 +402,7 @@ PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg)
break;
case ADDR_PARAM:
- fprintf(stderr, "%s ADDR_PARAM(%lu)\n", msg, param->addr);
+ fprintf(stderr, "%s ADDR_PARAM(%llu)\n", msg, param->addr);
break;
case NUMERIC_FILE_PARAM:
@@ -692,7 +672,7 @@ PHPDBG_API const phpdbg_command_t *phpdbg_stack_resolve(const phpdbg_command_t *
default: {
char *list = NULL;
- zend_uint it = 0;
+ uint32_t it = 0;
size_t pos = 0;
while (it < matches) {
diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c
index df304e3541..4429a7fb73 100644
--- a/sapi/phpdbg/phpdbg_frame.c
+++ b/sapi/phpdbg/phpdbg_frame.c
@@ -37,13 +37,7 @@ void phpdbg_restore_frame(TSRMLS_D) /* {{{ */
/* move things back */
EG(current_execute_data) = PHPDBG_FRAME(execute_data);
- EG(opline_ptr) = &PHPDBG_EX(opline);
- EG(active_op_array) = PHPDBG_EX(op_array);
- EG(return_value_ptr_ptr) = PHPDBG_EX(original_return_value);
- EG(active_symbol_table) = PHPDBG_EX(symbol_table);
- EG(This) = PHPDBG_EX(current_this);
- EG(scope) = PHPDBG_EX(current_scope);
- EG(called_scope) = PHPDBG_EX(current_called_scope);
+ EG(scope) = PHPDBG_EX(scope);
} /* }}} */
void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */
@@ -85,89 +79,72 @@ void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */
PHPDBG_FRAME(execute_data) = EG(current_execute_data);
EG(current_execute_data) = execute_data;
- EG(opline_ptr) = &PHPDBG_EX(opline);
- EG(active_op_array) = PHPDBG_EX(op_array);
- PHPDBG_FRAME(execute_data)->original_return_value = EG(return_value_ptr_ptr);
- EG(return_value_ptr_ptr) = PHPDBG_EX(original_return_value);
- EG(active_symbol_table) = PHPDBG_EX(symbol_table);
- EG(This) = PHPDBG_EX(current_this);
- EG(scope) = PHPDBG_EX(current_scope);
- EG(called_scope) = PHPDBG_EX(current_called_scope);
+ EG(scope) = PHPDBG_EX(scope);
}
phpdbg_notice("frame", "id=\"%d\"", "Switched to frame #%d", frame);
- phpdbg_list_file(
- zend_get_executed_filename(TSRMLS_C),
- 3,
- zend_get_executed_lineno(TSRMLS_C)-1,
- zend_get_executed_lineno(TSRMLS_C)
- TSRMLS_CC
- );
+
+ {
+ const char *file_chr = zend_get_executed_filename(TSRMLS_C);
+ zend_string *file = zend_string_init(file_chr, strlen(file_chr), 0);
+ phpdbg_list_file(file, 3, zend_get_executed_lineno(TSRMLS_C) - 1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC);
+ efree(file);
+ }
} /* }}} */
-static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */
+static void phpdbg_dump_prototype(zval *tmp TSRMLS_DC) /* {{{ */
{
- zval **funcname, **class, **type, **args, **argstmp;
- char is_class;
- int has_args = FAILURE;
+ zval *funcname, *class, class_zv, *type, *args, *argstmp;
- zend_hash_find(Z_ARRVAL_PP(tmp), "function", sizeof("function"), (void **) &funcname);
+ funcname = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("function"));
- if ((is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "object", sizeof("object"), (void **) &class)) == FAILURE) {
- is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "class", sizeof("class"), (void **)&class);
+ if ((class = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("object")))) {
+ ZVAL_NEW_STR(&class_zv, Z_OBJCE_P(class)->name);
+ class = &class_zv;
} else {
- zend_get_object_classname(*class, (const char **) &Z_STRVAL_PP(class), (zend_uint *) &Z_STRLEN_PP(class) TSRMLS_CC);
+ class = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("class"));
}
- if (is_class == SUCCESS) {
- zend_hash_find(Z_ARRVAL_PP(tmp), "type", sizeof("type"), (void **)&type);
+ if (class) {
+ type = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("type"));
}
- has_args = zend_hash_find(Z_ARRVAL_PP(tmp), "args", sizeof("args"), (void **)&args) == SUCCESS;
+ args = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("args"));
+
+ phpdbg_xml(" symbol=\"%s%s%s\"", class ? Z_STRVAL_P(class) : "", class ? Z_STRVAL_P(type) : "", Z_STRVAL_P(funcname));
- phpdbg_xml(" symbol=\"%s%s%s\"",
- is_class == FAILURE?"":Z_STRVAL_PP(class),
- is_class == FAILURE?"":Z_STRVAL_PP(type),
- Z_STRVAL_PP(funcname)
- );
- if (has_args) {
+ if (args) {
phpdbg_xml(">");
} else {
phpdbg_xml(" />");
}
- phpdbg_out("%s%s%s(",
- is_class == FAILURE?"":Z_STRVAL_PP(class),
- is_class == FAILURE?"":Z_STRVAL_PP(type),
- Z_STRVAL_PP(funcname)
- );
+ phpdbg_out("%s%s%s(", class ? Z_STRVAL_P(class) : "", class ? Z_STRVAL_P(type) : "", Z_STRVAL_P(funcname));
- if (has_args) {
- HashPosition iterator;
+ if (args) {
const zend_function *func = NULL;
const zend_arg_info *arginfo = NULL;
- int j = 0, m;
zend_bool is_variadic = 0;
+ int j = 0, m;
phpdbg_try_access {
/* assuming no autoloader call is necessary, class should have been loaded if it's in backtrace ... */
- if ((func = phpdbg_get_function(Z_STRVAL_PP(funcname), is_class == FAILURE ? NULL : Z_STRVAL_PP(class) TSRMLS_CC))) {
+ if ((func = phpdbg_get_function(Z_STRVAL_P(funcname), class ? Z_STRVAL_P(class) : NULL TSRMLS_CC))) {
arginfo = func->common.arg_info;
}
} phpdbg_end_try_access();
m = func ? func->common.num_args : 0;
- zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(args), &iterator);
- while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(args), (void **) &argstmp, &iterator) == SUCCESS) {
+ ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(args), argstmp) {
if (j) {
phpdbg_out(", ");
}
phpdbg_xml("<arg %r");
if (m && j < m) {
-#if PHP_VERSION_ID >= 50600
- is_variadic = arginfo ? arginfo[j].is_variadic : 0;
-#endif
+ if (!is_variadic) {
+ is_variadic = arginfo ? arginfo[j].is_variadic : 0;
+ }
phpdbg_xml(" variadic=\"%s\" name=\"%s\">", is_variadic ? "variadic" : "", arginfo ? arginfo[j].name : "");
phpdbg_out("%s=%s", arginfo ? arginfo[j].name : "?", is_variadic ? "[": "");
@@ -176,11 +153,11 @@ static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */
}
++j;
- zend_print_flat_zval_r(*argstmp TSRMLS_CC);
- zend_hash_move_forward_ex(Z_ARRVAL_PP(args), &iterator);
+ zend_print_flat_zval_r(argstmp TSRMLS_CC);
phpdbg_xml("</arg>");
- }
+ } ZEND_HASH_FOREACH_END();
+
if (is_variadic) {
phpdbg_out("]");
}
@@ -191,12 +168,11 @@ static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */
void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
{
- zval zbacktrace;
- zval **tmp;
- zval **file, **line;
HashPosition position;
+ zval zbacktrace;
+ zval *tmp;
+ zval *file, *line;
int i = 0, limit = num;
- int user_defined;
if (limit < 0) {
phpdbg_error("backtrace", "type=\"minnum\"", "Invalid backtrace size %d", limit);
@@ -213,22 +189,22 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
phpdbg_xml("<backtrace %r>");
zend_hash_internal_pointer_reset_ex(Z_ARRVAL(zbacktrace), &position);
- zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void **) &tmp, &position);
+ tmp = zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), &position);
while (1) {
- user_defined = zend_hash_find(Z_ARRVAL_PP(tmp), "file", sizeof("file"), (void **) &file);
- zend_hash_find(Z_ARRVAL_PP(tmp), "line", sizeof("line"), (void **) &line);
+ file = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("file"));
+ line = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("line"));
zend_hash_move_forward_ex(Z_ARRVAL(zbacktrace), &position);
- if (zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void **) &tmp, &position) == FAILURE) {
- phpdbg_write("frame", "id=\"%d\" symbol=\"{main}\" file=\"%s\" line=\"%d\"", "frame #%d: {main} at %s:%ld", i, Z_STRVAL_PP(file), Z_LVAL_PP(line));
+ if (!(tmp = zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), &position))) {
+ phpdbg_write("frame", "id=\"%d\" symbol=\"{main}\" file=\"%s\" line=\"%d\"", "frame #%d: {main} at %s:%ld", i, Z_STRVAL_P(file), Z_LVAL_P(line));
break;
}
- if (user_defined == SUCCESS) {
+ if (file) { /* userland */
phpdbg_out("frame #%d: ", i);
- phpdbg_xml("<frame %r id=\"%d\" file=\"%s\" line=\"%d\"", i, Z_STRVAL_PP(file), Z_LVAL_PP(line));
+ phpdbg_xml("<frame %r id=\"%d\" file=\"%s\" line=\"%d\"", i, Z_STRVAL_P(file), Z_LVAL_P(line));
phpdbg_dump_prototype(tmp TSRMLS_CC);
- phpdbg_out(" at %s:%ld\n", Z_STRVAL_PP(file), Z_LVAL_PP(line));
+ phpdbg_out(" at %s:%ld\n", Z_STRVAL_P(file), Z_LVAL_P(line));
i++;
} else {
phpdbg_out(" => ");
diff --git a/sapi/phpdbg/phpdbg_info.c b/sapi/phpdbg/phpdbg_info.c
index 4774fa5a9e..01633e4feb 100644
--- a/sapi/phpdbg/phpdbg_info.c
+++ b/sapi/phpdbg/phpdbg_info.c
@@ -61,21 +61,19 @@ PHPDBG_INFO(break) /* {{{ */
PHPDBG_INFO(files) /* {{{ */
{
- HashPosition pos;
- char *fname;
+ zend_string *fname;
phpdbg_try_access {
phpdbg_notice("includedfilecount", "num=\"%d\"", "Included files: %d", zend_hash_num_elements(&EG(included_files)));
} phpdbg_catch_access {
phpdbg_error("signalsegv", "", "Could not fetch included file count, invalid data source");
+ return SUCCESS;
} phpdbg_end_try_access();
phpdbg_try_access {
- zend_hash_internal_pointer_reset_ex(&EG(included_files), &pos);
- while (zend_hash_get_current_key_ex(&EG(included_files), &fname, NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
+ ZEND_HASH_FOREACH_STR_KEY(&EG(included_files), fname) {
phpdbg_writeln("includedfile", "name=\"%s\"", "File: %s", fname);
- zend_hash_move_forward_ex(&EG(included_files), &pos);
- }
+ } ZEND_HASH_FOREACH_END();
} phpdbg_catch_access {
phpdbg_error("signalsegv", "", "Could not fetch file name, invalid data source, aborting included file listing");
} phpdbg_end_try_access();
@@ -99,7 +97,6 @@ PHPDBG_INFO(error) /* {{{ */
PHPDBG_INFO(constants) /* {{{ */
{
- HashPosition pos;
HashTable consts;
zend_constant *data;
@@ -107,13 +104,11 @@ PHPDBG_INFO(constants) /* {{{ */
if (EG(zend_constants)) {
phpdbg_try_access {
- zend_hash_internal_pointer_reset_ex(EG(zend_constants), &pos);
- while (zend_hash_get_current_data_ex(EG(zend_constants), (void **) &data, &pos) == SUCCESS) {
+ ZEND_HASH_FOREACH_PTR(EG(zend_constants), data) {
if (data->module_number == PHP_USER_CONSTANT) {
- zend_hash_update(&consts, data->name, data->name_len, (void **) &data, sizeof(zend_constant *), NULL);
+ zend_hash_update_ptr(&consts, data->name, data);
}
- zend_hash_move_forward_ex(EG(zend_constants), &pos);
- }
+ } ZEND_HASH_FOREACH_END();
} phpdbg_catch_access {
phpdbg_error("signalsegv", "", "Cannot fetch all the constants, invalid data source");
} phpdbg_end_try_access();
@@ -123,12 +118,9 @@ PHPDBG_INFO(constants) /* {{{ */
if (zend_hash_num_elements(&consts)) {
phpdbg_out("Address Refs Type Constant\n");
- for (zend_hash_internal_pointer_reset_ex(&consts, &pos);
- zend_hash_get_current_data_ex(&consts, (void **) &data, &pos) == SUCCESS;
- zend_hash_move_forward_ex(&consts, &pos)) {
- data = *(zend_constant **) data;
+ ZEND_HASH_FOREACH_PTR(&consts, data) {
-#define VARIABLEINFO(attrs, msg, ...) phpdbg_writeln("constant", "address=\"%p\" refcount=\"%d\" type=\"%s\" name=\"%.*s\" " attrs, "%-18p %-7d %-9s %.*s" msg, &data->value, Z_REFCOUNT(data->value), zend_zval_type_name(&data->value), data->name_len - 1, data->name, ##__VA_ARGS__)
+#define VARIABLEINFO(attrs, msg, ...) phpdbg_writeln("constant", "address=\"%p\" refcount=\"%d\" type=\"%s\" name=\"%.*s\" " attrs, "%-18p %-7d %-9s %.*s" msg, &data->value, Z_REFCOUNT(data->value), zend_zval_type_name(&data->value), data->name->len, data->name->val, ##__VA_ARGS__)
switch (Z_TYPE(data->value)) {
case IS_STRING:
@@ -138,8 +130,11 @@ PHPDBG_INFO(constants) /* {{{ */
VARIABLEINFO("", "");
} phpdbg_end_try_access();
break;
- case IS_BOOL:
- VARIABLEINFO("value=\"%s\"", "\nbool (%s)", Z_LVAL(data->value) ? "true" : "false");
+ case IS_TRUE:
+ VARIABLEINFO("value=\"true\"", "\nbool (true)");
+ break;
+ case IS_FALSE:
+ VARIABLEINFO("value=\"false\"", "\nbool (false)");
break;
case IS_LONG:
VARIABLEINFO("value=\"%ld\"", "\nint (%ld)", Z_LVAL(data->value));
@@ -152,7 +147,7 @@ PHPDBG_INFO(constants) /* {{{ */
#undef VARIABLEINFO
}
- }
+ } ZEND_HASH_FOREACH_END();
}
return SUCCESS;
@@ -161,9 +156,9 @@ PHPDBG_INFO(constants) /* {{{ */
static int phpdbg_arm_auto_global(zend_auto_global *auto_global TSRMLS_DC) {
if (auto_global->armed) {
if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) {
- phpdbg_notice("variableinfo", "unreachable=\"%.*s\"", "Cannot show information about superglobal variable %.*s", auto_global->name_len, auto_global->name);
+ phpdbg_notice("variableinfo", "unreachable=\"%.*s\"", "Cannot show information about superglobal variable %.*s", auto_global->name->len, auto_global->name->val);
} else {
- auto_global->armed = auto_global->auto_global_callback(auto_global->name, auto_global->name_len TSRMLS_CC);
+ auto_global->armed = auto_global->auto_global_callback(auto_global->name TSRMLS_CC);
}
}
@@ -171,45 +166,33 @@ static int phpdbg_arm_auto_global(zend_auto_global *auto_global TSRMLS_DC) {
}
static int phpdbg_print_symbols(zend_bool show_globals TSRMLS_DC) {
- HashTable vars, *symtable;
- HashPosition pos;
- char *var;
- zval **data;
+ HashTable vars;
+ zend_array *symtable;
+ zend_string *var;
+ zval *data;
- if (!EG(active_op_array)) {
+ if (!EG(current_execute_data) || !EG(current_execute_data)->func) {
phpdbg_error("inactive", "type=\"op_array\"", "No active op array!");
return SUCCESS;
}
- if (!EG(active_symbol_table)) {
- zend_rebuild_symbol_table(TSRMLS_C);
-
- if (!EG(active_symbol_table)) {
- phpdbg_error("inactive", "type=\"symbol_table\"", "No active symbol table!");
- return SUCCESS;
- }
- }
-
-
if (show_globals) {
/* that array should only be manipulated during init, so safe for async access during execution */
zend_hash_apply(CG(auto_globals), (apply_func_t) phpdbg_arm_auto_global TSRMLS_CC);
symtable = &EG(symbol_table);
- } else {
- symtable = EG(active_symbol_table);
+ } else if (!(symtable = zend_rebuild_symbol_table(TSRMLS_C))) {
+ phpdbg_error("inactive", "type=\"symbol_table\"", "No active symbol table!");
+ return SUCCESS;
}
zend_hash_init(&vars, 8, NULL, NULL, 0);
phpdbg_try_access {
- zend_hash_internal_pointer_reset_ex(symtable, &pos);
- while (zend_hash_get_current_key_ex(symtable, &var, NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
- zend_hash_get_current_data_ex(symtable, (void **)&data, &pos);
- if (zend_is_auto_global(var, strlen(var) TSRMLS_CC) ^ !show_globals) {
- zend_hash_update(&vars, var, strlen(var)+1, (void**)data, sizeof(zval*), NULL);
+ ZEND_HASH_FOREACH_STR_KEY_VAL(&symtable->ht, var, data) {
+ if (zend_is_auto_global(var TSRMLS_CC) ^ !show_globals) {
+ zend_hash_update(&vars, var, data);
}
- zend_hash_move_forward_ex(symtable, &pos);
- }
+ } ZEND_HASH_FOREACH_END();
} phpdbg_catch_access {
phpdbg_error("signalsegv", "", "Cannot fetch all data from the symbol table, invalid data source");
} phpdbg_end_try_access();
@@ -217,7 +200,7 @@ static int phpdbg_print_symbols(zend_bool show_globals TSRMLS_DC) {
if (show_globals) {
phpdbg_notice("variableinfo", "num=\"%d\"", "Superglobal variables (%d)", zend_hash_num_elements(&vars));
} else {
- zend_op_array *ops = EG(active_op_array);
+ zend_op_array *ops = &EG(current_execute_data)->func->op_array;
if (ops->function_name) {
if (ops->scope) {
@@ -227,7 +210,7 @@ static int phpdbg_print_symbols(zend_bool show_globals TSRMLS_DC) {
}
} else {
if (ops->filename) {
- phpdbg_notice("variableinfo", "file=\"%s\" num=\"%d\"", "Variables in %s (%d)", ops->filename, zend_hash_num_elements(&vars));
+ phpdbg_notice("variableinfo", "file=\"%s\" num=\"%d\"", "Variables in %s (%d)", ops->filename->val, zend_hash_num_elements(&vars));
} else {
phpdbg_notice("variableinfo", "opline=\"%p\" num=\"%d\"", "Variables @ %p (%d)", ops, zend_hash_num_elements(&vars));
}
@@ -236,62 +219,54 @@ static int phpdbg_print_symbols(zend_bool show_globals TSRMLS_DC) {
if (zend_hash_num_elements(&vars)) {
phpdbg_out("Address Refs Type Variable\n");
- for (zend_hash_internal_pointer_reset_ex(&vars, &pos);
- zend_hash_get_current_data_ex(&vars, (void**) &data, &pos) == SUCCESS;
- zend_hash_move_forward_ex(&vars, &pos)) {
- char *var;
- zend_bool invalid_data = 1;
-
- zend_hash_get_current_key_ex(&vars, &var, NULL, NULL, 0, &pos);
-
+ ZEND_HASH_FOREACH_STR_KEY_VAL(&vars, var, data) {
phpdbg_try_access {
- if (!(invalid_data = !*data)) {
-#define VARIABLEINFO(attrs, msg, ...) phpdbg_writeln("variable", "address=\"%p\" refcount=\"%d\" type=\"%s\" refstatus=\"%s\" name=\"%s\" " attrs, "%-18p %-7d %-9s %s$%s" msg, *data, Z_REFCOUNT_PP(data), zend_zval_type_name(*data), Z_ISREF_PP(data) ? "&": "", var, ##__VA_ARGS__)
-
- switch (Z_TYPE_PP(data)) {
- case IS_RESOURCE:
- phpdbg_try_access {
- int type;
- VARIABLEINFO("type=\"%s\"", "\n|-------(typeof)------> (%s)\n", zend_list_find(Z_RESVAL_PP(data), &type) ? zend_rsrc_list_get_rsrc_type(type TSRMLS_CC) : "unknown");
- } phpdbg_catch_access {
- VARIABLEINFO("type=\"unknown\"", "\n|-------(typeof)------> (unknown)\n");
- } phpdbg_end_try_access();
- break;
- case IS_OBJECT:
- phpdbg_try_access {
- VARIABLEINFO("instanceof=\"%s\"", "\n|-----(instanceof)----> (%s)\n", Z_OBJCE_PP(data)->name);
- } phpdbg_catch_access {
- VARIABLEINFO("instanceof=\"%s\"", "\n|-----(instanceof)----> (unknown)\n");
- } phpdbg_end_try_access();
- break;
- case IS_STRING:
- phpdbg_try_access {
- VARIABLEINFO("length=\"%d\" value=\"%.*s\"", "\nstring (%d) \"%.*s%s\"", Z_STRLEN_PP(data), Z_STRLEN_PP(data) < 255 ? Z_STRLEN_PP(data) : 255, Z_STRVAL_PP(data), Z_STRLEN_PP(data) > 255 ? "..." : "");
- } phpdbg_catch_access {
- VARIABLEINFO("", "");
- } phpdbg_end_try_access();
- break;
- case IS_BOOL:
- VARIABLEINFO("value=\"%s\"", "\nbool (%s)", Z_LVAL_PP(data) ? "true" : "false");
- break;
- case IS_LONG:
- VARIABLEINFO("value=\"%ld\"", "\nint (%ld)", Z_LVAL_PP(data));
- break;
- case IS_DOUBLE:
- VARIABLEINFO("value=\"%lf\"", "\ndouble (%lf)", Z_DVAL_PP(data));
- break;
- default:
+#define VARIABLEINFO(attrs, msg, ...) phpdbg_writeln("variable", "address=\"%p\" refcount=\"%d\" type=\"%s\" refstatus=\"%s\" name=\"%.*s\" " attrs, "%-18p %-7d %-9s %s$%.*s" msg, data, Z_REFCOUNT_P(data), zend_zval_type_name(data), Z_ISREF_P(data) ? "&": "", var->len, var->val, ##__VA_ARGS__)
+
+ switch (Z_TYPE_P(data)) {
+ case IS_RESOURCE:
+ phpdbg_try_access {
+ const char *type = zend_rsrc_list_get_rsrc_type(Z_RES_P(data) TSRMLS_CC);
+ VARIABLEINFO("type=\"%s\"", "\n|-------(typeof)------> (%s)\n", type ? type : "unknown");
+ } phpdbg_catch_access {
+ VARIABLEINFO("type=\"unknown\"", "\n|-------(typeof)------> (unknown)\n");
+ } phpdbg_end_try_access();
+ break;
+ case IS_OBJECT:
+ phpdbg_try_access {
+ VARIABLEINFO("instanceof=\"%s\"", "\n|-----(instanceof)----> (%s)\n", Z_OBJCE_P(data)->name);
+ } phpdbg_catch_access {
+ VARIABLEINFO("instanceof=\"%s\"", "\n|-----(instanceof)----> (unknown)\n");
+ } phpdbg_end_try_access();
+ break;
+ case IS_STRING:
+ phpdbg_try_access {
+ VARIABLEINFO("length=\"%d\" value=\"%.*s\"", "\nstring (%d) \"%.*s%s\"", Z_STRLEN_P(data), Z_STRLEN_P(data) < 255 ? Z_STRLEN_P(data) : 255, Z_STRVAL_P(data), Z_STRLEN_P(data) > 255 ? "..." : "");
+ } phpdbg_catch_access {
VARIABLEINFO("", "");
- }
+ } phpdbg_end_try_access();
+ break;
+ case IS_TRUE:
+ VARIABLEINFO("value=\"true\"", "\nbool (true)");
+ break;
+ case IS_FALSE:
+ VARIABLEINFO("value=\"false\"", "\nbool (false)");
+ break;
+ case IS_LONG:
+ VARIABLEINFO("value=\"%ld\"", "\nint (%ld)", Z_LVAL_P(data));
+ break;
+ case IS_DOUBLE:
+ VARIABLEINFO("value=\"%lf\"", "\ndouble (%lf)", Z_DVAL_P(data));
+ break;
+ default:
+ VARIABLEINFO("", "");
}
#undef VARIABLEINFO
+ } phpdbg_catch_access {
+ phpdbg_writeln("variable", "address=\"%p\" name=\"%s\"", "%p\tn/a\tn/a\t$%s", data, var);
} phpdbg_end_try_access();
-
- if (invalid_data) {
- phpdbg_writeln("variable", "name=\"%s\"", "n/a\tn/a\tn/a\t$%s", var);
- }
- }
+ } ZEND_HASH_FOREACH_END();
}
zend_hash_destroy(&vars);
@@ -312,8 +287,9 @@ PHPDBG_INFO(globals) /* {{{ */
PHPDBG_INFO(literal) /* {{{ */
{
/* literals are assumed to not be manipulated during executing of their op_array and as such async safe */
- if ((EG(in_execution) && EG(active_op_array)) || PHPDBG_G(ops)) {
- zend_op_array *ops = EG(active_op_array) ? EG(active_op_array) : PHPDBG_G(ops);
+ zend_bool in_executor = PHPDBG_G(in_execution) && EG(current_execute_data) && EG(current_execute_data)->func;
+ if (in_executor || PHPDBG_G(ops)) {
+ zend_op_array *ops = in_executor ? &EG(current_execute_data)->func->op_array : PHPDBG_G(ops);
int literal = 0, count = ops->last_literal-1;
if (ops->function_name) {
@@ -324,16 +300,16 @@ PHPDBG_INFO(literal) /* {{{ */
}
} else {
if (ops->filename) {
- phpdbg_notice("literalinfo", "file=\"%s\" num=\"%d\"", "Literal Constants in %s (%d)", ops->filename, count);
+ phpdbg_notice("literalinfo", "file=\"%s\" num=\"%d\"", "Literal Constants in %s (%d)", ops->filename->val, count);
} else {
phpdbg_notice("literalinfo", "opline=\"%p\" num=\"%d\"", "Literal Constants @ %p (%d)", ops, count);
}
}
while (literal < ops->last_literal) {
- if (Z_TYPE(ops->literals[literal].constant) != IS_NULL) {
+ if (Z_TYPE(ops->literals[literal]) != IS_NULL) {
phpdbg_write("literal", "id=\"%u\"", "|-------- C%u -------> [", literal);
- zend_print_zval(&ops->literals[literal].constant, 0);
+ zend_print_zval(&ops->literals[literal], 0 TSRMLS_CC);
phpdbg_out("]\n");
}
literal++;
@@ -378,35 +354,27 @@ PHPDBG_INFO(memory) /* {{{ */
return SUCCESS;
} /* }}} */
-static inline void phpdbg_print_class_name(zend_class_entry **ce TSRMLS_DC) /* {{{ */
+static inline void phpdbg_print_class_name(zend_class_entry *ce TSRMLS_DC) /* {{{ */
{
- phpdbg_writeln("class", "type=\"%s\" flags=\"%s\" name=\"%s\" methodcount=\"%d\"", "%s %s %s (%d)",
- ((*ce)->type == ZEND_USER_CLASS) ?
- "User" : "Internal",
- ((*ce)->ce_flags & ZEND_ACC_INTERFACE) ?
- "Interface" :
- ((*ce)->ce_flags & ZEND_ACC_ABSTRACT) ?
- "Abstract Class" :
- "Class",
- (*ce)->name, zend_hash_num_elements(&(*ce)->function_table));
+ const char *visibility = ce->type == ZEND_USER_CLASS ? "User" : "Internal";
+ const char *type = (ce->ce_flags & ZEND_ACC_INTERFACE) ? "Interface" : (ce->ce_flags & ZEND_ACC_ABSTRACT) ? "Abstract Class" : "Class";
+
+ phpdbg_writeln("class", "type=\"%s\" flags=\"%s\" name=\"%.*s\" methodcount=\"%d\"", "%s %s %.*s (%d)", visibility, type, ce->name->len, ce->name->val, zend_hash_num_elements(&ce->function_table));
} /* }}} */
PHPDBG_INFO(classes) /* {{{ */
{
- HashPosition position;
- zend_class_entry **ce;
+ zend_class_entry *ce;
HashTable classes;
zend_hash_init(&classes, 8, NULL, NULL, 0);
phpdbg_try_access {
- for (zend_hash_internal_pointer_reset_ex(EG(class_table), &position);
- zend_hash_get_current_data_ex(EG(class_table), (void**)&ce, &position) == SUCCESS;
- zend_hash_move_forward_ex(EG(class_table), &position)) {
- if ((*ce)->type == ZEND_USER_CLASS) {
- zend_hash_next_index_insert(&classes, ce, sizeof(ce), NULL);
+ ZEND_HASH_FOREACH_PTR(EG(class_table), ce) {
+ if (ce->type == ZEND_USER_CLASS) {
+ zend_hash_next_index_insert_ptr(&classes, ce);
}
- }
+ } ZEND_HASH_FOREACH_END();
} phpdbg_catch_access {
phpdbg_notice("signalsegv", "", "Not all classes could be fetched, possibly invalid data source");
} phpdbg_end_try_access();
@@ -414,30 +382,25 @@ PHPDBG_INFO(classes) /* {{{ */
phpdbg_notice("classinfo", "num=\"%d\"", "User Classes (%d)", zend_hash_num_elements(&classes));
/* once added, assume that classes are stable... until shutdown. */
- for (zend_hash_internal_pointer_reset_ex(&classes, &position);
- zend_hash_get_current_data_ex(&classes, (void**)&ce, &position) == SUCCESS;
- zend_hash_move_forward_ex(&classes, &position)) {
-
+ ZEND_HASH_FOREACH_PTR(&classes, ce) {
phpdbg_print_class_name(ce TSRMLS_CC);
- if ((*ce)->parent) {
- zend_class_entry *pce;
-
+ if (ce->parent) {
phpdbg_xml("<parents %r>");
- pce = (*ce)->parent;
+ zend_class_entry *pce = ce->parent;
do {
phpdbg_out("|-------- ");
- phpdbg_print_class_name(&pce TSRMLS_CC);
+ phpdbg_print_class_name(pce TSRMLS_CC);
} while ((pce = pce->parent));
phpdbg_xml("</parents>");
}
- if ((*ce)->info.user.filename) {
- phpdbg_writeln("classsource", "file=\"%s\" line=\"%u\"", "|---- in %s on line %u", (*ce)->info.user.filename, (*ce)->info.user.line_start);
+ if (ce->info.user.filename) {
+ phpdbg_writeln("classsource", "file=\"%s\" line=\"%u\"", "|---- in %s on line %u", ce->info.user.filename->val, ce->info.user.line_start);
} else {
phpdbg_writeln("classsource", "", "|---- no source code");
}
- }
+ } ZEND_HASH_FOREACH_END();
zend_hash_destroy(&classes);
@@ -446,41 +409,34 @@ PHPDBG_INFO(classes) /* {{{ */
PHPDBG_INFO(funcs) /* {{{ */
{
- HashPosition position;
- zend_function *zf, **pzf;
+ zend_function *zf;
HashTable functions;
zend_hash_init(&functions, 8, NULL, NULL, 0);
phpdbg_try_access {
- for (zend_hash_internal_pointer_reset_ex(EG(function_table), &position);
- zend_hash_get_current_data_ex(EG(function_table), (void**)&zf, &position) == SUCCESS;
- zend_hash_move_forward_ex(EG(function_table), &position)) {
+ ZEND_HASH_FOREACH_PTR(EG(function_table), zf) {
if (zf->type == ZEND_USER_FUNCTION) {
- zend_hash_next_index_insert(&functions, (void**) &zf, sizeof(zend_function), NULL);
+ zend_hash_next_index_insert_ptr(&functions, zf);
}
- }
+ } ZEND_HASH_FOREACH_END();
} phpdbg_catch_access {
phpdbg_notice("signalsegv", "", "Not all functions could be fetched, possibly invalid data source");
} phpdbg_end_try_access();
phpdbg_notice("functioninfo", "num=\"%d\"", "User Functions (%d)", zend_hash_num_elements(&functions));
- for (zend_hash_internal_pointer_reset_ex(&functions, &position);
- zend_hash_get_current_data_ex(&functions, (void**)&pzf, &position) == SUCCESS;
- zend_hash_move_forward_ex(&functions, &position)) {
- zend_op_array *op_array = &((*pzf)->op_array);
+ ZEND_HASH_FOREACH_PTR(&functions, zf) {
+ zend_op_array *op_array = &zf->op_array;
- phpdbg_write("function", "name=\"%s\"", "|-------- %s", op_array->function_name ? op_array->function_name : "{main}");
+ phpdbg_write("function", "name=\"%s\"", "|-------- %s", op_array->function_name ? op_array->function_name->val : "{main}");
if (op_array->filename) {
- phpdbg_writeln("functionsource", "file=\"%s\" line=\"%d\"", " in %s on line %d",
- op_array->filename,
- op_array->line_start);
+ phpdbg_writeln("functionsource", "file=\"%s\" line=\"%d\"", " in %s on line %d", op_array->filename->val, op_array->line_start);
} else {
phpdbg_writeln("functionsource", "", " (no source code)");
}
- }
+ } ZEND_HASH_FOREACH_END();
zend_hash_destroy(&functions);
diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c
index 80b5d2b189..de03a3651e 100644
--- a/sapi/phpdbg/phpdbg_list.c
+++ b/sapi/phpdbg/phpdbg_list.c
@@ -53,16 +53,18 @@ PHPDBG_LIST(lines) /* {{{ */
}
switch (param->type) {
- case NUMERIC_PARAM:
- phpdbg_list_file(phpdbg_current_file(TSRMLS_C),
- (param->num < 0 ? 1 - param->num : param->num),
- (param->num < 0 ? param->num : 0) + zend_get_executed_lineno(TSRMLS_C),
- 0 TSRMLS_CC);
- break;
-
- case FILE_PARAM:
- phpdbg_list_file(param->file.name, param->file.line, 0, 0 TSRMLS_CC);
- break;
+ case NUMERIC_PARAM: {
+ const char *char_file = phpdbg_current_file(TSRMLS_C);
+ zend_string *file = zend_string_init(char_file, strlen(char_file), 0);
+ phpdbg_list_file(file, param->num < 0 ? 1 - param->num : param->num, (param->num < 0 ? param->num : 0) + zend_get_executed_lineno(TSRMLS_C), 0 TSRMLS_CC);
+ efree(file);
+ } break;
+
+ case FILE_PARAM: {
+ zend_string *file = zend_string_init(param->file.name, strlen(param->file.name), 0);
+ phpdbg_list_file(file, param->file.line, 0, 0 TSRMLS_CC);
+ efree(file);
+ } break;
phpdbg_default_switch_case();
}
@@ -79,13 +81,13 @@ PHPDBG_LIST(func) /* {{{ */
PHPDBG_LIST(method) /* {{{ */
{
- zend_class_entry **ce;
+ zend_class_entry *ce;
if (phpdbg_safe_class_lookup(param->method.class, strlen(param->method.class), &ce TSRMLS_CC) == SUCCESS) {
zend_function *function;
char *lcname = zend_str_tolower_dup(param->method.name, strlen(param->method.name));
- if (zend_hash_find(&(*ce)->function_table, lcname, strlen(lcname)+1, (void**) &function) == SUCCESS) {
+ if ((function = zend_hash_str_find_ptr(&ce->function_table, lcname, strlen(lcname)))) {
phpdbg_list_function(function TSRMLS_CC);
} else {
phpdbg_error("list", "type=\"notfound\" method=\"%s::%s\"", "Could not find %s::%s", param->method.class, param->method.name);
@@ -101,21 +103,17 @@ PHPDBG_LIST(method) /* {{{ */
PHPDBG_LIST(class) /* {{{ */
{
- zend_class_entry **ce;
+ zend_class_entry *ce;
if (phpdbg_safe_class_lookup(param->str, param->len, &ce TSRMLS_CC) == SUCCESS) {
- if ((*ce)->type == ZEND_USER_CLASS) {
- if ((*ce)->info.user.filename) {
- phpdbg_list_file(
- (*ce)->info.user.filename,
- (*ce)->info.user.line_end - (*ce)->info.user.line_start + 1,
- (*ce)->info.user.line_start, 0 TSRMLS_CC
- );
+ if (ce->type == ZEND_USER_CLASS) {
+ if (ce->info.user.filename) {
+ phpdbg_list_file(ce->info.user.filename, ce->info.user.line_end - ce->info.user.line_start + 1, ce->info.user.line_start, 0 TSRMLS_CC);
} else {
- phpdbg_error("list", "type=\"nosource\" class=\"%s\"", "The source of the requested class (%s) cannot be found", (*ce)->name);
+ phpdbg_error("list", "type=\"nosource\" class=\"%s\"", "The source of the requested class (%s) cannot be found", ce->name);
}
} else {
- phpdbg_error("list", "type=\"internalclass\" class=\"%s\"", "The class requested (%s) is not user defined", (*ce)->name);
+ phpdbg_error("list", "type=\"internalclass\" class=\"%s\"", "The class requested (%s) is not user defined", ce->name);
}
} else {
phpdbg_error("list", "type=\"notfound\" class=\"%s\"", "The requested class (%s) could not be found", param->str);
@@ -124,12 +122,12 @@ PHPDBG_LIST(class) /* {{{ */
return SUCCESS;
} /* }}} */
-void phpdbg_list_file(const char *filename, uint count, int offset, uint highlight TSRMLS_DC) /* {{{ */
+void phpdbg_list_file(zend_string *filename, uint count, int offset, uint highlight TSRMLS_DC) /* {{{ */
{
uint line, lastline;
- phpdbg_file_source **data;
+ phpdbg_file_source *data;
- if (zend_hash_find(&PHPDBG_G(file_sources), filename, strlen(filename), (void **) &data) == FAILURE) {
+ if (!(data = zend_hash_find_ptr(&PHPDBG_G(file_sources), filename))) {
phpdbg_error("list", "type=\"unknownfile\"", "Could not find information about included file...");
return;
}
@@ -141,16 +139,16 @@ void phpdbg_list_file(const char *filename, uint count, int offset, uint highlig
lastline = offset + count;
- if (lastline > (*data)->lines) {
- lastline = (*data)->lines;
+ if (lastline > data->lines) {
+ lastline = data->lines;
}
phpdbg_xml("<list %r file=\"%s\">", filename);
for (line = offset; line < lastline;) {
- uint linestart = (*data)->line[line++];
- uint linelen = (*data)->line[line] - linestart;
- char *buffer = (*data)->buf + linestart;
+ uint linestart = data->line[line++];
+ uint linelen = data->line[line] - linestart;
+ char *buffer = data->buf + linestart;
if (!highlight) {
phpdbg_write("line", "line=\"%u\" code=\"%.*s\"", " %05u: %.*s", line, linelen, buffer);
@@ -179,7 +177,7 @@ void phpdbg_list_function(const zend_function *fbc TSRMLS_DC) /* {{{ */
return;
}
- ops = (zend_op_array *)fbc;
+ ops = (zend_op_array *) fbc;
phpdbg_list_file(ops->filename, ops->line_end - ops->line_start + 1, ops->line_start, 0 TSRMLS_CC);
} /* }}} */
@@ -213,7 +211,7 @@ void phpdbg_list_function_byname(const char *str, size_t len TSRMLS_DC) /* {{{ *
func_name = zend_str_tolower_dup(func_name, func_name_len);
phpdbg_try_access {
- if (zend_hash_find(func_table, func_name, func_name_len+1, (void**)&fbc) == SUCCESS) {
+ if ((fbc = zend_hash_str_find_ptr(func_table, func_name, func_name_len))) {
phpdbg_list_function(fbc TSRMLS_CC);
} else {
phpdbg_error("list", "type=\"nofunction\" function=\"%s\"", "Function %s not found", func_name);
@@ -227,7 +225,7 @@ void phpdbg_list_function_byname(const char *str, size_t len TSRMLS_DC) /* {{{ *
zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type TSRMLS_DC) {
phpdbg_file_source data, *dataptr;
- zend_file_handle fake = {0};
+ zend_file_handle fake = {{0}};
zend_op_array *ret;
char *filename = (char *)(file->opened_path ? file->opened_path : file->filename);
uint line;
@@ -258,7 +256,6 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type TSRMLS_DC) {
fake.opened_path = file->opened_path;
*(dataptr = emalloc(sizeof(phpdbg_file_source) + sizeof(uint) * data.len)) = data;
- zend_hash_add(&PHPDBG_G(file_sources), filename, strlen(filename), &dataptr, sizeof(phpdbg_file_source *), NULL);
for (line = 0, bufptr = data.buf - 1, endptr = data.buf + data.len; ++bufptr < endptr;) {
if (*bufptr == '\n') {
@@ -269,6 +266,8 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type TSRMLS_DC) {
dataptr->line[line] = endptr - data.buf;
dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line);
+ zend_hash_str_add_ptr(&PHPDBG_G(file_sources), filename, strlen(filename), dataptr);
+
ret = PHPDBG_G(compile_file)(&fake, type TSRMLS_CC);
fake.opened_path = NULL;
diff --git a/sapi/phpdbg/phpdbg_list.h b/sapi/phpdbg/phpdbg_list.h
index c88328bfea..43a2d474d5 100644
--- a/sapi/phpdbg/phpdbg_list.h
+++ b/sapi/phpdbg/phpdbg_list.h
@@ -33,8 +33,8 @@ PHPDBG_LIST(method);
PHPDBG_LIST(func);
void phpdbg_list_function_byname(const char *, size_t TSRMLS_DC);
-void phpdbg_list_function(const zend_function* TSRMLS_DC);
-void phpdbg_list_file(const char*, uint, int, uint TSRMLS_DC);
+void phpdbg_list_function(const zend_function * TSRMLS_DC);
+void phpdbg_list_file(zend_string *, uint, int, uint TSRMLS_DC);
extern const phpdbg_command_t phpdbg_list_commands[];
diff --git a/sapi/phpdbg/phpdbg_opcode.c b/sapi/phpdbg/phpdbg_opcode.c
index 331718accc..99f43344a4 100644
--- a/sapi/phpdbg/phpdbg_opcode.c
+++ b/sapi/phpdbg/phpdbg_opcode.c
@@ -26,7 +26,7 @@
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
-static inline zend_uint phpdbg_decode_literal(zend_op_array *ops, zend_literal *literal TSRMLS_DC) /* {{{ */
+static inline uint32_t phpdbg_decode_literal(zend_op_array *ops, zval *literal TSRMLS_DC) /* {{{ */
{
int iter = 0;
@@ -40,32 +40,31 @@ static inline zend_uint phpdbg_decode_literal(zend_op_array *ops, zend_literal *
return 0;
} /* }}} */
-static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, zend_uint type, HashTable *vars TSRMLS_DC) /* {{{ */
+static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, uint32_t type, HashTable *vars TSRMLS_DC) /* {{{ */
{
char *decode = NULL;
switch (type &~ EXT_TYPE_UNUSED) {
case IS_CV:
- asprintf(&decode, "$%s", ops->vars[op->var].name);
+ asprintf(&decode, "$%s", ops->vars[EX_VAR_TO_NUM(op->var)]->val);
break;
case IS_VAR:
case IS_TMP_VAR: {
zend_ulong id = 0, *pid = NULL;
if (vars != NULL) {
- if (zend_hash_index_find(vars, (zend_ulong) ops->vars - op->var, (void**) &pid) != SUCCESS) {
+ if ((pid = zend_hash_index_find_ptr(vars, (zend_ulong) ops->vars - op->var))) {
+ id = *pid;
+ } else {
id = zend_hash_num_elements(vars);
- zend_hash_index_update(
- vars, (zend_ulong) ops->vars - op->var,
- (void**) &id,
- sizeof(zend_ulong), NULL);
- } else id = *pid;
+ zend_hash_index_update_mem(vars, (zend_ulong) ops->vars - op->var, &id, sizeof(zend_ulong));
+ }
}
- asprintf(&decode, "@%lu", id);
+ asprintf(&decode, "@%llu", id);
} break;
case IS_CONST:
- asprintf(&decode, "C%u", phpdbg_decode_literal(ops, op->literal TSRMLS_CC));
+ asprintf(&decode, "C%u", phpdbg_decode_literal(ops, op->zv TSRMLS_CC));
break;
case IS_UNUSED:
@@ -92,7 +91,7 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRM
case ZEND_JMPZNZ:
decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type, vars TSRMLS_CC);
- asprintf(&decode[2], "J%u or J%lu", op->op2.opline_num, op->extended_value);
+ asprintf(&decode[2], "J%u or J%llu", op->op2.opline_num, op->extended_value);
goto result;
case ZEND_JMPZ:
@@ -142,8 +141,8 @@ void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, ze
(PHPDBG_G(flags) & PHPDBG_IS_STEPPING) ||
(PHPDBG_G(oplog)))) {
- zend_op *opline = execute_data->opline;
- char *decode = phpdbg_decode_opline(execute_data->op_array, opline, vars TSRMLS_CC);
+ zend_op *opline = (zend_op *) execute_data->opline;
+ char *decode = phpdbg_decode_opline(&execute_data->func->op_array, opline, vars TSRMLS_CC);
if (ignore_flags || (!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) || (PHPDBG_G(flags) & PHPDBG_IS_STEPPING))) {
/* output line info */
@@ -152,7 +151,7 @@ void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, ze
opline,
phpdbg_decode_opcode(opline->opcode),
decode,
- execute_data->op_array->filename ? execute_data->op_array->filename : "unknown");
+ execute_data->func->op_array.filename ? execute_data->func->op_array.filename->val : "unknown");
}
if (!ignore_flags && PHPDBG_G(oplog)) {
@@ -161,7 +160,7 @@ void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, ze
opline,
phpdbg_decode_opcode(opline->opcode),
decode,
- execute_data->op_array->filename ? execute_data->op_array->filename : "unknown");
+ execute_data->func->op_array.filename ? execute_data->func->op_array.filename->val : "unknown");
}
if (decode) {
@@ -177,180 +176,6 @@ void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags
const char *phpdbg_decode_opcode(zend_uchar opcode) /* {{{ */
{
-#if ZEND_EXTENSION_API_NO <= PHP_5_5_API_NO
-#define CASE(s) case s: return #s
- switch (opcode) {
- CASE(ZEND_NOP);
- CASE(ZEND_ADD);
- CASE(ZEND_SUB);
- CASE(ZEND_MUL);
- CASE(ZEND_DIV);
- CASE(ZEND_MOD);
- CASE(ZEND_SL);
- CASE(ZEND_SR);
- CASE(ZEND_CONCAT);
- CASE(ZEND_BW_OR);
- CASE(ZEND_BW_AND);
- CASE(ZEND_BW_XOR);
- CASE(ZEND_BW_NOT);
- CASE(ZEND_BOOL_NOT);
- CASE(ZEND_BOOL_XOR);
- CASE(ZEND_IS_IDENTICAL);
- CASE(ZEND_IS_NOT_IDENTICAL);
- CASE(ZEND_IS_EQUAL);
- CASE(ZEND_IS_NOT_EQUAL);
- CASE(ZEND_IS_SMALLER);
- CASE(ZEND_IS_SMALLER_OR_EQUAL);
- CASE(ZEND_CAST);
- CASE(ZEND_QM_ASSIGN);
- CASE(ZEND_ASSIGN_ADD);
- CASE(ZEND_ASSIGN_SUB);
- CASE(ZEND_ASSIGN_MUL);
- CASE(ZEND_ASSIGN_DIV);
- CASE(ZEND_ASSIGN_MOD);
- CASE(ZEND_ASSIGN_SL);
- CASE(ZEND_ASSIGN_SR);
- CASE(ZEND_ASSIGN_CONCAT);
- CASE(ZEND_ASSIGN_BW_OR);
- CASE(ZEND_ASSIGN_BW_AND);
- CASE(ZEND_ASSIGN_BW_XOR);
- CASE(ZEND_PRE_INC);
- CASE(ZEND_PRE_DEC);
- CASE(ZEND_POST_INC);
- CASE(ZEND_POST_DEC);
- CASE(ZEND_ASSIGN);
- CASE(ZEND_ASSIGN_REF);
- CASE(ZEND_ECHO);
- CASE(ZEND_PRINT);
- CASE(ZEND_JMP);
- CASE(ZEND_JMPZ);
- CASE(ZEND_JMPNZ);
- CASE(ZEND_JMPZNZ);
- CASE(ZEND_JMPZ_EX);
- CASE(ZEND_JMPNZ_EX);
- CASE(ZEND_CASE);
- CASE(ZEND_SWITCH_FREE);
- CASE(ZEND_BRK);
- CASE(ZEND_CONT);
- CASE(ZEND_BOOL);
- CASE(ZEND_INIT_STRING);
- CASE(ZEND_ADD_CHAR);
- CASE(ZEND_ADD_STRING);
- CASE(ZEND_ADD_VAR);
- CASE(ZEND_BEGIN_SILENCE);
- CASE(ZEND_END_SILENCE);
- CASE(ZEND_INIT_FCALL_BY_NAME);
- CASE(ZEND_DO_FCALL);
- CASE(ZEND_DO_FCALL_BY_NAME);
- CASE(ZEND_RETURN);
- CASE(ZEND_RECV);
- CASE(ZEND_RECV_INIT);
- CASE(ZEND_SEND_VAL);
- CASE(ZEND_SEND_VAR);
- CASE(ZEND_SEND_REF);
- CASE(ZEND_NEW);
- CASE(ZEND_INIT_NS_FCALL_BY_NAME);
- CASE(ZEND_FREE);
- CASE(ZEND_INIT_ARRAY);
- CASE(ZEND_ADD_ARRAY_ELEMENT);
- CASE(ZEND_INCLUDE_OR_EVAL);
- CASE(ZEND_UNSET_VAR);
- CASE(ZEND_UNSET_DIM);
- CASE(ZEND_UNSET_OBJ);
- CASE(ZEND_FE_RESET);
- CASE(ZEND_FE_FETCH);
- CASE(ZEND_EXIT);
- CASE(ZEND_FETCH_R);
- CASE(ZEND_FETCH_DIM_R);
- CASE(ZEND_FETCH_OBJ_R);
- CASE(ZEND_FETCH_W);
- CASE(ZEND_FETCH_DIM_W);
- CASE(ZEND_FETCH_OBJ_W);
- CASE(ZEND_FETCH_RW);
- CASE(ZEND_FETCH_DIM_RW);
- CASE(ZEND_FETCH_OBJ_RW);
- CASE(ZEND_FETCH_IS);
- CASE(ZEND_FETCH_DIM_IS);
- CASE(ZEND_FETCH_OBJ_IS);
- CASE(ZEND_FETCH_FUNC_ARG);
- CASE(ZEND_FETCH_DIM_FUNC_ARG);
- CASE(ZEND_FETCH_OBJ_FUNC_ARG);
- CASE(ZEND_FETCH_UNSET);
- CASE(ZEND_FETCH_DIM_UNSET);
- CASE(ZEND_FETCH_OBJ_UNSET);
- CASE(ZEND_FETCH_DIM_TMP_VAR);
- CASE(ZEND_FETCH_CONSTANT);
- CASE(ZEND_GOTO);
- CASE(ZEND_EXT_STMT);
- CASE(ZEND_EXT_FCALL_BEGIN);
- CASE(ZEND_EXT_FCALL_END);
- CASE(ZEND_EXT_NOP);
- CASE(ZEND_TICKS);
- CASE(ZEND_SEND_VAR_NO_REF);
- CASE(ZEND_CATCH);
- CASE(ZEND_THROW);
- CASE(ZEND_FETCH_CLASS);
- CASE(ZEND_CLONE);
- CASE(ZEND_RETURN_BY_REF);
- CASE(ZEND_INIT_METHOD_CALL);
- CASE(ZEND_INIT_STATIC_METHOD_CALL);
- CASE(ZEND_ISSET_ISEMPTY_VAR);
- CASE(ZEND_ISSET_ISEMPTY_DIM_OBJ);
- CASE(ZEND_PRE_INC_OBJ);
- CASE(ZEND_PRE_DEC_OBJ);
- CASE(ZEND_POST_INC_OBJ);
- CASE(ZEND_POST_DEC_OBJ);
- CASE(ZEND_ASSIGN_OBJ);
- CASE(ZEND_INSTANCEOF);
- CASE(ZEND_DECLARE_CLASS);
- CASE(ZEND_DECLARE_INHERITED_CLASS);
- CASE(ZEND_DECLARE_FUNCTION);
- CASE(ZEND_RAISE_ABSTRACT_ERROR);
- CASE(ZEND_DECLARE_CONST);
- CASE(ZEND_ADD_INTERFACE);
- CASE(ZEND_DECLARE_INHERITED_CLASS_DELAYED);
- CASE(ZEND_VERIFY_ABSTRACT_CLASS);
- CASE(ZEND_ASSIGN_DIM);
- CASE(ZEND_ISSET_ISEMPTY_PROP_OBJ);
- CASE(ZEND_HANDLE_EXCEPTION);
- CASE(ZEND_USER_OPCODE);
-#ifdef ZEND_JMP_SET
- CASE(ZEND_JMP_SET);
-#endif
- CASE(ZEND_DECLARE_LAMBDA_FUNCTION);
-#ifdef ZEND_ADD_TRAIT
- CASE(ZEND_ADD_TRAIT);
-#endif
-#ifdef ZEND_BIND_TRAITS
- CASE(ZEND_BIND_TRAITS);
-#endif
-#ifdef ZEND_SEPARATE
- CASE(ZEND_SEPARATE);
-#endif
-#ifdef ZEND_DISCARD_EXCEPTION
- CASE(ZEND_DISCARD_EXCEPTION);
-#endif
-#ifdef ZEND_YIELD
- CASE(ZEND_YIELD);
-#endif
-#ifdef ZEND_GENERATOR_RETURN
- CASE(ZEND_GENERATOR_RETURN);
-#endif
-#ifdef ZEND_FAST_CALL
- CASE(ZEND_FAST_CALL);
-#endif
-#ifdef ZEND_FAST_RET
- CASE(ZEND_FAST_RET);
-#endif
-#ifdef ZEND_RECV_VARIADIC
- CASE(ZEND_RECV_VARIADIC);
-#endif
- CASE(ZEND_OP_DATA);
- default:
- return "UNKNOWN";
- }
-#else
const char *ret = zend_get_opcode_name(opcode);
return ret?ret:"UNKNOWN";
-#endif
} /* }}} */
diff --git a/sapi/phpdbg/phpdbg_out.c b/sapi/phpdbg/phpdbg_out.c
index a4793f144f..4d70381533 100644
--- a/sapi/phpdbg/phpdbg_out.c
+++ b/sapi/phpdbg/phpdbg_out.c
@@ -136,7 +136,8 @@ static int format_converter(register buffy *odp, const char *fmt, zend_bool esca
int i;
char *s = NULL, *free_s = NULL;
- int s_len, free_zcopy;
+ size_t s_len;
+ zend_bool free_zcopy;
zval *zvp, zcopy;
int min_width = 0;
@@ -331,8 +332,8 @@ static int format_converter(register buffy *odp, const char *fmt, zend_bool esca
*/
switch (*fmt) {
case 'Z':
- zvp = (zval*) va_arg(ap, zval*);
- zend_make_printable_zval(zvp, &zcopy, &free_zcopy);
+ zvp = (zval *) va_arg(ap, zval *);
+ free_zcopy = zend_make_printable_zval(zvp, &zcopy TSRMLS_CC);
if (free_zcopy) {
zvp = &zcopy;
}
@@ -1021,6 +1022,8 @@ static int phpdbg_process_print(int fd, int type, const char *tag, const char *m
if (msg) {
PHPDBG_G(last_was_newline) = msg[msglen - 1] == '\n';
if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) {
+ zend_string *encoded;
+
if (PHPDBG_G(in_script_xml) != type) {
char *stream_buf;
int stream_buflen = phpdbg_asprintf(&stream_buf, "<stream type=\"%s\">", type == P_STDERR ? "stderr" : "stdout");
@@ -1028,11 +1031,9 @@ static int phpdbg_process_print(int fd, int type, const char *tag, const char *m
efree(stream_buf);
PHPDBG_G(in_script_xml) = type;
}
-#if PHP_VERSION_ID >= 50600
- buf = php_escape_html_entities((unsigned char *) msg, msglen, (size_t *) &buflen, 0, ENT_NOQUOTES, PG(internal_encoding) && PG(internal_encoding)[0] ? PG(internal_encoding) : (SG(default_charset) ? SG(default_charset) : "UTF-8") TSRMLS_CC);
-#else
- buf = php_escape_html_entities((unsigned char *) msg, msglen, (size_t *) &buflen, 0, ENT_NOQUOTES, SG(default_charset) ? SG(default_charset) : "UTF-8" TSRMLS_CC);
-#endif
+ encoded = php_escape_html_entities((unsigned char *) msg, msglen, 0, ENT_NOQUOTES, PG(internal_encoding) && PG(internal_encoding)[0] ? PG(internal_encoding) : (SG(default_charset) ? SG(default_charset) : "UTF-8") TSRMLS_CC);
+ buflen = encoded->len;
+ memcpy(buf = emalloc(buflen + 1), encoded->val, buflen);
phpdbg_encode_ctrl_chars(&buf, &buflen);
phpdbg_mixed_write(fd, buf, buflen TSRMLS_CC);
efree(buf);
diff --git a/sapi/phpdbg/phpdbg_parser.c b/sapi/phpdbg/phpdbg_parser.c
index c766868369..8bb9103a98 100644
--- a/sapi/phpdbg/phpdbg_parser.c
+++ b/sapi/phpdbg/phpdbg_parser.c
@@ -1,8 +1,8 @@
-/* A Bison parser, made by GNU Bison 2.5. */
+/* A Bison parser, made by GNU Bison 2.6. */
/* Bison implementation for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "2.5"
+#define YYBISON_VERSION "2.6"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -58,8 +58,6 @@
/* Pull parsers. */
#define YYPULL 1
-/* Using locations. */
-#define YYLSP_NEEDED 0
/* Substitute the variable and function names. */
#define yyparse phpdbg_parse
@@ -70,11 +68,10 @@
#define yydebug phpdbg_debug
#define yynerrs phpdbg_nerrs
-
/* Copy the first part of user declarations. */
-/* Line 268 of yacc.c */
-#line 1 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 336 of yacc.c */
+#line 1 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
/*
@@ -102,13 +99,16 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
-/* Line 268 of yacc.c */
-#line 107 "sapi/phpdbg/phpdbg_parser.c"
+/* Line 336 of yacc.c */
+#line 104 "sapi/phpdbg/phpdbg_parser.c"
-/* Enabling traces. */
-#ifndef YYDEBUG
-# define YYDEBUG 0
-#endif
+# ifndef YY_NULL
+# if defined __cplusplus && 201103L <= __cplusplus
+# define YY_NULL nullptr
+# else
+# define YY_NULL 0
+# endif
+# endif
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
@@ -118,15 +118,21 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
# define YYERROR_VERBOSE 1
#endif
-/* Enabling the token table. */
-#ifndef YYTOKEN_TABLE
-# define YYTOKEN_TABLE 0
+/* In a future release of Bison, this section will be replaced
+ by #include "phpdbg_parser.h". */
+#ifndef PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H
+# define PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+#if YYDEBUG
+extern int phpdbg_debug;
#endif
-
/* "%code requires" blocks. */
-/* Line 288 of yacc.c */
-#line 31 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 350 of yacc.c */
+#line 31 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
#include "phpdbg.h"
#ifndef YY_TYPEDEF_YY_SCANNER_T
@@ -136,8 +142,8 @@ typedef void* yyscan_t;
-/* Line 288 of yacc.c */
-#line 141 "sapi/phpdbg/phpdbg_parser.c"
+/* Line 350 of yacc.c */
+#line 147 "sapi/phpdbg/phpdbg_parser.c"
/* Tokens. */
#ifndef YYTOKENTYPE
@@ -189,7 +195,6 @@ typedef void* yyscan_t;
-
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
@@ -198,11 +203,27 @@ typedef int YYSTYPE;
#endif
+#ifdef YYPARSE_PARAM
+#if defined __STDC__ || defined __cplusplus
+int phpdbg_parse (void *YYPARSE_PARAM);
+#else
+int phpdbg_parse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
+int phpdbg_parse (void *tsrm_ls);
+#else
+int phpdbg_parse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+#endif /* !PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H */
+
/* Copy the second part of user declarations. */
-/* Line 343 of yacc.c */
-#line 206 "sapi/phpdbg/phpdbg_parser.c"
+/* Line 353 of yacc.c */
+#line 227 "sapi/phpdbg/phpdbg_parser.c"
#ifdef short
# undef short
@@ -308,6 +329,7 @@ YYID (yyi)
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+ /* Use EXIT_SUCCESS as a witness for stdlib.h. */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
@@ -399,20 +421,20 @@ union yyalloc
#endif
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
-/* Copy COUNT objects from FROM to TO. The source and destination do
+/* Copy COUNT objects from SRC to DST. The source and destination do
not overlap. */
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
-# define YYCOPY(To, From, Count) \
- __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# define YYCOPY(Dst, Src, Count) \
+ __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
# else
-# define YYCOPY(To, From, Count) \
- do \
- { \
- YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (To)[yyi] = (From)[yyi]; \
- } \
+# define YYCOPY(Dst, Src, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (Dst)[yyi] = (Src)[yyi]; \
+ } \
while (YYID (0))
# endif
# endif
@@ -505,7 +527,7 @@ static const yytype_uint8 yyrline[] =
};
#endif
-#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+#if YYDEBUG || YYERROR_VERBOSE || 1
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
@@ -519,7 +541,7 @@ static const char *const yytname[] =
"\"opcode\"", "\"identifier (command or function name)\"",
"\"input (input string or data)\"", "\"input\"",
"\"request id (-r %d)\"", "$accept", "input", "parameters", "parameter",
- "req_id", "full_expression", 0
+ "req_id", "full_expression", YY_NULL
};
#endif
@@ -652,17 +674,18 @@ static const yytype_uint8 yystos[] =
#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY && yylen == 1) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- YYPOPSTACK (1); \
- goto yybackup; \
- } \
- else \
- { \
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (yylen); \
+ yystate = *yyssp; \
+ goto yybackup; \
+ } \
+ else \
+ { \
yyerror (tsrm_ls, YY_("syntax error: cannot back up")); \
YYERROR; \
} \
@@ -672,32 +695,33 @@ while (YYID (0))
#define YYTERROR 1
#define YYERRCODE 256
-
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
If N is 0, then set CURRENT to the empty location which ends
the previous symbol: RHS[0] (always defined). */
-#define YYRHSLOC(Rhs, K) ((Rhs)[K])
#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N) \
- do \
- if (YYID (N)) \
- { \
- (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
- (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
- (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
- (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
- } \
- else \
- { \
- (Current).first_line = (Current).last_line = \
- YYRHSLOC (Rhs, 0).last_line; \
- (Current).first_column = (Current).last_column = \
- YYRHSLOC (Rhs, 0).last_column; \
- } \
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (YYID (N)) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ } \
while (YYID (0))
#endif
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+
+
/* This macro is provided for backward compatibility. */
@@ -758,6 +782,8 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, tsrm_ls)
void *tsrm_ls;
#endif
{
+ FILE *yyo = yyoutput;
+ YYUSE (yyo);
if (!yyvaluep)
return;
YYUSE (tsrm_ls);
@@ -1012,12 +1038,12 @@ static int
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yytype_int16 *yyssp, int yytoken)
{
- YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
+ YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
YYSIZE_T yysize = yysize0;
YYSIZE_T yysize1;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
- const char *yyformat = 0;
+ const char *yyformat = YY_NULL;
/* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per
@@ -1077,7 +1103,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
break;
}
yyarg[yycount++] = yytname[yyx];
- yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+ yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
if (! (yysize <= yysize1
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2;
@@ -1171,20 +1197,6 @@ yydestruct (yymsg, yytype, yyvaluep, tsrm_ls)
}
-/* Prevent warnings from -Wmissing-prototypes. */
-#ifdef YYPARSE_PARAM
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void *YYPARSE_PARAM);
-#else
-int yyparse ();
-#endif
-#else /* ! YYPARSE_PARAM */
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void *tsrm_ls);
-#else
-int yyparse ();
-#endif
-#endif /* ! YYPARSE_PARAM */
/*----------.
@@ -1230,7 +1242,7 @@ YYSTYPE yylval;
`yyss': related to states.
`yyvs': related to semantic values.
- Refer to the stacks thru separate pointers, to allow yyoverflow
+ Refer to the stacks through separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The state stack. */
@@ -1463,36 +1475,36 @@ yyreduce:
{
case 3:
-/* Line 1806 of yacc.c */
-#line 68 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 68 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{ phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(1) - (1)])); }
break;
case 5:
-/* Line 1806 of yacc.c */
-#line 73 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 73 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{ phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(1) - (1)])); }
break;
case 6:
-/* Line 1806 of yacc.c */
-#line 74 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 74 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{ phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(2) - (2)])); }
break;
case 7:
-/* Line 1806 of yacc.c */
-#line 75 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 75 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (2)]); }
break;
case 8:
-/* Line 1806 of yacc.c */
-#line 79 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 79 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{
(yyval).type = FILE_PARAM;
(yyval).file.name = (yyvsp[(2) - (3)]).str;
@@ -1502,8 +1514,8 @@ yyreduce:
case 9:
-/* Line 1806 of yacc.c */
-#line 84 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 84 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{
(yyval).type = NUMERIC_FILE_PARAM;
(yyval).file.name = (yyvsp[(1) - (4)]).str;
@@ -1513,8 +1525,8 @@ yyreduce:
case 10:
-/* Line 1806 of yacc.c */
-#line 89 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 89 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{
(yyval).type = FILE_PARAM;
(yyval).file.name = malloc((yyvsp[(1) - (4)]).len + (yyvsp[(2) - (4)]).len + 1);
@@ -1529,8 +1541,8 @@ yyreduce:
case 11:
-/* Line 1806 of yacc.c */
-#line 99 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 99 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{
(yyval).type = NUMERIC_FILE_PARAM;
(yyval).file.name = malloc((yyvsp[(1) - (5)]).len + (yyvsp[(2) - (5)]).len + 1);
@@ -1545,8 +1557,8 @@ yyreduce:
case 12:
-/* Line 1806 of yacc.c */
-#line 109 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 109 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{
(yyval).type = METHOD_PARAM;
(yyval).method.class = (yyvsp[(1) - (3)]).str;
@@ -1556,8 +1568,8 @@ yyreduce:
case 13:
-/* Line 1806 of yacc.c */
-#line 114 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 114 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{
(yyval).type = NUMERIC_METHOD_PARAM;
(yyval).method.class = (yyvsp[(1) - (5)]).str;
@@ -1568,8 +1580,8 @@ yyreduce:
case 14:
-/* Line 1806 of yacc.c */
-#line 120 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 120 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{
(yyval).type = NUMERIC_FUNCTION_PARAM;
(yyval).str = (yyvsp[(1) - (3)]).str;
@@ -1580,8 +1592,8 @@ yyreduce:
case 15:
-/* Line 1806 of yacc.c */
-#line 126 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 126 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{
(yyval).type = COND_PARAM;
(yyval).str = (yyvsp[(2) - (2)]).str;
@@ -1591,64 +1603,64 @@ yyreduce:
case 16:
-/* Line 1806 of yacc.c */
-#line 131 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 131 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 17:
-/* Line 1806 of yacc.c */
-#line 132 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 132 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 18:
-/* Line 1806 of yacc.c */
-#line 133 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 133 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 19:
-/* Line 1806 of yacc.c */
-#line 134 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 134 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 20:
-/* Line 1806 of yacc.c */
-#line 135 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 135 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 21:
-/* Line 1806 of yacc.c */
-#line 136 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 136 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 22:
-/* Line 1806 of yacc.c */
-#line 137 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 137 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 23:
-/* Line 1806 of yacc.c */
-#line 141 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 141 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{ PHPDBG_G(req_id) = (yyvsp[(1) - (1)]).num; }
break;
case 25:
-/* Line 1806 of yacc.c */
-#line 146 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 146 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{
(yyval).type = EVAL_PARAM;
(yyval).str = (yyvsp[(3) - (3)]).str;
@@ -1658,8 +1670,8 @@ yyreduce:
case 26:
-/* Line 1806 of yacc.c */
-#line 151 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 151 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{
(yyval).type = SHELL_PARAM;
(yyval).str = (yyvsp[(3) - (3)]).str;
@@ -1669,8 +1681,8 @@ yyreduce:
case 27:
-/* Line 1806 of yacc.c */
-#line 156 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 156 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{
(yyval).type = RUN_PARAM;
(yyval).len = 0;
@@ -1679,8 +1691,8 @@ yyreduce:
case 28:
-/* Line 1806 of yacc.c */
-#line 160 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 1803 of yacc.c */
+#line 160 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
{
(yyval).type = RUN_PARAM;
(yyval).str = (yyvsp[(3) - (3)]).str;
@@ -1690,8 +1702,8 @@ yyreduce:
-/* Line 1806 of yacc.c */
-#line 1695 "sapi/phpdbg/phpdbg_parser.c"
+/* Line 1803 of yacc.c */
+#line 1707 "sapi/phpdbg/phpdbg_parser.c"
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -1878,7 +1890,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
-#if !defined(yyoverflow) || YYERROR_VERBOSE
+#if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
@@ -1921,8 +1933,8 @@ yyreturn:
-/* Line 2067 of yacc.c */
-#line 167 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 2049 of yacc.c */
+#line 167 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
static int yyerror(void ***tsrm_ls, const char *msg) {
diff --git a/sapi/phpdbg/phpdbg_parser.h b/sapi/phpdbg/phpdbg_parser.h
index dfa155d718..e8ab7a6503 100644
--- a/sapi/phpdbg/phpdbg_parser.h
+++ b/sapi/phpdbg/phpdbg_parser.h
@@ -1,8 +1,8 @@
-/* A Bison parser, made by GNU Bison 2.5. */
+/* A Bison parser, made by GNU Bison 2.6. */
/* Bison interface for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,10 +30,19 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
+#ifndef PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H
+# define PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+#if YYDEBUG
+extern int phpdbg_debug;
+#endif
/* "%code requires" blocks. */
-/* Line 2068 of yacc.c */
-#line 31 "/root/php-src-xml-data-phpdbg/sapi/phpdbg/phpdbg_parser.y"
+/* Line 2056 of yacc.c */
+#line 31 "/Users/Bob/php-src-X/sapi/phpdbg/phpdbg_parser.y"
#include "phpdbg.h"
#ifndef YY_TYPEDEF_YY_SCANNER_T
@@ -43,8 +52,8 @@ typedef void* yyscan_t;
-/* Line 2068 of yacc.c */
-#line 48 "sapi/phpdbg/phpdbg_parser.h"
+/* Line 2056 of yacc.c */
+#line 57 "sapi/phpdbg/phpdbg_parser.h"
/* Tokens. */
#ifndef YYTOKENTYPE
@@ -96,7 +105,6 @@ typedef void* yyscan_t;
-
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
@@ -105,5 +113,18 @@ typedef int YYSTYPE;
#endif
+#ifdef YYPARSE_PARAM
+#if defined __STDC__ || defined __cplusplus
+int phpdbg_parse (void *YYPARSE_PARAM);
+#else
+int phpdbg_parse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
+int phpdbg_parse (void *tsrm_ls);
+#else
+int phpdbg_parse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
-
+#endif /* !PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H */
diff --git a/sapi/phpdbg/phpdbg_print.c b/sapi/phpdbg/phpdbg_print.c
index 80eeddb39d..62a614281d 100644
--- a/sapi/phpdbg/phpdbg_print.c
+++ b/sapi/phpdbg/phpdbg_print.c
@@ -41,7 +41,7 @@ const phpdbg_command_t phpdbg_print_commands[] = {
PHPDBG_PRINT(opline) /* {{{ */
{
- if (EG(in_execution) && EG(current_execute_data)) {
+ if (PHPDBG_G(in_execution) && EG(current_execute_data)) {
phpdbg_print_opline(EG(current_execute_data), 1 TSRMLS_CC);
} else {
phpdbg_error("inactive", "type=\"execution\"", "Not Executing!");
@@ -59,22 +59,22 @@ static inline void phpdbg_print_function_helper(zend_function *method TSRMLS_DC)
if (op_array) {
zend_op *opline = &(op_array->opcodes[0]);
- zend_uint opcode = 0,
+ uint32_t opcode = 0,
end = op_array->last-1;
if (method->common.scope) {
phpdbg_writeln("printoplineinfo", "type=\"User\" startline=\"%d\" endline=\"%d\" method=\"%s::%s\" file=\"%s\"", "\tL%d-%d %s::%s() %s",
op_array->line_start,
op_array->line_end,
- method->common.scope->name,
- method->common.function_name,
- op_array->filename ? op_array->filename : "unknown");
+ method->common.scope->name->val,
+ method->common.function_name->val,
+ op_array->filename ? op_array->filename->val : "unknown");
} else {
phpdbg_writeln("printoplineinfo", "type=\"User\" startline=\"%d\" endline=\"%d\" function=\"%s\" file=\"%s\"", "\tL%d-%d %s() %s",
method->common.function_name ? op_array->line_start : 0,
method->common.function_name ? op_array->line_end : 0,
- method->common.function_name ? method->common.function_name : "{main}",
- op_array->filename ? op_array->filename : "unknown");
+ method->common.function_name ? method->common.function_name->val : "{main}",
+ op_array->filename ? op_array->filename->val : "unknown");
}
zend_hash_init(&vars, op_array->last, NULL, NULL, 0);
@@ -98,9 +98,9 @@ static inline void phpdbg_print_function_helper(zend_function *method TSRMLS_DC)
default: {
if (method->common.scope) {
- phpdbg_writeln("printoplineinfo", "type=\"Internal\" method=\"%s::%s\"", "Internal %s::%s()", method->common.scope->name, method->common.function_name);
+ phpdbg_writeln("printoplineinfo", "type=\"Internal\" method=\"%s::%s\"", "\tInternal %s::%s()", method->common.scope->name->val, method->common.function_name->val);
} else {
- phpdbg_writeln("printoplineinfo", "type=\"Internal\" function=\"%s\"", "\tInternal %s()", method->common.function_name);
+ phpdbg_writeln("printoplineinfo", "type=\"Internal\" function=\"%s\"", "\tInternal %s()", method->common.function_name->val);
}
}
}
@@ -127,18 +127,17 @@ return SUCCESS;
PHPDBG_PRINT(stack) /* {{{ */
{
- zend_op_array *ops = EG(active_op_array);
-
- if (EG(in_execution) && ops) {
+ if (PHPDBG_G(in_execution) && EG(current_execute_data)) {
+ zend_op_array *ops = &EG(current_execute_data)->func->op_array;
if (ops->function_name) {
if (ops->scope) {
- phpdbg_notice("printinfo", "method=\"%s::%s\" num=\"%d\"", "Stack in %s::%s() (%d ops)", ops->scope->name, ops->function_name, ops->last);
+ phpdbg_notice("printinfo", "method=\"%s::%s\" num=\"%d\"", "Stack in %s::%s() (%d ops)", ops->scope->name->val, ops->function_name->val, ops->last);
} else {
- phpdbg_notice("printinfo", "function=\"%s\" num=\"%d\"", "Stack in %s() (%d ops)", ops->function_name, ops->last);
+ phpdbg_notice("printinfo", "function=\"%s\" num=\"%d\"", "Stack in %s() (%d ops)", ops->function_name->val, ops->last);
}
} else {
if (ops->filename) {
- phpdbg_notice("printinfo", "file=\"%s\" num=\"%d\"", "Stack in %s (%d ops)", ops->filename, ops->last);
+ phpdbg_notice("printinfo", "file=\"%s\" num=\"%d\"", "Stack in %s (%d ops)", ops->filename->val, ops->last);
} else {
phpdbg_notice("printinfo", "opline=\"%p\" num=\"%d\"", "Stack @ %p (%d ops)", ops, ops->last);
}
@@ -153,31 +152,28 @@ PHPDBG_PRINT(stack) /* {{{ */
PHPDBG_PRINT(class) /* {{{ */
{
- zend_class_entry **ce;
+ zend_class_entry *ce;
if (phpdbg_safe_class_lookup(param->str, param->len, &ce TSRMLS_CC) == SUCCESS) {
phpdbg_notice("printinfo", "type=\"%s\" flag=\"%s\" class=\"%s\" num=\"%d\"", "%s %s: %s (%d methods)",
- ((*ce)->type == ZEND_USER_CLASS) ?
+ (ce->type == ZEND_USER_CLASS) ?
"User" : "Internal",
- ((*ce)->ce_flags & ZEND_ACC_INTERFACE) ?
+ (ce->ce_flags & ZEND_ACC_INTERFACE) ?
"Interface" :
- ((*ce)->ce_flags & ZEND_ACC_ABSTRACT) ?
+ (ce->ce_flags & ZEND_ACC_ABSTRACT) ?
"Abstract Class" :
"Class",
- (*ce)->name,
- zend_hash_num_elements(&(*ce)->function_table));
+ ce->name->val,
+ zend_hash_num_elements(&ce->function_table));
phpdbg_xml("<printmethods %r>");
- if (zend_hash_num_elements(&(*ce)->function_table)) {
- HashPosition position;
+ if (zend_hash_num_elements(&ce->function_table)) {
zend_function *method;
- for (zend_hash_internal_pointer_reset_ex(&(*ce)->function_table, &position);
- zend_hash_get_current_data_ex(&(*ce)->function_table, (void**) &method, &position) == SUCCESS;
- zend_hash_move_forward_ex(&(*ce)->function_table, &position)) {
+ ZEND_HASH_FOREACH_PTR(&ce->function_table, method) {
phpdbg_print_function_helper(method TSRMLS_CC);
- }
+ } ZEND_HASH_FOREACH_END();
}
phpdbg_xml("</printmethods>");
@@ -190,16 +186,17 @@ PHPDBG_PRINT(class) /* {{{ */
PHPDBG_PRINT(method) /* {{{ */
{
- zend_class_entry **ce;
+ zend_class_entry *ce;
if (phpdbg_safe_class_lookup(param->method.class, strlen(param->method.class), &ce TSRMLS_CC) == SUCCESS) {
zend_function *fbc;
- char *lcname = zend_str_tolower_dup(param->method.name, strlen(param->method.name));
+ zend_string *lcname = zend_string_alloc(strlen(param->method.name), 0);
+ zend_str_tolower_copy(lcname->val, param->method.name, lcname->len);
- if (zend_hash_find(&(*ce)->function_table, lcname, strlen(lcname)+1, (void**)&fbc) == SUCCESS) {
+ if ((fbc = zend_hash_find_ptr(&ce->function_table, lcname))) {
phpdbg_notice("printinfo", "type=\"%s\" flags=\"Method\" symbol=\"%s\" num=\"%d\"", "%s Method %s (%d ops)",
(fbc->type == ZEND_USER_FUNCTION) ? "User" : "Internal",
- fbc->common.function_name,
+ fbc->common.function_name->val,
(fbc->type == ZEND_USER_FUNCTION) ? fbc->op_array.last : 0);
phpdbg_print_function_helper(fbc TSRMLS_CC);
@@ -207,7 +204,7 @@ PHPDBG_PRINT(method) /* {{{ */
phpdbg_error("print", "type=\"nomethod\" method=\"%s::%s\"", "The method %s::%s could not be found", param->method.class, param->method.name);
}
- efree(lcname);
+ zend_string_release(lcname);
} else {
phpdbg_error("print", "type=\"noclass\" class=\"%s\"", "The class %s could not be found", param->method.class);
}
@@ -221,7 +218,7 @@ PHPDBG_PRINT(func) /* {{{ */
zend_function* fbc;
const char *func_name = param->str;
size_t func_name_len = param->len;
- char *lcname;
+ zend_string *lcname;
/* search active scope if begins with period */
if (func_name[0] == '.') {
if (EG(scope)) {
@@ -240,14 +237,15 @@ PHPDBG_PRINT(func) /* {{{ */
func_table = EG(function_table);
}
- lcname = zend_str_tolower_dup(func_name, func_name_len);
+ lcname = zend_string_alloc(func_name_len, 0);
+ zend_str_tolower_copy(lcname->val, func_name, lcname->len);
phpdbg_try_access {
- if (zend_hash_find(func_table, lcname, func_name_len + 1, (void **) &fbc) == SUCCESS) {
+ if ((fbc = zend_hash_find_ptr(func_table, lcname))) {
phpdbg_notice("printinfo", "type=\"%s\" flags=\"%s\" symbol=\"%s\" num=\"%d\"", "%s %s %s (%d ops)",
(fbc->type == ZEND_USER_FUNCTION) ? "User" : "Internal",
(fbc->common.scope) ? "Method" : "Function",
- fbc->common.function_name,
+ fbc->common.function_name->val,
(fbc->type == ZEND_USER_FUNCTION) ? fbc->op_array.last : 0);
phpdbg_print_function_helper(fbc TSRMLS_CC);
diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c
index 82444fbf1d..190907e687 100644
--- a/sapi/phpdbg/phpdbg_prompt.c
+++ b/sapi/phpdbg/phpdbg_prompt.c
@@ -22,6 +22,7 @@
#include <string.h>
#include "zend.h"
#include "zend_compile.h"
+#include "zend_exceptions.h"
#include "phpdbg.h"
#include "phpdbg_help.h"
@@ -103,20 +104,18 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ *
lc_name = zend_str_tolower_dup(name->str, name->len);
- if (zend_hash_exists(&PHPDBG_G(registered), lc_name, name->len+1)) {
- zval fname, *fretval;
+ if (zend_hash_str_exists(&PHPDBG_G(registered), lc_name, name->len)) {
+ zval fretval;
zend_fcall_info fci;
- ZVAL_STRINGL(&fname, lc_name, name->len, 1);
-
memset(&fci, 0, sizeof(zend_fcall_info));
+ ZVAL_STRINGL(&fci.function_name, lc_name, name->len);
fci.size = sizeof(zend_fcall_info);
fci.function_table = &PHPDBG_G(registered);
- fci.function_name = &fname;
- fci.symbol_table = EG(active_symbol_table);
- fci.object_ptr = NULL;
- fci.retval_ptr_ptr = &fretval;
+ fci.symbol_table = zend_rebuild_symbol_table(TSRMLS_C);
+ fci.object = NULL;
+ fci.retval = &fretval;
fci.no_separation = 1;
if (name->next) {
@@ -132,7 +131,7 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ *
case OP_PARAM:
case COND_PARAM:
case STR_PARAM:
- add_next_index_stringl(&params, next->str, next->len, 1);
+ add_next_index_stringl(&params, next->str, next->len);
break;
case NUMERIC_PARAM:
@@ -140,33 +139,28 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ *
break;
case METHOD_PARAM:
- spprintf(&buffered, 0, "%s::%s",
- next->method.class, next->method.name);
- add_next_index_string(&params, buffered, 0);
+ spprintf(&buffered, 0, "%s::%s", next->method.class, next->method.name);
+ add_next_index_string(&params, buffered);
break;
case NUMERIC_METHOD_PARAM:
- spprintf(&buffered, 0, "%s::%s#%ld",
- next->method.class, next->method.name, next->num);
- add_next_index_string(&params, buffered, 0);
+ spprintf(&buffered, 0, "%s::%s#%ld", next->method.class, next->method.name, next->num);
+ add_next_index_string(&params, buffered);
break;
case NUMERIC_FUNCTION_PARAM:
- spprintf(&buffered, 0, "%s#%ld",
- next->str, next->num);
- add_next_index_string(&params, buffered, 0);
+ spprintf(&buffered, 0, "%s#%ld", next->str, next->num);
+ add_next_index_string(&params, buffered);
break;
case FILE_PARAM:
- spprintf(&buffered, 0, "%s:%ld",
- next->file.name, next->file.line);
- add_next_index_string(&params, buffered, 0);
+ spprintf(&buffered, 0, "%s:%ld", next->file.name, next->file.line);
+ add_next_index_string(&params, buffered);
break;
case NUMERIC_FILE_PARAM:
- spprintf(&buffered, 0, "%s:#%ld",
- next->file.name, next->file.line);
- add_next_index_string(&params, buffered, 0);
+ spprintf(&buffered, 0, "%s:#%ld", next->file.name, next->file.line);
+ add_next_index_string(&params, buffered);
break;
default: {
@@ -188,14 +182,13 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ *
phpdbg_debug("created %d params from arguments", fci.param_count);
- zend_call_function(&fci, NULL TSRMLS_CC);
-
- if (fretval) {
- zend_print_zval_r(fretval, 0 TSRMLS_CC);
+ if (zend_call_function(&fci, NULL TSRMLS_CC) == SUCCESS) {
+ zend_print_zval_r(&fretval, 0 TSRMLS_CC);
phpdbg_out("\n");
+ zval_ptr_dtor(&fretval);
}
- zval_dtor(&fname);
+ zval_dtor(&fci.function_name);
efree(lc_name);
return SUCCESS;
@@ -401,13 +394,12 @@ int phpdbg_compile(TSRMLS_D) /* {{{ */
return SUCCESS;
}
- if (EG(in_execution)) {
+ if (PHPDBG_G(in_execution)) {
phpdbg_error("inactive", "type=\"isrunning\"", "Cannot compile while in execution");
return FAILURE;
}
if (php_stream_open_for_zend_ex(PHPDBG_G(exec), &fh, USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC) == SUCCESS) {
-
PHPDBG_G(ops) = zend_compile_file(&fh, ZEND_INCLUDE TSRMLS_CC);
zend_destroy_file_handle(&fh TSRMLS_CC);
@@ -422,7 +414,7 @@ int phpdbg_compile(TSRMLS_D) /* {{{ */
PHPDBG_COMMAND(step) /* {{{ */
{
- if (EG(in_execution)) {
+ if (PHPDBG_G(in_execution)) {
PHPDBG_G(flags) |= PHPDBG_IS_STEPPING;
}
@@ -436,19 +428,19 @@ PHPDBG_COMMAND(continue) /* {{{ */
PHPDBG_COMMAND(until) /* {{{ */
{
- if (!EG(in_execution)) {
+ if (!PHPDBG_G(in_execution)) {
phpdbg_error("inactive", "type=\"noexec\"", "Not executing");
return SUCCESS;
}
PHPDBG_G(flags) |= PHPDBG_IN_UNTIL;
{
- zend_uint next = 0, self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes);
- zend_op *opline = &EG(active_op_array)->opcodes[self];
+ const zend_op *opline = EG(current_execute_data)->opline;
+ const zend_op_array *op_array = &EG(current_execute_data)->func->op_array;
- for (next = self; next < EG(active_op_array)->last; next++) {
- if (EG(active_op_array)->opcodes[next].lineno != opline->lineno) {
- zend_hash_index_update(&PHPDBG_G(seek), (zend_ulong) &EG(active_op_array)->opcodes[next], &EG(active_op_array)->opcodes[next], sizeof(zend_op), NULL);
+ while (++opline < op_array->opcodes + op_array->last) {
+ if (opline->lineno != EG(current_execute_data)->opline->lineno) {
+ zend_hash_index_update_ptr(&PHPDBG_G(seek), (zend_ulong) opline, (void *) opline);
break;
}
}
@@ -457,58 +449,46 @@ PHPDBG_COMMAND(until) /* {{{ */
return PHPDBG_UNTIL;
} /* }}} */
+static void phpdbg_seek_to_end(TSRMLS_D) {
+ const zend_op *opline = EG(current_execute_data)->opline;
+ const zend_op_array *op_array = &EG(current_execute_data)->func->op_array - 1;
+
+ while (++opline < op_array->opcodes + op_array->last) {
+ switch (opline->opcode) {
+ case ZEND_RETURN:
+ case ZEND_THROW:
+ case ZEND_EXIT:
+#ifdef ZEND_YIELD
+ case ZEND_YIELD:
+#endif
+ zend_hash_index_update_ptr(&PHPDBG_G(seek), (zend_ulong) opline, (void *) opline);
+ return;
+ }
+ }
+}
+
PHPDBG_COMMAND(finish) /* {{{ */
{
- if (!EG(in_execution)) {
+ if (!PHPDBG_G(in_execution)) {
phpdbg_error("inactive", "type=\"noexec\"", "Not executing");
return SUCCESS;
}
PHPDBG_G(flags) |= PHPDBG_IN_FINISH;
- {
- zend_uint next = 0, self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes);
-
- for (next = self; next < EG(active_op_array)->last; next++) {
- switch (EG(active_op_array)->opcodes[next].opcode) {
- case ZEND_RETURN:
- case ZEND_THROW:
- case ZEND_EXIT:
-#ifdef ZEND_YIELD
- case ZEND_YIELD:
-#endif
- zend_hash_index_update(&PHPDBG_G(seek), (zend_ulong) &EG(active_op_array)->opcodes[next], &EG(active_op_array)->opcodes[next], sizeof(zend_op), NULL);
- break;
- }
- }
- }
+ phpdbg_seek_to_end(TSRMLS_C);
return PHPDBG_FINISH;
} /* }}} */
PHPDBG_COMMAND(leave) /* {{{ */
{
- if (!EG(in_execution)) {
+ if (!PHPDBG_G(in_execution)) {
phpdbg_error("inactive", "type=\"noexec\"", "Not executing");
return SUCCESS;
}
PHPDBG_G(flags) |= PHPDBG_IN_LEAVE;
- {
- zend_uint next = 0, self = (EG(current_execute_data)->opline - EG(active_op_array)->opcodes);
-
- for (next = self; next < EG(active_op_array)->last; next++) {
- switch (EG(active_op_array)->opcodes[next].opcode) {
- case ZEND_RETURN:
- case ZEND_THROW:
- case ZEND_EXIT:
-#ifdef ZEND_YIELD
- case ZEND_YIELD:
-#endif
- zend_hash_index_update(&PHPDBG_G(seek), (zend_ulong) &EG(active_op_array)->opcodes[next], &EG(active_op_array)->opcodes[next], sizeof(zend_op), NULL);
- break;
- }
- }
- }
+ phpdbg_seek_to_end(TSRMLS_C);
return PHPDBG_LEAVE;
} /* }}} */
@@ -527,59 +507,47 @@ PHPDBG_COMMAND(frame) /* {{{ */
static inline void phpdbg_handle_exception(TSRMLS_D) /* }}} */
{
zend_fcall_info fci;
-
- zval fname, *trace, exception;
+ zval trace;
/* get filename and linenumber before unsetting exception */
const char *filename = zend_get_executed_filename(TSRMLS_C);
- zend_uint lineno = zend_get_executed_lineno(TSRMLS_C);
-
- /* copy exception */
- exception = *EG(exception);
- zval_copy_ctor(&exception);
- EG(exception) = NULL;
+ uint32_t lineno = zend_get_executed_lineno(TSRMLS_C);
/* call __toString */
- ZVAL_STRINGL(&fname, "__tostring", sizeof("__tostring")-1, 1);
+ ZVAL_STRINGL(&fci.function_name, "__tostring", sizeof("__tostring") - 1);
fci.size = sizeof(fci);
- fci.function_table = &Z_OBJCE(exception)->function_table;
- fci.function_name = &fname;
+ fci.function_table = &EG(exception)->ce->function_table;
fci.symbol_table = NULL;
- fci.object_ptr = &exception;
- fci.retval_ptr_ptr = &trace;
+ fci.object = EG(exception);
+ fci.retval = &trace;
fci.param_count = 0;
fci.params = NULL;
fci.no_separation = 1;
- zend_call_function(&fci, NULL TSRMLS_CC);
-
- if (trace) {
- phpdbg_writeln("exception", "name=\"%s\" trace=\"%.*s\"", "Uncaught %s!\n%.*s", Z_OBJCE(exception)->name, Z_STRLEN_P(trace), Z_STRVAL_P(trace));
+ if (zend_call_function(&fci, NULL TSRMLS_CC) == SUCCESS) {
+ phpdbg_writeln("exception", "name=\"%s\" trace=\"%.*s\"", "Uncaught %s!\n%.*s", EG(exception)->ce->name->val, Z_STRLEN(trace), Z_STRVAL(trace));
zval_ptr_dtor(&trace);
} else {
- phpdbg_error("exception", "name=\"%s\"", "Uncaught %s!", Z_OBJCE(exception)->name);
+ phpdbg_error("exception", "name=\"%s\"" "Uncaught %s!", EG(exception)->ce->name->val);
}
/* output useful information about address */
- phpdbg_writeln("exception", "opline=\"%p\" file=\"%s\" line=\"%u\"", "Stack entered at %p in %s on line %u", EG(active_op_array)->opcodes, filename, lineno);
+ phpdbg_writeln("exception", "opline=\"%p\" file=\"%s\" line=\"%u\"", "Stack entered at %p in %s on line %u", EG(current_execute_data)->func->op_array.opcodes, filename, lineno);
- zval_dtor(&fname);
- zval_dtor(&exception);
+ zval_dtor(&fci.function_name);
+ zend_clear_exception(TSRMLS_C);
} /* }}} */
PHPDBG_COMMAND(run) /* {{{ */
{
- if (EG(in_execution)) {
+ if (PHPDBG_G(in_execution)) {
phpdbg_error("inactive", "type=\"isrunning\"", "Cannot start another execution while one is in progress");
return SUCCESS;
}
if (PHPDBG_G(ops) || PHPDBG_G(exec)) {
- zend_op **orig_opline = EG(opline_ptr);
- zend_op_array *orig_op_array = EG(active_op_array);
- zval **orig_retval_ptr = EG(return_value_ptr_ptr);
- zend_bool restore = 1;
zend_execute_data *ex = EG(current_execute_data);
+ zend_bool restore = 1;
if (!PHPDBG_G(ops)) {
if (phpdbg_compile(TSRMLS_C) == FAILURE) {
@@ -588,21 +556,16 @@ PHPDBG_COMMAND(run) /* {{{ */
}
}
- EG(active_op_array) = PHPDBG_G(ops);
- EG(return_value_ptr_ptr) = &PHPDBG_G(retval);
- if (!EG(active_symbol_table)) {
- zend_rebuild_symbol_table(TSRMLS_C);
- }
-
/* clean up from last execution */
if (ex && ex->symbol_table) {
- zend_hash_clean(ex->symbol_table);
+ zend_hash_clean(&ex->symbol_table->ht);
+ } else {
+ zend_rebuild_symbol_table(TSRMLS_C);
}
/* clean seek state */
PHPDBG_G(flags) &= ~PHPDBG_SEEK_MASK;
- zend_hash_clean(
- &PHPDBG_G(seek));
+ zend_hash_clean(&PHPDBG_G(seek));
/* reset hit counters */
phpdbg_reset_breakpoints(TSRMLS_C);
@@ -634,14 +597,11 @@ PHPDBG_COMMAND(run) /* {{{ */
zend_try {
PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE;
- zend_execute(EG(active_op_array) TSRMLS_CC);
+ zend_execute(PHPDBG_G(ops), &PHPDBG_G(retval) TSRMLS_CC);
PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE;
phpdbg_notice("stop", "type=\"normal\"", "Script ended normally");
} zend_catch {
- EG(active_op_array) = orig_op_array;
- EG(opline_ptr) = orig_opline;
- EG(return_value_ptr_ptr) = orig_retval_ptr;
-
+ PHPDBG_G(in_execution) = 0;
if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
phpdbg_error("stop", "type=\"bailout\"", "Caught exit/error from VM");
restore = 0;
@@ -657,10 +617,6 @@ PHPDBG_COMMAND(run) /* {{{ */
if (EG(exception)) {
phpdbg_handle_exception(TSRMLS_C);
}
-
- EG(active_op_array) = orig_op_array;
- EG(opline_ptr) = orig_opline;
- EG(return_value_ptr_ptr) = orig_retval_ptr;
}
} else {
phpdbg_error("inactive", "type=\"nocontext\"", "Nothing to execute!");
@@ -671,10 +627,10 @@ out:
return SUCCESS;
} /* }}} */
-int phpdbg_output_ev_variable(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval **zv TSRMLS_DC) {
+int phpdbg_output_ev_variable(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval *zv TSRMLS_DC) {
phpdbg_notice("eval", "variable=\"%.*s\"", "Printing variable %.*s", (int) len, name);
phpdbg_xml("<eval %r>");
- zend_print_zval_r(*zv, 0 TSRMLS_CC);
+ zend_print_zval_r(zv, 0 TSRMLS_CC);
phpdbg_xml("</eval>");
phpdbg_out("\n");
@@ -691,7 +647,7 @@ PHPDBG_COMMAND(ev) /* {{{ */
if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) {
phpdbg_try_access {
- phpdbg_parse_variable(param->str, param->len, &EG(symbol_table), 0, phpdbg_output_ev_variable, 0 TSRMLS_CC);
+ phpdbg_parse_variable(param->str, param->len, &EG(symbol_table).ht, 0, phpdbg_output_ev_variable, 0 TSRMLS_CC);
} phpdbg_catch_access {
phpdbg_error("signalsegv", "", "Could not fetch data, invalid data source");
} phpdbg_end_try_access();
@@ -705,16 +661,16 @@ PHPDBG_COMMAND(ev) /* {{{ */
/* disable stepping while eval() in progress */
PHPDBG_G(flags) |= PHPDBG_IN_EVAL;
zend_try {
- if (zend_eval_stringl(param->str, param->len,&retval, "eval()'d code" TSRMLS_CC) == SUCCESS) {
+ if (zend_eval_stringl(param->str, param->len, &retval, "eval()'d code" TSRMLS_CC) == SUCCESS) {
phpdbg_xml("<eval %r>");
if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) {
zval *zvp = &retval;
- phpdbg_xml_var_dump(&zvp TSRMLS_CC);
+ phpdbg_xml_var_dump(zvp TSRMLS_CC);
}
zend_print_zval_r(&retval, 0 TSRMLS_CC);
phpdbg_xml("</eval>");
phpdbg_out("\n");
- zval_dtor(&retval);
+ zval_ptr_dtor(&retval);
}
} zend_end_try();
PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL;
@@ -731,7 +687,7 @@ PHPDBG_COMMAND(ev) /* {{{ */
PHPDBG_COMMAND(back) /* {{{ */
{
- if (!EG(in_execution)) {
+ if (!PHPDBG_G(in_execution)) {
phpdbg_error("inactive", "type=\"noexec\"", "Not executing!");
return SUCCESS;
}
@@ -771,8 +727,8 @@ PHPDBG_COMMAND(print) /* {{{ */
phpdbg_writeln("print", "vars=\"%d\"", "Variables %d", PHPDBG_G(ops)->last_var ? PHPDBG_G(ops)->last_var - 1 : 0);
}
- phpdbg_writeln("print", "executing=\"%d\"", "Executing %s", EG(in_execution) ? "yes" : "no");
- if (EG(in_execution)) {
+ phpdbg_writeln("print", "executing=\"%d\"", "Executing %s", PHPDBG_G(in_execution) ? "yes" : "no");
+ if (PHPDBG_G(in_execution)) {
phpdbg_writeln("print", "vmret=\"%d\"", "VM Return %d", PHPDBG_G(vmret));
}
@@ -939,7 +895,7 @@ PHPDBG_API const char *phpdbg_load_module_or_extension(char **path, char **name
*name = new_extension->name;
- zend_register_extension(new_extension, handle);
+ zend_register_extension(new_extension, handle TSRMLS_CC);
if (new_extension->startup) {
if (new_extension->startup(new_extension) != SUCCESS) {
@@ -1080,9 +1036,9 @@ PHPDBG_COMMAND(register) /* {{{ */
char *lcname = zend_str_tolower_dup(param->str, param->len);
size_t lcname_len = strlen(lcname);
- if (!zend_hash_exists(&PHPDBG_G(registered), lcname, lcname_len+1)) {
- if (zend_hash_find(EG(function_table), lcname, lcname_len+1, (void**) &function) == SUCCESS) {
- zend_hash_update(&PHPDBG_G(registered), lcname, lcname_len+1, (void*)&function, sizeof(zend_function), NULL);
+ if (!zend_hash_str_exists(&PHPDBG_G(registered), lcname, lcname_len)) {
+ if ((function = zend_hash_str_find_ptr(EG(function_table), lcname, lcname_len))) {
+ zend_hash_str_update_ptr(&PHPDBG_G(registered), lcname, lcname_len, function);
function_add_ref(function);
phpdbg_notice("register", "function=\"%s\"", "Registered %s", lcname);
@@ -1110,7 +1066,7 @@ PHPDBG_COMMAND(quit) /* {{{ */
PHPDBG_COMMAND(clean) /* {{{ */
{
- if (EG(in_execution)) {
+ if (PHPDBG_G(in_execution)) {
phpdbg_error("inactive", "type=\"isrunning\"", "Cannot clean environment while executing");
return SUCCESS;
}
@@ -1230,7 +1186,7 @@ int phpdbg_interactive(zend_bool allow_async_unsafe TSRMLS_DC) /* {{{ */
case PHPDBG_NEXT: {
phpdbg_activate_err_buf(0 TSRMLS_CC);
phpdbg_free_err_buf(TSRMLS_C);
- if (!EG(in_execution) && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
+ if (!PHPDBG_G(in_execution) && !(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
phpdbg_error("command", "type=\"noexec\"", "Not running");
}
goto out;
@@ -1260,7 +1216,7 @@ out:
PHPDBG_G(req_id) = 0;
}
- if (EG(in_execution)) {
+ if (PHPDBG_G(in_execution)) {
phpdbg_restore_frame(TSRMLS_C);
}
@@ -1287,76 +1243,12 @@ void phpdbg_clean(zend_bool full TSRMLS_DC) /* {{{ */
}
} /* }}} */
-static inline zend_execute_data *phpdbg_create_execute_data(zend_op_array *op_array, zend_bool nested TSRMLS_DC) /* {{{ */
-{
-#if PHP_VERSION_ID >= 50500
- return zend_create_execute_data_from_op_array(op_array, nested TSRMLS_CC);
-#else
-
-#undef EX
-#define EX(element) execute_data->element
-#undef EX_CV
-#define EX_CV(var) EX(CVs)[var]
-#undef EX_CVs
-#define EX_CVs() EX(CVs)
-#undef EX_T
-#define EX_T(offset) (*(temp_variable *)((char *) EX(Ts) + offset))
-#undef EX_Ts
-#define EX_Ts() EX(Ts)
-
- zend_execute_data *execute_data = (zend_execute_data *)zend_vm_stack_alloc(
- ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data)) +
- ZEND_MM_ALIGNED_SIZE(sizeof(zval**) * op_array->last_var * (EG(active_symbol_table) ? 1 : 2)) +
- ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T TSRMLS_CC);
-
- EX(CVs) = (zval ***)((char *)execute_data + ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data)));
- memset(EX(CVs), 0, sizeof(zval **) * op_array->last_var);
- EX(Ts) = (temp_variable *)(((char *) EX(CVs)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval **) * op_array->last_var * (EG(active_symbol_table) ? 1 : 2)));
- EX(fbc) = NULL;
- EX(called_scope) = NULL;
- EX(object) = NULL;
- EX(old_error_reporting) = NULL;
- EX(op_array) = op_array;
- EX(symbol_table) = EG(active_symbol_table);
- EX(prev_execute_data) = EG(current_execute_data);
- EG(current_execute_data) = execute_data;
- EX(nested) = nested;
-
- if (!op_array->run_time_cache && op_array->last_cache_slot) {
- op_array->run_time_cache = ecalloc(op_array->last_cache_slot, sizeof(void*));
- }
-
- if (op_array->this_var != -1 && EG(This)) {
- Z_ADDREF_P(EG(This)); /* For $this pointer */
- if (!EG(active_symbol_table)) {
- EX_CV(op_array->this_var) = (zval**) EX_CVs() + (op_array->last_var + op_array->this_var);
- *EX_CV(op_array->this_var) = EG(This);
- } else {
- if (zend_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), (void **) &EX_CV(op_array->this_var))==FAILURE) {
- Z_DELREF_P(EG(This));
- }
- }
- }
-
- EX(opline) = op_array->opcodes;
- EG(opline_ptr) = &EX(opline);
-
- EX(function_state).function = (zend_function *) op_array;
- EX(function_state).arguments = NULL;
-
- return execute_data;
-#endif
-} /* }}} */
-
#define DO_INTERACTIVE(allow_async_unsafe) do { \
if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) { \
- phpdbg_list_file( \
- zend_get_executed_filename(TSRMLS_C), \
- 3, \
- zend_get_executed_lineno(TSRMLS_C)-1, \
- zend_get_executed_lineno(TSRMLS_C) \
- TSRMLS_CC \
- ); \
+ const char *file_char = zend_get_executed_filename(TSRMLS_C); \
+ zend_string *file = zend_string_init(file_char, strlen(file_char), 0); \
+ phpdbg_list_file(file, 3, zend_get_executed_lineno(TSRMLS_C)-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC); \
+ efree(file); \
} \
\
switch (phpdbg_interactive(allow_async_unsafe TSRMLS_CC)) { \
@@ -1369,45 +1261,19 @@ static inline zend_execute_data *phpdbg_create_execute_data(zend_op_array *op_ar
} \
} while (0)
-#if PHP_VERSION_ID >= 50500
void phpdbg_execute_ex(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */
{
-#else
-void phpdbg_execute_ex(zend_op_array *op_array TSRMLS_DC) /* {{{ */
-{
- long long flags = 0;
- zend_ulong address = 0L;
- zend_execute_data *execute_data;
- zend_bool nested = 0;
-#endif
- zend_bool original_in_execution = EG(in_execution);
+ zend_bool original_in_execution = PHPDBG_G(in_execution);
HashTable vars;
-#if PHP_VERSION_ID < 50500
- if (EG(exception)) {
- return;
- }
-#endif
+ zend_hash_init(&vars, execute_data->func->op_array.last, NULL, NULL, 0);
- EG(in_execution) = 1;
-
-#if PHP_VERSION_ID >= 50500
- if (0) {
-zend_vm_enter:
- execute_data = phpdbg_create_execute_data(EG(active_op_array), 1 TSRMLS_CC);
- }
- zend_hash_init(&vars, EG(active_op_array)->last, NULL, NULL, 0);
-#else
-zend_vm_enter:
- execute_data = phpdbg_create_execute_data(op_array, nested TSRMLS_CC);
- nested = 1;
- zend_hash_init(&vars, EG(active_op_array)->last, NULL, NULL, 0);
-#endif
+ PHPDBG_G(in_execution) = 1;
while (1) {
if ((PHPDBG_G(flags) & PHPDBG_BP_RESOLVE_MASK)) {
/* resolve nth opline breakpoints */
- phpdbg_resolve_op_array_breaks(EG(active_op_array) TSRMLS_CC);
+ phpdbg_resolve_op_array_breaks(&execute_data->func->op_array TSRMLS_CC);
}
#ifdef ZEND_WIN32
@@ -1507,38 +1373,19 @@ next:
PHPDBG_G(last_line) = execute_data->opline->lineno;
/* stupid hack to make zend_do_fcall_common_helper return ZEND_VM_ENTER() instead of recursively calling zend_execute() and eventually segfaulting */
- if ((execute_data->opline->opcode == ZEND_DO_FCALL_BY_NAME || execute_data->opline->opcode == ZEND_DO_FCALL) && execute_data->function_state.function->type == ZEND_USER_FUNCTION) {
-#if PHP_VERSION_ID < 50500
- zend_execute = execute;
-#else
+ if (execute_data->opline->opcode == ZEND_DO_FCALL && execute_data->func->type == ZEND_USER_FUNCTION) {
zend_execute_ex = execute_ex;
-#endif
}
PHPDBG_G(vmret) = execute_data->opline->handler(execute_data TSRMLS_CC);
-#if PHP_VERSION_ID < 50500
- zend_execute = phpdbg_execute_ex;
-#else
zend_execute_ex = phpdbg_execute_ex;
-#endif
- if (PHPDBG_G(vmret) > 0) {
- switch (PHPDBG_G(vmret)) {
- case 1:
- EG(in_execution) = original_in_execution;
- zend_hash_destroy(&vars);
- return;
- case 2:
-#if PHP_VERSION_ID < 50500
- op_array = EG(active_op_array);
-#endif
- zend_hash_destroy(&vars);
- goto zend_vm_enter;
- break;
- case 3:
- execute_data = EG(current_execute_data);
- break;
- default:
- break;
+ if (PHPDBG_G(vmret) != 0) {
+ if (PHPDBG_G(vmret) < 0) {
+ zend_hash_destroy(&vars);
+ PHPDBG_G(in_execution) = original_in_execution;
+ return;
+ } else {
+ execute_data = EG(current_execute_data);
}
}
}
@@ -1552,8 +1399,8 @@ void phpdbg_force_interruption(TSRMLS_D) {
PHPDBG_G(flags) |= PHPDBG_IN_SIGNAL_HANDLER;
if (data) {
- if (data->op_array) {
- phpdbg_notice("hardinterrupt", "opline=\"%p\" num=\"%lu\" file=\"%s\" line=\"%u\"", "Current opline: %p (op #%lu) in %s:%u", data->opline, (data->opline - data->op_array->opcodes) / sizeof(data->opline), data->op_array->filename, data->opline->lineno);
+ if (data->func) {
+ phpdbg_notice("hardinterrupt", "opline=\"%p\" num=\"%lu\" file=\"%s\" line=\"%u\"", "Current opline: %p (op #%lu) in %s:%u", data->opline, (data->opline - data->func->op_array.opcodes) / sizeof(data->opline), data->func->op_array.filename, data->opline->lineno);
} else {
phpdbg_notice("hardinterrupt", "opline=\"%p\"", "Current opline: %p (op_array information unavailable)", data->opline);
}
diff --git a/sapi/phpdbg/phpdbg_rinit_hook.c b/sapi/phpdbg/phpdbg_rinit_hook.c
index 049a782d9d..1bf891654d 100644
--- a/sapi/phpdbg/phpdbg_rinit_hook.c
+++ b/sapi/phpdbg/phpdbg_rinit_hook.c
@@ -45,10 +45,10 @@ static PHP_MINIT_FUNCTION(phpdbg_webhelper) /* {{{ */
static PHP_RINIT_FUNCTION(phpdbg_webhelper) /* {{{ */
{
- zval *cookies = PG(http_globals)[TRACK_VARS_COOKIE];
- zval **auth;
+ zval cookies = PG(http_globals)[TRACK_VARS_COOKIE];
+ zval *auth;
- if (!cookies || zend_hash_find(Z_ARRVAL_P(cookies), PHPDBG_NAME "_AUTH_COOKIE", sizeof(PHPDBG_NAME "_AUTH_COOKIE"), (void **) &auth) == FAILURE || Z_STRLEN_PP(auth) != strlen(PHPDBG_WG(auth)) || strcmp(Z_STRVAL_PP(auth), PHPDBG_WG(auth))) {
+ if (Z_TYPE(cookies) == IS_ARRAY || (auth = zend_hash_str_find(Z_ARRVAL(cookies), PHPDBG_NAME "_AUTH_COOKIE", sizeof(PHPDBG_NAME "_AUTH_COOKIE"))) || Z_STRLEN_P(auth) != strlen(PHPDBG_WG(auth)) || strcmp(Z_STRVAL_P(auth), PHPDBG_WG(auth))) {
return SUCCESS;
}
diff --git a/sapi/phpdbg/phpdbg_set.c b/sapi/phpdbg/phpdbg_set.c
index fc7e788fa0..82b9f69f7a 100644
--- a/sapi/phpdbg/phpdbg_set.c
+++ b/sapi/phpdbg/phpdbg_set.c
@@ -215,9 +215,9 @@ PHPDBG_SET(stepping) /* {{{ */
phpdbg_writeln("setstepping", "type=\"%s\"", "Stepping %s", PHPDBG_G(flags) & PHPDBG_STEP_OPCODE ? "opcode" : "line");
} else switch (param->type) {
case STR_PARAM: {
- if ((param->len == sizeof("opcode") - 1) && memcmp(param->str, "opcode", sizeof("opcode")) == SUCCESS) {
+ if (param->len == sizeof("opcode") - 1 && !memcmp(param->str, "opcode", sizeof("opcode"))) {
PHPDBG_G(flags) |= PHPDBG_STEP_OPCODE;
- } else if ((param->len == sizeof("line")-1) && memcmp(param->str, "line", sizeof("line")) == SUCCESS) {
+ } else if (param->len == sizeof("line") - 1 && !memcmp(param->str, "line", sizeof("line"))) {
PHPDBG_G(flags) &= ~PHPDBG_STEP_OPCODE;
} else {
phpdbg_error("setstepping", "type=\"wrongargs\"", "usage set stepping [<opcode|line>]");
diff --git a/sapi/phpdbg/phpdbg_sigsafe.c b/sapi/phpdbg/phpdbg_sigsafe.c
index 7238ad102f..1ca7bf230c 100644
--- a/sapi/phpdbg/phpdbg_sigsafe.c
+++ b/sapi/phpdbg/phpdbg_sigsafe.c
@@ -3,50 +3,15 @@
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
-static inline void zend_mm_init(zend_mm_heap *heap) {
- zend_mm_free_block *p;
- int i;
-
- heap->free_bitmap = 0;
- heap->large_free_bitmap = 0;
-#if ZEND_MM_CACHE
- heap->cached = 0;
- memset(heap->cache, 0, sizeof(heap->cache));
-#endif
-#if ZEND_MM_CACHE_STAT
- for (i = 0; i < ZEND_MM_NUM_BUCKETS; i++) {
- heap->cache_stat[i].count = 0;
- }
-#endif
- p = ZEND_MM_SMALL_FREE_BUCKET(heap, 0);
- for (i = 0; i < ZEND_MM_NUM_BUCKETS; i++) {
- p->next_free_block = p;
- p->prev_free_block = p;
- p = (zend_mm_free_block *)((char *)p + sizeof(zend_mm_free_block *) * 2);
- heap->large_free_buckets[i] = NULL;
- }
- heap->rest_buckets[0] = heap->rest_buckets[1] = ZEND_MM_REST_BUCKET(heap);
- heap->rest_count = 0;
-}
-
-static zend_mm_storage* zend_mm_mem_init(void *params) {
- TSRMLS_FETCH();
-
- return &PHPDBG_G(sigsafe_mem).storage;
-}
-
-static void zend_mm_mem_dummy(zend_mm_storage *storage) {
-}
-
#define STR(x) #x
#define EXP_STR(x) STR(x)
-static zend_mm_segment* zend_mm_mem_alloc(zend_mm_storage *storage, size_t size) {
+static void* zend_mm_mem_alloc(zend_mm_storage *storage, size_t size, size_t alignment) {
TSRMLS_FETCH();
if (EXPECTED(size == PHPDBG_SIGSAFE_MEM_SIZE && !PHPDBG_G(sigsafe_mem).allocated)) {
PHPDBG_G(sigsafe_mem).allocated = 1;
- return (zend_mm_segment *) PHPDBG_G(sigsafe_mem).mem;
+ return PHPDBG_G(sigsafe_mem).mem;
}
write(PHPDBG_G(io)[PHPDBG_STDERR].fd, ZEND_STRL("Tried to allocate more than " EXP_STR(PHPDBG_SIGSAFE_MEM_SIZE) " bytes from stack memory in signal handler ... bailing out of signal handler\n"));
@@ -60,40 +25,20 @@ static zend_mm_segment* zend_mm_mem_alloc(zend_mm_storage *storage, size_t size)
return NULL;
}
-static zend_mm_segment* zend_mm_mem_realloc(zend_mm_storage *storage, zend_mm_segment *ptr, size_t size) {
- return zend_mm_mem_alloc(storage, size);
-}
-
-static void zend_mm_mem_free(zend_mm_storage *storage, zend_mm_segment *ptr) {
+static void zend_mm_mem_free(zend_mm_storage *storage, void *ptr, size_t size) {
}
-static const zend_mm_mem_handlers phpdbg_handlers_sigsafe_mem = { "stack", zend_mm_mem_init, zend_mm_mem_dummy, zend_mm_mem_dummy, zend_mm_mem_alloc, zend_mm_mem_realloc, zend_mm_mem_free };
-
void phpdbg_set_sigsafe_mem(char *buffer TSRMLS_DC) {
phpdbg_signal_safe_mem *mem = &PHPDBG_G(sigsafe_mem);
- mem->old_heap = zend_mm_set_heap(&mem->heap TSRMLS_CC);
mem->mem = buffer;
mem->allocated = 0;
- mem->storage.handlers = &phpdbg_handlers_sigsafe_mem;
- mem->heap.storage = &mem->storage;
- mem->heap.block_size = PHPDBG_SIGSAFE_MEM_SIZE;
- mem->heap.compact_size = 0;
- mem->heap.segments_list = NULL;
- zend_mm_init(&mem->heap);
-#if ZEND_MM_CACHE_STAT
- memset(mem->heap.cache_stat, 0, sizeof(mem->heap.cache_stat));
-#endif
- mem->heap.use_zend_alloc = 1;
- mem->heap.real_size = 0;
- mem->heap.overflow = 0;
- mem->heap.real_peak = 0;
- mem->heap.limit = PHPDBG_SIGSAFE_MEM_SIZE;
- mem->heap.size = 0;
- mem->heap.peak = 0;
- mem->heap.internal = 0;
- mem->heap.reserve = NULL;
- mem->heap.reserve_size = 0;
+ mem->storage.chunk_alloc = zend_mm_mem_alloc;
+ mem->storage.chunk_free = zend_mm_mem_free;
+
+ mem->heap = zend_mm_startup_ex(&mem->storage);
+
+ mem->old_heap = zend_mm_set_heap(mem->heap TSRMLS_CC);
}
zend_mm_heap *phpdbg_original_heap_sigsafe_mem(TSRMLS_D) {
diff --git a/sapi/phpdbg/phpdbg_sigsafe.h b/sapi/phpdbg/phpdbg_sigsafe.h
index 6ed74f53db..9ef723fdca 100644
--- a/sapi/phpdbg/phpdbg_sigsafe.h
+++ b/sapi/phpdbg/phpdbg_sigsafe.h
@@ -1,14 +1,17 @@
#ifndef PHPDBG_SIGSAFE_H
#define PHPDBG_SIGSAFE_H
-#include "zend_mm_structs.h"
+//#include "zend_mm_structs.h"
-#define PHPDBG_SIGSAFE_MEM_SIZE (1 << 20)
+#define PHPDBG_SIGSAFE_MEM_SIZE ZEND_MM_CHUNK_SIZE
+//(1 << 20)
+
+#include "zend.h"
typedef struct {
char *mem;
zend_bool allocated;
- zend_mm_heap heap;
+ zend_mm_heap *heap;
zend_mm_heap *old_heap;
zend_mm_storage storage;
} phpdbg_signal_safe_mem;
diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c
index 85b6eeb3b5..bff971d4cf 100644
--- a/sapi/phpdbg/phpdbg_utils.c
+++ b/sapi/phpdbg/phpdbg_utils.c
@@ -165,27 +165,25 @@ PHPDBG_API const char *phpdbg_current_file(TSRMLS_D) /* {{{ */
PHPDBG_API const zend_function *phpdbg_get_function(const char *fname, const char *cname TSRMLS_DC) /* {{{ */
{
zend_function *func = NULL;
- size_t fname_len = strlen(fname);
- char *lcname = zend_str_tolower_dup(fname, fname_len);
+ zend_string *lfname = zend_string_alloc(strlen(fname), 0);
+ memcpy(lfname->val, zend_str_tolower_dup(fname, lfname->len), lfname->len + 1);
if (cname) {
- zend_class_entry **ce;
- size_t cname_len = strlen(cname);
- char *lc_cname = zend_str_tolower_dup(cname, cname_len);
- int ret = zend_lookup_class(lc_cname, cname_len, &ce TSRMLS_CC);
+ zend_class_entry *ce;
+ zend_string *lcname = zend_string_alloc(strlen(cname), 0);
+ memcpy(lcname->val, zend_str_tolower_dup(cname, lcname->len), lcname->len + 1);
+ ce = zend_lookup_class(lcname TSRMLS_CC);
- efree(lc_cname);
+ efree(lcname);
- if (ret == SUCCESS) {
- zend_hash_find(&(*ce)->function_table, lcname, fname_len+1,
- (void**)&func);
+ if (ce) {
+ func = zend_hash_find_ptr(&ce->function_table, lfname);
}
} else {
- zend_hash_find(EG(function_table), lcname, fname_len+1,
- (void**)&func);
+ func = zend_hash_find_ptr(EG(function_table), lfname);
}
- efree(lcname);
+ efree(lfname);
return func;
} /* }}} */
@@ -315,18 +313,14 @@ PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D) /* {{{ */
} /* }}} */
int phpdbg_rebuild_symtable(TSRMLS_D) {
- if (!EG(active_op_array)) {
+ if (!EG(current_execute_data) || !EG(current_execute_data)->func) {
phpdbg_error("inactive", "type=\"op_array\"", "No active op array!");
return FAILURE;
}
- if (!EG(active_symbol_table)) {
- zend_rebuild_symbol_table(TSRMLS_C);
-
- if (!EG(active_symbol_table)) {
- phpdbg_error("inactive", "type=\"symbol_table\"", "No active symbol table!");
- return FAILURE;
- }
+ if (!zend_rebuild_symbol_table(TSRMLS_C)) {
+ phpdbg_error("inactive", "type=\"symbol_table\"", "No active symbol table!");
+ return FAILURE;
}
return SUCCESS;
@@ -359,10 +353,10 @@ PHPDBG_API void phpdbg_set_async_io(int fd) {
#endif
}
-int phpdbg_safe_class_lookup(const char *name, int name_length, zend_class_entry ***ce TSRMLS_DC) {
+int phpdbg_safe_class_lookup(const char *name, int name_length, zend_class_entry **ce TSRMLS_DC) {
if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) {
char *lc_name, *lc_free;
- int lc_length, ret = FAILURE;
+ int lc_length;
if (name == NULL || !name_length) {
return FAILURE;
@@ -378,16 +372,19 @@ int phpdbg_safe_class_lookup(const char *name, int name_length, zend_class_entry
}
phpdbg_try_access {
- ret = zend_hash_find(EG(class_table), lc_name, lc_length, (void **) &ce);
+ *ce = zend_hash_str_find_ptr(EG(class_table), lc_name, lc_length);
} phpdbg_catch_access {
phpdbg_error("signalsegv", "class=\"%.*s\"", "Could not fetch class %.*s, invalid data source", name_length, name);
} phpdbg_end_try_access();
efree(lc_free);
- return ret;
} else {
- return zend_lookup_class(name, name_length, ce TSRMLS_CC);
+ zend_string *str_name = zend_string_init(name, name_length, 0);
+ *ce = zend_lookup_class(str_name TSRMLS_CC);
+ efree(str_name);
}
+
+ return ce ? SUCCESS : FAILURE;
}
char *phpdbg_get_property_key(char *key) {
@@ -397,7 +394,7 @@ char *phpdbg_get_property_key(char *key) {
return strchr(key + 1, 0) + 1;
}
-static int phpdbg_parse_variable_arg_wrapper(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval **zv, phpdbg_parse_var_func callback TSRMLS_DC) {
+static int phpdbg_parse_variable_arg_wrapper(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval *zv, phpdbg_parse_var_func callback TSRMLS_DC) {
return callback(name, len, keyname, keylen, parent, zv TSRMLS_CC);
}
@@ -410,7 +407,7 @@ PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable
zend_bool new_index = 1;
char *last_index;
size_t index_len = 0;
- zval **zv;
+ zval *zv;
if (len < 2 || *input != '$') {
goto error;
@@ -446,50 +443,64 @@ PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable
}
if (new_index && index_len == 0) {
- HashPosition position;
- for (zend_hash_internal_pointer_reset_ex(parent, &position);
- zend_hash_get_current_data_ex(parent, (void **)&zv, &position) == SUCCESS;
- zend_hash_move_forward_ex(parent, &position)) {
+ zend_ulong numkey;
+ zend_string *strkey;
+ ZEND_HASH_FOREACH_KEY_PTR(parent, numkey, strkey, zv) {
+ while (Z_TYPE_P(zv) == IS_INDIRECT) {
+ zv = Z_INDIRECT_P(zv);
+ }
+
if (i == len || (i == len - 1 && input[len - 1] == ']')) {
- zval *key = emalloc(sizeof(zval));
- size_t namelen;
+ char *key, *propkey;
+ size_t namelen, keylen;
char *name;
char *keyname = estrndup(last_index, index_len);
- zend_hash_get_current_key_zval_ex(parent, key, &position);
- convert_to_string(key);
- name = emalloc(i + Z_STRLEN_P(key) + 2);
- namelen = sprintf(name, "%.*s%s%s", (int)i, input, phpdbg_get_property_key(Z_STRVAL_P(key)), input[len - 1] == ']'?"]":"");
- efree(key);
+ if (strkey) {
+ key = strkey->val;
+ keylen = strkey->len;
+ } else {
+ keylen = spprintf(&key, 0, "%llu", numkey);
+ }
+ propkey = phpdbg_get_property_key(key);
+ name = emalloc(i + keylen + 2);
+ namelen = sprintf(name, "%.*s%.*s%s", (int) i, input, keylen - (propkey - key), propkey, input[len - 1] == ']'?"]":"");
+ if (!strkey) {
+ efree(key);
+ }
ret = callback(name, namelen, keyname, index_len, parent, zv, arg TSRMLS_CC) == SUCCESS || ret == SUCCESS?SUCCESS:FAILURE;
- } else if (Z_TYPE_PP(zv) == IS_OBJECT) {
- phpdbg_parse_variable_with_arg(input, len, Z_OBJPROP_PP(zv), i, callback, silent, arg TSRMLS_CC);
- } else if (Z_TYPE_PP(zv) == IS_ARRAY) {
- phpdbg_parse_variable_with_arg(input, len, Z_ARRVAL_PP(zv), i, callback, silent, arg TSRMLS_CC);
+ } else if (Z_TYPE_P(zv) == IS_OBJECT) {
+ phpdbg_parse_variable_with_arg(input, len, Z_OBJPROP_P(zv), i, callback, silent, arg TSRMLS_CC);
+ } else if (Z_TYPE_P(zv) == IS_ARRAY) {
+ phpdbg_parse_variable_with_arg(input, len, Z_ARRVAL_P(zv), i, callback, silent, arg TSRMLS_CC);
} else {
/* Ignore silently */
}
- }
+ } ZEND_HASH_FOREACH_END();
return ret;
} else if (new_index) {
char last_chr = last_index[index_len];
last_index[index_len] = 0;
- if (zend_symtable_find(parent, last_index, index_len + 1, (void **)&zv) == FAILURE) {
+ if (!(zv = zend_symtable_str_find(parent, last_index, index_len))) {
if (!silent) {
phpdbg_error("variable", "type=\"undefined\" variable=\"%.*s\"", "%.*s is undefined", (int) i, input);
}
return FAILURE;
}
+ while (Z_TYPE_P(zv) == IS_INDIRECT) {
+ zv = Z_INDIRECT_P(zv);
+ }
+
last_index[index_len] = last_chr;
if (i == len) {
char *name = estrndup(input, len);
char *keyname = estrndup(last_index, index_len);
ret = callback(name, len, keyname, index_len, parent, zv, arg TSRMLS_CC) == SUCCESS || ret == SUCCESS?SUCCESS:FAILURE;
- } else if (Z_TYPE_PP(zv) == IS_OBJECT) {
- parent = Z_OBJPROP_PP(zv);
- } else if (Z_TYPE_PP(zv) == IS_ARRAY) {
- parent = Z_ARRVAL_PP(zv);
+ } else if (Z_TYPE_P(zv) == IS_OBJECT) {
+ parent = Z_OBJPROP_P(zv);
+ } else if (Z_TYPE_P(zv) == IS_ARRAY) {
+ parent = Z_ARRVAL_P(zv);
} else {
phpdbg_error("variable", "type=\"notiterable\" variable=\"%.*s\"", "%.*s is nor an array nor an object", (int) i, input);
return FAILURE;
@@ -504,14 +515,22 @@ PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable
return FAILURE;
}
-static int phpdbg_xml_array_element_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) {
+int phpdbg_is_auto_global(char *name, int len TSRMLS_DC) {
+ int ret;
+ zend_string *str = zend_string_init(name, len, 0);
+ ret = zend_is_auto_global(str TSRMLS_CC);
+ efree(str);
+ return ret;
+}
+
+static int phpdbg_xml_array_element_dump(zval *zv, zend_string *key, zend_ulong num TSRMLS_DC) {
phpdbg_xml("<element");
phpdbg_try_access {
- if (hash_key->nKeyLength == 0) { /* numeric key */
- phpdbg_xml(" name=\"%ld\"", hash_key->h);
- } else { /* string key */
- phpdbg_xml(" name=\"%.*s\"", hash_key->nKeyLength - 1, hash_key->arKey);
+ if (key) { /* string key */
+ phpdbg_xml(" name=\"%.*s\"", key->len, key->val);
+ } else { /* numeric key */
+ phpdbg_xml(" name=\"%ld\"", num);
}
} phpdbg_catch_access {
phpdbg_xml(" severity=\"error\" ></element>");
@@ -527,15 +546,13 @@ static int phpdbg_xml_array_element_dump(zval **zv TSRMLS_DC, int num_args, va_l
return 0;
}
-static int phpdbg_xml_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) {
+static int phpdbg_xml_object_property_dump(zval *zv, zend_string *key, zend_ulong num TSRMLS_DC) {
phpdbg_xml("<property");
phpdbg_try_access {
- if (hash_key->nKeyLength == 0) { /* numeric key */
- phpdbg_xml(" name=\"%ld\"", hash_key->h);
- } else { /* string key */
+ if (key) { /* string key */
const char *prop_name, *class_name;
- int unmangle = zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength - 1, &class_name, &prop_name);
+ int unmangle = zend_unmangle_property_name(key, &class_name, &prop_name);
if (class_name && unmangle == SUCCESS) {
phpdbg_xml(" name=\"%s\"", prop_name);
@@ -545,8 +562,10 @@ static int phpdbg_xml_object_property_dump(zval **zv TSRMLS_DC, int num_args, va
phpdbg_xml(" class=\"%s\" protection=\"private\"", class_name);
}
} else {
- phpdbg_xml(" name=\"%.*s\" protection=\"public\"", hash_key->nKeyLength - 1, hash_key->arKey);
+ phpdbg_xml(" name=\"%.*s\" protection=\"public\"", key->len, key->val);
}
+ } else { /* numeric key */
+ phpdbg_xml(" name=\"%ld\" protection=\"public\"", num);
}
} phpdbg_catch_access {
phpdbg_xml(" severity=\"error\" ></property>");
@@ -562,37 +581,46 @@ static int phpdbg_xml_object_property_dump(zval **zv TSRMLS_DC, int num_args, va
return 0;
}
-#define COMMON (Z_ISREF_PP(zv) ? "&" : "")
+#define COMMON (is_ref ? "&" : "")
-PHPDBG_API void phpdbg_xml_var_dump(zval **zv TSRMLS_DC) {
+PHPDBG_API void phpdbg_xml_var_dump(zval *zv TSRMLS_DC) {
HashTable *myht;
- const char *class_name;
- zend_uint class_name_len;
- int (*element_dump_func)(zval** TSRMLS_DC, int, va_list, zend_hash_key*);
+ zend_string *class_name, *key;
+ zend_ulong num;
+ zval *val;
+ int (*element_dump_func)(zval *zv, zend_string *key, zend_ulong num TSRMLS_DC);
+ zend_bool is_ref = 0;
+
int is_temp;
phpdbg_try_access {
- switch (Z_TYPE_PP(zv)) {
- case IS_BOOL:
- phpdbg_xml("<bool refstatus=\"%s\" value=\"%s\" />", COMMON, Z_LVAL_PP(zv) ? "true" : "false");
+ is_ref = Z_ISREF_P(zv) && GC_REFCOUNT(Z_COUNTED_P(zv)) > 1;
+ ZVAL_DEREF(zv);
+
+ switch (Z_TYPE_P(zv)) {
+ case IS_TRUE:
+ phpdbg_xml("<bool refstatus=\"%s\" value=\"true\" />", COMMON);
+ break;
+ case IS_FALSE:
+ phpdbg_xml("<bool refstatus=\"%s\" value=\"false\" />", COMMON);
break;
case IS_NULL:
phpdbg_xml("<null refstatus=\"%s\" />", COMMON);
break;
case IS_LONG:
- phpdbg_xml("<int refstatus=\"%s\" value=\"%ld\" />", COMMON, Z_LVAL_PP(zv));
+ phpdbg_xml("<int refstatus=\"%s\" value=\"" ZEND_LONG_FMT "\" />", COMMON, Z_LVAL_P(zv));
break;
case IS_DOUBLE:
- phpdbg_xml("<float refstatus=\"%s\" value=\"%.*G\" />", COMMON, (int) EG(precision), Z_DVAL_PP(zv));
+ phpdbg_xml("<float refstatus=\"%s\" value=\"%.*G\" />", COMMON, (int) EG(precision), Z_DVAL_P(zv));
break;
case IS_STRING:
- phpdbg_xml("<string refstatus=\"%s\" length=\"%d\" value=\"%.*s\" />", COMMON, Z_STRLEN_PP(zv), Z_STRLEN_PP(zv), Z_STRVAL_PP(zv));
- break;
+ phpdbg_xml("<string refstatus=\"%s\" length=\"%d\" value=\"%.*s\" />", COMMON, Z_STRLEN_P(zv), Z_STRLEN_P(zv), Z_STRVAL_P(zv));
+ break;
case IS_ARRAY:
- myht = Z_ARRVAL_PP(zv);
- if (++myht->nApplyCount > 1) {
+ myht = Z_ARRVAL_P(zv);
+ if (ZEND_HASH_APPLY_PROTECTION(myht) && ++myht->u.v.nApplyCount > 1) {
phpdbg_xml("<recursion />");
- --myht->nApplyCount;
+ --myht->u.v.nApplyCount;
break;
}
phpdbg_xml("<array refstatus=\"%s\" num=\"%d\">", COMMON, zend_hash_num_elements(myht));
@@ -600,39 +628,39 @@ PHPDBG_API void phpdbg_xml_var_dump(zval **zv TSRMLS_DC) {
is_temp = 0;
goto head_done;
case IS_OBJECT:
- myht = Z_OBJDEBUG_PP(zv, is_temp);
- if (myht && ++myht->nApplyCount > 1) {
+ myht = Z_OBJDEBUG_P(zv, is_temp);
+ if (myht && ++myht->u.v.nApplyCount > 1) {
phpdbg_xml("<recursion />");
- --myht->nApplyCount;
+ --myht->u.v.nApplyCount;
break;
}
-
- if (Z_OBJ_HANDLER(**zv, get_class_name)) {
- Z_OBJ_HANDLER(**zv, get_class_name)(*zv, &class_name, &class_name_len, 0 TSRMLS_CC);
- phpdbg_xml("<object refstatus=\"%s\" class=\"%s\" id=\"%d\" num=\"%d\">", COMMON, class_name, Z_OBJ_HANDLE_PP(zv), myht ? zend_hash_num_elements(myht) : 0);
- efree((char*)class_name);
- } else {
- phpdbg_xml("<object refstatus=\"%s\" class=\"\" id=\"%d\" num=\"%d\">", COMMON, Z_OBJ_HANDLE_PP(zv), myht ? zend_hash_num_elements(myht) : 0);
- }
+
+ class_name = Z_OBJ_HANDLER_P(zv, get_class_name)(Z_OBJ_P(zv) TSRMLS_CC);
+ phpdbg_xml("<object refstatus=\"%s\" class=\"%.*s\" id=\"%d\" num=\"%d\">", COMMON, class_name->len, class_name->val, Z_OBJ_HANDLE_P(zv), myht ? zend_hash_num_elements(myht) : 0);
+ zend_string_release(class_name);
+
element_dump_func = phpdbg_xml_object_property_dump;
head_done:
if (myht) {
+ ZEND_HASH_FOREACH_KEY_VAL_IND(myht, num, key, val) {
+ element_dump_func(val, key, num TSRMLS_CC);
+ } ZEND_HASH_FOREACH_END();
zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) element_dump_func, 0);
- --myht->nApplyCount;
+ --myht->u.v.nApplyCount;
if (is_temp) {
zend_hash_destroy(myht);
efree(myht);
}
}
- if (Z_TYPE_PP(zv) == IS_ARRAY) {
+ if (Z_TYPE_P(zv) == IS_ARRAY) {
phpdbg_xml("</array>");
} else {
phpdbg_xml("</object>");
}
break;
case IS_RESOURCE: {
- const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(zv) TSRMLS_CC);
- phpdbg_xml("<resource refstatus=\"%s\" id=\"%ld\" type=\"%ld\" />", COMMON, Z_LVAL_PP(zv), type_name ? type_name : "unknown");
+ const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(zv) TSRMLS_CC);
+ phpdbg_xml("<resource refstatus=\"%s\" id=\"%pd\" type=\"%ld\" />", COMMON, Z_RES_P(zv)->handle, type_name ? type_name : "unknown");
break;
}
default:
diff --git a/sapi/phpdbg/phpdbg_utils.h b/sapi/phpdbg/phpdbg_utils.h
index d657dc79fd..83dc8e9694 100644
--- a/sapi/phpdbg/phpdbg_utils.h
+++ b/sapi/phpdbg/phpdbg_utils.h
@@ -80,36 +80,18 @@ PHPDBG_API void phpdbg_set_async_io(int fd);
int phpdbg_rebuild_symtable(TSRMLS_D);
-#if PHP_VERSION_ID < 50500
-/* copy from zend_hash.c PHP 5.5 for 5.4 compatibility */
-static void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos) {
- Bucket *p;
-
- p = pos ? (*pos) : ht->pInternalPointer;
-
- if (!p) {
- Z_TYPE_P(key) = IS_NULL;
- } else if (p->nKeyLength) {
- Z_TYPE_P(key) = IS_STRING;
- Z_STRVAL_P(key) = IS_INTERNED(p->arKey) ? (char*)p->arKey : estrndup(p->arKey, p->nKeyLength - 1);
- Z_STRLEN_P(key) = p->nKeyLength - 1;
- } else {
- Z_TYPE_P(key) = IS_LONG;
- Z_LVAL_P(key) = p->h;
- }
-}
-#endif
-
-int phpdbg_safe_class_lookup(const char *name, int name_length, zend_class_entry ***ce TSRMLS_DC);
+int phpdbg_safe_class_lookup(const char *name, int name_length, zend_class_entry **ce TSRMLS_DC);
char *phpdbg_get_property_key(char *key);
-typedef int (*phpdbg_parse_var_func)(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval **zv TSRMLS_DC);
-typedef int (*phpdbg_parse_var_with_arg_func)(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval **zv, void *arg TSRMLS_DC);
+typedef int (*phpdbg_parse_var_func)(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval *zv TSRMLS_DC);
+typedef int (*phpdbg_parse_var_with_arg_func)(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval *zv, void *arg TSRMLS_DC);
PHPDBG_API int phpdbg_parse_variable(char *input, size_t len, HashTable *parent, size_t i, phpdbg_parse_var_func callback, zend_bool silent TSRMLS_DC);
PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable *parent, size_t i, phpdbg_parse_var_with_arg_func callback, zend_bool silent, void *arg TSRMLS_DC);
-PHPDBG_API void phpdbg_xml_var_dump(zval **zv TSRMLS_DC);
+int phpdbg_is_auto_global(char *name, int len TSRMLS_DC);
+
+PHPDBG_API void phpdbg_xml_var_dump(zval *zv TSRMLS_DC);
#endif /* PHPDBG_UTILS_H */
diff --git a/sapi/phpdbg/phpdbg_wait.c b/sapi/phpdbg/phpdbg_wait.c
index ea506a2d93..9051ca379f 100644
--- a/sapi/phpdbg/phpdbg_wait.c
+++ b/sapi/phpdbg/phpdbg_wait.c
@@ -25,19 +25,19 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
ZEND_EXTERN_MODULE_GLOBALS(json);
static void phpdbg_rebuild_http_globals_array(int type, const char *name TSRMLS_DC) {
- zval **zvpp;
- if (PG(http_globals)[type]) {
- zval_dtor(PG(http_globals)[type]);
+ zval *zvp;
+ if (Z_TYPE(PG(http_globals)[type]) != IS_UNDEF) {
+ zval_dtor(&PG(http_globals)[type]);
}
- if (zend_hash_find(&EG(symbol_table), name, strlen(name) + 1, (void **) &zvpp) == SUCCESS) {
- Z_SET_REFCOUNT_PP(zvpp, 2);
- PG(http_globals)[type] = *zvpp;
+ if ((zvp = zend_hash_str_find(&EG(symbol_table).ht, name, strlen(name)))) {
+ Z_ADDREF_P(zvp);
+ PG(http_globals)[type] = *zvp;
}
}
static int phpdbg_dearm_autoglobals(zend_auto_global *auto_global TSRMLS_DC) {
- if (auto_global->name_len != sizeof("GLOBALS") - 1 || memcmp(auto_global->name, "GLOBALS", sizeof("GLOBALS") - 1)) {
+ if (auto_global->name->len != sizeof("GLOBALS") - 1 || memcmp(auto_global->name->val, "GLOBALS", sizeof("GLOBALS") - 1)) {
auto_global->armed = 0;
}
@@ -57,8 +57,8 @@ static int phpdbg_array_data_compare(const void *a, const void *b TSRMLS_DC) {
f = *((Bucket **) a);
s = *((Bucket **) b);
- first = *((zval **) f->pData);
- second = *((zval **) s->pData);
+ first = &f->val;
+ second = &s->val;
if (string_compare_function(&result, first, second TSRMLS_CC) == FAILURE) {
return 0;
@@ -85,16 +85,15 @@ static void phpdbg_array_intersect_init(phpdbg_intersect_ptr *info, HashTable *h
}
/* -1 => first array, 0 => both arrays equal, 1 => second array */
-static int phpdbg_array_intersect(phpdbg_intersect_ptr *info, zval ***ptr) {
+static int phpdbg_array_intersect(phpdbg_intersect_ptr *info, zval **ptr) {
int ret;
- zval **zvpp[2];
+ zval *zvp[2];
int invalid = !info->ht[0] + !info->ht[1];
if (invalid > 0) {
invalid = !info->ht[0];
- if (zend_hash_get_current_data_ex(info->ht[invalid], (void **) ptr, &info->pos[invalid]) == FAILURE) {
- *ptr = NULL;
+ if (!(*ptr = zend_hash_get_current_data_ex(info->ht[invalid], &info->pos[invalid]))) {
return 0;
}
@@ -103,23 +102,23 @@ static int phpdbg_array_intersect(phpdbg_intersect_ptr *info, zval ***ptr) {
return invalid ? 1 : -1;
}
- if (zend_hash_get_current_data_ex(info->ht[0], (void **) &zvpp[0], &info->pos[0]) == FAILURE) {
+ if (!(zvp[0] = zend_hash_get_current_data_ex(info->ht[0], &info->pos[0]))) {
info->ht[0] = NULL;
return phpdbg_array_intersect(info, ptr);
}
- if (zend_hash_get_current_data_ex(info->ht[1], (void **) &zvpp[1], &info->pos[1]) == FAILURE) {
+ if (!(zvp[1] = zend_hash_get_current_data_ex(info->ht[1], &info->pos[1]))) {
info->ht[1] = NULL;
return phpdbg_array_intersect(info, ptr);
}
- ret = zend_binary_zval_strcmp(*zvpp[0], *zvpp[1]);
+ ret = zend_binary_zval_strcmp(zvp[0], zvp[1]);
if (ret <= 0) {
- *ptr = zvpp[0];
+ *ptr = zvp[0];
zend_hash_move_forward_ex(info->ht[0], &info->pos[0]);
}
if (ret >= 0) {
- *ptr = zvpp[1];
+ *ptr = zvp[1];
zend_hash_move_forward_ex(info->ht[1], &info->pos[1]);
}
@@ -129,7 +128,7 @@ static int phpdbg_array_intersect(phpdbg_intersect_ptr *info, zval ***ptr) {
void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) {
#ifdef HAVE_JSON
zval *free_zv = NULL;
- zval zv, **zvpp;
+ zval zv, *zvp;
HashTable *ht;
php_json_decode(&zv, msg, len, 1, 1000 /* enough */ TSRMLS_CC);
@@ -141,14 +140,14 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) {
ht = Z_ARRVAL(zv);
/* Reapply symbol table */
- if (zend_hash_find(ht, "GLOBALS", sizeof("GLOBALS"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_ARRAY) {
+ if ((zvp = zend_hash_str_find(ht, ZEND_STRL("GLOBALS"))) && Z_TYPE_P(zvp) == IS_ARRAY) {
{
- zval **srv;
- if (zend_hash_find(Z_ARRVAL_PP(zvpp), "_SERVER", sizeof("_SERVER"), (void **) &srv) == SUCCESS && Z_TYPE_PP(srv) == IS_ARRAY) {
- zval **script;
- if (zend_hash_find(Z_ARRVAL_PP(srv), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &script) == SUCCESS && Z_TYPE_PP(script) == IS_STRING) {
+ zval *srv;
+ if ((srv = zend_hash_str_find(Z_ARRVAL_P(zvp), ZEND_STRL("_SERVER"))) && Z_TYPE_P(srv) == IS_ARRAY) {
+ zval *script;
+ if ((script = zend_hash_str_find(Z_ARRVAL_P(srv), ZEND_STRL("SCRIPT_FILENAME"))) && Z_TYPE_P(script) == IS_STRING) {
phpdbg_param_t param;
- param.str = Z_STRVAL_PP(script);
+ param.str = Z_STRVAL_P(script);
PHPDBG_COMMAND_HANDLER(exec)(&param TSRMLS_CC);
}
}
@@ -157,8 +156,8 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) {
PG(auto_globals_jit) = 0;
zend_hash_apply(CG(auto_globals), (apply_func_t) phpdbg_dearm_autoglobals TSRMLS_CC);
- zend_hash_clean(&EG(symbol_table));
- EG(symbol_table) = *Z_ARRVAL_PP(zvpp);
+ zend_hash_clean(&EG(symbol_table).ht);
+ EG(symbol_table) = *Z_ARR_P(zvp);
/* Rebuild cookies, env vars etc. from GLOBALS (PG(http_globals)) */
phpdbg_rebuild_http_globals_array(TRACK_VARS_POST, "_POST" TSRMLS_CC);
@@ -168,21 +167,21 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) {
phpdbg_rebuild_http_globals_array(TRACK_VARS_ENV, "_ENV" TSRMLS_CC);
phpdbg_rebuild_http_globals_array(TRACK_VARS_FILES, "_FILES" TSRMLS_CC);
- Z_ADDREF_PP(zvpp);
- free_zv = *zvpp;
+ Z_ADDREF_P(zvp);
+ free_zv = zvp;
}
- if (zend_hash_find(ht, "input", sizeof("input"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_STRING) {
+ if ((zvp = zend_hash_str_find(ht, ZEND_STRL("input"))) && Z_TYPE_P(zvp) == IS_STRING) {
if (SG(request_info).request_body) {
php_stream_close(SG(request_info).request_body);
}
SG(request_info).request_body = php_stream_temp_create_ex(TEMP_STREAM_DEFAULT, SAPI_POST_BLOCK_SIZE, PG(upload_tmp_dir));
php_stream_truncate_set_size(SG(request_info).request_body, 0);
- php_stream_write(SG(request_info).request_body, Z_STRVAL_PP(zvpp), Z_STRLEN_PP(zvpp));
+ php_stream_write(SG(request_info).request_body, Z_STRVAL_P(zvp), Z_STRLEN_P(zvp));
}
- if (zend_hash_find(ht, "cwd", sizeof("cwd"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_STRING) {
- if (VCWD_CHDIR(Z_STRVAL_PP(zvpp)) == SUCCESS) {
+ if ((zvp = zend_hash_str_find(ht, ZEND_STRL("cwd"))) && Z_TYPE_P(zvp) == IS_STRING) {
+ if (VCWD_CHDIR(Z_STRVAL_P(zvp)) == SUCCESS) {
if (BG(CurrentStatFile) && !IS_ABSOLUTE_PATH(BG(CurrentStatFile), strlen(BG(CurrentStatFile)))) {
efree(BG(CurrentStatFile));
BG(CurrentStatFile) = NULL;
@@ -194,50 +193,46 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) {
}
}
- if (zend_hash_find(ht, "sapi_name", sizeof("sapi_name"), (void **) &zvpp) == SUCCESS && (Z_TYPE_PP(zvpp) == IS_STRING || Z_TYPE_PP(zvpp) == IS_NULL)) {
+ if ((zvp = zend_hash_str_find(ht, ZEND_STRL("sapi_name"))) && (Z_TYPE_P(zvp) == IS_STRING || Z_TYPE_P(zvp) == IS_NULL)) {
if (PHPDBG_G(sapi_name_ptr)) {
free(PHPDBG_G(sapi_name_ptr));
}
- if (Z_TYPE_PP(zvpp) == IS_STRING) {
- PHPDBG_G(sapi_name_ptr) = sapi_module.name = strdup(Z_STRVAL_PP(zvpp));
+ if (Z_TYPE_P(zvp) == IS_STRING) {
+ PHPDBG_G(sapi_name_ptr) = sapi_module.name = strdup(Z_STRVAL_P(zvp));
} else {
PHPDBG_G(sapi_name_ptr) = sapi_module.name = NULL;
}
}
- if (zend_hash_find(ht, "modules", sizeof("modules"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_ARRAY) {
- HashPosition position;
+ if ((zvp = zend_hash_str_find(ht, ZEND_STRL("modules"))) && Z_TYPE_P(zvp) == IS_ARRAY) {
phpdbg_intersect_ptr pos;
- zval **module;
+ zval *module;
zend_module_entry *mod;
HashTable zv_registry;
/* intersect modules, unregister modules loaded "too much", announce not yet registered modules (phpdbg_notice) */
zend_hash_init(&zv_registry, zend_hash_num_elements(&module_registry), 0, ZVAL_PTR_DTOR, 0);
- for (zend_hash_internal_pointer_reset_ex(&module_registry, &position);
- zend_hash_get_current_data_ex(&module_registry, (void **) &mod, &position) == SUCCESS;
- zend_hash_move_forward_ex(&module_registry, &position)) {
+ ZEND_HASH_FOREACH_PTR(&module_registry, mod) {
if (mod->name) {
- zval **value = emalloc(sizeof(zval *));
- MAKE_STD_ZVAL(*value);
- ZVAL_STRING(*value, mod->name, 1);
- zend_hash_next_index_insert(&zv_registry, value, sizeof(zval *), NULL);
+ zval value;
+ ZVAL_NEW_STR(&value, zend_string_init(mod->name, strlen(mod->name), 0));
+ zend_hash_next_index_insert(&zv_registry, &value);
}
- }
+ } ZEND_HASH_FOREACH_END();
- phpdbg_array_intersect_init(&pos, &zv_registry, Z_ARRVAL_PP(zvpp) TSRMLS_CC);
+ phpdbg_array_intersect_init(&pos, &zv_registry, Z_ARRVAL_P(zvp) TSRMLS_CC);
do {
int mode = phpdbg_array_intersect(&pos, &module);
if (mode < 0) {
// loaded module, but not needed
- if (strcmp(PHPDBG_NAME, Z_STRVAL_PP(module))) {
- zend_hash_del(&module_registry, Z_STRVAL_PP(module), Z_STRLEN_PP(module) + 1);
+ if (strcmp(PHPDBG_NAME, Z_STRVAL_P(module))) {
+ zend_hash_del(&module_registry, Z_STR_P(module));
}
} else if (mode > 0) {
// not loaded module
- if (!sapi_module.name || strcmp(sapi_module.name, Z_STRVAL_PP(module))) {
- phpdbg_notice("wait", "missingmodule=\"%.*s\"", "The module %.*s isn't present in " PHPDBG_NAME ", you still can load via dl /path/to/module/%.*s.so", Z_STRLEN_PP(module), Z_STRVAL_PP(module), Z_STRLEN_PP(module), Z_STRVAL_PP(module));
+ if (!sapi_module.name || strcmp(sapi_module.name, Z_STRVAL_P(module))) {
+ phpdbg_notice("wait", "missingmodule=\"%.*s\"", "The module %.*s isn't present in " PHPDBG_NAME ", you still can load via dl /path/to/module/%.*s.so", Z_STRLEN_P(module), Z_STRVAL_P(module), Z_STRLEN_P(module), Z_STRVAL_P(module));
}
}
} while (module);
@@ -245,26 +240,25 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) {
zend_hash_clean(&zv_registry);
}
- if (zend_hash_find(ht, "extensions", sizeof("extensions"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_ARRAY) {
+ if ((zvp = zend_hash_str_find(ht, ZEND_STRL("extensions"))) && Z_TYPE_P(zvp) == IS_ARRAY) {
zend_extension *extension;
zend_llist_position pos;
- HashPosition hpos;
- zval **name, key;
+ zval *name = NULL;
+ zend_string *strkey;
extension = (zend_extension *) zend_llist_get_first_ex(&zend_extensions, &pos);
while (extension) {
extension = (zend_extension *) zend_llist_get_next_ex(&zend_extensions, &pos);
- /* php_serach_array() body should be in some ZEND_API function */
- for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(zvpp), &hpos);
- zend_hash_get_current_data_ex(Z_ARRVAL_PP(zvpp), (void **) &name, &hpos) == SUCCESS;
- zend_hash_move_forward_ex(Z_ARRVAL_PP(zvpp), &hpos)) {
- if (Z_TYPE_PP(name) == IS_STRING && !zend_binary_strcmp(extension->name, strlen(extension->name), Z_STRVAL_PP(name), Z_STRLEN_PP(name))) {
+ /* php_serach_array() body should be in some ZEND_API function... */
+ ZEND_HASH_FOREACH_STR_KEY_PTR(Z_ARRVAL_P(zvp), strkey, name) {
+ if (Z_TYPE_P(name) == IS_STRING && !zend_binary_strcmp(extension->name, strlen(extension->name), Z_STRVAL_P(name), Z_STRLEN_P(name))) {
break;
}
- }
+ name = NULL;
+ } ZEND_HASH_FOREACH_END();
- if (zend_hash_get_current_data_ex(Z_ARRVAL_PP(zvpp), (void **) &zvpp, &hpos) == FAILURE) {
+ if (name) {
/* sigh, breaking the encapsulation, there aren't any functions manipulating the llist at the place of the zend_llist_position */
zend_llist_element *elm = pos;
if (elm->prev) {
@@ -288,66 +282,53 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) {
pefree(elm, zend_extensions.persistent);
zend_extensions.count--;
} else {
- zend_hash_get_current_key_zval_ex(Z_ARRVAL_PP(zvpp), &key, &hpos);
+/* zend_hash_get_current_key_zval_ex(Z_ARRVAL_PP(zvpp), &key, &hpos);
if (Z_TYPE(key) == IS_LONG) {
zend_hash_index_del(Z_ARRVAL_PP(zvpp), Z_LVAL(key));
}
+*/
+ zend_hash_del(Z_ARRVAL_P(zvp), strkey);
}
+ }
- for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(zvpp), &hpos);
- zend_hash_get_current_data_ex(Z_ARRVAL_PP(zvpp), (void **) &name, &hpos) == SUCCESS;
- zend_hash_move_forward_ex(Z_ARRVAL_PP(zvpp), &hpos)) {
- phpdbg_notice("wait", "missingextension=\"%.*s\"", "The Zend extension %.*s isn't present in " PHPDBG_NAME ", you still can load via dl /path/to/extension.so", Z_STRLEN_PP(name), Z_STRVAL_PP(name));
+ ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(zvp), name) {
+ if (Z_TYPE_P(name) == IS_STRING) {
+ phpdbg_notice("wait", "missingextension=\"%.*s\"", "The Zend extension %.*s isn't present in " PHPDBG_NAME ", you still can load via dl /path/to/extension.so", Z_STRLEN_P(name), Z_STRVAL_P(name));
}
- }
+ } ZEND_HASH_FOREACH_END();
}
zend_ini_deactivate(TSRMLS_C);
- if (zend_hash_find(ht, "systemini", sizeof("systemini"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_ARRAY) {
- HashPosition position;
- zval **ini_entry;
+ if ((zvp = zend_hash_str_find(ht, ZEND_STRL("systemini"))) && Z_TYPE_P(zvp) == IS_ARRAY) {
+ zval *ini_entry;
zend_ini_entry *original_ini;
- zval key;
-
- for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(zvpp), &position);
- zend_hash_get_current_data_ex(Z_ARRVAL_PP(zvpp), (void**) &ini_entry, &position) == SUCCESS;
- zend_hash_move_forward_ex(Z_ARRVAL_PP(zvpp), &position)) {
- zend_hash_get_current_key_zval_ex(Z_ARRVAL_PP(zvpp), &key, &position);
- if (Z_TYPE(key) == IS_STRING) {
- if (Z_TYPE_PP(ini_entry) == IS_STRING) {
- if (zend_hash_find(EG(ini_directives), Z_STRVAL(key), Z_STRLEN(key) + 1, (void **) &original_ini) == SUCCESS) {
- if (!original_ini->on_modify || original_ini->on_modify(original_ini, Z_STRVAL_PP(ini_entry), Z_STRLEN_PP(ini_entry), original_ini->mh_arg1, original_ini->mh_arg2, original_ini->mh_arg3, ZEND_INI_STAGE_ACTIVATE TSRMLS_CC) == SUCCESS) {
- if (original_ini->modified && original_ini->orig_value != original_ini->value) {
- efree(original_ini->value);
- }
- original_ini->value = Z_STRVAL_PP(ini_entry);
- original_ini->value_length = Z_STRLEN_PP(ini_entry);
- Z_TYPE_PP(ini_entry) = IS_NULL; /* don't free the value */
+ zend_string *key;
+
+ ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(zvp), key, ini_entry) {
+ if (key && Z_TYPE_P(ini_entry) == IS_STRING) {
+ if ((original_ini = zend_hash_find_ptr(EG(ini_directives), key))) {
+ if (!original_ini->on_modify || original_ini->on_modify(original_ini, Z_STR_P(ini_entry), original_ini->mh_arg1, original_ini->mh_arg2, original_ini->mh_arg3, ZEND_INI_STAGE_ACTIVATE TSRMLS_CC) == SUCCESS) {
+ if (original_ini->modified && original_ini->orig_value != original_ini->value) {
+ efree(original_ini->value);
}
+ original_ini->value = Z_STR_P(ini_entry);
+ Z_ADDREF_P(ini_entry); /* don't free the string */
}
}
- efree(Z_STRVAL(key));
}
- }
+ } ZEND_HASH_FOREACH_END();
}
- if (zend_hash_find(ht, "userini", sizeof("userini"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_ARRAY) {
- HashPosition position;
- zval **ini_entry;
- zval key;
-
- for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(zvpp), &position);
- zend_hash_get_current_data_ex(Z_ARRVAL_PP(zvpp), (void**) &ini_entry, &position) == SUCCESS;
- zend_hash_move_forward_ex(Z_ARRVAL_PP(zvpp), &position)) {
- zend_hash_get_current_key_zval_ex(Z_ARRVAL_PP(zvpp), &key, &position);
- if (Z_TYPE(key) == IS_STRING) {
- if (Z_TYPE_PP(ini_entry) == IS_STRING) {
- zend_alter_ini_entry_ex(Z_STRVAL(key), Z_STRLEN(key) + 1, Z_STRVAL_PP(ini_entry), Z_STRLEN_PP(ini_entry), ZEND_INI_PERDIR, ZEND_INI_STAGE_HTACCESS, 1 TSRMLS_CC);
- }
- efree(Z_STRVAL(key));
+ if ((zvp = zend_hash_str_find(ht, ZEND_STRL("userini"))) && Z_TYPE_P(zvp) == IS_ARRAY) {
+ zval *ini_entry;
+ zend_string *key;
+
+ ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(zvp), key, ini_entry) {
+ if (key && Z_TYPE_P(ini_entry) == IS_STRING) {
+ zend_alter_ini_entry_ex(key, Z_STR_P(ini_entry), ZEND_INI_PERDIR, ZEND_INI_STAGE_HTACCESS, 1 TSRMLS_CC);
}
- }
+ } ZEND_HASH_FOREACH_END();
}
zval_dtor(&zv);
diff --git a/sapi/phpdbg/phpdbg_watch.c b/sapi/phpdbg/phpdbg_watch.c
index de6cddf5b3..7a39d3ee1a 100644
--- a/sapi/phpdbg/phpdbg_watch.c
+++ b/sapi/phpdbg/phpdbg_watch.c
@@ -30,6 +30,16 @@
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
+const phpdbg_command_t phpdbg_watch_commands[] = {
+ PHPDBG_COMMAND_D_EX(array, "create watchpoint on an array", 'a', watch_array, NULL, "s", 0),
+ PHPDBG_COMMAND_D_EX(delete, "delete watchpoint", 'd', watch_delete, NULL, "s", 0),
+ PHPDBG_COMMAND_D_EX(recursive, "create recursive watchpoints", 'r', watch_recursive, NULL, "s", 0),
+ PHPDBG_END_COMMAND
+};
+
+//#define HT_FROM_WATCH(watch) (watch->type == WATCH_ON_OBJECT ? watch->addr.obj->handlers->get_properties(watch->parent_container.zv TSRMLS_CC) : watch->type == WATCH_ON_ARRAY ? &watch->addr.arr->ht : NULL)
+#define HT_FROM_ZVP(zvp) (Z_TYPE_P(zvp) == IS_OBJECT ? Z_OBJPROP_P(zvp) : Z_TYPE_P(zvp) == IS_ARRAY ? Z_ARRVAL_P(zvp) : NULL)
+
typedef struct {
void *page;
size_t size;
@@ -52,7 +62,7 @@ static phpdbg_watchpoint_t *phpdbg_check_for_watchpoint(void *addr TSRMLS_DC) {
watch = result->ptr;
/* check if that addr is in a mprotect()'ed memory area */
- if ((char *)phpdbg_get_page_boundary(watch->addr.ptr) > (char *)addr || (char *)phpdbg_get_page_boundary(watch->addr.ptr) + phpdbg_get_total_page_size(watch->addr.ptr, watch->size) < (char *)addr) {
+ if ((char *) phpdbg_get_page_boundary(watch->addr.ptr) > (char *) addr || (char *) phpdbg_get_page_boundary(watch->addr.ptr) + phpdbg_get_total_page_size(watch->addr.ptr, watch->size) < (char *) addr) {
/* failure */
return NULL;
}
@@ -61,10 +71,8 @@ static phpdbg_watchpoint_t *phpdbg_check_for_watchpoint(void *addr TSRMLS_DC) {
}
static void phpdbg_change_watchpoint_access(phpdbg_watchpoint_t *watch, int access TSRMLS_DC) {
- int m;
-
/* pagesize is assumed to be in the range of 2^x */
- m = mprotect(phpdbg_get_page_boundary(watch->addr.ptr), phpdbg_get_total_page_size(watch->addr.ptr, watch->size), access);
+ mprotect(phpdbg_get_page_boundary(watch->addr.ptr), phpdbg_get_total_page_size(watch->addr.ptr, watch->size), access);
}
static inline void phpdbg_activate_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) {
@@ -76,11 +84,11 @@ static inline void phpdbg_deactivate_watchpoint(phpdbg_watchpoint_t *watch TSRML
}
static inline void phpdbg_store_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) {
- phpdbg_btree_insert(&PHPDBG_G(watchpoint_tree), (zend_ulong)watch->addr.ptr, watch);
+ phpdbg_btree_insert(&PHPDBG_G(watchpoint_tree), (zend_ulong) watch->addr.ptr, watch);
}
static inline void phpdbg_remove_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) {
- phpdbg_btree_delete(&PHPDBG_G(watchpoint_tree), (zend_ulong)watch->addr.ptr);
+ phpdbg_btree_delete(&PHPDBG_G(watchpoint_tree), (zend_ulong) watch->addr.ptr);
}
void phpdbg_create_addr_watchpoint(void *addr, size_t size, phpdbg_watchpoint_t *watch) {
@@ -98,17 +106,95 @@ void phpdbg_create_ht_watchpoint(HashTable *ht, phpdbg_watchpoint_t *watch) {
watch->type = WATCH_ON_HASHTABLE;
}
-void phpdbg_watch_HashTable_dtor(zval **ptr);
+void phpdbg_watch_HashTable_dtor(zval *ptr);
+
+static int phpdbg_delete_watchpoint(phpdbg_watchpoint_t *tmp_watch TSRMLS_DC);
+static void phpdbg_delete_ht_watchpoints_recursive(phpdbg_watchpoint_t *watch TSRMLS_DC);
+static void phpdbg_delete_zval_watchpoints_recursive(phpdbg_watchpoint_t *watch TSRMLS_DC);
+static void phpdbg_delete_watchpoints_recursive(phpdbg_watchpoint_t *watch TSRMLS_DC);
+
+/* TODO: Store all the possible watches the refcounted may refer to (for displaying & deleting by identifier) */
+
+static phpdbg_watchpoint_t *phpdbg_create_refcounted_watchpoint(phpdbg_watchpoint_t *parent, zend_refcounted *ref) {
+ phpdbg_watchpoint_t *watch = emalloc(sizeof(phpdbg_watchpoint_t));
+ watch->flags = parent->flags;
+ watch->parent = parent;
+ phpdbg_create_addr_watchpoint(&ref->refcount, sizeof(uint32_t), watch);
+ watch->type = WATCH_ON_REFCOUNTED;
+
+ return watch;
+}
+
+static void phpdbg_add_watch_collision(phpdbg_watchpoint_t *watch TSRMLS_DC) {
+ phpdbg_watch_collision *cur;
+ if ((cur = zend_hash_index_find_ptr(&PHPDBG_G(watch_collisions), (zend_ulong) watch->addr.ref))) {
+ cur->num++;
+ if (watch->flags == PHPDBG_WATCH_RECURSIVE) {
+ cur->refs++;
+ }
+ } else {
+ phpdbg_watch_collision coll;
+ coll.num = 1;
+ coll.refs = watch->flags == PHPDBG_WATCH_RECURSIVE;
+ coll.watch = *watch;
+ zend_hash_init(&coll.watches, 8, NULL, NULL, 0);
+ cur = zend_hash_index_add_mem(&PHPDBG_G(watch_collisions), (zend_ulong) watch->addr.ref, &coll, sizeof(phpdbg_watch_collision));
+ phpdbg_store_watchpoint(&cur->watch TSRMLS_CC);
+ phpdbg_activate_watchpoint(&cur->watch TSRMLS_CC);
+ }
+
+ zend_hash_str_add_ptr(&cur->watches, watch->parent->str, watch->parent->str_len, watch->parent);
+}
+
+static void phpdbg_remove_watch_collision(zend_refcounted *ref TSRMLS_DC) {
+ phpdbg_watch_collision *cur;
+ if ((cur = zend_hash_index_find_ptr(&PHPDBG_G(watch_collisions), (zend_ulong) ref))) {
+ phpdbg_watchpoint_t *watch = cur->watch.parent;
+
+ if (watch->flags == PHPDBG_WATCH_RECURSIVE && !--cur->refs) {
+ phpdbg_delete_watchpoints_recursive(watch TSRMLS_CC);
+ }
+
+ zend_hash_str_del(&cur->watches, watch->str, watch->str_len);
+
+ if (!--cur->num) {
+ phpdbg_deactivate_watchpoint(&cur->watch TSRMLS_CC);
+ phpdbg_remove_watchpoint(&cur->watch TSRMLS_CC);
+
+ phpdbg_delete_watchpoint(watch TSRMLS_CC);
+
+ zend_hash_index_del(&PHPDBG_G(watch_collisions), (zend_ulong) ref);
+ }
+ }
+}
static int phpdbg_create_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) {
watch->flags |= PHPDBG_WATCH_SIMPLE;
phpdbg_store_watchpoint(watch TSRMLS_CC);
- zend_hash_add(&PHPDBG_G(watchpoints), watch->str, watch->str_len, &watch, sizeof(phpdbg_watchpoint_t *), NULL);
+ zend_hash_str_add_ptr(&PHPDBG_G(watchpoints), watch->str, watch->str_len, watch);
+
+ if (watch->parent && watch->parent->type == WATCH_ON_ZVAL && Z_REFCOUNTED_P(watch->parent->addr.zv)) {
+ phpdbg_add_watch_collision(phpdbg_create_refcounted_watchpoint(watch, Z_COUNTED_P(watch->parent->addr.zv)) TSRMLS_CC);
+ }
if (watch->type == WATCH_ON_ZVAL) {
- phpdbg_btree_insert(&PHPDBG_G(watch_HashTables), (zend_ulong)watch->parent_container, watch->parent_container->pDestructor);
- watch->parent_container->pDestructor = (dtor_func_t)phpdbg_watch_HashTable_dtor;
+ if (watch->parent_container) {
+ phpdbg_btree_insert(&PHPDBG_G(watch_HashTables), (zend_ulong) watch->parent_container, watch->parent_container->pDestructor);
+ watch->parent_container->pDestructor = (dtor_func_t) phpdbg_watch_HashTable_dtor;
+ }
+
+ if (Z_ISREF_P(watch->addr.zv)) {
+ phpdbg_watchpoint_t *ref = emalloc(sizeof(phpdbg_watchpoint_t));
+ ref->flags = watch->flags;
+ ref->str = watch->str;
+ ref->str_len = watch->str_len;
+ ref->parent = watch;
+ ref->parent_container = NULL;
+ phpdbg_create_zval_watchpoint(Z_REFVAL_P(watch->addr.zv), ref);
+
+ phpdbg_create_watchpoint(ref TSRMLS_CC);
+ }
}
phpdbg_activate_watchpoint(watch TSRMLS_CC);
@@ -116,29 +202,35 @@ static int phpdbg_create_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) {
return SUCCESS;
}
-static int phpdbg_create_array_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) {
- HashTable *ht;
+static int phpdbg_create_array_watchpoint(phpdbg_watchpoint_t *zv_watch TSRMLS_DC) {
+ zval *zv = zv_watch->addr.zv;
+ phpdbg_watchpoint_t *watch = emalloc(sizeof(phpdbg_watchpoint_t));
+ HashTable *ht = HT_FROM_ZVP(zv);
- switch (Z_TYPE_P(watch->addr.zv)) {
- case IS_ARRAY:
- ht = Z_ARRVAL_P(watch->addr.zv);
- break;
- case IS_OBJECT:
- ht = Z_OBJPROP_P(watch->addr.zv);
- break;
- default:
- return FAILURE;
+ watch->parent = zv_watch;
+
+ if (!ht) {
+ return FAILURE;
}
phpdbg_create_ht_watchpoint(ht, watch);
phpdbg_create_watchpoint(watch TSRMLS_CC);
+ if (Z_TYPE_P(zv) == IS_ARRAY) {
+ watch->flags |= PHPDBG_WATCH_ARRAY;
+ } else {
+ watch->flags |= PHPDBG_WATCH_OBJECT;
+ }
+
+ phpdbg_add_watch_collision(phpdbg_create_refcounted_watchpoint(watch, Z_COUNTED_P(zv)) TSRMLS_CC);
+
return SUCCESS;
}
static int phpdbg_create_recursive_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_DC) {
HashTable *ht;
+ zval *zvp = watch->addr.zv;
if (watch->type != WATCH_ON_ZVAL) {
return FAILURE;
@@ -147,25 +239,18 @@ static int phpdbg_create_recursive_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_
watch->flags |= PHPDBG_WATCH_RECURSIVE;
phpdbg_create_watchpoint(watch TSRMLS_CC);
- switch (Z_TYPE_P(watch->addr.zv)) {
- case IS_ARRAY:
- ht = Z_ARRVAL_P(watch->addr.zv);
- break;
- case IS_OBJECT:
- ht = Z_OBJPROP_P(watch->addr.zv);
- break;
- default:
- return SUCCESS;
+ ZVAL_DEREF(zvp);
+
+ if (!(ht = HT_FROM_ZVP(zvp))) {
+ return SUCCESS;
}
{
HashPosition position;
- zval **zv;
+ zval *zv;
zval key;
- for (zend_hash_internal_pointer_reset_ex(ht, &position);
- zend_hash_get_current_data_ex(ht, (void **)&zv, &position) == SUCCESS;
- zend_hash_move_forward_ex(ht, &position)) {
+ ZEND_HASH_FOREACH_VAL(ht, zv) {
phpdbg_watchpoint_t *new_watch = emalloc(sizeof(phpdbg_watchpoint_t));
new_watch->flags = PHPDBG_WATCH_RECURSIVE;
@@ -174,19 +259,21 @@ static int phpdbg_create_recursive_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_
zend_hash_get_current_key_zval_ex(ht, &key, &position);
if (Z_TYPE(key) == IS_STRING) {
- new_watch->name_in_parent = zend_strndup(Z_STRVAL(key), Z_STRLEN(key));
+ new_watch->name_in_parent = estrndup(Z_STRVAL(key), Z_STRLEN(key));
new_watch->name_in_parent_len = Z_STRLEN(key);
} else {
- new_watch->name_in_parent = NULL;
- new_watch->name_in_parent_len = asprintf(&new_watch->name_in_parent, "%ld", Z_LVAL(key));
+ new_watch->name_in_parent_len = spprintf(&new_watch->name_in_parent, 0, "%lld", Z_LVAL(key));
}
- new_watch->str = NULL;
- new_watch->str_len = asprintf(&new_watch->str, "%.*s%s%s%s", (int) watch->str_len, watch->str, Z_TYPE_P(watch->addr.zv) == IS_ARRAY ? "[" : "->", phpdbg_get_property_key(new_watch->name_in_parent), Z_TYPE_P(watch->addr.zv) == IS_ARRAY ? "]" : "");
+ new_watch->str_len = spprintf(&new_watch->str, 0, "%.*s%s%s%s", (int) watch->str_len, watch->str, Z_TYPE_P(zvp) == IS_ARRAY ? "[" : "->", phpdbg_get_property_key(new_watch->name_in_parent), Z_TYPE_P(zvp) == IS_ARRAY ? "]" : "");
+
+ while (Z_TYPE_P(zv) == IS_INDIRECT) {
+ zv = Z_INDIRECT_P(zv);
+ }
- phpdbg_create_zval_watchpoint(*zv, new_watch);
+ phpdbg_create_zval_watchpoint(zv, new_watch);
phpdbg_create_recursive_watchpoint(new_watch TSRMLS_CC);
- }
+ } ZEND_HASH_FOREACH_END();
}
{
@@ -194,12 +281,18 @@ static int phpdbg_create_recursive_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_
new_watch->parent = watch;
new_watch->parent_container = watch->parent_container;
- new_watch->name_in_parent = zend_strndup(watch->name_in_parent, watch->name_in_parent_len);
+ new_watch->name_in_parent = estrndup(watch->name_in_parent, watch->name_in_parent_len);
new_watch->name_in_parent_len = watch->name_in_parent_len;
new_watch->str = NULL;
- new_watch->str_len = asprintf(&new_watch->str, "%.*s[]", (int)watch->str_len, watch->str);
+ new_watch->str_len = spprintf(&new_watch->str, 0, "%.*s[]", (int) watch->str_len, watch->str);
new_watch->flags = PHPDBG_WATCH_RECURSIVE;
+ if (Z_TYPE_P(zvp) == IS_ARRAY) {
+ new_watch->flags |= PHPDBG_WATCH_ARRAY;
+ } else {
+ new_watch->flags |= PHPDBG_WATCH_OBJECT;
+ }
+
phpdbg_create_ht_watchpoint(ht, new_watch);
phpdbg_create_watchpoint(new_watch TSRMLS_CC);
}
@@ -208,52 +301,58 @@ static int phpdbg_create_recursive_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_
}
static int phpdbg_delete_watchpoint_recursive(phpdbg_watchpoint_t *watch, zend_bool user_request TSRMLS_DC) {
- if (watch->type == WATCH_ON_HASHTABLE || (watch->type == WATCH_ON_ZVAL && (Z_TYPE_P(watch->addr.zv) == IS_ARRAY || Z_TYPE_P(watch->addr.zv) == IS_OBJECT))) {
+ if (watch->type == WATCH_ON_HASHTABLE) {
HashTable *ht;
phpdbg_btree_result *result;
if (watch->type == WATCH_ON_HASHTABLE && user_request) {
- HashPosition position;
- zval **zv;
- zval key;
- char *str;
- int str_len;
- phpdbg_watchpoint_t **watchpoint;
-
- ht = watch->addr.ht;
-
- for (zend_hash_internal_pointer_reset_ex(ht, &position);
- zend_hash_get_current_data_ex(ht, (void **)&zv, &position) == SUCCESS;
- zend_hash_move_forward_ex(ht, &position)) {
- zend_hash_get_current_key_zval_ex(ht, &key, &position);
- str = NULL;
- if (Z_TYPE(key) == IS_STRING) {
- str_len = asprintf(&str, "%.*s%s%s%s", (int) watch->parent->str_len, watch->parent->str, Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY ? "[" : "->", phpdbg_get_property_key(Z_STRVAL(key)), Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY ? "]" : "");
- } else {
- str_len = asprintf(&str, "%.*s%s%li%s", (int) watch->parent->str_len, watch->parent->str, Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY ? "[" : "->", Z_LVAL(key), Z_TYPE_P(watch->parent->addr.zv) == IS_ARRAY ? "]" : "");
- }
-
- if (zend_hash_find(&PHPDBG_G(watchpoints), str, str_len, (void **) &watchpoint) == SUCCESS) {
- phpdbg_delete_watchpoint_recursive(*watchpoint, 1 TSRMLS_CC);
- }
- }
+ phpdbg_delete_ht_watchpoints_recursive(watch TSRMLS_CC);
} else {
- switch (Z_TYPE_P(watch->addr.zv)) {
- case IS_ARRAY:
- ht = Z_ARRVAL_P(watch->addr.zv);
- break;
- case IS_OBJECT:
- ht = Z_OBJPROP_P(watch->addr.zv);
- break;
- }
+ ht = HT_FROM_ZVP(watch->addr.zv);
if ((result = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong) ht))) {
phpdbg_delete_watchpoint_recursive((phpdbg_watchpoint_t *) result->ptr, user_request TSRMLS_CC);
}
}
+ } else if (watch->type == WATCH_ON_ZVAL) {
+ phpdbg_delete_zval_watchpoints_recursive(watch TSRMLS_CC);
}
- return zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len);
+ return zend_hash_str_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len);
+}
+
+static void phpdbg_delete_ht_watchpoints_recursive(phpdbg_watchpoint_t *watch TSRMLS_DC) {
+ zend_string *strkey;
+ zend_long numkey;
+ char *str;
+ int str_len;
+ phpdbg_watchpoint_t *watchpoint;
+
+ ZEND_HASH_FOREACH_KEY(watch->addr.ht, numkey, strkey) {
+ if (strkey) {
+ str_len = asprintf(&str, "%.*s%s%s%s", (int) watch->str_len, watch->str, (watch->flags & PHPDBG_WATCH_ARRAY) ? "[" : "->", phpdbg_get_property_key(strkey->val), (watch->flags & PHPDBG_WATCH_ARRAY) ? "]" : "");
+ } else {
+ str_len = asprintf(&str, "%.*s%s%lli%s", (int) watch->str_len, watch->str, (watch->flags & PHPDBG_WATCH_ARRAY) ? "[" : "->", numkey, (watch->flags & PHPDBG_WATCH_ARRAY) ? "]" : "");
+ }
+
+ if ((watchpoint = zend_hash_str_find_ptr(&PHPDBG_G(watchpoints), str, str_len))) {
+ phpdbg_delete_watchpoint_recursive(watchpoint, 1 TSRMLS_CC);
+ }
+ } ZEND_HASH_FOREACH_END();
+}
+
+static void phpdbg_delete_zval_watchpoints_recursive(phpdbg_watchpoint_t *watch TSRMLS_DC) {
+ if (Z_REFCOUNTED_P(watch->addr.zv)) {
+ phpdbg_remove_watch_collision(Z_COUNTED_P(watch->addr.zv) TSRMLS_CC);
+ }
+}
+
+static void phpdbg_delete_watchpoints_recursive(phpdbg_watchpoint_t *watch TSRMLS_DC) {
+ if (watch->type == WATCH_ON_ZVAL) {
+ phpdbg_delete_zval_watchpoints_recursive(watch TSRMLS_CC);
+ } else if (watch->type == WATCH_ON_HASHTABLE) {
+ phpdbg_delete_ht_watchpoints_recursive(watch TSRMLS_CC);
+ }
}
static int phpdbg_delete_watchpoint(phpdbg_watchpoint_t *tmp_watch TSRMLS_DC) {
@@ -261,7 +360,7 @@ static int phpdbg_delete_watchpoint(phpdbg_watchpoint_t *tmp_watch TSRMLS_DC) {
phpdbg_watchpoint_t *watch;
phpdbg_btree_result *result;
- if ((result = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong)tmp_watch->addr.ptr)) == NULL) {
+ if ((result = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong) tmp_watch->addr.ptr)) == NULL) {
return FAILURE;
}
@@ -270,7 +369,7 @@ static int phpdbg_delete_watchpoint(phpdbg_watchpoint_t *tmp_watch TSRMLS_DC) {
if (watch->flags & PHPDBG_WATCH_RECURSIVE) {
ret = phpdbg_delete_watchpoint_recursive(watch, 1 TSRMLS_CC);
} else {
- ret = zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len);
+ ret = zend_hash_str_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len);
}
efree(tmp_watch->str);
@@ -280,7 +379,7 @@ static int phpdbg_delete_watchpoint(phpdbg_watchpoint_t *tmp_watch TSRMLS_DC) {
return ret;
}
-static int phpdbg_watchpoint_parse_wrapper(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval **zv, int (*callback)(phpdbg_watchpoint_t * TSRMLS_DC) TSRMLS_DC) {
+static int phpdbg_watchpoint_parse_wrapper(char *name, size_t len, char *keyname, size_t keylen, HashTable *parent, zval *zv, int (*callback)(phpdbg_watchpoint_t * TSRMLS_DC) TSRMLS_DC) {
int ret;
phpdbg_watchpoint_t *watch = emalloc(sizeof(phpdbg_watchpoint_t));
watch->flags = 0;
@@ -289,7 +388,7 @@ static int phpdbg_watchpoint_parse_wrapper(char *name, size_t len, char *keyname
watch->name_in_parent = keyname;
watch->name_in_parent_len = keylen;
watch->parent_container = parent;
- phpdbg_create_zval_watchpoint(*zv, watch);
+ phpdbg_create_zval_watchpoint(zv, watch);
ret = callback(watch TSRMLS_CC);
@@ -307,15 +406,15 @@ PHPDBG_API int phpdbg_watchpoint_parse_input(char *input, size_t len, HashTable
}
static int phpdbg_watchpoint_parse_symtables(char *input, size_t len, int (*callback)(phpdbg_watchpoint_t * TSRMLS_DC) TSRMLS_DC) {
- if (EG(This) && len >= 5 && !memcmp("$this", input, 5)) {
- zend_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), NULL);
+ if (EG(scope) && len >= 5 && !memcmp("$this", input, 5)) {
+ zend_hash_str_add(&EG(current_execute_data)->symbol_table->ht, ZEND_STRL("this"), &EG(current_execute_data)->This);
}
- if (zend_is_auto_global(input, len TSRMLS_CC) && phpdbg_watchpoint_parse_input(input, len, &EG(symbol_table), 0, callback, 1 TSRMLS_CC) != FAILURE) {
+ if (phpdbg_is_auto_global(input, len TSRMLS_CC) && phpdbg_watchpoint_parse_input(input, len, &EG(symbol_table).ht, 0, callback, 1 TSRMLS_CC) != FAILURE) {
return SUCCESS;
}
- return phpdbg_watchpoint_parse_input(input, len, EG(active_symbol_table), 0, callback, 0 TSRMLS_CC);
+ return phpdbg_watchpoint_parse_input(input, len, &EG(current_execute_data)->symbol_table->ht, 0, callback, 0 TSRMLS_CC);
}
PHPDBG_WATCH(delete) /* {{{ */
@@ -373,23 +472,23 @@ PHPDBG_WATCH(array) /* {{{ */
return SUCCESS;
} /* }}} */
-void phpdbg_watch_HashTable_dtor(zval **zv) {
+void phpdbg_watch_HashTable_dtor(zval *zv) {
phpdbg_btree_result *result;
TSRMLS_FETCH();
zval_ptr_dtor_wrapper(zv);
- if ((result = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong)*zv))) {
+ if ((result = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong) zv))) {
phpdbg_watchpoint_t *watch = result->ptr;
PHPDBG_G(watchpoint_hit) = 1;
- phpdbg_notice("watchdelete", "variable=\"%.*s\" recursive=\"%s\"", "%.*s was removed, removing watchpoint%s", (int)watch->str_len, watch->str, watch->flags & PHPDBG_WATCH_RECURSIVE ? " recursively" : "");
+ phpdbg_notice("watchdelete", "variable=\"%.*s\" recursive=\"%s\"", "%.*s was removed, removing watchpoint%s", (int) watch->str_len, watch->str, (watch->flags & PHPDBG_WATCH_RECURSIVE) ? " recursively" : "");
if (watch->flags & PHPDBG_WATCH_RECURSIVE) {
phpdbg_delete_watchpoint_recursive(watch, 0 TSRMLS_CC);
} else {
- zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len);
+ zend_hash_str_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len);
}
}
}
@@ -454,8 +553,8 @@ void phpdbg_watchpoints_clean(TSRMLS_D) {
zend_hash_clean(&PHPDBG_G(watchpoints));
}
-static void phpdbg_watch_dtor(void *pDest) {
- phpdbg_watchpoint_t *watch = *(phpdbg_watchpoint_t **)pDest;
+static void phpdbg_watch_dtor(zval *pDest) {
+ phpdbg_watchpoint_t *watch = (phpdbg_watchpoint_t *) Z_PTR_P(pDest);
TSRMLS_FETCH();
phpdbg_deactivate_watchpoint(watch TSRMLS_CC);
@@ -463,18 +562,17 @@ static void phpdbg_watch_dtor(void *pDest) {
efree(watch->str);
efree(watch->name_in_parent);
- efree(watch);
}
static void phpdbg_watch_mem_dtor(void *llist_data) {
- phpdbg_watch_memdump *dump = *(phpdbg_watch_memdump **)llist_data;
+ phpdbg_watch_memdump *dump = *(phpdbg_watch_memdump **) llist_data;
/* Disble writing again */
if (dump->reenable_writing) {
mprotect(dump->page, dump->size, PROT_READ);
}
- free(*(void **)llist_data);
+ free(*(void **) llist_data);
}
void phpdbg_setup_watchpoints(TSRMLS_D) {
@@ -491,60 +589,79 @@ void phpdbg_setup_watchpoints(TSRMLS_D) {
zend_llist_init(&PHPDBG_G(watchlist_mem), sizeof(void *), phpdbg_watch_mem_dtor, 1);
phpdbg_btree_init(&PHPDBG_G(watchpoint_tree), sizeof(void *) * 8);
phpdbg_btree_init(&PHPDBG_G(watch_HashTables), sizeof(void *) * 8);
- zend_hash_init(&PHPDBG_G(watchpoints), 8, NULL, phpdbg_watch_dtor, 0 ZEND_FILE_LINE_CC);
+ zend_hash_init(&PHPDBG_G(watchpoints), 8, NULL, phpdbg_watch_dtor, 0);
+ zend_hash_init(&PHPDBG_G(watch_collisions), 8, NULL, NULL, 0);
}
static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump TSRMLS_DC) {
/* fetch all changes between dump->page and dump->page + dump->size */
phpdbg_btree_position pos = phpdbg_btree_find_between(&PHPDBG_G(watchpoint_tree), (zend_ulong) dump->page, (zend_ulong) dump->page + dump->size);
- phpdbg_btree_result *result, *htresult;
+ phpdbg_btree_result *result;
int elementDiff;
void *curTest;
dump->reenable_writing = 0;
while ((result = phpdbg_btree_next(&pos))) {
- phpdbg_watchpoint_t *watch = result->ptr, *htwatch;
- void *oldPtr = (char *)&dump->data + ((size_t)watch->addr.ptr - (size_t)dump->page);
+ phpdbg_watchpoint_t *watch = result->ptr;
+ void *oldPtr = (char *) &dump->data + ((size_t) watch->addr.ptr - (size_t) dump->page);
char reenable = 1;
+ int removed = 0;
- if ((size_t)watch->addr.ptr < (size_t)dump->page || (size_t)watch->addr.ptr + watch->size > (size_t) dump->page + dump->size) {
+ if ((size_t) watch->addr.ptr < (size_t) dump->page || (size_t) watch->addr.ptr + watch->size > (size_t) dump->page + dump->size) {
continue;
}
/* Test if the zval was separated and if necessary move the watchpoint */
- if (zend_hash_find(watch->parent_container, watch->name_in_parent, watch->name_in_parent_len + 1, &curTest) == SUCCESS) {
- if (watch->type == WATCH_ON_HASHTABLE) {
- switch (Z_TYPE_PP((zval **)curTest)) {
- case IS_ARRAY:
- curTest = (void *)Z_ARRVAL_PP((zval **)curTest);
- break;
- case IS_OBJECT:
- curTest = (void *)Z_OBJPROP_PP((zval **)curTest);
- break;
+ if ((watch->type == WATCH_ON_HASHTABLE || watch->type == WATCH_ON_ZVAL) && watch->parent_container) {
+ if ((curTest = zend_hash_str_find(watch->parent_container, watch->name_in_parent, watch->name_in_parent_len))) {
+ while (Z_TYPE_P((zval *) curTest) == IS_INDIRECT) {
+ curTest = Z_INDIRECT_P((zval *) curTest);
}
- } else {
- curTest = *(void **)curTest;
- }
- if (curTest != watch->addr.ptr) {
- phpdbg_deactivate_watchpoint(watch TSRMLS_CC);
- phpdbg_remove_watchpoint(watch TSRMLS_CC);
- watch->addr.ptr = curTest;
- phpdbg_store_watchpoint(watch TSRMLS_CC);
- phpdbg_activate_watchpoint(watch TSRMLS_CC);
+ if (watch->type == WATCH_ON_HASHTABLE) {
+ switch (Z_TYPE_P((zval *) curTest)) {
+ case IS_ARRAY:
+ curTest = (void *) Z_ARRVAL_P((zval *) curTest);
+ break;
+ case IS_OBJECT:
+ curTest = (void *) Z_OBJPROP_P((zval *) curTest);
+ break;
+ }
+ }
- reenable = 0;
+ if (curTest != watch->addr.ptr) {
+ phpdbg_deactivate_watchpoint(watch TSRMLS_CC);
+ phpdbg_remove_watchpoint(watch TSRMLS_CC);
+ watch->addr.ptr = curTest;
+ phpdbg_store_watchpoint(watch TSRMLS_CC);
+ phpdbg_activate_watchpoint(watch TSRMLS_CC);
+
+ reenable = 0;
+ }
+ } else {
+ removed = 1;
}
}
/* Show to the user what changed and delete watchpoint upon removal */
if (memcmp(oldPtr, watch->addr.ptr, watch->size) != SUCCESS) {
- zend_bool do_break = PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS || (watch->type == WATCH_ON_ZVAL && memcmp(oldPtr, watch->addr.zv, sizeof(zvalue_value))) || (watch->type == WATCH_ON_HASHTABLE
-#if ZEND_DEBUG
- && !watch->addr.ht->inconsistent
-#endif
- && zend_hash_num_elements((HashTable *)oldPtr) != zend_hash_num_elements(watch->addr.ht));
+ zend_bool do_break = 0;
+
+ switch (watch->type) {
+ case WATCH_ON_ZVAL:
+ do_break = memcmp(oldPtr, watch->addr.zv, sizeof(zend_value) + sizeof(uint32_t) /* value + typeinfo */);
+ break;
+ case WATCH_ON_HASHTABLE:
+ do_break = zend_hash_num_elements((HashTable *) oldPtr) != zend_hash_num_elements(watch->addr.ht);
+ break;
+ case WATCH_ON_REFCOUNTED:
+ if (PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS) {
+ do_break = memcmp(oldPtr, watch->addr.ref, sizeof(uint32_t) /* no zend_refcounted metadata info */);
+ }
+ break;
+ }
+
if (do_break) {
PHPDBG_G(watchpoint_hit) = 1;
@@ -555,12 +672,10 @@ static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump TSRMLS_DC) {
switch (watch->type) {
case WATCH_ON_ZVAL: {
- int removed = ((zval *)oldPtr)->refcount__gc != watch->addr.zv->refcount__gc && !zend_symtable_exists(watch->parent_container, watch->name_in_parent, watch->name_in_parent_len + 1);
- int show_value = memcmp(oldPtr, watch->addr.zv, sizeof(zvalue_value));
- int show_ref = ((zval *)oldPtr)->refcount__gc != watch->addr.zv->refcount__gc || ((zval *)oldPtr)->is_ref__gc != watch->addr.zv->is_ref__gc;
+ int show_value = memcmp(oldPtr, watch->addr.zv, sizeof(zval) - sizeof(uint32_t) /* no metadata info */);
if (removed || show_value) {
- if ((Z_TYPE_P((zval *)oldPtr) == IS_ARRAY || Z_TYPE_P((zval *)oldPtr) == IS_OBJECT) && removed) {
+ if (removed && (Z_TYPE_P((zval *) oldPtr) == IS_ARRAY || Z_TYPE_P((zval *) oldPtr) == IS_OBJECT)) {
phpdbg_writeln("watchvalue", "type=\"old\" inaccessible=\"inaccessible\"", "Old value inaccessible, array or object (HashTable) already destroyed");
} else {
phpdbg_out("Old value: ");
@@ -570,21 +685,17 @@ static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump TSRMLS_DC) {
phpdbg_out("\n");
}
}
- if (PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS && (removed || show_ref)) {
- phpdbg_write("watchrefcount", "type=\"old\" refcount=\"%d\" isref=\"%d\"", "Old refcount: %d; Old is_ref: %d", ((zval *) oldPtr)->refcount__gc, ((zval *) oldPtr)->is_ref__gc);
- }
/* check if zval was removed */
if (removed) {
phpdbg_notice("watchdelete", "variable=\"%.*s\"", "Watchpoint %.*s was unset, removing watchpoint", (int) watch->str_len, watch->str);
- zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len);
+ zend_hash_str_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len);
reenable = 0;
- if (Z_TYPE_P((zval *) oldPtr) == IS_ARRAY || Z_TYPE_P((zval *) oldPtr) == IS_OBJECT) {
- goto remove_ht_watch;
+ if (Z_REFCOUNTED_P((zval *) oldPtr)) {
+ phpdbg_remove_watch_collision(Z_COUNTED_P((zval *) oldPtr) TSRMLS_CC);
}
-
break;
}
@@ -595,33 +706,27 @@ static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump TSRMLS_DC) {
phpdbg_xml("</watchvalue>");
phpdbg_out("\n");
}
- if (PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS && show_ref) {
- phpdbg_writeln("watchrefcount", "type=\"new\" refcount=\"%d\" isref=\"%d\"", "New refcount: %d; New is_ref: %d", watch->addr.zv->refcount__gc, watch->addr.zv->is_ref__gc);
- }
- if ((Z_TYPE_P(watch->addr.zv) == IS_ARRAY && Z_ARRVAL_P(watch->addr.zv) != Z_ARRVAL_P((zval *) oldPtr)) || (Z_TYPE_P(watch->addr.zv) != IS_OBJECT && Z_OBJ_HANDLE_P(watch->addr.zv) == Z_OBJ_HANDLE_P((zval *) oldPtr))) {
- /* add new watchpoints if necessary */
- if (watch->flags & PHPDBG_WATCH_RECURSIVE) {
- phpdbg_create_recursive_watchpoint(watch TSRMLS_CC);
+ /* add new watchpoints if necessary */
+ if (Z_PTR_P(watch->addr.zv) != Z_PTR_P((zval *) oldPtr)) {
+ if (Z_REFCOUNTED_P((zval *) oldPtr)) {
+ phpdbg_remove_watch_collision(Z_COUNTED_P((zval *) oldPtr) TSRMLS_CC);
+ }
+ if (Z_REFCOUNTED_P(watch->addr.zv)) {
+ if (PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS) {
+ phpdbg_writeln("watchrefcount", "type=\"new\" refcount=\"%d\"", "New refcount: %d", Z_COUNTED_P(watch->addr.zv)->refcount);
+ }
+ if (watch->flags & PHPDBG_WATCH_RECURSIVE) {
+ phpdbg_create_recursive_watchpoint(watch TSRMLS_CC);
+ }
}
- }
-
- if ((Z_TYPE_P((zval *) oldPtr) != IS_ARRAY || Z_ARRVAL_P(watch->addr.zv) == Z_ARRVAL_P((zval *) oldPtr)) && (Z_TYPE_P((zval *)oldPtr) != IS_OBJECT || Z_OBJ_HANDLE_P(watch->addr.zv) == Z_OBJ_HANDLE_P((zval *) oldPtr))) {
- break;
- }
-
-remove_ht_watch:
- if ((htresult = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong)Z_ARRVAL_P((zval *)oldPtr)))) {
- htwatch = htresult->ptr;
- zend_hash_del(&PHPDBG_G(watchpoints), htwatch->str, htwatch->str_len);
}
break;
}
case WATCH_ON_HASHTABLE:
-
-#if ZEND_DEBUG
- if (watch->addr.ht->inconsistent) {
+#if 0 && ZEND_DEBUG
+ if (watch->addr.arr->ht->inconsistent) {
phpdbg_notice("watchdelete", "variable=\"%.*s\"", "Watchpoint %.*s was unset, removing watchpoint", (int) watch->str_len, watch->str);
zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len);
@@ -630,7 +735,6 @@ remove_ht_watch:
break;
}
#endif
-
elementDiff = zend_hash_num_elements((HashTable *) oldPtr) - zend_hash_num_elements(watch->addr.ht);
if (elementDiff) {
if (elementDiff > 0) {
@@ -644,10 +748,21 @@ remove_ht_watch:
}
}
}
- if (((HashTable *) oldPtr)->pInternalPointer != watch->addr.ht->pInternalPointer) {
+ if (watch->addr.ht->nInternalPointer != ((HashTable *) oldPtr)->nInternalPointer) {
phpdbg_writeln("watcharrayptr", "", "Internal pointer of array was changed");
}
break;
+ case WATCH_ON_REFCOUNTED: {
+ if (PHPDBG_G(flags) & PHPDBG_SHOW_REFCOUNTS) {
+ phpdbg_writeln("watchrefcount", "type=\"old\" refcount=\"%d\"", "Old refcount: %d", ((zend_refcounted *) oldPtr)->refcount);
+
+ if (!removed) {
+ phpdbg_writeln("watchrefcount", "type=\"old\" refcount=\"%d\"", "Old refcount: %d", ((zend_refcounted *) oldPtr)->refcount);
+ }
+ }
+
+ break;
+ }
}
if (do_break) {
@@ -683,16 +798,13 @@ int phpdbg_print_changed_zvals(TSRMLS_D) {
}
void phpdbg_list_watchpoints(TSRMLS_D) {
- HashPosition position;
- phpdbg_watchpoint_t **watch;
+ phpdbg_watchpoint_t *watch;
phpdbg_xml("<watchlist %r>");
- for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(watchpoints), &position);
- zend_hash_get_current_data_ex(&PHPDBG_G(watchpoints), (void**) &watch, &position) == SUCCESS;
- zend_hash_move_forward_ex(&PHPDBG_G(watchpoints), &position)) {
- phpdbg_writeln("watchvariable", "variable=\"%.*s\" on=\"%s\" type=\"%s\"", "%.*s (%s, %s)", (int) (*watch)->str_len, (*watch)->str, (*watch)->type == WATCH_ON_HASHTABLE ? "array" : "variable", (*watch)->flags == PHPDBG_WATCH_RECURSIVE ? "recursive" : "simple");
- }
+ ZEND_HASH_FOREACH_PTR(&PHPDBG_G(watchpoints), watch) {
+ phpdbg_writeln("watchvariable", "variable=\"%.*s\" on=\"%s\" type=\"%s\"", "%.*s (%s, %s)", (int) watch->str_len, watch->str, watch->type == WATCH_ON_HASHTABLE ? "array" : watch->type == WATCH_ON_REFCOUNTED ? "refcount" : "variable", watch->flags == PHPDBG_WATCH_RECURSIVE ? "recursive" : "simple");
+ } ZEND_HASH_FOREACH_END();
phpdbg_xml("</watchlist>");
}
@@ -706,8 +818,11 @@ void phpdbg_watch_efree(void *ptr) {
if (result) {
phpdbg_watchpoint_t *watch = result->ptr;
- if ((size_t)watch->addr.ptr + watch->size > (size_t) ptr) {
- zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len);
+ if ((size_t) watch->addr.ptr + watch->size > (size_t) ptr) {
+ if (watch->type == WATCH_ON_ZVAL) {
+ phpdbg_remove_watch_collision(Z_COUNTED_P(watch->addr.zv) TSRMLS_CC);
+ }
+ zend_hash_str_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len);
}
}
diff --git a/sapi/phpdbg/phpdbg_watch.h b/sapi/phpdbg/phpdbg_watch.h
index 5c0079057c..35cab10dc1 100644
--- a/sapi/phpdbg/phpdbg_watch.h
+++ b/sapi/phpdbg/phpdbg_watch.h
@@ -25,7 +25,7 @@
#include "phpdbg_cmd.h"
#ifdef _WIN32
-# include "phpdbg_win.h"
+# include "phpdbg_win.h"
#endif
#define PHPDBG_WATCH(name) PHPDBG_COMMAND(watch_##name)
@@ -37,47 +37,49 @@ PHPDBG_WATCH(array);
PHPDBG_WATCH(delete);
PHPDBG_WATCH(recursive);
-/**
- * Commands
- */
-
-static const phpdbg_command_t phpdbg_watch_commands[] = {
- PHPDBG_COMMAND_D_EX(array, "create watchpoint on an array", 'a', watch_array, NULL, "s", 0),
- PHPDBG_COMMAND_D_EX(delete, "delete watchpoint", 'd', watch_delete, NULL, "s", 0),
- PHPDBG_COMMAND_D_EX(recursive, "create recursive watchpoints", 'r', watch_recursive, NULL, "s", 0),
- PHPDBG_END_COMMAND
-};
+extern const phpdbg_command_t phpdbg_watch_commands[];
/* Watchpoint functions/typedefs */
typedef enum {
WATCH_ON_ZVAL,
WATCH_ON_HASHTABLE,
+ WATCH_ON_REFCOUNTED,
} phpdbg_watchtype;
-#define PHPDBG_WATCH_SIMPLE 0x0
-#define PHPDBG_WATCH_RECURSIVE 0x1
+#define PHPDBG_WATCH_SIMPLE 0x0
+#define PHPDBG_WATCH_RECURSIVE 0x1
+#define PHPDBG_WATCH_ARRAY 0x2
+#define PHPDBG_WATCH_OBJECT 0x4
typedef struct _phpdbg_watchpoint_t phpdbg_watchpoint_t;
struct _phpdbg_watchpoint_t {
- phpdbg_watchpoint_t *parent;
- HashTable *parent_container;
- char *name_in_parent;
- size_t name_in_parent_len;
- char *str;
- size_t str_len;
union {
zval *zv;
HashTable *ht;
+ zend_refcounted *ref;
void *ptr;
} addr;
size_t size;
phpdbg_watchtype type;
char flags;
+ phpdbg_watchpoint_t *parent;
+ HashTable *parent_container;
+ char *name_in_parent;
+ size_t name_in_parent_len;
+ char *str;
+ size_t str_len;
};
+typedef struct {
+ phpdbg_watchpoint_t watch;
+ unsigned int num;
+ unsigned int refs;
+ HashTable watches;
+} phpdbg_watch_collision;
+
void phpdbg_setup_watchpoints(TSRMLS_D);
#ifndef _WIN32
@@ -102,11 +104,11 @@ void phpdbg_watch_efree(void *ptr);
static long phpdbg_pagesize;
static zend_always_inline void *phpdbg_get_page_boundary(void *addr) {
- return (void *)((size_t)addr & ~(phpdbg_pagesize - 1));
+ return (void *) ((size_t) addr & ~(phpdbg_pagesize - 1));
}
static zend_always_inline size_t phpdbg_get_total_page_size(void *addr, size_t size) {
- return (size_t)phpdbg_get_page_boundary((void *)((size_t)addr + size - 1)) - (size_t)phpdbg_get_page_boundary(addr) + phpdbg_pagesize;
+ return (size_t) phpdbg_get_page_boundary((void *) ((size_t) addr + size - 1)) - (size_t) phpdbg_get_page_boundary(addr) + phpdbg_pagesize;
}
#endif
diff --git a/sapi/phpdbg/phpdbg_webdata_transfer.c b/sapi/phpdbg/phpdbg_webdata_transfer.c
index e7438ea01a..2f18b9d082 100644
--- a/sapi/phpdbg/phpdbg_webdata_transfer.c
+++ b/sapi/phpdbg/phpdbg_webdata_transfer.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -19,93 +19,87 @@
#include "phpdbg_webdata_transfer.h"
#include "ext/json/php_json.h"
+static int phpdbg_is_auto_global(char *name, int len TSRMLS_DC) {
+ int ret;
+ zend_string *str = zend_string_init(name, len, 0);
+ ret = zend_is_auto_global(str TSRMLS_CC);
+ efree(str);
+ return ret;
+}
+
PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) {
#ifdef HAVE_JSON
smart_str buf = {0};
zval array;
HashTable *ht;
- /* I really need to change that to an array of zvals... */
- zval zv1 = {{0}}, *zvp1 = &zv1;
- zval zv2 = {{0}}, *zvp2 = &zv2;
- zval zv3 = {{0}}, *zvp3 = &zv3;
- zval zv4 = {{0}}, *zvp4 = &zv4;
- zval zv5 = {{0}}, *zvp5 = &zv5;
- zval zv6 = {{0}}, *zvp6 = &zv6;
- zval zv7 = {{0}}, *zvp7 = &zv7;
- zval zv8 = {{0}}, *zvp8 = &zv8;
+ zval zv[9] = {{{0}}};
array_init(&array);
ht = Z_ARRVAL(array);
/* fetch superglobals */
{
- zend_is_auto_global(ZEND_STRL("GLOBALS") TSRMLS_CC);
+ phpdbg_is_auto_global(ZEND_STRL("GLOBALS") TSRMLS_CC);
/* might be JIT */
- zend_is_auto_global(ZEND_STRL("_ENV") TSRMLS_CC);
- zend_is_auto_global(ZEND_STRL("_SERVER") TSRMLS_CC);
- zend_is_auto_global(ZEND_STRL("_REQUEST") TSRMLS_CC);
- array_init(&zv1);
- zend_hash_copy(Z_ARRVAL(zv1), &EG(symbol_table), NULL, (void *) NULL, sizeof(zval *));
- Z_ARRVAL(zv1)->pDestructor = NULL; /* we're operating on a copy! Don't double free zvals */
- zend_hash_del(Z_ARRVAL(zv1), "GLOBALS", sizeof("GLOBALS")); /* do not use the reference to itself in json */
- zend_hash_add(ht, "GLOBALS", sizeof("GLOBALS"), &zvp1, sizeof(zval *), NULL);
+ phpdbg_is_auto_global(ZEND_STRL("_ENV") TSRMLS_CC);
+ phpdbg_is_auto_global(ZEND_STRL("_SERVER") TSRMLS_CC);
+ phpdbg_is_auto_global(ZEND_STRL("_REQUEST") TSRMLS_CC);
+ array_init(&zv[1]);
+ zend_hash_copy(Z_ARRVAL(zv[1]), &EG(symbol_table).ht, NULL);
+ Z_ARRVAL(zv[1])->pDestructor = NULL; /* we're operating on a copy! Don't double free zvals */
+ zend_hash_str_del(Z_ARRVAL(zv[1]), ZEND_STRL("GLOBALS")); /* do not use the reference to itself in json */
+ zend_hash_str_add(ht, ZEND_STRL("GLOBALS"), &zv[1]);
}
/* save php://input */
{
php_stream *stream;
- int len;
- char *contents;
+ zend_string *str;
stream = php_stream_temp_create_ex(TEMP_STREAM_DEFAULT, SAPI_POST_BLOCK_SIZE, PG(upload_tmp_dir));
- if ((len = php_stream_copy_to_mem(stream, &contents, PHP_STREAM_COPY_ALL, 0)) > 0) {
- ZVAL_STRINGL(&zv2, contents, len, 0);
+ if ((str = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0))) {
+ ZVAL_STR(&zv[2], str);
} else {
- ZVAL_EMPTY_STRING(&zv2);
+ ZVAL_EMPTY_STRING(&zv[2]);
}
- Z_SET_REFCOUNT(zv2, 2);
- zend_hash_add(ht, "input", sizeof("input"), &zvp2, sizeof(zval *), NULL);
+ Z_SET_REFCOUNT(zv[2], 1);
+ zend_hash_str_add(ht, ZEND_STRL("input"), &zv[2]);
}
/* change sapi name */
{
if (sapi_module.name) {
- ZVAL_STRING(&zv6, sapi_module.name, 0);
+ ZVAL_STRING(&zv[6], sapi_module.name);
} else {
- Z_TYPE(zv6) = IS_NULL;
+ Z_TYPE_INFO(zv[6]) = IS_NULL;
}
- Z_SET_REFCOUNT(zv6, 2);
- zend_hash_add(ht, "sapi_name", sizeof("sapi_name"), &zvp6, sizeof(zval *), NULL);
+ zend_hash_str_add(ht, ZEND_STRL("sapi_name"), &zv[6]);
+ Z_SET_REFCOUNT(zv[6], 1);
}
/* handle modules / extensions */
{
- HashPosition position;
zend_module_entry *module;
zend_extension *extension;
zend_llist_position pos;
- array_init(&zv7);
- for (zend_hash_internal_pointer_reset_ex(&module_registry, &position);
- zend_hash_get_current_data_ex(&module_registry, (void**) &module, &position) == SUCCESS;
- zend_hash_move_forward_ex(&module_registry, &position)) {
- zval **value = emalloc(sizeof(zval *));
- ALLOC_ZVAL(*value);
- ZVAL_STRING(*value, module->name, 1);
- zend_hash_next_index_insert(Z_ARRVAL(zv7), value, sizeof(zval *), NULL);
- }
- zend_hash_add(ht, "modules", sizeof("modules"), &zvp7, sizeof(zval *), NULL);
+ array_init(&zv[7]);
+ ZEND_HASH_FOREACH_PTR(&module_registry, module) {
+ zval *value = ecalloc(sizeof(zval), 1);
+ ZVAL_STRING(value, module->name);
+ zend_hash_next_index_insert(Z_ARRVAL(zv[7]), value);
+ } ZEND_HASH_FOREACH_END();
+ zend_hash_str_add(ht, ZEND_STRL("modules"), &zv[7]);
- array_init(&zv8);
+ array_init(&zv[8]);
extension = (zend_extension *) zend_llist_get_first_ex(&zend_extensions, &pos);
while (extension) {
- zval **value = emalloc(sizeof(zval *));
- ALLOC_ZVAL(*value);
- ZVAL_STRING(*value, extension->name, 1);
- zend_hash_next_index_insert(Z_ARRVAL(zv8), value, sizeof(zval *), NULL);
+ zval *value = ecalloc(sizeof(zval), 1);
+ ZVAL_STRING(value, extension->name);
+ zend_hash_next_index_insert(Z_ARRVAL(zv[8]), value);
extension = (zend_extension *) zend_llist_get_next_ex(&zend_extensions, &pos);
}
- zend_hash_add(ht, "extensions", sizeof("extensions"), &zvp8, sizeof(zval *), NULL);
+ zend_hash_str_add(ht, ZEND_STRL("extensions"), &zv[8]);
}
/* switch cwd */
@@ -119,67 +113,58 @@ PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) {
ret = VCWD_GETWD(path);
#endif
if (ret) {
- ZVAL_STRING(&zv5, path, 1);
- Z_SET_REFCOUNT(zv5, 1);
- zend_hash_add(ht, "cwd", sizeof("cwd"), &zvp5, sizeof(zval *), NULL);
+ ZVAL_STRING(&zv[5], path);
+ Z_SET_REFCOUNT(zv[5], 1);
+ zend_hash_str_add(ht, ZEND_STRL("cwd"), &zv[5]);
}
}
/* get system ini entries */
{
- HashPosition position;
zend_ini_entry *ini_entry;
- array_init(&zv3);
- for (zend_hash_internal_pointer_reset_ex(EG(ini_directives), &position);
- zend_hash_get_current_data_ex(EG(ini_directives), (void**) &ini_entry, &position) == SUCCESS;
- zend_hash_move_forward_ex(EG(ini_directives), &position)) {
- zval **value = emalloc(sizeof(zval *));
+ array_init(&zv[3]);
+ ZEND_HASH_FOREACH_PTR(EG(ini_directives), ini_entry) {
+ zval *value = ecalloc(sizeof(zval), 1);
if (ini_entry->modified) {
if (!ini_entry->orig_value) {
efree(value);
continue;
}
- ALLOC_ZVAL(*value);
- ZVAL_STRINGL(*value, ini_entry->orig_value, ini_entry->orig_value_length, 1);
+ ZVAL_STR(value, ini_entry->orig_value);
} else {
if (!ini_entry->value) {
efree(value);
continue;
}
- ALLOC_ZVAL(*value);
- ZVAL_STRINGL(*value, ini_entry->value, ini_entry->value_length, 1);
+ ZVAL_STR(value, ini_entry->value);
}
- zend_hash_add(Z_ARRVAL(zv3), ini_entry->name, ini_entry->name_length, value, sizeof(zval *), NULL);
- }
- zend_hash_add(ht, "systemini", sizeof("systemini"), &zvp3, sizeof(zval *), NULL);
+ zend_hash_add(Z_ARRVAL(zv[3]), ini_entry->name, value);
+ } ZEND_HASH_FOREACH_END();
+ zend_hash_str_add(ht, ZEND_STRL("systemini"), &zv[3]);
}
/* get perdir ini entries */
if (EG(modified_ini_directives)) {
- HashPosition position;
zend_ini_entry *ini_entry;
- array_init(&zv4);
- for (zend_hash_internal_pointer_reset_ex(EG(modified_ini_directives), &position);
- zend_hash_get_current_data_ex(EG(modified_ini_directives), (void**) &ini_entry, &position) == SUCCESS;
- zend_hash_move_forward_ex(EG(modified_ini_directives), &position)) {
- zval **value = emalloc(sizeof(zval *));
+ array_init(&zv[4]);
+ ZEND_HASH_FOREACH_PTR(EG(ini_directives), ini_entry) {
+ zval *value = ecalloc(sizeof(zval), 1);
if (!ini_entry->value) {
efree(value);
continue;
}
- ALLOC_ZVAL(*value);
- ZVAL_STRINGL(*value, ini_entry->value, ini_entry->value_length, 1);
- zend_hash_add(Z_ARRVAL(zv4), ini_entry->name, ini_entry->name_length, value, sizeof(zval *), NULL);
- }
- zend_hash_add(ht, "userini", sizeof("userini"), &zvp4, sizeof(zval *), NULL);
+ ZVAL_STR(value, ini_entry->value);
+ zend_hash_add(Z_ARRVAL(zv[4]), ini_entry->name, value);
+ } ZEND_HASH_FOREACH_END();
+ zend_hash_str_add(ht, ZEND_STRL("userini"), &zv[4]);
}
/* encode data */
php_json_encode(&buf, &array, 0 TSRMLS_CC);
- *msg = buf.c;
- *len = buf.len;
+ *msg = buf.s->val;
+ *len = buf.s->len;
zval_dtor(&array);
#endif
}
diff --git a/sapi/phpdbg/tests/run-tests.php b/sapi/phpdbg/tests/run-tests.php
index 1cc31d815e..4afb64561c 100644
--- a/sapi/phpdbg/tests/run-tests.php
+++ b/sapi/phpdbg/tests/run-tests.php
@@ -389,7 +389,7 @@ namespace phpdbg\testing {
} break;
default: {
- $this->$chunks[0] = $chunks[1];
+ $this->{$chunks[0]} = $chunks[1];
}
}
} else switch(substr($trim, 1, 1)) {
diff --git a/sapi/phpdbg/xml.md b/sapi/phpdbg/xml.md
index 0556fb2415..7871b31376 100644
--- a/sapi/phpdbg/xml.md
+++ b/sapi/phpdbg/xml.md
@@ -60,7 +60,6 @@ type
- general attribute for most errors, describes the genre of the error
-
General tags
============
@@ -78,11 +77,6 @@ intro
- help: command name for help
- report: URL for bug reporting
-prompt
-------
-
-- msg tag contains the text prompt
-- indicates that a new command may be accepted
phpdbg
------
@@ -257,23 +251,6 @@ info (subcommands)
- &lt;lasterror error="" (file="" line="") />
- error attribute contains the last error as a string, is empty if there's no last error
-### constants ###
-
-- &lt;constantinfo num="" /> with num having an integer value, indicating the number of (local or superglobal) variables
-- if info vars was used it'll have also one of these attributes:
- - method
- - function
- - file
- - opline
-- for each variable there is a &lt;constant> element
-- &lt;constant address="" refcount="" type="" name="" />
- - address: pointer to zval (hexadecimal)
- - refcount: refcount of zval
- - type: the variable type (long, string, ...). If the value is "unknown", the other attributes are meaningless
- - name: the name of the variable
- - value: the value of primitive types (scalars) => string/int/bool/double
- - length: if string, then the length of that string
-
### vars / globals ###
- &lt;variableinfo num="" /> with num having an integer value, indicating the number of (local or superglobal) variables
@@ -282,7 +259,7 @@ info (subcommands)
- function
- file
- opline
-- for each variable there is a &lt;variable> element
+- for each variable there is a &lt;variable> followed by a &lt;variabledetails> element
- &lt;variable address="" refcount="" type="" name="" />
- address: pointer to zval (hexadecimal)
- refcount: refcount of zval
@@ -291,8 +268,6 @@ info (subcommands)
- refstatus: empty if the zval is not a reference
- class: the class the object in the zval is an instance of
- resource: the type of the resource in the zval
- - value: the value of primitive types (scalars) => string/int/bool/double
- - length: if string, then the length of that string
### literal ###
@@ -461,8 +436,6 @@ ev
- eval()uates some code
- output wrapped in &lt;eval> tags
-- output is here first a dump of xml tags (see "Variable Dump" section), then a dump wrapped in <stream> tags
-- if there's an error, the tag will be <eval>, instead of the usual <php> tag
sh
--
@@ -636,7 +609,6 @@ dl
- errors may have the module or extension attribute when their name is already known at the point of failure
-
Other tags
==========
@@ -677,83 +649,3 @@ Other tags
- generally emitted when data couldn't be fetched (e.g. by accessing inconsistent data); only used in hard interrupt mode
- it might mean that data couldn't be fetched at all, or that only incomplete data was fetched (e.g. when a fixed number of following attributes are fetched, this tag will mark a stop of fetching if none or not all tags were printed)
-
-
-Variable Dump
-=============
-
-- all except property and element tags have a refstatus attribute, is set to non-empty if it's a reference
-
-object properties
------------------
-
-- wrapped in a property tag &lt;property name="" protection="">
- - name: name of key
- - protection: one of these three values: public / protected / private
- - class: only present if protection attribute is set to "private", contains the name of the class to which the property belongs
-- if the property tag contains any serverity="error" attribute, there was some crucial error to read it, just skip it
-
-array elements
---------------
-- wrapped in an element tag &lt;property name="" protection="">
- - name: name of key
-- if the element tag contains any serverity="error" attribute, there was some crucial error to read it, jsut skip it
-
-int
----
-
-- &lt;int refstatus="" value="" />
- - value is the integer
-
-float
------
-
-- &lt;float refstatus="" value="" />
- - value is the float
-
-bool
-----
-
-- &lt;bool refstatus="" value="" />
- -value: true or false
-
-string
-------
-
-- &lt;string refstatus="" length="" value="" />
- - length: length or string
- - value: the string
-
-null
-----
-
-- &lt;null refstatus="" />
-
-array
------
-
-- &lt;array refstatus="" num="">
- - num: number of elements
- - contains &lt;element> tags
-
-object
-------
-
-- &lt;object refstatus="" class="" id="" num="">
- - class: name of the class the object is an instance of (may be empty if unknown)
- - id: id of the object
- - num: number of properties
- - contains &lt;property> tags
-
-resource
---------
-
-- &lt;resource refstatus="" id="" type="" />
- - id: resource id
- - type: type of resource
-
-recursion
----------
-
-- &lt;recursion />
-- if that tag appears, there's a recursive reference inside the value to be printed
diff --git a/sapi/phttpd/php_phttpd.h b/sapi/phttpd/php_phttpd.h
index 92409ac905..73c76cec0b 100644
--- a/sapi/phttpd/php_phttpd.h
+++ b/sapi/phttpd/php_phttpd.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c
index 60fc48ba35..ba8dfe3838 100644
--- a/sapi/phttpd/phttpd.c
+++ b/sapi/phttpd/phttpd.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/pi3web/README b/sapi/pi3web/README
index e3e523e940..e7726edcf4 100644
--- a/sapi/pi3web/README
+++ b/sapi/pi3web/README
@@ -1,36 +1,36 @@
-PHP5 Module
+PHP7 Module
==========
-This module requires PHP5 as thread safe shared library. Have a look
+This module requires PHP7 as thread safe shared library. Have a look
into the INSTALL file which accompanies that distribution.
If you distribute this software bundled with the PHP software in source
or binary form, then you must adhere to the PHP copyright conditions -
the terms are reasonable.
-You should have checked out and built the PHP5 source package from the
-PHP CVS tree into the Pi3Web source directory called 'PHP5' first. Then
-build PHP5 as Pi3Web module and after that build the Pi3Web PHP5 wrapper:
+You should have checked out and built the PHP7 source package from the
+PHP CVS tree into the Pi3Web source directory called 'PHP7' first. Then
+build PHP7 as Pi3Web module and after that build the Pi3Web PHP7 wrapper:
-1. Checkout PHP5
+1. Checkout PHP7
================
cvs -d :pserver:cvsread@cvs.php.net:/repository login
The required password is phpfi
-cvs -z3 -d :pserver:cvsread@cvs.php.net:/repository co php5
+cvs -z3 -d :pserver:cvsread@cvs.php.net:/repository co php7
You must also checkout the TSRM and the ZEND module from the ZEND cvs tree
-into the PHP5 root directory
+into the PHP7 root directory
cvs -d :pserver:cvsread@cvs.zend.com:/repository login
The required password is zend
cvs -z3 -d :pserver:cvsread@cvs.zend.com:/repository co Zend TSRM
-2. Build PHP5
+2. Build PHP7
=============
2.1 POSIX
---------
-cd ./php5
+cd ./php7
./buildconf
./configure --with-pi3web
make
@@ -41,10 +41,10 @@ other required downloads from the php website
- bison 1.25
- bindlib32
- number4.tar.gz
-nmake php5dllts.mak
+nmake php7dllts.mak
-3. Build Pi3Web PHP5 wrapper
+3. Build Pi3Web PHP7 wrapper
============================
-Run make in the Pi3Web /Source/PHP5 directory.
+Run make in the Pi3Web /Source/PHP7 directory.
For further information refer to http://www.php.net/version4/
diff --git a/sapi/pi3web/config.m4 b/sapi/pi3web/config.m4
index 347a74ca06..42ff164394 100644
--- a/sapi/pi3web/config.m4
+++ b/sapi/pi3web/config.m4
@@ -17,7 +17,7 @@ if test "$PHP_PI3WEB" != "no"; then
PHP_ADD_INCLUDE($PI3PATH/PiAPI)
PHP_ADD_INCLUDE($PI3PATH/Pi2API)
PHP_ADD_INCLUDE($PI3PATH/Pi3API)
- PHP_ADD_INCLUDE($PI3PATH/PHP5)
+ PHP_ADD_INCLUDE($PI3PATH/PHP7)
PHP_SELECT_SAPI(pi3web, shared, pi3web_sapi.c)
INSTALL_IT="\$(SHELL) \$(srcdir)/install-sh -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)$PI3PATH/bin/"
fi
diff --git a/sapi/pi3web/config.w32 b/sapi/pi3web/config.w32
index a5393e621b..9441784468 100644
--- a/sapi/pi3web/config.w32
+++ b/sapi/pi3web/config.w32
@@ -8,7 +8,7 @@ if (PHP_PI3WEB != "no") {
CHECK_LIB('piapi.lib', 'pi3web', PHP_PHP_BUILD + "\\Pi3Web\\lib;" + PHP_PI3WEB) &&
CHECK_LIB('pi2api.lib', 'pi3web', PHP_PHP_BUILD + "\\Pi3Web\\lib;" + PHP_PI3WEB) &&
CHECK_LIB('pi3api.lib', 'pi3web', PHP_PHP_BUILD + "\\Pi3Web\\lib;" + PHP_PI3WEB)) {
- SAPI('pi3web', 'pi3web_sapi.c', 'php' + PHP_VERSION + 'pi3web.dll', '/D PHP5PI3WEB_EXPORTS');
+ SAPI('pi3web', 'pi3web_sapi.c', 'php' + PHP_VERSION + 'pi3web.dll', '/D PHP7PI3WEB_EXPORTS');
AC_DEFINE('WITH_PI3WEB', 1);
} else {
WARNING('Pi3Web not enabled; headers/libraries not found');
diff --git a/sapi/pi3web/php5pi3web.dsp b/sapi/pi3web/php5pi3web.dsp
deleted file mode 100644
index bb5a248802..0000000000
--- a/sapi/pi3web/php5pi3web.dsp
+++ /dev/null
@@ -1,136 +0,0 @@
-# Microsoft Developer Studio Project File - Name="php5pi3web" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=php5pi3web - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php5pi3web.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php5pi3web.mak" CFG="php5pi3web - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php5pi3web - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php5pi3web - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php5pi3web - Win32 Release_TS_inline" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php5pi3web - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\..\Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "php5pi3web_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /I "..\..\..\..\PIAPI" /I "..\..\..\..\PI2API" /I "..\..\..\..\PI3API" /D "_DEBUG" /D ZEND_DEBUG=1 /D "_WINDOWS" /D "_USRDLL" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /D "PHP5PI3WEB_EXPORTS" /FR /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "_DEBUG"
-# ADD RSC /l 0x40d /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 php5ts_debug.lib 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 PiAPI.lib Pi2API.lib Pi3API.lib /nologo /version:4.0 /dll /debug /machine:I386 /nodefaultlib:"libcmt" /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\Debug_TS" /libpath:"..\..\..\..\PIAPI" /libpath:"..\..\..\..\PI2API" /libpath:"..\..\..\..\PI3API"
-
-!ELSEIF "$(CFG)" == "php5pi3web - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "php5pi3web_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /I "..\..\..\..\PIAPI" /I "..\..\..\..\PI2API" /I "..\..\..\..\PI3API" /D "NDEBUG" /D ZEND_DEBUG=0 /D "_WINDOWS" /D "_USRDLL" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /D "PHP5PI3WEB_EXPORTS" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 php5ts.lib 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 PiAPI.lib Pi2API.lib Pi3API.lib /nologo /version:4.0 /dll /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libcmt.lib" /libpath:"..\..\Release_TS" /libpath:"..\..\..\..\PIAPI" /libpath:"..\..\..\..\PI2API" /libpath:"..\..\..\..\PI3API"
-
-!ELSEIF "$(CFG)" == "php5pi3web - Win32 Release_TS_inline"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "php5pi3web___Win32_Release_TS_inline"
-# PROP BASE Intermediate_Dir "php5pi3web___Win32_Release_TS_inline"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS_inline"
-# PROP Intermediate_Dir "Release_TS_inline"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I ".." /I "..\main" /I "..\regex" /I "..\..\bindlib_w32" /I "..\Zend" /I "..\TSRM" /I "..\ext\mysql\libmysql" /I "..\..\..\PiAPI" /I "..\..\..\Pi2API" /I "..\..\..\Pi3API" /D "NDEBUG" /D ZEND_DEBUG=0 /D "_WINDOWS" /D "_USRDLL" /D "PHP5DLLTS_EXPORTS" /D "PHP_EXPORTS" /D "LIBZEND_EXPORTS" /D "TSRM_EXPORTS" /D "SAPI_EXPORTS" /D "MSVC5" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /I "..\..\..\..\PIAPI" /I "..\..\..\..\PI2API" /I "..\..\..\..\PI3API" /D "NDEBUG" /D ZEND_DEBUG=0 /D "ZEND_WIN32_FORCE_INLINE" /D "_WINDOWS" /D "_USRDLL" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /D "PHP5PI3WEB_EXPORTS" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 ZendTS.lib TSRM.lib resolv.lib libmysql.lib PiAPI.lib Pi2API.lib Pi3API.lib /nologo /version:4.0 /dll /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libcmt.lib" /out:"..\Release_TS\php5ts.dll" /libpath:"..\TSRM\Release_TS" /libpath:"..\Zend\Release_TS" /libpath:"..\..\bindlib_w32\Release" /libpath:"..\ext\mysql\libmysql\Release_TS" /libpath:"Release_TS" /libpath:"..\..\..\PiAPI" /libpath:"..\..\..\Pi2API" /libpath:"..\..\..\Pi3API"
-# ADD LINK32 php5ts.lib 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 PiAPI.lib Pi2API.lib Pi3API.lib /nologo /version:4.0 /dll /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libcmt.lib" /libpath:"..\..\Release_TS_inline" /libpath:"..\..\..\..\PIAPI" /libpath:"..\..\..\..\PI2API" /libpath:"..\..\..\..\PI3API"
-
-!ENDIF
-
-# Begin Target
-
-# Name "php5pi3web - Win32 Debug_TS"
-# Name "php5pi3web - Win32 Release_TS"
-# Name "php5pi3web - Win32 Release_TS_inline"
-# Begin Group "Source Files"
-
-# PROP Default_Filter ".c"
-# Begin Source File
-
-SOURCE=.\pi3web_sapi.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter ".h"
-# Begin Source File
-
-SOURCE=.\pi3web_sapi.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/sapi/pi3web/pi3web_sapi.c b/sapi/pi3web/pi3web_sapi.c
index 4bc08e5382..d92526cf5e 100644
--- a/sapi/pi3web/pi3web_sapi.c
+++ b/sapi/pi3web/pi3web_sapi.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -342,7 +342,7 @@ static sapi_module_struct pi3web_sapi_module = {
STANDARD_SAPI_MODULE_PROPERTIES
};
-MODULE_API DWORD PHP5_wrapper(LPCONTROL_BLOCK lpCB)
+MODULE_API DWORD PHP7_wrapper(LPCONTROL_BLOCK lpCB)
{
zend_file_handle file_handle = {0};
int iRet = PIAPI_COMPLETED;
@@ -385,7 +385,7 @@ MODULE_API DWORD PHP5_wrapper(LPCONTROL_BLOCK lpCB)
}
if ( open_file_for_scanning( &file_handle TSRMLS_CC ) == SUCCESS )
{
- zend_indent();
+ zend_indent(TSRMLS_C);
}
else
{
@@ -411,7 +411,7 @@ MODULE_API DWORD PHP5_wrapper(LPCONTROL_BLOCK lpCB)
return iRet;
}
-MODULE_API BOOL PHP5_startup() {
+MODULE_API BOOL PHP7_startup() {
tsrm_startup(1, 1, 0, NULL);
sapi_startup(&pi3web_sapi_module);
if (pi3web_sapi_module.startup) {
@@ -421,7 +421,7 @@ MODULE_API BOOL PHP5_startup() {
return IWasLoaded;
};
-MODULE_API BOOL PHP5_shutdown() {
+MODULE_API BOOL PHP7_shutdown() {
if (pi3web_sapi_module.shutdown) {
pi3web_sapi_module.shutdown(&pi3web_sapi_module);
};
diff --git a/sapi/pi3web/pi3web_sapi.h b/sapi/pi3web/pi3web_sapi.h
index d229fec53f..83f483d924 100644
--- a/sapi/pi3web/pi3web_sapi.h
+++ b/sapi/pi3web/pi3web_sapi.h
@@ -3,7 +3,7 @@
#ifdef PHP_WIN32
# include <windows.h>
-# ifdef PHP5PI3WEB_EXPORTS
+# ifdef PHP7PI3WEB_EXPORTS
# define MODULE_API __declspec(dllexport)
# else
# define MODULE_API __declspec(dllimport)
@@ -86,9 +86,9 @@ typedef struct _CONTROL_BLOCK {
} CONTROL_BLOCK, *LPCONTROL_BLOCK;
-MODULE_API DWORD PHP5_wrapper(LPCONTROL_BLOCK lpCB);
-MODULE_API BOOL PHP5_startup();
-MODULE_API BOOL PHP5_shutdown();
+MODULE_API DWORD PHP7_wrapper(LPCONTROL_BLOCK lpCB);
+MODULE_API BOOL PHP7_startup();
+MODULE_API BOOL PHP7_shutdown();
// the following type declaration is for the server side
typedef DWORD ( * PFN_WRAPPERFUNC )( CONTROL_BLOCK *pCB );
diff --git a/sapi/roxen/README b/sapi/roxen/README
index d834a0000e..59c215cba0 100644
--- a/sapi/roxen/README
+++ b/sapi/roxen/README
@@ -8,9 +8,9 @@ script is executed at any one time). The second option is using ZTS
(Zend Thread Safe mode). Unless --enable-roxen-zts is specified, this
won't be used.
-This solution now works fine and is recommended. Multiple PHP5
+This solution now works fine and is recommended. Multiple PHP7
requests will be run in parallell. The maximum number of parallell
-PHP5-execution is limited to the number of handle threads Roxen is
+PHP7-execution is limited to the number of handle threads Roxen is
started with.
Support for this module is lacking. Please contact Roxen Internet
diff --git a/sapi/roxen/TODO b/sapi/roxen/TODO
index 248f36f52e..47143f1be1 100644
--- a/sapi/roxen/TODO
+++ b/sapi/roxen/TODO
@@ -10,18 +10,18 @@ BUGS:
And another error (when trying to include a class)
Recursive mutex locks!
- /Usr/local/pike/7.0.54/lib/modules/PHP5.so.Interpreter:
- run("/home/www/www.tx.pl/news/test.php",mapping[3],modules/scripting/php5.pike.PHPScript(),modules/scripting/php5.pike.PHPScript.done)
- modules/scripting/php5.pike:169: run()
+ /Usr/local/pike/7.0.54/lib/modules/PHP7.so.Interpreter:
+ run("/home/www/www.tx.pl/news/test.php",mapping[3],modules/scripting/php7.pike.PHPScript(),modules/scripting/php7.pike.PHPScript.done)
+ modules/scripting/php7.pike:169: run()
base_server/roxen.pike:569: handler_thread(3).
And after this every access to any php script (on other virtual sites
also) ends (of course there is no proper output) with this error:
Php4.Interpreter->run: Tried to run a PHP-script from a PHP
- callback!/usr/local/pike/7.0.54/lib/modules/PHP5.so.Interpreter:
- run("/home/www/biall.com.pl/index.php3",mapping[2],modules/scripting/php5.pike.PHPScript(),modules/scripting/php5.pike.PHPScript.done)
- modules/scripting/php5.pike:169: run()
+ callback!/usr/local/pike/7.0.54/lib/modules/PHP7.so.Interpreter:
+ run("/home/www/biall.com.pl/index.php3",mapping[2],modules/scripting/php7.pike.PHPScript(),modules/scripting/php7.pike.PHPScript.done)
+ modules/scripting/php7.pike:169: run()
base_server/roxen.pike:569: handler_thread(3).
diff --git a/sapi/roxen/config.m4 b/sapi/roxen/config.m4
index 7601b0c1ed..d536ac571b 100644
--- a/sapi/roxen/config.m4
+++ b/sapi/roxen/config.m4
@@ -36,7 +36,7 @@ if test "$PHP_ROXEN" != "no"; then
PHP_ADD_INCLUDE($PIKE_INCLUDE_DIR)
AC_DEFINE(HAVE_ROXEN, 1, [Whether you use Roxen])
PHP_SELECT_SAPI(roxen, shared, roxen.c)
- INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $PIKE_MODULE_DIR/PHP5.so"
+ INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $PIKE_MODULE_DIR/PHP7.so"
RESULT="yes
Pike binary used: $PIKE
Pike include dir: $PIKE_INCLUDE_DIR
diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c
index b3a64345ea..756f7353e9 100644
--- a/sapi/roxen/roxen.c
+++ b/sapi/roxen/roxen.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -387,13 +387,12 @@ php_roxen_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
* the client. Used for POST/PUT requests.
*/
-INLINE static int php_roxen_low_read_post(char *buf, uint count_bytes)
+INLINE static int php_roxen_low_read_post(char *buf, uint count_bytes TSRMLS_DC)
{
uint total_read = 0;
#ifdef ROXEN_USE_ZTS
GET_THIS();
#endif
- TSRMLS_FETCH();
if(!MY_FD_OBJ->prog)
{
@@ -417,7 +416,7 @@ static int
php_roxen_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC)
{
uint total_read = 0;
- THREAD_SAFE_RUN(total_read = php_roxen_low_read_post(buf, count_bytes), "read post");
+ THREAD_SAFE_RUN(total_read = php_roxen_low_read_post(buf, count_bytes TSRMLS_CC), "read post");
return total_read;
}
@@ -617,12 +616,12 @@ void f_php_roxen_request_handler(INT32 args)
TSRMLS_FETCH();
if(current_thread == th_self())
- php_error(E_WARNING, "PHP5.Interpreter->run: Tried to run a PHP-script from a PHP "
+ php_error(E_WARNING, "PHP7.Interpreter->run: Tried to run a PHP-script from a PHP "
"callback!");
- get_all_args("PHP5.Interpreter->run", args, "%S%m%O%*", &script,
+ get_all_args("PHP7.Interpreter->run", args, "%S%m%O%*", &script,
&request_data, &my_fd_obj, &done_callback);
if(done_callback->type != PIKE_T_FUNCTION)
- php_error(E_WARNING, "PHP5.Interpreter->run: Bad argument 4, expected function.\n");
+ php_error(E_WARNING, "PHP7.Interpreter->run: Bad argument 4, expected function.\n");
PHP_LOCK(THIS); /* Need to lock here or reusing the same object might cause
* problems in changing stuff in that object */
#ifndef ROXEN_USE_ZTS
@@ -658,7 +657,7 @@ void f_php_roxen_request_handler(INT32 args)
{
int fd = fd_from_object(raw_fd->u.object);
if(fd == -1)
- php_error(E_WARNING, "PHP5.Interpreter->run: my_fd object not open or not an FD.\n");
+ php_error(E_WARNING, "PHP7.Interpreter->run: my_fd object not open or not an FD.\n");
THIS->my_fd = fd;
} else
THIS->my_fd = 0;
diff --git a/sapi/thttpd/config.m4 b/sapi/thttpd/config.m4
index 371edaee84..fddb709d92 100644
--- a/sapi/thttpd/config.m4
+++ b/sapi/thttpd/config.m4
@@ -25,10 +25,10 @@ if test "$PHP_THTTPD" != "no"; then
fi
PHP_TARGET_RDYNAMIC
INSTALL_IT="\
- echo 'PHP_LIBS = -L. -lphp5 \$(PHP_LIBS) \$(EXTRA_LIBS)' > $THTTPD/php_makefile; \
+ echo 'PHP_LIBS = -L. -lphp7 \$(PHP_LIBS) \$(EXTRA_LIBS)' > $THTTPD/php_makefile; \
echo 'PHP_LDFLAGS = \$(NATIVE_RPATHS) \$(PHP_LDFLAGS)' >> $THTTPD/php_makefile; \
echo 'PHP_CFLAGS = \$(COMMON_FLAGS) \$(CFLAGS_CLEAN) \$(CPPFLAGS) \$(EXTRA_CFLAGS)' >> $THTTPD/php_makefile; \
- rm -f $THTTPD/php_thttpd.c $THTTPD/php_thttpd.h $THTTPD/libphp5.a; \
+ rm -f $THTTPD/php_thttpd.c $THTTPD/php_thttpd.h $THTTPD/libphp7.a; \
\$(LN_S) $abs_srcdir/sapi/thttpd/thttpd.c $THTTPD/php_thttpd.c; \
\$(LN_S) $abs_srcdir/sapi/thttpd/php_thttpd.h $abs_builddir/$SAPI_STATIC $THTTPD/;\
$patch"
diff --git a/sapi/thttpd/php_thttpd.h b/sapi/thttpd/php_thttpd.h
index 75e79b4054..df7fb455e1 100644
--- a/sapi/thttpd/php_thttpd.h
+++ b/sapi/thttpd/php_thttpd.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c
index 843e4a62fb..7c03454f58 100644
--- a/sapi/thttpd/thttpd.c
+++ b/sapi/thttpd/thttpd.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -27,7 +27,7 @@
#include "php_ini.h"
#include "zend_highlight.h"
-#include "ext/standard/php_smart_str.h"
+#include "zend_smart_str.h"
#include <sys/time.h>
#include <sys/types.h>
@@ -181,7 +181,7 @@ static int sapi_thttpd_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
if (!SG(sapi_headers).http_status_line) {
ADD_VEC_S("HTTP/1.1 ");
- p = smart_str_print_long(buf+sizeof(buf)-1,
+ p = zend_print_long_to_buf(buf+sizeof(buf)-1,
SG(sapi_headers).http_response_code);
ADD_VEC(p, strlen(p));
ADD_VEC_S(" HTTP\r\n");
@@ -293,7 +293,7 @@ static void sapi_thttpd_register_variables(zval *track_vars_array TSRMLS_DC)
ADD_STRING_EX("REMOTE_HOST", p);
ADD_STRING_EX("SERVER_PORT",
- smart_str_print_long(buf + sizeof(buf) - 1,
+ zend_print_long_to_buf(buf + sizeof(buf) - 1,
TG(hc)->hs->port));
buf[0] = '/';
@@ -323,7 +323,7 @@ static void sapi_thttpd_register_variables(zval *track_vars_array TSRMLS_DC)
if (TG(hc)->contentlength != -1) {
ADD_STRING_EX("CONTENT_LENGTH",
- smart_str_print_long(buf + sizeof(buf) - 1,
+ zend_print_long_to_buf(buf + sizeof(buf) - 1,
TG(hc)->contentlength));
}
@@ -349,11 +349,12 @@ static zend_module_entry php_thttpd_module = {
STANDARD_MODULE_PROPERTIES
};
-static int php_thttpd_startup(sapi_module_struct *sapi_module)
+static int php_thttpd_startup(sapi_module_struct *sapi_module TSRMLS_DC)
{
#if PHP_API_VERSION >= 20020918
if (php_module_startup(sapi_module, &php_thttpd_module, 1) == FAILURE) {
#else
+ /* No TSRMLS_CC here to zend_startup_module() as 5.6 and older does not have that parameter */
if (php_module_startup(sapi_module) == FAILURE
|| zend_startup_module(&php_thttpd_module) == FAILURE) {
#endif
@@ -467,7 +468,7 @@ static void thttpd_request_ctor(TSRMLS_D)
static void thttpd_request_dtor(TSRMLS_D)
{
- smart_str_free_ex(&TG(sbuf), 1);
+ smart_str_free(&TG(sbuf));
if (SG(request_info).query_string)
free(SG(request_info).query_string);
free(SG(request_info).request_uri);
diff --git a/sapi/thttpd/thttpd_patch b/sapi/thttpd/thttpd_patch
index 33de921489..1a9ed29d60 100644
--- a/sapi/thttpd/thttpd_patch
+++ b/sapi/thttpd/thttpd_patch
@@ -34,7 +34,7 @@ diff -ur thttpd-2.21b/Makefile.in thttpd-2.21b-cool/Makefile.in
this: $(ALL)
-thttpd: $(OBJ)
-+thttpd: $(OBJ) libphp5.a
++thttpd: $(OBJ) libphp7.a
@rm -f $@
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) $(NETLIBS)
@@ -240,7 +240,7 @@ diff -ur thttpd-2.21b/libhttpd.c thttpd-2.21b-cool/libhttpd.c
+
+#define SMART_STR_USE_REALLOC
+
-+#include "ext/standard/php_smart_str.h"
++#include "zend_smart_str.h"
static void
-send_mime( httpd_conn* hc, int status, char* title, char* encodings, char* extraheads, char* type, int length, time_t mod )
diff --git a/sapi/tux/README b/sapi/tux/README
index 92c021123f..3c5ebc56ba 100644
--- a/sapi/tux/README
+++ b/sapi/tux/README
@@ -56,31 +56,31 @@ BUILD INSTRUCTIONS
$ ./configure --help
- 3. Touch a file in your web-root 'php5.tux'. This will
- cause requests to '/php5.tux' to be redirected to the
- userspace module php5.tux.
+ 3. Touch a file in your web-root 'php7.tux'. This will
+ cause requests to '/php7.tux' to be redirected to the
+ userspace module php7.tux.
4. Start TUX with something like
- # tux -d -t 8 -r /www -m /tux-modules php5.tux
+ # tux -d -t 8 -r /www -m /tux-modules php7.tux
(daemon mode, eight threads, web-root /www, modules in
- /tux-modules, load php5.tux)
+ /tux-modules, load php7.tux)
BEFORE running this command, the kernel side of TUX has to
be properly setup.
5. Try to access
- http://yourserver/php5.tux?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000
+ http://yourserver/php7.tux?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000
It should display the PHP credits page.
To access a script /foo/bar.php, use
- http://yourserver/php5.tux?/foo/bar.php
+ http://yourserver/php7.tux?/foo/bar.php
Parameters can be appended:
- http://yourserver/php5.tux?/foo/bar.php&var=value
+ http://yourserver/php7.tux?/foo/bar.php&var=value
diff --git a/sapi/tux/config.m4 b/sapi/tux/config.m4
index 06788be757..db4be82cf1 100644
--- a/sapi/tux/config.m4
+++ b/sapi/tux/config.m4
@@ -7,7 +7,7 @@ PHP_ARG_WITH(tux,,
AC_MSG_CHECKING([for TUX])
if test "$PHP_TUX" != "no"; then
- INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $PHP_TUX/php5.tux.so"
+ INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $PHP_TUX/php7.tux.so"
AC_CHECK_HEADERS(tuxmodule.h,[:],[AC_MSG_ERROR([Cannot find tuxmodule.h])])
PHP_SELECT_SAPI(tux, shared, php_tux.c)
AC_MSG_RESULT([$PHP_TUX])
diff --git a/sapi/tux/php_tux.c b/sapi/tux/php_tux.c
index 55d911f8ab..783fe852bc 100644
--- a/sapi/tux/php_tux.c
+++ b/sapi/tux/php_tux.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -21,7 +21,7 @@
#include "php_main.h"
#include "php_variables.h"
-#include "ext/standard/php_smart_str.h"
+#include "zend_smart_str.h"
#include "tuxmodule.h"
@@ -96,7 +96,7 @@ static int sapi_tux_ub_write(const char *str, uint str_length TSRMLS_DC)
return n;
}
-static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers)
+static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
{
char buf[1024];
struct iovec *vec;
@@ -107,7 +107,6 @@ static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers)
size_t len;
char *status_line;
int locate_cl;
- TSRMLS_FETCH();
max_headers = 30;
n = 1;
@@ -158,11 +157,10 @@ static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers)
return SAPI_HEADER_SENT_SUCCESSFULLY;
}
-static int sapi_tux_read_post(char *buffer, uint count_bytes)
+static int sapi_tux_read_post(char *buffer, uint count_bytes TSRMLS_DC)
{
#if 0
int amount = 0;
- TSRMLS_FETCH();
TG(req)->objectlen = count_bytes;
TG(req)->object_addr = buffer;
@@ -177,10 +175,8 @@ static int sapi_tux_read_post(char *buffer, uint count_bytes)
#endif
}
-static char *sapi_tux_read_cookies(void)
+static char *sapi_tux_read_cookies(TSRMLS_D)
{
- TSRMLS_FETCH();
-
return TG(req)->cookies;
}
diff --git a/sapi/webjames/README b/sapi/webjames/README
index 746a7762fb..15a7be3de0 100644
--- a/sapi/webjames/README
+++ b/sapi/webjames/README
@@ -16,7 +16,7 @@ http://www.webjames.alexwaugh.com/
BUILDING
-$ cd php5
+$ cd php7
$ ./configure \
--host=arm-riscos-aof \
--with-webjames=../webjames/src \
diff --git a/sapi/webjames/php_webjames.h b/sapi/webjames/php_webjames.h
index dcb6cdb911..08f4a11442 100644
--- a/sapi/webjames/php_webjames.h
+++ b/sapi/webjames/php_webjames.h
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
diff --git a/sapi/webjames/webjames.c b/sapi/webjames/webjames.c
index 264f910af4..2978131ac1 100644
--- a/sapi/webjames/webjames.c
+++ b/sapi/webjames/webjames.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+