Compare commits

...
Author SHA1 Message Date
SVN Migration 677471c126 This commit was manufactured by cvs2svn to create tag 'php_4_2_3RC1'. 2002-08-24 01:07:32 +00:00
Zeev Suraski 303da734d9 Update version number, prepare for release 2002-08-24 00:53:54 +00:00
Zeev Suraski 474dcb486e Fix bug #15106 2002-08-24 00:44:03 +00:00
Zeev Suraski 90609154cc MFH security fix 2002-08-23 23:48:48 +00:00
Marcus Boerger bbd3f25d23 MFH 2002-08-23 20:15:38 +00:00
Marcus Boerger 5e56f05afa fixes magically mentioned in NEWS before being commited 2002-08-23 19:59:00 +00:00
Marcus Boerger 1ba9d5eea0 differentiate: Makus, Marcus
#k = Markus Fischer
#c = Marcus Boerger alias helly
2002-08-23 18:25:01 +00:00
foobar a8a233102e I like periods..:) 2002-08-23 17:16:31 +00:00
Edin Kadribasic 139316bfa8 One more 2002-08-23 13:41:26 +00:00
Rasmus Lerdorf c303e2c9f6 Should probably mention this fix too. 2002-08-23 13:02:26 +00:00
Edin Kadribasic fb599af3ed Due credit to Steph. 2002-08-23 09:34:17 +00:00
Zeev Suraski dd81f500c7 Update NEWS (got as far as ext/standard (not inclusive) in the ext/ dir)
Please take a look at it and update it if you find 'bugs'.
2002-08-23 09:17:20 +00:00
Zeev Suraski 416fcc197e Avoid changing behavior in a bug-fix release 2002-08-23 09:14:42 +00:00
Zeev Suraski c17c4e6344 Update, remove somewhat useless entry (we'd have to figure out a way
to update it)
2002-08-23 08:43:14 +00:00
Zeev Suraski 71e7ee097f Fix ob_gzhandler()'s handling of requests without compression, but that do
have an Accept-Encoding header
2002-08-23 08:36:28 +00:00
Zeev Suraski 273a2bf38a Fix a few warnings (MFH) 2002-08-23 08:00:49 +00:00
foobar 48880dc48b Sync with HEAD 2002-08-23 01:18:34 +00:00
Edin Kadribasic 725aa965af Sync install.txt file with the one provided in other 4.2.x distro's. 2002-08-22 15:27:17 +00:00
Rasmus Lerdorf d7ae4db7fe MFH the xbithack fix 2002-08-22 14:45:56 +00:00
foobar 3deb7d765c MFH 2002-08-22 00:34:33 +00:00
foobar ed4a0fb2be MFH 2002-08-21 15:17:16 +00:00
Dan Kalowsky 333e94c183 MFH or MSG... your choice... 2002-08-20 23:09:01 +00:00
Dan Kalowsky 52bd0e67c4 Bug fix for #18999 2002-08-20 23:06:46 +00:00
Sander Roobol 86dc20c4b8 MFH 2002-08-20 19:45:44 +00:00
Sander Roobol 4083feba29 MFH (var_unserializer.c follows in a second) 2002-08-20 19:44:51 +00:00
Sascha Schumann 26d7374ce0 MFH 2002-08-20 19:02:59 +00:00
Edin Kadribasic 45c5d641ca MFH (Remove C++ comments, bug #17628) 2002-08-20 08:55:27 +00:00
Edin Kadribasic 32e538969e MFH (Fix for bug #14657, patch by Steph Fox) 2002-08-20 07:10:22 +00:00
Edin Kadribasic 3ac117a19b MFH (Fix for bug #11214, patch by Steph Fox) 2002-08-20 07:07:41 +00:00
Dan Kalowsky 3c97c82ee7 WS fix 2002-08-20 05:19:04 +00:00
Edin Kadribasic 507cc75d92 MFH 2002-08-19 14:06:03 +00:00
Dan Kalowsky 04e94d6f30 MFH 2002-08-19 13:21:45 +00:00
Christian Stocker 9350e18e55 MFH 1.174 (Make domxml_xslt_process() working again.)
MDH 1.187 (DOMXML crash on removing previously created attributes)
2002-08-19 07:27:33 +00:00
Dan Kalowsky 973312e1c5 MFH 2002-08-18 04:33:42 +00:00
Zeev Suraski dd920328ee Fix build 2002-08-17 21:00:43 +00:00
Dan Kalowsky d98ac26bfd MFH - fix Irix compiler errors 2002-08-17 20:03:50 +00:00
Ilia Alshanetsky 19d3cf09f6 Backported memory leak fixes from the 4.3 branch 2002-08-17 16:47:54 +00:00
Dan Kalowsky ad43336c68 MFH 2002-08-17 16:29:32 +00:00
Dan Kalowsky f12fcf4384 MFH, builds and reportadly re-enables nsapi support 2002-08-17 16:25:33 +00:00
Dan Kalowsky bdae3ed4a4 MFH, fixing close crash case on Windows 2002-08-17 16:20:10 +00:00
Zeev Suraski 31660f3c61 MFH Apache threading fix 2002-08-17 15:50:20 +00:00
Stefan Esser f1790b8616 MFH 2002-08-17 12:01:28 +00:00
Edin Kadribasic 137c2c02d9 MFH (make apache2filter work with Apache 2.0.40) 2002-08-15 22:27:03 +00:00
foobar 760e82dd0a MFH 2002-08-15 11:19:54 +00:00
Yasuo Ohgaki fda52535e1 Add 4.2.2 news just in case it's released. 2002-08-15 03:14:49 +00:00
Yasuo Ohgaki 7e9d022dfd MFH. Trans SID related changes. 2002-08-14 22:35:36 +00:00
Sascha Schumann fc2d7434d6 MFH *.a check 2002-08-01 10:19:17 +00:00
Zeev Suraski 19a8ef214e MFH per Rui's request 2002-08-01 05:47:56 +00:00
Yasuo Ohgaki a852f13e62 MFH
Cannot take NULL w/o mbstring.
2002-08-01 02:21:00 +00:00
foobar 28a8a70970 MFH: Fix for Apache version check. 2002-07-29 02:15:19 +00:00
foobar d06b046e86 MFH 2002-07-28 22:58:26 +00:00
Yasuo Ohgaki a713a88392 FHM 2002-07-28 21:03:51 +00:00
Stefan Esser 10e8ca4b3b MFH 2 2002-07-28 18:41:48 +00:00
Stefan Esser 02dafdc9b0 MFH 2002-07-28 18:39:48 +00:00
Yasuo Ohgaki 154fe2b566 MFH 2002-07-28 09:44:18 +00:00
Yasuo Ohgaki 261c2ac79a MFH 2002-07-28 09:26:43 +00:00
Rui Hirokawa a5c8d3aef2 fixed: output encoding translation by mb_output_handler() in ext/mbstring was not usable when Content-Type is set by header(). 2002-07-27 13:15:42 +00:00
foobar 7b475f7004 MFH: fix bug #18570 2002-07-25 17:38:01 +00:00
Stefan Esser 3ba2d54217 MFH 2002-07-25 09:35:18 +00:00
Derick Rethans c07f85ceb4 - MFH for fix for bug #16939 2002-07-25 08:16:40 +00:00
Stefan Esser df15a2e57e MFH 2002-07-24 11:25:55 +00:00
Derick Rethans b5d1bf2a67 - MFH for fix for bug #16626 2002-07-24 10:03:49 +00:00
Derick Rethans 82dfeee01d - MFH for fix for bug #18268 2002-07-24 10:01:31 +00:00
Sascha Schumann f0b94e8796 Working on 4.2.3 now 2002-07-23 13:54:07 +00:00
Sascha Schumann 490894cb44 MFH remove \r 2002-07-23 13:48:11 +00:00
Edin Kadribasic 5f25ab414f Allow pcre.h to be in $PREFIX/include/pcre since this is the case
with some Linux distributions (patch by Troels Arvin <troels@arvin.dk>).
2002-07-23 13:03:03 +00:00
Jan Lehnardt 343c47e24b - merge forgotten WS fix which makes non gcc compilers groan. (#17621) 2002-07-22 22:07:11 +00:00
Georg Richter 27c282d34a Automatic rollback for non committed transactions 2002-07-21 22:19:51 +00:00
Sascha Schumann 4d99f3e4e3 Fix warning
Noticed by: Derick
2002-07-21 12:43:02 +00:00
Sascha Schumann 4e0b6d1e15 MFH fix for wrongly detected CPP on platforms such as Solaris where
a package might be installed which actually does not contain a real
compiler.
2002-07-20 16:25:28 +00:00
Yasuo Ohgaki 154b12f2b5 MFH
@ Trans SID is disabled by default in php.ini
2002-07-19 09:47:06 +00:00
Edin Kadribasic 02d7a70809 MFH 2002-07-15 18:02:09 +00:00
Stefan Esser 7780655d38 use Zend API to access llist count 2002-07-15 16:40:57 +00:00
Edin Kadribasic 12063cbf71 MFH (fixes linking errors when --enable-mbstring is used) 2002-07-14 08:31:45 +00:00
foobar 1586c176f6 .php files are in .cvsignore here 2002-07-14 00:22:52 +00:00
foobar 3cdcc6a201 MFH 2002-07-12 21:47:37 +00:00
SVN Migration 5f6e25342f This commit was manufactured by cvs2svn to create branch 'PHP_4_2_0'. 2002-07-12 13:02:46 +00:00
foobar 38155bfcb2 MFH: Fix for #16337 2002-07-11 02:41:52 +00:00
Jason Greene 6793119e36 Fix socket_set_timeout on win32 ( was not being included ) 2002-07-10 14:59:22 +00:00
foobar d52283eef8 MFH 2002-07-07 00:47:46 +00:00
foobar 60cf7403e0 MFH 2002-07-05 18:33:03 +00:00
Rui Hirokawa 7c9479388f fixed shift_jis character corruption including 0x5c as second byte following a slash on uploaded filename. 2002-07-05 15:02:40 +00:00
Rui Hirokawa 1ac7b33e48 fixed ZTS build. 2002-07-03 22:18:43 +00:00
Rui Hirokawa 2bfd9402b1 fixed ZTS build and added language check. 2002-07-03 22:14:14 +00:00
Edin Kadribasic ae430bfba8 MFH (win32 build fix) 2002-07-03 11:06:10 +00:00
Christian Stocker 765ebf8eee - Not maintained (and maybe not working) anymore
- There's a new project PEAR_Frontend_Web which does a much better job
2002-07-03 09:53:46 +00:00
Rui Hirokawa dadaee4171 *** empty log message *** 2002-07-02 15:28:14 +00:00
Rui Hirokawa dfa9fab613 fixed shift_jis character corruption including 0x5c as second byte on uploaded filename. 2002-07-02 15:27:07 +00:00
Rui Hirokawa 64d489900a fixed shift_jis character corruption including 0x5c as second byte. 2002-07-02 15:26:25 +00:00
foobar 0a65579c76 MFH: Fix for bug #16252 2002-06-30 05:12:22 +00:00
foobar 4279002766 Removing libs/ is not a good idea 2002-06-29 00:59:32 +00:00
foobar 34c3cfa849 MFH: fix for bug: #17999 2002-06-26 23:31:09 +00:00
foobar e5610b3b47 ..unless someone adds all the missing ones.. :) 2002-06-24 11:51:42 +00:00
foobar b891ee9361 Fix the shared build properly. 2002-06-24 11:37:19 +00:00
Edin Kadribasic cac83f87a0 MFH
# Tested build on Linux and Win32.
# Wanted: testers on other platforms.
2002-06-24 09:34:06 +00:00
Derick Rethans 13dcb49db5 - Fix make install to respect the prefix= argument (patch by Troels Arvin
<troels@arvin.dk>)
2002-06-24 08:46:26 +00:00
Derick Rethans 468a3c4f56 - Fix building a shared extension (patch by Troels Arvin <troels@arvin.dk>) 2002-06-24 08:44:42 +00:00
Derick Rethans d94ae09341 - MFH 2002-06-24 08:42:30 +00:00
Derick Rethans f585c6ce18 - MFH 2002-06-24 08:24:21 +00:00
Edin Kadribasic 2af4859c3f MFH 2002-06-24 08:21:28 +00:00
Derick Rethans 17cd2e4cf8 - Fix the MFH :) 2002-06-24 08:18:54 +00:00
Derick Rethans cbdca16521 - MFH 2002-06-24 08:07:40 +00:00
Derick Rethans 76e641e8b7 - Partly MFH 2002-06-24 08:04:01 +00:00
Derick Rethans 322ce93714 - MFH 2002-06-24 08:00:51 +00:00
Derick Rethans e6522b68e9 - MFH 2002-06-24 07:55:32 +00:00
Derick Rethans e5bb3f348e - MFH 2002-06-23 22:28:15 +00:00
Stefan Esser 782fb51ad7 MFH: several fixes to fileupload code 2002-06-23 17:26:03 +00:00
Stefan Esser 3e05989a83 merged in the filtering control chars patch 2002-06-23 17:22:52 +00:00
Stefan Esser 336ca133d3 MFH: link/symlink safe_mode/open_base_dir fix 2002-06-23 17:18:17 +00:00
Stefan Esser 7b04ffa0c5 MFH: replace header fix, content-type header handling fix 2002-06-23 17:15:07 +00:00
Yasuo Ohgaki 30f0b61415 Added missing NEWS entry for a bug fix. 2002-06-20 01:43:32 +00:00
Andrei Zmievski a3b0f8e645 *** empty log message *** 2002-06-17 15:12:40 +00:00
Andrei Zmievski 252d12ce1c MFH 2002-06-17 15:11:39 +00:00
Edin Kadribasic adc45bc653 MFH (fix for #17733) 2002-06-13 08:40:33 +00:00
Christian Stocker ec51555630 MFH (fixed domxml_get_element_by_id() ) 2002-06-12 11:13:35 +00:00
Jan Lehnardt e5f1bf0f83 - MFH (WS-fix) 2002-06-10 16:36:28 +00:00
Daniela Mariaschi 9b087754d1 Add control on Ib version. ibase_add_user(), ibase_modify_user()
and ibase_delete_user() available with IB6 or later.
fix bug #17184
2002-06-06 21:35:38 +00:00
foobar 6c50fdabdf MFH: fix bug #17535 2002-06-04 02:35:00 +00:00
Harald Radi 4fba6307c0 fix build 2002-06-03 20:04:15 +00:00
Edin Kadribasic cbcb6e1936 MFH 2002-06-03 17:57:41 +00:00
Harald Radi 4885bd6361 MFH 2002-05-31 10:08:08 +00:00
Harald Radi 834a71b67e MFH 2002-05-31 09:59:53 +00:00
Edin Kadribasic a4a777fd97 I case we ever release 4.2.2. 2002-05-26 21:22:45 +00:00
Edin Kadribasic fb8a88da3d MFH (fix for exit()) 2002-05-26 21:16:31 +00:00
Edin Kadribasic f2dac4a25a MFH (patch for allowing strings in pow() args, fixes #17374) 2002-05-23 14:38:08 +00:00
Edin Kadribasic d033a0c3fd MFH (fix for #17315) 2002-05-21 01:04:42 +00:00
Markus Fischer fef95081c1 - MFH fix for #17323. 2002-05-20 23:31:02 +00:00
Yasuo Ohgaki b33b5991e1 MFH 2002-05-20 10:30:49 +00:00
foobar 641db909ff MFH 2002-05-19 00:03:34 +00:00
Christian Stocker 62210bef1d MFH for memleak fixes in domxml_dump_mem and domxml_html_dump_mem 2002-05-18 14:43:14 +00:00
Christian Stocker 4cf414e0e1 MFH for memleak patch 2002-05-18 10:21:54 +00:00
foobar d3bc482bf4 MFH 2002-05-16 15:27:50 +00:00
Rasmus Lerdorf 32511e9c55 MFH just in case 2002-05-16 14:53:12 +00:00
Harald Radi 11b294c74d MFH
# found the appropriate branch following the
# 'innsbrugga-style' paradigm markus suggested
2002-05-15 18:05:13 +00:00
Christian Stocker c66a9fdc22 libxml2 >= 2.4.14 is needed (since quite some time ...) 2002-05-15 12:43:00 +00:00
foobar e615a0d3cf Nuke 4.1 for good this time. 2002-05-15 10:22:51 +00:00
foobar ffb9c99cfc MFH 2002-05-15 10:20:36 +00:00
Markus Fischer 974913cf23 - MFH fix for Cc: crash 2002-05-14 14:17:04 +00:00
Jan Lehnardt 23534f667d - MFH 2002-05-14 10:34:14 +00:00
Rasmus Lerdorf 0f9cf6eb18 MFH 2002-05-13 18:12:25 +00:00
Jan Lehnardt 769f1a8564 - MFH 2002-05-13 18:10:53 +00:00
Derick Rethans 4b064814e5 - Bumb version number 2002-05-13 17:14:08 +00:00
Derick Rethans fb1b7c9060 - Fix version 2002-05-12 21:23:57 +00:00
foobar f39b4a8582 short is good 2002-05-12 21:07:40 +00:00
Edin Kadribasic 06ceb7da90 Merged safe_mode fixes into one entry. 2002-05-12 20:54:29 +00:00
Edin Kadribasic 934b4388cb Fixed typo. 2002-05-12 20:36:05 +00:00
Edin Kadribasic 055710e95a MFH 2002-05-12 20:27:37 +00:00
Rasmus Lerdorf 12e6c6d95f MFH 2002-05-12 16:08:31 +00:00
Daniela Mariaschi cd11446263 fix bug #17040
User can't close a connection if there are blobs opened.
He must close them before to not lose data....
2002-05-12 13:01:28 +00:00
Rasmus Lerdorf 844c90a395 Damn, forgot a debug line 2002-05-11 20:02:21 +00:00
Rasmus Lerdorf f9ee6d3d9e Argh! Horrible logic here. The safemode include dir check defaulted
to letting stuff through if no safemode include dir was defined.
@ Another safe-mode fix related to the safemode incdir feature (Rasmus)
2002-05-11 19:56:10 +00:00
Rasmus Lerdorf 2d73699721 MFH - parse_ini_file() safe-mode fix 2002-05-11 19:23:05 +00:00
Rasmus Lerdorf 4caca1d6eb MFH - safe-mode show_source() fix 2002-05-11 18:50:28 +00:00
Zeev Suraski 64595cc959 MFH - avoid choking on 0 byte files 2002-05-11 11:58:52 +00:00
Sebastian Bergmann fb49473192 MFH: Patch by Justin Erenkrantz <jerenkrantz@apache.org>. 2002-05-11 09:49:54 +00:00
Sander Roobol 5c6ec3c7bf Added notes that php.exe and not php-cli.exe should be used. 2002-05-09 09:56:45 +00:00
Jason Greene a86833cc06 Merge overflow fix 2002-05-08 15:33:49 +00:00
Jason Greene dc1ff44e37 MFH BSD fix 2002-05-07 21:34:19 +00:00
Jason Greene ed235cf8b7 MFH 2002-05-06 23:10:54 +00:00
Jason Greene adb0cb5c01 MFH
Fix for ZTS and crash bugs
2002-05-06 20:44:58 +00:00
Derick Rethans 964d412062 - Swap back version number 2002-05-06 18:56:54 +00:00
Derick Rethans 3cb5d4790a - Fix release date 2002-05-06 18:55:55 +00:00
129 changed files with 3692 additions and 1449 deletions

No files matched your search

+11 -11
View File
@@ -1,5 +1,5 @@
Installation Instructions for PHP 4.1
-------------------------------------
Installation Instructions for PHP 4
-----------------------------------
STOP!
@@ -62,8 +62,8 @@ Compiled-in modules:
Chances are you will see a lot more modules than these two. That's ok,
as long as mod_so.c shows up you can proceed with the following steps:
$ gunzip -c php-4.1.x.tar.gz | tar xf -
$ cd php-4.1.x
$ gunzip -c php-4.x.y.tar.gz | tar xf -
$ cd php-4.x.y
$ ./configure --with-mysql --with-apxs
$ make
$ make install
@@ -93,8 +93,8 @@ $ cd apache_1.3.x
$ ./configure
$ cd ..
$ gunzip -c php-4.1.x.tar.gz | tar xf -
$ cd php-4.1.x
$ gunzip -c php-4.x.y.tar.gz | tar xf -
$ cd php-4.x.y
$ ./configure --with-mysql --with-apache=../apache_1.3.x
$ make
$ make install
@@ -106,7 +106,7 @@ $ ./configure --prefix=/www --activate-module=src/modules/php4/libphp4.a
$ make
(you should now have an httpd binary which you can copy to your Apache bin dir if
is is your first install then you need to "make install" as well)
$ cd ../php-4.1.x
$ cd ../php-4.x.y
$ cp php.ini-dist /usr/local/lib/php.ini
You can edit /usr/local/lib/php.ini file to set PHP options.
Edit your httpd.conf or srm.conf file and add:
@@ -125,12 +125,12 @@ Installing PHP can be done in four simple steps:
1. Unpack your distribution file.
You will have downloaded a file named something like php-4.1.x.tar.gz.
Unzip this file with a command like: gunzip php-4.1.x.tar.gz
You will have downloaded a file named something like php-4.x.y.tar.gz.
Unzip this file with a command like: gunzip php-4.x.y.tar.gz
Next you have to untar it with: tar -xvf php-4.1.x.tar
Next you have to untar it with: tar -xvf php-4.x.y.tar
This will create a php-4.1.x directory. cd into this new directory.
This will create a php-4.x.y directory. cd into this new directory.
2a. Configure PHP (Dynamic Module) - Skip to 2b if you wish to build
a static module
+1 -1
View File
@@ -52,7 +52,7 @@ install-modules:
install-tester:
@echo "Installing regression tester"
@$(mkinstalldirs) $(PEAR_INSTALLDIR)
@$(mkinstalldirs) $(INSTALL_ROOT)$(PEAR_INSTALLDIR)
@$(INSTALL) -m 755 $(srcdir)/run-tests.php $(INSTALL_ROOT)$(PEAR_INSTALLDIR)
install-pear: install-modules
+40 -1
View File
@@ -1,6 +1,45 @@
PHP 4 NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
12 May 2002, Version 4.2.1
?? ??? 2002, Version 4.2.3
- Fixed a potential crash bug in import_request_variables() (Zeev)
- Fixed several problems with directory functions on Windows. (Steph)
- Fixed xbithack bug in Apache module. (Rasmus)
- Fixed a bug that prevented touch() from working on various platforms. (Steph)
- Fixed ob_gzhandler()'s handling of requests that do have the Accept-Encoding
header, but do not allow compression. (Zeev)
- Fixed several bugs in the multithreaded version that could cause random parse
errors, especially on machines with multiple CPUs. (Zeev, Zend Engine)
- Fixed a build problem in bcmath. (Alan)
- Fixed several bzip2 issues. (Andrei, kalowsky)
- Fixed several COM issues. (Harald)
- Various exif fixes. (Marcus)
- Fixed domxml_xslt_process() and domxml_get_element_by_id() and several
other issues in DOMXML. (Christian)
- Fixed DOMXML crash on removing previously created attributes. (Christian)
- Fixed crash when converting $GLOBALS to an object. (Zeev, Zend Engine)
- Fixed ImageCreateFromGD2Part() (Jani)
- Fixed a build issue in the IMAP extension under IRIX. (kalowsky)
- Fixed a bug in imap_last_error() (Jani)
- Various mbstring fixes. (Yasuo, Rui)
- Fixed a build problem in the mcal extension. (Jani)
- Made MySQL rollback open transactions when the request ends. (Georg)
- Fixed a crash in the shutdown order of the ODBC module. (kalowsky)
- Fixed PCRE build problems. (troels@arvin.dk)
- Fixed a crash in pg_lo_write() (Yasuo)
- Fixed posix_isatty() and posix_ttyname(). (Markus)
- Fixed accidental pg_lo_import() API change. (Yasuo)
- Fixed ereg_replace() crash when the backreference number was greater than the
number of captured subpatterns. (oliver@billix.franken.de)
- Fixed array_rand() on thread-safe platforms such as Windows. (Edin)
- Report the right exit code after a call to exit(). (Edin)
22 Jul 2002, Version 4.2.2
- Fixed serious security vulnerability. (Stefan Esser)
13 May 2002, Version 4.2.1
- Added safe-mode checks to show_source(), parse_ini_file() and rmdir(). Also
fixed security problems with safe_mode_include_dir directive. (Rasmus)
- Changed HTTP upload code to accept 0 byte file uploads. (Zeev)
- Major update of domxml. New functions, better DOM compliance and bug fixes:
* Changed the old $node->append_child() to $node->append_sibling() since
the new append_child() behaves correctly (= W3C standard).
+2 -1
View File
@@ -1,6 +1,7 @@
This is the first file you should be reading after you get your CVS account.
We'll assume you're basically familiar with CVS, but feel free to post
your questions on the mailing list.
your questions on the mailing list. Please have a look at
http://cvsbook.red-bean.com/ for more detailed information on CVS.
PHP is developed through the efforts of a large number of people.
Collaboration is a Good Thing(tm), and CVS lets us do this. Thus, following
+18 -1
View File
@@ -109,7 +109,7 @@ AC_DEFUN(PHP_EVAL_LIBLINE,[
case $ac_i in
-l*)
ac_ii=`echo $ac_i|cut -c 3-`
PHP_ADD_LIBRARY($ac_ii,,$2)
PHP_ADD_LIBRARY($ac_ii,1,$2)
;;
-L*)
ac_ii=`echo $ac_i|cut -c 3-`
@@ -1264,3 +1264,20 @@ AC_DEFUN(PHP_SETUP_ICONV, [
ifelse([$3],[],,[else $3])
fi
])
dnl
dnl PHP_AP_EXTRACT_VERSION(/path/httpd)
dnl This macro is used to get a comparable
dnl version for apache1/2.
dnl
AC_DEFUN(PHP_AP_EXTRACT_VERSION,[
ac_output=`$1 -v 2>&1`
ac_IFS=$IFS
IFS="- /.
"
set $ac_output
IFS=$ac_IFS
APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6`
])
+1 -1
View File
@@ -49,7 +49,7 @@ clean-modules:
clean-x:
rm -f $(targets) *.lo *.slo *.la *.o $(CLEANFILES)
rm -rf .libs libs
rm -rf .libs libs/*
distclean: distclean-recursive clean-x
rm -f config.cache config.log config.status config_vars.mk libtool \
+6 -7
View File
@@ -36,7 +36,7 @@ for arg in $0 "$@"; do
done
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE(php, 4.2.1RC2, nodefine)
AM_INIT_AUTOMAKE(php, 4.2.3RC1, nodefine)
AM_CONFIG_HEADER(main/php_config.h)
AM_MAINTAINER_MODE
@@ -116,8 +116,6 @@ T_ME=`$php_shtool echo -n -e %b`
dnl We want this one before the checks, so the checks can modify CFLAGS.
test -z "$CFLAGS" && auto_cflags=1
dnl AC_AIX needs to be before any macros that run the C compiler.
AC_AIX
abs_srcdir=`(cd $srcdir; pwd)`
abs_builddir=`pwd`
@@ -138,9 +136,10 @@ dnl -------------------------------------------------------------------------
AC_PROG_CC
AC_PROG_CC_C_O
AC_PROG_CPP
AC_AIX
dnl Change to AC_PROG_CC_STDC when we start requiring a post-2.13 autoconf
AM_PROG_CC_STDC
AC_PROG_CPP
dnl AC_PROG_CXX
dnl AC_PROG_CXXCPP
dnl check for -R, etc. switch
@@ -436,10 +435,10 @@ fi
dnl Check for IPv6 support
AC_CACHE_CHECK([for IPv6 support], ac_cv_ipv6_support,
[AC_TRY_COMPILE([ #include <sys/types.h>
[AC_TRY_LINK([ #include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>], [struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s],
ac_cv_ipv6_support=yes, ac_cv_ipv6_support=no)])
#include <netinet/in.h>], [struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;],
[ac_cv_ipv6_support=yes], [ac_cv_ipv6_support=no])])
if test "$ac_cv_ipv6_support" = yes; then
AC_DEFINE(HAVE_IPV6,1,[Whether you have IPv6 support])
fi
+1 -1
View File
@@ -28,7 +28,7 @@
#include "ext/standard/info.h"
#include "php_bcmath.h"
#include "ext/bcmath/libbcmath/src/bcmath.h"
#include "libbcmath/src/bcmath.h"
function_entry bcmath_functions[] = {
PHP_FE(bcadd, NULL)
+542 -53
View File
@@ -15,9 +15,10 @@
| Author: Zeev Suraski <zeev@zend.com> |
| Harald Radi <h.radi@nme.at> |
| Alan Brown <abrown@pobox.com> |
| Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
/*
* This module implements support for COM components that support the IDispatch
* interface. Both local (COM) and remote (DCOM) components can be accessed.
@@ -57,6 +58,7 @@
#include <iostream.h>
#include <math.h>
#include <ocidl.h>
#include "php.h"
#include "php_ini.h"
@@ -65,11 +67,12 @@
#include "php_VARIANT.h"
static ITypeLib *php_COM_find_typelib(char *search_string, int mode TSRMLS_DC);
static int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC);
static int do_COM_offget(VARIANT *result, comval *array, pval *property, int cleanup TSRMLS_DC);
static int do_COM_propget(VARIANT *var_result, comval *obj, pval *arg_property, int cleanup TSRMLS_DC);
static void php_register_COM_class(TSRMLS_D);
static void php_COM_init(int module_number TSRMLS_DC);
static char *php_string_from_clsid(const CLSID *clsid TSRMLS_DC);
static int com_enable_events(comval *obj, int enable);
static int le_comval;
static int codepage;
@@ -78,6 +81,9 @@ static int codepage;
int resourcecounter = 1;
#endif
static unsigned char arg1and2_force_ref[] =
{ 2, BYREF_FORCE, BYREF_FORCE };
function_entry COM_functions[] = {
PHP_FE(com_load, NULL)
PHP_FE(com_invoke, NULL)
@@ -87,6 +93,9 @@ function_entry COM_functions[] = {
PHP_FE(com_propput, NULL)
PHP_FE(com_load_typelib, NULL)
PHP_FE(com_isenum, NULL)
PHP_FE(com_event_sink, arg1and2_force_ref)
PHP_FE(com_message_pump, NULL)
PHP_FE(com_print_typeinfo, NULL)
PHP_FALIAS(com_get, com_propget, NULL)
PHP_FALIAS(com_propset, com_propput, NULL)
@@ -261,7 +270,7 @@ PHPAPI HRESULT php_COM_set(comval *obj, IDispatch FAR* FAR* ppDisp, int cleanup
C_REFCOUNT(obj) = 1;
C_DISPATCH(obj) = pDisp;
C_HASTLIB(obj) = SUCCEEDED(C_DISPATCH_VT(obj)->GetTypeInfo(C_DISPATCH(obj), 0, LANG_NEUTRAL, &C_TYPEINFO(obj)));
dispparams.rgvarg = NULL;
dispparams.rgdispidNamedArgs = NULL;
dispparams.cArgs = 0;
@@ -272,9 +281,11 @@ PHPAPI HRESULT php_COM_set(comval *obj, IDispatch FAR* FAR* ppDisp, int cleanup
if (C_HASENUM(obj) = SUCCEEDED(C_DISPATCH_VT(obj)->Invoke(C_DISPATCH(obj), DISPID_NEWENUM, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
DISPATCH_METHOD|DISPATCH_PROPERTYGET, &dispparams, var_result, NULL, NULL))) {
if (V_VT(var_result) == VT_UNKNOWN) {
V_UNKNOWN(var_result)->lpVtbl->AddRef(V_UNKNOWN(var_result));
C_HASENUM(obj) = SUCCEEDED(V_UNKNOWN(var_result)->lpVtbl->QueryInterface(V_UNKNOWN(var_result), &IID_IEnumVARIANT,
(void**)&C_ENUMVARIANT(obj)));
} else if (V_VT(var_result) == VT_DISPATCH) {
V_DISPATCH(var_result)->lpVtbl->AddRef(V_DISPATCH(var_result));
C_HASENUM(obj) = SUCCEEDED(V_DISPATCH(var_result)->lpVtbl->QueryInterface(V_DISPATCH(var_result), &IID_IEnumVARIANT,
(void**)&C_ENUMVARIANT(obj)));
}
@@ -358,6 +369,10 @@ PHPAPI HRESULT php_COM_destruct(comval *obj TSRMLS_DC)
{
HRESULT hr = S_OK;
com_enable_events(obj, FALSE);
if (obj->sinkdispatch)
obj->sinkdispatch->lpVtbl->Release(obj->sinkdispatch);
if (C_ISREFD(obj)) {
C_REFCOUNT(obj) = 1;
hr = php_COM_release(obj TSRMLS_CC);
@@ -507,40 +522,34 @@ PHP_FUNCTION(com_load)
server_name = NULL;
} else if (Z_TYPE_P(server_name) == IS_ARRAY) {
pval **tmp;
/* DAB: 22 Sept 2001 */
/* Aha - we have a number of possible */
/* arguments. They are in the hash */
/* By name: Server, Domain, Username, Password */
/* Flags. */
/* This has been crafted to maintian maximum backward */
/* compatability, If the server name is specified as a */
/* string, then the function shoule behave as before */
/* by defaulting username and password and using the */
/* (I believe) incorrect CLSCTX_SERVER instantiation */
/* paramter. However if server is specified in this array */
/* then we use either CLSCTX_REMOTE_SERVER or whatever */
/* flags are specified in the array */
/* DAB: 22 Sept 2001
* Aha - we have a number of possible arguments.
* They are in the hash By name: Server, Domain, Username, Password
* Flags.
* This has been crafted to maintian maximum backward compatability.
* If the server name is specified as a string, then the function
* should behave as before by defaulting username and password and
* using the (I believe) incorrect CLSCTX_SERVER instantiation
* paramter. However if server is specified in this array then we
* use either CLSCTX_REMOTE_SERVER or whatever flags are specified
* in the array */
HashTable *ht = Z_ARRVAL(*server_name);
if (FAILURE == zend_hash_find(ht, "Server", 7, (void **) &tmp)) {
server_name = NULL;
} else {
server_name = *tmp;
convert_to_string_ex(&server_name);
/* CLSCTX_SERVER includes INPROC and LOCAL */
/* SERVER. This means that any local server */
/* will be instantiated BEFORE even looking */
/* on a remote server. Thus if we have a */
/* server name, probably we want to access */
/* a remote machine or we would not have */
/* bothered specifying it. So it would be */
/* wrong to to connect locally. Futher, */
/* unless the name passed is a GUID, there has */
/* to be something to map the Prog.Id to GUID */
/* and unless that has been modified to remove */
/* the information about local instantiation */
/* CLSCTX_SERVER would force a local instantiation */
/* This setting can be overridden below if the user */
/* specifies a flags element */
/* CLSCTX_SERVER includes INPROC and LOCAL SERVER. This means
* that any local server will be instantiated BEFORE even
* looking on a remote server. Thus if we have a server name,
* probably we want to access a remote machine or we would not
* have bothered specifying it. So it would be wrong to to
* connect locally. Futher, unless the name passed is a GUID,
* there has to be something to map the Prog.Id to GUID and
* unless that has been modified to remove the information
* about local instantiation CLSCTX_SERVER would force a local
* instantiation This setting can be overridden below if the
* user specifies a flags element */
flags = CLSCTX_REMOTE_SERVER;
}
if (FAILURE == zend_hash_find(ht, "Username", 9, (void **) &tmp)) {
@@ -709,7 +718,7 @@ PHP_FUNCTION(com_load)
}
}
RETURN_LONG(zend_list_insert(obj, IS_COM));
RETURN_RESOURCE(zend_list_insert(obj, IS_COM));
}
/* }}} */
@@ -1004,6 +1013,461 @@ PHP_FUNCTION(com_addref)
}
/* }}} */
/* {{{ proto bool com_message_pump([int timeoutms])
Process COM messages, sleeping for up to timeoutms milliseconds */
PHP_FUNCTION(com_message_pump)
{
long timeoutms = 0;
MSG msg;
DWORD result;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &timeoutms) == FAILURE)
RETURN_FALSE;
result = MsgWaitForMultipleObjects(0, NULL, FALSE, timeoutms, QS_ALLINPUT);
if (result == WAIT_OBJECT_0) {
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
/* we processed messages */
RETVAL_TRUE;
} else {
/* we did not process messages (timed out) */
RETVAL_FALSE;
}
}
/* }}} */
static int com_enable_events(comval *obj, int enable)
{
if (obj->sinkdispatch) {
IConnectionPointContainer *cont;
IConnectionPoint *point;
if (SUCCEEDED(C_DISPATCH_VT(obj)->QueryInterface(C_DISPATCH(obj), &IID_IConnectionPointContainer, (void**)&cont))) {
if (SUCCEEDED(cont->lpVtbl->FindConnectionPoint(cont, &obj->sinkid, &point))) {
if (enable) {
point->lpVtbl->Advise(point, (IUnknown*)obj->sinkdispatch, &obj->sinkcookie);
} else {
point->lpVtbl->Unadvise(point, obj->sinkcookie);
}
point->lpVtbl->Release(point);
}
cont->lpVtbl->Release(cont);
}
}
return 0;
}
static const struct {
VARTYPE vt;
const char *name;
} vt_names[] = {
{ VT_NULL, "VT_NULL" },
{ VT_EMPTY, "VT_EMPTY" },
{ VT_UI1, "VT_UI1" },
{ VT_I2, "VT_I2" },
{ VT_I4, "VT_I4" },
{ VT_R4, "VT_R4" },
{ VT_R8, "VT_R8" },
{ VT_BOOL, "VT_BOOL" },
{ VT_ERROR, "VT_ERROR" },
{ VT_CY, "VT_CY" },
{ VT_DATE, "VT_DATE" },
{ VT_BSTR, "VT_BSTR" },
{ VT_DECIMAL, "VT_DECIMAL" },
{ VT_UNKNOWN, "VT_UNKNOWN" },
{ VT_DISPATCH, "VT_DISPATCH" },
{ VT_VARIANT, "VT_VARIANT" },
{ VT_I1, "VT_I1" },
{ VT_UI2, "VT_UI2" },
{ VT_UI4, "VT_UI4" },
{ VT_INT, "VT_INT" },
{ VT_UINT, "VT_UINT" },
{ VT_ARRAY, "VT_ARRAY" },
{ VT_BYREF, "VT_BYREF" },
{ VT_VOID, "VT_VOID" },
{ VT_PTR, "VT_PTR" },
{ VT_HRESULT, "VT_HRESULT" },
{ 0, NULL }
};
static inline const char *vt_to_string(VARTYPE vt)
{
int i;
for (i = 0; vt_names[i].name != NULL; i++) {
if (vt_names[i].vt == vt)
return vt_names[i].name;
}
return "?";
}
static int process_typeinfo(ITypeInfo *typeinfo, HashTable *id_to_name, int printdef, GUID *guid TSRMLS_DC)
{
TYPEATTR *attr;
FUNCDESC *func;
int i;
OLECHAR *olename;
char *ansiname = NULL;
unsigned int ansinamelen;
int ret = 0;
if (FAILED(typeinfo->lpVtbl->GetTypeAttr(typeinfo, &attr)))
return 0;
/* verify that it is suitable */
if (id_to_name == NULL || attr->typekind == TKIND_DISPATCH) {
if (guid)
memcpy(guid, &attr->guid, sizeof(GUID));
if (printdef) {
char *guidstring;
typeinfo->lpVtbl->GetDocumentation(typeinfo, MEMBERID_NIL, &olename, NULL, NULL, NULL);
ansiname = php_OLECHAR_to_char(olename, &ansinamelen, codepage TSRMLS_CC);
SysFreeString(olename);
guidstring = php_string_from_clsid(&attr->guid TSRMLS_CC);
php_printf("class %s { /* GUID=%s */\n", ansiname, guidstring);
efree(guidstring);
efree(ansiname);
}
if (id_to_name)
zend_hash_init(id_to_name, 0, NULL, ZVAL_PTR_DTOR, 0);
/* So we've got the dispatch interface; lets list the event methods */
for (i = 0; i < attr->cFuncs; i++) {
zval *tmp;
DISPID lastid = 0; /* for props */
int isprop;
if (FAILED(typeinfo->lpVtbl->GetFuncDesc(typeinfo, i, &func)))
break;
isprop = (func->invkind & DISPATCH_PROPERTYGET || func->invkind & DISPATCH_PROPERTYPUT);
if (!isprop || lastid != func->memid) {
lastid = func->memid;
typeinfo->lpVtbl->GetDocumentation(typeinfo, func->memid, &olename, NULL, NULL, NULL);
ansiname = php_OLECHAR_to_char(olename, &ansinamelen, codepage TSRMLS_CC);
SysFreeString(olename);
if (printdef) {
int j;
char *funcdesc;
unsigned int funcdesclen, cnames = 0;
BSTR *names;
names = (BSTR*)emalloc((func->cParams + 1) * sizeof(BSTR));
typeinfo->lpVtbl->GetNames(typeinfo, func->memid, names, func->cParams + 1, &cnames);
/* first element is the function name */
SysFreeString(names[0]);
php_printf("\t/* DISPID=%d */\n", func->memid);
if (func->elemdescFunc.tdesc.vt != VT_VOID) {
php_printf("\t/* %s [%d] */\n",
vt_to_string(func->elemdescFunc.tdesc.vt),
func->elemdescFunc.tdesc.vt
);
}
if (isprop) {
typeinfo->lpVtbl->GetDocumentation(typeinfo, func->memid, NULL, &olename, NULL, NULL);
if (olename) {
funcdesc = php_OLECHAR_to_char(olename, &funcdesclen, codepage TSRMLS_CC);
SysFreeString(olename);
php_printf("\t/* %s */\n", funcdesc);
efree(funcdesc);
}
php_printf("\tvar $%s;\n\n", ansiname);
} else {
/* a function */
php_printf("\tfunction %s(\n", ansiname);
for (j = 0; j < func->cParams; j++) {
ELEMDESC *elem = &func->lprgelemdescParam[j];
php_printf("\t\t/* %s [%d] ", vt_to_string(elem->tdesc.vt), elem->tdesc.vt);
if (elem->paramdesc.wParamFlags & PARAMFLAG_FIN)
php_printf("[in]");
if (elem->paramdesc.wParamFlags & PARAMFLAG_FOUT)
php_printf("[out]");
if (elem->tdesc.vt == VT_PTR) {
/* what does it point to ? */
php_printf(" --> %s [%d] ",
vt_to_string(elem->tdesc.lptdesc->vt),
elem->tdesc.lptdesc->vt
);
}
/* when we handle prop put and get, this will look nicer */
if (j+1 < (int)cnames) {
funcdesc = php_OLECHAR_to_char(names[j+1], &funcdesclen, codepage TSRMLS_CC);
SysFreeString(names[j+1]);
} else {
funcdesc = "???";
}
php_printf(" */ %s%s%c\n",
elem->tdesc.vt == VT_PTR ? "&$" : "$",
funcdesc,
j == func->cParams - 1 ? ' ' : ','
);
if (j+1 < (int)cnames)
efree(funcdesc);
}
php_printf("\t\t)\n\t{\n");
typeinfo->lpVtbl->GetDocumentation(typeinfo, func->memid, NULL, &olename, NULL, NULL);
if (olename) {
funcdesc = php_OLECHAR_to_char(olename, &funcdesclen, codepage TSRMLS_CC);
SysFreeString(olename);
php_printf("\t\t/* %s */\n", funcdesc);
efree(funcdesc);
}
php_printf("\t}\n");
}
efree(names);
}
if (id_to_name) {
zend_str_tolower(ansiname, ansinamelen);
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, ansiname, ansinamelen, 0);
zend_hash_index_update(id_to_name, func->memid, (void*)&tmp, sizeof(zval *), NULL);
}
}
typeinfo->lpVtbl->ReleaseFuncDesc(typeinfo, func);
}
if (printdef)
php_printf("}\n");
ret = 1;
} else {
zend_error(E_WARNING, "Thats not a dispatchable interface!! type kind = %08x\n", attr->typekind);
}
typeinfo->lpVtbl->ReleaseTypeAttr(typeinfo, attr);
return ret;
}
static ITypeInfo *locate_typeinfo(char *typelibname, comval *obj, char *dispname, int sink TSRMLS_DC)
{
ITypeInfo *typeinfo = NULL;
ITypeLib *typelib = NULL;
int gotguid = 0;
GUID iid;
if (obj) {
if (dispname == NULL && sink) {
IProvideClassInfo2 *pci2;
IProvideClassInfo *pci;
if (SUCCEEDED(C_DISPATCH_VT(obj)->QueryInterface(C_DISPATCH(obj), &IID_IProvideClassInfo2, (void**)&pci2))) {
gotguid = SUCCEEDED(pci2->lpVtbl->GetGUID(pci2, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &iid));
pci2->lpVtbl->Release(pci2);
}
if (!gotguid && SUCCEEDED(C_DISPATCH_VT(obj)->QueryInterface(C_DISPATCH(obj), &IID_IProvideClassInfo, (void**)&pci))) {
/* examine the available interfaces */
/* TODO: write some code here */
pci->lpVtbl->Release(pci);
}
} else if (dispname && C_HASTLIB(obj)) {
unsigned int idx;
/* get the library from the object; the rest will be dealt with later */
C_TYPEINFO_VT(obj)->GetContainingTypeLib(C_TYPEINFO(obj), &typelib, &idx);
} else if (typelibname == NULL) {
C_DISPATCH_VT(obj)->GetTypeInfo(C_DISPATCH(obj), 0, LANG_NEUTRAL, &typeinfo);
}
} else if (typelibname) {
/* Fetch the typelibrary and use that to look things up */
typelib = php_COM_find_typelib(typelibname, CONST_CS TSRMLS_CC);
}
if (!gotguid && dispname && typelib) {
unsigned short cfound;
MEMBERID memid;
OLECHAR *olename = php_char_to_OLECHAR(dispname, strlen(dispname), CP_ACP TSRMLS_CC);
cfound = 1;
if (FAILED(typelib->lpVtbl->FindName(typelib, olename, 0, &typeinfo, &memid, &cfound)) || cfound == 0) {
CLSID coclass;
ITypeInfo *coinfo;
/* assume that it might be a progid instead */
if (SUCCEEDED(CLSIDFromProgID(olename, &coclass)) &&
SUCCEEDED(typelib->lpVtbl->GetTypeInfoOfGuid(typelib, &coclass, &coinfo))) {
/* enumerate implemented interfaces and pick the one as indicated by sink */
TYPEATTR *attr;
int i;
coinfo->lpVtbl->GetTypeAttr(coinfo, &attr);
for (i = 0; i < attr->cImplTypes; i++) {
HREFTYPE rt;
int tf;
if (FAILED(coinfo->lpVtbl->GetImplTypeFlags(coinfo, i, &tf)))
continue;
if ((sink && tf == (IMPLTYPEFLAG_FSOURCE|IMPLTYPEFLAG_FDEFAULT)) ||
(!sink && (tf & IMPLTYPEFLAG_FSOURCE) == 0)) {
/* flags match what we are looking for */
if (SUCCEEDED(coinfo->lpVtbl->GetRefTypeOfImplType(coinfo, i, &rt)))
if (SUCCEEDED(coinfo->lpVtbl->GetRefTypeInfo(coinfo, rt, &typeinfo)))
break;
}
}
coinfo->lpVtbl->ReleaseTypeAttr(coinfo, attr);
coinfo->lpVtbl->Release(coinfo);
}
}
efree(olename);
} else if (gotguid) {
typelib->lpVtbl->GetTypeInfoOfGuid(typelib, &iid, &typeinfo);
}
if (typelib)
typelib->lpVtbl->Release(typelib);
return typeinfo;
}
/* {{{ proto bool com_print_typeinfo(mixed comobject | string typelib, string dispinterface, bool wantsink)
Print out a PHP class definition for a dispatchable interface */
PHP_FUNCTION(com_print_typeinfo)
{
zval *arg1;
char *ifacename = NULL;
char *typelibname = NULL;
int ifacelen;
zend_bool wantsink = 0;
comval *obj = NULL;
ITypeInfo *typeinfo;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/s!b", &arg1, &ifacename,
&ifacelen, &wantsink)) {
RETURN_FALSE;
}
if (Z_TYPE_P(arg1) == IS_OBJECT && (Z_OBJCE_P(arg1) == &COM_class_entry || !strcmp(Z_OBJCE_P(arg1)->name, "COM"))) {
zval **tmp;
zend_hash_index_find(Z_OBJPROP_P(arg1), 0, (void**)&tmp);
ZEND_FETCH_RESOURCE(obj, comval*, tmp, -1, "comval", IS_COM);
} else if (Z_TYPE_P(arg1) == IS_RESOURCE) {
ZEND_FETCH_RESOURCE(obj, comval*, &arg1, -1, "comval", IS_COM);
} else {
convert_to_string(arg1);
typelibname = Z_STRVAL_P(arg1);
}
typeinfo = locate_typeinfo(typelibname, obj, ifacename, wantsink TSRMLS_CC);
if (typeinfo) {
process_typeinfo(typeinfo, NULL, 1, NULL TSRMLS_CC);
typeinfo->lpVtbl->Release(typeinfo);
RETURN_TRUE;
} else {
zend_error(E_WARNING, "Unable to find typeinfo using the parameters supplied");
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto bool com_event_sink(mixed comobject, object sinkobject [, mixed sinkinterface])
Connect events from a COM object to a PHP object */
PHP_FUNCTION(com_event_sink)
{
zval *object, *sinkobject, *sink=NULL;
char *dispname = NULL, *typelibname = NULL;
zend_bool gotguid = 0;
comval *obj;
ITypeInfo *typeinfo = NULL;
RETVAL_FALSE;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z/", &object, &sinkobject, &sink)) {
RETURN_FALSE;
}
if (Z_TYPE_P(object) == IS_OBJECT && (Z_OBJCE_P(object) == &COM_class_entry || !strcmp(Z_OBJCE_P(object)->name, "COM"))) {
zval **tmp;
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void**)&tmp);
ZEND_FETCH_RESOURCE(obj, comval*, tmp, -1, "comval", IS_COM);
} else {
ZEND_FETCH_RESOURCE(obj, comval*, &object, -1, "comval", IS_COM);
}
if (sink && Z_TYPE_P(sink) == IS_ARRAY) {
/* 0 => typelibname, 1 => dispname */
zval **tmp;
if (zend_hash_index_find(Z_ARRVAL_P(sink), 0, (void**)&tmp) == SUCCESS)
typelibname = Z_STRVAL_PP(tmp);
if (zend_hash_index_find(Z_ARRVAL_P(sink), 1, (void**)&tmp) == SUCCESS)
dispname = Z_STRVAL_PP(tmp);
} else if (sink != NULL) {
convert_to_string(sink);
dispname = Z_STRVAL_P(sink);
}
typeinfo = locate_typeinfo(typelibname, obj, dispname, 1 TSRMLS_CC);
if (typeinfo) {
HashTable *id_to_name;
ALLOC_HASHTABLE(id_to_name);
if (process_typeinfo(typeinfo, id_to_name, 0, &obj->sinkid TSRMLS_CC)) {
/* Create the COM wrapper for this sink */
obj->sinkdispatch = php_COM_export_as_sink(sinkobject, &obj->sinkid, id_to_name TSRMLS_CC);
/* Now hook it up to the source */
com_enable_events(obj, TRUE);
RETVAL_TRUE;
} else {
FREE_HASHTABLE(id_to_name);
}
}
if (typeinfo)
typeinfo->lpVtbl->Release(typeinfo);
}
/* }}} */
static int do_COM_offget(VARIANT *result, comval *array, pval *property, int cleanup TSRMLS_DC)
{
@@ -1122,33 +1586,36 @@ static void do_COM_propput(pval *return_value, comval *obj, pval *arg_property,
php_error(E_WARNING,"PropPut() failed: %s", error_message);
}
LocalFree(error_message);
efree(propname);
FREE_VARIANT(var_result);
FREE_VARIANT(new_value);
efree(new_value);
efree(propname);
RETURN_NULL();
}
dispparams.cArgs = 0;
dispparams.cNamedArgs = 0;
if (return_value) {
dispparams.cArgs = 0;
dispparams.cNamedArgs = 0;
hr = php_COM_invoke(obj, dispid, DISPATCH_PROPERTYGET, &dispparams, var_result, &ErrString TSRMLS_CC);
hr = php_COM_invoke(obj, dispid, DISPATCH_PROPERTYGET, &dispparams, var_result, &ErrString TSRMLS_CC);
if (SUCCEEDED(hr)) {
php_variant_to_pval(var_result, return_value, codepage TSRMLS_CC);
} else {
*return_value = *value;
zval_copy_ctor(return_value);
}
if (SUCCEEDED(hr)) {
php_variant_to_pval(var_result, return_value, codepage TSRMLS_CC);
} else {
*return_value = *value;
zval_copy_ctor(return_value);
}
if (ErrString) {
pefree(ErrString, 1);
if (ErrString) {
pefree(ErrString, 1);
}
}
FREE_VARIANT(var_result);
FREE_VARIANT(new_value);
efree(new_value); // FREE_VARIANT does a VariantClear() which is not desired here !
efree(propname);
}
@@ -1322,6 +1789,7 @@ PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_refer
obj = obj_prop;
php_COM_set(obj, &V_DISPATCH(var_result), TRUE TSRMLS_CC);
VariantInit(var_result); // to protect C_DISPATCH(obj) from being freed when var_result is destructed
} else {
php_variant_to_pval(var_result, &return_value, codepage TSRMLS_CC);
@@ -1329,7 +1797,6 @@ PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_refer
obj_prop = NULL;
}
VariantInit(var_result); // to protect C_DISPATCH(obj) from being freed when var_result is destructed
pval_destructor(&overloaded_property->element);
}
@@ -1346,7 +1813,6 @@ PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_refer
PHPAPI int php_COM_set_property_handler(zend_property_reference *property_reference, pval *value)
{
pval result;
zend_overloaded_element *overloaded_property;
zend_llist_element *element;
pval **comval_handle;
@@ -1416,7 +1882,7 @@ PHPAPI int php_COM_set_property_handler(zend_property_reference *property_refere
FREE_VARIANT(var_result);
overloaded_property = (zend_overloaded_element *) element->data;
do_COM_propput(&result, obj, &overloaded_property->element, value TSRMLS_CC);
do_COM_propput(NULL, obj, &overloaded_property->element, value TSRMLS_CC);
FREE_COM(obj_prop);
pval_destructor(&overloaded_property->element);
@@ -1424,6 +1890,20 @@ PHPAPI int php_COM_set_property_handler(zend_property_reference *property_refere
return SUCCESS;
}
/* create an overloaded COM object from a dispatch pointer */
PHPAPI zval *php_COM_object_from_dispatch(IDispatch *disp, zval *val TSRMLS_DC)
{
comval *obj;
zval *zobj;
ALLOC_COM(obj);
MAKE_STD_ZVAL(zobj);
php_COM_set(obj, &disp, FALSE TSRMLS_CC);
ZVAL_COM_EX(zobj, obj, val);
return zobj;
}
PHPAPI void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference)
{
@@ -1526,6 +2006,10 @@ static ITypeLib *php_COM_find_typelib(char *search_string, int mode TSRMLS_DC)
*/
search_string = php_strtok_r(search_string, ",", &strtok_buf);
if (search_string == NULL)
return NULL;
major = php_strtok_r(NULL, ",", &strtok_buf);
minor = php_strtok_r(NULL, ",", &strtok_buf);
@@ -1672,7 +2156,7 @@ static ITypeLib *php_COM_find_typelib(char *search_string, int mode TSRMLS_DC)
}
static int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC)
PHPAPI int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC)
{
ITypeComp *TypeComp;
int i;
@@ -1754,7 +2238,6 @@ static int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC)
return SUCCESS;
}
/* {{{ proto bool com_isenum(object com_module)
Grabs an IEnumVariant */
PHP_FUNCTION(com_isenum)
@@ -1800,11 +2283,18 @@ static void php_COM_init(int module_number TSRMLS_DC)
php_register_COM_class(TSRMLS_C);
}
PHPAPI ZEND_DECLARE_MODULE_GLOBALS(com)
static void php_com_init_globals(zend_com_globals *com_globals)
{
}
PHP_MINIT_FUNCTION(COM)
{
ZEND_INIT_MODULE_GLOBALS(com, php_com_init_globals, NULL);
php_COM_init(module_number TSRMLS_CC);
php_VARIANT_init(module_number TSRMLS_CC);
php_COM_dispatch_init(module_number TSRMLS_CC);
REGISTER_LONG_CONSTANT("CLSCTX_INPROC_SERVER", CLSCTX_INPROC_SERVER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CLSCTX_INPROC_HANDLER", CLSCTX_INPROC_HANDLER, CONST_CS | CONST_PERSISTENT);
@@ -1818,7 +2308,6 @@ PHP_MINIT_FUNCTION(COM)
return SUCCESS;
}
PHP_MSHUTDOWN_FUNCTION(COM)
{
UNREGISTER_INI_ENTRIES();
@@ -1835,7 +2324,7 @@ zend_module_entry COM_module_entry = {
PHP_MSHUTDOWN(COM),
NULL,
NULL,
PHP_MINFO(COM),
PHP_MINFO(COM),
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
+1 -1
View File
@@ -1,2 +1,2 @@
Win32 COM
Zeev Suraski, Harald Radi, Alan Brown
Alan Brown, Wez Furlong, Harald Radi, Zeev Suraski
+1
View File
@@ -181,6 +181,7 @@ static pval php_VARIANT_get_property_handler(zend_property_reference *property_r
case OE_IS_OBJECT:
if (!strcmp(Z_STRVAL(overloaded_property->element), "value")) {
// var_arg can't be an idispatch, so we don't care for the implicit AddRef() call here
php_variant_to_pval(var_arg, &result, codepage TSRMLS_CC);
} else if (!strcmp(Z_STRVAL(overloaded_property->element), "type")) {
ZVAL_LONG(&result, V_VT(var_arg))
+13 -4
View File
@@ -19,19 +19,28 @@ typedef struct comval_ {
ITypeInfo *typeinfo;
IEnumVARIANT *enumvariant;
} i;
IDispatch *sinkdispatch;
GUID sinkid;
DWORD sinkcookie;
} comval;
END_EXTERN_C()
#define ZVAL_COM(z,o) { \
zval *handle; \
zval *handle = NULL; \
ZVAL_COM_EX(z,o,handle) \
}
#define ZVAL_COM_EX(z,o,handle) { \
HashTable *properties; \
\
ALLOC_HASHTABLE(properties); \
zend_hash_init(properties, 0, NULL, ZVAL_PTR_DTOR, 0); \
\
MAKE_STD_ZVAL(handle); \
ZVAL_LONG(handle, zend_list_insert((o), IS_COM)); \
if (handle == NULL) { \
MAKE_STD_ZVAL(handle); \
} \
ZVAL_RESOURCE(handle, zend_list_insert((o), IS_COM)); \
\
zval_copy_ctor(handle); \
zend_hash_index_update(properties, 0, &handle, sizeof(zval *), NULL); \
@@ -42,7 +51,7 @@ END_EXTERN_C()
#define RETURN_COM(o) RETVAL_COM(o) \
return;
#define ALLOC_COM(z) (z) = (comval *) emalloc(sizeof(comval)); \
#define ALLOC_COM(z) (z) = (comval *) ecalloc(1, sizeof(comval)); \
C_REFCOUNT(z) = 0;
#define FREE_COM(z) php_COM_destruct(z TSRMLS_CC);
+21 -6
View File
@@ -56,7 +56,7 @@ PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage T
case IS_OBJECT:
if (!strcmp(Z_OBJCE_P(pval_arg)->name, "VARIANT")) {
type = VT_VARIANT|VT_BYREF;
} else if (!strcmp(Z_OBJCE_P(pval_arg)->name, "COM")) {
} else {
type = VT_DISPATCH;
}
break;
@@ -155,6 +155,12 @@ PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type,
}
} else {
switch (V_VT(var_arg)) {
case VT_NULL:
case VT_VOID:
ZVAL_NULL(pval_arg);
break;
case VT_UI1:
convert_to_long_ex(&pval_arg);
V_UI1(var_arg) = (unsigned char) Z_LVAL_P(pval_arg);
@@ -211,6 +217,7 @@ PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type,
/** @todo
case IS_STRING:
*/
/* string representation of a time value */
default:
@@ -262,7 +269,14 @@ PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type,
break;
case VT_DISPATCH:
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
if (!strcmp(Z_OBJCE_P(pval_arg)->name, "COM")) {
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
} else {
V_DISPATCH(var_arg) = php_COM_export_object(pval_arg TSRMLS_CC);
if (V_DISPATCH(var_arg)) {
V_VT(var_arg) = VT_DISPATCH;
}
}
if (V_VT(var_arg) != VT_DISPATCH) {
VariantInit(var_arg);
}
@@ -437,7 +451,7 @@ PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type,
break;
default:
php_error(E_WARNING, "Type not supported or not yet implemented.");
php_error(E_WARNING,"Unsupported variant type: %d (0x%X)", V_VT(var_arg), V_VT(var_arg));
}
}
}
@@ -705,9 +719,10 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int codepage TS
ZVAL_NULL(pval_arg);
} else {
ALLOC_COM(obj);
php_COM_set(obj, &V_DISPATCH(var_arg), TRUE TSRMLS_CC);
php_COM_set(obj, &V_DISPATCH(var_arg), FALSE TSRMLS_CC);
ZVAL_COM(pval_arg, obj);
VariantInit(var_arg); // to protect C_DISPATCH(obj) from being freed when var_result is destructed
}
}
break;
@@ -769,7 +784,7 @@ PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRML
if (strlen == -1) {
/* request needed buffersize */
strlen = MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED) | MB_ERR_INVALID_CHARS, C_str, -1, NULL, 0);
strlen = MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS), C_str, -1, NULL, 0);
} else {
/* \0 terminator */
strlen++;
@@ -779,7 +794,7 @@ PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRML
unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR) * strlen);
/* convert string */
error = !MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED) | MB_ERR_INVALID_CHARS, C_str, strlen, unicode_str, strlen);
error = !MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS), C_str, strlen, unicode_str, strlen);
} else {
/* return a zero-length string */
unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR));
+627
View File
@@ -0,0 +1,627 @@
/*
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.php.net/license/2_02.txt. |
| 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: Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
/*
* This module is used to export PHP objects to COM and DOTNET by exposing
* them as objects implementing IDispatch.
* */
#include "php.h"
#include "php_COM.h"
#include "php_VARIANT.h"
#include "conversion.h"
#include "variant.h"
#define COBJMACROS
#include <unknwn.h> /* IDispatch */
#include <dispex.h> /* IDispatchEx */
typedef struct {
/* This first part MUST match the declaration
* of interface IDispatchEx */
CONST_VTBL struct IDispatchExVtbl *lpVtbl;
/* now the PHP stuff */
THREAD_T engine_thread; /* for sanity checking */
zval *object; /* the object exported */
LONG refcount; /* COM reference count */
HashTable *dispid_to_name; /* keep track of dispid -> name mappings */
HashTable *name_to_dispid; /* keep track of name -> dispid mappings */
GUID sinkid; /* iid that we "implement" for event sinking */
int id;
} php_dispatchex;
static void disp_destructor(php_dispatchex *disp);
static void dispatch_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
php_dispatchex *disp = (php_dispatchex *)rsrc->ptr;
disp_destructor(disp);
}
static int le_dispatch;
int php_COM_dispatch_init(int module_number TSRMLS_DC)
{
le_dispatch = zend_register_list_destructors_ex(dispatch_dtor, NULL, "COM:Dispatch", module_number);
return le_dispatch;
}
/* {{{ trace */
static inline void trace(char *fmt, ...)
{
va_list ap;
char buf[4096];
sprintf(buf, "T=%08x ", tsrm_thread_id());
OutputDebugString(buf);
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
OutputDebugString(buf);
va_end(ap);
}
/* }}} */
#define FETCH_DISP(methname) \
php_dispatchex *disp = (php_dispatchex*)This; \
trace(" PHP:%s %s\n", Z_OBJCE_P(disp->object)->name, methname); \
if (tsrm_thread_id() != disp->engine_thread) \
return E_UNEXPECTED;
static HRESULT STDMETHODCALLTYPE disp_queryinterface(
IDispatchEx *This,
/* [in] */ REFIID riid,
/* [iid_is][out] */ void **ppvObject)
{
FETCH_DISP("QueryInterface");
if (IsEqualGUID(&IID_IUnknown, riid) ||
IsEqualGUID(&IID_IDispatch, riid) ||
IsEqualGUID(&IID_IDispatchEx, riid) ||
IsEqualGUID(&disp->sinkid, riid)) {
*ppvObject = This;
InterlockedIncrement(&disp->refcount);
return S_OK;
}
*ppvObject = NULL;
return E_NOINTERFACE;
}
static ULONG STDMETHODCALLTYPE disp_addref(IDispatchEx *This)
{
FETCH_DISP("AddRef");
return InterlockedIncrement(&disp->refcount);
}
static ULONG STDMETHODCALLTYPE disp_release(IDispatchEx *This)
{
ULONG ret;
TSRMLS_FETCH();
FETCH_DISP("Release");
ret = InterlockedDecrement(&disp->refcount);
trace("-- refcount now %d\n", ret);
if (ret == 0) {
/* destroy it */
if (disp->id)
zend_list_delete(disp->id);
}
return ret;
}
static HRESULT STDMETHODCALLTYPE disp_gettypeinfocount(
IDispatchEx *This,
/* [out] */ UINT *pctinfo)
{
FETCH_DISP("GetTypeInfoCount");
*pctinfo = 0;
return S_OK;
}
static HRESULT STDMETHODCALLTYPE disp_gettypeinfo(
IDispatchEx *This,
/* [in] */ UINT iTInfo,
/* [in] */ LCID lcid,
/* [out] */ ITypeInfo **ppTInfo)
{
FETCH_DISP("GetTypeInfo");
*ppTInfo = NULL;
return DISP_E_BADINDEX;
}
static HRESULT STDMETHODCALLTYPE disp_getidsofnames(
IDispatchEx *This,
/* [in] */ REFIID riid,
/* [size_is][in] */ LPOLESTR *rgszNames,
/* [in] */ UINT cNames,
/* [in] */ LCID lcid,
/* [size_is][out] */ DISPID *rgDispId)
{
UINT i;
HRESULT ret = S_OK;
TSRMLS_FETCH();
FETCH_DISP("GetIDsOfNames");
for (i = 0; i < cNames; i++) {
char *name;
unsigned int namelen;
zval **tmp;
name = php_OLECHAR_to_char(rgszNames[i], &namelen, CP_ACP TSRMLS_CC);
/* Lookup the name in the hash */
if (zend_hash_find(disp->name_to_dispid, name, namelen+1, (void**)&tmp) == FAILURE) {
ret = DISP_E_UNKNOWNNAME;
rgDispId[i] = 0;
} else {
rgDispId[i] = Z_LVAL_PP(tmp);
}
efree(name);
}
return ret;
}
static HRESULT STDMETHODCALLTYPE disp_invoke(
IDispatchEx *This,
/* [in] */ DISPID dispIdMember,
/* [in] */ REFIID riid,
/* [in] */ LCID lcid,
/* [in] */ WORD wFlags,
/* [out][in] */ DISPPARAMS *pDispParams,
/* [out] */ VARIANT *pVarResult,
/* [out] */ EXCEPINFO *pExcepInfo,
/* [out] */ UINT *puArgErr)
{
return This->lpVtbl->InvokeEx(This, dispIdMember,
lcid, wFlags, pDispParams,
pVarResult, pExcepInfo, NULL);
}
static HRESULT STDMETHODCALLTYPE disp_getdispid(
IDispatchEx *This,
/* [in] */ BSTR bstrName,
/* [in] */ DWORD grfdex,
/* [out] */ DISPID *pid)
{
HRESULT ret = DISP_E_UNKNOWNNAME;
char *name;
unsigned int namelen;
zval **tmp;
TSRMLS_FETCH();
FETCH_DISP("GetDispID");
name = php_OLECHAR_to_char(bstrName, &namelen, CP_ACP TSRMLS_CC);
/* Lookup the name in the hash */
if (zend_hash_find(disp->name_to_dispid, name, namelen+1, (void**)&tmp) == SUCCESS) {
*pid = Z_LVAL_PP(tmp);
ret = S_OK;
}
efree(name);
return ret;
}
static HRESULT STDMETHODCALLTYPE disp_invokeex(
IDispatchEx *This,
/* [in] */ DISPID id,
/* [in] */ LCID lcid,
/* [in] */ WORD wFlags,
/* [in] */ DISPPARAMS *pdp,
/* [out] */ VARIANT *pvarRes,
/* [out] */ EXCEPINFO *pei,
/* [unique][in] */ IServiceProvider *pspCaller)
{
zval **name;
UINT i;
int codepage = CP_ACP;
zval *retval = NULL;
zval ***params = NULL;
HRESULT ret = DISP_E_MEMBERNOTFOUND;
TSRMLS_FETCH();
FETCH_DISP("InvokeEx");
if (SUCCESS == zend_hash_index_find(disp->dispid_to_name, id, (void**)&name)) {
/* TODO: add support for overloaded objects */
trace("-- Invoke: %d %20s flags=%08x args=%d\n", id, Z_STRVAL_PP(name), wFlags, pdp->cArgs);
/* convert args into zvals.
* Args are in reverse order */
params = (zval ***)emalloc(sizeof(zval **) * pdp->cArgs);
for (i = 0; i < pdp->cArgs; i++) {
VARIANT *arg;
zval *zarg;
arg = &pdp->rgvarg[ pdp->cArgs - 1 - i];
trace("alloc zval for arg %d VT=%08x\n", i, V_VT(arg));
ALLOC_INIT_ZVAL(zarg);
if (V_VT(arg) == VT_DISPATCH) {
trace("arg %d is dispatchable\n", i);
if (NULL == php_COM_object_from_dispatch(V_DISPATCH(arg), zarg TSRMLS_CC)) {
trace("failed to convert arg %d to zval\n", i);
ZVAL_NULL(zarg);
}
} else {
// arg can't be an idispatch, so we don't care for the implicit AddRef() call here
if (FAILURE == php_variant_to_pval(arg, zarg, codepage TSRMLS_CC)) {
trace("failed to convert arg %d to zval\n", i);
ZVAL_NULL(zarg);
}
}
params[i] = &zarg;
}
trace("arguments processed, prepare to do some work\n");
if (wFlags & DISPATCH_PROPERTYGET) {
trace("trying to get a property\n");
zend_hash_find(Z_OBJPROP_P(disp->object), Z_STRVAL_PP(name), Z_STRLEN_PP(name)+1, (void**)&retval);
} else if (wFlags & DISPATCH_PROPERTYPUT) {
trace("trying to set a property\n");
add_property_zval(disp->object, Z_STRVAL_PP(name), *params[0]);
} else if (wFlags & DISPATCH_METHOD) {
trace("Trying to call user function\n");
if (SUCCESS == call_user_function_ex(EG(function_table), &disp->object, *name,
&retval, pdp->cArgs, params, 1, NULL TSRMLS_CC)) {
ret = S_OK;
} else {
ret = DISP_E_EXCEPTION;
}
} else {
trace("Don't know how to handle this invocation %08x\n", wFlags);
}
/* release arguments */
for (i = 0; i < pdp->cArgs; i++)
zval_ptr_dtor(params[i]);
efree(params);
/* return value */
if (retval) {
if (pvarRes) {
if (Z_TYPE_P(retval) == IS_OBJECT) {
/* export the object using a dispatch like ourselves */
VariantInit(pvarRes);
V_VT(pvarRes) = VT_DISPATCH;
V_DISPATCH(pvarRes) = php_COM_export_object(retval TSRMLS_CC);
} else {
php_pval_to_variant(retval, pvarRes, codepage TSRMLS_CC);
}
}
zval_ptr_dtor(&retval);
} else if (pvarRes) {
VariantInit(pvarRes);
}
} else {
trace("InvokeEx: I don't support DISPID=%d\n", id);
}
return ret;
}
static HRESULT STDMETHODCALLTYPE disp_deletememberbyname(
IDispatchEx *This,
/* [in] */ BSTR bstrName,
/* [in] */ DWORD grfdex)
{
FETCH_DISP("DeleteMemberByName");
return S_FALSE;
}
static HRESULT STDMETHODCALLTYPE disp_deletememberbydispid(
IDispatchEx *This,
/* [in] */ DISPID id)
{
FETCH_DISP("DeleteMemberByDispID");
return S_FALSE;
}
static HRESULT STDMETHODCALLTYPE disp_getmemberproperties(
IDispatchEx *This,
/* [in] */ DISPID id,
/* [in] */ DWORD grfdexFetch,
/* [out] */ DWORD *pgrfdex)
{
FETCH_DISP("GetMemberProperties");
return DISP_E_UNKNOWNNAME;
}
static HRESULT STDMETHODCALLTYPE disp_getmembername(
IDispatchEx *This,
/* [in] */ DISPID id,
/* [out] */ BSTR *pbstrName)
{
zval *name;
TSRMLS_FETCH();
FETCH_DISP("GetMemberName");
if (SUCCESS == zend_hash_index_find(disp->dispid_to_name, id, (void**)&name)) {
OLECHAR *olestr = php_char_to_OLECHAR(Z_STRVAL_P(name), Z_STRLEN_P(name), CP_ACP TSRMLS_CC);
*pbstrName = SysAllocString(olestr);
efree(olestr);
return S_OK;
} else {
return DISP_E_UNKNOWNNAME;
}
}
static HRESULT STDMETHODCALLTYPE disp_getnextdispid(
IDispatchEx *This,
/* [in] */ DWORD grfdex,
/* [in] */ DISPID id,
/* [out] */ DISPID *pid)
{
ulong next = id+1;
FETCH_DISP("GetNextDispID");
while(!zend_hash_index_exists(disp->dispid_to_name, next))
next++;
if (zend_hash_index_exists(disp->dispid_to_name, next)) {
*pid = next;
return S_OK;
}
return S_FALSE;
}
static HRESULT STDMETHODCALLTYPE disp_getnamespaceparent(
IDispatchEx *This,
/* [out] */ IUnknown **ppunk)
{
FETCH_DISP("GetNameSpaceParent");
*ppunk = NULL;
return E_NOTIMPL;
}
static struct IDispatchExVtbl php_dispatch_vtbl = {
disp_queryinterface,
disp_addref,
disp_release,
disp_gettypeinfocount,
disp_gettypeinfo,
disp_getidsofnames,
disp_invoke,
disp_getdispid,
disp_invokeex,
disp_deletememberbyname,
disp_deletememberbydispid,
disp_getmemberproperties,
disp_getmembername,
disp_getnextdispid,
disp_getnamespaceparent
};
/* enumerate functions and properties of the object and assign
* dispatch ids */
static void generate_dispids(php_dispatchex *disp TSRMLS_DC)
{
HashPosition pos;
char *name = NULL;
zval *tmp;
int namelen;
int keytype;
ulong pid;
if (disp->dispid_to_name == NULL) {
ALLOC_HASHTABLE(disp->dispid_to_name);
ALLOC_HASHTABLE(disp->name_to_dispid);
zend_hash_init(disp->name_to_dispid, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_init(disp->dispid_to_name, 0, NULL, ZVAL_PTR_DTOR, 0);
}
/* properties */
zend_hash_internal_pointer_reset_ex(Z_OBJPROP_PP(&disp->object), &pos);
while (HASH_KEY_NON_EXISTANT != (keytype =
zend_hash_get_current_key_ex(Z_OBJPROP_PP(&disp->object), &name, &namelen, &pid, 0, &pos))) {
char namebuf[32];
if (keytype == HASH_KEY_IS_LONG) {
sprintf(namebuf, "%d", pid);
name = namebuf;
namelen = strlen(namebuf);
}
zend_hash_move_forward_ex(Z_OBJPROP_PP(&disp->object), &pos);
/* Find the existing id */
if (zend_hash_find(disp->name_to_dispid, name, namelen+1, (void**)&tmp) == SUCCESS)
continue;
/* add the mappings */
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, name, namelen, 1);
zend_hash_index_update(disp->dispid_to_name, pid, (void*)&tmp, sizeof(zval *), NULL);
MAKE_STD_ZVAL(tmp);
ZVAL_LONG(tmp, pid);
zend_hash_update(disp->name_to_dispid, name, namelen+1, (void*)&tmp, sizeof(zval *), NULL);
}
/* functions */
zend_hash_internal_pointer_reset_ex(&Z_OBJCE_PP(&disp->object)->function_table, &pos);
while (HASH_KEY_NON_EXISTANT != (keytype =
zend_hash_get_current_key_ex(&Z_OBJCE_PP(&disp->object)->function_table, &name, &namelen, &pid, 0, &pos))) {
char namebuf[32];
if (keytype == HASH_KEY_IS_LONG) {
sprintf(namebuf, "%d", pid);
name = namebuf;
namelen = strlen(namebuf);
}
zend_hash_move_forward_ex(Z_OBJPROP_PP(&disp->object), &pos);
/* Find the existing id */
if (zend_hash_find(disp->name_to_dispid, name, namelen+1, (void**)&tmp) == SUCCESS)
continue;
/* add the mappings */
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, name, namelen, 1);
zend_hash_index_update(disp->dispid_to_name, pid, (void*)&tmp, sizeof(zval *), NULL);
MAKE_STD_ZVAL(tmp);
ZVAL_LONG(tmp, pid);
zend_hash_update(disp->name_to_dispid, name, namelen+1, (void*)&tmp, sizeof(zval *), NULL);
}
}
static php_dispatchex *disp_constructor(zval *object TSRMLS_DC)
{
php_dispatchex *disp = (php_dispatchex*)CoTaskMemAlloc(sizeof(php_dispatchex));
trace("constructing a COM proxy\n");
if (disp == NULL)
return NULL;
memset(disp, 0, sizeof(php_dispatchex));
disp->engine_thread = tsrm_thread_id();
disp->lpVtbl = &php_dispatch_vtbl;
disp->refcount = 1;
if (object)
ZVAL_ADDREF(object);
disp->object = object;
disp->id = zend_list_insert(disp, le_dispatch);
return disp;
}
static void disp_destructor(php_dispatchex *disp)
{
TSRMLS_FETCH();
trace("destroying COM wrapper for PHP object %s\n", Z_OBJCE_P(disp->object)->name);
disp->id = 0;
if (disp->refcount > 0)
CoDisconnectObject((IUnknown*)disp, 0);
zend_hash_destroy(disp->dispid_to_name);
zend_hash_destroy(disp->name_to_dispid);
FREE_HASHTABLE(disp->dispid_to_name);
FREE_HASHTABLE(disp->name_to_dispid);
if (disp->object)
zval_ptr_dtor(&disp->object);
CoTaskMemFree(disp);
}
PHPAPI IDispatch *php_COM_export_as_sink(zval *val, GUID *sinkid, HashTable *id_to_name TSRMLS_DC)
{
php_dispatchex *disp = disp_constructor(val TSRMLS_CC);
HashPosition pos;
char *name = NULL;
zval *tmp, **ntmp;
int namelen;
int keytype;
ulong pid;
disp->dispid_to_name = id_to_name;
memcpy(&disp->sinkid, sinkid, sizeof(disp->sinkid));
/* build up the reverse mapping */
ALLOC_HASHTABLE(disp->name_to_dispid);
zend_hash_init(disp->name_to_dispid, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_internal_pointer_reset_ex(id_to_name, &pos);
while (HASH_KEY_NON_EXISTANT != (keytype =
zend_hash_get_current_key_ex(id_to_name, &name, &namelen, &pid, 0, &pos))) {
if (keytype == HASH_KEY_IS_LONG) {
zend_hash_get_current_data_ex(id_to_name, (void**)&ntmp, &pos);
MAKE_STD_ZVAL(tmp);
ZVAL_LONG(tmp, pid);
zend_hash_update(disp->name_to_dispid, Z_STRVAL_PP(ntmp), Z_STRLEN_PP(ntmp)+1, (void*)&tmp, sizeof(zval *), NULL);
}
zend_hash_move_forward_ex(id_to_name, &pos);
}
return (IDispatch*)disp;
}
PHPAPI IDispatch *php_COM_export_object(zval *val TSRMLS_DC)
{
php_dispatchex *disp = NULL;
if (Z_TYPE_P(val) != IS_OBJECT)
return NULL;
if (Z_OBJCE_P(val) == &COM_class_entry || !strcmp(Z_OBJCE_P(val)->name, "COM")) {
/* pass back it's IDispatch directly */
zval **tmp;
comval *obj;
int type;
zend_hash_index_find(Z_OBJPROP_P(val), 0, (void**)&tmp);
obj = (comval *)zend_list_find(Z_LVAL_PP(tmp), &type);
if (type != IS_COM)
return NULL;
C_DISPATCH(obj)->lpVtbl->AddRef(C_DISPATCH(obj));
return C_DISPATCH(obj);
}
disp = disp_constructor(val TSRMLS_CC);
generate_dispids(disp TSRMLS_CC);
return (IDispatch*)disp;
}
+22
View File
@@ -18,6 +18,9 @@ PHP_FUNCTION(com_propget);
PHP_FUNCTION(com_propput);
PHP_FUNCTION(com_load_typelib);
PHP_FUNCTION(com_isenum);
PHP_FUNCTION(com_event_sink);
PHP_FUNCTION(com_message_pump);
PHP_FUNCTION(com_print_typeinfo);
PHPAPI HRESULT php_COM_invoke(comval *obj, DISPID dispIdMember, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult, char **ErrString TSRMLS_DC);
PHPAPI HRESULT php_COM_get_ids_of_names(comval *obj, OLECHAR FAR* FAR* rgszNames, DISPID FAR* rgDispId TSRMLS_DC);
@@ -31,6 +34,13 @@ PHPAPI int php_COM_get_le_comval();
PHPAPI int php_COM_set_property_handler(zend_property_reference *property_reference, pval *value);
PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_reference);
PHPAPI void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference);
PHPAPI zval *php_COM_object_from_dispatch(IDispatch *disp, zval *val TSRMLS_DC);
PHPAPI int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC);
/* dispatch.c */
PHPAPI IDispatch *php_COM_export_object(zval *val TSRMLS_DC);
PHPAPI IDispatch *php_COM_export_as_sink(zval *val, GUID *sinkid, HashTable *id_to_name TSRMLS_DC);
int php_COM_dispatch_init(int module_number TSRMLS_DC);
zend_module_entry COM_module_entry;
zend_class_entry COM_class_entry;
@@ -43,6 +53,18 @@ END_EXTERN_C()
#define phpext_com_ptr &COM_module_entry
ZEND_BEGIN_MODULE_GLOBALS(com)
int nothing;
ZEND_END_MODULE_GLOBALS(com)
PHPAPI ZEND_EXTERN_MODULE_GLOBALS(com);
#ifdef ZTS
#define COMG(v) TSRMG(com_globals_id, zend_com_globals *, v)
#else
#define COMG(v) (com_globals.v)
#endif
#else
#define phpext_com_ptr NULL
+1 -1
View File
@@ -16,7 +16,7 @@
comval *obj; \
ALLOC_COM(obj); \
php_COM_set(obj, &V_DISPATCH(v), TRUE TSRMLS_CC); \
ZVAL_LONG((z), zend_list_insert(obj, IS_COM)); \
ZVAL_RESOURCE((z), zend_list_insert(obj, IS_COM)); \
} else { \
php_variant_to_pval((v), (z), codepage TSRMLS_CC); \
FREE_VARIANT(v); \
+2 -2
View File
@@ -198,7 +198,7 @@ int dbx_sybasect_getcolumnname(zval **rv, zval **result_handle, long column_inde
zval_ptr_dtor(zv_name);
FREE_ZVAL(zval_column_index);
// MOVE_RETURNED_TO_RV(rv, returned_zval);
/* MOVE_RETURNED_TO_RV(rv, returned_zval); */
return 1;
}
@@ -235,7 +235,7 @@ int dbx_sybasect_getcolumntype(zval **rv, zval **result_handle, long column_inde
zval_ptr_dtor(zv_type);
FREE_ZVAL(zval_column_index);
// MOVE_RETURNED_TO_RV(rv, returned_zval);
/* MOVE_RETURNED_TO_RV(rv, returned_zval); */
return 1;
}
+5 -5
View File
@@ -8,19 +8,19 @@ AC_DEFUN(PHP_DOM_CHECK_VERSION,[
AC_MSG_CHECKING(for libxml version)
AC_EGREP_CPP(yes,[
#include <libxml/xmlversion.h>
#if LIBXML_VERSION >= 20402
#if LIBXML_VERSION >= 20414
yes
#endif
],[
AC_MSG_RESULT(>= 2.4.2)
AC_MSG_RESULT(>= 2.4.14)
],[
AC_MSG_ERROR(libxml version 2.4.2 or greater required.)
AC_MSG_ERROR(libxml version 2.4.14 or greater required.)
])
CPPFLAGS=$old_CPPFLAGS
])
PHP_ARG_WITH(dom, for DOM support,
[ --with-dom[=DIR] Include DOM support (requires libxml >= 2.4.2).
[ --with-dom[=DIR] Include DOM support (requires libxml >= 2.4.14).
DIR is the libxml install directory.])
if test "$PHP_DOM" != "no"; then
@@ -40,7 +40,7 @@ if test "$PHP_DOM" != "no"; then
if test -z "$DOMXML_DIR"; then
AC_MSG_RESULT(not found)
AC_MSG_ERROR(Please reinstall the libxml >= 2.4.2 distribution)
AC_MSG_ERROR(Please reinstall the libxml >= 2.4.14 distribution)
fi
PHP_DOM_CHECK_VERSION
+39 -18
View File
@@ -493,15 +493,21 @@ static zval *dom_object_get_data(void *obj)
static inline void node_wrapper_dtor(xmlNodePtr node)
{
zval *wrapper;
int refcount = 0;
/* FIXME: type check probably unnecessary here? */
if (!node || Z_TYPE_P(node) == XML_DTD_NODE)
return;
wrapper = dom_object_get_data(node);
if (wrapper)
if (wrapper != NULL) {
refcount = wrapper->refcount;
zval_ptr_dtor(&wrapper);
/*only set it to null, if refcount was 1 before, otherwise it has still needed references */
if (refcount == 1) {
dom_object_set_data(node, NULL);
}
}
}
@@ -561,7 +567,6 @@ static void php_free_xml_doc(zend_rsrc_list_entry *rsrc TSRMLS_DC)
if (doc) {
node_list_wrapper_dtor(doc->children);
node_wrapper_dtor((xmlNodePtr) doc);
xmlFreeDoc(doc);
}
@@ -572,13 +577,28 @@ static void php_free_xml_node(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
xmlNodePtr node = (xmlNodePtr) rsrc->ptr;
if (node) {
zval *wrapper = dom_object_get_data(node);
if (wrapper)
zval_ptr_dtor(&wrapper);
/* if node has no parent, it will not be freed by php_free_xml_doc, so do it here
and for all children as well. */
if (node->parent == NULL) {
node_list_wrapper_dtor(node->children);
node_wrapper_dtor(node);
xmlFreeNode(node);
} else {
node_wrapper_dtor(node);
}
}
static void php_free_xml_attr(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
xmlNodePtr node = (xmlNodePtr) rsrc->ptr;
if (node->parent == NULL) {
node_wrapper_dtor(node);
xmlFreeProp((xmlAttrPtr) node);
} else {
node_wrapper_dtor(node);
}
}
#if defined(LIBXML_XPATH_ENABLED)
static void php_free_xpath_context(zend_rsrc_list_entry *rsrc TSRMLS_DC)
@@ -1247,7 +1267,7 @@ PHP_MINIT_FUNCTION(domxml)
*/
le_domxmlnodep = zend_register_list_destructors_ex(php_free_xml_node, NULL, "domnode", module_number);
le_domxmlcommentp = zend_register_list_destructors_ex(php_free_xml_node, NULL, "domnode", module_number);
le_domxmlattrp = zend_register_list_destructors_ex(php_free_xml_node, NULL, "domattribute", module_number);
le_domxmlattrp = zend_register_list_destructors_ex(php_free_xml_attr, NULL, "domattribute", module_number);
le_domxmltextp = zend_register_list_destructors_ex(php_free_xml_node, NULL, "domtext", module_number);
le_domxmlelementp = zend_register_list_destructors_ex(php_free_xml_node, NULL, "domelement", module_number);
le_domxmldtdp = zend_register_list_destructors_ex(php_free_xml_node, NULL, "domdtd", module_number);
@@ -2034,7 +2054,7 @@ PHP_FUNCTION(domxml_node_append_child)
* Uwe: must have been a temporary problem. It works for me with both
* xmlAddChildList and xmlAddChild
*/
// child = xmlAddSibling(nodep, new_child);
child = xmlAddChild(nodep, new_child);
if (NULL == child) {
@@ -2072,7 +2092,7 @@ PHP_FUNCTION(domxml_node_append_sibling)
RETURN_FALSE;
}
// FIXME reverted xmlAddChildList; crashes
/* FIXME reverted xmlAddChildList; crashes */
child = xmlAddSibling(nodep, new_child);
if (NULL == child) {
@@ -2663,14 +2683,14 @@ PHP_FUNCTION(domxml_doc_get_element_by_id)
xmlDocPtr docp;
idsIterator iter;
xmlHashTable *ids = NULL;
int retnode;
id = getThis();
DOMXML_GET_OBJ(docp, id, le_domxmldocp);
int retnode,idname_len;
char *idname;
DOMXML_PARAM_TWO(docp, id, le_domxmldocp, "s", &idname, &idname_len);
ids = (xmlHashTable *) docp->ids;
if(ids) {
iter.elementId = (xmlChar *)
iter.elementId = (xmlChar *) idname;
iter.element = NULL;
xmlHashScan(ids, idsHashScanner, &iter);
rv = php_domobject_new(iter.element, &retnode TSRMLS_CC);
@@ -3183,7 +3203,8 @@ PHP_FUNCTION(domxml_dump_mem)
if (!size) {
RETURN_FALSE;
}
RETURN_STRINGL(mem, size, 1);
RETVAL_STRINGL(mem, size, 1);
xmlFree(mem);
}
/* }}} */
@@ -3407,7 +3428,7 @@ PHP_FUNCTION(domxml_html_dump_mem)
xmlFree(mem);
RETURN_FALSE;
}
RETURN_STRINGL(mem, size, 1);
RETVAL_STRINGL(mem, size, 1);
xmlFree(mem);
}
/* }}} */
@@ -4266,7 +4287,7 @@ PHP_FUNCTION(domxml_xslt_process)
- test other stuff
- check xsltsp->errors ???
*/
zval *rv, *idxsl, *idxml, *idparams = NULL;
zval *rv = NULL, *idxsl, *idxml, *idparams = NULL;
zend_bool xpath_params = 0;
xsltStylesheetPtr xsltstp;
xmlDocPtr xmldocp;
+2
View File
@@ -341,6 +341,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
while (*walk)
if ('\\' == *walk
&& '0' <= walk[1] && '9' >= walk[1]
&& walk[1] - '0' <= ((char) re.re_nsub)
&& subs[walk[1] - '0'].rm_so > -1
&& subs[walk[1] - '0'].rm_eo > -1) {
new_l += subs[walk[1] - '0'].rm_eo
@@ -368,6 +369,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
while (*walk)
if ('\\' == *walk
&& '0' <= walk[1] && '9' >= walk[1]
&& walk[1] - '0' <= re.re_nsub
&& subs[walk[1] - '0'].rm_so > -1
&& subs[walk[1] - '0'].rm_eo > -1
/* this next case shouldn't happen. it does. */
+17 -8
View File
@@ -720,6 +720,7 @@ typedef struct {
int motorola_intel; /* 1 Motorola; 0 Intel */
char *UserComment;
int UserCommentLen;
char UserCommentEncoding[12];
char *Thumbnail;
@@ -808,6 +809,7 @@ void exif_add_image_info( image_info_type *image_info, int section_index, char *
case TAG_FMT_UNDEFINED:
if ( value) {
info_value->value.s = estrndup(value,length);
info_value->length = length;
} else {
info_value->length = 0;
info_value->value.s = estrdup("");
@@ -834,7 +836,7 @@ void exif_add_image_info( image_info_type *image_info, int section_index, char *
case TAG_FMT_SINGLE:
php_error(E_WARNING, "Found value of type single");
info_value->value.f = (double)*(float *)value;
info_value->value.f = *(float *)value;
case TAG_FMT_DOUBLE:
php_error(E_WARNING, "Found value of type double");
@@ -1280,7 +1282,7 @@ static int exif_process_user_comment(char **pszInfoPtr,char *szEncoding,char *sz
}
/* Olympus has this padded with trailing spaces. Remove these first. */
if (a) for (a=ByteCount-1;a && szValuePtr[a]==' ';a--) (szValuePtr)[a] = '\0';
if (ByteCount) for (a=ByteCount-1;a && szValuePtr[a]==' ';a--) (szValuePtr)[a] = '\0';
/* normal text without encoding */
return exif_process_string(pszInfoPtr, szValuePtr, ByteCount);
@@ -1340,9 +1342,11 @@ static void exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, ch
/* If its bigger than 4 bytes, the dir entry contains an offset. */
value_ptr = offset_base+offset_val;
if (offset_val+byte_count > IFDlength || value_ptr < dir_entry) {
/*
// It is important to check for IMAGE_FILETYPE_TIFF
// JPEG does not use absolute pointers instead its pointers are relative to the start
// of the TIFF header in APP1 section.
*/
if (offset_val<0 || offset_val+byte_count>ImageInfo->FileSize || (ImageInfo->FileType!=IMAGE_FILETYPE_TIFF_II && ImageInfo->FileType!=IMAGE_FILETYPE_TIFF_MM)) {
if (value_ptr < dir_entry) {
/* we can read this if offset_val > 0 */
@@ -1356,7 +1360,7 @@ static void exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, ch
return;
}
if ( byte_count>sizeof(cbuf)) {
// mark as outside range and get buffer
/* mark as outside range and get buffer */
value_ptr = emalloc(byte_count);
if ( !value_ptr) {
php_error(E_WARNING, "could not allocate data for entire image");
@@ -1364,11 +1368,13 @@ static void exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, ch
}
outside = value_ptr;
} else {
/*
// in most cases we only access a small range so
// it is faster to use a static buffer there
// BUT it offers also the possibility to have
// pointers read without the need to free them
// explicitley before returning.
*/
value_ptr = cbuf;
}
fpos = ftell(ImageInfo->infile);
@@ -1417,7 +1423,7 @@ static void exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, ch
switch(tag) {
case TAG_COPYRIGHT:
if (byte_count>1 && (l=php_strnlen(value_ptr,byte_count)) > 0) {
if ( l<byte_count-1) {
if ( (size_t)l<byte_count-1) {
/* When there are any characters after the first NUL */
exif_add_image_info( ImageInfo, SECTION_COMPUTED, "Copyright.Photographer", TAG_COPYRIGHT, TAG_FMT_STRING, l, value_ptr);
exif_add_image_info( ImageInfo, SECTION_COMPUTED, "Copyright.Editor", TAG_COPYRIGHT, TAG_FMT_STRING, byte_count-l-1, value_ptr+l+1);
@@ -1429,7 +1435,9 @@ static void exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, ch
break;
case TAG_USERCOMMENT:
exif_process_user_comment(&(ImageInfo->UserComment),ImageInfo->UserCommentEncoding,value_ptr,byte_count);
ImageInfo->UserCommentLen = exif_process_user_comment(&(ImageInfo->UserComment),ImageInfo->UserCommentEncoding,value_ptr,byte_count);
if (ImageInfo->UserCommentLen)
ImageInfo->UserCommentLen--; /* We want number of characters not allocation size */
break;
/* this is only a comment if type is string! */
@@ -1657,7 +1665,7 @@ static void exif_process_APP12(image_info_type *ImageInfo, char *buffer, unsigne
if ( (l1 = php_strnlen(buffer+2,length-2)) > 0) {
exif_add_image_info( ImageInfo, SECTION_APP12, "Company", TAG_NONE, TAG_FMT_STRING, l1, buffer+2);
if ( length > 2+l1+1) {
if ( length > 2+(unsigned int)l1+1) {
l2 = php_strnlen(buffer+2+l1+1,length-2-l1+1);
exif_add_image_info( ImageInfo, SECTION_APP12, "Info", TAG_NONE, TAG_FMT_STRING, l2, buffer+2+l1+1);
}
@@ -2266,7 +2274,8 @@ PHP_FUNCTION(exif_read_data)
exif_add_image_info( &ImageInfo, SECTION_COMPUTED, "FocusDistance", TAG_NONE, TAG_FMT_STRING, strlen(tmp), tmp);
}
if (ImageInfo.UserComment) {
exif_add_image_info( &ImageInfo, SECTION_COMPUTED, "UserComment", TAG_NONE, TAG_FMT_STRING, strlen(ImageInfo.UserComment), ImageInfo.UserComment);
/*exif_iif_add_int( &ImageInfo, SECTION_COMPUTED, "UserCommentLen", ImageInfo.UserCommentLen);*/
exif_add_image_info( &ImageInfo, SECTION_COMPUTED, "UserComment", TAG_NONE, TAG_FMT_UNDEFINED, ImageInfo.UserCommentLen, ImageInfo.UserComment);
if ( (len=strlen(ImageInfo.UserCommentEncoding))) {
exif_add_image_info( &ImageInfo, SECTION_COMPUTED, "UserCommentEncoding", TAG_NONE, TAG_FMT_STRING, len, ImageInfo.UserCommentEncoding);
}
@@ -2337,7 +2346,7 @@ PHP_FUNCTION(exif_thumbnail)
php_error(E_NOTICE,"Returning thumbnail(%d)", ImageInfo.ThumbnailSize);
#endif
ZVAL_STRINGL( return_value, ImageInfo.Thumbnail, ImageInfo.ThumbnailSize, 1);
RETVAL_STRINGL(ImageInfo.Thumbnail, ImageInfo.ThumbnailSize, 1);
#ifdef EXIF_DEBUG
php_error(E_NOTICE,"Discarding info");
+12 -8
View File
@@ -11,16 +11,20 @@ Check for exif_thumbnail
test2.jpg is the same image but contains Exif/Comment information and a
copy of test1.jpg as a thumbnail.
*/
$istat= stat('./ext/exif/tests/test1.jpg');
$fp = fopen('./ext/exif/tests/test1.jpg','r');
$image = fread($fp,$istat[7]);
echo substr($image,490,5).'_'.$istat[7];
ini_set('magic_quotes_runtime',0);
if (function_exists("ob_end_clean")) ob_end_clean();
$infile= './ext/exif/tests/test1.jpg';
$fp = fopen($infile,'rb');
$image = fread($fp,filesize($infile));
//$image = stripslashes($image);
echo md5($image).'_'.filesize($infile);
fclose($fp);
$thumb = exif_thumbnail('./ext/exif/tests/test2.jpg');
echo strcmp($image,$thumb) ? 'different' : '_identical_';
echo strlen($thumb);
echo '_'.substr($thumb,490,5);
echo strcmp($image,$thumb) ? '_different_' : '_identical_';
echo strlen($thumb).'_'.md5($thumb);
echo "\n";
/* 7GWgw_523_identical_523_7GWgw */
?>
--EXPECT--
7GWgw_523_identical_523_7GWgw
27bbfd9fc10e1e663d749f5225447905_523_identical_523_27bbfd9fc10e1e663d749f5225447905
+3 -2
View File
@@ -1145,8 +1145,9 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
int issock=0, socketd=0;
int argc=ZEND_NUM_ARGS();
if ((image_type == PHP_GDIMG_TYPE_GD2PART && argc != 4) ||
argc != 1 || zend_get_parameters_ex(argc, &file, &srcx, &srcy, &width, &height) == FAILURE) {
if ((image_type == PHP_GDIMG_TYPE_GD2PART && argc != 5) ||
(image_type != PHP_GDIMG_TYPE_GD2PART && argc != 1) ||
zend_get_parameters_ex(argc, &file, &srcx, &srcy, &width, &height) == FAILURE) {
ZEND_WRONG_PARAM_COUNT();
}
+2 -2
View File
@@ -17,9 +17,9 @@ if test "$PHP_GMP" != "no"; then
AC_MSG_ERROR(Unable to locate gmp.h)
fi
PHP_ADD_INCLUDE($GMP_DIR/include)
PHP_EXTENSION(gmp, $ext_shared)
AC_DEFINE(HAVE_GMP, 1, [ ])
PHP_ADD_LIBRARY_WITH_PATH(gmp, $GMP_DIR/lib)
PHP_SUBST(GMP_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(gmp, $GMP_DIR/lib, GMP_SHARED_LIBADD)
fi
+2 -2
View File
@@ -42,7 +42,7 @@ AC_DEFUN(PHP_IMAP_KRB_CHK, [
PHP_ADD_LIBRARY(com_err, 1, IMAP_SHARED_LIBADD)
else
AC_EGREP_HEADER(auth_gss, $IMAP_INC_DIR/linkage.h, [
AC_MSG_ERROR(This c-client library is build with Kerberos support.
AC_MSG_ERROR(This c-client library is built with Kerberos support.
Add --with-kerberos<=DIR> to your configure line. Check config.log for details.)
])
@@ -96,7 +96,7 @@ AC_DEFUN(PHP_IMAP_SSL_CHK, [
return 0;
}
],,[
AC_MSG_ERROR(This c-client library is build with SSL support.
AC_MSG_ERROR(This c-client library is built with SSL support.
Add --with-imap-ssl<=DIR> to your configure line. Check config.log for details.)
])
+22 -15
View File
@@ -620,20 +620,24 @@ PHP_RSHUTDOWN_FUNCTION(imap)
if (IMAPG(imap_errorstack) != NIL) {
/* output any remaining errors at their original error level */
ecur = IMAPG(imap_errorstack);
while (ecur != NIL) {
php_error(E_NOTICE, "%s (errflg=%d)", ecur->LTEXT, ecur->errflg);
ecur = ecur->next;
if (EG(error_reporting) & E_NOTICE) {
ecur = IMAPG(imap_errorstack);
while (ecur != NIL) {
php_error(E_NOTICE, "%s (errflg=%d)", ecur->LTEXT, ecur->errflg);
ecur = ecur->next;
}
}
mail_free_errorlist(&IMAPG(imap_errorstack));
}
if (IMAPG(imap_alertstack) != NIL) {
/* output any remaining alerts at E_NOTICE level */
acur = IMAPG(imap_alertstack);
while (acur != NIL) {
php_error(E_NOTICE, acur->LTEXT);
acur = acur->next;
if (EG(error_reporting) & E_NOTICE) {
acur = IMAPG(imap_alertstack);
while (acur != NIL) {
php_error(E_NOTICE, acur->LTEXT);
acur = acur->next;
}
}
mail_free_stringlist(&IMAPG(imap_alertstack));
}
@@ -2187,6 +2191,7 @@ PHP_FUNCTION(imap_utf7_decode)
zval **arg;
const unsigned char *in, *inp, *endp;
unsigned char *out, *outp;
unsigned char c;
int inlen, outlen;
enum {
ST_NORMAL, /* printable text */
@@ -2288,13 +2293,15 @@ PHP_FUNCTION(imap_utf7_decode)
break;
case ST_DECODE1:
outp[1] = UNB64(*inp);
*outp++ |= outp[1] >> 4;
c = outp[1] >> 4;
*outp++ |= c;
*outp <<= 4;
state = ST_DECODE2;
break;
case ST_DECODE2:
outp[1] = UNB64(*inp);
*outp++ |= outp[1] >> 2;
c = outp[1] >> 2;
*outp++ |= c;
*outp <<= 6;
state = ST_DECODE3;
break;
@@ -2328,6 +2335,7 @@ PHP_FUNCTION(imap_utf7_encode)
zval **arg;
const unsigned char *in, *inp, *endp;
unsigned char *out, *outp;
unsigned char c;
int inlen, outlen;
enum {
ST_NORMAL, /* printable text */
@@ -2411,12 +2419,14 @@ PHP_FUNCTION(imap_utf7_encode)
state = ST_ENCODE1;
break;
case ST_ENCODE1:
*outp++ = B64(*outp | *inp >> 4);
c = B64(*outp | *inp >> 4);
*outp++ = c;
*outp = *inp++ << 2;
state = ST_ENCODE2;
break;
case ST_ENCODE2:
*outp++ = B64(*outp | *inp >> 6);
c = B64(*outp | *inp >> 6);
*outp++ = c;
*outp++ = B64(*inp++);
state = ST_ENCODE0;
case ST_NORMAL:
@@ -4080,9 +4090,6 @@ void mm_log(char *str, long errflg)
TSRMLS_FETCH();
/* Author: CJH */
if (!(EG(error_reporting) & E_NOTICE)) {
return;
}
if (errflg != NIL) { /* CJH: maybe put these into a more comprehensive log for debugging purposes? */
if (IMAPG(imap_errorstack) == NIL) {
IMAPG(imap_errorstack) = mail_newerrorlist();
+12 -11
View File
@@ -103,11 +103,11 @@ function_entry ibase_functions[] = {
PHP_FE(ibase_blob_echo, NULL)
PHP_FE(ibase_blob_import, NULL)
PHP_FE(ibase_errmsg, NULL)
#ifdef SQL_DIALECT_V6
PHP_FE(ibase_add_user, NULL)
PHP_FE(ibase_modify_user, NULL)
PHP_FE(ibase_delete_user, NULL)
#endif
{NULL, NULL, NULL}
};
@@ -434,7 +434,7 @@ static void _php_ibase_free_query(ibase_query *ib_query)
}
isc_transaction_info(IB_STATUS, &ib_query->trans,sizeof(tr_items), tr_items, sizeof(tmp), tmp );
/* we have the trans still open and a statement to drop? */
if ( !(IB_STATUS[0] && IB_STATUS[0]) && ib_query->stmt) {
if ( !(IB_STATUS[0] && IB_STATUS[1]) && ib_query->stmt) {
IBDEBUG("Dropping statement handle (free_query)...");
if (isc_dsql_free_statement(IB_STATUS, &ib_query->stmt, DSQL_drop)){
_php_ibase_error();
@@ -465,7 +465,7 @@ static void _php_ibase_free_blob(zend_rsrc_list_entry *rsrc TSRMLS_DC)
if (ib_blob->bl_handle != NULL) { /* blob open*/
if (isc_cancel_blob(IB_STATUS, &ib_blob->bl_handle)) {
_php_ibase_error();
php_error(E_ERROR, "You can lose data. Close any blob after reading of writing it. Use ibase_blob_close() before calling ibase_close()");
}
}
efree(ib_blob);
@@ -2959,7 +2959,7 @@ PHP_FUNCTION(ibase_blob_import)
RETVAL_STRINGL((char *)&ib_blob, sizeof(ibase_blob_handle), 1);
}
/* }}} */
#ifdef SQL_DIALECT_V6
/* {{{ _php_ibase_user() */
static void _php_ibase_user(INTERNAL_FUNCTION_PARAMETERS, int operation)
{
@@ -3114,31 +3114,32 @@ static void _php_ibase_user(INTERNAL_FUNCTION_PARAMETERS, int operation)
RETURN_TRUE;
}
/* }}} */
/* {{{ proto int ibase_add_user(string server, string dba_user_name, string dba_password, string user_name, string password [, string first_name] [, string middle_name] [, string last_name])
Add an user to security database */
Add an user to security database (Ib6 or later) */
PHP_FUNCTION(ibase_add_user)
{
_php_ibase_user(INTERNAL_FUNCTION_PARAM_PASSTHRU, isc_action_svc_add_user);
}
/* }}} */
/* {{{ proto int ibase_modify_user(string server, string dba_user_name, string dba_password, string user_name, string password [, string first_name] [, string middle_name] [, string last_name])
Modify an user in security database */
Modify an user in security database (IB6 or later) */
PHP_FUNCTION(ibase_modify_user)
{
_php_ibase_user(INTERNAL_FUNCTION_PARAM_PASSTHRU, isc_action_svc_modify_user);
}
/* }}} */
/* {{{ proto int ibase_delete_user(string server, string dba_user_name, string dba_password, string username)
Delete an user from security database */
Delete an user from security database (IB6 or later)*/
PHP_FUNCTION(ibase_delete_user)
{
_php_ibase_user(INTERNAL_FUNCTION_PARAM_PASSTHRU, isc_action_svc_delete_user);
}
/* }}} */
#endif /* SQL_DIALECT_V6 */
#endif /* HAVE_IBASE */
+2 -2
View File
@@ -68,11 +68,11 @@ PHP_FUNCTION(ibase_blob_close);
PHP_FUNCTION(ibase_blob_echo);
PHP_FUNCTION(ibase_blob_info);
PHP_FUNCTION(ibase_blob_import);
#ifdef SQL_DIALECT_V6
PHP_FUNCTION(ibase_add_user);
PHP_FUNCTION(ibase_modify_user);
PHP_FUNCTION(ibase_delete_user);
#endif
PHP_FUNCTION(ibase_errmsg);
#define IBASE_MSGSIZE 256
+79 -30
View File
@@ -993,7 +993,7 @@ PHP_FUNCTION(mb_preferred_mime_name)
static void
php_mbstr_encoding_handler(zval *arg, char *res, char *separator TSRMLS_DC)
{
char *var, *val;
char *var, *val, *s1, *s2;
char *strtok_buf = NULL, **val_list;
zval *array_ptr = (zval *) arg;
int n, num, val_len, *len_list, *elist, elistsz;
@@ -1005,19 +1005,23 @@ php_mbstr_encoding_handler(zval *arg, char *res, char *separator TSRMLS_DC)
mbfl_string_init_set(&string, MBSTRG(current_language), MBSTRG(current_internal_encoding));
mbfl_string_init_set(&resvar, MBSTRG(current_language), MBSTRG(current_internal_encoding));
mbfl_string_init_set(&resval, MBSTRG(current_language), MBSTRG(current_internal_encoding));
/* count the variables contained in the query */
num = 0;
var = res;
n = strlen(res);
while(n > 0) {
if (*var == '=') {
num++;
}
var++;
n--;
if (!res || *res == '\0') {
return;
}
num *= 2;
/* count the variables(separators) contained in the "res".
* separator may contain multiple separator chars.
* separaror chars are set in php.ini (arg_separator.input)
*/
num = 1;
for (s1=res; *s1 != '\0'; s1++)
for (s2=separator; *s2 != '\0'; s2++)
if (*s1 == *s2)
num++;
num *= 2; /* need space for variable name and value */
val_list = (char **)ecalloc(num, sizeof(char *));
len_list = (int *)ecalloc(num, sizeof(int));
@@ -1025,28 +1029,24 @@ php_mbstr_encoding_handler(zval *arg, char *res, char *separator TSRMLS_DC)
n = 0;
strtok_buf = NULL;
var = php_strtok_r(res, separator, &strtok_buf);
while (var && n < num) {
while (var) {
val = strchr(var, '=');
val_list[n] = var;
len_list[n] = php_url_decode(var, strlen(var));
n++;
if (val) { /* have a value */
*val++ = '\0';
val_list[n] = var;
len_list[n] = php_url_decode(var, strlen(var));
n++;
val_list[n] = val;
len_list[n] = php_url_decode(val, strlen(val));
} else {
val_list[n] = var;
len_list[n] = php_url_decode(var, strlen(var));
n++;
val_list[n] = NULL;
val_list[n] = "";
len_list[n] = 0;
}
n++;
var = php_strtok_r(NULL, separator, &strtok_buf);
}
num = n;
}
num = n; /* make sure to process initilized vars only */
/* initialize converter */
to_encoding = MBSTRG(current_internal_encoding);
elist = MBSTRG(http_input_list);
@@ -1129,7 +1129,6 @@ php_mbstr_encoding_handler(zval *arg, char *res, char *separator TSRMLS_DC)
}
#if defined(MBSTR_ENC_TRANS)
SAPI_POST_HANDLER_FUNC(php_mbstr_post_handler)
{
MBSTRG(http_input_identify_post) = mbfl_no_encoding_invalid;
@@ -1140,7 +1139,38 @@ SAPI_POST_HANDLER_FUNC(php_mbstr_post_handler)
MBSTRG(http_input_identify_post) = MBSTRG(http_input_identify);
}
}
#endif
#define IS_SJIS1(c) ((((c)>=0x81 && (c)<=0x9f) || ((c)>=0xe0 && (c)<=0xf5)) ? 1 : 0)
#define IS_SJIS2(c) ((((c)>=0x40 && (c)<=0x7e) || ((c)>=0x80 && (c)<=0xfc)) ? 1 : 0)
char *mbstr_strrchr(const char *s, char c TSRMLS_DC){
unsigned char *p = (unsigned char *)s, *last = NULL;
while(*p) {
if (*p == c) {
last = p;
}
if (*p == '\0'){
break;
}
if (MBSTRG(current_language) == mbfl_no_language_japanese
&& IS_SJIS1(*p) && IS_SJIS2(*(p+1))) {
p++;
}
p++;
}
return last;
}
int mbstr_is_mb_leadbyte(const char *s TSRMLS_DC){
unsigned char *p = (unsigned char *)s;
if (MBSTRG(current_language) == mbfl_no_language_japanese
&& IS_SJIS1(*p) && IS_SJIS2(*(p+1))){
return 1;
}
return 0;
}
/* http input processing */
void mbstr_treat_data(int arg, char *str, zval* destArray TSRMLS_DC)
@@ -1454,10 +1484,12 @@ PHP_FUNCTION(mb_output_handler)
size_t arg_string_len;
long arg_status;
mbfl_string string, result;
const char *mimetype, *charset;
const char *charset;
char *p;
enum mbfl_no_encoding encoding;
int last_feed, len;
unsigned char send_text_mimetype = 0;
char *s, *mimetype = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &arg_string, &arg_string_len, &arg_status) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -1475,9 +1507,23 @@ PHP_FUNCTION(mb_output_handler)
if (encoding == mbfl_no_encoding_pass) {
RETURN_STRINGL(arg_string, arg_string_len, 1);
}
/* if content-type is not yet set, set it and activate the converter */
if (SG(sapi_headers).send_default_content_type ) {
/* analyze mime type */
if (SG(sapi_headers).mimetype &&
strncmp(SG(sapi_headers).mimetype, "text/", 5) == 0) {
if ((s = strchr(SG(sapi_headers).mimetype,';')) == NULL){
mimetype = estrdup(SG(sapi_headers).mimetype);
} else {
mimetype = estrndup(SG(sapi_headers).mimetype,s-SG(sapi_headers).mimetype);
}
send_text_mimetype = 1;
} else if (SG(sapi_headers).send_default_content_type) {
mimetype = SG(default_mimetype) ? SG(default_mimetype) : SAPI_DEFAULT_MIMETYPE;
}
/* if content-type is not yet set or text mimetype is set,
set it and activate the converter */
if (SG(sapi_headers).send_default_content_type || send_text_mimetype) {
charset = mbfl_no2preferred_mime_name(encoding);
if (charset) {
len = (sizeof ("Content-Type:")-1) + strlen(mimetype) + (sizeof (";charset=")-1) + strlen(charset) + 1;
@@ -1491,6 +1537,9 @@ PHP_FUNCTION(mb_output_handler)
}
/* activate the converter */
MBSTRG(outconv) = mbfl_buffer_converter_new(MBSTRG(current_internal_encoding), encoding, 0);
if (send_text_mimetype){
efree(mimetype);
}
}
}
+3
View File
@@ -117,6 +117,9 @@ PHP_FUNCTION(mb_ereg_search_setpos);
int php_mbregex_name2mbctype(const char *pname);
#endif
char *mbstr_strrchr(const char *s, char c TSRMLS_DC);
int mbstr_is_mb_leadbyte(const char *s TSRMLS_DC);
ZEND_BEGIN_MODULE_GLOBALS(mbstring)
int language;
int current_language;
+1 -1
View File
@@ -2,7 +2,7 @@
// TODO:
//$debug = true;
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
// EUC-JP
$r = mb_internal_encoding('EUC-JP');
+1 -1
View File
@@ -2,7 +2,7 @@
// TODO: This is not a real test.... Need to change so that it does real testing
//$debug = true;
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
$ini = ini_get('mbstring.http_input');
+1 -1
View File
@@ -2,7 +2,7 @@
//TODO: Add more encoding. Wrong paramter type test.
//$debug = true;
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
// Set HTTP output encoding to ASCII
$r = mb_http_output('ASCII');
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
//$debug = true;
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
// Set order to "auto"
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
//$debug = true;
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
// Note: It does not return TRUE/FALSE for setting char
+1 -1
View File
@@ -3,7 +3,7 @@
//$debug=true;
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
$str = mb_preferred_mime_name('sjis-win');
+1 -1
View File
@@ -3,7 +3,7 @@
//$debug=true;
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
// restore detect_order to 'auto'
mb_detect_order('auto');
+1 -1
View File
@@ -3,7 +3,7 @@
//$debug=true;
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
// Test string
+1 -1
View File
@@ -3,7 +3,7 @@
//$debug=true;
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
// Test string
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
// TODO: Add more encodings
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
// EUC-JP
$euc_jp = '0123この文字列は日本語です。EUC-JPを使っています。日本語は面倒臭い。';
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
// TODO: Add more encodings
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
// EUC-JP
$euc_jp = '0123この文字列は日本語です。EUC-JPを使っています。日本語は面倒臭い。';
+1 -1
View File
@@ -2,7 +2,7 @@
// TODO: Add more encoding
//$debug = true;
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
// EUC-JP
$euc_jp = '0123この文字列は日本語です。EUC-JPを使っています。日本語は面倒臭い。';
+1 -1
View File
@@ -2,7 +2,7 @@
// TODO: Add more tests
//$debug = true; // Uncomment this line to view error/warning/notice message in *.out file
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
// SJIS string (BASE64 encoded)
$sjis = base64_decode('k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==');
+1 -1
View File
@@ -2,7 +2,7 @@
// TODO: Add more tests
//$debug = true; // Uncomment this line to view error/warning/notice message in *.out file
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
// SJIS string (BASE64 encoded)
$sjis = base64_decode('k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==');
+1 -1
View File
@@ -2,7 +2,7 @@
// TODO: Add more tests
//$debug = true; // Uncomment this line to view error/warning/notice message in *.out file
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
// SJIS string (BASE64 encoded)
$sjis = base64_decode('k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==');
+1 -1
View File
@@ -2,7 +2,7 @@
// TODO: Add more encoding, strings.....
//$debug = true;
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
// EUC-JP
$euc_jp = '0123この文字列は日本語です。EUC-JPを使っています。日本語は面倒臭い。';
+1 -1
View File
@@ -3,7 +3,7 @@
//$debug=true;
ini_set('include_path','.');
include_once('common.php');
include_once('common.inc');
// restore detect_order to 'auto'
mb_detect_order('auto');
-53
View File
@@ -1,53 +0,0 @@
<?php
/*
* Common definition and Settings
*/
// Custom Error Hanlder for testing
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
global $debug;
$err_type = array (
1 => "Error", // E_ERROR
2 => "Warning", // E_WARINING
4 => "Parsing Error", // E_PARSE
8 => "Notice", // E_NOTICE
16 => "Core Error", // E_CORE_ERROR
32 => "Core Warning", // E_CORE_WARNING
64 => "Compile Error", // E_COMPILE_ERROR
128 => "Compile Warning", // E_COMPILE_WARNING
256 => "User Error", // E_USER_ERROR
512 => "User Warning", // E_USER_WARMING
1024=> "User Notice" // E_USER_NOTICE
);
if (!empty($debug)) {
printf("%s: %s (%d)\n", $err_type[$err_no], $err_msg, $linenum);
}
else {
printf("ERR: %s\n",$err_type[$err_no]);
}
}
set_error_handler('test_error_handler');
// Var def for testing
$t_ary = array(
's1' => '日本語EUC-JPの文字列',
's2' => 'English Text'
);
class tc
{
var $s1 = '日本語EUC-JPの文字列';
var $s2 = 'English Text';
function tc()
{
}
}
$t_obj = new tc;
?>
+2 -1
View File
@@ -42,7 +42,8 @@ if test "$PHP_MCAL" != "no"; then
fi
PHP_ADD_INCLUDE($MCAL_INCLUDE)
PHP_ADD_LIBRARY_DEFER_WITH_PATH(mcal, $MCAL_LIBRARY, MCAL_SHARED_LIBADD)
PHP_ADD_LIBPATH($MCAL_LIBRARY,MCAL_SHARED_LIBADD)
PHP_ADD_LIBRARY_DEFER(mcal,[],MCAL_SHARED_LIBADD)
PHP_SUBST(MCAL_SHARED_LIBADD)
AC_DEFINE(HAVE_MCAL,1,[ ])
PHP_EXTENSION(mcal,$ext_shared)
+1 -1
View File
@@ -391,7 +391,7 @@ PHP_MINFO_FUNCTION(mcrypt)
php_info_print_table_row(2, "version", "2.2.x");
#endif
#if HAVE_LIBMCRYPT24
php_info_print_table_row(2, "version", "2.4.x");
php_info_print_table_row(2, "version", ">= 2.4.x");
php_info_print_table_row(2, "Supported ciphers", tmp1.c);
php_info_print_table_row(2, "Supported modes", tmp2.c);
smart_str_free (&tmp1);
+22
View File
@@ -215,6 +215,26 @@ ZEND_GET_MODULE(mysql)
void timeout(int sig);
#define CHECK_LINK(link) { if (link==-1) { php_error(E_WARNING, "MySQL: A link to the server could not be established"); RETURN_FALSE; } }
/* {{{ _rollback_mysql_transactions
*/
static int _rollback_mysql_transactions(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
php_mysql_conn *link;
char query[128];
/* check if its a persistent link */
if (Z_TYPE_P(rsrc) != le_plink)
return 0;
link = (php_mysql_conn *) rsrc->ptr;
/* rollback possible transactions */
strcpy (query, "ROLLBACK");
mysql_real_query(&link->conn, query, strlen(query));
return 0;
}
/* }}} */
/* {{{ _free_mysql_result
* This wrapper is required since mysql_free_result() returns an integer, and
@@ -385,6 +405,8 @@ PHP_RINIT_FUNCTION(mysql)
*/
PHP_RSHUTDOWN_FUNCTION(mysql)
{
zend_hash_apply(&EG(persistent_list), (apply_func_t) _rollback_mysql_transactions TSRMLS_CC);
if (MySG(connect_error)!=NULL) {
efree(MySG(connect_error));
}
+30
View File
@@ -211,6 +211,21 @@ static void safe_odbc_disconnect( void *handle )
static void _close_odbc_conn(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
odbc_connection *conn = (odbc_connection *)rsrc->ptr;
int i, nument, type;
void *ptr;
nument = zend_hash_next_free_element(&EG(regular_list));
for(i = 1; i < nument; i++) {
ptr = zend_list_find(i, &type);
if (ptr && (type == le_result)) {
odbc_result *res;
res = (odbc_result *)ptr;
if (res->conn_ptr == conn) {
zend_list_delete(i);
}
}
}
safe_odbc_disconnect(conn->hdbc);
SQLFreeConnect(conn->hdbc);
@@ -223,6 +238,21 @@ static void _close_odbc_conn(zend_rsrc_list_entry *rsrc TSRMLS_DC)
static void _close_odbc_pconn(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
odbc_connection *conn = (odbc_connection *)rsrc->ptr;
int i, nument, type;
void *ptr;
nument = zend_hash_next_free_element(&EG(regular_list));
for(i = 1; i < nument; i++) {
ptr = zend_list_find(i, &type);
if (ptr && (type == le_result)) {
odbc_result *res;
res = (odbc_result *)ptr;
if (res->conn_ptr == conn) {
zend_list_delete(i);
}
}
}
safe_odbc_disconnect(conn->hdbc);
SQLFreeConnect(conn->hdbc);
+1 -2
View File
@@ -39,7 +39,6 @@
#include <openssl/pem.h>
#include <openssl/err.h>
#include <openssl/conf.h>
#include <openssl/e_os.h>
#include <openssl/rand.h>
#define DEFAULT_KEY_LENGTH 512
@@ -577,7 +576,7 @@ PHP_MINIT_FUNCTION(openssl)
if (config_filename == NULL) {
snprintf(default_ssl_conf_filename, sizeof(default_ssl_conf_filename), "%s/%s",
X509_get_default_cert_area(),
OPENSSL_CONF);
"openssl.cnf");
}
else
strncpy(default_ssl_conf_filename, config_filename, sizeof(default_ssl_conf_filename));
+143 -139
View File
@@ -23,7 +23,7 @@
#if PCNTL_DEBUG
#define DEBUG_OUT printf("DEBUG: ");printf
#else
#define DEBUG_OUT
#define DEBUG_OUT
#endif
#ifdef HAVE_CONFIG_H
@@ -32,8 +32,8 @@
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_pcntl.h"
#include "zend_extensions.h"
ZEND_DECLARE_MODULE_GLOBALS(pcntl)
@@ -41,16 +41,16 @@ static int le_pcntl;
static int pcntl_zend_extension_active;
function_entry pcntl_functions[] = {
PHP_FE(pcntl_fork, NULL)
PHP_FE(pcntl_waitpid, second_arg_force_ref)
PHP_FE(pcntl_signal, NULL)
PHP_FE(pcntl_wifexited, NULL)
PHP_FE(pcntl_wifstopped, NULL)
PHP_FE(pcntl_wifsignaled, NULL)
PHP_FE(pcntl_wexitstatus, NULL)
PHP_FE(pcntl_wtermsig, NULL)
PHP_FE(pcntl_wstopsig, NULL)
PHP_FE(pcntl_exec, NULL)
PHP_FE(pcntl_fork, NULL)
PHP_FE(pcntl_waitpid, second_arg_force_ref)
PHP_FE(pcntl_signal, NULL)
PHP_FE(pcntl_wifexited, NULL)
PHP_FE(pcntl_wifstopped, NULL)
PHP_FE(pcntl_wifsignaled, NULL)
PHP_FE(pcntl_wexitstatus, NULL)
PHP_FE(pcntl_wtermsig, NULL)
PHP_FE(pcntl_wstopsig, NULL)
PHP_FE(pcntl_exec, NULL)
{NULL, NULL, NULL}
};
@@ -77,28 +77,27 @@ ZEND_GET_MODULE(pcntl)
PCNTL_ZEND_EXT zend_extension pcntl_extension_entry = {
"pcntl",
"1.0",
"Jason Greene",
"Jason Greene",
"http://www.php.net",
"2001",
pcntl_zend_extension_startup,
pcntl_zend_extension_shutdown,
pcntl_zend_extension_startup,
pcntl_zend_extension_shutdown,
pcntl_zend_extension_activate,
pcntl_zend_extension_deactivate,
NULL,
NULL,
NULL,
NULL,
pcntl_zend_extension_statement_handler,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
void php_register_signal_constants(INIT_FUNC_ARGS)
{
/* Wait Constants */
#ifdef WNOHANG
REGISTER_LONG_CONSTANT("WNOHANG", (long) WNOHANG, CONST_CS | CONST_PERSISTENT);
@@ -117,9 +116,9 @@ void php_register_signal_constants(INIT_FUNC_ARGS)
REGISTER_LONG_CONSTANT("SIGILL", (long) SIGILL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SIGTRAP", (long) SIGTRAP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SIGABRT", (long) SIGABRT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SIGIOT", (long) SIGIOT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SIGBUS", (long) SIGBUS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SIGFPE", (long) SIGFPE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SIGIOT", (long) SIGIOT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SIGBUS", (long) SIGBUS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SIGFPE", (long) SIGFPE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SIGKILL", (long) SIGKILL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SIGUSR1", (long) SIGUSR1, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SIGSEGV", (long) SIGSEGV, CONST_CS | CONST_PERSISTENT);
@@ -158,7 +157,7 @@ void php_register_signal_constants(INIT_FUNC_ARGS)
REGISTER_LONG_CONSTANT("SIGBABY", (long) SIGSYS, CONST_CS | CONST_PERSISTENT);
}
static void php_pcntl_init_globals(zend_pcntl_globals *pcntl_globals)
static void php_pcntl_init_globals(zend_pcntl_globals *pcntl_globals)
{
zend_hash_init(&pcntl_globals->php_signal_table, 16, NULL, NULL, 1);
@@ -166,11 +165,11 @@ static void php_pcntl_init_globals(zend_pcntl_globals *pcntl_globals)
memset(&pcntl_globals->php_signal_queue,0,sizeof(pcntl_globals->php_signal_queue));
zend_llist_init(&pcntl_globals->php_signal_queue, sizeof (long), NULL, 1);
pcntl_globals->signal_queue_ready=0;
pcntl_globals->processing_signal_queue=0;
pcntl_globals->signal_queue_ready = 0;
pcntl_globals->processing_signal_queue = 0;
}
static void php_pcntl_shutdown_globals(zend_pcntl_globals *pcntl_globals)
static void php_pcntl_shutdown_globals(zend_pcntl_globals *pcntl_globals)
{
zend_hash_destroy(&pcntl_globals->php_signal_table);
zend_llist_destroy(&pcntl_globals->php_signal_queue);
@@ -178,16 +177,15 @@ static void php_pcntl_shutdown_globals(zend_pcntl_globals *pcntl_globals)
PHP_MINIT_FUNCTION(pcntl)
{
php_register_signal_constants(INIT_FUNC_ARGS_PASSTHRU);
php_register_signal_constants(INIT_FUNC_ARGS_PASSTHRU);
ZEND_INIT_MODULE_GLOBALS(pcntl, php_pcntl_init_globals, php_pcntl_shutdown_globals);
if (zend_register_extension(&pcntl_extension_entry, 0)==FAILURE)
if (zend_register_extension(&pcntl_extension_entry, 0)==FAILURE)
return FAILURE;
return SUCCESS;
}
PHP_MSHUTDOWN_FUNCTION(pcntl)
{
zend_hash_destroy(&PCNTL_G(php_signal_table));
zend_llist_destroy(&PCNTL_G(php_signal_queue));
return SUCCESS;
@@ -209,7 +207,7 @@ PHP_FUNCTION(pcntl_fork)
{
pid_t id;
id=fork();
id = fork();
if (id == -1) {
php_error(E_ERROR, "Error %d in %s", errno, get_active_function_name(TSRMLS_C));
}
@@ -229,6 +227,8 @@ PHP_FUNCTION(pcntl_waitpid)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz|l", &pid, &z_status, &options) == FAILURE)
return;
convert_to_long_ex(&z_status);
status = Z_LVAL_P(z_status);
@@ -247,14 +247,14 @@ PHP_FUNCTION(pcntl_wifexited)
#ifdef WIFEXITED
zval **status;
int status_word;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ZEND_NUM_ARGS(), &status) == FAILURE){
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ZEND_NUM_ARGS(), &status) == FAILURE) {
WRONG_PARAM_COUNT;
}
status_word = (int) Z_LVAL_PP(status);
if (WIFEXITED(status_word)) RETURN_TRUE;
if (WIFEXITED(status_word)) RETURN_TRUE;
#endif
RETURN_FALSE;
}
@@ -267,14 +267,14 @@ PHP_FUNCTION(pcntl_wifstopped)
#ifdef WIFSTOPPED
zval **status;
int status_word;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ZEND_NUM_ARGS(), &status) == FAILURE){
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ZEND_NUM_ARGS(), &status) == FAILURE) {
WRONG_PARAM_COUNT;
}
status_word = (int) Z_LVAL_PP(status);
if (WIFSTOPPED(status_word)) RETURN_TRUE;
if (WIFSTOPPED(status_word)) RETURN_TRUE;
#endif
RETURN_FALSE;
}
@@ -287,14 +287,14 @@ PHP_FUNCTION(pcntl_wifsignaled)
#ifdef WIFSIGNALED
zval **status;
int status_word;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ZEND_NUM_ARGS(), &status) == FAILURE){
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ZEND_NUM_ARGS(), &status) == FAILURE) {
WRONG_PARAM_COUNT;
}
status_word = (int) Z_LVAL_PP(status);
if (WIFSIGNALED(status_word)) RETURN_TRUE;
if (WIFSIGNALED(status_word)) RETURN_TRUE;
#endif
RETURN_FALSE;
}
@@ -307,16 +307,16 @@ PHP_FUNCTION(pcntl_wexitstatus)
#ifdef WEXITSTATUS
zval **status;
int status_word;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ZEND_NUM_ARGS(), &status) == FAILURE){
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ZEND_NUM_ARGS(), &status) == FAILURE) {
WRONG_PARAM_COUNT;
}
status_word = (int) Z_LVAL_PP(status);
/* WEXITSTATUS only returns 8 bits so we *MUST* cast this to signed char
if you want to have valid negative exit codes */
RETURN_LONG((signed char) WEXITSTATUS(status_word));
RETURN_LONG((signed char) WEXITSTATUS(status_word));
#else
RETURN_FALSE;
#endif
@@ -330,14 +330,14 @@ PHP_FUNCTION(pcntl_wtermsig)
#ifdef WTERMSIG
zval **status;
int status_word;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ZEND_NUM_ARGS(), &status) == FAILURE){
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ZEND_NUM_ARGS(), &status) == FAILURE) {
WRONG_PARAM_COUNT;
}
status_word = (int) Z_LVAL_PP(status);
RETURN_LONG(WTERMSIG(status_word));
RETURN_LONG(WTERMSIG(status_word));
#else
RETURN_FALSE;
#endif
@@ -352,7 +352,7 @@ PHP_FUNCTION(pcntl_wstopsig)
zval **status;
int status_word;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ZEND_NUM_ARGS(), &status) == FAILURE){
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ZEND_NUM_ARGS(), &status) == FAILURE) {
WRONG_PARAM_COUNT;
}
@@ -372,85 +372,91 @@ PHP_FUNCTION(pcntl_exec)
zval *args, *envs;
zval **element;
HashTable *args_hash, *envs_hash;
int argc=0, argi=0;
int envc=0, envi=0;
int return_val=0;
char **argv=NULL, **envp=NULL;
char **current_arg, **pair;
int argc = 0, argi = 0;
int envc = 0, envi = 0;
int return_val = 0;
char **argv = NULL, **envp = NULL;
char **current_arg, **pair;
int pair_length;
char *key;
char *key;
int key_length;
char *path;
int path_len;
long key_num;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|aa", &path, &path_len, &args, &envs) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|aa", &path, &path_len, &args, &envs) == FAILURE) {
return;
}
if (ZEND_NUM_ARGS() > 1) {
if (ZEND_NUM_ARGS() > 1) {
/* Build argumnent list */
args_hash=HASH_OF(args);
argc=zend_hash_num_elements(args_hash);
argv=alloca((argc+2) * sizeof(char *));
*argv=path;
for ( zend_hash_internal_pointer_reset(args_hash), current_arg=argv+1;
(argi < argc && (zend_hash_get_current_data(args_hash, (void **) &element) == SUCCESS));
(argi++, current_arg++, zend_hash_move_forward(args_hash)) ) {
*current_arg=Z_STRVAL_PP(element);
args_hash = HASH_OF(args);
argc = zend_hash_num_elements(args_hash);
argv = alloca((argc+2) * sizeof(char *));
*argv = path;
for ( zend_hash_internal_pointer_reset(args_hash), current_arg = argv+1;
(argi < argc && (zend_hash_get_current_data(args_hash, (void **) &element) == SUCCESS));
(argi++, current_arg++, zend_hash_move_forward(args_hash)) ) {
convert_to_string_ex(element);
*current_arg = Z_STRVAL_PP(element);
}
*(current_arg)=NULL;
*(current_arg) = NULL;
} else {
argv=alloca(2 * sizeof(char *));
*argv=path;
*(argv+1)=NULL;
argv = alloca(2 * sizeof(char *));
*argv = path;
*(argv+1) = NULL;
}
if ( ZEND_NUM_ARGS() == 3 ) {
if ( ZEND_NUM_ARGS() == 3 ) {
/* Build environment pair list */
envs_hash=HASH_OF(envs);
envc=zend_hash_num_elements(envs_hash);
envp=alloca((envc+1) * sizeof(char *));
for ( zend_hash_internal_pointer_reset(envs_hash), pair=envp;
(envi < envc && (zend_hash_get_current_data(envs_hash, (void **) &element) == SUCCESS));
(envi++, pair++, zend_hash_move_forward(envs_hash)) ) {
switch (return_val=zend_hash_get_current_key_ex(envs_hash, &key, &key_length, &key_num, 0, NULL)) {
envs_hash = HASH_OF(envs);
envc = zend_hash_num_elements(envs_hash);
envp = alloca((envc+1) * sizeof(char *));
for ( zend_hash_internal_pointer_reset(envs_hash), pair = envp;
(envi < envc && (zend_hash_get_current_data(envs_hash, (void **) &element) == SUCCESS));
(envi++, pair++, zend_hash_move_forward(envs_hash)) ) {
switch (return_val = zend_hash_get_current_key_ex(envs_hash, &key, &key_length, &key_num, 0, NULL)) {
case HASH_KEY_IS_LONG:
key=alloca(101);
key = alloca(101);
snprintf(key, 100, "%ld", key_num);
key_length=strlen(key);
break;
key_length = strlen(key);
break;
case HASH_KEY_NON_EXISTANT:
pair--;
continue;
}
convert_to_string_ex(element);
/* Length of element + equal sign + length of key + null */
pair_length=Z_STRLEN_PP(element) + key_length + 2;
*pair=emalloc(pair_length);
strlcpy(*pair, key, key_length);
pair_length = Z_STRLEN_PP(element) + key_length + 2;
*pair = emalloc(pair_length);
strlcpy(*pair, key, key_length);
strlcat(*pair, "=", pair_length);
strlcat(*pair, Z_STRVAL_PP(element), pair_length);
/* Cleanup */
if (return_val == HASH_KEY_IS_LONG) free_alloca(key);
}
*(pair)=NULL;
*(pair) = NULL;
}
if (execve(path, argv, envp) == -1) {
php_error(E_WARNING, "Error has occured in %s: (errno %d) %s", get_active_function_name(TSRMLS_CC),
errno, strerror(errno));
php_error(E_WARNING, "Error has occured in %s: (errno %d) %s",
get_active_function_name(TSRMLS_C), errno, strerror(errno));
}
/* Cleanup */
for (pair=envp; *pair!=NULL; pair++) efree(*pair);
if (envp != NULL) {
for (pair = envp; *pair != NULL; pair++) efree(*pair);
free_alloca(envp);
}
free_alloca(argv);
free_alloca(envp);
RETURN_FALSE;
}
/* }}} */
@@ -460,7 +466,7 @@ PHP_FUNCTION(pcntl_exec)
PHP_FUNCTION(pcntl_signal)
{
zval **signo, **handle;
char *func_name;
char *func_name;
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &signo, &handle) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -470,17 +476,17 @@ PHP_FUNCTION(pcntl_signal)
/* Special long value case for SIG_DFL and SIG_IGN */
if (Z_TYPE_PP(handle)==IS_LONG) {
if (Z_LVAL_PP(handle)!= (long) SIG_DFL && Z_LVAL_PP(handle) != (long) SIG_IGN) {
php_error(E_WARNING, "Invalid value for handle argument specifEied in %s", get_active_function_name(TSRMLS_C));
if (Z_LVAL_PP(handle)!= (long) SIG_DFL && Z_LVAL_PP(handle) != (long) SIG_IGN) {
php_error(E_WARNING, "Invalid value for handle argument specifEied in %s", get_active_function_name(TSRMLS_C));
}
if (php_signal(Z_LVAL_PP(signo), (Sigfunc *) Z_LVAL_PP(handle))==SIG_ERR) {
php_error(E_WARNING, "Error assigning singal in %s", get_active_function_name(TSRMLS_C));
RETURN_FALSE;
RETURN_FALSE;
}
RETURN_TRUE;
}
}
if (Z_TYPE_PP(handle)!=IS_STRING) {
if (Z_TYPE_PP(handle) != IS_STRING) {
php_error(E_WARNING, "Invalid type specified for handle argument in %s", get_active_function_name(TSRMLS_C));
RETURN_FALSE;
}
@@ -488,19 +494,19 @@ PHP_FUNCTION(pcntl_signal)
convert_to_string_ex(handle); /* Just in case */
if (!zend_is_callable(*handle, 0, &func_name)) {
php_error(E_WARNING, "%s: %s is not a callable function name error", get_active_function_name(TSRMLS_C), func_name);
efree(func_name);
efree(func_name);
RETURN_FALSE;
}
efree(func_name);
efree(func_name);
/* Add the function name to our signal table */
zend_hash_index_update(&PCNTL_G(php_signal_table), Z_LVAL_PP(signo), Z_STRVAL_PP(handle), (Z_STRLEN_PP(handle) + 1) * sizeof(char), NULL);
if (php_signal(Z_LVAL_PP(signo), pcntl_signal_handler)==SIG_ERR) {
php_error(E_WARNING, "Error assigning singal in %s", get_active_function_name(TSRMLS_C));
RETURN_FALSE;
php_error(E_WARNING, "Error assigning singal in %s", get_active_function_name(TSRMLS_C));
RETURN_FALSE;
}
RETURN_TRUE;
RETURN_TRUE;
}
/* }}} */
@@ -516,19 +522,19 @@ static void old_pcntl_signal_handler(int signo)
DEBUG_OUT("Signl handler not fount");
return;
}
/* DEBUG_OUT("Signal handler found, Calling %s\n", func_name); */
/* DEBUG_OUT("Signal handler found, Calling %s\n", func_name); */
MAKE_STD_ZVAL(param);
MAKE_STD_ZVAL(call_name);
MAKE_STD_ZVAL(retval);
ZVAL_LONG(param, signo);
ZVAL_STRING(call_name, func_name, 1);
ZVAL_STRING(call_name, func_name, 1);
/* Call php singal handler - Note that we do not report errors, and we ignore the return value */
call_user_function(EG(function_table), NULL, call_name, retval, 1, &param TSRMLS_CC);
zval_dtor(call_name);
zval_dtor(call_name);
efree(call_name);
efree(param);
efree(param);
efree(retval);
return;
@@ -537,27 +543,26 @@ static void old_pcntl_signal_handler(int signo)
/* Our custom signal handler that calls the appropriate php_function */
static void pcntl_signal_handler(int signo)
{
long signal_num=signo;
long signal_num = signo;
TSRMLS_FETCH();
DEBUG_OUT("Caught signo %d\n", signo);
if (! PCNTL_G(processing_signal_queue) && pcntl_zend_extension_active ) {
zend_llist_add_element(&PCNTL_G(php_signal_queue), &signal_num);
PCNTL_G(signal_queue_ready)=1;
PCNTL_G(signal_queue_ready) = 1;
DEBUG_OUT("Added queue entry\n");
}
return;
}
/* Pcntl Zend Extension Hooks */
int pcntl_zend_extension_startup(zend_extension *extension)
{
TSRMLS_FETCH();
DEBUG_OUT("Statup Called\n");
pcntl_zend_extension_active=1;
pcntl_zend_extension_active = 1;
CG(extended_info) = 1;
return SUCCESS;
}
@@ -571,9 +576,9 @@ void pcntl_zend_extension_shutdown(zend_extension *extension)
void pcntl_zend_extension_activate(void)
{
TSRMLS_FETCH();
DEBUG_OUT("Activate Called\n");
pcntl_zend_extension_active=1;
pcntl_zend_extension_active = 1;
CG(extended_info) = 1;
return;
}
@@ -581,7 +586,7 @@ void pcntl_zend_extension_activate(void)
void pcntl_zend_extension_deactivate(void)
{
DEBUG_OUT("Deactivate Called\n");
pcntl_zend_extension_active=0;
pcntl_zend_extension_active = 0;
return;
}
@@ -597,33 +602,32 @@ void pcntl_zend_extension_statement_handler(zend_op_array *op_array)
if (! PCNTL_G(signal_queue_ready) || PCNTL_G(processing_signal_queue))
return;
/* Mark our queue empty */
PCNTL_G(signal_queue_ready)=0;
/* Mark our queue empty */
PCNTL_G(signal_queue_ready) = 0;
/* If for some reason our signal queue is empty then return */
if (zend_llist_count(&PCNTL_G(php_signal_queue)) <= 0) {
return;
}
/* Disable queue so this function is not infinate */
PCNTL_G(processing_signal_queue)=1;
PCNTL_G(processing_signal_queue) = 1;
/* Allocate */
MAKE_STD_ZVAL(param);
MAKE_STD_ZVAL(call_name);
MAKE_STD_ZVAL(retval);
/* Traverse through our signal queue and call the appropriate php functions */
for (element=(&PCNTL_G(php_signal_queue))->head; element; element=element->next) {
long *signal_num=(long *)&element->data;
for (element = (&PCNTL_G(php_signal_queue))->head; element; element = element->next) {
long *signal_num = (long *)&element->data;
if (zend_hash_index_find(&PCNTL_G(php_signal_table), *signal_num, (void *) &func_name)==FAILURE) {
continue;
}
convert_to_long_ex(&param);
convert_to_string_ex(&call_name);
ZVAL_LONG(param, *signal_num);
ZVAL_STRING(call_name, func_name, 0);
/* Call php singal handler - Note that we do not report errors, and we ignore the return value */
call_user_function(EG(function_table), NULL, call_name, retval, 1, &param TSRMLS_CC);
}
@@ -631,7 +635,7 @@ void pcntl_zend_extension_statement_handler(zend_op_array *op_array)
zend_llist_clean(&PCNTL_G(php_signal_queue));
/* Re-enable queue */
PCNTL_G(processing_signal_queue)=0;
PCNTL_G(processing_signal_queue) = 0;
/* Clean up */
efree(param);
+1
View File
@@ -25,6 +25,7 @@ if test "$PHP_PCRE_REGEX" != "no"; then
else
test -f $PHP_PCRE_REGEX/pcre.h && PCRE_INCDIR=$PHP_PCRE_REGEX
test -f $PHP_PCRE_REGEX/include/pcre.h && PCRE_INCDIR=$PHP_PCRE_REGEX/include
test -f $PHP_PCRE_REGEX/include/pcre/pcre.h && PCRE_INCDIR=$PHP_PCRE_REGEX/include/pcre
if test -z "$PCRE_INCDIR"; then
AC_MSG_RESULT(Could not find pcre.h in $PHP_PCRE_REGEX)
+1 -1
View File
@@ -27,7 +27,7 @@ if test "$PHP_PGSQL" != "no"; then
done
for j in lib lib/pgsql lib/postgres lib/postgresql ""; do
if test -f "$i/$j/libpq.so"; then
if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then
PGSQL_LIBDIR=$i/$j
fi
done
+19 -10
View File
@@ -1765,12 +1765,14 @@ PHP_FUNCTION(pg_lo_close)
}
/* }}} */
#define PGSQL_LO_READ_BUF_SIZE 8192
/* {{{ proto string pg_lo_read(resource large_object [, int len])
Read a large object */
PHP_FUNCTION(pg_lo_read)
{
zval **pgsql_id, **len;
int buf_len = 1024, nbytes;
int buf_len = PGSQL_LO_READ_BUF_SIZE, nbytes;
char *buf;
pgLofp *pgsql;
@@ -1816,6 +1818,16 @@ PHP_FUNCTION(pg_lo_write)
if (argc > 2) {
convert_to_long_ex(z_len);
if (Z_LVAL_PP(z_len) > Z_STRLEN_PP(str)) {
php_error(E_WARNING, "%s() cannot write more than buffer size %d. Tried to wtite %d",
get_active_function_name(TSRMLS_C), Z_LVAL_PP(str), Z_LVAL_PP(z_len));
RETURN_FALSE;
}
if (Z_LVAL_PP(z_len) < 0) {
php_error(E_WARNING, "%s() buffer size must be larger than 0. %d specified for buffer size.",
get_active_function_name(TSRMLS_C), Z_LVAL_PP(str), Z_LVAL_PP(z_len));
RETURN_FALSE;
}
len = Z_LVAL_PP(z_len);
}
else {
@@ -1837,11 +1849,10 @@ PHP_FUNCTION(pg_lo_write)
PHP_FUNCTION(pg_lo_read_all)
{
zval **pgsql_id;
int i, tbytes;
int tbytes;
volatile int nbytes;
char buf[8192];
char buf[PGSQL_LO_READ_BUF_SIZE];
pgLofp *pgsql;
int output=1;
switch(ZEND_NUM_ARGS()) {
case 1:
@@ -1857,11 +1868,9 @@ PHP_FUNCTION(pg_lo_read_all)
ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_id, -1, "PostgreSQL large object", le_lofp);
tbytes = 0;
while ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, buf, 8192))>0) {
for(i=0; i<nbytes; i++) {
if (output) { (void) PUTC(buf[i]); }
}
tbytes += i;
while ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, buf, PGSQL_LO_READ_BUF_SIZE))>0) {
php_body_write(buf, nbytes TSRMLS_CC);
tbytes += nbytes;
}
RETURN_LONG(tbytes);
}
@@ -1888,7 +1897,7 @@ PHP_FUNCTION(pg_lo_import)
CHECK_DEFAULT_LINK(id);
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC,
"rs", &pgsql_link, &file_in, &name_len) == SUCCESS) {
"sr", &file_in, &name_len, &pgsql_link) == SUCCESS) {
php_error(E_NOTICE, "Old API for %s() is used.", get_active_function_name(TSRMLS_C));
}
else {
+4 -4
View File
@@ -45,7 +45,7 @@ RSC=rc.exe
# 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 "PGSQL_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "D:\Projects\php_build\postgresql\src\interfaces\libpq" /I "..\..\..\php_build\PostgreSQL\src\include" /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\php_build\postgresql\src\interfaces\libpq" /I "..\..\..\bindlib_w32" /D "NDEBUG" /D "PGSQL_EXPORTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZEND_WIN32" /D "PHP_WIN32" /D "COMPILE_DL_PGSQL" /D HAVE_PGSQL=1 /D ZEND_DEBUG=0 /D "HAVE_PQCMDTUPLES" /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "D:\Projects\php_build\postgresql\src\interfaces\libpq" /I "..\..\..\php_build\PostgreSQL\src\include" /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\php_build\postgresql\src\interfaces\libpq" /I "..\..\..\bindlib_w32" /D "NDEBUG" /D ZEND_DEBUG=0 /D "PGSQL_EXPORTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZEND_WIN32" /D "PHP_WIN32" /D "COMPILE_DL_PGSQL" /D HAVE_PGSQL=1 /D "HAVE_PQCMDTUPLES" /D "HAVE_PQCLIENTENCODING" /D "HAVE_PQESCAPE" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@@ -72,7 +72,7 @@ LINK32=link.exe
# 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 "PGSQL_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "D:\Projects\php_build\postgresql\src\interfaces\libpq" /I "..\..\..\php_build\PostgreSQL\src\include" /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\php_build\postgresql\src\interfaces\libpq" /I "..\..\..\bindlib_w32" /D "_DEBUG" /D "PGSQL_EXPORTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZEND_WIN32" /D "PHP_WIN32" /D "COMPILE_DL_PGSQL" /D HAVE_PGSQL=1 /D ZEND_DEBUG=1 /D "HAVE_PQCMDTUPLES" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "D:\Projects\php_build\postgresql\src\interfaces\libpq" /I "..\..\..\php_build\PostgreSQL\src\include" /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\php_build\postgresql\src\interfaces\libpq" /I "..\..\..\bindlib_w32" /D "_DEBUG" /D ZEND_DEBUG=1 /D "PGSQL_EXPORTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZEND_WIN32" /D "PHP_WIN32" /D "COMPILE_DL_PGSQL" /D HAVE_PGSQL=1 /D "HAVE_PQCMDTUPLES" /D "HAVE_PQCLIENTENCODING" /D "HAVE_PQESCAPE" /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"
@@ -100,7 +100,7 @@ LINK32=link.exe
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\..\PostgreSQL\include" /I "..\..\..\bindlib_w32" /D "NDEBUG" /D "ZTS" /D "PGSQL_EXPORTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZEND_WIN32" /D "PHP_WIN32" /D "COMPILE_DL_PGSQL" /D HAVE_PGSQL=1 /D ZTS=1 /FD /c
# SUBTRACT BASE CPP /YX
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\php_build\postgresql\src\interfaces\libpq" /I "..\..\..\php_build\PostgreSQL\src\include" /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "NDEBUG" /D "ZTS" /D "PGSQL_EXPORTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZEND_WIN32" /D "PHP_WIN32" /D "COMPILE_DL_PGSQL" /D HAVE_PGSQL=1 /D ZEND_DEBUG=0 /D "HAVE_PQCMDTUPLES" /FR /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\php_build\postgresql\src\interfaces\libpq" /I "..\..\..\php_build\PostgreSQL\src\include" /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "NDEBUG" /D "ZTS" /D ZEND_DEBUG=0 /D "PGSQL_EXPORTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZEND_WIN32" /D "PHP_WIN32" /D "COMPILE_DL_PGSQL" /D HAVE_PGSQL=1 /D "HAVE_PQCMDTUPLES" /D "HAVE_PQCLIENTENCODING" /D "HAVE_PQESCAPE" /FR /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@@ -127,7 +127,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "PGSQL_EXPORTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZEND_WIN32" /D "PHP_WIN32" /D "COMPILE_DL_PGSQL" /D HAVE_PGSQL=1 /D ZTS=1 /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "D:\Projects\php_build\postgresql\src\interfaces\libpq" /I "..\..\..\php_build\PostgreSQL\src\include" /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\php_build\postgresql\src\interfaces\libpq" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "_DEBUG" /D "PGSQL_EXPORTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZEND_WIN32" /D "PHP_WIN32" /D "COMPILE_DL_PGSQL" /D HAVE_PGSQL=1 /D "ZTS" /D ZEND_DEBUG=1 /D "HAVE_PQCMDTUPLES" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "D:\Projects\php_build\postgresql\src\interfaces\libpq" /I "..\..\..\php_build\PostgreSQL\src\include" /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\php_build\postgresql\src\interfaces\libpq" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "_DEBUG" /D "ZTS" /D ZEND_DEBUG=1 /D "PGSQL_EXPORTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZEND_WIN32" /D "PHP_WIN32" /D "COMPILE_DL_PGSQL" /D HAVE_PGSQL=1 /D "HAVE_PQCMDTUPLES" /D "HAVE_PQCLIENTENCODING" /D "HAVE_PQESCAPE" /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"
+10 -6
View File
@@ -585,13 +585,15 @@ PHP_FUNCTION(posix_ctermid)
Determine terminal device name (POSIX.1, 4.7.2) */
PHP_FUNCTION(posix_ttyname)
{
long fd;
zval *z_fd;
char *p;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &fd) == FAILURE)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &z_fd) == FAILURE)
return;
if (NULL == (p = ttyname(fd))) {
convert_to_long(z_fd);
if (NULL == (p = ttyname(Z_LVAL_P(z_fd)))) {
POSIX_G(last_error) = errno;
RETURN_FALSE;
}
@@ -604,13 +606,15 @@ PHP_FUNCTION(posix_ttyname)
Determine if filedesc is a tty (POSIX.1, 4.7.1) */
PHP_FUNCTION(posix_isatty)
{
long fd;
zval *z_fd;
int result;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &fd) == FAILURE)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &z_fd) == FAILURE)
return;
result = isatty(fd);
convert_to_long(z_fd);
result = isatty(Z_LVAL_P(z_fd));
if (!result)
RETURN_FALSE;
+1 -1
View File
@@ -68,7 +68,7 @@ if test "$PHP_LIBEDIT" != "no"; then
AC_CHECK_LIB(ncurses, tgetent,
[
PHP_ADD_LIBRARY_WITH_PATH(ncurses,,READLINE__SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(ncurses,,READLINE_SHARED_LIBADD)
],[
AC_CHECK_LIB(termcap, tgetent,
[
+1 -1
View File
@@ -1,2 +1,2 @@
Win32 COM
Zeev Suraski, Harald Radi, Alan Brown
Alan Brown, Wez Furlong, Harald Radi, Zeev Suraski
+542 -53
View File
@@ -15,9 +15,10 @@
| Author: Zeev Suraski <zeev@zend.com> |
| Harald Radi <h.radi@nme.at> |
| Alan Brown <abrown@pobox.com> |
| Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
/*
* This module implements support for COM components that support the IDispatch
* interface. Both local (COM) and remote (DCOM) components can be accessed.
@@ -57,6 +58,7 @@
#include <iostream.h>
#include <math.h>
#include <ocidl.h>
#include "php.h"
#include "php_ini.h"
@@ -65,11 +67,12 @@
#include "php_VARIANT.h"
static ITypeLib *php_COM_find_typelib(char *search_string, int mode TSRMLS_DC);
static int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC);
static int do_COM_offget(VARIANT *result, comval *array, pval *property, int cleanup TSRMLS_DC);
static int do_COM_propget(VARIANT *var_result, comval *obj, pval *arg_property, int cleanup TSRMLS_DC);
static void php_register_COM_class(TSRMLS_D);
static void php_COM_init(int module_number TSRMLS_DC);
static char *php_string_from_clsid(const CLSID *clsid TSRMLS_DC);
static int com_enable_events(comval *obj, int enable);
static int le_comval;
static int codepage;
@@ -78,6 +81,9 @@ static int codepage;
int resourcecounter = 1;
#endif
static unsigned char arg1and2_force_ref[] =
{ 2, BYREF_FORCE, BYREF_FORCE };
function_entry COM_functions[] = {
PHP_FE(com_load, NULL)
PHP_FE(com_invoke, NULL)
@@ -87,6 +93,9 @@ function_entry COM_functions[] = {
PHP_FE(com_propput, NULL)
PHP_FE(com_load_typelib, NULL)
PHP_FE(com_isenum, NULL)
PHP_FE(com_event_sink, arg1and2_force_ref)
PHP_FE(com_message_pump, NULL)
PHP_FE(com_print_typeinfo, NULL)
PHP_FALIAS(com_get, com_propget, NULL)
PHP_FALIAS(com_propset, com_propput, NULL)
@@ -261,7 +270,7 @@ PHPAPI HRESULT php_COM_set(comval *obj, IDispatch FAR* FAR* ppDisp, int cleanup
C_REFCOUNT(obj) = 1;
C_DISPATCH(obj) = pDisp;
C_HASTLIB(obj) = SUCCEEDED(C_DISPATCH_VT(obj)->GetTypeInfo(C_DISPATCH(obj), 0, LANG_NEUTRAL, &C_TYPEINFO(obj)));
dispparams.rgvarg = NULL;
dispparams.rgdispidNamedArgs = NULL;
dispparams.cArgs = 0;
@@ -272,9 +281,11 @@ PHPAPI HRESULT php_COM_set(comval *obj, IDispatch FAR* FAR* ppDisp, int cleanup
if (C_HASENUM(obj) = SUCCEEDED(C_DISPATCH_VT(obj)->Invoke(C_DISPATCH(obj), DISPID_NEWENUM, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
DISPATCH_METHOD|DISPATCH_PROPERTYGET, &dispparams, var_result, NULL, NULL))) {
if (V_VT(var_result) == VT_UNKNOWN) {
V_UNKNOWN(var_result)->lpVtbl->AddRef(V_UNKNOWN(var_result));
C_HASENUM(obj) = SUCCEEDED(V_UNKNOWN(var_result)->lpVtbl->QueryInterface(V_UNKNOWN(var_result), &IID_IEnumVARIANT,
(void**)&C_ENUMVARIANT(obj)));
} else if (V_VT(var_result) == VT_DISPATCH) {
V_DISPATCH(var_result)->lpVtbl->AddRef(V_DISPATCH(var_result));
C_HASENUM(obj) = SUCCEEDED(V_DISPATCH(var_result)->lpVtbl->QueryInterface(V_DISPATCH(var_result), &IID_IEnumVARIANT,
(void**)&C_ENUMVARIANT(obj)));
}
@@ -358,6 +369,10 @@ PHPAPI HRESULT php_COM_destruct(comval *obj TSRMLS_DC)
{
HRESULT hr = S_OK;
com_enable_events(obj, FALSE);
if (obj->sinkdispatch)
obj->sinkdispatch->lpVtbl->Release(obj->sinkdispatch);
if (C_ISREFD(obj)) {
C_REFCOUNT(obj) = 1;
hr = php_COM_release(obj TSRMLS_CC);
@@ -507,40 +522,34 @@ PHP_FUNCTION(com_load)
server_name = NULL;
} else if (Z_TYPE_P(server_name) == IS_ARRAY) {
pval **tmp;
/* DAB: 22 Sept 2001 */
/* Aha - we have a number of possible */
/* arguments. They are in the hash */
/* By name: Server, Domain, Username, Password */
/* Flags. */
/* This has been crafted to maintian maximum backward */
/* compatability, If the server name is specified as a */
/* string, then the function shoule behave as before */
/* by defaulting username and password and using the */
/* (I believe) incorrect CLSCTX_SERVER instantiation */
/* paramter. However if server is specified in this array */
/* then we use either CLSCTX_REMOTE_SERVER or whatever */
/* flags are specified in the array */
/* DAB: 22 Sept 2001
* Aha - we have a number of possible arguments.
* They are in the hash By name: Server, Domain, Username, Password
* Flags.
* This has been crafted to maintian maximum backward compatability.
* If the server name is specified as a string, then the function
* should behave as before by defaulting username and password and
* using the (I believe) incorrect CLSCTX_SERVER instantiation
* paramter. However if server is specified in this array then we
* use either CLSCTX_REMOTE_SERVER or whatever flags are specified
* in the array */
HashTable *ht = Z_ARRVAL(*server_name);
if (FAILURE == zend_hash_find(ht, "Server", 7, (void **) &tmp)) {
server_name = NULL;
} else {
server_name = *tmp;
convert_to_string_ex(&server_name);
/* CLSCTX_SERVER includes INPROC and LOCAL */
/* SERVER. This means that any local server */
/* will be instantiated BEFORE even looking */
/* on a remote server. Thus if we have a */
/* server name, probably we want to access */
/* a remote machine or we would not have */
/* bothered specifying it. So it would be */
/* wrong to to connect locally. Futher, */
/* unless the name passed is a GUID, there has */
/* to be something to map the Prog.Id to GUID */
/* and unless that has been modified to remove */
/* the information about local instantiation */
/* CLSCTX_SERVER would force a local instantiation */
/* This setting can be overridden below if the user */
/* specifies a flags element */
/* CLSCTX_SERVER includes INPROC and LOCAL SERVER. This means
* that any local server will be instantiated BEFORE even
* looking on a remote server. Thus if we have a server name,
* probably we want to access a remote machine or we would not
* have bothered specifying it. So it would be wrong to to
* connect locally. Futher, unless the name passed is a GUID,
* there has to be something to map the Prog.Id to GUID and
* unless that has been modified to remove the information
* about local instantiation CLSCTX_SERVER would force a local
* instantiation This setting can be overridden below if the
* user specifies a flags element */
flags = CLSCTX_REMOTE_SERVER;
}
if (FAILURE == zend_hash_find(ht, "Username", 9, (void **) &tmp)) {
@@ -709,7 +718,7 @@ PHP_FUNCTION(com_load)
}
}
RETURN_LONG(zend_list_insert(obj, IS_COM));
RETURN_RESOURCE(zend_list_insert(obj, IS_COM));
}
/* }}} */
@@ -1004,6 +1013,461 @@ PHP_FUNCTION(com_addref)
}
/* }}} */
/* {{{ proto bool com_message_pump([int timeoutms])
Process COM messages, sleeping for up to timeoutms milliseconds */
PHP_FUNCTION(com_message_pump)
{
long timeoutms = 0;
MSG msg;
DWORD result;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &timeoutms) == FAILURE)
RETURN_FALSE;
result = MsgWaitForMultipleObjects(0, NULL, FALSE, timeoutms, QS_ALLINPUT);
if (result == WAIT_OBJECT_0) {
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
/* we processed messages */
RETVAL_TRUE;
} else {
/* we did not process messages (timed out) */
RETVAL_FALSE;
}
}
/* }}} */
static int com_enable_events(comval *obj, int enable)
{
if (obj->sinkdispatch) {
IConnectionPointContainer *cont;
IConnectionPoint *point;
if (SUCCEEDED(C_DISPATCH_VT(obj)->QueryInterface(C_DISPATCH(obj), &IID_IConnectionPointContainer, (void**)&cont))) {
if (SUCCEEDED(cont->lpVtbl->FindConnectionPoint(cont, &obj->sinkid, &point))) {
if (enable) {
point->lpVtbl->Advise(point, (IUnknown*)obj->sinkdispatch, &obj->sinkcookie);
} else {
point->lpVtbl->Unadvise(point, obj->sinkcookie);
}
point->lpVtbl->Release(point);
}
cont->lpVtbl->Release(cont);
}
}
return 0;
}
static const struct {
VARTYPE vt;
const char *name;
} vt_names[] = {
{ VT_NULL, "VT_NULL" },
{ VT_EMPTY, "VT_EMPTY" },
{ VT_UI1, "VT_UI1" },
{ VT_I2, "VT_I2" },
{ VT_I4, "VT_I4" },
{ VT_R4, "VT_R4" },
{ VT_R8, "VT_R8" },
{ VT_BOOL, "VT_BOOL" },
{ VT_ERROR, "VT_ERROR" },
{ VT_CY, "VT_CY" },
{ VT_DATE, "VT_DATE" },
{ VT_BSTR, "VT_BSTR" },
{ VT_DECIMAL, "VT_DECIMAL" },
{ VT_UNKNOWN, "VT_UNKNOWN" },
{ VT_DISPATCH, "VT_DISPATCH" },
{ VT_VARIANT, "VT_VARIANT" },
{ VT_I1, "VT_I1" },
{ VT_UI2, "VT_UI2" },
{ VT_UI4, "VT_UI4" },
{ VT_INT, "VT_INT" },
{ VT_UINT, "VT_UINT" },
{ VT_ARRAY, "VT_ARRAY" },
{ VT_BYREF, "VT_BYREF" },
{ VT_VOID, "VT_VOID" },
{ VT_PTR, "VT_PTR" },
{ VT_HRESULT, "VT_HRESULT" },
{ 0, NULL }
};
static inline const char *vt_to_string(VARTYPE vt)
{
int i;
for (i = 0; vt_names[i].name != NULL; i++) {
if (vt_names[i].vt == vt)
return vt_names[i].name;
}
return "?";
}
static int process_typeinfo(ITypeInfo *typeinfo, HashTable *id_to_name, int printdef, GUID *guid TSRMLS_DC)
{
TYPEATTR *attr;
FUNCDESC *func;
int i;
OLECHAR *olename;
char *ansiname = NULL;
unsigned int ansinamelen;
int ret = 0;
if (FAILED(typeinfo->lpVtbl->GetTypeAttr(typeinfo, &attr)))
return 0;
/* verify that it is suitable */
if (id_to_name == NULL || attr->typekind == TKIND_DISPATCH) {
if (guid)
memcpy(guid, &attr->guid, sizeof(GUID));
if (printdef) {
char *guidstring;
typeinfo->lpVtbl->GetDocumentation(typeinfo, MEMBERID_NIL, &olename, NULL, NULL, NULL);
ansiname = php_OLECHAR_to_char(olename, &ansinamelen, codepage TSRMLS_CC);
SysFreeString(olename);
guidstring = php_string_from_clsid(&attr->guid TSRMLS_CC);
php_printf("class %s { /* GUID=%s */\n", ansiname, guidstring);
efree(guidstring);
efree(ansiname);
}
if (id_to_name)
zend_hash_init(id_to_name, 0, NULL, ZVAL_PTR_DTOR, 0);
/* So we've got the dispatch interface; lets list the event methods */
for (i = 0; i < attr->cFuncs; i++) {
zval *tmp;
DISPID lastid = 0; /* for props */
int isprop;
if (FAILED(typeinfo->lpVtbl->GetFuncDesc(typeinfo, i, &func)))
break;
isprop = (func->invkind & DISPATCH_PROPERTYGET || func->invkind & DISPATCH_PROPERTYPUT);
if (!isprop || lastid != func->memid) {
lastid = func->memid;
typeinfo->lpVtbl->GetDocumentation(typeinfo, func->memid, &olename, NULL, NULL, NULL);
ansiname = php_OLECHAR_to_char(olename, &ansinamelen, codepage TSRMLS_CC);
SysFreeString(olename);
if (printdef) {
int j;
char *funcdesc;
unsigned int funcdesclen, cnames = 0;
BSTR *names;
names = (BSTR*)emalloc((func->cParams + 1) * sizeof(BSTR));
typeinfo->lpVtbl->GetNames(typeinfo, func->memid, names, func->cParams + 1, &cnames);
/* first element is the function name */
SysFreeString(names[0]);
php_printf("\t/* DISPID=%d */\n", func->memid);
if (func->elemdescFunc.tdesc.vt != VT_VOID) {
php_printf("\t/* %s [%d] */\n",
vt_to_string(func->elemdescFunc.tdesc.vt),
func->elemdescFunc.tdesc.vt
);
}
if (isprop) {
typeinfo->lpVtbl->GetDocumentation(typeinfo, func->memid, NULL, &olename, NULL, NULL);
if (olename) {
funcdesc = php_OLECHAR_to_char(olename, &funcdesclen, codepage TSRMLS_CC);
SysFreeString(olename);
php_printf("\t/* %s */\n", funcdesc);
efree(funcdesc);
}
php_printf("\tvar $%s;\n\n", ansiname);
} else {
/* a function */
php_printf("\tfunction %s(\n", ansiname);
for (j = 0; j < func->cParams; j++) {
ELEMDESC *elem = &func->lprgelemdescParam[j];
php_printf("\t\t/* %s [%d] ", vt_to_string(elem->tdesc.vt), elem->tdesc.vt);
if (elem->paramdesc.wParamFlags & PARAMFLAG_FIN)
php_printf("[in]");
if (elem->paramdesc.wParamFlags & PARAMFLAG_FOUT)
php_printf("[out]");
if (elem->tdesc.vt == VT_PTR) {
/* what does it point to ? */
php_printf(" --> %s [%d] ",
vt_to_string(elem->tdesc.lptdesc->vt),
elem->tdesc.lptdesc->vt
);
}
/* when we handle prop put and get, this will look nicer */
if (j+1 < (int)cnames) {
funcdesc = php_OLECHAR_to_char(names[j+1], &funcdesclen, codepage TSRMLS_CC);
SysFreeString(names[j+1]);
} else {
funcdesc = "???";
}
php_printf(" */ %s%s%c\n",
elem->tdesc.vt == VT_PTR ? "&$" : "$",
funcdesc,
j == func->cParams - 1 ? ' ' : ','
);
if (j+1 < (int)cnames)
efree(funcdesc);
}
php_printf("\t\t)\n\t{\n");
typeinfo->lpVtbl->GetDocumentation(typeinfo, func->memid, NULL, &olename, NULL, NULL);
if (olename) {
funcdesc = php_OLECHAR_to_char(olename, &funcdesclen, codepage TSRMLS_CC);
SysFreeString(olename);
php_printf("\t\t/* %s */\n", funcdesc);
efree(funcdesc);
}
php_printf("\t}\n");
}
efree(names);
}
if (id_to_name) {
zend_str_tolower(ansiname, ansinamelen);
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, ansiname, ansinamelen, 0);
zend_hash_index_update(id_to_name, func->memid, (void*)&tmp, sizeof(zval *), NULL);
}
}
typeinfo->lpVtbl->ReleaseFuncDesc(typeinfo, func);
}
if (printdef)
php_printf("}\n");
ret = 1;
} else {
zend_error(E_WARNING, "Thats not a dispatchable interface!! type kind = %08x\n", attr->typekind);
}
typeinfo->lpVtbl->ReleaseTypeAttr(typeinfo, attr);
return ret;
}
static ITypeInfo *locate_typeinfo(char *typelibname, comval *obj, char *dispname, int sink TSRMLS_DC)
{
ITypeInfo *typeinfo = NULL;
ITypeLib *typelib = NULL;
int gotguid = 0;
GUID iid;
if (obj) {
if (dispname == NULL && sink) {
IProvideClassInfo2 *pci2;
IProvideClassInfo *pci;
if (SUCCEEDED(C_DISPATCH_VT(obj)->QueryInterface(C_DISPATCH(obj), &IID_IProvideClassInfo2, (void**)&pci2))) {
gotguid = SUCCEEDED(pci2->lpVtbl->GetGUID(pci2, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &iid));
pci2->lpVtbl->Release(pci2);
}
if (!gotguid && SUCCEEDED(C_DISPATCH_VT(obj)->QueryInterface(C_DISPATCH(obj), &IID_IProvideClassInfo, (void**)&pci))) {
/* examine the available interfaces */
/* TODO: write some code here */
pci->lpVtbl->Release(pci);
}
} else if (dispname && C_HASTLIB(obj)) {
unsigned int idx;
/* get the library from the object; the rest will be dealt with later */
C_TYPEINFO_VT(obj)->GetContainingTypeLib(C_TYPEINFO(obj), &typelib, &idx);
} else if (typelibname == NULL) {
C_DISPATCH_VT(obj)->GetTypeInfo(C_DISPATCH(obj), 0, LANG_NEUTRAL, &typeinfo);
}
} else if (typelibname) {
/* Fetch the typelibrary and use that to look things up */
typelib = php_COM_find_typelib(typelibname, CONST_CS TSRMLS_CC);
}
if (!gotguid && dispname && typelib) {
unsigned short cfound;
MEMBERID memid;
OLECHAR *olename = php_char_to_OLECHAR(dispname, strlen(dispname), CP_ACP TSRMLS_CC);
cfound = 1;
if (FAILED(typelib->lpVtbl->FindName(typelib, olename, 0, &typeinfo, &memid, &cfound)) || cfound == 0) {
CLSID coclass;
ITypeInfo *coinfo;
/* assume that it might be a progid instead */
if (SUCCEEDED(CLSIDFromProgID(olename, &coclass)) &&
SUCCEEDED(typelib->lpVtbl->GetTypeInfoOfGuid(typelib, &coclass, &coinfo))) {
/* enumerate implemented interfaces and pick the one as indicated by sink */
TYPEATTR *attr;
int i;
coinfo->lpVtbl->GetTypeAttr(coinfo, &attr);
for (i = 0; i < attr->cImplTypes; i++) {
HREFTYPE rt;
int tf;
if (FAILED(coinfo->lpVtbl->GetImplTypeFlags(coinfo, i, &tf)))
continue;
if ((sink && tf == (IMPLTYPEFLAG_FSOURCE|IMPLTYPEFLAG_FDEFAULT)) ||
(!sink && (tf & IMPLTYPEFLAG_FSOURCE) == 0)) {
/* flags match what we are looking for */
if (SUCCEEDED(coinfo->lpVtbl->GetRefTypeOfImplType(coinfo, i, &rt)))
if (SUCCEEDED(coinfo->lpVtbl->GetRefTypeInfo(coinfo, rt, &typeinfo)))
break;
}
}
coinfo->lpVtbl->ReleaseTypeAttr(coinfo, attr);
coinfo->lpVtbl->Release(coinfo);
}
}
efree(olename);
} else if (gotguid) {
typelib->lpVtbl->GetTypeInfoOfGuid(typelib, &iid, &typeinfo);
}
if (typelib)
typelib->lpVtbl->Release(typelib);
return typeinfo;
}
/* {{{ proto bool com_print_typeinfo(mixed comobject | string typelib, string dispinterface, bool wantsink)
Print out a PHP class definition for a dispatchable interface */
PHP_FUNCTION(com_print_typeinfo)
{
zval *arg1;
char *ifacename = NULL;
char *typelibname = NULL;
int ifacelen;
zend_bool wantsink = 0;
comval *obj = NULL;
ITypeInfo *typeinfo;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/s!b", &arg1, &ifacename,
&ifacelen, &wantsink)) {
RETURN_FALSE;
}
if (Z_TYPE_P(arg1) == IS_OBJECT && (Z_OBJCE_P(arg1) == &COM_class_entry || !strcmp(Z_OBJCE_P(arg1)->name, "COM"))) {
zval **tmp;
zend_hash_index_find(Z_OBJPROP_P(arg1), 0, (void**)&tmp);
ZEND_FETCH_RESOURCE(obj, comval*, tmp, -1, "comval", IS_COM);
} else if (Z_TYPE_P(arg1) == IS_RESOURCE) {
ZEND_FETCH_RESOURCE(obj, comval*, &arg1, -1, "comval", IS_COM);
} else {
convert_to_string(arg1);
typelibname = Z_STRVAL_P(arg1);
}
typeinfo = locate_typeinfo(typelibname, obj, ifacename, wantsink TSRMLS_CC);
if (typeinfo) {
process_typeinfo(typeinfo, NULL, 1, NULL TSRMLS_CC);
typeinfo->lpVtbl->Release(typeinfo);
RETURN_TRUE;
} else {
zend_error(E_WARNING, "Unable to find typeinfo using the parameters supplied");
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto bool com_event_sink(mixed comobject, object sinkobject [, mixed sinkinterface])
Connect events from a COM object to a PHP object */
PHP_FUNCTION(com_event_sink)
{
zval *object, *sinkobject, *sink=NULL;
char *dispname = NULL, *typelibname = NULL;
zend_bool gotguid = 0;
comval *obj;
ITypeInfo *typeinfo = NULL;
RETVAL_FALSE;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z/", &object, &sinkobject, &sink)) {
RETURN_FALSE;
}
if (Z_TYPE_P(object) == IS_OBJECT && (Z_OBJCE_P(object) == &COM_class_entry || !strcmp(Z_OBJCE_P(object)->name, "COM"))) {
zval **tmp;
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void**)&tmp);
ZEND_FETCH_RESOURCE(obj, comval*, tmp, -1, "comval", IS_COM);
} else {
ZEND_FETCH_RESOURCE(obj, comval*, &object, -1, "comval", IS_COM);
}
if (sink && Z_TYPE_P(sink) == IS_ARRAY) {
/* 0 => typelibname, 1 => dispname */
zval **tmp;
if (zend_hash_index_find(Z_ARRVAL_P(sink), 0, (void**)&tmp) == SUCCESS)
typelibname = Z_STRVAL_PP(tmp);
if (zend_hash_index_find(Z_ARRVAL_P(sink), 1, (void**)&tmp) == SUCCESS)
dispname = Z_STRVAL_PP(tmp);
} else if (sink != NULL) {
convert_to_string(sink);
dispname = Z_STRVAL_P(sink);
}
typeinfo = locate_typeinfo(typelibname, obj, dispname, 1 TSRMLS_CC);
if (typeinfo) {
HashTable *id_to_name;
ALLOC_HASHTABLE(id_to_name);
if (process_typeinfo(typeinfo, id_to_name, 0, &obj->sinkid TSRMLS_CC)) {
/* Create the COM wrapper for this sink */
obj->sinkdispatch = php_COM_export_as_sink(sinkobject, &obj->sinkid, id_to_name TSRMLS_CC);
/* Now hook it up to the source */
com_enable_events(obj, TRUE);
RETVAL_TRUE;
} else {
FREE_HASHTABLE(id_to_name);
}
}
if (typeinfo)
typeinfo->lpVtbl->Release(typeinfo);
}
/* }}} */
static int do_COM_offget(VARIANT *result, comval *array, pval *property, int cleanup TSRMLS_DC)
{
@@ -1122,33 +1586,36 @@ static void do_COM_propput(pval *return_value, comval *obj, pval *arg_property,
php_error(E_WARNING,"PropPut() failed: %s", error_message);
}
LocalFree(error_message);
efree(propname);
FREE_VARIANT(var_result);
FREE_VARIANT(new_value);
efree(new_value);
efree(propname);
RETURN_NULL();
}
dispparams.cArgs = 0;
dispparams.cNamedArgs = 0;
if (return_value) {
dispparams.cArgs = 0;
dispparams.cNamedArgs = 0;
hr = php_COM_invoke(obj, dispid, DISPATCH_PROPERTYGET, &dispparams, var_result, &ErrString TSRMLS_CC);
hr = php_COM_invoke(obj, dispid, DISPATCH_PROPERTYGET, &dispparams, var_result, &ErrString TSRMLS_CC);
if (SUCCEEDED(hr)) {
php_variant_to_pval(var_result, return_value, codepage TSRMLS_CC);
} else {
*return_value = *value;
zval_copy_ctor(return_value);
}
if (SUCCEEDED(hr)) {
php_variant_to_pval(var_result, return_value, codepage TSRMLS_CC);
} else {
*return_value = *value;
zval_copy_ctor(return_value);
}
if (ErrString) {
pefree(ErrString, 1);
if (ErrString) {
pefree(ErrString, 1);
}
}
FREE_VARIANT(var_result);
FREE_VARIANT(new_value);
efree(new_value); // FREE_VARIANT does a VariantClear() which is not desired here !
efree(propname);
}
@@ -1322,6 +1789,7 @@ PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_refer
obj = obj_prop;
php_COM_set(obj, &V_DISPATCH(var_result), TRUE TSRMLS_CC);
VariantInit(var_result); // to protect C_DISPATCH(obj) from being freed when var_result is destructed
} else {
php_variant_to_pval(var_result, &return_value, codepage TSRMLS_CC);
@@ -1329,7 +1797,6 @@ PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_refer
obj_prop = NULL;
}
VariantInit(var_result); // to protect C_DISPATCH(obj) from being freed when var_result is destructed
pval_destructor(&overloaded_property->element);
}
@@ -1346,7 +1813,6 @@ PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_refer
PHPAPI int php_COM_set_property_handler(zend_property_reference *property_reference, pval *value)
{
pval result;
zend_overloaded_element *overloaded_property;
zend_llist_element *element;
pval **comval_handle;
@@ -1416,7 +1882,7 @@ PHPAPI int php_COM_set_property_handler(zend_property_reference *property_refere
FREE_VARIANT(var_result);
overloaded_property = (zend_overloaded_element *) element->data;
do_COM_propput(&result, obj, &overloaded_property->element, value TSRMLS_CC);
do_COM_propput(NULL, obj, &overloaded_property->element, value TSRMLS_CC);
FREE_COM(obj_prop);
pval_destructor(&overloaded_property->element);
@@ -1424,6 +1890,20 @@ PHPAPI int php_COM_set_property_handler(zend_property_reference *property_refere
return SUCCESS;
}
/* create an overloaded COM object from a dispatch pointer */
PHPAPI zval *php_COM_object_from_dispatch(IDispatch *disp, zval *val TSRMLS_DC)
{
comval *obj;
zval *zobj;
ALLOC_COM(obj);
MAKE_STD_ZVAL(zobj);
php_COM_set(obj, &disp, FALSE TSRMLS_CC);
ZVAL_COM_EX(zobj, obj, val);
return zobj;
}
PHPAPI void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference)
{
@@ -1526,6 +2006,10 @@ static ITypeLib *php_COM_find_typelib(char *search_string, int mode TSRMLS_DC)
*/
search_string = php_strtok_r(search_string, ",", &strtok_buf);
if (search_string == NULL)
return NULL;
major = php_strtok_r(NULL, ",", &strtok_buf);
minor = php_strtok_r(NULL, ",", &strtok_buf);
@@ -1672,7 +2156,7 @@ static ITypeLib *php_COM_find_typelib(char *search_string, int mode TSRMLS_DC)
}
static int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC)
PHPAPI int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC)
{
ITypeComp *TypeComp;
int i;
@@ -1754,7 +2238,6 @@ static int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC)
return SUCCESS;
}
/* {{{ proto bool com_isenum(object com_module)
Grabs an IEnumVariant */
PHP_FUNCTION(com_isenum)
@@ -1800,11 +2283,18 @@ static void php_COM_init(int module_number TSRMLS_DC)
php_register_COM_class(TSRMLS_C);
}
PHPAPI ZEND_DECLARE_MODULE_GLOBALS(com)
static void php_com_init_globals(zend_com_globals *com_globals)
{
}
PHP_MINIT_FUNCTION(COM)
{
ZEND_INIT_MODULE_GLOBALS(com, php_com_init_globals, NULL);
php_COM_init(module_number TSRMLS_CC);
php_VARIANT_init(module_number TSRMLS_CC);
php_COM_dispatch_init(module_number TSRMLS_CC);
REGISTER_LONG_CONSTANT("CLSCTX_INPROC_SERVER", CLSCTX_INPROC_SERVER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CLSCTX_INPROC_HANDLER", CLSCTX_INPROC_HANDLER, CONST_CS | CONST_PERSISTENT);
@@ -1818,7 +2308,6 @@ PHP_MINIT_FUNCTION(COM)
return SUCCESS;
}
PHP_MSHUTDOWN_FUNCTION(COM)
{
UNREGISTER_INI_ENTRIES();
@@ -1835,7 +2324,7 @@ zend_module_entry COM_module_entry = {
PHP_MSHUTDOWN(COM),
NULL,
NULL,
PHP_MINFO(COM),
PHP_MINFO(COM),
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
+13 -4
View File
@@ -19,19 +19,28 @@ typedef struct comval_ {
ITypeInfo *typeinfo;
IEnumVARIANT *enumvariant;
} i;
IDispatch *sinkdispatch;
GUID sinkid;
DWORD sinkcookie;
} comval;
END_EXTERN_C()
#define ZVAL_COM(z,o) { \
zval *handle; \
zval *handle = NULL; \
ZVAL_COM_EX(z,o,handle) \
}
#define ZVAL_COM_EX(z,o,handle) { \
HashTable *properties; \
\
ALLOC_HASHTABLE(properties); \
zend_hash_init(properties, 0, NULL, ZVAL_PTR_DTOR, 0); \
\
MAKE_STD_ZVAL(handle); \
ZVAL_LONG(handle, zend_list_insert((o), IS_COM)); \
if (handle == NULL) { \
MAKE_STD_ZVAL(handle); \
} \
ZVAL_RESOURCE(handle, zend_list_insert((o), IS_COM)); \
\
zval_copy_ctor(handle); \
zend_hash_index_update(properties, 0, &handle, sizeof(zval *), NULL); \
@@ -42,7 +51,7 @@ END_EXTERN_C()
#define RETURN_COM(o) RETVAL_COM(o) \
return;
#define ALLOC_COM(z) (z) = (comval *) emalloc(sizeof(comval)); \
#define ALLOC_COM(z) (z) = (comval *) ecalloc(1, sizeof(comval)); \
C_REFCOUNT(z) = 0;
#define FREE_COM(z) php_COM_destruct(z TSRMLS_CC);
+21 -6
View File
@@ -56,7 +56,7 @@ PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage T
case IS_OBJECT:
if (!strcmp(Z_OBJCE_P(pval_arg)->name, "VARIANT")) {
type = VT_VARIANT|VT_BYREF;
} else if (!strcmp(Z_OBJCE_P(pval_arg)->name, "COM")) {
} else {
type = VT_DISPATCH;
}
break;
@@ -155,6 +155,12 @@ PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type,
}
} else {
switch (V_VT(var_arg)) {
case VT_NULL:
case VT_VOID:
ZVAL_NULL(pval_arg);
break;
case VT_UI1:
convert_to_long_ex(&pval_arg);
V_UI1(var_arg) = (unsigned char) Z_LVAL_P(pval_arg);
@@ -211,6 +217,7 @@ PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type,
/** @todo
case IS_STRING:
*/
/* string representation of a time value */
default:
@@ -262,7 +269,14 @@ PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type,
break;
case VT_DISPATCH:
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
if (!strcmp(Z_OBJCE_P(pval_arg)->name, "COM")) {
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
} else {
V_DISPATCH(var_arg) = php_COM_export_object(pval_arg TSRMLS_CC);
if (V_DISPATCH(var_arg)) {
V_VT(var_arg) = VT_DISPATCH;
}
}
if (V_VT(var_arg) != VT_DISPATCH) {
VariantInit(var_arg);
}
@@ -437,7 +451,7 @@ PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type,
break;
default:
php_error(E_WARNING, "Type not supported or not yet implemented.");
php_error(E_WARNING,"Unsupported variant type: %d (0x%X)", V_VT(var_arg), V_VT(var_arg));
}
}
}
@@ -705,9 +719,10 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int codepage TS
ZVAL_NULL(pval_arg);
} else {
ALLOC_COM(obj);
php_COM_set(obj, &V_DISPATCH(var_arg), TRUE TSRMLS_CC);
php_COM_set(obj, &V_DISPATCH(var_arg), FALSE TSRMLS_CC);
ZVAL_COM(pval_arg, obj);
VariantInit(var_arg); // to protect C_DISPATCH(obj) from being freed when var_result is destructed
}
}
break;
@@ -769,7 +784,7 @@ PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRML
if (strlen == -1) {
/* request needed buffersize */
strlen = MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED) | MB_ERR_INVALID_CHARS, C_str, -1, NULL, 0);
strlen = MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS), C_str, -1, NULL, 0);
} else {
/* \0 terminator */
strlen++;
@@ -779,7 +794,7 @@ PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRML
unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR) * strlen);
/* convert string */
error = !MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED) | MB_ERR_INVALID_CHARS, C_str, strlen, unicode_str, strlen);
error = !MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS), C_str, strlen, unicode_str, strlen);
} else {
/* return a zero-length string */
unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR));
+627
View File
@@ -0,0 +1,627 @@
/*
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.php.net/license/2_02.txt. |
| 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: Wez Furlong <wez@thebrainroom.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
/*
* This module is used to export PHP objects to COM and DOTNET by exposing
* them as objects implementing IDispatch.
* */
#include "php.h"
#include "php_COM.h"
#include "php_VARIANT.h"
#include "conversion.h"
#include "variant.h"
#define COBJMACROS
#include <unknwn.h> /* IDispatch */
#include <dispex.h> /* IDispatchEx */
typedef struct {
/* This first part MUST match the declaration
* of interface IDispatchEx */
CONST_VTBL struct IDispatchExVtbl *lpVtbl;
/* now the PHP stuff */
THREAD_T engine_thread; /* for sanity checking */
zval *object; /* the object exported */
LONG refcount; /* COM reference count */
HashTable *dispid_to_name; /* keep track of dispid -> name mappings */
HashTable *name_to_dispid; /* keep track of name -> dispid mappings */
GUID sinkid; /* iid that we "implement" for event sinking */
int id;
} php_dispatchex;
static void disp_destructor(php_dispatchex *disp);
static void dispatch_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
php_dispatchex *disp = (php_dispatchex *)rsrc->ptr;
disp_destructor(disp);
}
static int le_dispatch;
int php_COM_dispatch_init(int module_number TSRMLS_DC)
{
le_dispatch = zend_register_list_destructors_ex(dispatch_dtor, NULL, "COM:Dispatch", module_number);
return le_dispatch;
}
/* {{{ trace */
static inline void trace(char *fmt, ...)
{
va_list ap;
char buf[4096];
sprintf(buf, "T=%08x ", tsrm_thread_id());
OutputDebugString(buf);
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
OutputDebugString(buf);
va_end(ap);
}
/* }}} */
#define FETCH_DISP(methname) \
php_dispatchex *disp = (php_dispatchex*)This; \
trace(" PHP:%s %s\n", Z_OBJCE_P(disp->object)->name, methname); \
if (tsrm_thread_id() != disp->engine_thread) \
return E_UNEXPECTED;
static HRESULT STDMETHODCALLTYPE disp_queryinterface(
IDispatchEx *This,
/* [in] */ REFIID riid,
/* [iid_is][out] */ void **ppvObject)
{
FETCH_DISP("QueryInterface");
if (IsEqualGUID(&IID_IUnknown, riid) ||
IsEqualGUID(&IID_IDispatch, riid) ||
IsEqualGUID(&IID_IDispatchEx, riid) ||
IsEqualGUID(&disp->sinkid, riid)) {
*ppvObject = This;
InterlockedIncrement(&disp->refcount);
return S_OK;
}
*ppvObject = NULL;
return E_NOINTERFACE;
}
static ULONG STDMETHODCALLTYPE disp_addref(IDispatchEx *This)
{
FETCH_DISP("AddRef");
return InterlockedIncrement(&disp->refcount);
}
static ULONG STDMETHODCALLTYPE disp_release(IDispatchEx *This)
{
ULONG ret;
TSRMLS_FETCH();
FETCH_DISP("Release");
ret = InterlockedDecrement(&disp->refcount);
trace("-- refcount now %d\n", ret);
if (ret == 0) {
/* destroy it */
if (disp->id)
zend_list_delete(disp->id);
}
return ret;
}
static HRESULT STDMETHODCALLTYPE disp_gettypeinfocount(
IDispatchEx *This,
/* [out] */ UINT *pctinfo)
{
FETCH_DISP("GetTypeInfoCount");
*pctinfo = 0;
return S_OK;
}
static HRESULT STDMETHODCALLTYPE disp_gettypeinfo(
IDispatchEx *This,
/* [in] */ UINT iTInfo,
/* [in] */ LCID lcid,
/* [out] */ ITypeInfo **ppTInfo)
{
FETCH_DISP("GetTypeInfo");
*ppTInfo = NULL;
return DISP_E_BADINDEX;
}
static HRESULT STDMETHODCALLTYPE disp_getidsofnames(
IDispatchEx *This,
/* [in] */ REFIID riid,
/* [size_is][in] */ LPOLESTR *rgszNames,
/* [in] */ UINT cNames,
/* [in] */ LCID lcid,
/* [size_is][out] */ DISPID *rgDispId)
{
UINT i;
HRESULT ret = S_OK;
TSRMLS_FETCH();
FETCH_DISP("GetIDsOfNames");
for (i = 0; i < cNames; i++) {
char *name;
unsigned int namelen;
zval **tmp;
name = php_OLECHAR_to_char(rgszNames[i], &namelen, CP_ACP TSRMLS_CC);
/* Lookup the name in the hash */
if (zend_hash_find(disp->name_to_dispid, name, namelen+1, (void**)&tmp) == FAILURE) {
ret = DISP_E_UNKNOWNNAME;
rgDispId[i] = 0;
} else {
rgDispId[i] = Z_LVAL_PP(tmp);
}
efree(name);
}
return ret;
}
static HRESULT STDMETHODCALLTYPE disp_invoke(
IDispatchEx *This,
/* [in] */ DISPID dispIdMember,
/* [in] */ REFIID riid,
/* [in] */ LCID lcid,
/* [in] */ WORD wFlags,
/* [out][in] */ DISPPARAMS *pDispParams,
/* [out] */ VARIANT *pVarResult,
/* [out] */ EXCEPINFO *pExcepInfo,
/* [out] */ UINT *puArgErr)
{
return This->lpVtbl->InvokeEx(This, dispIdMember,
lcid, wFlags, pDispParams,
pVarResult, pExcepInfo, NULL);
}
static HRESULT STDMETHODCALLTYPE disp_getdispid(
IDispatchEx *This,
/* [in] */ BSTR bstrName,
/* [in] */ DWORD grfdex,
/* [out] */ DISPID *pid)
{
HRESULT ret = DISP_E_UNKNOWNNAME;
char *name;
unsigned int namelen;
zval **tmp;
TSRMLS_FETCH();
FETCH_DISP("GetDispID");
name = php_OLECHAR_to_char(bstrName, &namelen, CP_ACP TSRMLS_CC);
/* Lookup the name in the hash */
if (zend_hash_find(disp->name_to_dispid, name, namelen+1, (void**)&tmp) == SUCCESS) {
*pid = Z_LVAL_PP(tmp);
ret = S_OK;
}
efree(name);
return ret;
}
static HRESULT STDMETHODCALLTYPE disp_invokeex(
IDispatchEx *This,
/* [in] */ DISPID id,
/* [in] */ LCID lcid,
/* [in] */ WORD wFlags,
/* [in] */ DISPPARAMS *pdp,
/* [out] */ VARIANT *pvarRes,
/* [out] */ EXCEPINFO *pei,
/* [unique][in] */ IServiceProvider *pspCaller)
{
zval **name;
UINT i;
int codepage = CP_ACP;
zval *retval = NULL;
zval ***params = NULL;
HRESULT ret = DISP_E_MEMBERNOTFOUND;
TSRMLS_FETCH();
FETCH_DISP("InvokeEx");
if (SUCCESS == zend_hash_index_find(disp->dispid_to_name, id, (void**)&name)) {
/* TODO: add support for overloaded objects */
trace("-- Invoke: %d %20s flags=%08x args=%d\n", id, Z_STRVAL_PP(name), wFlags, pdp->cArgs);
/* convert args into zvals.
* Args are in reverse order */
params = (zval ***)emalloc(sizeof(zval **) * pdp->cArgs);
for (i = 0; i < pdp->cArgs; i++) {
VARIANT *arg;
zval *zarg;
arg = &pdp->rgvarg[ pdp->cArgs - 1 - i];
trace("alloc zval for arg %d VT=%08x\n", i, V_VT(arg));
ALLOC_INIT_ZVAL(zarg);
if (V_VT(arg) == VT_DISPATCH) {
trace("arg %d is dispatchable\n", i);
if (NULL == php_COM_object_from_dispatch(V_DISPATCH(arg), zarg TSRMLS_CC)) {
trace("failed to convert arg %d to zval\n", i);
ZVAL_NULL(zarg);
}
} else {
// arg can't be an idispatch, so we don't care for the implicit AddRef() call here
if (FAILURE == php_variant_to_pval(arg, zarg, codepage TSRMLS_CC)) {
trace("failed to convert arg %d to zval\n", i);
ZVAL_NULL(zarg);
}
}
params[i] = &zarg;
}
trace("arguments processed, prepare to do some work\n");
if (wFlags & DISPATCH_PROPERTYGET) {
trace("trying to get a property\n");
zend_hash_find(Z_OBJPROP_P(disp->object), Z_STRVAL_PP(name), Z_STRLEN_PP(name)+1, (void**)&retval);
} else if (wFlags & DISPATCH_PROPERTYPUT) {
trace("trying to set a property\n");
add_property_zval(disp->object, Z_STRVAL_PP(name), *params[0]);
} else if (wFlags & DISPATCH_METHOD) {
trace("Trying to call user function\n");
if (SUCCESS == call_user_function_ex(EG(function_table), &disp->object, *name,
&retval, pdp->cArgs, params, 1, NULL TSRMLS_CC)) {
ret = S_OK;
} else {
ret = DISP_E_EXCEPTION;
}
} else {
trace("Don't know how to handle this invocation %08x\n", wFlags);
}
/* release arguments */
for (i = 0; i < pdp->cArgs; i++)
zval_ptr_dtor(params[i]);
efree(params);
/* return value */
if (retval) {
if (pvarRes) {
if (Z_TYPE_P(retval) == IS_OBJECT) {
/* export the object using a dispatch like ourselves */
VariantInit(pvarRes);
V_VT(pvarRes) = VT_DISPATCH;
V_DISPATCH(pvarRes) = php_COM_export_object(retval TSRMLS_CC);
} else {
php_pval_to_variant(retval, pvarRes, codepage TSRMLS_CC);
}
}
zval_ptr_dtor(&retval);
} else if (pvarRes) {
VariantInit(pvarRes);
}
} else {
trace("InvokeEx: I don't support DISPID=%d\n", id);
}
return ret;
}
static HRESULT STDMETHODCALLTYPE disp_deletememberbyname(
IDispatchEx *This,
/* [in] */ BSTR bstrName,
/* [in] */ DWORD grfdex)
{
FETCH_DISP("DeleteMemberByName");
return S_FALSE;
}
static HRESULT STDMETHODCALLTYPE disp_deletememberbydispid(
IDispatchEx *This,
/* [in] */ DISPID id)
{
FETCH_DISP("DeleteMemberByDispID");
return S_FALSE;
}
static HRESULT STDMETHODCALLTYPE disp_getmemberproperties(
IDispatchEx *This,
/* [in] */ DISPID id,
/* [in] */ DWORD grfdexFetch,
/* [out] */ DWORD *pgrfdex)
{
FETCH_DISP("GetMemberProperties");
return DISP_E_UNKNOWNNAME;
}
static HRESULT STDMETHODCALLTYPE disp_getmembername(
IDispatchEx *This,
/* [in] */ DISPID id,
/* [out] */ BSTR *pbstrName)
{
zval *name;
TSRMLS_FETCH();
FETCH_DISP("GetMemberName");
if (SUCCESS == zend_hash_index_find(disp->dispid_to_name, id, (void**)&name)) {
OLECHAR *olestr = php_char_to_OLECHAR(Z_STRVAL_P(name), Z_STRLEN_P(name), CP_ACP TSRMLS_CC);
*pbstrName = SysAllocString(olestr);
efree(olestr);
return S_OK;
} else {
return DISP_E_UNKNOWNNAME;
}
}
static HRESULT STDMETHODCALLTYPE disp_getnextdispid(
IDispatchEx *This,
/* [in] */ DWORD grfdex,
/* [in] */ DISPID id,
/* [out] */ DISPID *pid)
{
ulong next = id+1;
FETCH_DISP("GetNextDispID");
while(!zend_hash_index_exists(disp->dispid_to_name, next))
next++;
if (zend_hash_index_exists(disp->dispid_to_name, next)) {
*pid = next;
return S_OK;
}
return S_FALSE;
}
static HRESULT STDMETHODCALLTYPE disp_getnamespaceparent(
IDispatchEx *This,
/* [out] */ IUnknown **ppunk)
{
FETCH_DISP("GetNameSpaceParent");
*ppunk = NULL;
return E_NOTIMPL;
}
static struct IDispatchExVtbl php_dispatch_vtbl = {
disp_queryinterface,
disp_addref,
disp_release,
disp_gettypeinfocount,
disp_gettypeinfo,
disp_getidsofnames,
disp_invoke,
disp_getdispid,
disp_invokeex,
disp_deletememberbyname,
disp_deletememberbydispid,
disp_getmemberproperties,
disp_getmembername,
disp_getnextdispid,
disp_getnamespaceparent
};
/* enumerate functions and properties of the object and assign
* dispatch ids */
static void generate_dispids(php_dispatchex *disp TSRMLS_DC)
{
HashPosition pos;
char *name = NULL;
zval *tmp;
int namelen;
int keytype;
ulong pid;
if (disp->dispid_to_name == NULL) {
ALLOC_HASHTABLE(disp->dispid_to_name);
ALLOC_HASHTABLE(disp->name_to_dispid);
zend_hash_init(disp->name_to_dispid, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_init(disp->dispid_to_name, 0, NULL, ZVAL_PTR_DTOR, 0);
}
/* properties */
zend_hash_internal_pointer_reset_ex(Z_OBJPROP_PP(&disp->object), &pos);
while (HASH_KEY_NON_EXISTANT != (keytype =
zend_hash_get_current_key_ex(Z_OBJPROP_PP(&disp->object), &name, &namelen, &pid, 0, &pos))) {
char namebuf[32];
if (keytype == HASH_KEY_IS_LONG) {
sprintf(namebuf, "%d", pid);
name = namebuf;
namelen = strlen(namebuf);
}
zend_hash_move_forward_ex(Z_OBJPROP_PP(&disp->object), &pos);
/* Find the existing id */
if (zend_hash_find(disp->name_to_dispid, name, namelen+1, (void**)&tmp) == SUCCESS)
continue;
/* add the mappings */
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, name, namelen, 1);
zend_hash_index_update(disp->dispid_to_name, pid, (void*)&tmp, sizeof(zval *), NULL);
MAKE_STD_ZVAL(tmp);
ZVAL_LONG(tmp, pid);
zend_hash_update(disp->name_to_dispid, name, namelen+1, (void*)&tmp, sizeof(zval *), NULL);
}
/* functions */
zend_hash_internal_pointer_reset_ex(&Z_OBJCE_PP(&disp->object)->function_table, &pos);
while (HASH_KEY_NON_EXISTANT != (keytype =
zend_hash_get_current_key_ex(&Z_OBJCE_PP(&disp->object)->function_table, &name, &namelen, &pid, 0, &pos))) {
char namebuf[32];
if (keytype == HASH_KEY_IS_LONG) {
sprintf(namebuf, "%d", pid);
name = namebuf;
namelen = strlen(namebuf);
}
zend_hash_move_forward_ex(Z_OBJPROP_PP(&disp->object), &pos);
/* Find the existing id */
if (zend_hash_find(disp->name_to_dispid, name, namelen+1, (void**)&tmp) == SUCCESS)
continue;
/* add the mappings */
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, name, namelen, 1);
zend_hash_index_update(disp->dispid_to_name, pid, (void*)&tmp, sizeof(zval *), NULL);
MAKE_STD_ZVAL(tmp);
ZVAL_LONG(tmp, pid);
zend_hash_update(disp->name_to_dispid, name, namelen+1, (void*)&tmp, sizeof(zval *), NULL);
}
}
static php_dispatchex *disp_constructor(zval *object TSRMLS_DC)
{
php_dispatchex *disp = (php_dispatchex*)CoTaskMemAlloc(sizeof(php_dispatchex));
trace("constructing a COM proxy\n");
if (disp == NULL)
return NULL;
memset(disp, 0, sizeof(php_dispatchex));
disp->engine_thread = tsrm_thread_id();
disp->lpVtbl = &php_dispatch_vtbl;
disp->refcount = 1;
if (object)
ZVAL_ADDREF(object);
disp->object = object;
disp->id = zend_list_insert(disp, le_dispatch);
return disp;
}
static void disp_destructor(php_dispatchex *disp)
{
TSRMLS_FETCH();
trace("destroying COM wrapper for PHP object %s\n", Z_OBJCE_P(disp->object)->name);
disp->id = 0;
if (disp->refcount > 0)
CoDisconnectObject((IUnknown*)disp, 0);
zend_hash_destroy(disp->dispid_to_name);
zend_hash_destroy(disp->name_to_dispid);
FREE_HASHTABLE(disp->dispid_to_name);
FREE_HASHTABLE(disp->name_to_dispid);
if (disp->object)
zval_ptr_dtor(&disp->object);
CoTaskMemFree(disp);
}
PHPAPI IDispatch *php_COM_export_as_sink(zval *val, GUID *sinkid, HashTable *id_to_name TSRMLS_DC)
{
php_dispatchex *disp = disp_constructor(val TSRMLS_CC);
HashPosition pos;
char *name = NULL;
zval *tmp, **ntmp;
int namelen;
int keytype;
ulong pid;
disp->dispid_to_name = id_to_name;
memcpy(&disp->sinkid, sinkid, sizeof(disp->sinkid));
/* build up the reverse mapping */
ALLOC_HASHTABLE(disp->name_to_dispid);
zend_hash_init(disp->name_to_dispid, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_internal_pointer_reset_ex(id_to_name, &pos);
while (HASH_KEY_NON_EXISTANT != (keytype =
zend_hash_get_current_key_ex(id_to_name, &name, &namelen, &pid, 0, &pos))) {
if (keytype == HASH_KEY_IS_LONG) {
zend_hash_get_current_data_ex(id_to_name, (void**)&ntmp, &pos);
MAKE_STD_ZVAL(tmp);
ZVAL_LONG(tmp, pid);
zend_hash_update(disp->name_to_dispid, Z_STRVAL_PP(ntmp), Z_STRLEN_PP(ntmp)+1, (void*)&tmp, sizeof(zval *), NULL);
}
zend_hash_move_forward_ex(id_to_name, &pos);
}
return (IDispatch*)disp;
}
PHPAPI IDispatch *php_COM_export_object(zval *val TSRMLS_DC)
{
php_dispatchex *disp = NULL;
if (Z_TYPE_P(val) != IS_OBJECT)
return NULL;
if (Z_OBJCE_P(val) == &COM_class_entry || !strcmp(Z_OBJCE_P(val)->name, "COM")) {
/* pass back it's IDispatch directly */
zval **tmp;
comval *obj;
int type;
zend_hash_index_find(Z_OBJPROP_P(val), 0, (void**)&tmp);
obj = (comval *)zend_list_find(Z_LVAL_PP(tmp), &type);
if (type != IS_COM)
return NULL;
C_DISPATCH(obj)->lpVtbl->AddRef(C_DISPATCH(obj));
return C_DISPATCH(obj);
}
disp = disp_constructor(val TSRMLS_CC);
generate_dispids(disp TSRMLS_CC);
return (IDispatch*)disp;
}
+22
View File
@@ -18,6 +18,9 @@ PHP_FUNCTION(com_propget);
PHP_FUNCTION(com_propput);
PHP_FUNCTION(com_load_typelib);
PHP_FUNCTION(com_isenum);
PHP_FUNCTION(com_event_sink);
PHP_FUNCTION(com_message_pump);
PHP_FUNCTION(com_print_typeinfo);
PHPAPI HRESULT php_COM_invoke(comval *obj, DISPID dispIdMember, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult, char **ErrString TSRMLS_DC);
PHPAPI HRESULT php_COM_get_ids_of_names(comval *obj, OLECHAR FAR* FAR* rgszNames, DISPID FAR* rgDispId TSRMLS_DC);
@@ -31,6 +34,13 @@ PHPAPI int php_COM_get_le_comval();
PHPAPI int php_COM_set_property_handler(zend_property_reference *property_reference, pval *value);
PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_reference);
PHPAPI void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference);
PHPAPI zval *php_COM_object_from_dispatch(IDispatch *disp, zval *val TSRMLS_DC);
PHPAPI int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC);
/* dispatch.c */
PHPAPI IDispatch *php_COM_export_object(zval *val TSRMLS_DC);
PHPAPI IDispatch *php_COM_export_as_sink(zval *val, GUID *sinkid, HashTable *id_to_name TSRMLS_DC);
int php_COM_dispatch_init(int module_number TSRMLS_DC);
zend_module_entry COM_module_entry;
zend_class_entry COM_class_entry;
@@ -43,6 +53,18 @@ END_EXTERN_C()
#define phpext_com_ptr &COM_module_entry
ZEND_BEGIN_MODULE_GLOBALS(com)
int nothing;
ZEND_END_MODULE_GLOBALS(com)
PHPAPI ZEND_EXTERN_MODULE_GLOBALS(com);
#ifdef ZTS
#define COMG(v) TSRMG(com_globals_id, zend_com_globals *, v)
#else
#define COMG(v) (com_globals.v)
#endif
#else
#define phpext_com_ptr NULL
+1
View File
@@ -181,6 +181,7 @@ static pval php_VARIANT_get_property_handler(zend_property_reference *property_r
case OE_IS_OBJECT:
if (!strcmp(Z_STRVAL(overloaded_property->element), "value")) {
// var_arg can't be an idispatch, so we don't care for the implicit AddRef() call here
php_variant_to_pval(var_arg, &result, codepage TSRMLS_CC);
} else if (!strcmp(Z_STRVAL(overloaded_property->element), "type")) {
ZVAL_LONG(&result, V_VT(var_arg))
+1 -1
View File
@@ -16,7 +16,7 @@
comval *obj; \
ALLOC_COM(obj); \
php_COM_set(obj, &V_DISPATCH(v), TRUE TSRMLS_CC); \
ZVAL_LONG((z), zend_list_insert(obj, IS_COM)); \
ZVAL_RESOURCE((z), zend_list_insert(obj, IS_COM)); \
} else { \
php_variant_to_pval((v), (z), codepage TSRMLS_CC); \
FREE_VARIANT(v); \
+8 -3
View File
@@ -56,12 +56,17 @@ if test "$PHP_XMLRPC" = "yes"; then
elif test "$PHP_XMLRPC" != "no"; then
if test -r $PHP_XMLRPC/include/xmlrpc.h; then
XMLRPC_DIR=$PHP_XMLRPC
XMLRPC_DIR=$PHP_XMLRPC/include
elif test -r $PHP_XMLRPC/include/xmlrpc-epi/xmlrpc.h; then
dnl some xmlrpc-epi header files have generic file names like
dnl queue.h or base64.h. Distributions have to create dir
dnl for xmlrpc-epi because of this.
XMLRPC_DIR=$PHP_XMLRPC/include/xmlrpc-epi
else
AC_MSG_CHECKING(for XMLRPC-EPI in default path)
for i in /usr/local /usr; do
if test -r $i/include/xmlrpc.h; then
XMLRPC_DIR=$i
XMLRPC_DIR=$i/include
AC_MSG_RESULT(found in $i)
fi
done
@@ -72,7 +77,7 @@ elif test "$PHP_XMLRPC" != "no"; then
AC_MSG_ERROR(Please reinstall the XMLRPC-EPI distribution)
fi
PHP_ADD_INCLUDE($XMLRPC_DIR/include)
PHP_ADD_INCLUDE($XMLRPC_DIR)
PHP_ADD_LIBRARY_WITH_PATH(xmlrpc, $XMLRPC_DIR/lib, XMLRPC_SHARED_LIBADD)
fi
+9
View File
@@ -30,6 +30,15 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef PHP_WIN32
#include <php_config.h>
#else
#include <config.w32.h>
#endif
static const char rcsid[] = "#(@) $Id$";
+2 -2
View File
@@ -1002,7 +1002,7 @@ PHP_FUNCTION(socket_bind)
RETURN_FALSE;
}
retval = bind(php_sock->bsd_socket, (struct sockaddr *)sa, sizeof(sa_storage));
retval = bind(php_sock->bsd_socket, (struct sockaddr *)sa, sizeof(struct sockaddr_in));
break;
}
@@ -1263,7 +1263,7 @@ PHP_FUNCTION(socket_recv)
zval_dtor(buf);
Z_TYPE_P(buf)=IS_NULL;
} else {
recv_buf[retval+1] = '\0';
recv_buf[retval] = '\0';
/* Rebuild buffer zval */
zval_dtor(buf);
+3 -11
View File
@@ -353,7 +353,7 @@ static int array_natural_general_compare(const void *a, const void *b, int fold_
convert_to_string(&first);
}
if (Z_TYPE_P(sval) != IS_STRING) {
zval_copy_ctor(&first);
zval_copy_ctor(&second);
convert_to_string(&second);
}
@@ -2545,7 +2545,7 @@ PHP_FUNCTION(array_diff)
/* for each argument, create and sort list with pointers to the hash buckets */
lists = (Bucket ***)emalloc(argc * sizeof(Bucket **));
ptrs = (Bucket ***)emalloc(argc * sizeof(Bucket **));
set_compare_func(SORT_STRING TSRMLS_CC);
set_compare_func(SORT_STRING TSRMLS_CC);
for (i=0; i<argc; i++) {
if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
php_error(E_WARNING, "Argument #%d to array_diff() is not an array", i+1);
@@ -2880,15 +2880,7 @@ PHP_FUNCTION(array_rand)
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(input), &pos);
while (num_req_val && (key_type = zend_hash_get_current_key_ex(Z_ARRVAL_PP(input), &string_key, &string_key_len, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTANT) {
#ifdef HAVE_RANDOM
randval = random();
#else
#ifdef HAVE_LRAND48
randval = lrand48();
#else
randval = rand();
#endif
#endif
randval = php_rand(TSRMLS_C);
if ((double)(randval/(PHP_RAND_MAX+1.0)) < (double)num_req_val/(double)num_avail) {
/* If we are returning a single result, just do it. */
+23 -2
View File
@@ -626,7 +626,7 @@ function_entry basic_functions[] = {
PHP_FALIAS(fopenstream, warn_not_available, NULL)
#endif
#if HAVE_SYS_TIME_H
#if HAVE_SYS_TIME_H || defined(PHP_WIN32)
PHP_FE(socket_set_timeout, NULL)
#else
PHP_FALIAS(socket_set_timeout, warn_not_available, NULL)
@@ -1085,6 +1085,9 @@ PHP_RINIT_FUNCTION(basic)
PHP_RINIT(syslog) (INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(dir) (INIT_FUNC_ARGS_PASSTHRU);
/* Reset magic_quotes_runtime */
PG(magic_quotes_runtime) = INI_BOOL("magic_quotes_runtime");
return SUCCESS;
}
@@ -1889,6 +1892,14 @@ PHP_FUNCTION(highlight_file)
}
convert_to_string(filename);
if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_P(filename), NULL, CHECKUID_ALLOW_ONLY_FILE))) {
RETURN_FALSE;
}
if (php_check_open_basedir(Z_STRVAL_P(filename) TSRMLS_CC)) {
RETURN_FALSE;
}
if (i) {
php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
}
@@ -2493,6 +2504,15 @@ PHP_FUNCTION(parse_ini_file)
}
convert_to_string_ex(filename);
if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(filename), NULL, CHECKUID_ALLOW_ONLY_FILE))) {
RETURN_FALSE;
}
if (php_check_open_basedir(Z_STRVAL_PP(filename) TSRMLS_CC)) {
RETURN_FALSE;
}
fh.handle.fp = VCWD_FOPEN(Z_STRVAL_PP(filename), "r");
if (!fh.handle.fp) {
php_error(E_WARNING, "Cannot open '%s' for reading", Z_STRVAL_PP(filename));
@@ -2525,7 +2545,8 @@ static int copy_request_variable(void *pDest, int num_args, va_list args, zend_h
memcpy(new_key, prefix, prefix_len);
memcpy(new_key+prefix_len, hash_key->arKey, hash_key->nKeyLength);
ZEND_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), new_key, new_key_len, *var, 0, 1);
zend_hash_del(&EG(symbol_table), new_key, new_key_len);
ZEND_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), new_key, new_key_len, *var, (*var)->refcount+1, 0);
efree(new_key);
return 0;
+1 -1
View File
@@ -90,7 +90,7 @@ CREDIT_LINE("Verisign Payflow Pro", "John Donagher, David Croft");
CREDIT_LINE("Vpopmail", "David Croft, Boian Bonev");
CREDIT_LINE("W32API", "James Moore");
CREDIT_LINE("WDDX", "Andrei Zmievski");
CREDIT_LINE("Win32 COM", "Zeev Suraski, Harald Radi, Alan Brown");
CREDIT_LINE("Win32 COM", "Alan Brown, Wez Furlong, Harald Radi, Zeev Suraski");
CREDIT_LINE("XML", "Stig Bakken, Thies C. Arntzen");
CREDIT_LINE("xmlrpc", "Dan Libby");
CREDIT_LINE("YAZ", "Adam Dickmeiss");
-1
View File
@@ -180,7 +180,6 @@ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject)
object_init_ex(return_value, dir_class_entry_ptr);
add_property_stringl(return_value, "path", Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), 1);
add_property_resource(return_value, "handle", dirp->id);
zend_list_addref(dirp->id);
} else {
RETURN_RESOURCE(dirp->id);
}
+2 -2
View File
@@ -878,7 +878,7 @@ PHP_FUNCTION(set_socket_blocking)
Set timeout on socket read to seconds + microseonds */
PHP_FUNCTION(socket_set_timeout)
{
#if HAVE_SYS_TIME_H
#if HAVE_SYS_TIME_H || defined(PHP_WIN32)
zval **socket, **seconds, **microseconds;
int type;
void *what;
@@ -1490,7 +1490,7 @@ PHP_FUNCTION(rmdir)
convert_to_string_ex(arg1);
if (PG(safe_mode) &&(!php_checkuid(Z_STRVAL_PP(arg1), NULL, CHECKUID_ALLOW_FILE_NOT_EXISTS))) {
if (PG(safe_mode) &&(!php_checkuid(Z_STRVAL_PP(arg1), NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
RETURN_FALSE;
}
+46 -25
View File
@@ -465,11 +465,11 @@ PHP_FUNCTION(chmod)
}
/* }}} */
#if HAVE_UTIME
/* {{{ proto bool touch(string filename [, int time [, int atime]])
Set modification time of file */
PHP_FUNCTION(touch)
{
#if HAVE_UTIME
pval **filename, **filetime, **fileatime;
int ret;
struct stat sb;
@@ -478,17 +478,15 @@ PHP_FUNCTION(touch)
struct utimbuf *newtime = NULL;
int ac = ZEND_NUM_ARGS();
newtime = &newtimebuf;
if (ac == 1 && zend_get_parameters_ex(1, &filename) != FAILURE) {
#ifndef HAVE_UTIME_NULL
newtime->modtime = newtime->actime = time(NULL);
#endif
} else if (ac == 2 && zend_get_parameters_ex(2, &filename, &filetime) != FAILURE) {
newtime = &newtimebuf;
convert_to_long_ex(filetime);
newtime->actime = time(NULL);
newtime->modtime = newtime->actime = Z_LVAL_PP(filetime);
} else if (ac == 3 && zend_get_parameters_ex(3, &filename, &filetime, &fileatime) != FAILURE) {
newtime = &newtimebuf;
convert_to_long_ex(fileatime);
convert_to_long_ex(filetime);
newtime->actime = Z_LVAL_PP(fileatime);
@@ -524,9 +522,9 @@ PHP_FUNCTION(touch)
RETURN_FALSE;
}
RETURN_TRUE;
#endif
}
/* }}} */
#endif
/* {{{ proto void clearstatcache(void)
Clear file stat cache */
@@ -539,7 +537,7 @@ PHP_FUNCTION(clearstatcache)
}
/* }}} */
#define IS_LINK_OPERATION() (type == 8 /* filetype */ || type == 14 /* is_link */ || type == 16 /* lstat */)
#define IS_LINK_OPERATION(__t) ((__t) == FS_TYPE || (__t) == FS_IS_LINK || (__t) == FS_LSTAT)
#define IS_EXISTS_CHECK(__t) ((__t) == FS_EXISTS || (__t) == FS_IS_W || (__t) == FS_IS_R || (__t) == FS_IS_X || (__t) == FS_IS_FILE || (__t) == FS_IS_DIR || (__t) == FS_IS_LINK)
/* {{{ php_stat
@@ -553,6 +551,27 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
char *stat_sb_names[13]={"dev", "ino", "mode", "nlink", "uid", "gid", "rdev",
"size", "atime", "mtime", "ctime", "blksize", "blocks"};
if (PG(safe_mode) &&(!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
RETURN_FALSE;
}
if (php_check_open_basedir(filename TSRMLS_CC)) {
RETURN_FALSE;
}
#ifndef PHP_WIN32
switch (type) {
case FS_IS_W:
RETURN_BOOL (!access (filename, W_OK));
case FS_IS_R:
RETURN_BOOL (!access (filename, R_OK));
case FS_IS_X:
RETURN_BOOL (!access (filename, X_OK));
case FS_EXISTS:
RETURN_BOOL (!access (filename, F_OK));
}
#endif
stat_sb = &BG(sb);
if (!BG(CurrentStatFile) || strcmp(filename, BG(CurrentStatFile))) {
@@ -569,22 +588,24 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
BG(lsb).st_mode = 0; /* mark lstat buf invalid */
#endif
if (VCWD_STAT(BG(CurrentStatFile), &BG(sb)) == -1) {
if (!IS_LINK_OPERATION() && (!IS_EXISTS_CHECK(type) || errno != ENOENT)) { /* fileexists() test must print no error */
if (!IS_LINK_OPERATION(type) && (!IS_EXISTS_CHECK(type) || errno != ENOENT)) { /* fileexists() test must print no error */
php_error(E_WARNING, "stat failed for %s (errno=%d - %s)", BG(CurrentStatFile), errno, strerror(errno));
}
efree(BG(CurrentStatFile));
BG(CurrentStatFile) = NULL;
if (!IS_LINK_OPERATION()) { /* Don't require success for link operation */
if (!IS_LINK_OPERATION(type)) { /* Don't require success for link operation */
RETURN_FALSE;
}
}
}
#if HAVE_SYMLINK
if (IS_LINK_OPERATION() && !BG(lsb).st_mode) {
if (IS_LINK_OPERATION(type) && !BG(lsb).st_mode) {
/* do lstat if the buffer is empty */
if (VCWD_LSTAT(filename, &BG(lsb)) == -1) {
php_error(E_WARNING, "lstat failed for %s (errno=%d - %s)", filename, errno, strerror(errno));
if (!IS_EXISTS_CHECK(type) || errno != ENOENT) { /* fileexists() test must print no error */
php_error(E_WARNING, "lstat failed for %s (errno=%d - %s)", BG(CurrentStatFile), errno, strerror(errno));
}
RETURN_FALSE;
}
}
@@ -658,26 +679,26 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ
RETURN_STRING("unknown", 1);
case FS_IS_W:
if (getuid()==0) {
RETURN_LONG(1); /* root */
RETURN_TRUE; /* root */
}
RETURN_LONG((BG(sb).st_mode & wmask) != 0);
RETURN_BOOL((BG(sb).st_mode & wmask) != 0);
case FS_IS_R:
if (getuid()==0) {
RETURN_LONG(1); /* root */
RETURN_TRUE; /* root */
}
RETURN_LONG((BG(sb).st_mode&rmask)!=0);
RETURN_BOOL((BG(sb).st_mode&rmask)!=0);
case FS_IS_X:
if (getuid()==0) {
xmask = S_IXROOT; /* root */
}
RETURN_LONG((BG(sb).st_mode&xmask)!=0 && !S_ISDIR(BG(sb).st_mode));
RETURN_BOOL((BG(sb).st_mode&xmask)!=0 && !S_ISDIR(BG(sb).st_mode));
case FS_IS_FILE:
RETURN_LONG(S_ISREG(BG(sb).st_mode));
RETURN_BOOL(S_ISREG(BG(sb).st_mode));
case FS_IS_DIR:
RETURN_LONG(S_ISDIR(BG(sb).st_mode));
RETURN_BOOL(S_ISDIR(BG(sb).st_mode));
case FS_IS_LINK:
#if HAVE_SYMLINK
RETURN_LONG(S_ISLNK(BG(lsb).st_mode));
RETURN_BOOL(S_ISLNK(BG(lsb).st_mode));
#else
RETURN_FALSE;
#endif
@@ -812,32 +833,32 @@ FileFunction(PHP_FN(filectime), FS_CTIME)
FileFunction(PHP_FN(filetype), FS_TYPE)
/* }}} */
/* {{{ proto int is_writable(string filename)
/* {{{ proto bool is_writable(string filename)
Returns true if file can be written */
FileFunction(PHP_FN(is_writable), FS_IS_W)
/* }}} */
/* {{{ proto int is_readable(string filename)
/* {{{ proto bool is_readable(string filename)
Returns true if file can be read */
FileFunction(PHP_FN(is_readable), FS_IS_R)
/* }}} */
/* {{{ proto int is_executable(string filename)
/* {{{ proto bool is_executable(string filename)
Returns true if file is executable */
FileFunction(PHP_FN(is_executable), FS_IS_X)
/* }}} */
/* {{{ proto int is_file(string filename)
/* {{{ proto bool is_file(string filename)
Returns true if file is a regular file */
FileFunction(PHP_FN(is_file), FS_IS_FILE)
/* }}} */
/* {{{ proto int is_dir(string filename)
/* {{{ proto bool is_dir(string filename)
Returns true if file is directory */
FileFunction(PHP_FN(is_dir), FS_IS_DIR)
/* }}} */
/* {{{ proto int is_link(string filename)
/* {{{ proto bool is_link(string filename)
Returns true if file is symbolic link */
FileFunction(PHP_FN(is_link), FS_IS_LINK)
/* }}} */
+1 -1
View File
@@ -121,7 +121,7 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
strcat(cookie, "; secure");
}
return sapi_add_header(cookie, strlen(cookie), 0);
return sapi_add_header_ex(cookie, strlen(cookie), 0, 0 TSRMLS_CC);
}
+3
View File
@@ -135,6 +135,9 @@ FILE *php_fopen_url_wrap_http(const char *path, char *mode, int options, int *is
/* send authorization header if we have user/pass */
if (resource->user != NULL && resource->pass != NULL) {
php_url_decode(resource->user, strlen(resource->user));
php_url_decode(resource->pass, strlen(resource->pass));
scratch = (char *) emalloc(strlen(resource->user) + strlen(resource->pass) + 2);
if (!scratch) {
php_url_free(resource);
+24
View File
@@ -114,6 +114,18 @@ PHP_FUNCTION(symlink)
RETURN_FALSE;
}
if (PG(safe_mode) && !php_checkuid(Z_STRVAL_PP(frompath), NULL, CHECKUID_CHECK_FILE_AND_DIR)) {
RETURN_FALSE;
}
if (php_check_open_basedir(Z_STRVAL_PP(topath) TSRMLS_CC)) {
RETURN_FALSE;
}
if (php_check_open_basedir(Z_STRVAL_PP(frompath) TSRMLS_CC)) {
RETURN_FALSE;
}
if (!strncasecmp(Z_STRVAL_PP(topath), "http://", 7) || !strncasecmp(Z_STRVAL_PP(topath), "ftp://", 6)) {
php_error(E_WARNING, "Unable to symlink to a URL");
RETURN_FALSE;
@@ -146,6 +158,18 @@ PHP_FUNCTION(link)
RETURN_FALSE;
}
if (PG(safe_mode) && !php_checkuid(Z_STRVAL_PP(frompath), NULL, CHECKUID_CHECK_FILE_AND_DIR)) {
RETURN_FALSE;
}
if (php_check_open_basedir(Z_STRVAL_PP(topath) TSRMLS_CC)) {
RETURN_FALSE;
}
if (php_check_open_basedir(Z_STRVAL_PP(frompath) TSRMLS_CC)) {
RETURN_FALSE;
}
if (!strncasecmp(Z_STRVAL_PP(topath), "http://", 7) || !strncasecmp(Z_STRVAL_PP(topath), "ftp://", 6)) {
php_error(E_WARNING, "Unable to link to a URL");
RETURN_FALSE;
+19 -7
View File
@@ -70,8 +70,12 @@ PHP_FUNCTION(ezmlm_hash)
PHP_FUNCTION(mail)
{
char *to=NULL, *message=NULL, *headers=NULL, *subject=NULL, *extra_cmd=NULL;
int to_len,message_len,headers_len,subject_len,extra_cmd_len;
int to_len,message_len,headers_len,subject_len,extra_cmd_len,i;
if (PG(safe_mode) && (ZEND_NUM_ARGS() == 5)) {
php_error(E_WARNING, "%s(): SAFE MODE Restriction in effect. The fifth parameter is disabled in SAFE MODE.", get_active_function_name(TSRMLS_C));
RETURN_FALSE;
}
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|ss",
&to, &to_len,
@@ -83,14 +87,22 @@ PHP_FUNCTION(mail)
return;
}
for(to_len--;to_len;to_len--) {
if(!isspace(to[to_len]))break;
to[to_len]='\0';
if (to_len > 0) {
for(to_len--;to_len;to_len--) {
if(!isspace((unsigned char)to[to_len]))break;
to[to_len]='\0';
}
for(i=0;!iscntrl((unsigned char)to[i]);i++) {}
to[i]='\0';
}
for(subject_len--;subject_len;subject_len--) {
if(!isspace(subject[subject_len]))break;
subject[subject_len]='\0';
if (subject_len > 0) {
for(subject_len--;subject_len;subject_len--) {
if(!isspace((unsigned char)subject[subject_len]))break;
subject[subject_len]='\0';
}
for(i=0;!iscntrl((unsigned char)subject[i]);i++) {}
subject[i]='\0';
}
if(extra_cmd)
+13 -9
View File
@@ -429,14 +429,11 @@ PHP_FUNCTION(pow)
return;
}
/* TODO: handle numeric strings. */
if ((Z_TYPE_P(zbase) != IS_LONG && Z_TYPE_P(zbase) != IS_DOUBLE) ||
(Z_TYPE_P(zexp ) != IS_LONG && Z_TYPE_P(zexp ) != IS_DOUBLE)) {
php_error(E_WARNING, "Invalid argument(s) passed to %s()", get_active_function_name(TSRMLS_C));
RETURN_FALSE;
}
/* make sure we're dealing with numbers */
convert_scalar_to_number(zbase TSRMLS_CC);
convert_scalar_to_number(zexp TSRMLS_CC);
/* if both base and exponent were longs, try to get a long out */
/* if both base and exponent were longs, we'll try to get a long out */
wantlong = Z_TYPE_P(zbase) == IS_LONG
&& Z_TYPE_P(zexp ) == IS_LONG && Z_LVAL_P(zexp) >= 0;
@@ -760,7 +757,7 @@ _php_math_longtobase(zval *arg, int base)
* the number.
*/
PHPAPI char *
_php_math_zvaltobase(zval *arg, int base)
_php_math_zvaltobase(zval *arg, int base TSRMLS_DC)
{
static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
@@ -773,6 +770,13 @@ _php_math_zvaltobase(zval *arg, int base)
char *ptr, *end;
char buf[(sizeof(double) << 3) + 1];
/* Don't try to convert +/- infinity */
if (fvalue == HUGE_VAL || fvalue == -HUGE_VAL) {
php_error(E_WARNING, "Number too large in %s() call",
get_active_function_name(TSRMLS_C));
return empty_string;
}
end = ptr = buf + sizeof(buf) - 1;
*ptr = '\0';
@@ -933,7 +937,7 @@ PHP_FUNCTION(base_convert)
if(_php_math_basetozval(*number, Z_LVAL_PP(frombase), &temp) != SUCCESS) {
RETURN_FALSE;
}
result = _php_math_zvaltobase(&temp, Z_LVAL_PP(tobase));
result = _php_math_zvaltobase(&temp, Z_LVAL_PP(tobase) TSRMLS_CC);
RETVAL_STRING(result, 0);
}
+5 -1
View File
@@ -209,6 +209,9 @@ PHP_FUNCTION(pack)
break;
default:
efree(argv);
efree(formatcodes);
efree(formatargs);
php_error(E_WARNING, "pack type %c: unknown format code", code);
RETURN_FALSE;
}
@@ -518,7 +521,7 @@ PHP_FUNCTION(unpack)
inputpos = 0;
if (array_init(return_value) == FAILURE)
return;
RETURN_FALSE;
while (formatlen-- > 0) {
char type = *(format++);
@@ -809,6 +812,7 @@ PHP_FUNCTION(unpack)
break;
} else {
php_error(E_WARNING, "pack type %c: not enough input, need %d, have %d", type, size, inputlen - inputpos);
zval_dtor(return_value);
RETURN_FALSE;
}
}
+2
View File
@@ -341,6 +341,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
while (*walk)
if ('\\' == *walk
&& '0' <= walk[1] && '9' >= walk[1]
&& walk[1] - '0' <= ((char) re.re_nsub)
&& subs[walk[1] - '0'].rm_so > -1
&& subs[walk[1] - '0'].rm_eo > -1) {
new_l += subs[walk[1] - '0'].rm_eo
@@ -368,6 +369,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
while (*walk)
if ('\\' == *walk
&& '0' <= walk[1] && '9' >= walk[1]
&& walk[1] - '0' <= re.re_nsub
&& subs[walk[1] - '0'].rm_so > -1
&& subs[walk[1] - '0'].rm_eo > -1
/* this next case shouldn't happen. it does. */
+14 -7
View File
@@ -1811,7 +1811,7 @@ PHP_FUNCTION(ucfirst)
convert_to_string_ex(str);
if (!Z_STRLEN_PP(str)) {
RETURN_FALSE;
RETURN_EMPTY_STRING();
}
ZVAL_STRINGL(return_value, Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1);
@@ -1832,7 +1832,7 @@ PHP_FUNCTION(ucwords)
convert_to_string_ex(str);
if (!Z_STRLEN_PP(str)) {
RETURN_FALSE;
RETURN_EMPTY_STRING();
}
ZVAL_STRINGL(return_value, Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1);
@@ -2118,7 +2118,6 @@ PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC)
{
char *s, *t;
int l;
char escape_char='\\';
if (len != NULL) {
l = *len;
@@ -2129,7 +2128,7 @@ PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC)
t = str;
if (PG(magic_quotes_sybase)) {
while (l >= 0) {
while (l > 0) {
if(*t=='\'') {
if((l>0) && (t[1]=='\'')) {
t++;
@@ -2137,8 +2136,16 @@ PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC)
(*len)--;
l--;
}
}
*s++ = *t++;
*s++ = *t++;
} else if (*t=='\\' && l>0 && t[1]=='0') {
*s++='\0';
t += 2;
if (len != NULL)
(*len)--;
l--;
} else {
*s++ = *t++;
}
l--;
}
*s = '\0';
@@ -2148,7 +2155,7 @@ PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC)
while (l > 0) {
if (*t == escape_char) {
if (*t == '\\') {
t++; /* skip the slash */
if (len != NULL)
(*len)--;
+1
View File
@@ -1,4 +1,5 @@
<?php
ini_set('precision',14);
$tmp = pow(2,64);
$data = array(
'PHP',
+18 -7
View File
@@ -1,4 +1,4 @@
/* Generated by re2c 0.5 on Sun Apr 28 19:59:39 2002 */
/* Generated by re2c 0.5 on Tue Aug 20 21:45:31 2002 */
#line 1 "var_unserializer.re"
#include "php.h"
#include "ext/standard/php_var.h"
@@ -575,13 +575,24 @@ yy45: yych = *++YYCURSOR;
yy46: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy47: if(yych <= '/'){
if(yych == '.') goto yy58;
goto yy2;
yy47: if(yych <= ':'){
if(yych <= '.'){
if(yych <= '-') goto yy2;
goto yy58;
} else {
if(yych <= '/') goto yy2;
if(yych <= '9') goto yy46;
goto yy2;
}
} else {
if(yych <= '9') goto yy46;
if(yych == ';') goto yy51;
goto yy2;
if(yych <= 'E'){
if(yych <= ';') goto yy51;
if(yych <= 'D') goto yy2;
goto yy53;
} else {
if(yych == 'e') goto yy53;
goto yy2;
}
}
yy48: yych = *++YYCURSOR;
if(yych <= '/') goto yy2;
+1 -1
View File
@@ -92,7 +92,7 @@ void var_destroy(php_unserialize_data_t *var_hashx)
/*!re2c
iv = [+-]? [0-9]+;
nv = [+-]? ([0-9]* "." [0-9]+|[0-9]+ "." [0-9]+);
nvexp = nv [eE] [+-]? iv;
nvexp = (iv | nv) [eE] [+-]? iv;
any = [\000-\277];
*/
+17 -8
View File
@@ -105,12 +105,21 @@ compare_special_version_forms(const char *form1, const char *form2)
PHPAPI int
php_version_compare(const char *orig_ver1, const char *orig_ver2)
{
char *ver1 = php_canonicalize_version(orig_ver1);
char *ver2 = php_canonicalize_version(orig_ver2);
char *ver1;
char *ver2;
char *p1, *p2, *n1, *n2;
long l1, l2;
int compare = 0;
if (!*orig_ver1 || !*orig_ver2) {
if (!*orig_ver1 && !*orig_ver2) {
return 0;
} else {
return *orig_ver1 ? 1 : -1;
}
}
ver1 = php_canonicalize_version(orig_ver1);
ver2 = php_canonicalize_version(orig_ver2);
p1 = n1 = ver1;
p2 = n2 = ver2;
while (*p1 && *p2 && n1 && n2) {
@@ -187,22 +196,22 @@ PHP_FUNCTION(version_compare)
if (argc == 2) {
RETURN_LONG(compare);
}
if (!strcmp(op, "<") || !strcmp(op, "lt")) {
if (!strncmp(op, "<", op_len) || !strncmp(op, "lt", op_len)) {
RETURN_BOOL(compare == -1);
}
if (!strcmp(op, "<=") || !strcmp(op, "le")) {
if (!strncmp(op, "<=", op_len) || !strncmp(op, "le", op_len)) {
RETURN_BOOL(compare != 1);
}
if (!strcmp(op, ">") || !strcmp(op, "gt")) {
if (!strncmp(op, ">", op_len) || !strncmp(op, "gt", op_len)) {
RETURN_BOOL(compare == 1);
}
if (!strcmp(op, ">=") || !strcmp(op, "ge")) {
if (!strncmp(op, ">=", op_len) || !strncmp(op, "ge", op_len)) {
RETURN_BOOL(compare != -1);
}
if (!strcmp(op, "==") || !strcmp(op, "=") || !strcmp(op, "eq")) {
if (!strncmp(op, "==", op_len) || !strncmp(op, "=", op_len) || !strncmp(op, "eq", op_len)) {
RETURN_BOOL(compare == 0);
}
if (!strcmp(op, "!=") || !strcmp(op, "<>") || !strcmp(op, "ne")) {
if (!strncmp(op, "!=", op_len) || !strncmp(op, "<>", op_len) || !strncmp(op, "ne", op_len)) {
RETURN_BOOL(compare != 0);
}
RETURN_NULL();
+1
View File
@@ -41,6 +41,7 @@ typedef struct {
int key; /* For error reporting. */
int semid; /* Returned by semget(). */
int count; /* Acquire count for auto-release. */
int auto_release; /* flag that says to auto-release. */
} sysvsem_sem;
extern sysvsem_module php_sysvsem_module;
+26 -49
View File
@@ -108,12 +108,14 @@ static void release_sysvsem_sem(zend_rsrc_list_entry *rsrc TSRMLS_DC)
sysvsem_sem *sem_ptr = (sysvsem_sem *)rsrc->ptr;
struct sembuf sop[2];
int opcount = 1;
/*
* if count == -1, semaphore has been removed
* Need better way to handle this
*/
if(sem_ptr->count == -1) {
if(sem_ptr->count == -1 || !sem_ptr->auto_release) {
return;
}
/* Decrement the usage count. */
@@ -130,8 +132,10 @@ static void release_sysvsem_sem(zend_rsrc_list_entry *rsrc TSRMLS_DC)
sop[1].sem_num = SYSVSEM_SEM;
sop[1].sem_op = sem_ptr->count;
sop[1].sem_flg = SEM_UNDO;
opcount++;
}
if (semop(sem_ptr->semid, sop, sem_ptr->count ? 2 : 1) == -1) {
if (semop(sem_ptr->semid, sop, opcount) == -1) {
php_error(E_WARNING, "semop() failed in release_sysvsem_sem for key 0x%x: %s", sem_ptr->key, strerror(errno));
}
@@ -154,12 +158,11 @@ PHP_MINIT_FUNCTION(sysvsem)
#undef SETVAL_WANTS_PTR
#endif
/* {{{ proto int sem_get(int key [, int max_acquire [, int perm]])
/* {{{ proto int sem_get(int key [, int max_acquire [, int perm [, int auto_release]]])
Return an id for the semaphore with the given key, and allow max_acquire (default 1) processes to acquire it simultaneously */
PHP_FUNCTION(sem_get)
{
pval **arg_key, **arg_max_acquire, **arg_perm;
int key, max_acquire, perm;
int key, max_acquire, perm, auto_release = 1;
int semid;
struct sembuf sop[3];
int count;
@@ -171,37 +174,8 @@ PHP_FUNCTION(sem_get)
max_acquire = 1;
perm = 0666;
switch (ZEND_NUM_ARGS()) {
case 1:
if (zend_get_parameters_ex(1, &arg_key)==FAILURE) {
RETURN_FALSE;
}
convert_to_long_ex(arg_key);
key = (int)Z_LVAL_PP(arg_key);
break;
case 2:
if (zend_get_parameters_ex(2, &arg_key, &arg_max_acquire)==FAILURE) {
RETURN_FALSE;
}
convert_to_long_ex(arg_key);
key = (int)Z_LVAL_PP(arg_key);
convert_to_long_ex(arg_max_acquire);
max_acquire = (int)Z_LVAL_PP(arg_max_acquire);
break;
case 3:
if (zend_get_parameters_ex(3, &arg_key, &arg_max_acquire, &arg_perm)==FAILURE) {
RETURN_FALSE;
}
convert_to_long_ex(arg_key);
convert_to_long_ex(arg_max_acquire);
convert_to_long_ex(arg_perm);
key = (int)Z_LVAL_PP(arg_key);
max_acquire = (int)Z_LVAL_PP(arg_max_acquire);
perm = (int)Z_LVAL_PP(arg_perm);
break;
default:
WRONG_PARAM_COUNT;
break;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|lll", &key, &max_acquire, &perm, &auto_release)) {
RETURN_FALSE;
}
/* Get/create the semaphore. Note that we rely on the semaphores
@@ -298,6 +272,7 @@ PHP_FUNCTION(sem_get)
sem_ptr->key = key;
sem_ptr->semid = semid;
sem_ptr->count = 0;
sem_ptr->auto_release = auto_release;
Z_LVAL_P(return_value) = zend_list_insert(sem_ptr, php_sysvsem_module.le_sem);
Z_TYPE_P(return_value) = IS_LONG;
@@ -382,11 +357,12 @@ PHP_FUNCTION(sem_release)
PHP_FUNCTION(sem_remove)
{
pval **arg_id;
int id,type;
pval **arg_id;
int id,type;
sysvsem_sem *sem_ptr;
#if HAVE_SEMUN
union semun un;
struct semid_ds buf;
#endif
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_id) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -403,29 +379,30 @@ PHP_FUNCTION(sem_remove)
}
#if HAVE_SEMUN
if(semctl(sem_ptr->semid,NULL,IPC_STAT,un)<0) {
un.buf = &buf;
if(semctl(sem_ptr->semid, 0, IPC_STAT, &un) < 0) {
#else
if(semctl(sem_ptr->semid,NULL,IPC_STAT,NULL)<0) {
if(semctl(sem_ptr->semid, 0, IPC_STAT, NULL) < 0) {
#endif
php_error(E_WARNING, "%d is not a existing SysV Semaphore Id", id);
RETURN_FALSE;
}
php_error(E_WARNING, "%d is not a existing SysV Semaphore Id", id);
RETURN_FALSE;
}
#if HAVE_SEMUN
if(semctl(sem_ptr->semid,NULL,IPC_RMID,un)<0) {
if(semctl(sem_ptr->semid, 0, IPC_RMID, &un) < 0) {
#else
if(semctl(sem_ptr->semid,NULL,IPC_RMID,NULL)<0) {
if(semctl(sem_ptr->semid, 0, IPC_RMID, NULL) < 0) {
#endif
php_error(E_WARNING, "sem_remove() failed for id %d: %s", id, strerror(errno));
RETURN_FALSE;
}
php_error(E_WARNING, "sem_remove() failed for id %d: %s", id, strerror(errno));
RETURN_FALSE;
}
/* let release_sysvsem_sem know we have removed
* the semaphore to avoid issues with releasing.
*/
sem_ptr->count = -1;
RETURN_TRUE;
RETURN_TRUE;
}
/* }}} */
+2 -1
View File
@@ -478,7 +478,7 @@ PHP_FUNCTION(token_get_all)
if (zend_parse_parameters(argc TSRMLS_CC, "s", &source, &source_len) == FAILURE)
return;
ZVAL_STRINGL(&source_z, source, source_len, 0);
ZVAL_STRINGL(&source_z, source, source_len, 1);
zend_save_lexical_state(&original_lex_state TSRMLS_CC);
if (zend_prepare_string_for_scanning(&source_z, "" TSRMLS_CC) == FAILURE) {
@@ -488,6 +488,7 @@ PHP_FUNCTION(token_get_all)
tokenize(return_value TSRMLS_CC);
zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
zval_dtor(&source_z);
}
/* }}} */
-1
View File
@@ -262,7 +262,6 @@ PHP_FUNCTION(vpopmail_add_alias_domain)
php_strtolower(Z_STRVAL_PP(domain), Z_STRLEN_PP(domain));
php_strtolower(Z_STRVAL_PP(aliasdomain), Z_STRLEN_PP(aliasdomain));
TSRMLS_FETCH();
VPOPMAILG(vpopmail_open) = 1;
tmpstr = vget_assign(Z_STRVAL_PP(domain), Dir, 156, &uid, &gid);
+8 -3
View File
@@ -56,12 +56,17 @@ if test "$PHP_XMLRPC" = "yes"; then
elif test "$PHP_XMLRPC" != "no"; then
if test -r $PHP_XMLRPC/include/xmlrpc.h; then
XMLRPC_DIR=$PHP_XMLRPC
XMLRPC_DIR=$PHP_XMLRPC/include
elif test -r $PHP_XMLRPC/include/xmlrpc-epi/xmlrpc.h; then
dnl some xmlrpc-epi header files have generic file names like
dnl queue.h or base64.h. Distributions have to create dir
dnl for xmlrpc-epi because of this.
XMLRPC_DIR=$PHP_XMLRPC/include/xmlrpc-epi
else
AC_MSG_CHECKING(for XMLRPC-EPI in default path)
for i in /usr/local /usr; do
if test -r $i/include/xmlrpc.h; then
XMLRPC_DIR=$i
XMLRPC_DIR=$i/include
AC_MSG_RESULT(found in $i)
fi
done
@@ -72,7 +77,7 @@ elif test "$PHP_XMLRPC" != "no"; then
AC_MSG_ERROR(Please reinstall the XMLRPC-EPI distribution)
fi
PHP_ADD_INCLUDE($XMLRPC_DIR/include)
PHP_ADD_INCLUDE($XMLRPC_DIR)
PHP_ADD_LIBRARY_WITH_PATH(xmlrpc, $XMLRPC_DIR/lib, XMLRPC_SHARED_LIBADD)
fi
+9
View File
@@ -30,6 +30,15 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef PHP_WIN32
#include <php_config.h>
#else
#include <config.w32.h>
#endif
static const char rcsid[] = "#(@) $Id$";
+2 -4
View File
@@ -1247,11 +1247,8 @@ PHP_FUNCTION(ob_gzhandler)
|| zend_hash_find(&EG(symbol_table), "HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS"), (void **) &data)==FAILURE
|| Z_TYPE_PP(data)!=IS_ARRAY
|| zend_hash_find(Z_ARRVAL_PP(data), "HTTP_ACCEPT_ENCODING", sizeof("HTTP_ACCEPT_ENCODING"), (void **) &a_encoding)==FAILURE) {
/* return the original string */
*return_value = **zv_string;
zval_copy_ctor(return_value);
ZLIBG(ob_gzhandler_status)=-1;
return;
RETURN_FALSE;
}
convert_to_string_ex(a_encoding);
if (php_memnstr(Z_STRVAL_PP(a_encoding), "gzip", 4, Z_STRVAL_PP(a_encoding) + Z_STRLEN_PP(a_encoding))) {
@@ -1259,6 +1256,7 @@ PHP_FUNCTION(ob_gzhandler)
} else if(php_memnstr(Z_STRVAL_PP(a_encoding), "deflate", 7, Z_STRVAL_PP(a_encoding) + Z_STRLEN_PP(a_encoding))) {
coding = CODING_DEFLATE;
} else {
ZLIBG(ob_gzhandler_status)=-1;
RETURN_FALSE;
}
+40 -15
View File
@@ -27,7 +27,7 @@
#include "SAPI.h"
#include "ext/standard/php_string.h"
#include "ext/standard/pageinfo.h"
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
#if (HAVE_PCRE || HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE)
#include "ext/pcre/php_pcre.h"
#endif
#ifdef ZTS
@@ -284,6 +284,7 @@ SAPI_API void sapi_activate(TSRMLS_D)
SG(sapi_headers).http_response_code = 200;
*/
SG(sapi_headers).http_status_line = NULL;
SG(sapi_headers).mimetype = NULL;
SG(headers_sent) = 0;
SG(read_post_bytes) = 0;
SG(request_info).post_data = NULL;
@@ -385,12 +386,17 @@ static int sapi_extract_response_code(const char *header_line)
return code;
}
static int sapi_find_matching_header(void *element1, void *element2)
{
return strncasecmp(((sapi_header_struct*)element1)->header, (char*)element2, strlen((char*)element2)) == 0;
}
/* This function expects a *duplicated* string, that was previously emalloc()'d.
* Pointers sent to this functions will be automatically freed by the framework.
*/
SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bool duplicate, zend_bool replace TSRMLS_DC)
{
int retval, free_header = 0;
int retval;
sapi_header_struct sapi_header;
char *colon_offset;
long myuid = 0L;
@@ -436,13 +442,17 @@ SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bo
if (colon_offset) {
*colon_offset = 0;
if (!STRCASECMP(header_line, "Content-Type")) {
char *ptr = colon_offset, *mimetype = NULL, *newheader;
char *ptr = colon_offset+1, *mimetype = NULL, *newheader;
size_t len = header_line_len - (ptr - header_line), newlen;
while (*ptr == ' ' && *ptr != '\0') {
ptr++;
}
mimetype = estrdup(ptr);
newlen = sapi_apply_default_charset(&mimetype, len TSRMLS_CC);
if (!SG(sapi_headers).mimetype){
SG(sapi_headers).mimetype = estrdup(mimetype);
}
if (newlen != 0) {
newlen += sizeof("Content-type: ");
newheader = emalloc(newlen);
@@ -452,8 +462,9 @@ SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bo
sapi_header.header_len = newlen - 1;
colon_offset = strchr(newheader, ':');
*colon_offset = '\0';
free_header = 1;
efree(header_line);
}
efree(mimetype);
SG(sapi_headers).send_default_content_type = 0;
} else if (!STRCASECMP(header_line, "Location")) {
@@ -465,15 +476,16 @@ SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bo
} else if (!STRCASECMP(header_line, "WWW-Authenticate")) { /* HTTP Authentication */
int newlen;
char *result, *newheader;
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
zval *repl_temp;
char *ptr = colon_offset+1;
int ptr_len=0, result_len = 0;
#endif
SG(sapi_headers).http_response_code = 401; /* authentication-required */
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
if(PG(safe_mode)) {
if(PG(safe_mode))
#if (HAVE_PCRE || HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE)
{
zval *repl_temp;
char *ptr = colon_offset+1;
int ptr_len=0, result_len = 0;
myuid = php_getuid();
ptr_len = strlen(ptr);
@@ -524,7 +536,7 @@ SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bo
efree(repl_temp);
}
#else
if(PG(safe_mode)) {
{
myuid = php_getuid();
result = emalloc(32);
newlen = sprintf(result, "WWW-Authenticate: %ld", myuid);
@@ -551,11 +563,21 @@ SAPI_API int sapi_add_header_ex(char *header_line, uint header_line_len, zend_bo
zend_llist_clean(&SG(sapi_headers).headers);
}
if (retval & SAPI_HEADER_ADD) {
/* in replace mode first remove the header if it already exists in the headers llist */
if (replace) {
colon_offset = strchr(sapi_header.header, ':');
if (colon_offset) {
char sav;
colon_offset++;
sav = *colon_offset;
*colon_offset = 0;
zend_llist_del_element(&SG(sapi_headers).headers, sapi_header.header, (int(*)(void*, void*))sapi_find_matching_header);
*colon_offset = sav;
}
}
zend_llist_add_element(&SG(sapi_headers).headers, (void *) &sapi_header);
}
if (free_header) {
efree(sapi_header.header);
}
return SUCCESS;
}
@@ -612,6 +634,9 @@ SAPI_API int sapi_send_headers(TSRMLS_D)
if (SG(sapi_headers).http_status_line) {
efree(SG(sapi_headers).http_status_line);
}
if (SG(sapi_headers).mimetype) {
efree(SG(sapi_headers).mimetype);
}
return ret;
}
+1
View File
@@ -51,6 +51,7 @@ typedef struct {
zend_llist headers;
int http_response_code;
unsigned char send_default_content_type;
char *mimetype;
char *http_status_line;
} sapi_headers_struct;
+4 -4
View File
@@ -137,7 +137,7 @@ int php_shutdown_fopen_wrappers(TSRMLS_D)
When open_basedir is NULL, always return 0
*/
PHPAPI int php_check_specific_open_basedir(char *basedir, char *path TSRMLS_DC)
PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path TSRMLS_DC)
{
char resolved_name[MAXPATHLEN];
char resolved_basedir[MAXPATHLEN];
@@ -184,7 +184,7 @@ PHPAPI int php_check_specific_open_basedir(char *basedir, char *path TSRMLS_DC)
/* {{{ php_check_open_basedir
*/
PHPAPI int php_check_open_basedir(char *path TSRMLS_DC)
PHPAPI int php_check_open_basedir(const char *path TSRMLS_DC)
{
/* Only check when open_basedir is available */
if (PG(open_basedir) && *PG(open_basedir)) {
@@ -268,7 +268,7 @@ PHPAPI int php_check_safe_mode_include_dir(char *path TSRMLS_DC)
}
/* Nothing to check... */
return 0;
return -1;
}
/* }}} */
@@ -441,7 +441,7 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **
}
filename_length = strlen(filename);
/* Relative path open */
if (*filename == '.') {
if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) {
+2 -2
View File
@@ -71,8 +71,8 @@ PHPAPI FILE *php_fopen_wrapper(char *filename, char *mode, int options, int *iss
PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC);
PHPAPI char *expand_filepath(const char *filepath, char *real_path TSRMLS_DC);
PHPAPI int php_check_open_basedir(char *path TSRMLS_DC);
PHPAPI int php_check_specific_open_basedir(char *basedir, char *path TSRMLS_DC);
PHPAPI int php_check_open_basedir(const char *path TSRMLS_DC);
PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path TSRMLS_DC);
PHPAPI int php_check_safe_mode_include_dir(char *path TSRMLS_DC);
Loaded 100 of 129 files, more files were not shown because too many files have changed in this diff. Show more