[packages] php5: update pecl module dio to 0.0.6

Signed-off-by: Michael Heimpold <mhei@heimpold.de>



git-svn-id: svn://svn.openwrt.org/openwrt/packages@32875 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
mhei 2012-07-25 20:41:58 +00:00
parent 06e5755183
commit a268560dfe
2 changed files with 1547 additions and 1474 deletions

View File

@ -13,7 +13,7 @@
+fi
--- /dev/null
+++ b/ext/dio/dio.c
@@ -0,0 +1,801 @@
@@ -0,0 +1,871 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
@ -112,7 +112,7 @@
+ return;
+ }
+
+ if (php_check_open_basedir(file_name TSRMLS_CC) || (PG(safe_mode) && !php_checkuid(file_name, "wb+", CHECKUID_CHECK_MODE_PARAM))) {
+ if (php_check_open_basedir(file_name TSRMLS_CC) || DIO_SAFE_MODE_CHECK(file_name, "wb+")) {
+ RETURN_FALSE;
+ }
+
@ -127,14 +127,73 @@
+ RETURN_FALSE;
+ }
+
+ if (!new_php_fd(&f, fd)) {
+ RETURN_FALSE;
+ }
+
+ ZEND_REGISTER_RESOURCE(return_value, f, le_fd);
+}
+/* }}} */
+
+#ifndef PHP_WIN32
+
+/* {{{ proto resource dio_fdopen(int fd)
+ Returns a resource for the specified file descriptor. */
+PHP_FUNCTION(dio_fdopen)
+{
+ php_fd_t *f;
+ long lfd;
+ int fd;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &lfd) == FAILURE) {
+ return;
+ }
+
+ fd = (int)lfd;
+
+ if ((fcntl(fd, F_GETFL, 0) == -1) && (errno == EBADF)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad file descriptor %d", fd);
+ RETURN_FALSE;
+ }
+
+ if (!new_php_fd(&f, fd)) {
+ RETURN_FALSE;
+ }
+
+ ZEND_REGISTER_RESOURCE(return_value, f, le_fd);
+}
+/* }}} */
+
+
+/* {{{ proto resource dio_dup(resource fd)
+ Opens a duplicate of the specified open resource. */
+PHP_FUNCTION(dio_dup)
+{
+ zval *r_fd;
+ php_fd_t *f, *df;
+ int dfd;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &r_fd) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(f, php_fd_t *, &r_fd, -1, le_fd_name, le_fd);
+
+ dfd = dup(f->fd);
+ if (dfd == -1) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot duplication file descriptor %d: %s", f->fd, strerror(errno));
+ RETURN_FALSE;
+ }
+
+ if (!new_php_fd(&df, dfd)) {
+ RETURN_FALSE;
+ }
+
+ ZEND_REGISTER_RESOURCE(return_value, df, le_fd);
+}
+/* }}} */
+#endif
+
+/* {{{ proto string dio_read(resource fd[, int n])
+ Read n bytes from fd and return them, if n is not specified, read 1k */
+PHP_FUNCTION(dio_read)
@ -194,7 +253,7 @@
+
+ res = write(f->fd, data, trunc_len ? trunc_len : data_len);
+ if (res == -1) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot write data to file descriptor %d, %s", f->fd, strerror(errno));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot write data to file descriptor %d: %s", f->fd, strerror(errno));
+ }
+
+ RETURN_LONG(res);
@ -451,7 +510,7 @@
+ }
+
+ if (zend_hash_find(fh, "is_canonical", sizeof("is_canonical"), (void **) &element) == FAILURE) {
+ Is_Canonical = 1;
+ Is_Canonical = 0;
+ } else {
+ Is_Canonical = Z_LVAL_PP(element);
+ }
@ -664,6 +723,15 @@
+ ZEND_ARG_INFO(0, mode)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(dio_fdopen_args, 0, 0, 1)
+ ZEND_ARG_INFO(0, fd)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(dio_dup_args, 0, 0, 1)
+ ZEND_ARG_INFO(0, fd)
+ZEND_END_ARG_INFO()
+
+
+ZEND_BEGIN_ARG_INFO_EX(dio_read_args, 0, 0, 1)
+ ZEND_ARG_INFO(0, fd)
+ ZEND_ARG_INFO(0, n)
@ -725,12 +793,14 @@
+
+static zend_object_handlers dio_raw_object_handlers;
+
+static function_entry dio_functions[] = {
+static zend_function_entry dio_functions[] = {
+ /* Class functions. */
+
+ /* Legacy functions (Deprecated - See dio_legacy.c) */
+ PHP_FE(dio_open, dio_open_args)
+#ifndef PHP_WIN32
+ PHP_FE(dio_fdopen, dio_fdopen_args)
+ PHP_FE(dio_dup, dio_dup_args)
+ PHP_FE(dio_truncate, dio_truncate_args)
+#endif
+ PHP_FE(dio_stat, dio_stat_args)
@ -1712,7 +1782,7 @@
+ */
--- /dev/null
+++ b/ext/dio/dio_stream_wrappers.c
@@ -0,0 +1,410 @@
@@ -0,0 +1,406 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
@ -1858,8 +1928,7 @@
+ filename = path + sizeof(DIO_RAW_STREAM_PROTOCOL) - 1;
+
+ /* Check we can actually access it. */
+ if (php_check_open_basedir(filename TSRMLS_CC) ||
+ (PG(safe_mode) && !php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) {
+ if (php_check_open_basedir(filename TSRMLS_CC) || DIO_SAFE_MODE_CHECK(filename, mode)) {
+ return NULL;
+ }
+
@ -1925,8 +1994,7 @@
+ }
+
+ /* Check we can actually access the file. */
+ if (php_check_open_basedir(filename TSRMLS_CC) ||
+ (PG(safe_mode) && !php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) {
+ if (php_check_open_basedir(filename TSRMLS_CC) || DIO_SAFE_MODE_CHECK(filename, mode)) {
+ RETURN_FALSE;
+ }
+
@ -2022,8 +2090,7 @@
+ filename = path + sizeof(DIO_SERIAL_STREAM_PROTOCOL) - 1;
+
+ /* Check we can actually access it. */
+ if (php_check_open_basedir(filename TSRMLS_CC) ||
+ (PG(safe_mode) && !php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) {
+ if (php_check_open_basedir(filename TSRMLS_CC) || DIO_SAFE_MODE_CHECK(filename, mode)) {
+ return NULL;
+ }
+
@ -2089,8 +2156,7 @@
+ }
+
+ /* Check we can actually access the file. */
+ if (php_check_open_basedir(filename TSRMLS_CC) ||
+ (PG(safe_mode) && !php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) {
+ if (php_check_open_basedir(filename TSRMLS_CC) || DIO_SAFE_MODE_CHECK(filename, mode)) {
+ RETURN_FALSE;
+ }
+
@ -3075,7 +3141,7 @@
+ */
--- /dev/null
+++ b/ext/dio/php_dio_stream_wrappers.h
@@ -0,0 +1,44 @@
@@ -0,0 +1,51 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
@ -3102,6 +3168,13 @@
+#define DIO_SERIAL_STREAM_NAME "dio.serial"
+#define DIO_SERIAL_STREAM_PROTOCOL "dio.serial://"
+
+/* To support PHP 5.4 and later */
+#if PHP_VERSION_ID < 50399
+#define DIO_SAFE_MODE_CHECK(f, m) (PG(safe_mode) && !php_checkuid(f, m, CHECKUID_CHECK_MODE_PARAM))
+#else
+#define DIO_SAFE_MODE_CHECK(f, m) (0)
+#endif
+
+extern php_stream_wrapper php_dio_raw_stream_wrapper;
+
+PHP_FUNCTION(dio_raw);

View File

@ -1,6 +1,6 @@
--- a/ext/dio/dio.c
+++ b/ext/dio/dio.c
@@ -442,6 +442,26 @@ PHP_FUNCTION(dio_tcsetattr)
@@ -501,6 +501,26 @@ PHP_FUNCTION(dio_tcsetattr)
/* assign to correct values... */
switch (Baud_Rate) {