Compare commits

...
155 Commits
Author SHA1 Message Date
SVN Migration 095b48f772 This commit was manufactured by cvs2svn to create tag 'php_5_0_1'. 2004-08-12 20:39:37 +00:00
Andi Gutmans d8c1e99f02 - Roll 5.0.1 2004-08-12 20:39:36 +00:00
Chuck Hagenbuch 8d0cc271bf More spaces -> tabs. 2004-08-12 19:32:18 +00:00
Ilia Alshanetsky bbde60d6d2 MFH: Properly fix the msgno check inside imap_fetchbody(). 2004-08-12 19:20:17 +00:00
Chuck Hagenbuch e2b820f0ea MFH: fix. 2004-08-12 18:02:03 +00:00
Derick Rethans c970dbb647 - Reorder a bit and add . 2004-08-12 07:25:32 +00:00
Andi Gutmans 29c32f04e3 - Back to -dev 2004-08-12 06:39:26 +00:00
Andi Gutmans 00c6777aa1 - 5.0.1RC2 2004-08-12 06:35:22 +00:00
Magnus M��tt� 143ae77156 Add missing NEWS entry (bug 29147). 2004-08-12 05:42:13 +00:00
Marcus Boerger 87ba25b722 MFH: Change to use md5_file() 2004-08-12 00:38:12 +00:00
Ilia Alshanetsky dc77b5700c MFH: Fixed memory leak. 2004-08-11 23:25:52 +00:00
Ilia Alshanetsky 0e5c01290d Fixed bug #29607 (highlighting code with HEREDOC produces invalid output). 2004-08-11 22:38:31 +00:00
Derick Rethans ba16543ef5 - Tix Fypo 2004-08-11 15:23:00 +00:00
Derick Rethans f65e4feda4 - MFH: Added a notice to getimagesize in case zlib is not available and a
compressed SWF movie has been passed to the function.
2004-08-11 12:31:37 +00:00
Derick Rethans 20181fde3d - Reworded this a bit 2004-08-11 12:24:41 +00:00
Christian Stocker 491ed1813e MFH (fix test) 2004-08-11 08:24:41 +00:00
Derick Rethans caa5dbe679 - MFH: Patch to allow the Zend memory allocators to be disabled. 2004-08-11 06:13:12 +00:00
Sara Golemon 7e6d72f030 MFH: Fix format specifiers 2004-08-11 04:29:26 +00:00
Sara Golemon 6ea962c767 MFH: $errmsg should have been forced reference 2004-08-11 04:10:44 +00:00
Marcus Boerger c87b2d0cee BFN (small but important change) 2004-08-10 22:40:14 +00:00
Ilia Alshanetsky c2c31547c2 Bug fixing news. 2004-08-10 22:17:31 +00:00
Ilia Alshanetsky 21851b0001 MFH: Fixed bug #29606 (php_strip_whitespace() prints to stdout rather then
returning the value).
2004-08-10 22:16:50 +00:00
Dmitry Stogov bd96cca64f Fixed bug #28969 (Wrong data encoding of special characters) 2004-08-10 16:30:31 +00:00
SVN Migration 02893ad216 This commit was manufactured by cvs2svn to create branch 'PHP_5_0'. 2004-08-10 16:18:09 +00:00
Wez Furlong 4f88703159 BFN 2004-08-10 13:47:30 +00:00
Wez Furlong abc62474bf MFH: Fix for #29256 2004-08-10 13:45:58 +00:00
Christian Stocker 3a9754715a MFH (Fix segfault on error in xslt) 2004-08-10 08:02:00 +00:00
Andi Gutmans 2f212ab8d5 - Back to -dev 2004-08-10 07:28:09 +00:00
Andi Gutmans 71be1ed5f1 - 5.0.1RC1 2004-08-10 07:17:05 +00:00
Moriyoshi Koizumi 1c6896076f - Bugfix #29493 (extract(array, EXTR_REFS) misbehaves with elements referred
twice or more times)
2004-08-10 06:01:20 +00:00
Andi Gutmans 6a2d265af6 - The documentation team has re-wroten the installation part of the manual. 2004-08-10 05:36:12 +00:00
Ilia Alshanetsky 6fe9c3735a MFH: Fixed bug #29581 (Typo inside php.ini comments for mysql.trace_mode). 2004-08-10 00:44:23 +00:00
Andi Gutmans 5d43cf4ec4 - Update NEWS 2004-08-09 22:24:10 +00:00
Andi Gutmans 8b3b1eb121 Update credits for php docs 2004-08-09 21:53:19 +00:00
Dmitry Stogov 836a7b1a88 Included ext/soap fixes from CVS HEAD. 2004-08-09 05:50:06 +00:00
Georg Richter c26edafb17 fixed bug #29577 (MYSQLI_CLIENT_FOUND_ROWS undefined) 2004-08-09 04:33:40 +00:00
Ilia Alshanetsky a9bf810ba2 Remove \r characters from file. 2004-08-08 21:25:55 +00:00
Christian Stocker a737e92b08 Fixed bug #29573. 2004-08-08 18:09:46 +00:00
Christian Stocker 54ae55a949 MFH (fix for Bug #29573 : Segmentation fault when php function(called from XSLT templat) throw exception
and Zero Byte Memory Leaks)
2004-08-08 18:05:47 +00:00
Wez Furlong 5ab53094fa BFN 2004-08-07 21:04:51 +00:00
Wez Furlong aff24aed0d MFH: Fix for Bug #29490 from Michael Sisolak 2004-08-07 21:01:43 +00:00
Sara Golemon b915644ec4 MFH ZTS Fix 2004-08-06 17:35:59 +00:00
Wez Furlong 28c71a667a MFH: avoid possible segfault with stream_socket_client and bogus flags. 2004-08-06 14:18:49 +00:00
Ilia Alshanetsky d45c4f86d3 MFH: php_error() -> php_error_docref() 2004-08-05 23:57:53 +00:00
Edin Kadribasic 8060534f63 MFH: Export php_libxml_error_handler for windows build (#29541) 2004-08-05 21:03:15 +00:00
Antony Dovgal 80bdf7eae5 MFH: remove all references to @ thing, as it's not recommended 2004-08-05 14:19:59 +00:00
Ilia Alshanetsky 2dad2b3882 MFH: Eliminate unneeded variable. 2004-08-05 00:44:32 +00:00
Frank M. Kromann aa0a80bea8 Revert. ADD_EXTENSION_DEP is available in this branch! 2004-08-04 19:22:12 +00:00
Frank M. Kromann dec171c4bf No extension dependency in this branch 2004-08-04 17:22:14 +00:00
Frank M. Kromann 6d5779844f MFH: Move iconv exports to the iconv extension and make libxml depend on iconv 2004-08-04 17:13:11 +00:00
SVN Migration 94ed0368b9 This commit was manufactured by cvs2svn to create branch 'PHP_5_0'. 2004-08-04 16:46:49 +00:00
Zeev Suraski 6c8d9c8c8e Fix prototypes 2004-08-04 16:39:56 +00:00
Zeev Suraski 9de0be49d6 Fix prototypes 2004-08-04 14:40:53 +00:00
Georg Richter 5a76218edd fixed bug #29522 2004-08-04 13:02:40 +00:00
Marcus Boerger d84c321376 MFH missing part 2004-08-04 10:32:43 +00:00
Ilia Alshanetsky b3262ff512 MFH: Fixed argument handling in sun* functions. 2004-08-04 00:28:05 +00:00
Edin Kadribasic a825563c0b Typofix 2004-08-03 22:56:15 +00:00
Edin Kadribasic da476e0da9 MFH 2004-08-03 22:50:18 +00:00
Marcus Boerger 46107c39a4 MFH 2004-08-03 17:10:58 +00:00
Marcus Boerger a263d88c81 BFN 2004-08-03 17:07:56 +00:00
Marcus Boerger 9158cd2494 - MFH Bug #29505 get_class_vars() severely broken when used with arrays 2004-08-03 17:02:35 +00:00
SVN Migration 2e98f2dd1a This commit was manufactured by cvs2svn to create branch 'PHP_5_0'. 2004-08-03 16:59:54 +00:00
Antony Dovgal 902b4bda6a MFH: typo in ini parameter name 2004-08-03 06:26:59 +00:00
Antony Dovgal 87b52bb5cd MFH: fix typo in php.ini-dist & php.ini-recommended 2004-08-03 06:21:17 +00:00
Greg Beaver e6199b5279 commit for win32 - binary so line endings are always preserved - ..and in PHP_5_0, where it also belongs 2004-08-03 04:36:56 +00:00
SVN Migration e7f995106c This commit was manufactured by cvs2svn to create branch 'PHP_5_0'. 2004-08-03 04:36:01 +00:00
Ilia Alshanetsky 3bcb1f3af1 MFH: Allow sqlite_fetch_column_types() to properly handle table names with
spaces in them.
2004-08-02 22:43:42 +00:00
Marcus Boerger 13a652c81c MFH Change to use memcmp instead of strcmp 2004-08-02 22:43:16 +00:00
Ilia Alshanetsky 5ddd062e36 MFH: A gentler (performance wise) allocation of buffer for temp variables. 2004-08-02 02:35:03 +00:00
Marcus Boerger 4bedc6bb31 - Add new tests 2004-08-01 21:55:58 +00:00
Marcus Boerger 70f94e52ea - Enforce protocol on magic methods/functions 2004-08-01 21:55:39 +00:00
Wez Furlong 87c3363fa9 MFH usleep fix, and BFN. 2004-08-01 00:35:11 +00:00
Wez Furlong ca1dc06e04 MFH: zts fix 2004-07-31 16:37:18 +00:00
Wez Furlong b5ed0a1d3d MFH: streams fixes 2004-07-31 11:00:11 +00:00
Wez Furlong 19c8eeb4e8 MFH: zts fix for ini entries and dl() 2004-07-30 15:05:02 +00:00
Wez Furlong 293e62c99d MFH: win32 zts fix 2004-07-30 14:39:18 +00:00
Wez Furlong 2da7dd5982 MFH: various ZTS fixes 2004-07-30 14:24:59 +00:00
Edin Kadribasic 6325b1b630 MFH 2004-07-30 12:40:54 +00:00
Edin Kadribasic 9244e0eee1 MFH 2004-07-30 09:59:06 +00:00
Edin Kadribasic 712d951ffc MFH 2004-07-30 09:30:30 +00:00
Ilia Alshanetsky 40773632e0 MFH: Fixed bug #29443 (Sanity check for wbmp detection). 2004-07-30 01:10:42 +00:00
Edin Kadribasic 88628a2319 MFH 2004-07-29 22:26:52 +00:00
Edin Kadribasic 31120ba5f7 MFH: Fix informix compilation on Windows (bug #29340) 2004-07-29 21:12:47 +00:00
Timm Friebe 75276870db - MFH:
. Fixed bug #29064 (Exact numeric/decimal/money datatypes lose precision)
  . Fixed bug #27843 (sybase_query() triggers (spurious?) notices when
    query is a stored procedure)
  . Fixed multiple memory leaks with sybase_unbuffered_query()
  . Changed sybase_query() to ignore store_results = false in  buffering
    mode, it would yield unpredictable results
  . Fixed sybase_unbuffered_query() when used with store_results = false
  . Changed sybase_fetch_object() to ignore second argument when passed
    as NULL
  . Made sybase_data_seek() error message more verbose
  . Fixed memory leak in shutdown when not all rows where selected in an
    unbuffered query
# sort of, empty_string -> STR_EMPTY_ALLOC patch ommitted
2004-07-29 20:05:46 +00:00
SVN Migration fc0b122460 This commit was manufactured by cvs2svn to create branch 'PHP_5_0'. 2004-07-29 03:58:02 +00:00
Ilia Alshanetsky d976c362ac MFH: Fixed but #29437 (Possible crash inside array_walk_recursive()). 2004-07-29 00:35:12 +00:00
Wez Furlong 6c82c26884 BFN 2004-07-29 00:17:01 +00:00
Wez Furlong a0ef3e1865 MFH: #29431 2004-07-28 23:53:04 +00:00
Wez Furlong 4f91645642 MFH:
#29258: variant_date_from_timestamp() does not honour timezone
#29392: com_dotnet crashes when echo'ing an object
2004-07-28 23:48:26 +00:00
Wez Furlong 46b2bef868 Moved to PECL 2004-07-28 23:39:36 +00:00
Ilia Alshanetsky 26319ee1a1 MFH: Better address availability check. 2004-07-28 23:34:30 +00:00
Ilia Alshanetsky 42a8242676 MFH: Fixed possible crash in stream_socket_recvfrom() when length
parameter has a negative value.
2004-07-28 23:21:56 +00:00
Marcus Boerger 57ab773c70 MFH 2004-07-28 22:55:26 +00:00
Andi Gutmans 219364ee55 - Fix MAC OSX to always use native DSO loading 2004-07-28 19:07:26 +00:00
Christian Stocker 8b5fc29c7a MFH
Fixed bug #29409 (Segfault in PHP functions called from XSLT). (Rob)
2004-07-28 12:42:16 +00:00
Ilia Alshanetsky 21f4b69b2b MFH: Fixed bug #29342 (strtotime() does not handle empty date string
properly).
2004-07-28 01:44:41 +00:00
Ilia Alshanetsky f76ce400eb MFH: Fixed bug 29395 (sqlite_escape_string() returns bogus data on empty
strings).
2004-07-27 16:40:46 +00:00
Ilia Alshanetsky 16204148bb MFH: Added missing comma. 2004-07-27 12:44:35 +00:00
Ilia Alshanetsky 1f2d017ae1 MFH: Fixed bug #29349 (imagecreatefromstring() crashes with external GD
library).
2004-07-27 00:27:07 +00:00
Georg Richter 1b10ad424a MFH: fixed bug 29335 2004-07-26 07:22:01 +00:00
Georg Richter 3e65f6bf57 MFH: fixed bug in mysqli->client_version 2004-07-26 05:45:41 +00:00
Marcus Boerger f84d03b2bc - Update/Add tests 2004-07-25 19:35:30 +00:00
SVN Migration 2db28891e4 This commit was manufactured by cvs2svn to create branch 'PHP_5_0'. 2004-07-25 19:21:22 +00:00
Ilia Alshanetsky 7adc26fd8b MFH: Fixed bug #29369 (Uploaded files with ' or " in their names get their
names truncated at those characters).
2004-07-25 19:19:28 +00:00
Marcus Boerger fe80df5446 BFN 2004-07-25 17:38:44 +00:00
Marcus Boerger 8588815ef3 - MFH: Fix bug #29368 : The destructor is called when an exception is
thrown from the constructor
2004-07-25 17:37:55 +00:00
Georg Richter a70fc67b0b fixed bug #29311 2004-07-23 12:48:20 +00:00
SVN Migration b5c53ae6c7 This commit was manufactured by cvs2svn to create branch 'PHP_5_0'. 2004-07-23 12:47:37 +00:00
Edin Kadribasic 3d018fb061 MFB: Updated version number 2004-07-23 02:28:36 +00:00
Ilia Alshanetsky 3845e2c145 MFH: Fixed bug #29333 (output_buffering + trans_sess_id can corrupt output) 2004-07-23 02:05:51 +00:00
Stefan Esser 1930c2c33b MFH 2004-07-22 22:59:11 +00:00
SVN Migration 1e2b92b517 This commit was manufactured by cvs2svn to create branch 'PHP_5_0'. 2004-07-22 22:39:01 +00:00
Marcus Boerger 983fa5a21e Fix testcase 2004-07-22 18:39:45 +00:00
Georg Richter 3ecbb5c314 MFH: changed warning (bug #29298) for outdated client library 2004-07-22 07:25:31 +00:00
Sara Golemon 8fa1628958 MFH: This should fix binary safety for bound results. 2004-07-22 03:26:59 +00:00
Edin Kadribasic e52b580cad MFH: Fix for #28929 by Michael Sisolak 2004-07-21 22:53:27 +00:00
Edin Kadribasic 4b28e0a8f1 MFH: Build fix 2004-07-21 22:22:21 +00:00
Ilia Alshanetsky 91f5ceb3be MFH: Fixed bug #29209 (imap_fetchbody() doesn't check message index). 2004-07-21 21:57:09 +00:00
Marcus Boerger 603758b484 BFN 2004-07-21 18:38:23 +00:00
Marcus Boerger b6b575c1d5 MFH: Fixded #29291: get_class_vars() return names with NULLs 2004-07-21 18:37:36 +00:00
Christian Stocker e2f3142c78 MFH. Fix for Bug 29010 "make test does not wait to email address" (by Sebastian Nohn) 2004-07-21 11:20:33 +00:00
Ilia Alshanetsky 7623887079 MFH: Abort earlier on invalid format. 2004-07-21 00:14:50 +00:00
Moriyoshi Koizumi 1bd6ec4c91 - MFH (ctype.c: 1.31): Correct range checks.
- MFH (ctype.c: 1.31): Normalize negative values.
2004-07-20 20:09:27 +00:00
Moriyoshi Koizumi 33a6aefce8 oops... 2004-07-20 19:36:00 +00:00
Marcus Boerger d3f8aaecd8 BFN 2004-07-20 19:30:09 +00:00
Marcus Boerger 049cca1711 MFH 2004-07-20 19:25:18 +00:00
Moriyoshi Koizumi a40df45348 - MFH (iconv.c: 1.119): Fix possible leaks / segfaults in persistent iconv
filter.
2004-07-20 18:48:23 +00:00
Marcus Boerger 8f42eaae01 BFN 2004-07-20 18:25:48 +00:00
Marcus Boerger ebeefd9f7d MFH bugfix 28895 2004-07-20 18:23:49 +00:00
Moriyoshi Koizumi 646f9a4a8b - MFH (filters.c: 1.41): Add more null checks. 2004-07-20 18:17:07 +00:00
Moriyoshi Koizumi b4fa1661af - MFH (filters.c: 1.40): pemalloc() might return NULL 2004-07-20 18:04:36 +00:00
Stanislav Malyshev ba3c63dbc9 export ini parser 2004-07-20 08:45:04 +00:00
Sebastian Bergmann 350535d498 BFN: Fixed ReflectionClass::getMethod() and ReflectionClass::getProperty() to raise an ReflectionException instead of returning NULL on failure. 2004-07-20 05:48:45 +00:00
Ilia Alshanetsky 467caa4307 MFH: Fixed bug #29226 (ctype_* functions missing validation of numeric
string representations).
2004-07-20 01:03:18 +00:00
Sergey Kartashoff 01b6956d61 - A Bug #29147 was fixed. Thanks to Antony Dovgal <tony2001 at phpclub.net>
for his patch.
2004-07-19 19:46:52 +00:00
Marcus Boerger 61c3a669b4 - MFH protos and error message 2004-07-19 19:24:37 +00:00
Moriyoshi Koizumi befb6e9b80 - MFH (bug29119.phpt: 1.2): Fix test name 2004-07-19 18:49:46 +00:00
Moriyoshi Koizumi 35e43dabe1 - MFH (html.c: 1.98, bug29199.phpt: 1.1): Fix bug #29199 (html_entity_decode()
misbehaves with UTF-8)
2004-07-19 17:53:00 +00:00
SVN Migration b905779950 This commit was manufactured by cvs2svn to create branch 'PHP_5_0'. 2004-07-19 17:51:42 +00:00
Moriyoshi Koizumi 04c32887f1 - MFH (iconv.c: 1.118): Fix a bug in iconv stream filter that prevents
pending buckets from being processed.
2004-07-19 08:35:48 +00:00
Moriyoshi Koizumi e0a39d68d8 - MFH (config.m4: 1.52): Fix VPATH build. (patch by Joe Orton) 2004-07-19 05:09:46 +00:00
Moriyoshi Koizumi 92ec8541c1 - MFH: rename php_compat.h to php_onig_compat.h to avoid name conflict.
(reported by Joe Orton, thanks.)
2004-07-19 05:06:01 +00:00
SVN Migration 82a7ef78f3 This commit was manufactured by cvs2svn to create branch 'PHP_5_0'. 2004-07-19 05:04:34 +00:00
Ilia Alshanetsky 236c42c14e MFH: Fixed bug #28633 (sprintf incorrectly adding padding to floats). 2004-07-18 17:28:04 +00:00
SVN Migration b8fdc56a8b This commit was manufactured by cvs2svn to create branch 'PHP_5_0'. 2004-07-18 17:27:51 +00:00
Rob Richards 17ad61bd7f enable exslt support for win32 builds
WS fixes for exslt tests
2004-07-18 13:22:46 +00:00
Rob Richards ec1507ea9d add missing optional value param to createElementNS (chregu) 2004-07-18 13:15:50 +00:00
Rob Richards 69bd1f31fd Fixed bug #29221 (Segfault using DOM ownerDocument in a PHP object) 2004-07-18 11:44:25 +00:00
Moriyoshi Koizumi b9d4af72e9 - MFH (sapi_apache2.c: 1.41): request_dtor should be called if a fatal error
occurs during activation phase.
2004-07-17 21:31:43 +00:00
Sara Golemon fbbc036830 BFN 2004-07-16 23:45:21 +00:00
Sara Golemon c2b0fdd647 MFH: convert.* filters not consuming buckets_in on PSFS_FLUSH_* 2004-07-16 23:42:00 +00:00
Marcus Boerger 3706b626fe BFN 2004-07-16 07:27:34 +00:00
Marcus Boerger edbfc48fdd MFH 2004-07-16 07:26:49 +00:00
Ilia Alshanetsky 59c6886c65 Fixed bug #28800 (strings beginning with "inf" improperly converted). 2004-07-16 02:02:09 +00:00
SVN Migration 8091552925 This commit was manufactured by cvs2svn to create branch 'PHP_5_0'. 2004-07-15 19:41:23 +00:00
269 changed files with 8611 additions and 21251 deletions

No files matched your search

+1298 -379
View File
File diff suppressed because it is too large. Load diff
+55 -2
View File
@@ -1,7 +1,61 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2004, PHP 5.0.1
12 Aug 2004, PHP 5.0.1
- Changed destructor mechanism so that destructors are called prior to request
shutdown. (Marcus)
- Rewritten UNIX and Windows install help files. (Documentation Team)
- Updated several libraries bundled with the windows release which now
includes libxml2-2.6.11, libxslt-1.1.7 and iconv-1.9.1. (Rob, Edin)
- Improved and moved ActiveScript SAPI to PECL. (Wez)
- Fixed bug #29606 (php_strip_whitespace() prints to stdout rather then
returning the value). (Ilia)
- Fixed bug #29577 (MYSQLI_CLIENT_FOUND_ROWS undefined) (Georg)
- Fixed bug #29573 (Segmentation fault, when exception thrown within
PHP function called from XSLT). (Christian)
- Fixed bug #29522 (accessing properties without connection) (Georg)
- Fixed bug #29505 (get_class_vars() severely broken when used with arrays).
(Marcus)
- Fixed bug #29490 (.Net object instantiation failed). (Michael Sisolak).
- Fixed bug #29474 (win32: usleep() doesn't work). (Wez)
- Fixed bug #29449 (win32: feof() hangs on empty tcp stream). (Wez)
- Fixed bug #29437 (Possible crash inside array_walk_recursive()). (Ilia)
- Fixed bug #29431 (crash when parsing invalid address; invalid address
returned by stream_socket_recvfrom(), stream_socket_getname()). (Wez)
- Fixed bug #29409 (Segfault in PHP functions called from XSLT). (Rob)
- Fixed unloading of dynamically loaded extensions.
(Marcus, kameshj at fastmail dot fm)
- Fixed bug #29395 (sqlite_escape_string() returns bogus data on empty
strings). (Ilia, Tony)
- Fixed bug #29392 (com_dotnet crashes when echo'ing an object). (Wez)
- Fixed bug #29368 (The destructor is called when an exception is thrown from
the constructor). (Marcus)
- Fixed bug #29354 (Exception constructor marked as both public and protected).
(Marcus)
- Fixed bug #29342 (strtotime() does not handle empty date string properly).
(Ilia)
- Fixed bug #29340 (win32 build produces invalid php_ifx.dll). (Edin)
- Fixed bug #29335 (fetch functions now use MYSQLI_BOTH as default) (Georg)
- Fixed bug #29291 (get_class_vars() return names with NULLs). (Marcus)
- Fixed bug #29264 (gettext extension not working). (Edin)
- Fixed bug #29258 (variant_date_from_timestamp() does not honour
timezone). (Wez)
- Fixed bug #29256 (error when sending large packets on a socket). (Dmitry)
- Fixed bug #29236 (memory error when wsdl-cache is enabled). (Dmitry)
- Fixed bug #29147 (Compile Error in mnoGoSearch functions). (Sergey, Antony)
- Fixed bug #29132 ($_SERVER["PHP_AUTH_USER"] isn't defined). (Stefan)
- Fixed bug #29119 (html_entity_decode() misbehaves with UTF-8). (Moriyoshi)
- Fixed bug #29109 (SoapFault exception: [WSDL] Out of memory). (Dmitry)
- Fixed bug #29061 (soap extension segfaults). (Dmitry)
- Fixed bug #28985 (__getTypes() returning nothing on complex WSDL). (Dmitry)
- Fixed bug #28969 (Wrong data encoding of special characters). (Dmitry)
- Fixed bug #28895 (ReflectionClass::isAbstract always returns false). (Marcus)
- Fixed bug #28829 (Thread-unsafety in bcmath elementary values). (Sara)
- Fixed bug #28464 (catch() does not catch exceptions by interfaces). (Marcus)
- Fixed ReflectionClass::getMethod() and ReflectionClass::getProperty() to
raise an ReflectionException instead of returning NULL on failure.
(Sebastian)
- Fixed convert.* filters to consume remaining buckets_in on flush. (Sara)
- Fixed bug in mysqli->client_version. (Georg)
13 Jul 2004, PHP 5.0.0
- Updated PCRE to provide better error handling in certain cases. (Andrei)
@@ -10,7 +64,6 @@ PHP NEWS
- Fixed bug #29008 (array_combine() does not handle non-numeric/string keys).
(Ilia)
- Fixed bug #28999 (fixed behaviour of exec() to work as it did in 4.X). (Ilia)
- Fixed bug #28895 (ReflectionClass::isAbstract always returns false). (Marcus)
- Fixed bug #28868 (Internal filter registry not thread safe). (Sara)
- Fixed bug #28851 (call_user_func_array has typo in error message). (Marcus)
- Fixed bug #28831 (ArrayObject::offsetGet() does the work of offsetUnset()).
+10 -18
View File
@@ -37,8 +37,11 @@ The next few rules are more of a technical nature.
messages every day. Woe be to those who attempt to mess with it.
2. All news updates intended for public viewing, such as new features,
bug fixes, improvements, etc., should go into the NEWS file. Also see
the note below about automatically updating NEWS in your commit message.
bug fixes, improvements, etc., should go into the NEWS file.
NB! Lines, starting with @ will go automagically into NEWS file, but
this is NOT recommended, though. Please, add news entries directly to
NEWS file and don't forget to keep them adjusted and sorted.
3. Do not commit multiple file and dump all messages in one commit. If you
modified several unrelated files, commit each group separately and
@@ -59,14 +62,10 @@ The next few rules are more of a technical nature.
The format of the commit messages is pretty simple.
If a line begins with #, it is taken to be a comment and will not appear
in the ChangeLog. If the line begins with @, it will be redirected to the
NEWS file. Everything else goes into the ChangeLog.
in the ChangeLog. Everything else goes into the ChangeLog.
It is important to note that if your comment or news logline spans multiple
lines, you have to put # or @ at the beginning of _every_ such line. Every
entry in NEWS has to have a name after it, so if you did it with someone's
help, put both your names there. Your name WILL NOT be automatically put
at the end of the NEWS entry - so, please provide it yourself.
lines, you have to put # at the beginning of _every_ such line.
Example. Say you modified two files, datetime.c and string.c. In datetime.c
you added a new format option for date() function, and in string.c you fixed
@@ -78,17 +77,12 @@ For datetime.c:
(PHP date) Added new 'K' format modifier for printing out number of
days until New Year's Eve.
@- Added new 'K' format modifier that will output the number of days
@ until New Year's Eve. (Bob)
For string.c:
(php_trim) Fixed a memory leak resulting from improper use of zval_dtor().
# Man, that thing was leaking all over the place!
@- Fixed memory leak in trim(). (Bob)
The lines above marked with @ will go into NEWS file automagically, and the
# lines will be omitted from the ChangeLog. Alternatively, you might want
to modify NEWS file directly and not use the @ lines.
The # lines will be omitted from the ChangeLog automagically.
If you fix some bugs, you should note the bug ID numbers in your
commit message. Bug ID should be prefixed by "#" for easier access to
@@ -97,12 +91,10 @@ bug report when developers are browsing CVS via. LXR or Bonsai.
Example:
Fixed pgsql notice handler double free crash bug. Bug #14016
@ Fixed pgsql notice handler double free crash bug. Bug #14016
If you don't see your messages in ChangeLog and NEWS right away, don't worry!
If you don't see your messages in ChangeLog right away, don't worry!
These files are updated once a day, so your stuff will not show up until
somewhat later. Don't go adding stuff to NEWS by hand if you already put @
lines in the commit message.
somewhat later.
You can use LXR (http://lxr.php.net/) and Bonsai (http://bonsai.php.net/)
to look at PHP CVS repository in various ways.
+1 -1
View File
@@ -545,7 +545,7 @@ Changes in the Zend Engine 2.0
<?php
class Exception {
function __construct(string $message=NULL, int $code=0) {
function __construct(/*string*/ $message=NULL, /*int*/ $code=0) {
if (func_num_args()) {
$this->message = $message;
}
+31
View File
@@ -0,0 +1,31 @@
--TEST--
Bug #29505 (get_class_vars() severely broken when used with arrays)
--FILE--
<?php
class Test {
public $empty = array();
public $three = array(1, "b"=>"c", 3=>array());
}
var_dump(get_class_vars('Test'));
?>
===DONE===
--EXPECT--
array(2) {
["empty"]=>
array(0) {
}
["three"]=>
array(3) {
[0]=>
int(1)
["b"]=>
string(1) "c"
[3]=>
array(0) {
}
}
}
===DONE===
+2 -2
View File
@@ -22,7 +22,7 @@
#ifndef ZEND_H
#define ZEND_H
#define ZEND_VERSION "2.0.1-dev"
#define ZEND_VERSION "2.0.1"
#define ZEND_ENGINE_2
@@ -91,7 +91,7 @@ const char *zend_mh_bundle_error(void);
#endif /* HAVE_MACH_O_DYLD_H */
#if defined(HAVE_LIBDL)
#if defined(HAVE_LIBDL) && !defined(HAVE_MACH_O_DYLD_H)
# ifndef RTLD_LAZY
# define RTLD_LAZY 1 /* Solaris 1, FreeBSD's (2.1.7.1 and older) */
+50
View File
@@ -85,6 +85,10 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LIN
ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
#define USE_ZEND_ALLOC 1
#if USE_ZEND_ALLOC
/* Standard wrapper macros */
#define emalloc(size) _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
#define safe_emalloc(nmemb, size, offset) _safe_emalloc((nmemb), (size), (offset) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
@@ -123,6 +127,52 @@ ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC ZE
#define safe_estrdup(ptr) ((ptr)?(estrdup(ptr)):(empty_string))
#define safe_estrndup(ptr, len) ((ptr)?(estrndup((ptr), (len))):(empty_string))
#else
#define _GNU_SOURCE
#include <string.h>
#undef _GNU_SOURCE
/* Standard wrapper macros */
#define emalloc(size) malloc(size)
#define safe_emalloc(nmemb, size, offset) malloc((nmemb) * (size) + (offset))
#define efree(ptr) free(ptr)
#define ecalloc(nmemb, size) calloc((nmemb), (size))
#define erealloc(ptr, size) realloc((ptr), (size))
#define erealloc_recoverable(ptr, size) realloc((ptr), (size))
#define estrdup(s) strdup(s)
#define estrndup(s, length) strndup((s), (length))
/* Relay wrapper macros */
#define emalloc_rel(size) malloc(size)
#define safe_emalloc_rel(nmemb, size, offset) malloc((nmemb) * (size) + (offset))
#define efree_rel(ptr) free(ptr)
#define ecalloc_rel(nmemb, size) calloc((nmemb), (size))
#define erealloc_rel(ptr, size) realloc((ptr), (size))
#define erealloc_recoverable_rel(ptr, size) realloc((ptr), (size))
#define estrdup_rel(s) strdup(s)
#define estrndup_rel(s, length) strndup((s), (length))
/* Selective persistent/non persistent allocation macros */
#define pemalloc(size, persistent) malloc(size)
#define pefree(ptr, persistent) free(ptr)
#define pecalloc(nmemb, size, persistent) calloc((nmemb), (size))
#define perealloc(ptr, size, persistent) realloc((ptr), (size))
#define perealloc_recoverable(ptr, size, persistent) realloc((ptr), (size))
#define pestrdup(s, persistent) strdup(s)
#define pemalloc_rel(size, persistent) malloc(size)
#define pefree_rel(ptr, persistent) free(ptr)
#define pecalloc_rel(nmemb, size, persistent) calloc((nmemb), (size))
#define perealloc_rel(ptr, size, persistent) realloc((ptr), (size))
#define perealloc_recoverable_rel(ptr, size, persistent) realloc((ptr), (size))
#define pestrdup_rel(s, persistent) strdup(s)
#define safe_estrdup(ptr) ((ptr)?(strdup(ptr)):(empty_string))
#define safe_estrndup(ptr, len) ((ptr)?(strndup((ptr), (len))):(empty_string))
#endif
ZEND_API int zend_set_memory_limit(unsigned int memory_limit);
ZEND_API void start_memory_manager(TSRMLS_D);
+34 -5
View File
@@ -661,7 +661,6 @@ ZEND_FUNCTION(get_class_vars)
{
zval **class_name;
zend_class_entry *ce, **pce;
zval *tmp;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &class_name)==FAILURE) {
ZEND_WRONG_PARAM_COUNT();
@@ -674,11 +673,41 @@ ZEND_FUNCTION(get_class_vars)
} else {
ce = *pce;
array_init(return_value);
if (!ce->constants_updated) {
zend_hash_apply_with_argument(&ce->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
ce->constants_updated = 1;
if (zend_hash_num_elements(&ce->default_properties) > 0) {
HashPosition pos;
zval **prop;
zend_hash_internal_pointer_reset_ex(&ce->default_properties, &pos);
while (zend_hash_get_current_data_ex(&ce->default_properties, (void **) &prop, &pos) == SUCCESS) {
char *key, *class_name, *prop_name;
uint key_len;
ulong num_index;
zval *prop_copy;
zend_hash_get_current_key_ex(&ce->default_properties, &key, &key_len, &num_index, 0, &pos);
zend_hash_move_forward_ex(&ce->default_properties, &pos);
zend_unmangle_property_name(key, &class_name, &prop_name);
if (class_name && class_name[0] != '*' && strcmp(class_name, ce->name)) {
/* filter privates from base classes */
continue;
}
/* copy: enforce read only access */
ALLOC_ZVAL(prop_copy);
*prop_copy = **prop;
zval_copy_ctor(prop_copy);
INIT_PZVAL(prop_copy);
/* this is necessary to make it able to work with default array
* properties, returned to user */
if (Z_TYPE_P(prop_copy) == IS_CONSTANT_ARRAY || Z_TYPE_P(prop_copy) == IS_CONSTANT) {
zval_update_constant(&prop_copy, 0 TSRMLS_CC);
}
add_assoc_zval(return_value, prop_name, prop_copy);
}
}
zend_hash_copy(return_value->value.ht, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
}
}
/* }}} */
+25 -8
View File
@@ -1087,16 +1087,37 @@ void zend_do_handle_exception(TSRMLS_D)
void zend_do_end_function_declaration(znode *function_token TSRMLS_DC)
{
char lcname[16];
int name_len;
zend_do_extended_info(TSRMLS_C);
zend_do_return(NULL, 0 TSRMLS_CC);
zend_do_handle_exception(TSRMLS_C);
pass_two(CG(active_op_array) TSRMLS_CC);
if (CG(active_class_entry)
&& !strcmp(CG(active_op_array)->function_name, ZEND_CLONE_FUNC_NAME)
&& CG(active_op_array)->num_args != 0) {
zend_error(E_COMPILE_ERROR, "The clone method cannot accept any arguments");
/* we don't care if the function name is longer, in fact lowercasing only
* the beginning of the name speeds up the check process */
name_len = strlen(CG(active_op_array)->function_name);
zend_str_tolower_copy(lcname, CG(active_op_array)->function_name, MIN(name_len, sizeof(lcname)-1));
lcname[sizeof(lcname)-1] = '\0'; // zend_str_tolower_copy won't necessarily set the zero byte
if (CG(active_class_entry)) {
if (name_len == sizeof(ZEND_DESTRUCTOR_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_DESTRUCTOR_FUNC_NAME, sizeof(ZEND_DESTRUCTOR_FUNC_NAME)) && CG(active_op_array)->num_args != 0) {
zend_error(E_COMPILE_ERROR, "Destuctor %s::%s() cannot take arguments", CG(active_class_entry)->name, ZEND_DESTRUCTOR_FUNC_NAME);
} else if (name_len == sizeof(ZEND_CLONE_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_CLONE_FUNC_NAME, sizeof(ZEND_CLONE_FUNC_NAME)) && CG(active_op_array)->num_args != 0) {
zend_error(E_COMPILE_ERROR, "Method %s::%s() cannot accept any arguments", CG(active_class_entry)->name, ZEND_CLONE_FUNC_NAME);
} else if (name_len == sizeof(ZEND_GET_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_GET_FUNC_NAME, sizeof(ZEND_GET_FUNC_NAME)) && CG(active_op_array)->num_args != 1) {
zend_error(E_COMPILE_ERROR, "Method %s::%s() must take exactly 1 argument", CG(active_class_entry)->name, ZEND_GET_FUNC_NAME);
} else if (name_len == sizeof(ZEND_SET_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME)) && CG(active_op_array)->num_args != 2) {
zend_error(E_COMPILE_ERROR, "Method %s::%s() must take exactly 2 arguments", CG(active_class_entry)->name, ZEND_SET_FUNC_NAME);
} else if (name_len == sizeof(ZEND_CALL_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)) && CG(active_op_array)->num_args != 2) {
zend_error(E_COMPILE_ERROR, "Method %s::%s() must take exactly 2 arguments", CG(active_class_entry)->name, ZEND_CALL_FUNC_NAME);
}
} else {
if (name_len == sizeof(ZEND_AUTOLOAD_FUNC_NAME) - 1 && !memcmp(lcname, ZEND_AUTOLOAD_FUNC_NAME, sizeof(ZEND_AUTOLOAD_FUNC_NAME)) && CG(active_op_array)->num_args != 1) {
zend_error(E_COMPILE_ERROR, "%s() must take exactly 1 argument", ZEND_AUTOLOAD_FUNC_NAME);
}
}
CG(active_op_array)->line_end = zend_get_compiled_lineno(TSRMLS_C);
@@ -1114,10 +1135,6 @@ void zend_do_receive_arg(zend_uchar op, znode *var, znode *offset, znode *initia
zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
zend_arg_info *cur_arg_info;
if (CG(active_class_entry) && CG(active_class_entry)->destructor == (zend_function *) CG(active_op_array))
{
zend_error(E_COMPILE_ERROR, "Destuctor %s::%s() cannot take arguments", CG(active_class_entry)->name, CG(active_op_array)->function_name);
}
CG(active_op_array)->num_args++;
opline->opcode = op;
opline->result = *var;
+1
View File
@@ -840,6 +840,7 @@ END_EXTERN_C()
#define ZEND_GET_FUNC_NAME "__get"
#define ZEND_SET_FUNC_NAME "__set"
#define ZEND_CALL_FUNC_NAME "__call"
#define ZEND_AUTOLOAD_FUNC_NAME "__autoload"
#endif /* ZEND_COMPILE_H */
+20 -13
View File
@@ -52,6 +52,7 @@ static void zend_extension_fcall_end_handler(zend_extension *extension, zend_op_
#define EX_T(offset) (*(temp_variable *)((char *) EX(Ts) + offset))
#define T(offset) (*(temp_variable *)((char *) Ts + offset))
#define TEMP_VAR_STACK_LIMIT 2000
/* former zend_execute_locks.h */
static inline void zend_pzval_lock_func(zval *z)
@@ -1330,7 +1331,11 @@ static int zend_check_symbol(zval **pz TSRMLS_DC)
}
#define RETURN_FROM_EXECUTE_LOOP(execute_data) \
efree(EX(Ts)); \
if (EX(op_array)->T < TEMP_VAR_STACK_LIMIT) { \
free_alloca(EX(Ts)); \
} else { \
efree(EX(Ts)); \
} \
EG(in_execution) = EX(original_in_execution); \
EG(current_execute_data) = EX(prev_execute_data); \
return 1; /* CHECK_ME */
@@ -1349,7 +1354,11 @@ ZEND_API void execute(zend_op_array *op_array TSRMLS_DC)
/* Initialize execute_data */
EX(fbc) = NULL;
EX(object) = NULL;
EX(Ts) = (temp_variable *) safe_emalloc(sizeof(temp_variable), op_array->T, 0);
if (op_array->T < TEMP_VAR_STACK_LIMIT) {
EX(Ts) = (temp_variable *) do_alloca(sizeof(temp_variable) * op_array->T);
} else {
EX(Ts) = (temp_variable *) safe_emalloc(sizeof(temp_variable), op_array->T, 0);
}
EX(op_array) = op_array;
EX(original_in_execution) = EG(in_execution);
EX(prev_execute_data) = EG(current_execute_data);
@@ -2777,6 +2786,9 @@ int zend_do_fcall_common_helper(ZEND_OPCODE_HANDLER_ARGS)
if (EG(This)) {
if (EG(exception) && EX(fbc) && EX(fbc)->common.fn_flags&ZEND_ACC_CTOR) {
EG(This)->refcount--;
if (EG(This)->refcount == 1) {
zend_object_store_ctor_failed(EG(This) TSRMLS_CC);
}
zval_ptr_dtor(&EG(This));
} else if (should_change_scope) {
zval_ptr_dtor(&EG(This));
@@ -2929,21 +2941,16 @@ int zend_catch_handler(ZEND_OPCODE_HANDLER_ARGS)
}
ce = Z_OBJCE_P(EG(exception));
if (ce != EX_T(opline->op1.u.var).class_entry) {
while (ce->parent) {
if (ce->parent == EX_T(opline->op1.u.var).class_entry) {
goto exception_should_be_taken;
if (!instanceof_function(ce, EX_T(opline->op1.u.var).class_entry TSRMLS_CC)) {
if (opline->op1.u.EA.type) {
zend_throw_exception_internal(NULL TSRMLS_CC);
NEXT_OPCODE();
}
ce = ce->parent;
SET_OPCODE(&op_array->opcodes[opline->extended_value]);
return 0; /* CHECK_ME */
}
if (opline->op1.u.EA.type) {
zend_throw_exception_internal(NULL TSRMLS_CC);
NEXT_OPCODE();
}
SET_OPCODE(&op_array->opcodes[opline->extended_value]);
return 0; /* CHECK_ME */
}
exception_should_be_taken:
zend_hash_update(EG(active_symbol_table), opline->op2.u.constant.value.str.val,
opline->op2.u.constant.value.str.len+1, &EG(exception), sizeof(zval *), (void **) NULL);
EG(exception) = NULL;
+2 -2
View File
@@ -911,7 +911,7 @@ ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***
return FAILURE;
}
ZVAL_STRINGL(&autoload_function, "__autoload", sizeof("__autoload")-1, 0);
ZVAL_STRINGL(&autoload_function, ZEND_AUTOLOAD_FUNC_NAME, sizeof(ZEND_AUTOLOAD_FUNC_NAME)-1, 0);
INIT_PZVAL(class_name_ptr);
ZVAL_STRINGL(class_name_ptr, name, name_length, 0);
@@ -932,7 +932,7 @@ ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***
if (EG(exception)) {
free_alloca(lc_name);
zend_error(E_ERROR, "__autoload(%s) threw an exception of type '%s'", name, Z_OBJCE_P(EG(exception))->name);
zend_error(E_ERROR, "Function %s(%s) threw an exception of type '%s'", ZEND_AUTOLOAD_FUNC_NAME, name, Z_OBJCE_P(EG(exception))->name);
return FAILURE;
}
EG(exception) = exception;
+10 -4
View File
@@ -159,6 +159,12 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
switch (token_type) {
case T_END_HEREDOC:
zend_html_puts(token.value.str.val, token.value.str.len TSRMLS_CC);
{
char *ptr = LANG_SCNG(yy_text);
if (ptr[LANG_SCNG(yy_leng) - 1] != ';') {
zend_html_putc('\n');
}
}
break;
default:
zend_html_puts(LANG_SCNG(yy_text), LANG_SCNG(yy_leng) TSRMLS_CC);
@@ -203,7 +209,7 @@ ZEND_API void zend_strip(TSRMLS_D)
switch (token_type) {
case T_WHITESPACE:
if (!prev_space) {
putchar(' ');
zend_write(" ", sizeof(" ") - 1);
prev_space = 1;
}
/* lack of break; is intentional */
@@ -215,9 +221,9 @@ ZEND_API void zend_strip(TSRMLS_D)
case T_END_HEREDOC: {
char *ptr = LANG_SCNG(yy_text);
fwrite(ptr, LANG_SCNG(yy_leng) - 1, 1, stdout);
zend_write(ptr, LANG_SCNG(yy_leng) - 1);
/* The ensure that we only write one ; and that it followed by the required newline */
putchar('\n');
zend_write("\n", sizeof("\n") - 1);
if (ptr[LANG_SCNG(yy_leng) - 1] == ';') {
lex_scan(&token TSRMLS_CC);
}
@@ -226,7 +232,7 @@ ZEND_API void zend_strip(TSRMLS_D)
break;
default:
fwrite(LANG_SCNG(yy_text), LANG_SCNG(yy_leng), 1, stdout);
zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
break;
}
+16 -1
View File
@@ -147,10 +147,25 @@ ZEND_API int zend_register_ini_entries(zend_ini_entry *ini_entry, int module_num
zend_ini_entry *p = ini_entry;
zend_ini_entry *hashed_ini_entry;
zval default_value;
HashTable *directives = registered_zend_ini_directives;
#ifdef ZTS
/* if we are called during the request, eg: from dl(),
* then we should not touch the global directives table,
* and should update the per-(request|thread) version instead.
* This solves two problems: one is that ini entries for dl()'d
* extensions will now work, and the second is that updating the
* global hash here from dl() is not mutex protected and can
* lead to death.
*/
if (directives != EG(ini_directives)) {
directives = EG(ini_directives);
}
#endif
while (p->name) {
p->module_number = module_number;
if (zend_hash_add(registered_zend_ini_directives, p->name, p->name_length, p, sizeof(zend_ini_entry), (void **) &hashed_ini_entry)==FAILURE) {
if (zend_hash_add(directives, p->name, p->name_length, p, sizeof(zend_ini_entry), (void **) &hashed_ini_entry)==FAILURE) {
zend_unregister_ini_entries(module_number TSRMLS_CC);
return FAILURE;
}
+1 -1
View File
@@ -192,7 +192,7 @@ END_EXTERN_C()
/* INI parsing engine */
typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, int callback_type, void *arg);
BEGIN_EXTERN_C()
int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, zend_ini_parser_cb_t ini_parser_cb, void *arg);
ZEND_API int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, zend_ini_parser_cb_t ini_parser_cb, void *arg);
END_EXTERN_C()
#define ZEND_INI_PARSER_ENTRY 1
+1 -1
View File
@@ -139,7 +139,7 @@ static void ini_error(char *str)
}
int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, zend_ini_parser_cb_t ini_parser_cb, void *arg)
ZEND_API int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, zend_ini_parser_cb_t ini_parser_cb, void *arg)
{
int retval;
zend_ini_parser_param ini_parser_param;
+9
View File
@@ -207,6 +207,15 @@ ZEND_API void zend_object_store_set_object(zval *zobject, void *object TSRMLS_DC
}
/* Called when the ctor was terminated by an exception */
ZEND_API void zend_object_store_ctor_failed(zval *zobject TSRMLS_DC)
{
zend_object_handle handle = Z_OBJ_HANDLE_P(zobject);
EG(objects_store).object_buckets[handle].destructor_called = 1;
}
/* Proxy objects workings */
typedef struct _zend_proxy_object {
zval *object;
+1
View File
@@ -68,6 +68,7 @@ ZEND_API zend_object_value zend_objects_store_clone_obj(zval *object TSRMLS_DC);
ZEND_API void *zend_object_store_get_object(zval *object TSRMLS_DC);
/* See comment in zend_objects_API.c before you use this */
ZEND_API void zend_object_store_set_object(zval *zobject, void *object TSRMLS_DC);
ZEND_API void zend_object_store_ctor_failed(zval *zobject TSRMLS_DC);
ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects TSRMLS_DC);
+2
View File
@@ -87,6 +87,8 @@ static inline zend_bool is_numeric_string(char *str, int length, long *lval, dou
*lval = local_lval;
}
return IS_LONG;
} else if (end_ptr_long == str && *end_ptr_long != '\0') { /* ignore partial string matches */
return 0;
}
} else {
end_ptr_long=NULL;
+20 -16
View File
@@ -1541,7 +1541,7 @@ ZEND_METHOD(reflection_parameter, getName)
}
/* }}} */
/* {{{ proto public ReflectionClass Reflection_Parameter::getClass()
/* {{{ proto public ReflectionClass ReflectionParameter::getClass()
Returns this parameters's class hint or NULL if there is none */
ZEND_METHOD(reflection_parameter, getClass)
{
@@ -1879,7 +1879,7 @@ ZEND_METHOD(reflection_method, getModifiers)
}
/* }}} */
/* {{{ proto public ReflectionClass Reflection_Method::getDeclaringClass()
/* {{{ proto public ReflectionClass ReflectionMethod::getDeclaringClass()
Get the declaring class */
ZEND_METHOD(reflection_method, getDeclaringClass)
{
@@ -2134,7 +2134,7 @@ ZEND_METHOD(reflection_class, getDocComment)
}
/* }}} */
/* {{{ proto public ReflectionMethod Reflection_Class::getConstructor()
/* {{{ proto public ReflectionMethod ReflectionClass::getConstructor()
Returns the class' constructor if there is one, NULL otherwise */
ZEND_METHOD(reflection_class, getConstructor)
{
@@ -2152,7 +2152,7 @@ ZEND_METHOD(reflection_class, getConstructor)
}
/* }}} */
/* {{{ proto public ReflectionMethod Reflection_Class::getMethod(string name)
/* {{{ proto public ReflectionMethod ReflectionClass::getMethod(string name) throws ReflectionException
Returns the class' method specified by it's name */
ZEND_METHOD(reflection_class, getMethod)
{
@@ -2172,7 +2172,9 @@ ZEND_METHOD(reflection_class, getMethod)
if (zend_hash_find(&ce->function_table, name, name_len + 1, (void**) &mptr) == SUCCESS) {
reflection_method_factory(ce, mptr, return_value TSRMLS_CC);
} else {
RETURN_NULL();
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Method %s does not exist", name);
return;
}
}
/* }}} */
@@ -2195,7 +2197,7 @@ static int _addmethod(zend_function *mptr, int num_args, va_list args, zend_hash
}
/* }}} */
/* {{{ proto public ReflectionMethod[] Reflection_Class::getMethods()
/* {{{ proto public ReflectionMethod[] ReflectionClass::getMethods()
Returns an array of this class' methods */
ZEND_METHOD(reflection_class, getMethods)
{
@@ -2221,7 +2223,7 @@ ZEND_METHOD(reflection_class, getMethods)
}
/* }}} */
/* {{{ proto public ReflectionProperty Reflection_Class::getProperty(string name)
/* {{{ proto public ReflectionProperty ReflectionClass::getProperty(string name) throws ReflectionException
Returns the class' property specified by it's name */
ZEND_METHOD(reflection_class, getProperty)
{
@@ -2240,7 +2242,9 @@ ZEND_METHOD(reflection_class, getProperty)
if (zend_hash_find(&ce->properties_info, name, name_len + 1, (void**) &property_info) == SUCCESS) {
reflection_property_factory(ce, property_info, return_value TSRMLS_CC);
} else {
RETURN_NULL();
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Property %s does not exist", name);
return;
}
}
/* }}} */
@@ -2263,7 +2267,7 @@ static int _addproperty(zend_property_info *pptr, int num_args, va_list args, ze
}
/* }}} */
/* {{{ proto public ReflectionProperty[] Reflection_Class::getProperties()
/* {{{ proto public ReflectionProperty[] ReflectionClass::getProperties()
Returns an array of this class' properties */
ZEND_METHOD(reflection_class, getProperties)
{
@@ -2383,7 +2387,7 @@ ZEND_METHOD(reflection_class, isFinal)
Returns whether this class is abstract */
ZEND_METHOD(reflection_class, isAbstract)
{
_class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_IMPLICIT_ABSTRACT_CLASS);
_class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
}
/* }}} */
@@ -2478,7 +2482,7 @@ ZEND_METHOD(reflection_class, newInstance)
}
/* }}} */
/* {{{ proto public ReflectionClass[] Reflection_Class::getInterfaces()
/* {{{ proto public ReflectionClass[] ReflectionClass::getInterfaces()
Returns an array of interfaces this class implements */
ZEND_METHOD(reflection_class, getInterfaces)
{
@@ -2504,7 +2508,7 @@ ZEND_METHOD(reflection_class, getInterfaces)
}
/* }}} */
/* {{{ proto public ReflectionClass Reflection_Class::getParentClass()
/* {{{ proto public ReflectionClass ReflectionClass::getParentClass()
Returns the class' parent class, or, if none exists, FALSE */
ZEND_METHOD(reflection_class, getParentClass)
{
@@ -2541,7 +2545,7 @@ ZEND_METHOD(reflection_class, isSubclassOf)
case IS_STRING:
if (zend_lookup_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), &pce TSRMLS_CC) == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Interface %s doesn't exist", Z_STRVAL_P(class_name));
"Interface %s does not exist", Z_STRVAL_P(class_name));
return;
}
class_ce = *pce;
@@ -2587,7 +2591,7 @@ ZEND_METHOD(reflection_class, implementsInterface)
case IS_STRING:
if (zend_lookup_class(Z_STRVAL_P(interface), Z_STRLEN_P(interface), &pce TSRMLS_CC) == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Interface %s doesn't exist", Z_STRVAL_P(interface));
"Interface %s does not exist", Z_STRVAL_P(interface));
return;
}
interface_ce = *pce;
@@ -2953,7 +2957,7 @@ ZEND_METHOD(reflection_property, setValue)
}
/* }}} */
/* {{{ proto public ReflectionClass Reflection_Property::getDeclaringClass()
/* {{{ proto public ReflectionClass ReflectionProperty::getDeclaringClass()
Get the declaring class */
ZEND_METHOD(reflection_property, getDeclaringClass)
{
@@ -3056,7 +3060,7 @@ ZEND_METHOD(reflection_extension, getVersion)
}
/* }}} */
/* {{{ proto public ReflectionFunction[] Reflection_Extension::getFunctions()
/* {{{ proto public ReflectionFunction[] ReflectionExtension::getFunctions()
Returns an array of this extension's fuctions */
ZEND_METHOD(reflection_extension, getFunctions)
{
+1 -1
View File
@@ -41,7 +41,7 @@ AC_CONFIG_HEADER(main/php_config.h)
MAJOR_VERSION=5
MINOR_VERSION=0
RELEASE_VERSION=1
EXTRA_VERSION="-dev"
EXTRA_VERSION=""
VERSION="$MAJOR_VERSION.$MINOR_VERSION.$RELEASE_VERSION$EXTRA_VERSION"
dnl Define where extension directories are located in the configure context
+7 -2
View File
@@ -102,6 +102,7 @@ PHP_FUNCTION(com_dotnet_create_instance)
struct dotnet_runtime_stuff *stuff;
IObjectHandle *handle;
DISPPARAMS params;
OLECHAR *olestring;
VARIANT vargs[2];
VARIANT retval;
HRESULT hr;
@@ -138,10 +139,14 @@ PHP_FUNCTION(com_dotnet_create_instance)
VariantInit(&retval);
V_VT(&vargs[0]) = VT_BSTR;
V_BSTR(&vargs[0]) = php_com_string_to_olestring(datatype_name, datatype_name_len, obj->code_page TSRMLS_CC);
olestring = php_com_string_to_olestring(datatype_name, datatype_name_len, obj->code_page TSRMLS_CC);
V_BSTR(&vargs[0]) = SysAllocStringByteLen((char*)olestring, datatype_name_len * sizeof(OLECHAR));
efree(olestring);
V_VT(&vargs[1]) = VT_BSTR;
V_BSTR(&vargs[1]) = php_com_string_to_olestring(assembly_name, assembly_name_len, obj->code_page TSRMLS_CC);
olestring = php_com_string_to_olestring(assembly_name, assembly_name_len, obj->code_page TSRMLS_CC);
V_BSTR(&vargs[1]) = SysAllocStringByteLen((char*)olestring, assembly_name_len * sizeof(OLECHAR));
efree(olestring);
hr = IDispatch_Invoke(stuff->dotnet_domain, stuff->create_instance, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
DISPATCH_METHOD, &params, &retval, NULL, NULL);
+1 -1
View File
@@ -194,7 +194,7 @@ PHP_MINIT_FUNCTION(com_dotnet)
INIT_CLASS_ENTRY(ce, "com_exception", NULL);
php_com_exception_class_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default(), NULL TSRMLS_CC);
php_com_exception_class_entry->ce_flags |= ZEND_ACC_FINAL;
php_com_exception_class_entry->constructor->common.fn_flags |= ZEND_ACC_PROTECTED;
// php_com_exception_class_entry->constructor->common.fn_flags |= ZEND_ACC_PROTECTED;
INIT_CLASS_ENTRY(ce, "com_safearray_proxy", NULL);
php_com_saproxy_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
+35 -11
View File
@@ -286,11 +286,19 @@ static void function_dtor(void *pDest)
}
}
static PHP_FUNCTION(com_method_handler)
{
Z_OBJ_HANDLER_P(getThis(), call_method)(
((zend_internal_function*)EG(function_state_ptr)->function)->function_name,
INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
static union _zend_function *com_method_get(zval *object, char *name, int len TSRMLS_DC)
{
zend_internal_function f, *fptr = NULL;
php_com_dotnet_object *obj;
union _zend_function *func;
DISPID dummy;
obj = CDNO_FETCH(object);
@@ -298,6 +306,10 @@ static union _zend_function *com_method_get(zval *object, char *name, int len TS
return NULL;
}
if (FAILED(php_com_get_id_of_name(obj, name, len, &dummy TSRMLS_CC))) {
return NULL;
}
/* check cache */
if (obj->method_cache == NULL || FAILURE == zend_hash_find(obj->method_cache, name, len, (void**)&fptr)) {
f.type = ZEND_OVERLOADED_FUNCTION;
@@ -306,7 +318,10 @@ static union _zend_function *com_method_get(zval *object, char *name, int len TS
f.scope = obj->ce;
f.fn_flags = 0;
f.function_name = estrndup(name, len);
f.handler = PHP_FN(com_method_handler);
fptr = &f;
if (obj->typeinfo) {
/* look for byref params */
ITypeComp *comp;
@@ -346,6 +361,9 @@ static union _zend_function *com_method_get(zval *object, char *name, int len TS
case DESCKIND_TYPECOMP:
ITypeComp_Release(bindptr.lptcomp);
break;
case DESCKIND_NONE:
break;
}
if (TI) {
ITypeInfo_Release(TI);
@@ -356,21 +374,27 @@ static union _zend_function *com_method_get(zval *object, char *name, int len TS
}
}
/* save this method in the cache */
if (!obj->method_cache) {
ALLOC_HASHTABLE(obj->method_cache);
zend_hash_init(obj->method_cache, 2, NULL, function_dtor, 0);
}
if (fptr) {
/* save this method in the cache */
if (!obj->method_cache) {
ALLOC_HASHTABLE(obj->method_cache);
zend_hash_init(obj->method_cache, 2, NULL, function_dtor, 0);
}
zend_hash_update(obj->method_cache, name, len, &f, sizeof(f), (void**)&fptr);
zend_hash_update(obj->method_cache, name, len, &f, sizeof(f), (void**)&fptr);
}
}
/* duplicate this into a new chunk of emalloc'd memory,
* since the engine will efree it */
func = emalloc(sizeof(*fptr));
memcpy(func, fptr, sizeof(*fptr));
if (fptr) {
/* duplicate this into a new chunk of emalloc'd memory,
* since the engine will efree it */
func = emalloc(sizeof(*fptr));
memcpy(func, fptr, sizeof(*fptr));
return func;
return func;
}
return NULL;
}
static int com_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS)
+2 -1
View File
@@ -799,7 +799,8 @@ PHP_FUNCTION(variant_date_from_timestamp)
}
VariantInit(&res);
tmv = gmtime(&timestamp);
tzset();
tmv = localtime(&timestamp);
memset(&systime, 0, sizeof(systime));
systime.wDay = tmv->tm_mday;
+9 -5
View File
@@ -296,12 +296,16 @@ static HRESULT STDMETHODCALLTYPE disp_invokeex(
} else if (wFlags & DISPATCH_PROPERTYPUT) {
zend_update_property(Z_OBJCE_P(disp->object), disp->object, Z_STRVAL_PP(name), Z_STRLEN_PP(name)+1, *params[0] TSRMLS_CC);
} else if (wFlags & DISPATCH_METHOD) {
if (SUCCESS == call_user_function_ex(EG(function_table), &disp->object, *name,
&retval, pdp->cArgs, params, 1, NULL TSRMLS_CC)) {
ret = S_OK;
} else {
zend_try {
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;
}
} zend_catch {
ret = DISP_E_EXCEPTION;
}
} zend_end_try();
} else {
trace("Don't know how to handle this invocation %08x\n", wFlags);
}
+7 -1
View File
@@ -97,7 +97,13 @@ PHP_MINFO_FUNCTION(ctype)
return; \
switch (Z_TYPE_P(c)) { \
case IS_LONG: \
RETURN_BOOL(iswhat(Z_LVAL_P(c))); \
if (Z_LVAL_P(c) <= 255 && Z_LVAL_P(c) >= 0) { \
RETURN_BOOL(iswhat(Z_LVAL_P(c))); \
} else if (Z_LVAL_P(c) >= -128) { \
RETURN_BOOL(iswhat(Z_LVAL_P(c) + 256)); \
} \
SEPARATE_ZVAL(&c); \
convert_to_string(c); \
case IS_STRING: \
{ \
char *p; \
+4 -4
View File
@@ -14,7 +14,7 @@ magic_quotes_runtime=1
require_once('test.inc');
echo "database handler: $handler\n";
// print md5 checksum of test.cdb which is generated by cdb_make program
var_dump(md5(implode('',file(dirname(__FILE__).'/test.cdb'))));
var_dump(md5_file(dirname(__FILE__).'/test.cdb'));
if (($db_make=dba_open($db_file, "n", $handler))!==FALSE) {
dba_insert("1", "1", $db_make);
dba_insert("2", "2", $db_make);
@@ -26,7 +26,7 @@ magic_quotes_runtime=1
// dba_replace cdb_make doesn't know replace
dba_close($db_make);
// write md5 checksum of generated database file
var_dump(md5(implode('',file($db_file))));
var_dump(md5_file($db_file));
// no need to test created database: this is done by dba_cdb_read.phpt
} else {
echo "Error creating database\n";
@@ -34,5 +34,5 @@ magic_quotes_runtime=1
?>
--EXPECT--
database handler: cdb_make
string(32) "723d19f39c1b15b3b455dd64323148d1"
string(32) "723d19f39c1b15b3b455dd64323148d1"
string(32) "12fc5ba2b9dcfef2480e5324eeb5f3e5"
string(32) "12fc5ba2b9dcfef2480e5324eeb5f3e5"
+5 -5
View File
@@ -1063,7 +1063,7 @@ PHP_FUNCTION(dom_document_import_node)
/* }}} end dom_document_import_node */
/* {{{ proto DOMElement dom_document_create_element_ns(string namespaceURI, string qualifiedName);
/* {{{ proto DOMElement dom_document_create_element_ns(string namespaceURI, string qualifiedName [,string value]);
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-DocCrElNS
Since: DOM Level 2
*/
@@ -1073,13 +1073,13 @@ PHP_FUNCTION(dom_document_create_element_ns)
xmlDocPtr docp;
xmlNodePtr nodep = NULL;
xmlNsPtr nsptr = NULL;
int ret, uri_len = 0, name_len = 0;
char *uri, *name;
int ret, uri_len = 0, name_len = 0, value_len = 0;
char *uri, *name, *value = NULL;
char *localname = NULL, *prefix = NULL;
int errorcode;
dom_object *intern;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os!s", &id, dom_document_class_entry, &uri, &uri_len, &name, &name_len) == FAILURE) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os!s|s", &id, dom_document_class_entry, &uri, &uri_len, &name, &name_len, &value, &value_len) == FAILURE) {
return;
}
@@ -1089,7 +1089,7 @@ PHP_FUNCTION(dom_document_create_element_ns)
if (errorcode == 0) {
if (xmlValidateName((xmlChar *) localname, 0) == 0) {
nodep = xmlNewDocNode (docp, NULL, localname, NULL);
nodep = xmlNewDocNode (docp, NULL, localname, value);
if (nodep != NULL && uri != NULL) {
nsptr = xmlSearchNsByHref (nodep->doc, nodep, uri);
if (nsptr == NULL) {
-1
View File
@@ -384,7 +384,6 @@ PHP_MINIT_FUNCTION(dom)
INIT_CLASS_ENTRY(ce, "DOMException", php_dom_domexception_class_functions);
dom_domexception_class_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default(), NULL TSRMLS_CC);
dom_domexception_class_entry->ce_flags |= ZEND_ACC_FINAL;
dom_domexception_class_entry->constructor->common.fn_flags |= ZEND_ACC_PROTECTED;
zend_declare_property_long(dom_domexception_class_entry, "code", sizeof("code")-1, 0, ZEND_ACC_PUBLIC TSRMLS_CC);
REGISTER_DOM_CLASS(ce, "DOMStringList", NULL, php_dom_domstringlist_class_functions, dom_domstringlist_class_entry);
+1 -1
View File
@@ -23,7 +23,7 @@ function adjustDoctype($xml) {
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><head><title>Hello world</title></head><body><p>
This is a not well-formed<br/>
html files with undeclared entities 
html files with undeclared entities&#xA0;
</p></body></html>
--- save as HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
-2
View File
@@ -1,2 +0,0 @@
enchant
Pierre-Alain Joye, Ilia Alshanetsky
-36
View File
@@ -1,36 +0,0 @@
dnl
dnl $Id$
dnl
PHP_ARG_WITH(enchant,for ENCHANT support,
[ --with-enchant[=DIR] Include enchant support.
GNU Aspell version 1.1.3 or higher required.])
if test "$PHP_ENCHANT" != "no"; then
PHP_NEW_EXTENSION(enchant, enchant.c, $ext_shared)
if test "$PHP_ENCHANT" != "yes"; then
ENCHANT_SEARCH_DIRS=$PHP_ENCHANT
else
ENCHANT_SEARCH_DIRS="/usr/local /usr"
fi
for i in $ENCHANT_SEARCH_DIRS; do
if test -f $i/include/enchant/enchant.h; then
ENCHANT_DIR=$i
ENCHANT_INCDIR=$i/include/enchant
elif test -f $i/include/enchant.h; then
ENCHANT_DIR=$i
ENCHANT_INCDIR=$i/include
fi
done
if test -z "$ENCHANT_DIR"; then
AC_MSG_ERROR(Cannot find enchant)
fi
ENCHANT_LIBDIR=$ENCHANT_DIR/lib
AC_DEFINE(HAVE_ENCHANT,1,[ ])
PHP_SUBST(ENCHANT_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(enchant, $ENCHANT_LIBDIR, ENCHANT_SHARED_LIBADD)
PHP_ADD_INCLUDE($ENCHANT_INCDIR)
fi
-9
View File
@@ -1,9 +0,0 @@
// $Id$
// vim:ft=javascript
ARG_ENABLE("enchant", "Enchant Support", "no");
if (PHP_ENCHANT == "yes") {
EXTENSION("enchant", "enchant.c");
AC_DEFINE('HAVE_ENCHANT', 1, 'Have Enchant support', false);
}
-25
View File
@@ -1,25 +0,0 @@
<?php
$tag = 'en_US';
$r = enchant_broker_init();
$bprovides = enchant_broker_describe($r);
echo "Current broker provides the following backend(s):\n";
print_r($bprovides);
if (enchant_broker_dict_exists($r,$tag)) {
$d = enchant_broker_request_dict($r, $tag);
$dprovides = enchant_dict_describe($d);
echo "dictionary $tag provides:\n";
$spellerrors = enchant_dict_check($d, "soong");
print_r($dprovides);
echo "found $spellerrors spell errors\n";
if ($spellerrors) {
$suggs = enchant_dict_suggest($d, "soong");
echo "Suggestions for 'soong':";
print_r($suggs);
}
enchant_broker_free_dict($d);
} else {
}
enchant_broker_free($r);
?>
-731
View File
@@ -1,731 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 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/3_0.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: Pierre-Alain Joye <paj@pearfr.org> |
| Ilia Alshanetsky <ilia@prohost.org> |
+----------------------------------------------------------------------+
$Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "enchant.h"
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_enchant.h"
typedef EnchantBroker * EnchantBrokerPtr;
typedef struct _broker_struct enchant_broker;
typedef struct _dict_struct enchant_dict;
typedef enchant_broker * enchant_brokerPtr;
typedef enchant_dict * enchant_dictPtr;
typedef struct _broker_struct {
EnchantBroker *pbroker;
enchant_dict **dict;
unsigned int dictcnt;
zval *rsrc_id;
} _enchant_broker;
typedef struct _dict_struct {
unsigned int id;
EnchantDict *pdict;
enchant_broker *pbroker;
zval *rsrc_id;
enchant_dict *next;
enchant_dict *prev;
} _enchant_dict;
/* True global resources - no need for thread safety here */
static int le_enchant_broker;
static int le_enchant_dict;
/* If you declare any globals in php_enchant.h uncomment this:*/
/*ZEND_DECLARE_MODULE_GLOBALS(enchant)*/
/* {{{ enchant_functions[]
*
* Every user visible function must have an entry in enchant_functions[].
*/
function_entry enchant_functions[] = {
PHP_FE(enchant_broker_init, NULL)
PHP_FE(enchant_broker_free, NULL)
PHP_FE(enchant_broker_get_error, NULL)
PHP_FE(enchant_broker_request_dict, NULL)
PHP_FE(enchant_broker_request_pwl_dict, NULL)
PHP_FE(enchant_broker_free_dict, NULL)
PHP_FE(enchant_broker_dict_exists, NULL)
PHP_FE(enchant_broker_set_ordering, NULL)
PHP_FE(enchant_broker_describe, NULL)
PHP_FE(enchant_dict_check, NULL)
PHP_FE(enchant_dict_suggest, NULL)
PHP_FE(enchant_dict_add_to_personal, NULL)
PHP_FE(enchant_dict_add_to_session, NULL)
PHP_FE(enchant_dict_is_in_session, NULL)
PHP_FE(enchant_dict_store_replacement, NULL)
PHP_FE(enchant_dict_get_error, NULL)
PHP_FE(enchant_dict_describe, NULL)
PHP_FE(enchant_dict_quick_check, third_arg_force_ref)
{NULL, NULL, NULL} /* Must be the last line in enchant_functions[] */
};
/* }}} */
/* {{{ enchant_module_entry
*/
zend_module_entry enchant_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
"enchant",
enchant_functions,
PHP_MINIT(enchant),
PHP_MSHUTDOWN(enchant),
NULL, /* Replace with NULL if there's nothing to do at request start */
NULL, /* Replace with NULL if there's nothing to do at request end */
PHP_MINFO(enchant),
#if ZEND_MODULE_API_NO >= 20010901
"0.1", /* Replace with version number for your extension */
#endif
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#ifdef COMPILE_DL_ENCHANT
ZEND_GET_MODULE(enchant)
#endif
static void
enumerate_providers_fn (const char * const name,
const char * const desc,
const char * const file,
void * ud)
{
zval *zdesc = (zval *) ud;
zval *tmp_array;
MAKE_STD_ZVAL(tmp_array);
array_init(tmp_array);
add_assoc_string(tmp_array, "name", (char *)name, 1);
add_assoc_string(tmp_array, "desc", (char *)desc, 1);
add_assoc_string(tmp_array, "file", (char *)file, 1);
if (Z_TYPE_P(zdesc)!=IS_ARRAY) {
array_init(zdesc);
}
add_next_index_zval(zdesc, tmp_array);
}
static void
describe_dict_fn (const char * const lang,
const char * const name,
const char * const desc,
const char * const file,
void * ud)
{
zval *zdesc = (zval *) ud;
array_init(zdesc);
add_assoc_string(zdesc, "lang", (char *)lang, 1);
add_assoc_string(zdesc, "name", (char *)name, 1);
add_assoc_string(zdesc, "desc", (char *)desc, 1);
add_assoc_string(zdesc, "file", (char *)file, 1);
}
static void php_enchant_broker_free(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
if (rsrc->ptr) {
enchant_broker *broker = (enchant_broker *)rsrc->ptr;
if (broker) {
if (broker->pbroker) {
if (broker->dictcnt && broker->dict) {
if (broker->dict) {
int total, tofree;
tofree = total = broker->dictcnt-1;
do {
zend_list_delete(Z_RESVAL_P(broker->dict[total]->rsrc_id));
efree(broker->dict[total]);
total--;
} while (total>=0);
}
efree(broker->dict);
broker->dict = NULL;
}
enchant_broker_free(broker->pbroker);
}
efree(broker);
}
}
}
static void php_enchant_dict_free(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
if (rsrc->ptr) {
enchant_dict *pdict = (enchant_dict *)rsrc->ptr;
if (pdict) {
if (pdict->pdict && pdict->pbroker) {
enchant_broker_free_dict(pdict->pbroker->pbroker, pdict->pdict);
}
if (pdict->id) {
pdict->pbroker->dict[pdict->id-1]->next = NULL;
}
}
}
}
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(enchant)
{
le_enchant_broker = zend_register_list_destructors_ex(php_enchant_broker_free, NULL, "enchant broker", module_number);
le_enchant_dict = zend_register_list_destructors_ex(php_enchant_dict_free, NULL, "enchant dict", module_number);
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MSHUTDOWN_FUNCTION(enchant)
{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
static void __enumerate_providers_fn (const char * const name,
const char * const desc,
const char * const file,
void * ud)
{
php_info_print_table_row(3, name, desc, file);
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(enchant)
{
EnchantBroker *pbroker;
pbroker = enchant_broker_init();
php_info_print_table_start();
php_info_print_table_header(2, "enchant support", "enabled");
php_info_print_table_row(2, "Version", "@version@");
php_info_print_table_row(2, "Revision", "$Revision$");
php_info_print_table_end();
php_info_print_table_start();
enchant_broker_describe(pbroker, __enumerate_providers_fn, NULL);
php_info_print_table_end();
enchant_broker_free(pbroker);
}
/* }}} */
#define PHP_ENCHANT_GET_BROKER \
ZEND_FETCH_RESOURCE(pbroker, enchant_broker *, &broker, -1, "enchant_broker", le_enchant_broker); \
if (!pbroker || !pbroker->pbroker) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", "Resource broker invalid"); \
RETURN_FALSE; \
}
#define PHP_ENCHANT_GET_DICT \
ZEND_FETCH_RESOURCE(pdict, enchant_dict *, &dict, -1, "enchant dict", le_enchant_dict); \
if (!pdict || !pdict->pdict) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", "Invalid dictionary resource."); \
RETURN_FALSE; \
}
/* {{{ proto resource enchant_broker_init()
create a new broker object capable of requesting */
PHP_FUNCTION(enchant_broker_init)
{
enchant_broker *broker;
EnchantBroker *pbroker;
if (ZEND_NUM_ARGS()) {
ZEND_WRONG_PARAM_COUNT();
}
pbroker = enchant_broker_init();
if (pbroker) {
broker = (enchant_broker *) emalloc(sizeof(enchant_broker));
broker->pbroker = pbroker;
broker->dict = NULL;
broker->dictcnt = 0;
ZEND_REGISTER_RESOURCE(return_value, broker, le_enchant_broker);
broker->rsrc_id = return_value;
} else {
RETURN_FALSE;
}
}
/* }}} */
/* {{{ proto boolean enchant_free(resource broker)
Destroys the broker object and its dictionnaries */
PHP_FUNCTION(enchant_broker_free)
{
zval *broker;
enchant_broker *pbroker;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &broker) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_BROKER;
zend_list_delete(Z_RESVAL_P(broker));
RETURN_TRUE;
}
/* }}} */
/* {{{ proto string enchant_broker_get_error(resource broker)
Returns the last error of the broker */
PHP_FUNCTION(enchant_broker_get_error)
{
zval *broker;
enchant_broker *pbroker;
char *msg;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &broker) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_BROKER;
msg = enchant_broker_get_error(pbroker->pbroker);
if (msg) {
RETURN_STRING((char *)msg, 1);
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto resource enchant_broker_request_dict(resource broker, string tag)
create a new dictionary using tag, the non-empty language tag you wish to request
a dictionary for ("en_US", "de_DE", ...) */
PHP_FUNCTION(enchant_broker_request_dict)
{
zval *broker;
enchant_broker *pbroker;
enchant_dict *dict;
EnchantDict *d;
char *tag;
int taglen;
int pos;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &broker, &tag, &taglen) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_BROKER;
d = enchant_broker_request_dict(pbroker->pbroker, (const char *)tag);
if (d) {
if (pbroker->dictcnt) {
pbroker->dict = (enchant_dict **)erealloc(pbroker->dict, sizeof(enchant_dict *) * pbroker->dictcnt);
pos = pbroker->dictcnt++;
} else {
pbroker->dict = (enchant_dict **)emalloc(sizeof(enchant_dict *));
pos = 0;
pbroker->dictcnt++;
}
dict = pbroker->dict[pos] = (enchant_dict *)emalloc(sizeof(enchant_dict));
dict->id = pos;
dict->pbroker = pbroker;
dict->pdict = d;
dict->rsrc_id = return_value;
dict->prev = pos ? pbroker->dict[pos-1] : NULL;
dict->next = NULL;
pbroker->dict[pos] = dict;
if (pos) {
pbroker->dict[pos-1]->next = dict;
}
ZEND_REGISTER_RESOURCE(return_value, dict, le_enchant_dict);
} else {
RETURN_FALSE;
}
}
/* }}} */
/* {{{ proto resource enchant_broker_request_pwl_dict(resource dict, string filename)
creates a dictionary using a PWL file. A PWL file is personal word file one word per line.
It must exist before the call.*/
PHP_FUNCTION(enchant_broker_request_pwl_dict)
{
zval *broker;
enchant_broker *pbroker;
enchant_dict *dict;
EnchantDict *d;
char *pwl;
int pwllen;
int pos;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &broker, &pwl, &pwllen) == FAILURE) {
RETURN_FALSE;
}
if ((PG(safe_mode) && (!php_checkuid(pwl, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(pwl TSRMLS_CC)) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_BROKER;
d = enchant_broker_request_pwl_dict(pbroker->pbroker, (const char *)pwl);
if (d) {
if (pbroker->dictcnt) {
pos = pbroker->dictcnt++;
pbroker->dict = (enchant_dict **)erealloc(pbroker->dict, sizeof(enchant_dict *) * pbroker->dictcnt);
} else {
pbroker->dict = (enchant_dict **)emalloc(sizeof(enchant_dict *));
pos = 0;
pbroker->dictcnt++;
}
dict = pbroker->dict[pos] = (enchant_dict *)emalloc(sizeof(enchant_dict));
dict->id = pos;
dict->pbroker = pbroker;
dict->pdict = d;
dict->rsrc_id = return_value;
dict->prev = pos?pbroker->dict[pos-1]:NULL;
dict->next = NULL;
pbroker->dict[pos] = dict;
if (pos) {
pbroker->dict[pos-1]->next = dict;
}
ZEND_REGISTER_RESOURCE(return_value, dict, le_enchant_dict);
} else {
RETURN_FALSE;
}
}
/* }}} */
/* {{{ proto resource enchant_broker_free_dict(resource dict)
Free the dictionary resource */
PHP_FUNCTION(enchant_broker_free_dict)
{
zval *dict;
enchant_dict *pdict;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &dict) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_DICT;
zend_list_delete(Z_RESVAL_P(dict));
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool enchant_broker_dict_exists(resource broker, string tag)
Wether a dictionary exists or not. Using non-empty tag */
PHP_FUNCTION(enchant_broker_dict_exists)
{
zval *broker;
char *tag;
int taglen;
enchant_broker * pbroker;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &broker, &tag, &taglen) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_BROKER;
RETURN_BOOL(enchant_broker_dict_exists(pbroker->pbroker, tag));
}
/* }}} */
/* {{{ proto bool enchant_broker_set_ordering(resource broker, string tag, string ordering)
Declares a preference of dictionaries to use for the language
described/referred to by 'tag'. The ordering is a comma delimited
list of provider names. As a special exception, the "*" tag can
be used as a language tag to declare a default ordering for any
language that does not explictly declare an ordering. */
PHP_FUNCTION(enchant_broker_set_ordering)
{
zval *broker;
char *pordering;
int porderinglen;
char *ptag;
int ptaglen;
enchant_broker * pbroker;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &broker, &ptag, &ptaglen, &pordering, &porderinglen) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_BROKER;
enchant_broker_set_ordering(pbroker->pbroker, ptag, pordering);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto array enchant_broker_describe(resource broker)
Enumerates the Enchant providers and tells
you some rudimentary information about them. The same info is provided through phpinfo() */
PHP_FUNCTION(enchant_broker_describe)
{
EnchantBrokerDescribeFn describetozval = enumerate_providers_fn;
zval *broker;
enchant_broker * pbroker;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &broker) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_BROKER;
enchant_broker_describe(pbroker->pbroker, describetozval, (void *)return_value);
}
/* }}} */
/* {{{ proto bool enchant_dict_quick_check(resource dict, string word [, array &suggestions])
If the word is correctly spelled return true, otherwise return false, if suggestions variable
is provided, fill it with spelling alternatives. */
PHP_FUNCTION(enchant_dict_quick_check)
{
zval *dict, *sugg = NULL;
char *word;
int wordlen;
enchant_dict *pdict;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|z/", &dict, &word, &wordlen, &sugg) == FAILURE) {
RETURN_FALSE;
}
if (sugg) {
zval_dtor(sugg);
}
PHP_ENCHANT_GET_DICT;
if (enchant_dict_check(pdict->pdict, word, wordlen) > 0) {
if (!sugg && ZEND_NUM_ARGS() == 2) {
RETURN_FALSE;
}
int n_sugg;
char **suggs;
array_init(sugg);
suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg);
if (suggs && n_sugg) {
int i;
for (i = 0; i < n_sugg; i++) {
add_next_index_string(sugg, suggs[i], 1);
}
enchant_dict_free_suggestions(pdict->pdict, suggs);
}
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool enchant_dict_check(resource dict, string word)
If the word is correctly spelled return true, otherwise return false */
PHP_FUNCTION(enchant_dict_check)
{
zval *dict;
char *word;
int wordlen;
enchant_dict *pdict;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_DICT;
RETURN_BOOL(!enchant_dict_check(pdict->pdict, word, wordlen));
}
/* }}} */
/* {{{ proto array enchant_dict_suggest(resource dict, string word)
Will return a list of values if any of those pre-conditions are not met.*/
PHP_FUNCTION(enchant_dict_suggest)
{
zval *dict;
char *word;
int wordlen;
char **suggs;
enchant_dict *pdict;
int n_sugg;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_DICT;
suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg);
if (suggs && n_sugg) {
int i;
array_init(return_value);
for (i = 0; i < n_sugg; i++) {
add_next_index_string(return_value, suggs[i], 1);
}
enchant_dict_free_suggestions(pdict->pdict, suggs);
}
}
/* }}} */
/* {{{ proto void enchant_dict_add_to_personal(resource dict, string word)
add 'word' to personal word list */
PHP_FUNCTION(enchant_dict_add_to_personal)
{
zval *dict;
char *word;
int wordlen;
enchant_dict *pdict;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_DICT;
enchant_dict_add_to_personal(pdict->pdict, word, wordlen);
}
/* }}} */
/* {{{ proto void enchant_dict_add_to_session(resource dict, string word)
add 'word' to this spell-checking session */
PHP_FUNCTION(enchant_dict_add_to_session)
{
zval *dict;
char *word;
int wordlen;
enchant_dict *pdict;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_DICT;
enchant_dict_add_to_session(pdict->pdict, word, wordlen);
}
/* }}} */
/* {{{ proto bool enchant_dict_is_in_session(resource dict, string word)
whether or not 'word' exists in this spelling-session */
PHP_FUNCTION(enchant_dict_is_in_session)
{
zval *dict;
char *word;
int wordlen;
enchant_dict *pdict;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_DICT;
RETURN_BOOL(enchant_dict_is_in_session(pdict->pdict, word, wordlen));
}
/* }}} */
/* {{{ proto void enchant_dict_store_replacement(resource dict, string mis, string cor)
add a correction for 'mis' using 'cor'.
Notes that you replaced @mis with @cor, so it's possibly more likely
that future occurrences of @mis will be replaced with @cor. So it might
bump @cor up in the suggestion list.*/
PHP_FUNCTION(enchant_dict_store_replacement)
{
zval *dict;
char *mis, *cor;
int mislen, corlen;
enchant_dict *pdict;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &dict, &mis, &mislen, &cor, &corlen) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_DICT;
enchant_dict_store_replacement(pdict->pdict, mis, mislen, cor, corlen);
}
/* }}} */
/* {{{ proto string enchant_dict_get_error(resource dict)
Returns the last error of the current spelling-session */
PHP_FUNCTION(enchant_dict_get_error)
{
zval *dict;
enchant_dict *pdict;
char *msg;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &dict) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_DICT;
msg = enchant_dict_get_error(pdict->pdict);
if (msg) {
RETURN_STRING((char *)msg, 1);
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto array enchant_dict_describe(resource dict)
Describes an individual dictionary 'dict' */
PHP_FUNCTION(enchant_dict_describe)
{
zval *dict;
enchant_dict *pdict;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &dict) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_DICT;
enchant_dict_describe(pdict->pdict, describe_dict_fn, (void *)return_value);
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
-73
View File
@@ -1,73 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE package SYSTEM "../pear/package.dtd">
<package>
<name>enchant</name>
<summary>libenchant binder, support near all spelling tools</summary>
<maintainers>
<maintainer>
<user>pajoye</user>
<name>Pierre-Alain Joye</name>
<email>paj@pearfr.org</email>
<role>lead</role>
</maintainer>
<maintainer>
<user>iliaa</user>
<name>Ilia Alshanetsky</name>
<email>ilia@php.net</email>
<role>developer</role>
</maintainer>
</maintainers>
<description>Enchant is a binder for libenchant. Libenchant provides a common
API for many spell libraries:
- aspell/pspell (intended to replace ispell)
- hspell (hebrew)
- ispell
- myspell (OpenOffice project, mozilla)
- uspell (primarily Yiddish, Hebrew, and Eastern European languages)
A plugin system allows to add custom spell support.
see www.abisource.com/enchant/</description>
<license>PHP</license>
<release>
<state>beta</state>
<version>0.2.1</version>
<date>2004-03-11</date>
<notes>- Fix possible leak in suggestions result
- Move to beta status</notes>
<filelist>
<file role="src" name="config.m4"/>
<file role="src" name="config.w32"/>
<file role="src" name="enchant.c"/>
<file role="src" name="php_enchant.h"/>
<file role="doc" name="CREDITS"/>
<dir name="docs" role="doc">
<dir name="examples">
<file name="example1.php"/>
</dir>
</dir>
</filelist>
<configureoptions>
<configureoption name="with-enchant" default="shared" prompt="libenchant prefix?"/>
</configureoptions>
<deps>
<dep type="php" rel="ge" version="5" />
</deps>
</release>
<changelog>
<release>
<state>alpha</state>
<version>0.2.0</version>
<notes>- Add Ilia Alshanetsky as maintainer
- Cleanup sources codes (ilia)
- Add enchant_dict_quick_check (ilia)</notes>
</release>
<release>
<version>0.1</version>
<state>alpha</state>
<date>2003-03-08</date>
<notes>Initial release</notes>
</release>
</changelog>
</package>
<!--
vim:et:ts=1:sw=1
-->
-80
View File
@@ -1,80 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 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/3_0.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: Pierre-Alain Joye <paj@pearfr.org> |
+----------------------------------------------------------------------+
$Id$
*/
#ifndef PHP_ENCHANT_H
#define PHP_ENCHANT_H
extern zend_module_entry enchant_module_entry;
#define phpext_enchant_ptr &enchant_module_entry
#ifdef PHP_WIN32
#define PHP_ENCHANT_API __declspec(dllexport)
#else
#define PHP_ENCHANT_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
static void php_enchant_broker_free(zend_rsrc_list_entry *rsrc TSRMLS_DC);
static void php_enchant_dict_free(zend_rsrc_list_entry *rsrc TSRMLS_DC);
PHP_MINIT_FUNCTION(enchant);
PHP_MSHUTDOWN_FUNCTION(enchant);
PHP_MINFO_FUNCTION(enchant);
PHP_FUNCTION(enchant_broker_init);
PHP_FUNCTION(enchant_broker_free);
PHP_FUNCTION(enchant_broker_get_error);
PHP_FUNCTION(enchant_broker_request_dict);
PHP_FUNCTION(enchant_broker_request_pwl_dict);
PHP_FUNCTION(enchant_broker_free_dict);
PHP_FUNCTION(enchant_broker_dict_exists);
PHP_FUNCTION(enchant_broker_set_ordering);
PHP_FUNCTION(enchant_broker_describe);
PHP_FUNCTION(enchant_dict_check);
PHP_FUNCTION(enchant_dict_suggest);
PHP_FUNCTION(enchant_dict_add_to_personal);
PHP_FUNCTION(enchant_dict_add_to_session);
PHP_FUNCTION(enchant_dict_is_in_session);
PHP_FUNCTION(enchant_dict_store_replacement);
PHP_FUNCTION(enchant_dict_get_error);
PHP_FUNCTION(enchant_dict_describe);
PHP_FUNCTION(enchant_dict_quick_check);
#ifdef ZTS
#define ENCHANT_G(v) TSRMG(enchant_globals_id, zend_enchant_globals *, v)
#else
#define ENCHANT_G(v) (enchant_globals.v)
#endif
#endif /* PHP_ENCHANT_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* indent-tabs-mode: t
* End:
*/
-2
View File
@@ -1,2 +0,0 @@
fileinfo
Ilia Alshanetsky
View File
Whitespace-only changes.
-54
View File
@@ -1,54 +0,0 @@
dnl $Id$
dnl config.m4 for extension fileinfo
PHP_ARG_WITH(fileinfo, for fileinfo support,
[ --with-fileinfo=DIR Include fileinfo support])
if test "$PHP_FILEINFO" != "no"; then
SEARCH_PATH="/usr/local /usr"
SEARCH_FOR="/include/magic.h"
if test -r $PHP_FILEINFO/$SEARCH_FOR; then
FILEINFO_DIR=$PHP_FILEINFO
else
AC_MSG_CHECKING([for magic files in default path])
for i in $SEARCH_PATH ; do
if test -r $i/$SEARCH_FOR; then
FILEINFO_DIR=$i
AC_MSG_RESULT(found in $i)
fi
done
fi
if test -z "$FILEINFO_DIR"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Please reinstall the libmagic distribution])
fi
PHP_ADD_INCLUDE($FILEINFO_DIR/include)
LIBNAME=magic
LIBSYMBOL=magic_open
PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
[
PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $FILEINFO_DIR/lib, FILEINFO_SHARED_LIBADD)
AC_DEFINE(HAVE_FILEINFOLIB,1,[ ])
],[
AC_MSG_ERROR([wrong magic lib version or lib not found])
],[
-L$FILEINFO_DIR/lib -lm -ldl
])
MAGIC_MIME_LOCATIONS="/usr/local/share/file/magic /usr/share/file/magic /etc/magic"
for i in $MAGIC_MIME_LOCATIONS; do
if test -f $i; then
PHP_DEFAULT_MAGIC_FILE=$i
break
fi
done
AC_DEFINE_UNQUOTED(PHP_DEFAULT_MAGIC_FILE,"$PHP_DEFAULT_MAGIC_FILE",[magic file path])
PHP_SUBST(FILEINFO_SHARED_LIBADD)
PHP_NEW_EXTENSION(fileinfo, fileinfo.c, $ext_shared)
fi
-433
View File
@@ -1,433 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.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: Ilia Alshanetsky <ilia@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <magic.h>
/*
* HOWMANY specifies the maximum offset libmagic will look at
* this is currently hardcoded in the libmagic source but not exported
*/
#ifndef HOWMANY
#define HOWMANY 65536
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "ext/standard/file.h" /* needed for context stuff */
#include "php_fileinfo.h"
#include "fopen_wrappers.h" /* needed for is_url */
struct php_fileinfo {
long options;
struct magic_set *magic;
};
#ifndef PHP_DEFAULT_MAGIC_FILE
#define PHP_DEFAULT_MAGIC_FILE NULL
#endif
#ifdef ZEND_ENGINE_2
static zend_object_handlers finfo_object_handlers;
zend_class_entry *finfo_class_entry;
struct finfo_object {
zend_object zo;
struct php_fileinfo *ptr;
};
#define FILEINFO_DECLARE_INIT_OBJECT(object) \
zval *object = getThis();
#define FILEINFO_REGISTER_OBJECT(_object, _ptr) \
{ \
struct finfo_object *obj; \
obj = (struct finfo_object*)zend_object_store_get_object(_object TSRMLS_CC); \
obj->ptr = _ptr; \
}
#define FILEINFO_FROM_OBJECT(finfo, object) \
{ \
struct finfo_object *obj = zend_object_store_get_object(object TSRMLS_CC); \
finfo = obj->ptr; \
if (!finfo) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The invalid fileinfo object."); \
RETURN_FALSE; \
} \
}
/* {{{ finfo_objects_dtor
*/
static void finfo_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC)
{
struct finfo_object *intern = (struct finfo_object *) object;
if (intern->ptr) {
magic_close(intern->ptr->magic);
efree(intern->ptr);
}
efree(intern);
}
/* }}} */
/* {{{ finfo_objects_new
*/
PHP_FILEINFO_API zend_object_value finfo_objects_new(zend_class_entry *class_type TSRMLS_DC)
{
zend_object_value retval;
struct finfo_object *intern;
intern = emalloc(sizeof(struct finfo_object));
intern->zo.ce = class_type;
intern->zo.in_get = 0;
intern->zo.in_set = 0;
intern->zo.properties = NULL;
intern->ptr = NULL;
retval.handle = zend_objects_store_put(intern, finfo_objects_dtor, NULL, NULL TSRMLS_CC);
retval.handlers = (zend_object_handlers *) &finfo_object_handlers;
return retval;
}
/* }}} */
/* {{{ finfo_class_functions
*/
function_entry finfo_class_functions[] = {
ZEND_ME_MAPPING(finfo, finfo_open, NULL)
ZEND_ME_MAPPING(set_flags, finfo_set_flags,NULL)
ZEND_ME_MAPPING(file, finfo_file, NULL)
ZEND_ME_MAPPING(buffer, finfo_buffer, NULL)
{NULL, NULL, NULL}
};
/* }}} */
#else
#define FILEINFO_REGISTER_OBJECT(_object, _ptr) {}
#define FILEINFO_FROM_OBJECT(socket_id, object) {}
#define FILEINFO_DECLARE_INIT_OBJECT(object)
#define object 0
#endif
#define FINFO_SET_OPTION(magic, options) \
if (magic_setflags(magic, options) == -1) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to set option '%ld' %d:%s", \
options, magic_errno(magic), magic_error(magic)); \
RETURN_FALSE; \
}
/* True global resources - no need for thread safety here */
static int le_fileinfo;
void finfo_resource_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
if (rsrc->ptr) {
struct php_fileinfo *finfo = (struct php_fileinfo *) rsrc->ptr;
magic_close(finfo->magic);
efree(rsrc->ptr);
rsrc->ptr = NULL;
}
}
/* {{{ fileinfo_functions[]
*/
function_entry fileinfo_functions[] = {
PHP_FE(finfo_open, NULL)
PHP_FE(finfo_close, NULL)
PHP_FE(finfo_set_flags, NULL)
PHP_FE(finfo_file, NULL)
PHP_FE(finfo_buffer, NULL)
{NULL, NULL, NULL}
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(finfo)
{
#ifdef ZEND_ENGINE_2
zend_class_entry _finfo_class_entry;
INIT_CLASS_ENTRY(_finfo_class_entry, "finfo", finfo_class_functions);
_finfo_class_entry.create_object = finfo_objects_new;
finfo_class_entry = zend_register_internal_class(&_finfo_class_entry TSRMLS_CC);
/* copy the standard object handlers to you handler table */
memcpy(&finfo_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
#endif /* ZEND_ENGINE_2 */
le_fileinfo = zend_register_list_destructors_ex(finfo_resource_destructor, NULL, "file_info", module_number);
REGISTER_LONG_CONSTANT("FILEINFO_NONE", MAGIC_NONE, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILEINFO_SYMLINK", MAGIC_SYMLINK, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILEINFO_MIME", MAGIC_MIME, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILEINFO_COMPRESS", MAGIC_COMPRESS, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILEINFO_DEVICES", MAGIC_DEVICES, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILEINFO_CONTINUE", MAGIC_CONTINUE, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILEINFO_PRESERVE_ATIME", MAGIC_PRESERVE_ATIME, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILEINFO_RAW", MAGIC_RAW, CONST_CS|CONST_PERSISTENT);
return SUCCESS;
}
/* }}} */
/* {{{ fileinfo_module_entry
*/
zend_module_entry fileinfo_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
"fileinfo",
fileinfo_functions,
PHP_MINIT(finfo),
NULL,
NULL,
NULL,
PHP_MINFO(fileinfo),
#if ZEND_MODULE_API_NO >= 20010901
"0.1", /* Replace with version number for your extension */
#endif
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#ifdef COMPILE_DL_FILEINFO
ZEND_GET_MODULE(fileinfo)
#endif
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(fileinfo)
{
php_info_print_table_start();
php_info_print_table_header(2, "fileinfo support", "enabled");
php_info_print_table_end();
}
/* }}} */
/* {{{ proto resource finfo_open([int options [, string arg]])
Create a new fileinfo resource. */
PHP_FUNCTION(finfo_open)
{
long options = MAGIC_NONE;
char *file = PHP_DEFAULT_MAGIC_FILE;
int file_len = 0;
struct php_fileinfo *finfo;
FILEINFO_DECLARE_INIT_OBJECT(object)
char resolved_path[MAXPATHLEN];
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ls", &options, &file, &file_len) == FAILURE) {
RETURN_FALSE;
}
if (file_len) { /* user specified filed, perform open_basedir checks */
if (!VCWD_REALPATH(file, resolved_path)) {
RETURN_FALSE;
}
file = resolved_path;
if ((PG(safe_mode) && (!php_checkuid(file, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(file TSRMLS_CC)) {
RETURN_FALSE;
}
}
finfo = emalloc(sizeof(struct php_fileinfo));
finfo->options = options;
finfo->magic = magic_open(options);
if (finfo->magic == NULL) {
efree(finfo);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid mode '%ld'.", options);
RETURN_FALSE;
}
if (magic_load(finfo->magic, file) == -1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to load magic database at '%s'.", file);
efree(finfo);
magic_close(finfo->magic);
RETURN_FALSE;
}
if (object) {
FILEINFO_REGISTER_OBJECT(object, finfo);
} else {
ZEND_REGISTER_RESOURCE(return_value, finfo, le_fileinfo);
}
}
/* }}} */
/* {{{ proto resource finfo_close(resource finfo)
Close fileinfo resource. */
PHP_FUNCTION(finfo_close)
{
struct php_fileinfo *finfo;
zval *zfinfo;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zfinfo) == FAILURE) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE(finfo, struct php_fileinfo *, &zfinfo, -1, "file_info", le_fileinfo);
zend_list_delete(Z_RESVAL_P(zfinfo));
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool finfo_set_flags(resource finfo, int options)
Set libmagic configuration options. */
PHP_FUNCTION(finfo_set_flags)
{
long options;
struct php_fileinfo *finfo;
zval *zfinfo;
FILEINFO_DECLARE_INIT_OBJECT(object)
if (object) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &options) == FAILURE) {
RETURN_FALSE;
}
FILEINFO_FROM_OBJECT(finfo, object);
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl", &zfinfo, &options) == FAILURE) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE(finfo, struct php_fileinfo *, &zfinfo, -1, "file_info", le_fileinfo);
}
FINFO_SET_OPTION(finfo->magic, options)
finfo->options = options;
RETURN_TRUE;
}
/* }}} */
static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
long options = 0;
char *buffer, *tmp, *ret_val;
int buffer_len;
struct php_fileinfo *finfo;
zval *zfinfo, *zcontext = NULL;
FILEINFO_DECLARE_INIT_OBJECT(object)
if (object) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lbz", &buffer, &buffer_len, &options, &zcontext) == FAILURE) {
RETURN_FALSE;
}
FILEINFO_FROM_OBJECT(finfo, object);
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs|lbz", &zfinfo, &buffer, &buffer_len, &options, &zcontext) == FAILURE) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE(finfo, struct php_fileinfo *, &zfinfo, -1, "file_info", le_fileinfo);
}
/* Set options for the current file/buffer. */
if (options) {
FINFO_SET_OPTION(finfo->magic, options)
}
if (mode) { /* file */
/* determine if the file is a local file or remote URL */
char *tmp2;
php_stream_wrapper *wrap = php_stream_locate_url_wrapper(buffer, &tmp2, 0 TSRMLS_DC);
if (wrap && wrap->is_url) {
#ifdef ZEND_ENGINE_2
php_stream_context *context = php_stream_context_from_zval(zcontext, 0);
#else
php_stream_context *context = NULL;
#endif
php_stream *stream = php_stream_open_wrapper_ex(buffer, "rb",
ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, context);
if (!stream) {
RETURN_FALSE;
}
buffer_len = php_stream_copy_to_mem(stream, &tmp, HOWMANY, 0);
php_stream_close(stream);
if (buffer_len == 0) {
RETURN_FALSE;
}
} else { /* local file */
char resolved_path[MAXPATHLEN];
if (!VCWD_REALPATH(buffer, resolved_path)) {
RETURN_FALSE;
}
ret_val = (char *) magic_file(finfo->magic, buffer);
goto common;
}
} else { /* buffer */
tmp = buffer;
}
ret_val = (char *) magic_buffer(finfo->magic, tmp, buffer_len);
if (mode) {
efree(tmp);
}
common:
/* Restore options */
if (options) {
FINFO_SET_OPTION(finfo->magic, finfo->options)
}
if (!ret_val) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed identify data %d:%s",
magic_errno(finfo->magic), magic_error(finfo->magic));
RETURN_FALSE;
} else {
RETURN_STRING(ret_val, 1);
}
}
/* {{{ proto string finfo_file(resource finfo, char *file_name [, int options [, resource context]])
Return information about a file. */
PHP_FUNCTION(finfo_file)
{
_php_finfo_get_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
}
/* }}} */
/* {{{ proto string finfo_buffer(resource finfo, char *string [, int options])
Return infromation about a string buffer. */
PHP_FUNCTION(finfo_buffer)
{
_php_finfo_get_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
-29
View File
@@ -1,29 +0,0 @@
<?php
if(!extension_loaded('fileinfo')) {
dl('fileinfo.' . PHP_SHLIB_SUFFIX);
}
if(!extension_loaded('fileinfo')) {
die("fileinfo extension is not avaliable, please compile it.\n");
}
// normal operation
$res = finfo_open(FILEINFO_MIME); /* return mime type ala mimetype extension */
$files = glob("*");
foreach ($files as $file) {
echo finfo_file($res, $file) . "\n";
}
finfo_close($res);
// OO mode
/*
* FILEINFO_PRESERVE_ATIME - if possible preserve the original access time
* FILEINFO_SYMLINK - follow symlinks
* FILEINFO_DEVICES - look at the contents of blocks or character special devices
* FILEINFO_COMPRESS - decompress compressed files
*/
$fi = new finfo(FILEINFO_PRESERVE_ATIME|FILEINFO_SYMLINK|FILEINFO_DEVICES|FILEINFO_COMPRESS);
$files = glob("*");
foreach ($files as $file) {
echo $fi->buffer(file_get_contents($file)) . "\n";
}
?>
-43
View File
@@ -1,43 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE package SYSTEM "../pear/package.dtd">
<package>
<name>Fileinfo</name>
<summary>libmagic bindings</summary>
<maintainers>
<maintainer>
<user>iliaa</user>
<name>Ilia Alshanetsky</name>
<email>ilia@php.net</email>
<role>lead</role>
</maintainer>
</maintainers>
<description>
This extension allows retrieval of information regarding vast majority of file.
This information may include dimensions, quality, length etc...
Additionally it can also be used to retrieve the mime type for a particular
file and for text files proper language encoding.
</description>
<license>PHP</license>
<release>
<state>beta</state>
<version>0.2</version>
<date>2004-05-26</date>
<notes>
Fixed bug that caused PHP to refuse to recognize fileinfo.so.
</notes>
<filelist>
<file role="src" name="config.m4"/>
<file role="src" name="fileinfo.c"/>
<file role="src" name="php_fileinfo.h"/>
<file role="doc" name="CREDITS"/>
<file role="doc" name="EXPERIMENTAL"/>
<file role="doc" name="fileinfo.php"/>
</filelist>
<deps>
</deps>
</release>
</package>
<!--
vim:et:ts=1:sw=1
-->
-61
View File
@@ -1,61 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.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: Ilia Alshanetsky <ilia@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef PHP_FILEINFO_H
#define PHP_FILEINFO_H
extern zend_module_entry fileinfo_module_entry;
#define phpext_fileinfo_ptr &fileinfo_module_entry
#ifdef PHP_WIN32
#define PHP_FILEINFO_API __declspec(dllexport)
#else
#define PHP_FILEINFO_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
PHP_MINFO_FUNCTION(fileinfo);
PHP_FUNCTION(finfo_open);
PHP_FUNCTION(finfo_close);
PHP_FUNCTION(finfo_set_flags);
PHP_FUNCTION(finfo_file);
PHP_FUNCTION(finfo_buffer);
#ifdef ZTS
#define FILEINFO_G(v) TSRMG(fileinfo_globals_id, zend_fileinfo_globals *, v)
#else
#define FILEINFO_G(v) (fileinfo_globals.v)
#endif
#endif /* PHP_FILEINFO_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
+4 -1
View File
@@ -259,6 +259,7 @@ AC_DEFUN(PHP_GD_CHECK_VERSION,[
PHP_CHECK_LIBRARY(gd, gdImageGifCtx, [AC_DEFINE(HAVE_GD_GIF_CTX, 1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ])
PHP_CHECK_LIBRARY(gd, gdCacheCreate, [AC_DEFINE(HAVE_GD_CACHE_CREATE, 1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ])
PHP_CHECK_LIBRARY(gd, gdFontCacheShutdown, [AC_DEFINE(HAVE_GD_THREAD_SAFE, 1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ])
PHP_CHECK_LIBRARY(gd, gdNewDynamicCtxEx, [AC_DEFINE(HAVE_GD_DYNAMIC_CTX_EX, 1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ])
])
dnl
@@ -272,7 +273,7 @@ if test "$PHP_GD" = "yes"; then
libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c libgd/gdfontmb.c libgd/gdfontl.c \
libgd/gdfontg.c libgd/gdtables.c libgd/gdft.c libgd/gdcache.c libgd/gdkanji.c \
libgd/wbmp.c libgd/gd_wbmp.c libgd/gdhelpers.c libgd/gd_topal.c libgd/gd_gif_in.c \
libgd/xbm.c"
libgd/xbm.c libgd/gd_gif_out.c "
dnl check for fabsf and floorf which are available since C99
AC_CHECK_FUNCS(fabsf floorf)
@@ -306,7 +307,9 @@ dnl These are always available with bundled library
AC_DEFINE(HAVE_GD_XBM, 1, [ ])
AC_DEFINE(HAVE_GD_BUNDLED, 1, [ ])
AC_DEFINE(HAVE_GD_GIF_READ, 1, [ ])
AC_DEFINE(HAVE_GD_GIF_CREATE, 1, [ ])
AC_DEFINE(HAVE_GD_IMAGEELLIPSE, 1, [ ])
AC_DEFINE(HAVE_GD_DYNAMIC_CTX_EX, 1, [ ])
dnl Make sure the libgd/ is first in the include path
GDLIB_CFLAGS="-DHAVE_LIBPNG"
+2 -1
View File
@@ -13,7 +13,7 @@ if (PHP_GD != "no") {
EXTENSION("gd", "gd.c gdttf.c", null, "-Iext/gd/libgd", "php_gd2.dll");
ADD_SOURCES("ext/gd/libgd", "gd2copypal.c gd_arc_f_buggy.c gd.c \
gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \
gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gdhelpers.c gd_io.c gd_io_dp.c \
gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \
gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \
gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c xbm.c", "gd");
AC_DEFINE('HAVE_LIBGD', 1, 'GD support');
@@ -21,6 +21,7 @@ if (PHP_GD != "no") {
/D HAVE_GD_BUNDLED=1 \
/D HAVE_GD_GD2 \
/D HAVE_GD_GIF_READ=1 \
/D HAVE_GD_GIF_CREATE=1 \
/D HAVE_GDIMAGECOLORRESOLVE=1 \
/D HAVE_GD_IMAGESETBRUSH=1 \
/D HAVE_GD_IMAGESETTILE=1 \
+8 -4
View File
@@ -115,6 +115,10 @@ extern int gdImageColorResolve(gdImagePtr, int, int, int);
int gdImageColorClosestHWB(gdImagePtr im, int r, int g, int b);
#endif
#ifndef HAVE_GD_DYNAMIC_CTX_EX
#define gdNewDynamicCtxEx(len, data, val) gdNewDynamicCtx(len, data)
#endif
/* Section Filters Declarations */
/* IMPORTANT NOTE FOR NEW FILTER
* Do not forget to update:
@@ -453,7 +457,7 @@ PHP_RSHUTDOWN_FUNCTION(gd)
/* }}} */
#if HAVE_GD_BUNDLED
#define PHP_GD_VERSION_STRING "bundled (2.0.23 compatible)"
#define PHP_GD_VERSION_STRING "bundled (2.0.28 compatible)"
#elif HAVE_LIBGD20
#define PHP_GD_VERSION_STRING "2.0 or higher"
#elif HAVE_GDIMAGECOLORRESOLVE
@@ -1343,7 +1347,7 @@ static int _php_image_type (char data[8])
#ifdef HAVE_GD_WBMP
else {
gdIOCtx *io_ctx;
io_ctx = gdNewDynamicCtx(8, data);
io_ctx = gdNewDynamicCtxEx(8, data, 0);
if (io_ctx) {
if (getmbi((int(*)(void *)) gdGetC, io_ctx) == 0 && skipheader((int(*)(void *)) gdGetC, io_ctx) == 0 ) {
#if HAVE_LIBGD204
@@ -1375,7 +1379,7 @@ gdImagePtr _php_image_create_from_string(zval **data, char *tn, gdImagePtr (*ioc
gdImagePtr im;
gdIOCtx *io_ctx;
io_ctx = gdNewDynamicCtx (Z_STRLEN_PP(data), Z_STRVAL_PP(data));
io_ctx = gdNewDynamicCtxEx(Z_STRLEN_PP(data), Z_STRVAL_PP(data), 0);
if (!io_ctx) {
return NULL;
@@ -1530,7 +1534,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
goto out_err;
}
io_ctx = gdNewDynamicCtx(buff_size, buff);
io_ctx = gdNewDynamicCtxEx(buff_size, buff, 0);
if (!io_ctx) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot allocate GD IO context");
goto out_err;
+8 -4
View File
@@ -43,8 +43,8 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release_TS"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D "HAVE_GD_WBMP" /D "HAVE_GD_XBM" /D HAVE_LIBGD13=1 /D HAVE_LIBGD=1 /D HAVE_LIBGD15=1 /D HAVE_LIBGD204=1 /FR /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /I "libgd" /D ZEND_DEBUG=0 /D HAVE_LIBGD15=1 /D HAVE_LIBGD204=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D "HAVE_GD_WBMP" /D "HAVE_GD_XBM" /D HAVE_LIBGD=1 /D HAVE_LIBGD13=1 /D HAVE_LIBGD20=1 /D "USE_GD_IOCTX" /D HAVE_LIBFREETYPE=1 /D "USE_GD_IMGSTRTTF" /D HAVE_GD_STRINGTTF=1 /D HAVE_GD_BUNDLED=1 /D "MSWIN32" /D "HAVE_LIBPNG" /D "HAVE_LIBJPEG" /D "HAVE_GD_GD2" /D HAVE_GD_STRINGFTEX=1 /D HAVE_GD_IMAGESETBRUSH=1 /D HAVE_GD_IMAGESETTILE=1 /FR /FD /c
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GD_GIF_CREATE=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D "HAVE_GD_WBMP" /D "HAVE_GD_XBM" /D HAVE_LIBGD13=1 /D HAVE_LIBGD=1 /D HAVE_LIBGD15=1 /D HAVE_LIBGD204=1 /FR /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /I "libgd" /D ZEND_DEBUG=0 /D HAVE_LIBGD15=1 /D HAVE_LIBGD204=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GD_GIF_CREATE=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D "HAVE_GD_WBMP" /D "HAVE_GD_XBM" /D HAVE_LIBGD=1 /D HAVE_LIBGD13=1 /D HAVE_LIBGD20=1 /D "USE_GD_IOCTX" /D HAVE_LIBFREETYPE=1 /D "USE_GD_IMGSTRTTF" /D HAVE_GD_STRINGTTF=1 /D HAVE_GD_BUNDLED=1 /D "MSWIN32" /D "HAVE_LIBPNG" /D "HAVE_LIBJPEG" /D "HAVE_GD_GD2" /D HAVE_GD_STRINGFTEX=1 /D HAVE_GD_IMAGESETBRUSH=1 /D HAVE_GD_IMAGESETTILE=1 /FR /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@@ -73,8 +73,8 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug_TS"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D "HAVE_GD_WBMP" /D HAVE_LIBGD13=1 /D HAVE_LIBGD=1 /D HAVE_LIBGD15=1 /D HAVE_LIBGD204=1 /FR /YX /FD /c
# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /I "libgd" /D ZEND_DEBUG=1 /D "HAVE_LIBGD15" /D HAVE_LIBGD204=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D "HAVE_GD_WBMP" /D HAVE_LIBGD=1 /D HAVE_LIBGD13=1 /D HAVE_LIBGD20=1 /D "USE_GD_IOCTX" /D HAVE_LIBFREETYPE=1 /D "USE_GD_IMGSTRTTF" /D HAVE_GD_STRINGTTF=1 /D HAVE_GD_BUNDLED=1 /D "MSWIN32" /D "HAVE_LIBPNG" /D "HAVE_LIBJPEG" /D "HAVE_GD_GD2" /D HAVE_GD_STRINGFTEX=1 /D HAVE_GD_IMAGESETBRUSH=1 /D HAVE_GD_IMAGESETTILE=1 /FR /FD /c
# ADD BASE CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GD_GIF_CREATE=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D "HAVE_GD_WBMP" /D HAVE_LIBGD13=1 /D HAVE_LIBGD=1 /D HAVE_LIBGD15=1 /D HAVE_LIBGD204=1 /FR /YX /FD /c
# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /I "libgd" /D ZEND_DEBUG=1 /D "HAVE_LIBGD15" /D HAVE_LIBGD204=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GD_GIF_CREATE=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D "HAVE_GD_WBMP" /D HAVE_LIBGD=1 /D HAVE_LIBGD13=1 /D HAVE_LIBGD20=1 /D "USE_GD_IOCTX" /D HAVE_LIBFREETYPE=1 /D "USE_GD_IMGSTRTTF" /D HAVE_GD_STRINGTTF=1 /D HAVE_GD_BUNDLED=1 /D "MSWIN32" /D "HAVE_LIBPNG" /D "HAVE_LIBJPEG" /D "HAVE_GD_GD2" /D HAVE_GD_STRINGFTEX=1 /D HAVE_GD_IMAGESETBRUSH=1 /D HAVE_GD_IMAGESETTILE=1 /FR /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@@ -213,6 +213,10 @@ SOURCE=.\libgd\gd_gd2.c
SOURCE=.\libgd\gd_gif_in.c
# End Source File
# Begin Source File
SOURCE=.\libgd\gd_gif_out.c
# End Source File
# Begin Source File
SOURCE=.\libgd\gd_io.c
+5
View File
@@ -407,8 +407,11 @@ void gdImageColorDeallocate(gdImagePtr im, int color);
conversion to palette is not great (for small images
it can be negative) and the quality loss is ugly. */
gdImagePtr gdImageCreatePaletteFromTrueColor (gdImagePtr im, int ditherFlag, int colorsWanted);
void gdImageTrueColorToPalette(gdImagePtr im, int ditherFlag, int colorsWanted);
/* An attempt at getting the results of gdImageTrueColorToPalette
to look a bit more like the original (im1 is the original
and im2 is the palette version */
@@ -428,6 +431,8 @@ void gdImageColorTransparent(gdImagePtr im, int color);
void gdImagePaletteCopy(gdImagePtr dst, gdImagePtr src);
void gdImagePng(gdImagePtr im, FILE *out);
void gdImagePngCtx(gdImagePtr im, gdIOCtx *out);
void gdImageGif(gdImagePtr im, FILE *out);
void gdImageGifCtx(gdImagePtr im, gdIOCtx *out);
/* 2.0.12: Compression level: 0-9 or -1, where 0 is NO COMPRESSION at all,
* 1 is FASTEST but produces larger files, 9 provides the best
* compression (smallest files) but takes a long time to compress, and
+759
View File
@@ -0,0 +1,759 @@
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include "gd.h"
/* Code drawn from ppmtogif.c, from the pbmplus package
**
** Based on GIFENCOD by David Rowley <mgardi@watdscu.waterloo.edu>. A
** Lempel-Zim compression based on "compress".
**
** Modified by Marcel Wijkstra <wijkstra@fwi.uva.nl>
**
** Copyright (C) 1989 by Jef Poskanzer.
**
** Permission to use, copy, modify, and distribute this software and its
** documentation for any purpose and without fee is hereby granted, provided
** that the above copyright notice appear in all copies and that both that
** copyright notice and this permission notice appear in supporting
** documentation. This software is provided "as is" without express or
** implied warranty.
**
** The Graphics Interchange Format(c) is the Copyright property of
** CompuServe Incorporated. GIF(sm) is a Service Mark property of
** CompuServe Incorporated.
*/
/*
* a code_int must be able to hold 2**GIFBITS values of type int, and also -1
*/
typedef int code_int;
#ifdef SIGNED_COMPARE_SLOW
typedef unsigned long int count_int;
typedef unsigned short int count_short;
#else /*SIGNED_COMPARE_SLOW*/
typedef long int count_int;
#endif /*SIGNED_COMPARE_SLOW*/
/* 2.0.28: threadsafe */
#define maxbits GIFBITS
/* should NEVER generate this code */
#define maxmaxcode ((code_int)1 << GIFBITS)
#define HSIZE 5003 /* 80% occupancy */
#define hsize HSIZE /* Apparently invariant, left over from
compress */
typedef struct {
int Width, Height;
int curx, cury;
long CountDown;
int Pass;
int Interlace;
int n_bits; /* number of bits/code */
code_int maxcode; /* maximum code, given n_bits */
count_int htab [HSIZE];
unsigned short codetab [HSIZE];
code_int free_ent; /* first unused entry */
/*
* block compression parameters -- after all codes are used up,
* and compression rate changes, start over.
*/
int clear_flg;
int offset;
long int in_count; /* length of input */
long int out_count; /* # of codes output (for debugging) */
int g_init_bits;
gdIOCtx * g_outfile;
int ClearCode;
int EOFCode;
unsigned long cur_accum;
int cur_bits;
/*
* Number of characters so far in this 'packet'
*/
int a_count;
/*
* Define the storage for the packet accumulator
*/
char accum[ 256 ];
} GifCtx;
static int gifPutWord(int w, gdIOCtx *out);
static int colorstobpp(int colors);
static void BumpPixel (GifCtx *ctx);
static int GIFNextPixel (gdImagePtr im, GifCtx *ctx);
static void GIFEncode (gdIOCtxPtr fp, int GWidth, int GHeight, int GInterlace, int Background, int Transparent, int BitsPerPixel, int *Red, int *Green, int *Blue, gdImagePtr im);
static void compress (int init_bits, gdIOCtx *outfile, gdImagePtr im, GifCtx *ctx);
static void output (code_int code, GifCtx *ctx);
static void cl_block (GifCtx *ctx);
static void cl_hash (register count_int chsize, GifCtx *ctx);
static void char_init (GifCtx *ctx);
static void char_out (int c, GifCtx *ctx);
static void flush_char (GifCtx *ctx);
void * gdImageGifPtr (gdImagePtr im, int *size)
{
void *rv;
gdIOCtx *out = gdNewDynamicCtx (2048, NULL);
gdImageGifCtx (im, out);
rv = gdDPExtractData (out, size);
out->gd_free (out);
return rv;
}
void gdImageGif (gdImagePtr im, FILE * outFile)
{
gdIOCtx *out = gdNewFileCtx (outFile);
gdImageGifCtx (im, out);
out->gd_free (out);
}
void gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out)
{
gdImagePtr pim = 0, tim = im;
int interlace, transparent, BitsPerPixel;
interlace = im->interlace;
transparent = im->transparent;
if (im->trueColor) {
/* Expensive, but the only way that produces an
acceptable result: mix down to a palette
based temporary image. */
pim = gdImageCreatePaletteFromTrueColor(im, 1, 256);
if (!pim) {
return;
}
tim = pim;
}
BitsPerPixel = colorstobpp(tim->colorsTotal);
/* All set, let's do it. */
GIFEncode(
out, tim->sx, tim->sy, interlace, 0, transparent, BitsPerPixel,
tim->red, tim->green, tim->blue, tim);
if (pim) {
/* Destroy palette based temporary image. */
gdImageDestroy( pim);
}
}
static int
colorstobpp(int colors)
{
int bpp = 0;
if ( colors <= 2 )
bpp = 1;
else if ( colors <= 4 )
bpp = 2;
else if ( colors <= 8 )
bpp = 3;
else if ( colors <= 16 )
bpp = 4;
else if ( colors <= 32 )
bpp = 5;
else if ( colors <= 64 )
bpp = 6;
else if ( colors <= 128 )
bpp = 7;
else if ( colors <= 256 )
bpp = 8;
return bpp;
}
/*****************************************************************************
*
* GIFENCODE.C - GIF Image compression interface
*
* GIFEncode( FName, GHeight, GWidth, GInterlace, Background, Transparent,
* BitsPerPixel, Red, Green, Blue, gdImagePtr )
*
*****************************************************************************/
#define TRUE 1
#define FALSE 0
/*
* Bump the 'curx' and 'cury' to point to the next pixel
*/
static void
BumpPixel(GifCtx *ctx)
{
/*
* Bump the current X position
*/
++(ctx->curx);
/*
* If we are at the end of a scan line, set curx back to the beginning
* If we are interlaced, bump the cury to the appropriate spot,
* otherwise, just increment it.
*/
if( ctx->curx == ctx->Width ) {
ctx->curx = 0;
if( !ctx->Interlace )
++(ctx->cury);
else {
switch( ctx->Pass ) {
case 0:
ctx->cury += 8;
if( ctx->cury >= ctx->Height ) {
++(ctx->Pass);
ctx->cury = 4;
}
break;
case 1:
ctx->cury += 8;
if( ctx->cury >= ctx->Height ) {
++(ctx->Pass);
ctx->cury = 2;
}
break;
case 2:
ctx->cury += 4;
if( ctx->cury >= ctx->Height ) {
++(ctx->Pass);
ctx->cury = 1;
}
break;
case 3:
ctx->cury += 2;
break;
}
}
}
}
/*
* Return the next pixel from the image
*/
static int
GIFNextPixel(gdImagePtr im, GifCtx *ctx)
{
int r;
if( ctx->CountDown == 0 )
return EOF;
--(ctx->CountDown);
r = gdImageGetPixel(im, ctx->curx, ctx->cury);
BumpPixel(ctx);
return r;
}
/* public */
static void
GIFEncode(gdIOCtxPtr fp, int GWidth, int GHeight, int GInterlace, int Background, int Transparent, int BitsPerPixel, int *Red, int *Green, int *Blue, gdImagePtr im)
{
int B;
int RWidth, RHeight;
int LeftOfs, TopOfs;
int Resolution;
int ColorMapSize;
int InitCodeSize;
int i;
GifCtx ctx;
ctx.Interlace = GInterlace;
ctx.in_count = 1;
memset(&ctx, 0, sizeof(ctx));
ColorMapSize = 1 << BitsPerPixel;
RWidth = ctx.Width = GWidth;
RHeight = ctx.Height = GHeight;
LeftOfs = TopOfs = 0;
Resolution = BitsPerPixel;
/*
* Calculate number of bits we are expecting
*/
ctx.CountDown = (long)ctx.Width * (long)ctx.Height;
/*
* Indicate which pass we are on (if interlace)
*/
ctx.Pass = 0;
/*
* The initial code size
*/
if( BitsPerPixel <= 1 )
InitCodeSize = 2;
else
InitCodeSize = BitsPerPixel;
/*
* Set up the current x and y position
*/
ctx.curx = ctx.cury = 0;
/*
* Write the Magic header
*/
gdPutBuf(Transparent < 0 ? "GIF87a" : "GIF89a", 6, fp );
/*
* Write out the screen width and height
*/
gifPutWord( RWidth, fp );
gifPutWord( RHeight, fp );
/*
* Indicate that there is a global colour map
*/
B = 0x80; /* Yes, there is a color map */
/*
* OR in the resolution
*/
B |= (Resolution - 1) << 5;
/*
* OR in the Bits per Pixel
*/
B |= (BitsPerPixel - 1);
/*
* Write it out
*/
gdPutC( B, fp );
/*
* Write out the Background colour
*/
gdPutC( Background, fp );
/*
* Byte of 0's (future expansion)
*/
gdPutC( 0, fp );
/*
* Write out the Global Colour Map
*/
for( i=0; i<ColorMapSize; ++i ) {
gdPutC( Red[i], fp );
gdPutC( Green[i], fp );
gdPutC( Blue[i], fp );
}
/*
* Write out extension for transparent colour index, if necessary.
*/
if ( Transparent >= 0 ) {
gdPutC( '!', fp );
gdPutC( 0xf9, fp );
gdPutC( 4, fp );
gdPutC( 1, fp );
gdPutC( 0, fp );
gdPutC( 0, fp );
gdPutC( (unsigned char) Transparent, fp );
gdPutC( 0, fp );
}
/*
* Write an Image separator
*/
gdPutC( ',', fp );
/*
* Write the Image header
*/
gifPutWord( LeftOfs, fp );
gifPutWord( TopOfs, fp );
gifPutWord( ctx.Width, fp );
gifPutWord( ctx.Height, fp );
/*
* Write out whether or not the image is interlaced
*/
if( ctx.Interlace )
gdPutC( 0x40, fp );
else
gdPutC( 0x00, fp );
/*
* Write out the initial code size
*/
gdPutC( InitCodeSize, fp );
/*
* Go and actually compress the data
*/
compress( InitCodeSize+1, fp, im, &ctx );
/*
* Write out a Zero-length packet (to end the series)
*/
gdPutC( 0, fp );
/*
* Write the GIF file terminator
*/
gdPutC( ';', fp );
}
/***************************************************************************
*
* GIFCOMPR.C - GIF Image compression routines
*
* Lempel-Ziv compression based on 'compress'. GIF modifications by
* David Rowley (mgardi@watdcsu.waterloo.edu)
*
***************************************************************************/
/*
* General DEFINEs
*/
#define GIFBITS 12
#ifdef NO_UCHAR
typedef char char_type;
#else /*NO_UCHAR*/
typedef unsigned char char_type;
#endif /*NO_UCHAR*/
/*
*
* GIF Image compression - modified 'compress'
*
* Based on: compress.c - File compression ala IEEE Computer, June 1984.
*
* By Authors: Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas)
* Jim McKie (decvax!mcvax!jim)
* Steve Davies (decvax!vax135!petsd!peora!srd)
* Ken Turkowski (decvax!decwrl!turtlevax!ken)
* James A. Woods (decvax!ihnp4!ames!jaw)
* Joe Orost (decvax!vax135!petsd!joe)
*
*/
#include <ctype.h>
#define ARGVAL() (*++(*argv) || (--argc && *++argv))
#ifdef COMPATIBLE /* But wrong! */
# define MAXCODE(n_bits) ((code_int) 1 << (n_bits) - 1)
#else /*COMPATIBLE*/
# define MAXCODE(n_bits) (((code_int) 1 << (n_bits)) - 1)
#endif /*COMPATIBLE*/
#define HashTabOf(i) ctx->htab[i]
#define CodeTabOf(i) ctx->codetab[i]
/*
* To save much memory, we overlay the table used by compress() with those
* used by decompress(). The tab_prefix table is the same size and type
* as the codetab. The tab_suffix table needs 2**GIFBITS characters. We
* get this from the beginning of htab. The output stack uses the rest
* of htab, and contains characters. There is plenty of room for any
* possible stack (stack used to be 8000 characters).
*/
#define tab_prefixof(i) CodeTabOf(i)
#define tab_suffixof(i) ((char_type*)(htab))[i]
#define de_stack ((char_type*)&tab_suffixof((code_int)1<<GIFBITS))
/*
* compress stdin to stdout
*
* Algorithm: use open addressing double hashing (no chaining) on the
* prefix code / next character combination. We do a variant of Knuth's
* algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
* secondary probe. Here, the modular division first probe is gives way
* to a faster exclusive-or manipulation. Also do block compression with
* an adaptive reset, whereby the code table is cleared when the compression
* ratio decreases, but after the table fills. The variable-length output
* codes are re-sized at this point, and a special CLEAR code is generated
* for the decompressor. Late addition: construct the table according to
* file size for noticeable speed improvement on small files. Please direct
* questions about this implementation to ames!jaw.
*/
static void
output(code_int code, GifCtx *ctx);
static void
compress(int init_bits, gdIOCtxPtr outfile, gdImagePtr im, GifCtx *ctx)
{
register long fcode;
register code_int i /* = 0 */;
register int c;
register code_int ent;
register code_int disp;
register code_int hsize_reg;
register int hshift;
/*
* Set up the globals: g_init_bits - initial number of bits
* g_outfile - pointer to output file
*/
ctx->g_init_bits = init_bits;
ctx->g_outfile = outfile;
/*
* Set up the necessary values
*/
ctx->offset = 0;
ctx->out_count = 0;
ctx->clear_flg = 0;
ctx->in_count = 1;
ctx->maxcode = MAXCODE(ctx->n_bits = ctx->g_init_bits);
ctx->ClearCode = (1 << (init_bits - 1));
ctx->EOFCode = ctx->ClearCode + 1;
ctx->free_ent = ctx->ClearCode + 2;
char_init(ctx);
ent = GIFNextPixel( im, ctx );
hshift = 0;
for ( fcode = (long) hsize; fcode < 65536L; fcode *= 2L )
++hshift;
hshift = 8 - hshift; /* set hash code range bound */
hsize_reg = hsize;
cl_hash( (count_int) hsize_reg, ctx ); /* clear hash table */
output( (code_int)ctx->ClearCode, ctx );
#ifdef SIGNED_COMPARE_SLOW
while ( (c = GIFNextPixel( im )) != (unsigned) EOF ) {
#else /*SIGNED_COMPARE_SLOW*/
while ( (c = GIFNextPixel( im, ctx )) != EOF ) { /* } */
#endif /*SIGNED_COMPARE_SLOW*/
++(ctx->in_count);
fcode = (long) (((long) c << maxbits) + ent);
i = (((code_int)c << hshift) ^ ent); /* xor hashing */
if ( HashTabOf (i) == fcode ) {
ent = CodeTabOf (i);
continue;
} else if ( (long)HashTabOf (i) < 0 ) /* empty slot */
goto nomatch;
disp = hsize_reg - i; /* secondary hash (after G. Knott) */
if ( i == 0 )
disp = 1;
probe:
if ( (i -= disp) < 0 )
i += hsize_reg;
if ( HashTabOf (i) == fcode ) {
ent = CodeTabOf (i);
continue;
}
if ( (long)HashTabOf (i) > 0 )
goto probe;
nomatch:
output ( (code_int) ent, ctx );
++(ctx->out_count);
ent = c;
#ifdef SIGNED_COMPARE_SLOW
if ( (unsigned) ctx->free_ent < (unsigned) maxmaxcode) {
#else /*SIGNED_COMPARE_SLOW*/
if ( ctx->free_ent < maxmaxcode ) { /* } */
#endif /*SIGNED_COMPARE_SLOW*/
CodeTabOf (i) = ctx->free_ent++; /* code -> hashtable */
HashTabOf (i) = fcode;
} else
cl_block(ctx);
}
/*
* Put out the final code.
*/
output( (code_int)ent, ctx );
++(ctx->out_count);
output( (code_int) ctx->EOFCode, ctx );
}
/*****************************************************************
* TAG( output )
*
* Output the given code.
* Inputs:
* code: A n_bits-bit integer. If == -1, then EOF. This assumes
* that n_bits =< (long)wordsize - 1.
* Outputs:
* Outputs code to the file.
* Assumptions:
* Chars are 8 bits long.
* Algorithm:
* Maintain a GIFBITS character long buffer (so that 8 codes will
* fit in it exactly). Use the VAX insv instruction to insert each
* code in turn. When the buffer fills up empty it and start over.
*/
static unsigned long masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F,
0x001F, 0x003F, 0x007F, 0x00FF,
0x01FF, 0x03FF, 0x07FF, 0x0FFF,
0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF };
static void
output(code_int code, GifCtx *ctx)
{
ctx->cur_accum &= masks[ ctx->cur_bits ];
if( ctx->cur_bits > 0 )
ctx->cur_accum |= ((long)code << ctx->cur_bits);
else
ctx->cur_accum = code;
ctx->cur_bits += ctx->n_bits;
while( ctx->cur_bits >= 8 ) {
char_out( (unsigned int)(ctx->cur_accum & 0xff), ctx );
ctx->cur_accum >>= 8;
ctx->cur_bits -= 8;
}
/*
* If the next entry is going to be too big for the code size,
* then increase it, if possible.
*/
if ( ctx->free_ent > ctx->maxcode || ctx->clear_flg ) {
if( ctx->clear_flg ) {
ctx->maxcode = MAXCODE (ctx->n_bits = ctx->g_init_bits);
ctx->clear_flg = 0;
} else {
++(ctx->n_bits);
if ( ctx->n_bits == maxbits )
ctx->maxcode = maxmaxcode;
else
ctx->maxcode = MAXCODE(ctx->n_bits);
}
}
if( code == ctx->EOFCode ) {
/*
* At EOF, write the rest of the buffer.
*/
while( ctx->cur_bits > 0 ) {
char_out( (unsigned int)(ctx->cur_accum & 0xff), ctx);
ctx->cur_accum >>= 8;
ctx->cur_bits -= 8;
}
flush_char(ctx);
}
}
/*
* Clear out the hash table
*/
static void
cl_block (GifCtx *ctx) /* table clear for block compress */
{
cl_hash ( (count_int) hsize, ctx );
ctx->free_ent = ctx->ClearCode + 2;
ctx->clear_flg = 1;
output( (code_int)ctx->ClearCode, ctx);
}
static void
cl_hash(register count_int chsize, GifCtx *ctx) /* reset code table */
{
register count_int *htab_p = ctx->htab+chsize;
register long i;
register long m1 = -1;
i = chsize - 16;
do { /* might use Sys V memset(3) here */
*(htab_p-16) = m1;
*(htab_p-15) = m1;
*(htab_p-14) = m1;
*(htab_p-13) = m1;
*(htab_p-12) = m1;
*(htab_p-11) = m1;
*(htab_p-10) = m1;
*(htab_p-9) = m1;
*(htab_p-8) = m1;
*(htab_p-7) = m1;
*(htab_p-6) = m1;
*(htab_p-5) = m1;
*(htab_p-4) = m1;
*(htab_p-3) = m1;
*(htab_p-2) = m1;
*(htab_p-1) = m1;
htab_p -= 16;
} while ((i -= 16) >= 0);
for ( i += 16; i > 0; --i )
*--htab_p = m1;
}
/******************************************************************************
*
* GIF Specific routines
*
******************************************************************************/
/*
* Set up the 'byte output' routine
*/
static void
char_init(GifCtx *ctx)
{
ctx->a_count = 0;
}
/*
* Add a character to the end of the current packet, and if it is 254
* characters, flush the packet to disk.
*/
static void
char_out(int c, GifCtx *ctx)
{
ctx->accum[ ctx->a_count++ ] = c;
if( ctx->a_count >= 254 )
flush_char(ctx);
}
/*
* Flush the packet to disk, and reset the accumulator
*/
static void
flush_char(GifCtx *ctx)
{
if( ctx->a_count > 0 ) {
gdPutC( ctx->a_count, ctx->g_outfile );
gdPutBuf( ctx->accum, ctx->a_count, ctx->g_outfile );
ctx->a_count = 0;
}
}
static int gifPutWord(int w, gdIOCtx *out)
{
/* Byte order is little-endian */
gdPutC(w & 0xFF, out);
gdPutC((w >> 8) & 0xFF, out);
return 0;
}
+1333 -1137
View File
File diff suppressed because it is too large. Load diff
+2 -1
View File
@@ -27,7 +27,6 @@
#if HAVE_LIBINTL
#include <stdio.h>
#include <libintl.h>
#include "ext/standard/info.h"
#include "php_gettext.h"
@@ -57,6 +56,8 @@ function_entry php_gettext_functions[] = {
};
/* }}} */
#include <libintl.h>
zend_module_entry php_gettext_module_entry = {
STANDARD_MODULE_HEADER,
"gettext",
+3 -1
View File
@@ -12,6 +12,8 @@ if (PHP_ICONV != "no") {
AC_DEFINE("HAVE_LIBICONV", 1, "Define if libiconv is available");
AC_DEFINE("PHP_ICONV_IMPL", "\"libiconv\"", "Which iconv implementation to use");
AC_DEFINE("ICONV_SUPPORTS_ERRNO", 1, "Whether iconv supports errno or not");
if (!PHP_ICONV_SHARED) {
ADD_DEF_FILE("ext\\iconv\\php_iconv.def");
}
}
}
+58 -23
View File
@@ -2344,7 +2344,7 @@ static php_iconv_err_t php_iconv_stream_filter_ctor(php_iconv_stream_filter *sel
/* }}} */
/* {{{ php_iconv_stream_filter_append_bucket */
static size_t php_iconv_stream_filter_append_bucket(
static int php_iconv_stream_filter_append_bucket(
php_iconv_stream_filter *self,
php_stream *stream, php_stream_filter *filter,
php_stream_bucket_brigade *buckets_out,
@@ -2367,7 +2367,11 @@ static size_t php_iconv_stream_filter_append_bucket(
}
out_buf_size = ocnt = prev_ocnt = initial_out_buf_size;
out_buf = pd = pemalloc(out_buf_size, self->persistent);
if (NULL == (out_buf = pemalloc(out_buf_size, persistent))) {
return FAILURE;
}
pd = out_buf;
if (self->stub_len > 0) {
pt = self->stub;
@@ -2407,14 +2411,26 @@ static size_t php_iconv_stream_filter_append_bucket(
if (new_out_buf_size < out_buf_size) {
/* whoa! no bigger buckets are sold anywhere... */
new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, self->persistent TSRMLS_CC);
if (NULL == (new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, persistent TSRMLS_CC))) {
goto out_failure;
}
php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC);
out_buf_size = ocnt = initial_out_buf_size;
out_buf = pd = pemalloc(out_buf_size, self->persistent);
if (NULL == (out_buf = pemalloc(out_buf_size, persistent))) {
return FAILURE;
}
pd = out_buf;
} else {
new_out_buf = perealloc(out_buf, new_out_buf_size, self->persistent);
if (NULL == (new_out_buf = perealloc(out_buf, new_out_buf_size, persistent))) {
if (NULL == (new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, persistent TSRMLS_CC))) {
goto out_failure;
}
php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC);
return FAILURE;
}
pd = new_out_buf + (pd - out_buf);
ocnt += (new_out_buf_size - out_buf_size);
out_buf = new_out_buf;
@@ -2472,14 +2488,26 @@ static size_t php_iconv_stream_filter_append_bucket(
if (new_out_buf_size < out_buf_size) {
/* whoa! no bigger buckets are sold anywhere... */
new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, self->persistent TSRMLS_CC);
if (NULL == (new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, persistent TSRMLS_CC))) {
goto out_failure;
}
php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC);
out_buf_size = ocnt = initial_out_buf_size;
out_buf = pd = pemalloc(out_buf_size, self->persistent);
if (NULL == (out_buf = pemalloc(out_buf_size, persistent))) {
return FAILURE;
}
pd = out_buf;
} else {
new_out_buf = perealloc(out_buf, new_out_buf_size, self->persistent);
if (NULL == (new_out_buf = perealloc(out_buf, new_out_buf_size, persistent))) {
if (NULL == (new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, persistent TSRMLS_CC))) {
goto out_failure;
}
php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC);
return FAILURE;
}
pd = new_out_buf + (pd - out_buf);
ocnt += (new_out_buf_size - out_buf_size);
out_buf = new_out_buf;
@@ -2506,17 +2534,19 @@ static size_t php_iconv_stream_filter_append_bucket(
}
if (out_buf_size - ocnt > 0) {
new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, self->persistent TSRMLS_CC);
if (NULL == (new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, persistent TSRMLS_CC))) {
goto out_failure;
}
php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC);
} else {
pefree(out_buf, self->persistent);
pefree(out_buf, persistent);
}
*consumed += buf_len - icnt;
return SUCCESS;
out_failure:
pefree(out_buf, self->persistent);
pefree(out_buf, persistent);
return FAILURE;
}
@@ -2531,27 +2561,32 @@ static php_stream_filter_status_t php_iconv_stream_filter_do_filter(
size_t consumed = 0;
php_iconv_stream_filter *self = (php_iconv_stream_filter *)filter->abstract;
if (flags != PSFS_FLAG_NORMAL) {
if (php_iconv_stream_filter_append_bucket(self, stream, filter, buckets_out, NULL, 0, &consumed, self->persistent TSRMLS_CC) != SUCCESS) {
while (buckets_in->head != NULL) {
bucket = buckets_in->head;
php_stream_bucket_unlink(bucket TSRMLS_CC);
if (php_iconv_stream_filter_append_bucket(self, stream, filter,
buckets_out, bucket->buf, bucket->buflen, &consumed,
php_stream_is_persistent(stream) TSRMLS_CC) != SUCCESS) {
goto out_failure;
}
} else {
while (buckets_in->head != NULL) {
bucket = buckets_in->head;
php_stream_bucket_unlink(bucket TSRMLS_CC);
php_stream_bucket_delref(bucket TSRMLS_CC);
}
if (php_iconv_stream_filter_append_bucket(self, stream, filter, buckets_out, bucket->buf, bucket->buflen, &consumed, self->persistent TSRMLS_CC) != SUCCESS) { goto out_failure;
}
php_stream_bucket_delref(bucket TSRMLS_CC);
if (flags != PSFS_FLAG_NORMAL) {
if (php_iconv_stream_filter_append_bucket(self, stream, filter,
buckets_out, NULL, 0, &consumed,
php_stream_is_persistent(stream) TSRMLS_CC) != SUCCESS) {
goto out_failure;
}
}
if (bytes_consumed) {
if (bytes_consumed != NULL) {
*bytes_consumed = consumed;
}
return PSFS_PASS_ON;
out_failure:
+6
View File
@@ -0,0 +1,6 @@
EXPORTS
_libiconv_version
libiconv_close
libiconv
libiconv_open
libiconv_set_relocation_prefix
-103
View File
@@ -1,103 +0,0 @@
#ifndef _INCLUDED_IMAP_H
#define _INCLUDED_IMAP_H
#if COMPILE_DL
#undef HAVE_IMAP
#define HAVE_IMAP 1
#endif
#if HAVE_IMAP
#ifndef PHP_WIN32
#include "build-defs.h"
#endif
/* Functions accessable to PHP */
extern zend_module_entry imap_module_entry;
#define imap_module_ptr &imap_module_entry
extern PHP_MINIT_FUNCTION(imap);
extern PHP_RINIT_FUNCTION(imap);
extern PHP_RSHUTDOWN_FUNCTION(imap);
PHP_MINFO_FUNCTION(imap);
PHP_FUNCTION(imap_open);
PHP_FUNCTION(imap_popen);
PHP_FUNCTION(imap_reopen);
PHP_FUNCTION(imap_num_msg);
PHP_FUNCTION(imap_num_recent);
PHP_FUNCTION(imap_headers);
PHP_FUNCTION(imap_headerinfo);
PHP_FUNCTION(imap_rfc822_parse_headers);
PHP_FUNCTION(imap_body);
PHP_FUNCTION(imap_fetchstructure);
PHP_FUNCTION(imap_fetchbody);
PHP_FUNCTION(imap_expunge);
PHP_FUNCTION(imap_delete);
PHP_FUNCTION(imap_undelete);
PHP_FUNCTION(imap_check);
PHP_FUNCTION(imap_close);
PHP_FUNCTION(imap_mail_copy);
PHP_FUNCTION(imap_mail_move);
PHP_FUNCTION(imap_createmailbox);
PHP_FUNCTION(imap_renamemailbox);
PHP_FUNCTION(imap_deletemailbox);
PHP_FUNCTION(imap_listmailbox);
PHP_FUNCTION(imap_scanmailbox);
PHP_FUNCTION(imap_subscribe);
PHP_FUNCTION(imap_unsubscribe);
PHP_FUNCTION(imap_append);
PHP_FUNCTION(imap_ping);
PHP_FUNCTION(imap_base64);
PHP_FUNCTION(imap_qprint);
PHP_FUNCTION(imap_8bit);
PHP_FUNCTION(imap_binary);
PHP_FUNCTION(imap_mailboxmsginfo);
PHP_FUNCTION(imap_rfc822_write_address);
PHP_FUNCTION(imap_rfc822_parse_adrlist);
PHP_FUNCTION(imap_setflag_full);
PHP_FUNCTION(imap_clearflag_full);
PHP_FUNCTION(imap_sort);
PHP_FUNCTION(imap_fetchheader);
PHP_FUNCTION(imap_fetchtext);
PHP_FUNCTION(imap_uid);
PHP_FUNCTION(imap_msgno);
PHP_FUNCTION(imap_list);
PHP_FUNCTION(imap_list_full);
PHP_FUNCTION(imap_listscan);
PHP_FUNCTION(imap_lsub);
PHP_FUNCTION(imap_lsub_full);
PHP_FUNCTION(imap_create);
PHP_FUNCTION(imap_rename);
PHP_FUNCTION(imap_status);
PHP_FUNCTION(imap_bodystruct);
PHP_FUNCTION(imap_fetch_overview);
PHP_FUNCTION(imap_mail_compose);
PHP_FUNCTION(imap_alerts);
PHP_FUNCTION(imap_errors);
PHP_FUNCTION(imap_last_error);
PHP_FUNCTION(imap_mail);
PHP_FUNCTION(imap_search);
PHP_FUNCTION(imap_utf8);
PHP_FUNCTION(imap_utf7_decode);
PHP_FUNCTION(imap_utf7_encode);
PHP_FUNCTION(imap_mime_header_decode);
#else
#define imap_module_ptr NULL
#endif /* HAVE_IMAP */
#endif
#define phpext_imap_ptr imap_module_ptr
+26 -24
View File
@@ -112,7 +112,7 @@ function_entry imap_functions[] = {
PHP_FE(imap_qprint, NULL)
PHP_FE(imap_8bit, NULL)
PHP_FE(imap_binary, NULL)
PHP_FE(imap_utf8, NULL)
PHP_FE(imap_utf8, NULL)
PHP_FE(imap_status, NULL)
PHP_FE(imap_mailboxmsginfo, NULL)
PHP_FE(imap_setflag_full, NULL)
@@ -131,24 +131,24 @@ function_entry imap_functions[] = {
PHP_FE(imap_utf7_encode, NULL)
PHP_FE(imap_mime_header_decode, NULL)
PHP_FE(imap_thread, NULL)
PHP_FE(imap_timeout, NULL)
PHP_FE(imap_timeout, NULL)
#if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
PHP_FE(imap_get_quota, NULL)
PHP_FE(imap_get_quotaroot, NULL)
PHP_FE(imap_set_quota, NULL)
PHP_FE(imap_setacl, NULL)
PHP_FE(imap_getacl, NULL)
PHP_FE(imap_setacl, NULL)
PHP_FE(imap_getacl, NULL)
#endif
PHP_FE(imap_mail, NULL)
PHP_FALIAS(imap_header, imap_headerinfo, NULL)
PHP_FALIAS(imap_listmailbox, imap_list, NULL)
PHP_FALIAS(imap_getmailboxes, imap_list_full, NULL)
PHP_FALIAS(imap_scanmailbox, imap_listscan, NULL)
PHP_FALIAS(imap_listsubscribed, imap_lsub, NULL)
PHP_FALIAS(imap_getsubscribed, imap_lsub_full, NULL)
PHP_FALIAS(imap_header, imap_headerinfo, NULL)
PHP_FALIAS(imap_listmailbox, imap_list, NULL)
PHP_FALIAS(imap_getmailboxes, imap_list_full, NULL)
PHP_FALIAS(imap_scanmailbox, imap_listscan, NULL)
PHP_FALIAS(imap_listsubscribed, imap_lsub, NULL)
PHP_FALIAS(imap_getsubscribed, imap_lsub_full, NULL)
PHP_FALIAS(imap_fetchtext, imap_body, NULL)
PHP_FALIAS(imap_scan, imap_listscan, NULL)
PHP_FALIAS(imap_create, imap_createmailbox, NULL)
@@ -182,6 +182,12 @@ ZEND_GET_MODULE(imap)
/* True globals, no need for thread safety */
static int le_imap;
#define PHP_IMAP_CHECK_MSGNO(msgindex) \
if ((msgindex < 1) || ((unsigned) msgindex > imap_le_struct->imap_stream->nmsgs)) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad message number"); \
RETURN_FALSE; \
} \
/* {{{ mail_close_it
*/
static void mail_close_it(zend_rsrc_list_entry *rsrc TSRMLS_DC)
@@ -1529,11 +1535,8 @@ PHP_FUNCTION(imap_headerinfo)
convert_to_string_ex(defaulthost);
}
if (!Z_LVAL_PP(msgno) || Z_LVAL_PP(msgno) < 1 || (unsigned) Z_LVAL_PP(msgno) > imap_le_struct->imap_stream->nmsgs) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad message number");
RETURN_FALSE;
}
PHP_IMAP_CHECK_MSGNO(Z_LVAL_PP(msgno));
if (mail_fetchstructure(imap_le_struct->imap_stream, Z_LVAL_PP(msgno), NIL)) {
cache = mail_elt(imap_le_struct->imap_stream, Z_LVAL_PP(msgno));
} else {
@@ -1779,10 +1782,7 @@ PHP_FUNCTION(imap_fetchstructure)
} else {
msgindex = Z_LVAL_PP(msgno);
}
if ((msgindex < 1) || ((unsigned) msgindex > imap_le_struct->imap_stream->nmsgs)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad message number");
RETURN_FALSE;
}
PHP_IMAP_CHECK_MSGNO(msgindex);
mail_fetchstructure_full(imap_le_struct->imap_stream, Z_LVAL_PP(msgno), &body , myargc == 3 ? Z_LVAL_PP(flags) : NIL);
@@ -1816,7 +1816,12 @@ PHP_FUNCTION(imap_fetchbody)
if (myargc == 4) {
convert_to_long_ex(flags);
}
if (myargc < 4 || !(Z_LVAL_PP(flags) & FT_UID)) {
/* only perform the check if the msgno is a message number and not a UID */
PHP_IMAP_CHECK_MSGNO(Z_LVAL_PP(msgno));
}
body = mail_fetchbody_full(imap_le_struct->imap_stream, Z_LVAL_PP(msgno), Z_STRVAL_PP(sec), &len, myargc==4 ? Z_LVAL_PP(flags) : NIL);
if (!body) {
@@ -2512,10 +2517,7 @@ PHP_FUNCTION(imap_fetchheader)
msgindex = Z_LVAL_PP(msgno);
}
if ((msgindex < 1) || ((unsigned) msgindex > imap_le_struct->imap_stream->nmsgs)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad message number");
RETURN_FALSE;
}
PHP_IMAP_CHECK_MSGNO(msgindex);
RETVAL_STRING(mail_fetchheader_full(imap_le_struct->imap_stream, Z_LVAL_PP(msgno), NIL, NIL, (myargc == 3 ? Z_LVAL_PP(flags) : NIL)), 1);
}
+1 -1
View File
@@ -17,7 +17,7 @@ if (PHP_INFORMIX != "no") {
ADD_FLAG("CFLAGS_INFORMIX", "/I " + php_ifx_dir + "\\incl\\esql ");
EXTENSION('informix', 'ifx.c', null, "/D IFX_VERSION=921 /D HAVE_IFX_IUS=1", "php_ifx.dll");
EXTENSION('informix', 'ifx.c', null, "/D IFX_VERSION=921 /D HAVE_IFX_IUS=1 /D HAVE_IFX=1", "php_ifx.dll");
MFO.WriteLine(configure_module_dirname + "\\ifx.c: " + configure_module_dirname + "\\ifx.ec");
MFO.WriteLine("\t<<informix_build.bat");
MFO.WriteLine("PATH " + php_ifx_bin + ";%PATH%");
+1
View File
@@ -15,6 +15,7 @@ if (PHP_LIBXML == "yes") {
if (!PHP_LIBXML_SHARED) {
ADD_DEF_FILE("ext\\libxml\\php_libxml2.def");
}
ADD_EXTENSION_DEP('libxml', 'iconv');
}
}
+2 -2
View File
@@ -377,7 +377,7 @@ void php_libxml_ctx_warning(void *ctx, const char *msg, ...)
va_end(args);
}
void php_libxml_error_handler(void *ctx, const char *msg, ...)
PHP_LIBXML_API void php_libxml_error_handler(void *ctx, const char *msg, ...)
{
va_list args;
va_start(args, msg);
@@ -568,7 +568,7 @@ int php_libxml_decrement_node_ptr(php_libxml_node_object *object TSRMLS_DC) {
obj_node = (php_libxml_node_ptr *) object->node;
ret_refcount = --obj_node->refcount;
if (ret_refcount == 0) {
if (obj_node->node != NULL && obj_node->node->type != XML_DOCUMENT_NODE) {
if (obj_node->node != NULL) {
obj_node->node->_private = NULL;
}
efree(obj_node);
+1 -1
View File
@@ -77,7 +77,7 @@ PHP_LIBXML_API int php_libxml_register_export(zend_class_entry *ce, php_libxml_e
void php_libxml_node_free_resource(xmlNodePtr node TSRMLS_DC);
/* When object dtor is called as node may still be referenced */
void php_libxml_node_decrement_resource(php_libxml_node_object *object TSRMLS_DC);
void php_libxml_error_handler(void *ctx, const char *msg, ...);
PHP_LIBXML_API void php_libxml_error_handler(void *ctx, const char *msg, ...);
void php_libxml_ctx_warning(void *ctx, const char *msg, ...);
void php_libxml_ctx_error(void *ctx, const char *msg, ...);
+339 -6
View File
@@ -13,13 +13,22 @@ __xmlGenericError
__xmlGenericErrorContext
__xmlGetWarningsDefaultValue
__xmlIndentTreeOutput
xmlIsBaseCharGroup DATA
xmlIsCharGroup DATA
xmlIsCombiningGroup DATA
xmlIsDigitGroup DATA
xmlIsExtenderGroup DATA
xmlIsIdeographicGroup DATA
xmlIsPubidChar_tab DATA
__xmlKeepBlanksDefaultValue
xmlLastError DATA
__xmlLineNumbersDefaultValue
__xmlLoadExtDtdDefaultValue
xmlMalloc DATA
xmlMallocAtomic DATA
xmlMemStrdup DATA
__xmlParserDebugEntities
xmlParserMaxDepth DATA
__xmlParserVersion
__xmlPedanticParserDefaultValue
xmlRealloc DATA
@@ -28,6 +37,7 @@ __xmlSaveNoEmptyTags
xmlStringComment DATA
xmlStringText DATA
xmlStringTextNoenc DATA
xmlStructuredError DATA
__xmlSubstituteEntitiesDefaultValue
__xmlTreeIndentString
xmlXPathNAN DATA
@@ -72,6 +82,13 @@ htmlAutoCloseTag
htmlCreateFileParserCtxt
htmlCreateMemoryParserCtxt
htmlCreatePushParserCtxt
htmlCtxtReadDoc
htmlCtxtReadFd
htmlCtxtReadFile
htmlCtxtReadIO
htmlCtxtReadMemory
htmlCtxtReset
htmlCtxtUseOptions
htmlDefaultSAXHandlerInit
htmlDocContentDumpFormatOutput
htmlDocContentDumpOutput
@@ -104,6 +121,11 @@ htmlParseDocument
htmlParseElement
htmlParseEntityRef
htmlParseFile
htmlReadDoc
htmlReadFd
htmlReadFile
htmlReadIO
htmlReadMemory
htmlSAXParseDoc
htmlSAXParseFile
htmlSaveFile
@@ -159,6 +181,7 @@ xmlAddRef
xmlAddSibling
xmlAllocOutputBuffer
xmlAllocParserInputBuffer
xmlAttrSerializeTxtContent
xmlAutomataCompile
xmlAutomataGetInitState
xmlAutomataIsDeterminist
@@ -181,6 +204,7 @@ xmlBufferCat
xmlBufferContent
xmlBufferCreate
xmlBufferCreateSize
xmlBufferCreateStatic
xmlBufferDump
xmlBufferEmpty
xmlBufferFree
@@ -194,6 +218,7 @@ xmlBufferWriteChar
xmlBufferWriteQuotedString
xmlBuildQName
xmlBuildURI
xmlByteConsumed
xmlC14NDocDumpMemory
xmlC14NDocSave
xmlC14NDocSaveTo
@@ -223,9 +248,11 @@ xmlCharEncCloseFunc
xmlCharEncFirstLine
xmlCharEncInFunc
xmlCharEncOutFunc
xmlCharInRange
xmlCharStrdup
xmlCharStrndup
xmlCheckFilename
xmlCheckHTTPInput
xmlCheckLanguageID
xmlCheckUTF8
xmlCheckVersion
@@ -233,6 +260,7 @@ xmlCleanupCharEncodingHandlers
xmlCleanupEncodingAliases
xmlCleanupGlobals
xmlCleanupInputCallbacks
xmlCleanupMemory
xmlCleanupOutputCallbacks
xmlCleanupParser
xmlCleanupPredefinedEntities
@@ -249,6 +277,7 @@ xmlCopyElementContent
xmlCopyElementTable
xmlCopyEntitiesTable
xmlCopyEnumeration
xmlCopyError
xmlCopyNamespace
xmlCopyNamespaceList
xmlCopyNode
@@ -266,7 +295,26 @@ xmlCreateIntSubset
xmlCreateMemoryParserCtxt
xmlCreatePushParserCtxt
xmlCreateURI
xmlCreateURLParserCtxt
xmlCtxtGetLastError
xmlCtxtReadDoc
xmlCtxtReadFd
xmlCtxtReadFile
xmlCtxtReadIO
xmlCtxtReadMemory
xmlCtxtReset
xmlCtxtResetLastError
xmlCtxtResetPush
xmlCtxtUseOptions
xmlCurrentChar
xmlDictCreate
xmlDictCreateSub
xmlDictFree
xmlDictLookup
xmlDictOwns
xmlDictQLookup
xmlDictReference
xmlDictSize
xmlDebugDumpAttr
xmlDebugDumpAttrList
xmlDebugDumpDTD
@@ -282,6 +330,14 @@ xmlDefaultSAXHandlerInit
xmlDelEncodingAlias
xmlDeregisterNodeDefault
xmlDetectCharEncoding
xmlDictCreate
xmlDictCreateSub
xmlDictFree
xmlDictLookup
xmlDictOwns
xmlDictQLookup
xmlDictReference
xmlDictSize
xmlDocCopyNode
xmlDocDump
xmlDocDumpFormatMemory
@@ -303,6 +359,7 @@ xmlElemDump
xmlEncodeEntities
xmlEncodeEntitiesReentrant
xmlEncodeSpecialChars
xmlErrMemory
xmlFileClose
xmlFileMatch
xmlFileOpen
@@ -327,11 +384,14 @@ xmlFreeNs
xmlFreeNsList
xmlFreeParserCtxt
xmlFreeParserInputBuffer
xmlFreePattern
xmlFreePatternList
xmlFreeProp
xmlFreePropList
xmlFreeRMutex
xmlFreeRefTable
xmlFreeTextReader
xmlFreeTextWriter
xmlFreeURI
xmlFreeValidCtxt
xmlGcMemGet
@@ -356,6 +416,7 @@ xmlGetGlobalState
xmlGetID
xmlGetIntSubset
xmlGetLastChild
xmlGetLastError
xmlGetLineNo
xmlGetNoNsProp
xmlGetNodePath
@@ -379,6 +440,9 @@ xmlHashFree
xmlHashLookup
xmlHashLookup2
xmlHashLookup3
xmlHashQLookup
xmlHashQLookup2
xmlHashQLookup3
xmlHashRemoveEntry
xmlHashRemoveEntry2
xmlHashRemoveEntry3
@@ -425,6 +489,12 @@ xmlIsMixedElement
xmlIsPubidChar
xmlIsRef
xmlIsXHTML
xmlIsBaseCharGroup DATA
xmlIsCharGroup DATA
xmlIsCombiningGroup DATA
xmlIsDigitGroup DATA
xmlIsExtenderGroup DATA
xmlIsIdeographicGroup DATA
xmlKeepBlanksDefault
xmlLineNumbersDefault
xmlLinkGetData
@@ -461,6 +531,8 @@ xmlLoadSGMLSuperCatalog
xmlLockLibrary
xmlLsCountNode
xmlLsOneNode
xmlMallocAtomicLoc
xmlMallocLoc
xmlMemDisplay
xmlMemFree
xmlMemGet
@@ -468,6 +540,7 @@ xmlMemMalloc
xmlMemRealloc
xmlMemSetup
xmlMemShow
xmlMemStrdupLoc
xmlMemUsed
xmlMemoryDump
xmlMemoryStrdup
@@ -501,13 +574,16 @@ xmlNanoFTPUpdateURL
xmlNanoHTTPAuthHeader
xmlNanoHTTPCleanup
xmlNanoHTTPClose
xmlNanoHTTPEncoding
xmlNanoHTTPFetch
xmlNanoHTTPInit
xmlNanoHTTPMethod
xmlNanoHTTPMethodRedir
xmlNanoHTTPMimeType
xmlNanoHTTPOpen
xmlNanoHTTPOpenRedir
xmlNanoHTTPRead
xmlNanoHTTPRedir
xmlNanoHTTPReturnCode
xmlNanoHTTPSave
xmlNanoHTTPScanProxy
@@ -551,11 +627,18 @@ xmlNewTextChild
xmlNewTextLen
xmlNewTextReader
xmlNewTextReaderFilename
xmlNewTextWriter
xmlNewTextWriterDoc
xmlNewTextWriterFilename
xmlNewTextWriterMemory
xmlNewTextWriterPushParser
xmlNewTextWriterTree
xmlNewValidCtxt
xmlNextChar
xmlNoNetExternalEntityLoader
xmlNodeAddContent
xmlNodeAddContentLen
xmlNodeBufGetContent
xmlNodeDump
xmlNodeDumpOutput
xmlNodeGetBase
@@ -655,6 +738,7 @@ xmlParserInputBufferCreateFile
xmlParserInputBufferCreateFilename
xmlParserInputBufferCreateIO
xmlParserInputBufferCreateMem
xmlParserInputBufferCreateStatic
xmlParserInputBufferGrow
xmlParserInputBufferPush
xmlParserInputBufferRead
@@ -666,12 +750,32 @@ xmlParserPrintFileInfo
xmlParserValidityError
xmlParserValidityWarning
xmlParserWarning
xmlPatternMatch
xmlPatterncompile
xmlPedanticParserDefault
xmlPopInput
xmlPrintURI
xmlPushInput
xmlRMutexLock
xmlRMutexUnlock
xmlReadDoc
xmlReadFd
xmlReadFile
xmlReadIO
xmlReadMemory
xmlReaderForDoc
xmlReaderForFd
xmlReaderForFile
xmlReaderForIO
xmlReaderForMemory
xmlReaderNewDoc
xmlReaderNewFd
xmlReaderNewFile
xmlReaderNewIO
xmlReaderNewMemory
xmlReaderNewWalker
xmlReaderWalker
xmlReallocLoc
xmlReconciliateNs
xmlRecoverDoc
xmlRecoverFile
@@ -712,10 +816,47 @@ xmlRelaxNGValidateFullElement
xmlRelaxNGValidatePopElement
xmlRelaxNGValidatePushCData
xmlRelaxNGValidatePushElement
xmlRelaxParserSetFlag
xmlRemoveID
xmlRemoveProp
xmlRemoveRef
xmlReplaceNode
xmlResetError
xmlResetLastError
xmlSAX2AttributeDecl
xmlSAX2CDataBlock
xmlSAX2Characters
xmlSAX2Comment
xmlSAX2ElementDecl
xmlSAX2EndDocument
xmlSAX2EndElement
xmlSAX2EndElementNs
xmlSAX2EntityDecl
xmlSAX2ExternalSubset
xmlSAX2GetColumnNumber
xmlSAX2GetEntity
xmlSAX2GetLineNumber
xmlSAX2GetParameterEntity
xmlSAX2GetPublicId
xmlSAX2GetSystemId
xmlSAX2HasExternalSubset
xmlSAX2HasInternalSubset
xmlSAX2IgnorableWhitespace
xmlSAX2InitDefaultSAXHandler
xmlSAX2InitDocbDefaultSAXHandler
xmlSAX2InitHtmlDefaultSAXHandler
xmlSAX2InternalSubset
xmlSAX2IsStandalone
xmlSAX2NotationDecl
xmlSAX2ProcessingInstruction
xmlSAX2Reference
xmlSAX2ResolveEntity
xmlSAX2SetDocumentLocator
xmlSAX2StartDocument
xmlSAX2StartElement
xmlSAX2StartElementNs
xmlSAX2UnparsedEntityDecl
xmlSAXDefaultVersion
xmlSAXParseDTD
xmlSAXParseDoc
xmlSAXParseEntity
@@ -725,6 +866,7 @@ xmlSAXParseMemory
xmlSAXParseMemoryWithData
xmlSAXUserParseFile
xmlSAXUserParseMemory
xmlSAXVersion
xmlSaveFile
xmlSaveFileEnc
xmlSaveFileTo
@@ -745,6 +887,7 @@ xmlSchemaFreeValidCtxt
xmlSchemaFreeValue
xmlSchemaGetPredefinedType
xmlSchemaInitTypes
xmlSchemaNewDocParserCtxt
xmlSchemaNewFacet
xmlSchemaNewMemParserCtxt
xmlSchemaNewParserCtxt
@@ -770,6 +913,7 @@ xmlSetListDoc
xmlSetNs
xmlSetNsProp
xmlSetProp
xmlSetStructuredErrorFunc
xmlSetTreeDoc
xmlSetupParserForBuffer
xmlShell
@@ -794,6 +938,9 @@ xmlSplitQName3
xmlSprintfElementContent
xmlStopParser
xmlStrEqual
xmlStrPrintf
xmlStrQEqual
xmlStrVPrintf
xmlStrcasecmp
xmlStrcasestr
xmlStrcat
@@ -803,22 +950,33 @@ xmlStrdup
xmlStringCurrentChar
xmlStringDecodeEntities
xmlStringGetNodeList
xmlStringLenDecodeEntities
xmlStringLenGetNodeList
xmlStrlen
xmlStrncasecmp
xmlStrncat
xmlStrncatNew
xmlStrncmp
xmlStrndup
xmlStrstr
xmlStrsub
xmlSubstituteEntitiesDefault
xmlSwitchEncoding
xmlSwitchInputEncoding
xmlSwitchToEncoding
xmlTextConcat
xmlTextMerge
xmlTextReaderAttributeCount
xmlTextReaderBaseUri
xmlTextReaderClose
xmlTextReaderConstBaseUri
xmlTextReaderConstLocalName
xmlTextReaderConstName
xmlTextReaderConstNamespaceUri
xmlTextReaderConstPrefix
xmlTextReaderConstString
xmlTextReaderConstValue
xmlTextReaderConstXmlLang
xmlTextReaderCurrentDoc
xmlTextReaderCurrentNode
xmlTextReaderDepth
@@ -847,9 +1005,12 @@ xmlTextReaderMoveToNextAttribute
xmlTextReaderName
xmlTextReaderNamespaceUri
xmlTextReaderNext
xmlTextReaderNextSibling
xmlTextReaderNodeType
xmlTextReaderNormalization
xmlTextReaderPrefix
xmlTextReaderPreserve
xmlTextReaderPreservePattern
xmlTextReaderQuoteChar
xmlTextReaderRead
xmlTextReaderReadAttributeValue
@@ -861,8 +1022,77 @@ xmlTextReaderRelaxNGSetSchema
xmlTextReaderRelaxNGValidate
xmlTextReaderSetErrorHandler
xmlTextReaderSetParserProp
xmlTextReaderSetStructuredErrorHandler
xmlTextReaderValue
xmlTextReaderXmlLang
xmlTextWriterEndAttribute
xmlTextWriterEndCDATA
xmlTextWriterEndComment
xmlTextWriterEndDTD
xmlTextWriterEndDocument
xmlTextWriterEndElement
xmlTextWriterEndPI
xmlTextWriterFlush
xmlTextWriterFullEndElement
xmlTextWriterSetIndent
xmlTextWriterSetIndentString
xmlTextWriterStartAttribute
xmlTextWriterStartAttributeNS
xmlTextWriterStartCDATA
xmlTextWriterStartComment
xmlTextWriterStartDTD
xmlTextWriterStartDTDAttlist
xmlTextWriterStartDTDElement
xmlTextWriterStartDTDEntity
xmlTextWriterStartDocument
xmlTextWriterStartElement
xmlTextWriterStartElementNS
xmlTextWriterStartPI
xmlTextWriterWriteAttribute
xmlTextWriterWriteAttributeNS
xmlTextWriterWriteBase64
xmlTextWriterWriteBinHex
xmlTextWriterWriteCDATA
xmlTextWriterWriteComment
xmlTextWriterWriteDTD
xmlTextWriterWriteDTDAttlist
xmlTextWriterWriteDTDElement
xmlTextWriterWriteDTDEntity
xmlTextWriterWriteDTDExternalEntity
xmlTextWriterWriteDTDInternalEntity
xmlTextWriterWriteDTDNotation
xmlTextWriterWriteElement
xmlTextWriterWriteElementNS
xmlTextWriterWriteFormatAttribute
xmlTextWriterWriteFormatAttributeNS
xmlTextWriterWriteFormatCDATA
xmlTextWriterWriteFormatComment
xmlTextWriterWriteFormatDTD
xmlTextWriterWriteFormatDTDAttlist
xmlTextWriterWriteFormatDTDElement
xmlTextWriterWriteFormatDTDInternalEntity
xmlTextWriterWriteFormatElement
xmlTextWriterWriteFormatElementNS
xmlTextWriterWriteFormatPI
xmlTextWriterWriteFormatRaw
xmlTextWriterWriteFormatString
xmlTextWriterWritePI
xmlTextWriterWriteRaw
xmlTextWriterWriteRawLen
xmlTextWriterWriteString
xmlTextWriterWriteVFormatAttribute
xmlTextWriterWriteVFormatAttributeNS
xmlTextWriterWriteVFormatCDATA
xmlTextWriterWriteVFormatComment
xmlTextWriterWriteVFormatDTD
xmlTextWriterWriteVFormatDTDAttlist
xmlTextWriterWriteVFormatDTDElement
xmlTextWriterWriteVFormatDTDInternalEntity
xmlTextWriterWriteVFormatElement
xmlTextWriterWriteVFormatElementNS
xmlTextWriterWriteVFormatPI
xmlTextWriterWriteVFormatRaw
xmlTextWriterWriteVFormatString
xmlThrDefBufferAllocScheme
xmlThrDefDefaultBufferSize
xmlThrDefDeregisterNodeDefault
@@ -877,8 +1107,10 @@ xmlThrDefPedanticParserDefaultValue
xmlThrDefRegisterNodeDefault
xmlThrDefSaveNoEmptyTags
xmlThrDefSetGenericErrorFunc
xmlThrDefSetStructuredErrorFunc
xmlThrDefSubstituteEntitiesDefaultValue
xmlThrDefTreeIndentString
xmlUCSIsAegeanNumbers
xmlUCSIsAlphabeticPresentationForms
xmlUCSIsArabic
xmlUCSIsArabicPresentationFormsA
@@ -893,6 +1125,7 @@ xmlUCSIsBopomofo
xmlUCSIsBopomofoExtended
xmlUCSIsBoxDrawing
xmlUCSIsBraillePatterns
xmlUCSIsBuhid
xmlUCSIsByzantineMusicalSymbols
xmlUCSIsCJKCompatibility
xmlUCSIsCJKCompatibilityForms
@@ -942,11 +1175,14 @@ xmlUCSIsCatZp
xmlUCSIsCatZs
xmlUCSIsCherokee
xmlUCSIsCombiningDiacriticalMarks
xmlUCSIsCombiningDiacriticalMarksforSymbols
xmlUCSIsCombiningHalfMarks
xmlUCSIsCombiningMarksforSymbols
xmlUCSIsControlPictures
xmlUCSIsCurrencySymbols
xmlUCSIsCypriotSyllabary
xmlUCSIsCyrillic
xmlUCSIsCyrillicSupplement
xmlUCSIsDeseret
xmlUCSIsDevanagari
xmlUCSIsDingbats
@@ -959,12 +1195,14 @@ xmlUCSIsGeorgian
xmlUCSIsGothic
xmlUCSIsGreek
xmlUCSIsGreekExtended
xmlUCSIsGreekandCoptic
xmlUCSIsGujarati
xmlUCSIsGurmukhi
xmlUCSIsHalfwidthandFullwidthForms
xmlUCSIsHangulCompatibilityJamo
xmlUCSIsHangulJamo
xmlUCSIsHangulSyllables
xmlUCSIsHanunoo
xmlUCSIsHebrew
xmlUCSIsHighPrivateUseSurrogates
xmlUCSIsHighSurrogates
@@ -975,18 +1213,26 @@ xmlUCSIsKanbun
xmlUCSIsKangxiRadicals
xmlUCSIsKannada
xmlUCSIsKatakana
xmlUCSIsKatakanaPhoneticExtensions
xmlUCSIsKhmer
xmlUCSIsKhmerSymbols
xmlUCSIsLao
xmlUCSIsLatin1Supplement
xmlUCSIsLatinExtendedA
xmlUCSIsLatinExtendedAdditional
xmlUCSIsLatinExtendedB
xmlUCSIsLetterlikeSymbols
xmlUCSIsLimbu
xmlUCSIsLinearBIdeograms
xmlUCSIsLinearBSyllabary
xmlUCSIsLowSurrogates
xmlUCSIsMalayalam
xmlUCSIsMathematicalAlphanumericSymbols
xmlUCSIsMathematicalOperators
xmlUCSIsMiscellaneousMathematicalSymbolsA
xmlUCSIsMiscellaneousMathematicalSymbolsB
xmlUCSIsMiscellaneousSymbols
xmlUCSIsMiscellaneousSymbolsandArrows
xmlUCSIsMiscellaneousTechnical
xmlUCSIsMongolian
xmlUCSIsMusicalSymbols
@@ -996,23 +1242,40 @@ xmlUCSIsOgham
xmlUCSIsOldItalic
xmlUCSIsOpticalCharacterRecognition
xmlUCSIsOriya
xmlUCSIsOsmanya
xmlUCSIsPhoneticExtensions
xmlUCSIsPrivateUse
xmlUCSIsPrivateUseArea
xmlUCSIsRunic
xmlUCSIsShavian
xmlUCSIsSinhala
xmlUCSIsSmallFormVariants
xmlUCSIsSpacingModifierLetters
xmlUCSIsSpecials
xmlUCSIsSuperscriptsandSubscripts
xmlUCSIsSupplementalArrowsA
xmlUCSIsSupplementalArrowsB
xmlUCSIsSupplementalMathematicalOperators
xmlUCSIsSupplementaryPrivateUseAreaA
xmlUCSIsSupplementaryPrivateUseAreaB
xmlUCSIsSyriac
xmlUCSIsTagalog
xmlUCSIsTagbanwa
xmlUCSIsTags
xmlUCSIsTaiLe
xmlUCSIsTaiXuanJingSymbols
xmlUCSIsTamil
xmlUCSIsTelugu
xmlUCSIsThaana
xmlUCSIsThai
xmlUCSIsTibetan
xmlUCSIsUgaritic
xmlUCSIsUnifiedCanadianAboriginalSyllabics
xmlUCSIsVariationSelectors
xmlUCSIsVariationSelectorsSupplement
xmlUCSIsYiRadicals
xmlUCSIsYiSyllables
xmlUCSIsYijingHexagramSymbols
xmlURIEscape
xmlURIEscapeStr
xmlURIUnescapeString
@@ -1058,8 +1321,14 @@ xmlValidatePushCData
xmlValidatePushElement
xmlValidateQName
xmlValidateRoot
xmlXIncludeFreeContext
xmlXIncludeNewContext
xmlXIncludeProcess
xmlXIncludeProcessFlags
xmlXIncludeProcessNode
xmlXIncludeProcessTree
xmlXIncludeProcessTreeFlags
xmlXIncludeSetFlags
xmlXPathAddValues
xmlXPathBooleanFunction
xmlXPathCastBooleanToNumber
@@ -1078,6 +1347,7 @@ xmlXPathCastToNumber
xmlXPathCastToString
xmlXPathCeilingFunction
xmlXPathCmpNodes
xmlXPathCtxtCompile
xmlXPathCompareValues
xmlXPathCompile
xmlXPathCompiledEval
@@ -1087,6 +1357,7 @@ xmlXPathConvertBoolean
xmlXPathConvertNumber
xmlXPathConvertString
xmlXPathCountFunction
xmlXPathCtxtCompile
xmlXPathDebugDumpCompExpr
xmlXPathDebugDumpObject
xmlXPathDifference
@@ -1094,6 +1365,7 @@ xmlXPathDistinct
xmlXPathDistinctSorted
xmlXPathDivValues
xmlXPathEqualValues
xmlXPathErr
xmlXPathEval
xmlXPathEvalExpr
xmlXPathEvalExpression
@@ -1208,6 +1480,7 @@ xmlXPathWrapCString
xmlXPathWrapExternal
xmlXPathWrapNodeSet
xmlXPathWrapString
xmlXPathErr
xmlXPatherror
xmlXPtrBuildNodeList
xmlXPtrEval
@@ -1230,9 +1503,69 @@ xmlXPtrNewRangePointNode
xmlXPtrNewRangePoints
xmlXPtrRangeToFunction
xmlXPtrWrapLocationSet
_libiconv_version
libiconv_close
libiconv
libiconv_open
libiconv_set_relocation_prefix
xmlNewTextWriter
xmlNewTextWriterDoc
xmlNewTextWriterFilename
xmlNewTextWriterMemory
xmlNewTextWriterPushParser
xmlNewTextWriterTree
xmlFreeTextWriter
xmlTextWriterEndAttribute
xmlTextWriterEndCDATA
xmlTextWriterEndComment
xmlTextWriterEndDTD
xmlTextWriterEndDTDAttlist
xmlTextWriterEndDTDElement
xmlTextWriterEndDTDEntity
xmlTextWriterEndDocument
xmlTextWriterEndElement
xmlTextWriterEndPI
xmlTextWriterFlush
xmlTextWriterFullEndElement
xmlTextWriterSetIndent
xmlTextWriterSetIndentString
xmlTextWriterStartAttribute
xmlTextWriterStartAttributeNS
xmlTextWriterStartCDATA
xmlTextWriterStartComment
xmlTextWriterStartDTD
xmlTextWriterStartDTDAttlist
xmlTextWriterStartDTDElement
xmlTextWriterStartDTDEntity
xmlTextWriterStartDocument
xmlTextWriterStartElement
xmlTextWriterStartElementNS
xmlTextWriterStartPI
xmlTextWriterWriteAttribute
xmlTextWriterWriteAttributeNS
xmlTextWriterWriteBase64
xmlTextWriterWriteBinHex
xmlTextWriterWriteCDATA
xmlTextWriterWriteComment
xmlTextWriterWriteDTD
xmlTextWriterWriteDTDAttlist
xmlTextWriterWriteDTDElement
xmlTextWriterWriteDTDEntity
xmlTextWriterWriteDTDExternalEntity
xmlTextWriterWriteDTDExternalEntityContents
xmlTextWriterWriteDTDInternalEntity
xmlTextWriterWriteDTDNotation
xmlTextWriterWriteElement
xmlTextWriterWriteElementNS
xmlTextWriterWriteFormatAttribute
xmlTextWriterWriteFormatAttributeNS
xmlTextWriterWriteFormatCDATA
xmlTextWriterWriteFormatComment
xmlTextWriterWriteFormatDTD
xmlTextWriterWriteFormatDTDAttlist
xmlTextWriterWriteFormatDTDElement
xmlTextWriterWriteFormatDTDInternalEntity
xmlTextWriterWriteFormatElement
xmlTextWriterWriteFormatElementNS
xmlTextWriterWriteFormatPI
xmlTextWriterWriteFormatRaw
xmlTextWriterWriteFormatString
xmlTextWriterWritePI
xmlTextWriterWriteRaw
xmlTextWriterWriteRawLen
xmlTextWriterWriteString
+1
View File
@@ -84,6 +84,7 @@ int main() { return foo(10, "", 3.14); }
PHP_MBSTRING_ADD_CFLAG([-DNOT_RUBY])
PHP_MBSTRING_ADD_BUILD_DIR([oniguruma])
PHP_MBSTRING_ADD_BUILD_DIR([oniguruma/enc])
PHP_MBSTRING_ADD_INCLUDE([oniguruma])
PHP_MBSTRING_ADD_CONFIG_HEADER([oniguruma/config.h])
+1 -1
View File
@@ -8,7 +8,7 @@
#ifndef ONIGURUMA_H
#define ONIGURUMA_H
#include "php_compat.h"
#include "php_onig_compat.h"
#define ONIGURUMA
#define ONIGURUMA_VERSION_MAJOR 2
File renamed without changes.
+14 -15
View File
@@ -430,7 +430,7 @@ DLEXPORT PHP_MINFO_FUNCTION(mnogosearch)
static char* MyRemoveHiLightDup(const char *s){
size_t len=strlen(s)+1;
char *d, *res = (char*)UdmMalloc(len);
char *d, *res = (char*)emalloc(len);
for(d=res; s[0]; s++)
{
@@ -1625,7 +1625,7 @@ DLEXPORT PHP_FUNCTION(udm_make_excerpt)
al = (char *)MyRemoveHiLightDup((const char *)(UdmVarListFindStr(&(Res->Doc[row].Sections), "URL", "")));
UdmVarListReplaceInt(&(Res->Doc[row].Sections), "STORED_ID", UdmCRC32(al, strlen(al)));
free(al);
efree(al);
#if UDM_VERSION_ID >= 30216
Excerpt = UdmExcerptDoc(Agent, Res, &(Res->Doc[row]), ExcerptSize, ExcerptPadding);
@@ -1777,7 +1777,7 @@ DLEXPORT PHP_FUNCTION(udm_get_res_field_ex)
char *al;
al = (char *)MyRemoveHiLightDup((const char *)(UdmVarListFindStr(&(Res->Doc[row].Sections), field, "")));
UdmVarListReplaceStr(&Res->Doc[row].Sections,field,al);
free(al);
efree(al);
}
RETURN_STRING((char *)UdmVarListFindStr(&Res->Doc[row].Sections,field,""),1);
} else {
@@ -1839,12 +1839,11 @@ DLEXPORT PHP_FUNCTION(udm_store_doc_cgi)
if(!Doc->Buf.content) {
UdmResultFree(Res);
UdmDocFree(Doc);
UDM_FREE(HDoc);
RETURN_FALSE;
}
HEnd=HDoc = (char*)UdmMalloc(UDM_MAXDOCSIZE + 32);
HEnd=HDoc = (char*)emalloc(UDM_MAXDOCSIZE + 32);
*HEnd='\0';
if (strncasecmp(content_type, "text/plain", 10) == 0) {
@@ -1885,7 +1884,7 @@ DLEXPORT PHP_FUNCTION(udm_store_doc_cgi)
UdmResultFree(Res);
UdmDocFree(Doc);
UDM_FREE(HDoc);
efree(HDoc);
RETURN_TRUE;
}
@@ -2066,7 +2065,7 @@ DLEXPORT PHP_FUNCTION(udm_get_res_field)
char *al;
al = (char *)MyRemoveHiLightDup((const char *)(UdmVarListFindStr(&(Res->Doc[row].Sections), "URL", "")));
UdmVarListReplaceStr(&Res->Doc[row].Sections,"URL",al);
free(al);
efree(al);
RETURN_STRING((char *)UdmVarListFindStr(&(Res->Doc[row].Sections),"URL",""),1);
}
@@ -2256,7 +2255,7 @@ DLEXPORT PHP_FUNCTION(udm_get_res_param)
len += Res->WWList.Word[i].len + 64;
{
size_t wsize=(1+len)*sizeof(char);
char *wordinfo = (char*) malloc(wsize);
char *wordinfo = (char*) emalloc(wsize);
*wordinfo = '\0';
@@ -2270,7 +2269,7 @@ DLEXPORT PHP_FUNCTION(udm_get_res_param)
sprintf(UDM_STREND(wordinfo)," %s : stopword", Res->WWList.Word[i].word);
}
}
RETURN_STRING(wordinfo,1);
RETURN_STRING(wordinfo,0);
}
}
#else
@@ -2286,7 +2285,7 @@ DLEXPORT PHP_FUNCTION(udm_get_res_param)
len += Res->WWList.Word[i].len + 64;
{
size_t wsize=(1+len)*sizeof(char);
char *wordinfo = (char*) malloc(wsize);
char *wordinfo = (char*) emalloc(wsize);
int corder = (size_t)-1, ccount = 0;
*wordinfo = '\0';
@@ -2305,7 +2304,7 @@ DLEXPORT PHP_FUNCTION(udm_get_res_param)
sprintf(UDM_STREND(wordinfo),"%s%s : %d / %d", (*wordinfo) ? ", " : "", Res->WWList.Word[i].word, Res->WWList.Word[i].count, ccount);
} else continue;
}
RETURN_STRING(wordinfo,1);
RETURN_STRING(wordinfo,0);
}
}
break;
@@ -2489,7 +2488,7 @@ DLEXPORT PHP_FUNCTION(udm_cat_list)
#endif
array_init(return_value);
if (!(buf=calloc(1,UDMSTRSIZ+1))) {
if (!(buf=ecalloc(1,UDMSTRSIZ+1))) {
RETURN_FALSE;
}
@@ -2513,7 +2512,7 @@ DLEXPORT PHP_FUNCTION(udm_cat_list)
c++;
}
#endif
free(buf);
efree(buf);
} else {
RETURN_FALSE;
}
@@ -2563,7 +2562,7 @@ DLEXPORT PHP_FUNCTION(udm_cat_path)
#endif
array_init(return_value);
if (!(buf=calloc(1,UDMSTRSIZ+1))) {
if (!(buf=ecalloc(1,UDMSTRSIZ+1))) {
RETURN_FALSE;
}
@@ -2587,7 +2586,7 @@ DLEXPORT PHP_FUNCTION(udm_cat_path)
c++;
}
#endif
free(buf);
efree(buf);
} else {
RETURN_FALSE;
}
+1 -1
View File
@@ -46,7 +46,7 @@ if test "$PHP_MYSQLI" != "no"; then
AC_DEFINE(HAVE_MYSQLILIB,1,[ ])
PHP_CHECK_LIBRARY(mysqlclient, mysql_stmt_field_count,
[ ],[
AC_MSG_ERROR([MySQLI doesn't support versions < 4.1.3 anymore. Please update your libraries.])
AC_MSG_ERROR([MySQLI doesn't support versions < 4.1.3 (for MySQL 4.1.x) and < 5.0.1 for (MySQL 5.0.x) anymore. Please update your libraries.])
],[])
],[
AC_MSG_ERROR([wrong mysql library version or lib not found. Check config.log for more information.])
+9 -1
View File
@@ -200,6 +200,13 @@ zval *mysqli_read_property(zval *object, zval *member, int type TSRMLS_DC)
ret = zend_hash_find(obj->prop_handler, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &hnd);
}
if (ret == SUCCESS) {
/* check if connection is still valid */
if (!obj->ptr ||
!((MYSQL *)((MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->mysql)->thread_id) {
retval = EG(uninitialized_zval_ptr);
return(retval);
}
ret = hnd->read_func(obj, &retval TSRMLS_CC);
if (ret == SUCCESS) {
/* ensure we're creating a temporary variable */
@@ -431,6 +438,7 @@ PHP_MINIT_FUNCTION(mysqli)
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_INTERACTIVE", CLIENT_INTERACTIVE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_IGNORE_SPACE", CLIENT_IGNORE_SPACE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_NO_SCHEMA", CLIENT_NO_SCHEMA, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_FOUND_ROWS", CLIENT_FOUND_ROWS, CONST_CS | CONST_PERSISTENT);
/* for mysqli_query */
REGISTER_LONG_CONSTANT("MYSQLI_STORE_RESULT", 0, CONST_CS | CONST_PERSISTENT);
@@ -594,7 +602,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
}
fetchtype = override_flags;
} else {
fetchtype = MYSQLI_NUM;
fetchtype = MYSQLI_ASSOC;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &mysql_result, mysqli_result_class_entry, &fetchtype) == FAILURE) {
return;
}
+1 -1
View File
@@ -629,7 +629,7 @@ PHP_FUNCTION(mysqli_stmt_fetch)
ZVAL_LONG(stmt->result.vars[i], llval);
}
} else {
ZVAL_STRING(stmt->result.vars[i], stmt->result.buf[i].val, 1);
ZVAL_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val, stmt->result.buf[i].buflen, 1);
}
break;
default:
+1
View File
@@ -203,6 +203,7 @@ function_entry mysqli_link_methods[] = {
PHP_FALIAS(master_query,mysqli_master_query,NULL)
PHP_FALIAS(multi_query,mysqli_multi_query,NULL)
PHP_FALIAS(more_results,mysqli_more_results, NULL)
PHP_FALIAS(mysqli, mysqli_connect, NULL)
PHP_FALIAS(next_result, mysqli_next_result, NULL)
PHP_FALIAS(options,mysqli_options,NULL)
PHP_FALIAS(ping,mysqli_ping,NULL)
+10
View File
@@ -80,6 +80,15 @@ int __func(mysqli_object *obj, zval **retval TSRMLS_DC)\
/* {{{ property link_client_version_read */
int link_client_version_read(mysqli_object *obj, zval **retval TSRMLS_DC)
{
ALLOC_ZVAL(*retval);
ZVAL_LONG(*retval, MYSQL_VERSION_ID);
return SUCCESS;
}
/* }}} */
/* {{{ property link_client_info_read */
int link_client_info_read(mysqli_object *obj, zval **retval TSRMLS_DC)
{
ALLOC_ZVAL(*retval);
ZVAL_STRING(*retval, MYSQL_SERVER_VERSION, 1);
@@ -191,6 +200,7 @@ MYSQLI_MAP_PROPERTY_FUNC_STRING(stmt_sqlstate_read, mysql_stmt_sqlstate, MYSQLI_
mysqli_property_entry mysqli_link_property_entries[] = {
{"affected_rows", link_affected_rows_read, NULL},
{"client_info", link_client_info_read, NULL},
{"client_version", link_client_version_read, NULL},
{"test", link_test_read, NULL},
{"connect_errno", link_connect_errno_read, NULL},
+44
View File
@@ -0,0 +1,44 @@
--TEST--
constructor test
--FILE--
<?php
include "connect.inc";
/* class 1 calls parent constructor */
class mysql1 extends mysqli {
function __construct() {
parent::__construct("localhost", "root", "", "test");
}
}
/* class 2 has an own constructor */
class mysql2 extends mysqli {
function __construct() {
$this->connect("localhost", "root", "", "test");
}
}
/* class 3 has no constructor */
class mysql3 extends mysqli {
}
$foo[0] = new mysql1();
$foo[1] = new mysql2();
$foo[2] = new mysql3("localhost", "root", "", "test");
for ($i=0; $i < 3; $i++) {
if (($result = $foo[$i]->query("SELECT DATABASE()"))) {
$row = $result->fetch_row();
printf("%d: %s\n", $i, $row[0]);
$result->close();
}
$foo[$i]->close();
}
?>
--EXPECTF--
0: test
1: test
2: test
-56
View File
@@ -1,56 +0,0 @@
dnl
dnl $Id$
dnl
dnl By default we'll compile and link against the bundled PCRE library
dnl if DIR is supplied, we'll use that for linking
PHP_ARG_WITH(pcre-regex,for PCRE support,
[ --without-pcre-regex Do not include Perl Compatible Regular Expressions
support. Use --with-pcre-regex=DIR to specify DIR
where PCRE's include and library files are located,
if not using bundled library.],yes)
if test "$PHP_PCRE_REGEX" != "no"; then
if test "$PHP_PCRE_REGEX" = "yes"; then
PHP_NEW_EXTENSION(pcre, pcrelib/maketables.c pcrelib/get.c pcrelib/study.c pcrelib/pcre.c php_pcre.c, $ext_shared,,-DSUPPORT_UTF8 -DLINK_SIZE=2 -DPOSIX_MALLOC_THRESHOLD=10 -I@ext_srcdir@/pcrelib)
PHP_ADD_BUILD_DIR($ext_builddir/pcrelib)
AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ])
else
for i in $PHP_PCRE_REGEX $PHP_PCRE_REGEX/include $PHP_PCRE_REGEX/include/pcre; do
test -f $i/pcre.h && PCRE_INCDIR=$i
done
if test -z "$PCRE_INCDIR"; then
AC_MSG_ERROR([Could not find pcre.h in $PHP_PCRE_REGEX])
fi
for j in $PHP_PCRE_REGEX $PHP_PCRE_REGEX/lib; do
test -f $j/libpcre.a -o -f $j/libpcre.$SHLIB_SUFFIX_NAME && PCRE_LIBDIR=$j
done
if test -z "$PCRE_LIBDIR" ; then
AC_MSG_ERROR([Could not find libpcre.(a|$SHLIB_SUFFIX_NAME) in $PHP_PCRE_REGEX])
fi
changequote({,})
pcre_major=`grep PCRE_MAJOR $PCRE_INCDIR/pcre.h | sed -e 's/[^0-9]//g'`
pcre_minor=`grep PCRE_MINOR $PCRE_INCDIR/pcre.h | sed -e 's/[^0-9]//g'`
changequote([,])
pcre_minor_length=`echo "$pcre_minor" | wc -c | sed -e 's/[^0-9]//g'`
if test "$pcre_minor_length" -eq 2 ; then
pcre_minor="$pcre_minor"0
fi
pcre_version=$pcre_major$pcre_minor
if test "$pcre_version" -lt 208; then
AC_MSG_ERROR([The PCRE extension requires PCRE library version >= 2.08])
fi
PHP_ADD_LIBRARY_WITH_PATH(pcre, $PCRE_LIBDIR, PCRE_SHARED_LIBADD)
AC_DEFINE(HAVE_PCRE, 1, [ ])
PHP_ADD_INCLUDE($PCRE_INCDIR)
PHP_NEW_EXTENSION(pcre, php_pcre.c, $ext_shared,,-DSUPPORT_UTF8 -DLINK_SIZE=2 -DPOSIX_MALLOC_THRESHOLD=10)
fi
PHP_SUBST(PCRE_SHARED_LIBADD)
fi
-2
View File
@@ -1,2 +0,0 @@
PHP Data Objects
Wez Furlong, Marcus Boerger, Sterling Hughes, George Schlossnagle
View File
Whitespace-only changes.
-31
View File
@@ -1,31 +0,0 @@
phpincludedir=$(prefix)/include/php
PDO_HEADER_FILES= \
php_pdo.h \
php_pdo_driver.h
install-pdo-headers:
echo "Installing PDO headers: $(INSTALL_ROOT)$(phpincludedir)/ext/pdo/"
$(mkinstalldirs) $(INSTALL_ROOT)$(phpincludedir)/ext/pdo
for f in $(PDO_HEADER_FILES); do \
if test -f "$(top_srcdir)/$$f"; then \
$(INSTALL_DATA) $(top_srcdir)/$$f $(INSTALL_ROOT)$(phpincludedir)/ext/pdo; \
elif test -f "$(top_builddir)/$$f"; then \
$(INSTALL_DATA) $(top_builddir)/$$f $(INSTALL_ROOT)$(phpincludedir)/ext/pdo; \
elif test -f "$(top_srcdir)/ext/pdo/$$f"; then \
$(INSTALL_DATA) $(top_srcdir)/ext/pdo/$$f $(INSTALL_ROOT)$(phpincludedir)/ext/pdo; \
elif test -f "$(top_builddir)/ext/pdo/$$f"; then \
$(INSTALL_DATA) $(top_builddir)/ext/pdo/$$f $(INSTALL_ROOT)$(phpincludedir)/ext/pdo; \
else \
echo "hmmm"; \
fi \
done;
# mini hack
install: $(all_targets) $(install_targets) install-pdo-headers
$(top_srcdir)/ext/pdo/pdo_sql_parser.c: $(top_srcdir)/ext/pdo/pdo_sql_parser.re
re2c -b $(top_srcdir)/ext/pdo/pdo_sql_parser.re > $@
$(srcdir)/pdo_sql_parser.c: $(srcdir)/pdo_sql_parser.re
re2c -b $(srcdir)/pdo_sql_parser.re > $@
-56
View File
@@ -1,56 +0,0 @@
$Id$
PHP Data Objects
================
Concept: Data Access Abstraction
Goals:
1/ Be light-weight
2/ Provide common API for common database operations
3/ Be performant
4/ Keep majority of PHP specific stuff in the PDO core (such as persistent
resource management); drivers should only have to worry about getting the
data and not about PHP internals.
Transactions and autocommit
===========================
When you create a database handle, you *should* specify the autocommit
behaviour that you require. PDO will default to autocommit on.
$dbh = new PDO("...", $user, $pass, array(PDO_ATTR_AUTOCOMMIT => true));
When auto-commit is on, the driver will implicitly commit each query as it is
executed. This works fine for most simple tasks but can be significantly
slower when you are making a large number of udpates.
$dbh = new PDO("...", $user, $pass, array(PDO_ATTR_AUTOCOMMIT => false));
When auto-commit is off, you must then use $dbh->beginWork() to initiate a
transaction. When your work is done, you then call $dbh->commit() or
$dbh->rollBack() to persist or abort your changes respectively.
Not all databases support transactions.
You can change the auto-commit mode at run-time:
$dbh->setAttribute(PDO_ATTR_AUTOCOMMIT, false);
Regardless of the error handling mode set on the database handle, if the
autocommit mode cannot be changed, an exception will be thrown.
Some drivers will allow you to temporarily disable autocommit if you call
$dbh->beginWork(). When you commit() or rollBack() such a transaction, the
handle will switch back to autocommit mode again. If the mode could not be
changed, an exception will be raised, as noted above.
When the database handle is closed or destroyed (or at request end for
persistent handles), the driver will implicitly rollBack(). It is your
responsibility to call commit() when you are done making changes and
autocommit is turned off.
vim:tw=78:et
-25
View File
@@ -1,25 +0,0 @@
$Id$
In no particular order:
Low-level:
- Scanner for :named placeholders and prepare()/execute() emulation (George)
- $dbh->quote()
- Exceptions and unified error API
- Scrollable cursors
- meta data from driver, such as server version and supported features
- field meta data from statement handles
- $dbh->exec() for one-shot SQL
- LOB support via Streams API
- persistent handles
- iterator support
- "lazy" fetch support
Not-so-low-level:
- hash key case folding for portabilitiy, ala sqlite.assoc_case, but not using an ini option.
- fetchAll(), single row, single column fetches etc.
Could be more...
vim:tw=78:et
-10
View File
@@ -1,10 +0,0 @@
dnl $Id$
dnl config.m4 for extension pdo
PHP_ARG_ENABLE(pdo, whether to enable PDO support,
[ --enable-pdo Enable PHP Data Objects support])
if test "$PHP_PDO" != "no"; then
PHP_NEW_EXTENSION(pdo, pdo.c pdo_dbh.c pdo_stmt.c pdo_sql_parser.c, $ext_shared)
PHP_ADD_MAKEFILE_FRAGMENT
fi
-9
View File
@@ -1,9 +0,0 @@
// $Id$
// vim:ft=javascript
ARG_ENABLE("pdo", "Enable PHP Data Objects support", "no");
if (PHP_PDO != "no") {
EXTENSION('pdo', 'pdo.c pdo_dbh.c pdo_stmt.c pdo_sql_parser.c');
}
-84
View File
@@ -1,84 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE package SYSTEM "../pear/package.dtd">
<package version="1.0">
<name>PDO</name>
<summary>PHP Data Objects Interface</summary>
<maintainers>
<maintainer>
<user>wez</user>
<name>Wez Furlong</name>
<email>wez@php.net</email>
<role>lead</role>
</maintainer>
<maintainer>
<user>helly</user>
<name>Marcus Boerger</name>
<email>helly@php.net</email>
<role>lead</role>
</maintainer>
<maintainer>
<user>iliaa</user>
<name>Ilia Alshanetsky</name>
<email>iliaa@php.net</email>
<role>lead</role>
</maintainer>
<maintainer>
<user>gschlossnagle</user>
<name>George Schlossnagle</name>
<email>george@omniti.com</email>
<role>lead</role>
</maintainer>
</maintainers>
<description>
PDO provides a uniform data access interface, sporting advanced features such
as prepared statements and bound parameters. PDO drivers are dynamically
loadable and may be developed independently from the core, but still accessed
using the same API.
</description>
<license>PHP</license>
<release>
<state>alpha</state>
<version>0.1.1</version>
<date>2004-05-21</date>
<notes>
Note that PDO on its own is useless.
You need to install a PDO database driver to make use of it,
check http://pecl.php.net for a list of available PDO drivers.
It is highly recommended that you update to the latest PHP 5 snapshot before using PDO.
You can obtain it from http://snaps.php.net.
If you are running on Windows, you should download:
http://snaps.php.net/win32/php5-win32-latest.zip
http://snaps.php.net/win32/PECL_5_0/php_pdo.dll
You can find additional PDO drivers at:
http://snaps.php.net/win32/PECL_5_0/
</notes>
<filelist>
<file role="src" name="config.m4"/>
<file role="src" name="config.w32"/>
<file role="src" name="pdo.c"/>
<file role="src" name="pdo_dbh.c"/>
<file role="src" name="pdo_stmt.c"/>
<file role="src" name="php_pdo.h"/>
<file role="src" name="php_pdo_driver.h"/>
<file role="src" name="php_pdo_int.h"/>
<file role="src" name="pdo_sql_parser.re"/>
<file role="src" name="pdo_sql_parser.c"/>
<file role="src" name="php_pdo_sql_parser.h"/>
<file role="src" name="Makefile.frag"/>
<file role="doc" name="README"/>
<file role="doc" name="TODO"/>
<file role="doc" name="pdo.php"/>
<file role="doc" name="CREDITS"/>
</filelist>
<deps>
<dep type="php" rel="ge" version="5.0.0RC3-dev"/>
</deps>
</release>
</package>
-315
View File
@@ -1,315 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.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@php.net> |
| Marcus Boerger <helly@php.net> |
| Sterling Hughes <sterling@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <ctype.h>
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_pdo.h"
#include "php_pdo_driver.h"
#include "php_pdo_int.h"
#include "zend_exceptions.h"
ZEND_DECLARE_MODULE_GLOBALS(pdo)
/* True global resources - no need for thread safety here */
/* the registry of PDO drivers */
static HashTable pdo_driver_hash;
/* we use persistent resources for the driver connection stuff */
static int le_ppdo;
/* for exceptional circumstances */
zend_class_entry *pdo_exception_ce;
PDO_API zend_class_entry *php_pdo_get_exception(void)
{
return pdo_exception_ce;
}
zend_class_entry *pdo_dbh_ce, *pdo_dbstmt_ce, *pdo_row_ce;
/* {{{ pdo_functions[] */
function_entry pdo_functions[] = {
{NULL, NULL, NULL}
};
/* }}} */
/* {{{ pdo_module_entry */
zend_module_entry pdo_module_entry = {
STANDARD_MODULE_HEADER,
"PDO",
pdo_functions,
PHP_MINIT(pdo),
PHP_MSHUTDOWN(pdo),
PHP_RINIT(pdo),
PHP_RSHUTDOWN(pdo),
PHP_MINFO(pdo),
"0.1.1",
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#ifdef COMPILE_DL_PDO
ZEND_GET_MODULE(pdo)
#endif
/* {{{ PHP_INI */
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("pdo.global_value", "42", PHP_INI_ALL, OnUpdateLong, global_value, zend_pdo_globals, pdo_globals)
PHP_INI_END()
/* }}} */
/* {{{ php_pdo_init_globals */
static void php_pdo_init_globals(zend_pdo_globals *pdo_globals)
{
pdo_globals->global_value = 0;
}
/* }}} */
PDO_API int php_pdo_register_driver(pdo_driver_t *driver)
{
if (driver->api_version != PDO_DRIVER_API) {
zend_error(E_ERROR, "failed api version check");
return FAILURE;
}
if (!zend_hash_exists(&module_registry, "pdo", sizeof("pdo"))) {
zend_error(E_ERROR, "You MUST load PDO before loading any PDO drivers");
return FAILURE; /* NOTREACHED */
}
return zend_hash_add(&pdo_driver_hash, (char*)driver->driver_name, driver->driver_name_len,
(void**)&driver, sizeof(driver), NULL);
}
PDO_API void php_pdo_unregister_driver(pdo_driver_t *driver)
{
if (!zend_hash_exists(&module_registry, "pdo", sizeof("pdo"))) {
return;
}
zend_hash_del(&pdo_driver_hash, (char*)driver->driver_name, driver->driver_name_len);
}
pdo_driver_t *pdo_find_driver(const char *name, int namelen)
{
pdo_driver_t **driver = NULL;
zend_hash_find(&pdo_driver_hash, (char*)name, namelen, (void**)&driver);
return driver ? *driver : NULL;
}
PDO_API int php_pdo_parse_data_source(const char *data_source,
unsigned long data_source_len, struct pdo_data_src_parser *parsed,
int nparams)
{
int i, j;
int valstart = -1;
int semi = -1;
int optstart = 0;
int nlen;
int n_matches = 0;
i = 0;
while (i < data_source_len) {
/* looking for NAME= */
if (data_source[i] == '\0') {
break;
}
if (data_source[i] != '=') {
++i;
continue;
}
valstart = ++i;
/* now we're looking for VALUE; or just VALUE<NUL> */
semi = -1;
while (i < data_source_len) {
if (data_source[i] == '\0') {
semi = i++;
break;
}
if (data_source[i] == ';') {
semi = i++;
break;
}
++i;
}
if (semi == -1) {
semi = i;
}
/* find the entry in the array */
nlen = valstart - optstart - 1;
for (j = 0; j < nparams; j++) {
if (0 == strncmp(data_source + optstart, parsed[j].optname, nlen) && parsed[j].optname[nlen] == '\0') {
/* got a match */
if (parsed[j].freeme) {
efree(parsed[j].optval);
}
parsed[j].optval = estrndup(data_source + valstart, semi - valstart);
parsed[j].freeme = 1;
++n_matches;
break;
}
}
while (i < data_source_len && isspace(data_source[i])) {
i++;
}
optstart = i;
}
return n_matches;
}
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(pdo)
{
zend_class_entry ce;
ZEND_INIT_MODULE_GLOBALS(pdo, php_pdo_init_globals, NULL);
REGISTER_INI_ENTRIES();
zend_hash_init(&pdo_driver_hash, 0, NULL, NULL, 1);
REGISTER_LONG_CONSTANT("PDO_PARAM_NULL", (long)PDO_PARAM_NULL, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_PARAM_INT", (long)PDO_PARAM_INT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_PARAM_STR", (long)PDO_PARAM_STR, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_PARAM_LOB", (long)PDO_PARAM_LOB, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_PARAM_STMT", (long)PDO_PARAM_STMT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_FETCH_LAZY", (long)PDO_FETCH_LAZY, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_FETCH_ASSOC",(long)PDO_FETCH_ASSOC, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_FETCH_NUM", (long)PDO_FETCH_NUM, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_FETCH_BOTH", (long)PDO_FETCH_BOTH, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_FETCH_OBJ", (long)PDO_FETCH_OBJ, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_FETCH_BOUND",(long)PDO_FETCH_BOUND, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ATTR_AUTOCOMMIT", (long)PDO_ATTR_AUTOCOMMIT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ATTR_SCROLL", (long)PDO_ATTR_SCROLL, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ATTR_PREFETCH", (long)PDO_ATTR_PREFETCH, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ATTR_TIMEOUT", (long)PDO_ATTR_TIMEOUT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ATTR_ERRMODE", (long)PDO_ATTR_ERRMODE, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ATTR_SERVER_VERSION", (long)PDO_ATTR_SERVER_VERSION, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ATTR_CLIENT_VERSION", (long)PDO_ATTR_CLIENT_VERSION, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ATTR_SERVER_INFO", (long)PDO_ATTR_SERVER_INFO, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ATTR_CONNECTION_STATUS", (long)PDO_ATTR_CONNECTION_STATUS, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ATTR_CASE", (long)PDO_ATTR_CASE, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ATTR_CURSOR_NAME", (long)PDO_ATTR_CURSOR_NAME, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ATTR_CURSOR", (long)PDO_ATTR_CURSOR, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERRMODE_SILENT", (long)PDO_ERRMODE_SILENT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERRMODE_WARNING", (long)PDO_ERRMODE_WARNING, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERRMODE_EXCEPTION", (long)PDO_ERRMODE_EXCEPTION, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_CASE_NATURAL", (long)PDO_CASE_NATURAL, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_CASE_LOWER", (long)PDO_CASE_LOWER, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_CASE_UPPER", (long)PDO_CASE_UPPER, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERR_NONE", (long)PDO_ERR_NONE, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERR_CANT_MAP", (long)PDO_ERR_CANT_MAP, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERR_SYNTAX", (long)PDO_ERR_SYNTAX, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERR_CONSTRAINT", (long)PDO_ERR_CONSTRAINT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERR_NOT_FOUND", (long)PDO_ERR_NOT_FOUND, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERR_ALREADY_EXISTS", (long)PDO_ERR_ALREADY_EXISTS, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERR_NOT_IMPLEMENTED", (long)PDO_ERR_NOT_IMPLEMENTED, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERR_MISMATCH", (long)PDO_ERR_MISMATCH, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERR_TRUNCATED", (long)PDO_ERR_TRUNCATED, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERR_DISCONNECTED", (long)PDO_ERR_DISCONNECTED, CONST_CS|CONST_PERSISTENT);
INIT_CLASS_ENTRY(ce, "PDOException", NULL);
pdo_exception_ce = zend_register_internal_class_ex(&ce, zend_exception_get_default(), NULL TSRMLS_CC);
zend_declare_property_null(pdo_exception_ce, "errorInfo", sizeof("errorInfo")-1, ZEND_ACC_PUBLIC TSRMLS_CC);
INIT_CLASS_ENTRY(ce, "PDO", pdo_dbh_functions);
ce.create_object = pdo_dbh_new;
pdo_dbh_ce = zend_register_internal_class(&ce TSRMLS_CC);
INIT_CLASS_ENTRY(ce, "PDOStatement", pdo_dbstmt_functions);
ce.create_object = pdo_dbstmt_new;
pdo_dbstmt_ce = zend_register_internal_class(&ce TSRMLS_CC);
INIT_CLASS_ENTRY(ce, "PDORow", pdo_row_functions);
ce.create_object = pdo_row_new;
pdo_row_ce = zend_register_internal_class(&ce TSRMLS_CC);
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MSHUTDOWN_FUNCTION */
PHP_MSHUTDOWN_FUNCTION(pdo)
{
UNREGISTER_INI_ENTRIES();
zend_hash_destroy(&pdo_driver_hash);
return SUCCESS;
}
/* }}} */
/* {{{ PHP_RINIT_FUNCTION */
PHP_RINIT_FUNCTION(pdo)
{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_RSHUTDOWN_FUNCTION */
PHP_RSHUTDOWN_FUNCTION(pdo)
{
/* TODO: visit persistent handles: for each persistent statement handle,
* remove bound parameter associations */
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION */
PHP_MINFO_FUNCTION(pdo)
{
php_info_print_table_start();
php_info_print_table_header(2, "pdo support", "enabled");
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
-35
View File
@@ -1,35 +0,0 @@
<?php
//$x = new PDO("oci:dbname=hostname", 'php', 'php');
$x = new PDO("odbc:ram", 'php', 'php', array(PDO_ATTR_AUTOCOMMIT => 0));
$stmt = $x->prepare("select NAME, VALUE from test where value like ?");
$the_name = 'bar%';
$stmt->execute(array($the_name)) or die("failed to execute!");
$stmt->bindColumn('VALUE', $value);
while ($row = $stmt->fetch()) {
echo "name=$row[NAME] value=$row[VALUE]\n";
echo "value is $value\n";
echo "\n";
}
echo "Let's try an update\n";
$stmt = $x->prepare("INSERT INTO test (NAME, VALUE) VALUES (:name, :value)");
$stmt->bindParam(":name", $the_name, PDO_PARAM_STR, 32);
$stmt->bindParam(":value", $the_value, PDO_PARAM_STR, 32);
for ($i = 0; $i < 4; $i++) {
$the_name = "foo" . rand();
$the_value = "bar" . rand();
if (!$stmt->execute()) {
break;
}
}
echo "All done\n";
?>
-703
View File
@@ -1,703 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.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@php.net> |
| Marcus Boerger <helly@php.net> |
| Sterling Hughes <sterling@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
/* The PDO Database Handle Class */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_pdo.h"
#include "php_pdo_driver.h"
#include "php_pdo_int.h"
#include "zend_exceptions.h"
void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC)
{
enum pdo_error_type *pdo_err = &dbh->error_code;
const char *msg = "<<Unknown>>";
char *supp = NULL;
long native_code = 0;
char *message = NULL;
zval *info = NULL;
if (dbh->error_mode == PDO_ERRMODE_SILENT) {
return;
}
if (stmt) {
pdo_err = &stmt->error_code;
}
switch (*pdo_err) {
case PDO_ERR_NONE: msg = "No error"; break;
case PDO_ERR_CANT_MAP: msg = "Consult errorInfo() for more details"; break;
case PDO_ERR_SYNTAX: msg = "Syntax Error"; break;
case PDO_ERR_CONSTRAINT:msg = "Constraint violation"; break;
case PDO_ERR_NOT_FOUND: msg = "Not found"; break;
case PDO_ERR_ALREADY_EXISTS: msg = "Already exists"; break;
case PDO_ERR_NOT_IMPLEMENTED: msg = "Not Implemented"; break;
case PDO_ERR_MISMATCH: msg = "Mismatch"; break;
case PDO_ERR_TRUNCATED: msg = "Truncated"; break;
case PDO_ERR_DISCONNECTED: msg = "Disconnected"; break;
default: msg = "<<Invalid>>";
}
if (dbh->methods->fetch_err) {
MAKE_STD_ZVAL(info);
array_init(info);
add_next_index_long(info, *pdo_err);
if (dbh->methods->fetch_err(dbh, stmt, info TSRMLS_CC)) {
zval **item;
if (SUCCESS == zend_hash_index_find(Z_ARRVAL_P(info), 1, (void**)&item)) {
native_code = Z_LVAL_PP(item);
}
if (SUCCESS == zend_hash_index_find(Z_ARRVAL_P(info), 2, (void**)&item)) {
supp = estrndup(Z_STRVAL_PP(item), Z_STRLEN_PP(item));
}
}
}
if (supp && *pdo_err == PDO_ERR_CANT_MAP) {
spprintf(&message, 0, "%ld %s", native_code, supp);
} else if (supp) {
spprintf(&message, 0, "%s: %ld %s", msg, native_code, supp);
} else {
spprintf(&message, 0, "%s", msg);
}
if (dbh->error_mode == PDO_ERRMODE_WARNING) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", message);
if (info) {
zval_ptr_dtor(&info);
}
} else {
zval *ex;
zend_class_entry *def_ex = zend_exception_get_default(), *pdo_ex = php_pdo_get_exception();
MAKE_STD_ZVAL(ex);
object_init_ex(ex, pdo_ex);
zend_update_property_string(def_ex, ex, "message", sizeof("message")-1, message TSRMLS_CC);
zend_update_property_long(def_ex, ex, "code", sizeof("code")-1, *pdo_err TSRMLS_CC);
if (info) {
zend_update_property(pdo_ex, ex, "errorInfo", sizeof("errorInfo")-1, info TSRMLS_CC);
}
zend_throw_exception_object(ex TSRMLS_CC);
}
if (message) {
efree(message);
}
if (supp) {
efree(supp);
}
}
/* {{{ proto object PDO::__construct(string dsn, string username, string passwd [, array driver_opts])
*/
static PHP_FUNCTION(dbh_constructor)
{
zval *object = getThis();
pdo_dbh_t *dbh = NULL;
zend_bool is_persistent = FALSE;
char *data_source;
int data_source_len;
char *colon;
char *username=NULL, *password=NULL;
int usernamelen, passwordlen;
pdo_driver_t *driver = NULL;
zval *driver_options = NULL;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ssa!", &data_source, &data_source_len,
&username, &usernamelen, &password, &passwordlen, &driver_options)) {
ZVAL_NULL(object);
return;
}
/* parse the data source name */
colon = strchr(data_source, ':');
if (!colon) {
zend_throw_exception_ex(php_pdo_get_exception(), PDO_ERR_SYNTAX TSRMLS_CC, "invalid data source name");
ZVAL_NULL(object);
return;
}
driver = pdo_find_driver(data_source, colon - data_source);
if (!driver) {
/* NB: don't want to include the data_source in the error message as
* it might contain a password */
zend_throw_exception_ex(php_pdo_get_exception(), PDO_ERR_NOT_FOUND TSRMLS_CC, "could not find driver");
ZVAL_NULL(object);
return;
}
dbh = (pdo_dbh_t *) zend_object_store_get_object(object TSRMLS_CC);
if (dbh == NULL) {
/* need this check for persistent allocations */
zend_throw_exception_ex(php_pdo_get_exception(), PDO_ERR_NONE TSRMLS_CC, "out of memory!?");
}
dbh->is_persistent = is_persistent;
dbh->data_source_len = strlen(colon + 1);
/* when persistent stuff is done, we should check the return values here
* too */
dbh->data_source = (const char*)pestrdup(colon + 1, is_persistent);
dbh->username = username ? pestrdup(username, is_persistent) : NULL;
dbh->password = password ? pestrdup(password, is_persistent) : NULL;
dbh->auto_commit = pdo_attr_lval(driver_options, PDO_ATTR_AUTOCOMMIT, 1 TSRMLS_CC);
if (driver->db_handle_factory(dbh, driver_options TSRMLS_CC)) {
/* all set */
if (is_persistent) {
/* register in the persistent list etc. */
/* we should also need to replace the object store entry,
since it was created with emalloc */
;
}
return;
}
/* the connection failed; things will tidy up in free_storage */
/* XXX raise exception */
ZVAL_NULL(object);
}
/* }}} */
/* {{{ proto object PDO::prepare(string statment [, int options [, array driver_options]])
Prepares a statement for execution and returns a statement object */
/* TODO: options will be a PDO specific bitmask controlling such things as
* cursor type. */
static PHP_METHOD(PDO, prepare)
{
pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
pdo_stmt_t *stmt;
char *statement;
int statement_len;
zval *driver_options = NULL;
long options = 0;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|la", &statement,
&statement_len, &options, &driver_options)) {
RETURN_FALSE;
}
PDO_DBH_CLEAR_ERR();
stmt = ecalloc(1, sizeof(*stmt));
/* unconditionally keep this for later reference */
stmt->query_string = estrndup(statement, statement_len);
stmt->query_stringlen = statement_len;
if (dbh->methods->preparer(dbh, statement, statement_len, stmt, options, driver_options TSRMLS_CC)) {
/* prepared; create a statement object for PHP land to access it */
Z_TYPE_P(return_value) = IS_OBJECT;
Z_OBJ_HANDLE_P(return_value) = zend_objects_store_put(stmt, NULL, pdo_dbstmt_free_storage, NULL TSRMLS_CC);
Z_OBJ_HT_P(return_value) = &pdo_dbstmt_object_handlers;
/* give it a reference to me */
stmt->database_object_handle = *getThis();
zend_objects_store_add_ref(getThis() TSRMLS_CC);
stmt->dbh = dbh;
/* we haven't created a lazy object yet */
ZVAL_NULL(&stmt->lazy_object_ref);
stmt->refcount = 1;
return;
}
efree(stmt);
PDO_HANDLE_DBH_ERR();
RETURN_FALSE;
}
/* }}} */
/* {{{ proto bool PDO::beginTransaction()
Initiates a transaction */
static PHP_METHOD(PDO, beginTransaction)
{
pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
if (dbh->in_txn) {
zend_throw_exception_ex(php_pdo_get_exception(), PDO_ERR_NONE TSRMLS_CC, "There is already an active transaction");
RETURN_FALSE;
}
if (!dbh->methods->begin) {
/* TODO: this should be an exception; see the auto-commit mode
* comments below */
zend_throw_exception_ex(php_pdo_get_exception(), PDO_ERR_NONE TSRMLS_CC, "This driver doesn't support transactions");
RETURN_FALSE;
}
if (dbh->methods->begin(dbh TSRMLS_CC)) {
dbh->in_txn = 1;
RETURN_TRUE;
}
PDO_HANDLE_DBH_ERR();
RETURN_FALSE;
}
/* }}} */
/* {{{ proto bool PDO::commit()
Commit a transaction */
static PHP_METHOD(PDO, commit)
{
pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
if (!dbh->in_txn) {
zend_throw_exception_ex(php_pdo_get_exception(), PDO_ERR_NONE TSRMLS_CC, "There is no active transaction");
RETURN_FALSE;
}
if (dbh->methods->commit(dbh TSRMLS_CC)) {
dbh->in_txn = 0;
RETURN_TRUE;
}
PDO_HANDLE_DBH_ERR();
RETURN_FALSE;
}
/* }}} */
/* {{{ proto bool PDO::rollBack()
roll back a transaction */
static PHP_METHOD(PDO, rollBack)
{
pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
if (!dbh->in_txn) {
zend_throw_exception_ex(php_pdo_get_exception(), PDO_ERR_NONE TSRMLS_CC, "There is no active transaction");
RETURN_FALSE;
}
if (dbh->methods->rollback(dbh TSRMLS_CC)) {
dbh->in_txn = 0;
RETURN_TRUE;
}
PDO_HANDLE_DBH_ERR();
RETURN_FALSE;
}
/* }}} */
/* {{{ proto bool PDO::setAttribute(long attribute, mixed value)
Set an attribute */
static PHP_METHOD(PDO, setAttribute)
{
pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
long attr;
zval *value = NULL;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz!", &attr, &value)) {
RETURN_FALSE;
}
switch (attr) {
case PDO_ATTR_ERRMODE:
convert_to_long(value);
switch (Z_LVAL_P(value)) {
case PDO_ERRMODE_SILENT:
case PDO_ERRMODE_WARNING:
case PDO_ERRMODE_EXCEPTION:
dbh->error_mode = Z_LVAL_P(value);
RETURN_TRUE;
default:
zend_throw_exception_ex(php_pdo_get_exception(), PDO_ERR_SYNTAX TSRMLS_CC, "Error mode %d is invalid", Z_LVAL_P(value));
}
RETURN_FALSE;
case PDO_ATTR_CASE:
convert_to_long(value);
switch (Z_LVAL_P(value)) {
case PDO_CASE_NATURAL:
case PDO_CASE_UPPER:
case PDO_CASE_LOWER:
dbh->desired_case = Z_LVAL_P(value);
RETURN_TRUE;
default:
zend_throw_exception_ex(php_pdo_get_exception(), PDO_ERR_SYNTAX TSRMLS_CC, "Case folding mode %d is invalid", Z_LVAL_P(value));
}
RETURN_FALSE;
default:
;
}
if (!dbh->methods->set_attribute) {
goto fail;
}
PDO_DBH_CLEAR_ERR();
if (dbh->methods->set_attribute(dbh, attr, value TSRMLS_CC)) {
RETURN_TRUE;
}
fail:
if (attr == PDO_ATTR_AUTOCOMMIT) {
zend_throw_exception_ex(php_pdo_get_exception(), PDO_ERR_NONE TSRMLS_CC, "The auto-commit mode cannot be changed for this driver");
} else if (!dbh->methods->set_attribute) {
/* XXX: do something better here */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "This driver doesn't support setting attributes");
} else {
PDO_HANDLE_DBH_ERR();
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto mixed PDO::getAttribute(long attribute)
Get an attribute */
static PHP_METHOD(PDO, getAttribute)
{
pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
long attr;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &attr)) {
RETURN_FALSE;
}
if (!dbh->methods->get_attribute) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "This driver doesn't support fetching attributes");
RETURN_FALSE;
}
PDO_DBH_CLEAR_ERR();
switch (dbh->methods->get_attribute(dbh, attr, return_value TSRMLS_CC)) {
case -1:
PDO_HANDLE_DBH_ERR();
RETURN_FALSE;
case 0:
/* XXX: should do something better here */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "This driver doesn't support fetching %ld attribute", attr);
break;
default:
return;
}
}
/* }}} */
/* {{{ proto long PDO::exec(string query)
Execute a query that does not return a row set, returning the number of affected rows */
static PHP_METHOD(PDO, exec)
{
pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
char *statement;
int statement_len;
long ret;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &statement, &statement_len)) {
RETURN_FALSE;
}
if (!statement_len) {
RETURN_FALSE;
}
PDO_DBH_CLEAR_ERR();
ret = dbh->methods->doer(dbh, statement, statement_len TSRMLS_CC);
if(ret == -1) {
PDO_HANDLE_DBH_ERR();
RETURN_FALSE;
} else {
RETURN_LONG(ret);
}
}
/* }}} */
/* {{{ proto int PDO::lastInsertId()
Returns the number id of rows that we affected by the last call to PDO::exec(). Not always meaningful. */
static PHP_METHOD(PDO, lastInsertId)
{
pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
if (ZEND_NUM_ARGS()) {
RETURN_FALSE;
}
PDO_DBH_CLEAR_ERR();
if (!dbh->methods->last_id) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "This driver does not support last inserted id retrieval.");
} else {
RETURN_LONG(dbh->methods->last_id(dbh TSRMLS_CC));
}
}
/* }}} */
/* {{{ proto int PDO::errorCode()
Fetch the error code associated with the last operation on the database handle */
static PHP_METHOD(PDO, errorCode)
{
pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
if (ZEND_NUM_ARGS()) {
RETURN_FALSE;
}
RETURN_LONG(dbh->error_code);
}
/* }}} */
/* {{{ proto int PDO::errorInfo()
Fetch extended error information associated with the last operation on the database handle */
static PHP_METHOD(PDO, errorInfo)
{
pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
if (ZEND_NUM_ARGS()) {
RETURN_FALSE;
}
array_init(return_value);
add_next_index_long(return_value, dbh->error_code);
if (dbh->methods->fetch_err) {
dbh->methods->fetch_err(dbh, NULL, return_value TSRMLS_CC);
}
}
/* }}} */
function_entry pdo_dbh_functions[] = {
PHP_ME_MAPPING(__construct, dbh_constructor, NULL)
PHP_ME(PDO, prepare, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, beginTransaction,NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, commit, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, rollBack, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, setAttribute, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, exec, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, lastInsertId, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, errorCode, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, errorInfo, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, getAttribute, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
/* {{{ overloaded object handlers for PDO class */
static zval *dbh_prop_read(zval *object, zval *member, int type TSRMLS_DC)
{
zval *return_value;
MAKE_STD_ZVAL(return_value);
ZVAL_NULL(return_value);
return return_value;
}
static void dbh_prop_write(zval *object, zval *member, zval *value TSRMLS_DC)
{
return;
}
static zval *dbh_read_dim(zval *object, zval *offset, int type TSRMLS_DC)
{
zval *return_value;
MAKE_STD_ZVAL(return_value);
ZVAL_NULL(return_value);
return return_value;
}
static void dbh_write_dim(zval *object, zval *offset, zval *value TSRMLS_DC)
{
return;
}
static int dbh_prop_exists(zval *object, zval *member, int check_empty TSRMLS_DC)
{
return 0;
}
static int dbh_dim_exists(zval *object, zval *member, int check_empty TSRMLS_DC)
{
return 0;
}
static void dbh_prop_delete(zval *object, zval *offset TSRMLS_DC)
{
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot delete properties from a PDO DBH");
}
static void dbh_dim_delete(zval *object, zval *offset TSRMLS_DC)
{
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot delete dimensions from a PDO DBH");
}
static HashTable *dbh_get_properties(zval *object TSRMLS_DC)
{
return NULL;
}
static union _zend_function *dbh_method_get(zval *object, char *method_name, int method_len TSRMLS_DC)
{
zend_function *fbc;
char *lc_method_name;
lc_method_name = emalloc(method_len + 1);
zend_str_tolower_copy(lc_method_name, method_name, method_len);
if (zend_hash_find(&pdo_dbh_ce->function_table, lc_method_name, method_len+1, (void**)&fbc) == FAILURE) {
efree(lc_method_name);
return NULL;
}
efree(lc_method_name);
return fbc;
}
static int dbh_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS)
{
return FAILURE;
}
static union _zend_function *dbh_get_ctor(zval *object TSRMLS_DC)
{
pdo_dbh_t *dbh = zend_object_store_get_object(object TSRMLS_CC);
if(dbh->ce != pdo_dbh_ce) {
return dbh->ce->constructor;
} else {
static zend_internal_function ctor = {0};
ctor.type = ZEND_INTERNAL_FUNCTION;
ctor.function_name = "__construct";
ctor.scope = pdo_dbh_ce;
ctor.handler = ZEND_FN(dbh_constructor);
return (union _zend_function*)&ctor;
}
}
static zend_class_entry *dbh_get_ce(zval *object TSRMLS_DC)
{
return pdo_dbh_ce;
}
static int dbh_get_classname(zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC)
{
*class_name = estrndup("PDO", sizeof("PDO")-1);
*class_name_len = sizeof("PDO")-1;
return 0;
}
static int dbh_compare(zval *object1, zval *object2 TSRMLS_DC)
{
return -1;
}
static zend_object_handlers pdo_dbh_object_handlers = {
ZEND_OBJECTS_STORE_HANDLERS,
dbh_prop_read,
dbh_prop_write,
dbh_read_dim,
dbh_write_dim,
NULL,
NULL,
NULL,
dbh_prop_exists,
dbh_prop_delete,
dbh_dim_exists,
dbh_dim_delete,
dbh_get_properties,
dbh_method_get,
dbh_call_method,
dbh_get_ctor,
dbh_get_ce,
dbh_get_classname,
dbh_compare,
NULL, /* cast */
NULL
};
static void pdo_dbh_free_storage(zend_object *object TSRMLS_DC)
{
pdo_dbh_t *dbh = (pdo_dbh_t*)object;
if (!dbh) {
return;
}
if (dbh->is_persistent) {
/* XXX: don't really free it, just delete the rsrc id */
return;
}
dbh->methods->closer(dbh TSRMLS_CC);
if (dbh->data_source) {
pefree((char *)dbh->data_source, dbh->is_persistent);
}
if (dbh->username) {
pefree(dbh->username, dbh->is_persistent);
}
if (dbh->password) {
pefree(dbh->password, dbh->is_persistent);
}
pefree(dbh, dbh->is_persistent);
}
zend_object_value pdo_dbh_new(zend_class_entry *ce TSRMLS_DC)
{
zend_object_value retval;
pdo_dbh_t *dbh;
dbh = emalloc(sizeof(*dbh));
memset(dbh, 0, sizeof(*dbh));
dbh->ce = ce;
retval.handle = zend_objects_store_put(dbh, NULL, pdo_dbh_free_storage, NULL TSRMLS_CC);
retval.handlers = &pdo_dbh_object_handlers;
return retval;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
-317
View File
@@ -1,317 +0,0 @@
/* Generated by re2c 0.5 on Fri May 21 17:33:58 2004 */
#line 1 "/home/george/src/pecl/pdo/pdo_sql_parser.re"
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.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: George Schlossnagle <george@omniti.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#include "php.h"
#include "php_pdo_driver.h"
#define PDO_PARSER_TEXT 1
#define PDO_PARSER_BIND 2
#define PDO_PARSER_BIND_POS 3
#define PDO_PARSER_EOI 4
#define RET(i) {s->cur = cursor; return i; }
#define YYCTYPE char
#define YYCURSOR cursor
#define YYLIMIT s->lim
#define YYMARKER s->ptr
#define YYFILL(n)
typedef struct Scanner {
char *lim, *ptr, *cur, *tok;
} Scanner;
static int scan(Scanner *s)
{
char *cursor = s->cur;
std:
s->tok = cursor;
#line 54
{
YYCTYPE yych;
unsigned int yyaccept;
static unsigned char yybm[] = {
0, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 0, 168, 168, 168, 168, 192,
168, 168, 168, 168, 168, 168, 168, 168,
184, 184, 184, 184, 184, 184, 184, 184,
184, 184, 160, 168, 168, 168, 168, 160,
168, 184, 184, 184, 184, 184, 184, 184,
184, 184, 184, 184, 184, 184, 184, 184,
184, 184, 184, 184, 184, 184, 184, 184,
184, 184, 184, 168, 8, 168, 168, 184,
168, 184, 184, 184, 184, 184, 184, 184,
184, 184, 184, 184, 184, 184, 184, 184,
184, 184, 184, 184, 184, 184, 184, 184,
184, 184, 184, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168,
};
goto yy0;
yy1: ++YYCURSOR;
yy0:
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
if(yybm[0+yych] & 8) goto yy8;
if(yych <= '\000') goto yy11;
if(yych <= '&') goto yy2;
if(yych <= '\'') goto yy4;
if(yych <= '>') goto yy5;
goto yy6;
yy2: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych >= '\001') goto yy24;
yy3:
#line 61
{ RET(PDO_PARSER_TEXT); }
yy4: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych <= '\000') goto yy3;
if(yych == '"') goto yy3;
goto yy17;
yy5: yych = *++YYCURSOR;
if(yybm[0+yych] & 16) goto yy13;
goto yy3;
yy6: yych = *++YYCURSOR;
yy7:
#line 60
{ RET(PDO_PARSER_BIND_POS); }
yy8: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy9: if(yybm[0+yych] & 8) goto yy8;
yy10:
#line 62
{ RET(PDO_PARSER_TEXT); }
yy11: yych = *++YYCURSOR;
yy12:
#line 63
{ RET(PDO_PARSER_EOI); }
yy13: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy14: if(yybm[0+yych] & 16) goto yy13;
yy15:
#line 59
{ RET(PDO_PARSER_BIND); }
yy16: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy17: if(yybm[0+yych] & 32) goto yy16;
if(yych <= '&') goto yy18;
if(yych <= '\'') goto yy19;
goto yy22;
yy18: YYCURSOR = YYMARKER;
switch(yyaccept){
case 1: goto yy21;
case 0: goto yy3;
}
yy19: yyaccept = 1;
YYMARKER = ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy20: if(yybm[0+yych] & 32) goto yy16;
if(yych <= '&') goto yy21;
if(yych <= '\'') goto yy19;
goto yy22;
yy21:
#line 58
{ RET(PDO_PARSER_TEXT); }
yy22: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if(yych == '\'') goto yy16;
goto yy18;
yy23: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy24: if(yybm[0+yych] & 128) goto yy23;
if(yych <= '\000') goto yy18;
if(yych <= '[') goto yy26;
yy25: ++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if(yych == '"') goto yy23;
goto yy18;
yy26: yych = *++YYCURSOR;
yy27:
#line 57
{ RET(PDO_PARSER_TEXT); }
}
#line 64
}
int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **outquery,
int *outquery_len TSRMLS_DC)
{
Scanner s;
char *ptr;
int t;
int bindno = 0;
int newbuffer_len;
int padding;
HashTable *params = stmt->bound_params;
struct pdo_bound_param_data *param;
/* allocate buffer for query with expanded binds, ptr is our writing pointer */
newbuffer_len = inquery_len;
/* calculate the possible padding factor due to quoting */
if(stmt->dbh->max_escaped_char_length) {
padding = stmt->dbh->max_escaped_char_length;
} else {
padding = 3;
}
if(params) {
zend_hash_internal_pointer_reset(params);
while (SUCCESS == zend_hash_get_current_data(params, (void**)&param)) {
if(param->parameter) {
convert_to_string(param->parameter);
/* accomodate a string that needs to be fully quoted
bind placeholders are at least 2 characters, so
the accomodate their own "'s
*/
newbuffer_len += padding * Z_STRLEN_P(param->parameter);
}
zend_hash_move_forward(params);
}
}
*outquery = (char *) emalloc(newbuffer_len + 1);
*outquery_len = 0;
ptr = *outquery;
s.cur = inquery;
s.lim = inquery + inquery_len;
while((t = scan(&s)) != PDO_PARSER_EOI) {
if(t == PDO_PARSER_TEXT) {
memcpy(ptr, s.tok, s.cur - s.tok);
ptr += (s.cur - s.tok);
*outquery_len += (s.cur - s.tok);
}
else if(t == PDO_PARSER_BIND) {
if(!params) {
/* error */
efree(*outquery);
*outquery = NULL;
return (int) (s.cur - inquery);
}
/* lookup bind first via hash and then index */
/* stupid keys need to be null-terminated, even though we know their length */
if((SUCCESS == zend_hash_find(params, s.tok, s.cur-s.tok,(void **)&param))
||
(SUCCESS == zend_hash_index_find(params, bindno, (void **)&param)))
{
char *quotedstr;
int quotedstrlen;
/* restore the in-string key, doesn't need null-termination here */
/* currently everything is a string here */
/* quote the bind value if necessary */
if(stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter),
Z_STRLEN_P(param->parameter), &quotedstr, &quotedstrlen TSRMLS_CC))
{
memcpy(ptr, quotedstr, quotedstrlen);
ptr += quotedstrlen;
*outquery_len += quotedstrlen;
efree(quotedstr);
} else {
memcpy(ptr, Z_STRVAL_P(param->parameter), Z_STRLEN_P(param->parameter));
ptr += Z_STRLEN_P(param->parameter);
*outquery_len += (Z_STRLEN_P(param->parameter));
}
}
else {
/* error and cleanup */
efree(*outquery);
*outquery = NULL;
return (int) (s.cur - inquery);
}
bindno++;
}
else if(t == PDO_PARSER_BIND_POS) {
if(!params) {
/* error */
efree(*outquery);
*outquery = NULL;
return (int) (s.cur - inquery);
}
/* lookup bind by index */
if(SUCCESS == zend_hash_index_find(params, bindno, (void **)&param))
{
char *quotedstr;
int quotedstrlen;
/* currently everything is a string here */
/* quote the bind value if necessary */
if(stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter),
Z_STRLEN_P(param->parameter), &quotedstr, &quotedstrlen TSRMLS_CC))
{
memcpy(ptr, quotedstr, quotedstrlen);
ptr += quotedstrlen;
*outquery_len += quotedstrlen;
efree(quotedstr);
} else {
memcpy(ptr, Z_STRVAL_P(param->parameter), Z_STRLEN_P(param->parameter));
ptr += Z_STRLEN_P(param->parameter);
*outquery_len += (Z_STRLEN_P(param->parameter));
}
}
else {
/* error and cleanup */
efree(*outquery);
*outquery = NULL;
return (int) (s.cur - inquery);
}
bindno++;
}
}
*ptr = '\0';
return 0;
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker ft=c
* vim<600: noet sw=4 ts=4
*/
-201
View File
@@ -1,201 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.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: George Schlossnagle <george@omniti.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#include "php.h"
#include "php_pdo_driver.h"
#define PDO_PARSER_TEXT 1
#define PDO_PARSER_BIND 2
#define PDO_PARSER_BIND_POS 3
#define PDO_PARSER_EOI 4
#define RET(i) {s->cur = cursor; return i; }
#define YYCTYPE char
#define YYCURSOR cursor
#define YYLIMIT s->lim
#define YYMARKER s->ptr
#define YYFILL(n)
typedef struct Scanner {
char *lim, *ptr, *cur, *tok;
} Scanner;
static int scan(Scanner *s)
{
char *cursor = s->cur;
std:
s->tok = cursor;
/*!re2c
BINDCHR = [:][a-zA-Z0-9_]+;
QUESTION = [?];
SPECIALS = [:?"'];
ESCQQ = [\\]["];
ESCQ = [\\]['];
EOF = [\000];
ANYNOEOF = [\001-\377];
*/
/*!re2c
(["] (ESCQQ|ANYNOEOF\[\\"])* ["]) { RET(PDO_PARSER_TEXT); }
(['] (ESCQ|ANYNOEOF\[\\"])* [']) { RET(PDO_PARSER_TEXT); }
BINDCHR { RET(PDO_PARSER_BIND); }
QUESTION { RET(PDO_PARSER_BIND_POS); }
SPECIALS { RET(PDO_PARSER_TEXT); }
(ANYNOEOF\SPECIALS)+ { RET(PDO_PARSER_TEXT); }
EOF { RET(PDO_PARSER_EOI); }
*/
}
int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **outquery,
int *outquery_len TSRMLS_DC)
{
Scanner s;
char *ptr;
int t;
int bindno = 0;
int newbuffer_len;
int padding;
HashTable *params = stmt->bound_params;
struct pdo_bound_param_data *param;
/* allocate buffer for query with expanded binds, ptr is our writing pointer */
newbuffer_len = inquery_len;
/* calculate the possible padding factor due to quoting */
if(stmt->dbh->max_escaped_char_length) {
padding = stmt->dbh->max_escaped_char_length;
} else {
padding = 3;
}
if(params) {
zend_hash_internal_pointer_reset(params);
while (SUCCESS == zend_hash_get_current_data(params, (void**)&param)) {
if(param->parameter) {
convert_to_string(param->parameter);
/* accomodate a string that needs to be fully quoted
bind placeholders are at least 2 characters, so
the accomodate their own "'s
*/
newbuffer_len += padding * Z_STRLEN_P(param->parameter);
}
zend_hash_move_forward(params);
}
}
*outquery = (char *) emalloc(newbuffer_len + 1);
*outquery_len = 0;
ptr = *outquery;
s.cur = inquery;
s.lim = inquery + inquery_len;
while((t = scan(&s)) != PDO_PARSER_EOI) {
if(t == PDO_PARSER_TEXT) {
memcpy(ptr, s.tok, s.cur - s.tok);
ptr += (s.cur - s.tok);
*outquery_len += (s.cur - s.tok);
}
else if(t == PDO_PARSER_BIND) {
if(!params) {
/* error */
efree(*outquery);
*outquery = NULL;
return (int) (s.cur - inquery);
}
/* lookup bind first via hash and then index */
/* stupid keys need to be null-terminated, even though we know their length */
if((SUCCESS == zend_hash_find(params, s.tok, s.cur-s.tok,(void **)&param))
||
(SUCCESS == zend_hash_index_find(params, bindno, (void **)&param)))
{
char *quotedstr;
int quotedstrlen;
/* restore the in-string key, doesn't need null-termination here */
/* currently everything is a string here */
/* quote the bind value if necessary */
if(stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter),
Z_STRLEN_P(param->parameter), &quotedstr, &quotedstrlen TSRMLS_CC))
{
memcpy(ptr, quotedstr, quotedstrlen);
ptr += quotedstrlen;
*outquery_len += quotedstrlen;
efree(quotedstr);
} else {
memcpy(ptr, Z_STRVAL_P(param->parameter), Z_STRLEN_P(param->parameter));
ptr += Z_STRLEN_P(param->parameter);
*outquery_len += (Z_STRLEN_P(param->parameter));
}
}
else {
/* error and cleanup */
efree(*outquery);
*outquery = NULL;
return (int) (s.cur - inquery);
}
bindno++;
}
else if(t == PDO_PARSER_BIND_POS) {
if(!params) {
/* error */
efree(*outquery);
*outquery = NULL;
return (int) (s.cur - inquery);
}
/* lookup bind by index */
if(SUCCESS == zend_hash_index_find(params, bindno, (void **)&param))
{
char *quotedstr;
int quotedstrlen;
/* currently everything is a string here */
/* quote the bind value if necessary */
if(stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter),
Z_STRLEN_P(param->parameter), &quotedstr, &quotedstrlen TSRMLS_CC))
{
memcpy(ptr, quotedstr, quotedstrlen);
ptr += quotedstrlen;
*outquery_len += quotedstrlen;
efree(quotedstr);
} else {
memcpy(ptr, Z_STRVAL_P(param->parameter), Z_STRLEN_P(param->parameter));
ptr += Z_STRLEN_P(param->parameter);
*outquery_len += (Z_STRLEN_P(param->parameter));
}
}
else {
/* error and cleanup */
efree(*outquery);
*outquery = NULL;
return (int) (s.cur - inquery);
}
bindno++;
}
}
*ptr = '\0';
return 0;
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker ft=c
* vim<600: noet sw=4 ts=4
*/
-1111
View File
File diff suppressed because it is too large. Load diff
-69
View File
@@ -1,69 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.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@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef PHP_PDO_H
#define PHP_PDO_H
extern zend_module_entry pdo_module_entry;
#define phpext_pdo_ptr &pdo_module_entry
#ifdef PHP_WIN32
# ifdef PDO_EXPORTS
# define PDO_API __declspec(dllexport)
# elif defined(COMPILE_DL_PDO)
# define PDO_API __declspec(dllimport)
# else
# define PDO_API /* nothing special */
# endif
#else
# define PDO_API /* nothing special */
#endif
#ifdef ZTS
# include "TSRM.h"
#endif
PHP_MINIT_FUNCTION(pdo);
PHP_MSHUTDOWN_FUNCTION(pdo);
PHP_RINIT_FUNCTION(pdo);
PHP_RSHUTDOWN_FUNCTION(pdo);
PHP_MINFO_FUNCTION(pdo);
ZEND_BEGIN_MODULE_GLOBALS(pdo)
long global_value;
ZEND_END_MODULE_GLOBALS(pdo)
#ifdef ZTS
# define PDOG(v) TSRMG(pdo_globals_id, zend_pdo_globals *, v)
#else
# define PDOG(v) (pdo_globals.v)
#endif
#endif /* PHP_PDO_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
-415
View File
@@ -1,415 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.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@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef PHP_PDO_DRIVER_H
#define PHP_PDO_DRIVER_H
#include "php_pdo.h"
/* forward declarations */
typedef struct _pdo_dbh_t pdo_dbh_t;
typedef struct _pdo_stmt_t pdo_stmt_t;
struct pdo_bound_param_data;
#ifndef TRUE
# define TRUE 1
#endif
#ifndef FALSE
# define FALSE 0
#endif
#define PDO_DRIVER_API 20040513
enum pdo_param_type {
PDO_PARAM_NULL,
PDO_PARAM_INT,
PDO_PARAM_STR,
PDO_PARAM_LOB,
PDO_PARAM_STMT, /* hierarchical result set */
};
enum pdo_fetch_type {
PDO_FETCH_LAZY,
PDO_FETCH_ASSOC,
PDO_FETCH_NUM,
PDO_FETCH_BOTH,
PDO_FETCH_OBJ,
PDO_FETCH_BOUND, /* return true/false only; rely on bound columns */
};
enum pdo_attribute_type {
PDO_ATTR_AUTOCOMMIT, /* use to turn on or off auto-commit mode */
PDO_ATTR_SCROLL, /* ask for a scrollable cursor (when you prepare()) */
PDO_ATTR_PREFETCH, /* configure the prefetch size for drivers that support it */
PDO_ATTR_TIMEOUT, /* connection timeout in seconds */
PDO_ATTR_ERRMODE, /* control how errors are handled */
PDO_ATTR_SERVER_VERSION, /* database server version */
PDO_ATTR_CLIENT_VERSION, /* client library version */
PDO_ATTR_SERVER_INFO, /* server information */
PDO_ATTR_CONNECTION_STATUS, /* connection status */
PDO_ATTR_CASE, /* control case folding for portability */
PDO_ATTR_CURSOR_NAME, /* name a cursor for use in "WHERE CURRENT OF <name>" */
PDO_ATTR_CURSOR, /* cursor type */
/* this defines the start of the range for driver specific options.
* Drivers should define their own attribute constants beginning with this
* value. */
PDO_ATTR_DRIVER_SPECIFIC = 1000
};
enum pdo_cursor_type {
PDO_CURSOR_FWDONLY, /* forward only cursor (default) */
PDO_CURSOR_SCROLL, /* scrollable cursor */
};
/* generic error code values.
* Don't want to go overboard with these.
* */
enum pdo_error_type {
PDO_ERR_NONE, /* no error condition */
PDO_ERR_CANT_MAP, /* no way to map native error to the generic codes; consult the native error for more info */
PDO_ERR_SYNTAX,
PDO_ERR_CONSTRAINT,
PDO_ERR_NOT_FOUND,
PDO_ERR_ALREADY_EXISTS,
PDO_ERR_NOT_IMPLEMENTED,
PDO_ERR_MISMATCH,
PDO_ERR_TRUNCATED,
PDO_ERR_DISCONNECTED,
};
enum pdo_error_mode {
PDO_ERRMODE_SILENT, /* just set error codes */
PDO_ERRMODE_WARNING, /* raise E_WARNING */
PDO_ERRMODE_EXCEPTION, /* throw exceptions */
};
enum pdo_case_conversion {
PDO_CASE_NATURAL,
PDO_CASE_UPPER,
PDO_CASE_LOWER
};
/* {{{ utils for reading attributes set as driver_options */
static inline long pdo_attr_lval(zval *options, enum pdo_fetch_type option_name, long defval TSRMLS_DC)
{
zval **v;
if (options && SUCCESS == zend_hash_index_find(Z_ARRVAL_P(options), option_name, (void**)&v)) {
convert_to_long_ex(v);
return Z_LVAL_PP(v);
}
return defval;
}
/* }}} */
/* This structure is registered with PDO when a PDO driver extension is
* initialized */
typedef struct {
const char *driver_name;
unsigned long driver_name_len;
unsigned long api_version; /* needs to be compatible with PDO */
#define PDO_DRIVER_HEADER(name) \
#name, sizeof(#name)-1, \
PDO_DRIVER_API
/* create driver specific portion of the database handle and stash it into
* the dbh. dbh contains the data source string and flags for this
* instance */
int (*db_handle_factory)(pdo_dbh_t *dbh, zval *driver_options TSRMLS_DC);
} pdo_driver_t;
/* {{{ methods for a database handle */
/* close or otherwise disconnect the database */
typedef int (*pdo_dbh_close_func)(pdo_dbh_t *dbh TSRMLS_DC);
/* prepare a statement and stash driver specific portion into stmt */
typedef int (*pdo_dbh_prepare_func)(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, long options, zval *driver_options TSRMLS_DC);
/* execute a statement (that does not return a result set) */
typedef long (*pdo_dbh_do_func)(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC);
/* quote a string */
typedef int (*pdo_dbh_quote_func)(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen TSRMLS_DC);
/* transaction related */
typedef int (*pdo_dbh_txn_func)(pdo_dbh_t *dbh TSRMLS_DC);
/* setting of attributes */
typedef int (*pdo_dbh_set_attr_func)(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC);
/* return last insert id */
typedef long (*pdo_dbh_last_id_func)(pdo_dbh_t *dbh TSRMLS_DC);
/* fetch error information. if stmt is not null, fetch information pertaining
* to the statement, otherwise fetch global error information. The driver
* should add the following information to the array "info" in this order:
* - native error code
* - string representation of the error code ... any other optional driver
* specific data ... */
typedef int (*pdo_dbh_fetch_error_func)(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info TSRMLS_DC);
/* fetching of attributes */
typedef int (*pdo_dbh_get_attr_func)(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC);
struct pdo_dbh_methods {
pdo_dbh_close_func closer;
pdo_dbh_prepare_func preparer;
pdo_dbh_do_func doer;
pdo_dbh_quote_func quoter;
pdo_dbh_txn_func begin;
pdo_dbh_txn_func commit;
pdo_dbh_txn_func rollback;
pdo_dbh_set_attr_func set_attribute;
pdo_dbh_last_id_func last_id;
pdo_dbh_fetch_error_func fetch_err;
pdo_dbh_get_attr_func get_attribute;
};
/* }}} */
/* {{{ methods for a statement handle */
/* free the statement handle */
typedef int (*pdo_stmt_dtor_func)(pdo_stmt_t *stmt TSRMLS_DC);
/* start the query */
typedef int (*pdo_stmt_execute_func)(pdo_stmt_t *stmt TSRMLS_DC);
/* causes the next row in the set to be fetched; indicates if there are no
* more rows */
typedef int (*pdo_stmt_fetch_func)(pdo_stmt_t *stmt TSRMLS_DC);
/* queries information about the type of a column, by index (0 based).
* Driver should populate stmt->columns[colno] with appropriate info */
typedef int (*pdo_stmt_describe_col_func)(pdo_stmt_t *stmt, int colno TSRMLS_DC);
/* retrieves pointer and size of the value for a column */
typedef int (*pdo_stmt_get_col_data_func)(pdo_stmt_t *stmt, int colno, char **ptr, unsigned long *len TSRMLS_DC);
/* hook for bound params */
enum pdo_param_event {
PDO_PARAM_EVT_ALLOC,
PDO_PARAM_EVT_FREE,
PDO_PARAM_EVT_EXEC_PRE,
PDO_PARAM_EVT_EXEC_POST,
PDO_PARAM_EVT_FETCH_PRE,
PDO_PARAM_EVT_FETCH_POST,
};
typedef int (*pdo_stmt_param_hook_func)(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, enum pdo_param_event event_type TSRMLS_DC);
/* setting of attributes */
typedef int (*pdo_stmt_set_attr_func)(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC);
/* fetching of attributes */
typedef int (*pdo_stmt_get_attr_func)(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC);
struct pdo_stmt_methods {
pdo_stmt_dtor_func dtor;
pdo_stmt_execute_func executer;
pdo_stmt_fetch_func fetcher;
pdo_stmt_describe_col_func describer;
pdo_stmt_get_col_data_func get_col;
pdo_stmt_param_hook_func param_hook;
pdo_stmt_set_attr_func set_attribute;
pdo_stmt_get_attr_func get_attribute;
};
/* }}} */
enum pdo_placeholder_support {
PDO_PLACEHOLDER_NONE=0,
PDO_PLACEHOLDER_NAMED=1,
PDO_PLACEHOLDER_POSITIONAL=2
};
/* represents a connection to a database */
struct _pdo_dbh_t {
/* driver specific methods */
struct pdo_dbh_methods *methods;
/* driver specific data */
void *driver_data;
/* credentials */
char *username, *password;
/* if true, then data stored and pointed at by this handle must all be
* persistently allocated */
unsigned is_persistent:1;
/* if true, driver should act as though a COMMIT were executed between
* each executed statement; otherwise, COMMIT must be carried out manually
* */
unsigned auto_commit:1;
/* if true, the handle has been closed and will not function anymore */
unsigned is_closed:1;
/* if true, the driver requires that memory be allocated explicitly for
* the columns that are returned */
unsigned alloc_own_columns:1;
/* if true, the driver supports placeholders and can implement
* bindParam() for its prepared statements, if false, PDO should
* emulate prepare and bind on its behalf */
unsigned supports_placeholders:2;
/* if true, commit or rollBack is allowed to be called */
unsigned in_txn:1;
/* max length a single character can become after correct quoting */
unsigned max_escaped_char_length:3;
/* the sum of the number of bits here and the bit fields preceeding should
* equal 32 */
unsigned _reserved_flags:22;
/* data source string used to open this handle */
const char *data_source;
unsigned long data_source_len;
/* the global error code. */
enum pdo_error_type error_code;
enum pdo_error_mode error_mode;
enum pdo_case_conversion native_case, desired_case;
/* needed for inheritance to work */
zend_class_entry *ce;
#if 0
/* persistent hash key associated with this handle */
const char *persistent_id;
/* and the list id associated with it */
int persistent_rsrc_id;
#endif
};
/* describes a column */
struct pdo_column_data {
char *name;
long namelen;
unsigned long maxlen;
enum pdo_param_type param_type;
unsigned long precision;
};
/* describes a bound parameter */
struct pdo_bound_param_data {
long paramno; /* if -1, then it has a name, and we don't know the index *yet* */
char *name;
long namelen;
long max_value_len; /* as a hint for pre-allocation */
zval *parameter; /* the variable itself */
enum pdo_param_type param_type; /* desired or suggested type */
zval *driver_params; /* optional parameter(s) for the driver */
void *driver_data;
pdo_stmt_t *stmt; /* for convenience in dtor */
int is_param; /* parameter or column ? */
};
/* represents a prepared statement */
struct _pdo_stmt_t {
/* driver specifics */
struct pdo_stmt_methods *methods;
void *driver_data;
/* if true, we've already successfully executed this statement at least
* once */
unsigned executed:1;
unsigned _reserved:31;
/* the number of columns in the result set; not valid until after
* the statement has been executed at least once. In some cases, might
* not be valid until fetch (at the driver level) has been called at least once.
* */
int column_count;
struct pdo_column_data *columns;
/* we want to keep the dbh alive while we live, so we own a reference */
zval database_object_handle;
pdo_dbh_t *dbh;
/* keep track of bound input parameters. Some drivers support
* input/output parameters, but you can't rely on that working */
HashTable *bound_params;
/* keep track of PHP variables bound to named (or positional) columns
* in the result set */
HashTable *bound_columns;
/* not always meaningful */
long row_count;
/* used to hold the statement's current query */
char *query_string;
int query_stringlen;
/* the copy of the query with expanded binds ONLY for emulated-prepare drivers */
char *active_query_string;
int active_query_stringlen;
/* the cursor specific error code. */
enum pdo_error_type error_code;
/* for lazy fetches, we always return the same lazy object handle.
* Let's keep it here. */
zval lazy_object_ref;
unsigned long refcount;
};
/* call this in MINIT to register your PDO driver */
PDO_API int php_pdo_register_driver(pdo_driver_t *driver);
/* call this in MSHUTDOWN to unregister your PDO driver */
PDO_API void php_pdo_unregister_driver(pdo_driver_t *driver);
/* For the convenience of drivers, this function will parse a data source
* string, of the form "name=value; name2=value2" and populate variables
* according to the data you pass in and array of pdo_data_src_parser structures */
struct pdo_data_src_parser {
const char *optname;
char *optval;
int freeme;
};
PDO_API int php_pdo_parse_data_source(const char *data_source,
unsigned long data_source_len, struct pdo_data_src_parser *parsed,
int nparams);
PDO_API zend_class_entry *php_pdo_get_exception(void);
#endif /* PHP_PDO_DRIVER_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
-61
View File
@@ -1,61 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.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@php.net> |
| Marcus Boerger <helly@php.net> |
| Sterling Hughes <sterling@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
/* Stuff private to the PDO extension and not for consumption by PDO drivers
* */
extern zend_class_entry *pdo_exception_ce;
extern zend_object_value pdo_dbh_new(zend_class_entry *ce TSRMLS_DC);
extern function_entry pdo_dbh_functions[];
extern zend_class_entry *pdo_dbh_ce;
extern zend_object_value pdo_dbstmt_new(zend_class_entry *ce TSRMLS_DC);
extern function_entry pdo_dbstmt_functions[];
extern zend_class_entry *pdo_dbstmt_ce;
void pdo_dbstmt_free_storage(zend_object *object TSRMLS_DC);
extern zend_object_handlers pdo_dbstmt_object_handlers;
extern zend_object_value pdo_row_new(zend_class_entry *ce TSRMLS_DC);
extern function_entry pdo_row_functions[];
extern zend_class_entry *pdo_row_ce;
void pdo_row_free_storage(zend_object *object TSRMLS_DC);
extern zend_object_handlers pdo_row_object_handlers;
extern pdo_driver_t *pdo_find_driver(const char *name, int namelen);
extern void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC);
#define PDO_DBH_CLEAR_ERR() dbh->error_code = PDO_ERR_NONE
#define PDO_STMT_CLEAR_ERR() stmt->error_code = PDO_ERR_NONE
#define PDO_HANDLE_DBH_ERR() if (dbh->error_code) { pdo_handle_error(dbh, NULL TSRMLS_CC); }
#define PDO_HANDLE_STMT_ERR() if (stmt->error_code) { pdo_handle_error(stmt->dbh, stmt TSRMLS_CC); }
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
-27
View File
@@ -1,27 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.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: George Schlossnagle <george@omniti.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef PHP_PDO_MYSQL_SQL_PARSER_H
#define PHP_PDO_MYSQL_SQL_PARSER_H
#include "php.h"
int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **outquery,
int *outquery_len);
#endif
-2
View File
@@ -1,2 +0,0 @@
Firebird/InterBase driver for PDO
Ard Biesheuvel
View File
Whitespace-only changes.
-49
View File
@@ -1,49 +0,0 @@
dnl
dnl $Id$
dnl
PHP_ARG_WITH(pdo-firebird,for Firebird support for PDO,
[ --with-pdo-firebird[=DIR] Include Firebird support for PDO. DIR is the Firebird base
install directory, defaults to /opt/firebird])
if test "$PHP_PDO_FIREBIRD" != "no"; then
if test "$PHP_PDO_FIREBIRD" = "yes"; then
FIREBIRD_INCDIR=/opt/firebird/include
FIREBIRD_LIBDIR=/opt/firebird/lib
else
FIREBIRD_INCDIR=$PHP_PDO_FIREBIRD/include
FIREBIRD_LIBDIR=$PHP_PDO_FIREBIRD/lib
fi
PHP_CHECK_LIBRARY(gds, isc_detach_database,
[
FIREBIRD_LIBNAME=gds
], [
PHP_CHECK_LIBRARY(ib_util, isc_detach_database,
[
FIREBIRD_LIBNAME=ib_util
], [
AC_MSG_ERROR([libgds or libib_util not found! Check config.log for more information.])
], [
-L$FIREBIRD_LIBDIR
])
], [
-L$FIREBIRD_LIBDIR
])
if test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
pdo_inc_path=$prefix/include/php/ext
elif test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
pdo_inc_path=$abs_srcdir/ext
elif test -f ext/pdo/php_pdo_driver.h; then
pdo_inc_path=ext
else
AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
fi
PHP_ADD_LIBRARY_WITH_PATH($FIREBIRD_LIBNAME, $FIREBIRD_LIBDIR, PDO_FIREBIRD_SHARED_LIBADD)
PHP_ADD_INCLUDE($FIREBIRD_INCDIR)
AC_DEFINE(HAVE_PDO_FIREBIRD,1,[ ])
PHP_NEW_EXTENSION(pdo_firebird, pdo_firebird.c firebird_driver.c firebird_statement.c, $ext_shared,,-I$pdo_inc_path)
PHP_SUBST(PDO_FIREBIRD_SHARED_LIBADD)
fi
-18
View File
@@ -1,18 +0,0 @@
// $Id$
// vim:ft=javascript
ARG_WITH("pdo-firebird", "Firebird support for PDO", "no");
if (PHP_PDO_FIREBIRD != "no") {
if ((CHECK_LIB("fbclient_ms.lib", "pdo_firebird", PHP_PHP_BUILD + "\\interbase\\lib_ms;" + PHP_PDO_FIREBIRD)
|| CHECK_LIB("gds32_ms.lib", "pdo_firebird", PHP_PHP_BUILD + "\\interbase\\lib_ms;" + PHP_PDO_FIREBIRD)
) && CHECK_HEADER_ADD_INCLUDE("ibase.h", "CFLAGS_PDO_FIREBIRD", PHP_PHP_BUILD + "\\interbase\\include;" + PHP_PDO_FIREBIRD)) {
EXTENSION("pdo_firebird", "pdo_firebird.c firebird_driver.c firebird_statement.c");
ADD_FLAG('CFLAGS_PDO_FIREBIRD', "/I ..\\pecl");
} else {
WARNING("pdo_firebird not enabled; libraries and headers not found");
}
ADD_EXTENSION_DEP('pdo_firebird', 'pdo');
}
-659
View File
@@ -1,659 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.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: Ard Biesheuvel <abies@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define _GNU_SOURCE
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "pdo/php_pdo.h"
#include "pdo/php_pdo_driver.h"
#include "php_pdo_firebird.h"
#include "php_pdo_firebird_int.h"
static int firebird_alloc_prepare_stmt(pdo_dbh_t*, const char*, long, XSQLDA*, isc_stmt_handle*,
HashTable* TSRMLS_DC);
/* map driver specific error message to PDO error */
void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, long line TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = stmt ? ((pdo_firebird_stmt *)stmt->driver_data)->H
: (pdo_firebird_db_handle *)dbh->driver_data;
enum pdo_error_type *const error_code = stmt ? &stmt->error_code : &dbh->error_code;
switch (isc_sqlcode(H->isc_status)) {
case 0:
*error_code = PDO_ERR_NONE;
break;
default:
*error_code = PDO_ERR_CANT_MAP;
break;
case -104:
*error_code = PDO_ERR_SYNTAX;
break;
case -530:
case -803:
*error_code = PDO_ERR_CONSTRAINT;
break;
case -204:
case -205:
case -206:
case -829:
*error_code = PDO_ERR_NOT_FOUND;
break;
*error_code = PDO_ERR_ALREADY_EXISTS;
break;
*error_code = PDO_ERR_NOT_IMPLEMENTED;
break;
case -313:
case -804:
*error_code = PDO_ERR_MISMATCH;
break;
case -303:
case -314:
case -413:
*error_code = PDO_ERR_TRUNCATED;
break;
*error_code = PDO_ERR_DISCONNECTED;
break;
}
}
/* }}} */
#define RECORD_ERROR(dbh) _firebird_error(dbh, NULL, __FILE__, __LINE__ TSRMLS_CC)
/* called by PDO to close a db handle */
static int firebird_handle_closer(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
if (dbh->in_txn) {
if (dbh->auto_commit) {
if (isc_commit_transaction(H->isc_status, &H->tr)) {
RECORD_ERROR(dbh);
}
} else {
if (isc_rollback_transaction(H->isc_status, &H->tr)) {
RECORD_ERROR(dbh);
}
}
}
if (isc_detach_database(H->isc_status, &H->db)) {
RECORD_ERROR(dbh);
}
pefree(H, dbh->is_persistent);
return 0;
}
/* }}} */
/* called by PDO to prepare an SQL query */
static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, /* {{{ */
pdo_stmt_t *stmt, long options, zval *driver_options TSRMLS_DC)
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
pdo_firebird_stmt *S = NULL;
HashTable *np;
do {
isc_stmt_handle s = NULL;
XSQLDA num_sqlda;
static char const info[] = { isc_info_sql_stmt_type };
char result[8];
num_sqlda.version = PDO_FB_SQLDA_VERSION;
num_sqlda.sqln = 1;
ALLOC_HASHTABLE(np);
zend_hash_init(np, 8, NULL, NULL, 0);
/* allocate and prepare statement */
if (!firebird_alloc_prepare_stmt(dbh, sql, sql_len, &num_sqlda, &s, np TSRMLS_CC)) {
break;
}
/* allocate a statement handle struct of the right size (struct out_sqlda is inlined) */
S = ecalloc(1, sizeof(*S)-sizeof(XSQLDA) + XSQLDA_LENGTH(num_sqlda.sqld));
S->H = H;
S->stmt = s;
S->fetch_buf = ecalloc(1,sizeof(char*) * num_sqlda.sqld);
S->out_sqlda.version = PDO_FB_SQLDA_VERSION;
S->out_sqlda.sqln = stmt->column_count = num_sqlda.sqld;
S->named_params = np;
/* determine the statement type */
if (isc_dsql_sql_info(H->isc_status, &s, sizeof(info), const_cast(info), sizeof(result),
result)) {
break;
}
S->statement_type = result[3];
/* fill the output sqlda with information about the prepared query */
if (isc_dsql_describe(H->isc_status, &s, PDO_FB_SQLDA_VERSION, &S->out_sqlda)) {
RECORD_ERROR(dbh);
break;
}
/* allocate the input descriptors */
if (isc_dsql_describe_bind(H->isc_status, &s, PDO_FB_SQLDA_VERSION, &num_sqlda)) {
break;
}
if (num_sqlda.sqld) {
S->in_sqlda = ecalloc(1,XSQLDA_LENGTH(num_sqlda.sqld));
S->in_sqlda->version = PDO_FB_SQLDA_VERSION;
S->in_sqlda->sqln = num_sqlda.sqld;
if (isc_dsql_describe_bind(H->isc_status, &s, PDO_FB_SQLDA_VERSION, S->in_sqlda)) {
break;
}
}
stmt->driver_data = S;
stmt->methods = &firebird_stmt_methods;
return 1;
} while (0);
RECORD_ERROR(dbh);
zend_hash_destroy(np);
FREE_HASHTABLE(np);
if (S) {
if (S->in_sqlda) {
efree(S->in_sqlda);
}
efree(S);
}
return 0;
}
/* }}} */
/* called by PDO to execute a statement that doesn't produce a result set */
static long firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
isc_stmt_handle stmt = NULL;
static char const info_count[] = { isc_info_sql_records };
char result[64];
int ret = 0;
XSQLDA in_sqlda, out_sqlda;
/* TODO no placeholders in exec() for now */
in_sqlda.version = out_sqlda.version = PDO_FB_SQLDA_VERSION;
in_sqlda.sqld = out_sqlda.sqld = 0;
/* allocate and prepare statement */
if (!firebird_alloc_prepare_stmt(dbh, sql, sql_len, &out_sqlda, &stmt, 0 TSRMLS_CC)) {
return -1;
}
/* execute the statement */
if (isc_dsql_execute2(H->isc_status, &H->tr, &stmt, PDO_FB_SQLDA_VERSION, &in_sqlda, &out_sqlda)) {
RECORD_ERROR(dbh);
return -1;
}
/* find out how many rows were affected */
if (isc_dsql_sql_info(H->isc_status, &stmt, sizeof(info_count), const_cast(info_count),
sizeof(result), result)) {
RECORD_ERROR(dbh);
return -1;
}
if (result[0] == isc_info_sql_records) {
unsigned i = 3, result_size = isc_vax_integer(&result[1],2);
while (result[i] != isc_info_end && i < result_size) {
short len = (short)isc_vax_integer(&result[i+1],2);
if (result[i] != isc_info_req_select_count) {
ret += isc_vax_integer(&result[i+3],len);
}
i += len+3;
}
}
/* commit if we're in auto_commit mode */
if (dbh->auto_commit && isc_commit_retaining(H->isc_status, &H->tr)) {
RECORD_ERROR(dbh);
}
return ret;
}
/* }}} */
/* called by the PDO SQL parser to add quotes to values that are copied into SQL */
static int firebird_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, /* {{{ */
char **quoted, int *quotedlen TSRMLS_DC)
{
int qcount = 0;
char const *c;
/* Firebird only requires single quotes to be doubled if string lengths are used */
/* count the number of ' characters */
for (c = unquoted; (c = strchr(c,'\'')); qcount++, c++);
if (!qcount) {
return 0;
} else {
char const *l, *r;
char *c;
*quotedlen = unquotedlen + qcount;
*quoted = c = emalloc(*quotedlen+1);
/* foreach (chunk that ends in a quote) */
for (l = unquoted; (r = strchr(l,'\'')); l = r+1) {
/* copy the chunk */
strncpy(c, l, r-l);
c += (r-l);
/* add the second quote */
*c++ = '\'';
}
/* copy the remainder */
strncpy(c, l, *quotedlen-(c-*quoted));
return 1;
}
}
/* }}} */
/* called by PDO to start a transaction */
static int firebird_handle_begin(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
char tpb[8] = { isc_tpb_version3 }, *ptpb = tpb+1;
#if abies_0
if (dbh->transaction_flags & PDO_TRANS_ISOLATION_LEVEL) {
if (dbh->transaction_flags & PDO_TRANS_READ_UNCOMMITTED) {
/* this is a poor fit, but it's all we have */
*ptpb++ = isc_tpb_read_committed;
*ptpb++ = isc_tpb_rec_version;
dbh->transaction_flags &= ~(PDO_TRANS_ISOLATION_LEVEL^PDO_TRANS_READ_UNCOMMITTED);
} else if (dbh->transaction_flags & PDO_TRANS_READ_COMMITTED) {
*ptpb++ = isc_tpb_read_committed;
*ptpb++ = isc_tpb_no_rec_version;
dbh->transaction_flags &= ~(PDO_TRANS_ISOLATION_LEVEL^PDO_TRANS_READ_COMMITTED);
} else if (dbh->transaction_flags & PDO_TRANS_REPEATABLE_READ) {
*ptpb++ = isc_tpb_concurrency;
dbh->transaction_flags &= ~(PDO_TRANS_ISOLATION_LEVEL^PDO_TRANS_REPEATABLE_READ);
} else {
*ptpb++ = isc_tpb_consistency;
dbh->transaction_flags &= ~(PDO_TRANS_ISOLATION_LEVEL^PDO_TRANS_SERIALIZABLE);
}
}
if (dbh->transaction_flags & PDO_TRANS_ACCESS_MODE) {
if (dbh->transaction_flags & PDO_TRANS_READONLY) {
*ptpb++ = isc_tpb_read;
dbh->transaction_flags &= ~(PDO_TRANS_ACCESS_MODE^PDO_TRANS_READONLY);
} else {
*ptpb++ = isc_tpb_write;
dbh->transaction_flags &= ~(PDO_TRANS_ACCESS_MODE^PDO_TRANS_READWRITE);
}
}
if (dbh->transaction_flags & PDO_TRANS_CONFLICT_RESOLUTION) {
if (dbh->transaction_flags & PDO_TRANS_RETRY) {
*ptpb++ = isc_tpb_wait;
dbh->transaction_flags &= ~(PDO_TRANS_CONFLICT_RESOLUTION^PDO_TRANS_RETRY);
} else {
*ptpb++ = isc_tpb_nowait;
dbh->transaction_flags &= ~(PDO_TRANS_CONFLICT_RESOLUTION^PDO_TRANS_ABORT);
}
}
#endif
if (isc_start_transaction(H->isc_status, &H->tr, 1, &H->db, (unsigned short)(ptpb-tpb), tpb)) {
RECORD_ERROR(dbh);
return 0;
}
return 1;
}
/* }}} */
/* called by PDO to commit a transaction */
static int firebird_handle_commit(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
if (isc_commit_transaction(H->isc_status, &H->tr)) {
RECORD_ERROR(dbh);
return 0;
}
return 1;
}
/* }}} */
/* called by PDO to rollback a transaction */
static int firebird_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
if (isc_rollback_transaction(H->isc_status, &H->tr)) {
RECORD_ERROR(dbh);
return 0;
}
return 1;
}
/* }}} */
/* used by prepare and exec to allocate a statement handle and prepare the SQL */
static int firebird_alloc_prepare_stmt(pdo_dbh_t *dbh, const char *sql, long sql_len, /* {{{ */
XSQLDA *out_sqlda, isc_stmt_handle *s, HashTable *named_params TSRMLS_DC)
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
char *c, *new_sql, in_quote, in_param, pname[64], *ppname;
long l, pindex = -1;
/* Firebird allows SQL statements up to 64k, so bail if it doesn't fit */
if (sql_len > SHORT_MAX) {
dbh->error_code = PDO_ERR_TRUNCATED;
return 0;
}
/* start a new transaction implicitly if auto_commit is enabled and no transaction is open */
if (dbh->auto_commit && !dbh->in_txn) {
/* dbh->transaction_flags = PDO_TRANS_READ_UNCOMMITTED; */
if (!firebird_handle_begin(dbh TSRMLS_CC)) {
return 0;
}
dbh->in_txn = 1;
}
/* allocate the statement */
if (isc_dsql_allocate_statement(H->isc_status, &H->db, s)) {
RECORD_ERROR(dbh);
return 0;
}
/* in order to support named params, which Firebird itself doesn't,
we need to replace :foo by ?, and store the name we just replaced */
new_sql = c = emalloc(sql_len+1);
for (l = in_quote = in_param = 0; l <= sql_len; ++l) {
if ( !(in_quote ^= (sql[l] == '\''))) {
if (!in_param) {
switch (sql[l]) {
case ':':
in_param = 1;
ppname = pname;
case '?':
*c++ = '?';
++pindex;
continue;
}
} else {
if ((in_param &= (sql[l] == '_') || (sql[l] >= 'A' && sql[l] <= 'Z')
|| (sql[l] >= 'a' && sql[l] <= 'z') || (sql[l] >= '0' && sql[l] <= '9'))) {
*ppname++ = sql[l];
continue;
} else {
*ppname++ = 0;
if (named_params) {
zend_hash_update(named_params, pname, (unsigned int)(ppname-pname),
(void*)&pindex, sizeof(long)+1,NULL);
}
}
}
}
*c++ = sql[l];
}
/* prepare the statement */
if (isc_dsql_prepare(H->isc_status, &H->tr, s, 0, new_sql, PDO_FB_DIALECT, out_sqlda)) {
RECORD_ERROR(dbh);
efree(new_sql);
return 0;
}
efree(new_sql);
return 1;
}
/* }}} */
/* called by PDO to set a driver-specific dbh attribute */
static int firebird_handle_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
switch (attr) {
case PDO_ATTR_AUTOCOMMIT:
convert_to_boolean(val);
/* ignore if the new value equals the old one */
if (dbh->auto_commit ^ Z_BVAL_P(val)) {
if (dbh->in_txn) {
if (Z_BVAL_P(val)) {
/* turning on auto_commit with an open transaction is illegal, because
we won't know what to do with it */
H->last_app_error = "Cannot enable auto-commit while a transaction is already open";
return 0;
} else {
/* close the transaction */
if (!firebird_handle_commit(dbh TSRMLS_CC)) {
break;
}
dbh->in_txn = 0;
}
}
dbh->auto_commit = Z_BVAL_P(val);
}
return 1;
}
return 0;
}
/* }}} */
/* callback to used to report database server info */
static void firebird_info_cb(void *arg, char const *s) /* {{{ */
{
if (arg) {
if (*(char*)arg) { /* second call */
strcat(arg, " ");
}
strcat(arg, s);
}
}
/* }}} */
/* called by PDO to get a driver-specific dbh attribute */
static int firebird_handle_get_attribute(pdo_dbh_t const *dbh, long attr, zval *val TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
switch (attr) {
char tmp[200];
case PDO_ATTR_AUTOCOMMIT:
ZVAL_LONG(val,dbh->auto_commit);
return 1;
case PDO_ATTR_CONNECTION_STATUS:
ZVAL_BOOL(val, !isc_version(&H->db, firebird_info_cb, NULL));
return 1;
case PDO_ATTR_CLIENT_VERSION: {
#if defined(__GNUC__) || defined(PHP_WIN32)
info_func_t info_func = NULL;
#ifdef __GNUC__
info_func = (info_func_t)dlsym(RTLD_DEFAULT, "isc_get_client_version");
#else
HMODULE l = GetModuleHandle("fbclient");
if (!l && !(l = GetModuleHandle("gds32"))) {
break;
}
info_func = (info_func_t)GetProcAddress(l, "isc_get_client_version");
#endif
if (info_func) {
info_func(tmp);
ZVAL_STRING(val,tmp,1);
} else {
ZVAL_STRING(val,"Firebird 1.0/Interbase 6",1);
}
#else
ZVAL_NULL(val);
#endif
}
return 1;
case PDO_ATTR_SERVER_VERSION:
case PDO_ATTR_SERVER_INFO:
*tmp = 0;
if (!isc_version(&H->db, firebird_info_cb, (void*)tmp)) {
ZVAL_STRING(val,tmp,1);
return 1;
}
}
return 0;
}
/* }}} */
/* called by PDO to retrieve driver-specific information about an error that has occurred */
static int pdo_firebird_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info TSRMLS_DC) /* {{{ */
{
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
ISC_STATUS *s = H->isc_status;
char buf[400];
long i = 0, l, sqlcode = isc_sqlcode(s);
if (sqlcode) {
add_next_index_long(info, sqlcode);
while ((l = isc_interprete(&buf[i],&s))) {
i += l;
strcpy(&buf[i++], " ");
}
add_next_index_string(info, buf, 1);
} else {
add_next_index_long(info, -999);
add_next_index_string(info, const_cast(H->last_app_error),1);
}
return 1;
}
/* }}} */
static struct pdo_dbh_methods firebird_methods = { /* {{{ */
firebird_handle_closer,
firebird_handle_preparer,
firebird_handle_doer,
firebird_handle_quoter,
firebird_handle_begin,
firebird_handle_commit,
firebird_handle_rollback,
firebird_handle_set_attribute,
NULL, /* last_id not supported */
pdo_firebird_fetch_error_func,
firebird_handle_get_attribute,
};
/* }}} */
/* the driver-specific PDO handle constructor */
static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_DC) /* {{{ */
{
struct pdo_data_src_parser vars[] = {
{ "dbname", NULL, 0 },
{ "charset", NULL, 0 },
{ "role", NULL, 0 }
};
int i, ret = 0;
pdo_firebird_db_handle *H = dbh->driver_data = pecalloc(1,sizeof(*H),dbh->is_persistent);
php_pdo_parse_data_source(dbh->data_source, dbh->data_source_len, vars, 2);
do {
static char const dpb_flags[] = {
isc_dpb_user_name, isc_dpb_password, isc_dpb_lc_ctype, isc_dpb_sql_role_name };
char const *dpb_values[] = { dbh->username, dbh->password, vars[1].optval, vars[2].optval };
char dpb_buffer[256] = { isc_dpb_version1 }, *dpb;
dpb = dpb_buffer + 1;
/* loop through all the provided arguments and set dpb fields accordingly */
for (i = 0; i < sizeof(dpb_flags); ++i) {
if (dpb_values[i]) {
dpb += sprintf(dpb, "%c%c%s", dpb_flags[i], (unsigned char)strlen(dpb_values[i]),
dpb_values[i]);
}
}
/* fire it up baby! */
if (isc_attach_database(H->isc_status, 0, vars[0].optval, &H->db,(short)(dpb-dpb_buffer),
dpb_buffer)) {
break;
}
dbh->methods = &firebird_methods;
dbh->supports_placeholders = PDO_PLACEHOLDER_POSITIONAL;
dbh->native_case = PDO_CASE_UPPER;
dbh->alloc_own_columns = 1;
ret = 1;
} while (0);
for (i = 0; i < sizeof(vars)/sizeof(vars[0]); ++i) {
if (vars[i].freeme) {
efree(vars[i].optval);
}
}
if (!ret) {
firebird_handle_closer(dbh TSRMLS_CC);
}
return ret;
}
/* }}} */
pdo_driver_t pdo_firebird_driver = { /* {{{ */
PDO_DRIVER_HEADER(firebird),
pdo_firebird_handle_factory
};
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
-696
View File
@@ -1,696 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.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: Ard Biesheuvel <abies@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "pdo/php_pdo.h"
#include "pdo/php_pdo_driver.h"
#include "php_pdo_firebird.h"
#include "php_pdo_firebird_int.h"
#include <time.h>
#define RECORD_ERROR(stmt) _firebird_error(NULL, stmt, __FILE__, __LINE__ TSRMLS_CC)
/* free the allocated space for passing field values to the db and back */
static void free_sqlda(XSQLDA const *sqlda) /* {{{ */
{
int i;
for (i = 0; i < sqlda->sqld; ++i) {
XSQLVAR const *var = &sqlda->sqlvar[i];
if (var->sqlind) {
efree(var->sqlind);
}
}
}
/* }}} */
/* called by PDO to clean up a statement handle */
static int firebird_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
int result = 1, i;
/* release the statement */
if (isc_dsql_free_statement(S->H->isc_status, &S->stmt, DSQL_drop)) {
RECORD_ERROR(stmt);
result = 0;
}
/* clean up the fetch buffers if they have been used */
for (i = 0; i < S->out_sqlda.sqld; ++i) {
if (S->fetch_buf[i]) {
efree(S->fetch_buf[i]);
}
}
efree(S->fetch_buf);
zend_hash_destroy(S->named_params);
FREE_HASHTABLE(S->named_params);
/* clean up the input descriptor */
if (S->in_sqlda) {
free_sqlda(S->in_sqlda);
efree(S->in_sqlda);
}
free_sqlda(&S->out_sqlda);
efree(S);
return result;
}
/* }}} */
/* called by PDO to execute a prepared query */
static int firebird_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
pdo_firebird_db_handle *H = S->H;
do {
/* named cursors should be closed first */
if (*S->name && isc_dsql_free_statement(H->isc_status, &S->stmt, DSQL_close)) {
break;
}
/* assume all params have been bound */
if ((S->statement_type == isc_info_sql_stmt_exec_procedure &&
isc_dsql_execute2(H->isc_status, &H->tr, &S->stmt, PDO_FB_SQLDA_VERSION,
S->in_sqlda, &S->out_sqlda))
|| isc_dsql_execute(H->isc_status, &H->tr, &S->stmt, PDO_FB_SQLDA_VERSION,
S->in_sqlda)) {
break;
}
/* commit? */
if (stmt->dbh->auto_commit && isc_commit_retaining(H->isc_status, &H->tr)) {
break;
}
*S->name = 0;
S->exhausted = 0;
return 1;
} while (0);
RECORD_ERROR(stmt);
return 0;
}
/* }}} */
/* called by PDO to fetch the next row from a statement */
static int firebird_stmt_fetch(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
pdo_firebird_db_handle *H = S->H;
if (!stmt->executed) {
stmt->error_code = PDO_ERR_CANT_MAP;
H->last_app_error = "Cannot fetch from a closed cursor";
} else if (!S->exhausted) {
/* an EXECUTE PROCEDURE statement can be fetched from once, without calling the API, because
* the result was returned in the execute call */
if (S->statement_type == isc_info_sql_stmt_exec_procedure) {
S->exhausted = 1;
} else {
if (isc_dsql_fetch(H->isc_status, &S->stmt, PDO_FB_SQLDA_VERSION, &S->out_sqlda)) {
if (H->isc_status[0] && H->isc_status[1]) {
RECORD_ERROR(stmt);
}
S->exhausted = 1;
return 0;
}
}
return 1;
}
return 0;
}
/* }}} */
/* called by PDO to retrieve information about the fields being returned */
static int firebird_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) /* {{{ */
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
struct pdo_column_data *col = &stmt->columns[colno];
XSQLVAR *var = &S->out_sqlda.sqlvar[colno];
/* allocate storage for the column */
var->sqlind = (void*)emalloc(var->sqllen + 2*sizeof(short));
var->sqldata = &((char*)var->sqlind)[sizeof(short)];
col->precision = -var->sqlscale;
col->maxlen = var->sqllen;
col->namelen = var->aliasname_length;
col->name = estrndup(var->aliasname,var->aliasname_length);
return 1;
}
/* }}} */
#if abies_0
/* internal function to override return types of parameters */
static void set_param_type(enum pdo_param_type *param_type, XSQLVAR const *var) /* {{{ */
{
/* set the param type after the field type */
switch (var->sqltype & ~1) {
case SQL_INT64:
#if SIZEOF_LONG < 8
if (0) /* always a string if its size exceeds native long */
#endif
case SQL_SHORT:
case SQL_LONG:
if (var->sqlscale == 0) {
*param_type = PDO_PARAM_INT;
break;
}
case SQL_TEXT:
case SQL_VARYING:
case SQL_TYPE_DATE:
case SQL_TYPE_TIME:
case SQL_TIMESTAMP:
case SQL_BLOB:
*param_type = PDO_PARAM_STR;
break;
case SQL_FLOAT:
case SQL_DOUBLE:
*param_type = PDO_PARAM_DBL;
break;
}
}
/* }}} */
#endif
#define FETCH_BUF(buf,type,len,lenvar) ((buf) = (buf) ? (buf) : \
emalloc((len) ? (len * sizeof(type)) : ((*(unsigned long*)lenvar) = sizeof(type))))
/* fetch a blob into a fetch buffer */
static int firebird_fetch_blob(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ */
unsigned long *len, ISC_QUAD *blob_id TSRMLS_DC)
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
pdo_firebird_db_handle *H = S->H;
isc_blob_handle blobh = NULL;
char const bl_item = isc_info_blob_total_length;
char bl_info[20];
unsigned short i;
int result = *len = 0;
if (isc_open_blob(H->isc_status, &H->db, &H->tr, &blobh, blob_id)) {
RECORD_ERROR(stmt);
return 0;
}
if (isc_blob_info(H->isc_status, &blobh, 1, const_cast(&bl_item),
sizeof(bl_info), bl_info)) {
RECORD_ERROR(stmt);
goto fetch_blob_end;
}
/* find total length of blob's data */
for (i = 0; i < sizeof(bl_info); ) {
unsigned short item_len;
char item = bl_info[i++];
if (item == isc_info_end || item == isc_info_truncated || item == isc_info_error
|| i >= sizeof(bl_info)) {
H->last_app_error = "Couldn't determine BLOB size";
goto fetch_blob_end;
}
item_len = (unsigned short) isc_vax_integer(&bl_info[i], 2);
if (item == isc_info_blob_total_length) {
*len = isc_vax_integer(&bl_info[i+2], item_len);
break;
}
i += item_len+2;
}
/* we've found the blob's length, now fetch! */
if (*len) {
unsigned long cur_len;
unsigned short seg_len;
ISC_STATUS stat;
*ptr = S->fetch_buf[colno] = erealloc(*ptr, *len+1);
for (cur_len = stat = 0; (!stat || stat == isc_segment) && cur_len < *len; cur_len += seg_len) {
unsigned short chunk_size = (*len-cur_len) > USHRT_MAX ? USHRT_MAX
: (unsigned short)(*len-cur_len);
stat = isc_get_segment(H->isc_status, &blobh, &seg_len, chunk_size, &(*ptr)[cur_len]);
}
(*ptr)[*len++] = '\0';
if (H->isc_status[0] == 1 && (stat != 0 && stat != isc_segstr_eof && stat != isc_segment)) {
H->last_app_error = "Error reading from BLOB";
goto fetch_blob_end;
}
}
result = 1;
fetch_blob_end:
if (isc_close_blob(H->isc_status, &blobh)) {
RECORD_ERROR(stmt);
return 0;
}
return result;
}
/* }}} */
static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ */
unsigned long *len TSRMLS_DC)
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
XSQLVAR const *var = &S->out_sqlda.sqlvar[colno];
if (*var->sqlind == -1) {
/* A NULL value */
*ptr = NULL;
*len = 0;
} else {
/* override the column param type */
/* set_param_type(&stmt->columns[colno].param_type,var); */
stmt->columns[colno].param_type = PDO_PARAM_STR;
if (var->sqlscale < 0) {
static ISC_INT64 const scales[] = { 1, 10, 100, 1000, 10000, 100000, 1000000,
100000000, 1000000000, 1000000000, LL_LIT(10000000000),LL_LIT(100000000000),
LL_LIT(10000000000000), LL_LIT(100000000000000),LL_LIT(1000000000000000),
LL_LIT(1000000000000000),LL_LIT(1000000000000000000) };
ISC_INT64 n, f = scales[-var->sqlscale];
switch (var->sqltype & ~1) {
case SQL_SHORT:
n = *(short*)var->sqldata;
break;
case SQL_LONG:
n = *(ISC_LONG*)var->sqldata;
break;
case SQL_INT64:
n = *(ISC_INT64*)var->sqldata;
}
*ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL);
if (n >= 0) {
*len = sprintf(*ptr, "%" LL_MASK "d.%0*" LL_MASK "d",
n / f, -var->sqlscale, n % f);
} else if (n < -f) {
*len = sprintf(*ptr, "%" LL_MASK "d.%0*" LL_MASK "d",
n / f, -var->sqlscale, -n % f);
} else {
*len = sprintf(*ptr, "-0.%0*" LL_MASK "d", -var->sqlscale, -n % f);
}
} else {
switch (var->sqltype & ~1) {
struct tm t;
char *fmt;
/**
* For the time being, this code has been changed to convert every returned value to a string
* before passing it back up to the PDO driver.
*/
case SQL_VARYING:
*ptr = &var->sqldata[2];
*len = *(short*)var->sqldata;
break;
case SQL_TEXT:
*ptr = var->sqldata;
*len = var->sqllen;
break;
// --- cut here ---
case SQL_SHORT:
*ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL);
*len = sprintf(*ptr, "%d", *(short*)var->sqldata);
break;
case SQL_LONG:
*ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL);
*len = sprintf(*ptr, "%ld", *(ISC_LONG*)var->sqldata);
break;
case SQL_INT64:
*ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL);
*len = sprintf(*ptr, "%" LL_MASK "d", *(ISC_INT64*)var->sqldata);
break;
case SQL_FLOAT:
*ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL);
*len = sprintf(*ptr, "%f", *(float*)var->sqldata);
break;
case SQL_DOUBLE:
*ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL);
*len = sprintf(*ptr, "%f" , *(double*)var->sqldata);
break;
// --- cut here ---
#if abies_0
case SQL_SHORT:
*ptr = FETCH_BUF(S->fetch_buf[colno], long, 0, *len);
*(long*)*ptr = *(short*)var->sqldata;
break;
case SQL_LONG:
#if SIZEOF_LONG == 8
*ptr = FETCH_BUF(S->fetch_buf[colno], long, 0, *len);
*(long*)*ptr = *(ISC_LONG*)var->sqldata;
#else
*ptr = var->sqldata;
#endif
break;
case SQL_INT64:
*len = sizeof(long);
#if SIZEOF_LONG == 8
*ptr = var->sqldata;
#else
*ptr = FETCH_BUF(S->fetch_buf[colno], char, 20, NULL);
*len = sprintf(*ptr, "%" LL_MASK "d", *(ISC_INT64*)var->sqldata);
#endif
break;
case SQL_FLOAT:
*ptr = FETCH_BUF(S->fetch_buf[colno], double, 0, *len);
*(double*)*ptr = *(float*)var->sqldata;
break;
case SQL_DOUBLE:
*ptr = var->sqldata;
*len = sizeof(double);
break;
#endif
case SQL_TYPE_DATE:
isc_decode_sql_date((ISC_DATE*)var->sqldata, &t);
fmt = INI_STR("ibase.dateformat");
if (0) {
case SQL_TYPE_TIME:
isc_decode_sql_time((ISC_TIME*)var->sqldata, &t);
fmt = INI_STR("ibase.timeformat");
} else if (0) {
case SQL_TIMESTAMP:
isc_decode_timestamp((ISC_TIMESTAMP*)var->sqldata, &t);
fmt = INI_STR("ibase.timestampformat");
}
/* convert the timestamp into a string */
*ptr = FETCH_BUF(S->fetch_buf[colno], char, *len = 80, NULL);
*len = strftime(*ptr, *len, fmt, &t);
break;
case SQL_BLOB:
return firebird_fetch_blob(stmt,colno,ptr,len,
(ISC_QUAD*)var->sqldata TSRMLS_CC);
}
}
}
return 1;
}
/* }}} */
static int firebird_bind_blob(pdo_stmt_t *stmt, ISC_QUAD *blob_id, zval *param TSRMLS_DC)
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
pdo_firebird_db_handle *H = S->H;
isc_blob_handle h = NULL;
unsigned long put_cnt = 0, rem_cnt;
unsigned short chunk_size;
int result = 1;
if (isc_create_blob(H->isc_status, &H->db, &H->tr, &h, blob_id)) {
RECORD_ERROR(stmt);
return 0;
}
SEPARATE_ZVAL(&param);
convert_to_string_ex(&param);
for (rem_cnt = Z_STRLEN_P(param); rem_cnt > 0; rem_cnt -= chunk_size) {
chunk_size = rem_cnt > USHRT_MAX ? USHRT_MAX : (unsigned short)rem_cnt;
if (isc_put_segment(H->isc_status, &h, chunk_size, &Z_STRVAL_P(param)[put_cnt])) {
RECORD_ERROR(stmt);
result = 0;
break;
}
put_cnt += chunk_size;
}
zval_dtor(param);
if (isc_close_blob(H->isc_status, &h)) {
RECORD_ERROR(stmt);
return 0;
}
return result;
}
static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, /* {{{ */
enum pdo_param_event event_type TSRMLS_DC)
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
XSQLDA *sqlda = param->is_param ? S->in_sqlda : &S->out_sqlda;
XSQLVAR *var;
if (event_type == PDO_PARAM_EVT_FREE) { /* not used */
return 1;
}
if (!sqlda || param->paramno >= sqlda->sqld) {
stmt->error_code = PDO_ERR_NOT_FOUND;
S->H->last_app_error = "Invalid parameter index";
return 0;
}
if (param->is_param && param->paramno == -1) {
long *index;
/* try to determine the index by looking in the named_params hash */
if (SUCCESS == zend_hash_find(S->named_params, param->name, param->namelen+1, (void*)&index)) {
param->paramno = *index;
} else {
/* ... or by looking in the input descriptor */
int i;
for (i = 0; i < sqlda->sqld; ++i) {
XSQLVAR *var = &sqlda->sqlvar[i];
if ((var->aliasname_length && !strncasecmp(param->name, var->aliasname,
min(param->namelen, var->aliasname_length)))
|| (var->sqlname_length && !strncasecmp(param->name, var->sqlname,
min(param->namelen, var->sqlname_length)))) {
param->paramno = i;
break;
}
}
if (i >= sqlda->sqld) {
stmt->error_code = PDO_ERR_NOT_FOUND;
S->H->last_app_error = "Invalid parameter name";
return 0;
}
}
}
var = &sqlda->sqlvar[param->paramno];
switch (event_type) {
char *value;
unsigned long value_len;
case PDO_PARAM_EVT_ALLOC:
if (param->is_param) {
/* allocate the parameter */
var->sqlind = (void*)emalloc(var->sqllen + 2*sizeof(short));
var->sqldata = &((char*)var->sqlind)[sizeof(short)];
}
break;
case PDO_PARAM_EVT_EXEC_PRE:
if (!param->is_param) {
break;
}
*var->sqlind = 0;
switch (var->sqltype & ~1) {
case SQL_ARRAY:
stmt->error_code = PDO_ERR_NOT_IMPLEMENTED;
S->H->last_app_error = "Cannot bind to array field";
return 0;
case SQL_BLOB:
return firebird_bind_blob(stmt, (ISC_QUAD*)var->sqldata,
param->parameter TSRMLS_CC);
}
/* check if a NULL should be inserted */
switch (Z_TYPE_P(param->parameter)) {
int force_null;
case IS_LONG:
var->sqltype = sizeof(long) == 8 ? SQL_INT64 : SQL_LONG;
var->sqldata = (void*)&Z_LVAL_P(param->parameter);
var->sqllen = sizeof(long);
break;
case IS_DOUBLE:
var->sqltype = SQL_DOUBLE;
var->sqldata = (void*)&Z_DVAL_P(param->parameter);
var->sqllen = sizeof(double);
break;
case IS_STRING:
force_null = 0;
/* for these types, an empty string can be handled like a NULL value */
switch (var->sqltype & ~1) {
case SQL_SHORT:
case SQL_LONG:
case SQL_INT64:
case SQL_FLOAT:
case SQL_DOUBLE:
case SQL_TIMESTAMP:
case SQL_TYPE_DATE:
case SQL_TYPE_TIME:
force_null = (Z_STRLEN_P(param->parameter) == 0);
}
if (!force_null) {
var->sqltype = SQL_TEXT;
var->sqldata = Z_STRVAL_P(param->parameter);
var->sqllen = Z_STRLEN_P(param->parameter);
break;
}
case IS_NULL:
/* complain if this field doesn't allow NULL values */
if (~var->sqltype & 1) {
stmt->error_code = PDO_ERR_CONSTRAINT;
S->H->last_app_error = "Parameter requires non-null value";
return 0;
}
*var->sqlind = -1;
break;
default:
stmt->error_code = PDO_ERR_NOT_IMPLEMENTED;
S->H->last_app_error = "Binding arrays/objects is not supported";
return 0;
}
break;
case PDO_PARAM_EVT_FETCH_POST:
value = NULL;
value_len = 0;
if (firebird_stmt_get_col(stmt, param->paramno, &value, &value_len TSRMLS_CC)) {
switch (param->param_type) {
case PDO_PARAM_STR:
if (value) {
ZVAL_STRINGL(param->parameter, value, value_len, 1);
break;
}
case PDO_PARAM_INT:
if (value) {
ZVAL_LONG(param->parameter, *(long*)value);
break;
}
#if abies_0
case PDO_PARAM_DBL:
if (value) {
ZVAL_DOUBLE(param->parameter, *(double*)value);
break;
}
#endif
default:
ZVAL_NULL(param->parameter);
}
return 1;
}
return 0;
default:
;
}
return 1;
}
/* }}} */
static int firebird_stmt_set_attribute(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC) /* {{{ */
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
switch (attr) {
default:
return 0;
case PDO_ATTR_CURSOR_NAME:
convert_to_string(val);
if (isc_dsql_set_cursor_name(S->H->isc_status, &S->stmt, Z_STRVAL_P(val),0)) {
RECORD_ERROR(stmt);
return 0;
}
strncpy(S->name, Z_STRVAL_P(val), sizeof(S->name));
S->name[sizeof(S->name)] = 0;
break;
}
return 1;
}
/* }}} */
static int firebird_stmt_get_attribute(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC) /* {{{ */
{
pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt->driver_data;
switch (attr) {
default:
return 0;
case PDO_ATTR_CURSOR_NAME:
if (*S->name) {
ZVAL_STRING(val,S->name,1);
} else {
ZVAL_NULL(val);
}
break;
}
return 1;
}
/* }}} */
struct pdo_stmt_methods firebird_stmt_methods = { /* {{{ */
firebird_stmt_dtor,
firebird_stmt_execute,
firebird_stmt_fetch,
firebird_stmt_describe,
firebird_stmt_get_col,
firebird_stmt_param_hook,
firebird_stmt_set_attribute,
firebird_stmt_get_attribute
};
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
-55
View File
@@ -1,55 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE package SYSTEM "../pear/package.dtd">
<package version="1.0"><!-- $Id: package.xml,v 1.5 2004-06-23 13:42:06 abies Exp $ -->
<name>PDO_FIREBIRD</name>
<summary>Firebird/InterBase 6 driver for PDO</summary>
<maintainers>
<maintainer>
<user>abies</user>
<name>Ard Biesheuvel</name>
<email>abies@php.net</email>
<role>lead</role>
</maintainer>
</maintainers>
<configureoptions>
<configureoption name="with-pdo-firebird" prompt="dir"/>
</configureoptions>
<description>
This extension provides a Firebird/InterBase driver for PDO. It supports
all versions of Firebird and InterBase versions 6 and up.
</description>
<license>PHP</license>
<release>
<state>alpha</state>
<version>0.1</version>
<date>2004-06-23</date>
<notes>
To compile and run this module, you will need to have the main PDO module and Firebird's
or InterBase's client library installed on your system.
</notes>
<filelist>
<file role="doc" name="CREDITS"/>
<file role="src" name="config.m4"/>
<file role="src" name="config.w32"/>
<file role="src" name="firebird_driver.c"/>
<file role="src" name="firebird_statement.c"/>
<file role="src" name="pdo_firebird.c"/>
<file role="src" name="php_pdo_firebird.h"/>
<file role="src" name="php_pdo_firebird_int.h"/>
<dir name="tests">
<file role="test">connect.phpt</file>
<file role="test">ddl.phpt</file>
<file role="test">execute.phpt</file>
</dir>
</filelist>
<deps>
<dep type="php" rel="ge" version="5.0.0"/>
<dep type="ext" rel="ge" name="pdo" version="0.1"/>
</deps>
</release>
</package>
-87
View File
@@ -1,87 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.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: Ard Biesheuvel <abies@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "pdo/php_pdo.h"
#include "pdo/php_pdo_driver.h"
#include "php_pdo_firebird.h"
#include "php_pdo_firebird_int.h"
function_entry pdo_firebird_functions[] = { /* {{{ */
{NULL, NULL, NULL}
};
/* }}} */
zend_module_entry pdo_firebird_module_entry = { /* {{{ */
STANDARD_MODULE_HEADER,
"PDO_Firebird",
pdo_firebird_functions,
PHP_MINIT(pdo_firebird),
PHP_MSHUTDOWN(pdo_firebird),
NULL,
NULL,
PHP_MINFO(pdo_firebird),
"0.1",
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#ifdef COMPILE_DL_PDO_FIREBIRD
ZEND_GET_MODULE(pdo_firebird)
#endif
PHP_MINIT_FUNCTION(pdo_firebird) /* {{{ */
{
php_pdo_register_driver(&pdo_firebird_driver);
return SUCCESS;
}
/* }}} */
PHP_MSHUTDOWN_FUNCTION(pdo_firebird) /* {{{ */
{
php_pdo_unregister_driver(&pdo_firebird_driver);
return SUCCESS;
}
/* }}} */
PHP_MINFO_FUNCTION(pdo_firebird) /* {{{ */
{
php_info_print_table_start();
php_info_print_table_header(2, "PDO Driver for Firebird/InterBase", "enabled");
php_info_print_table_end();
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
Loaded 100 of 269 files, more files were not shown because too many files have changed in this diff. Show more