php7-pecl-dio: upgrade to 0.0.9

The upstream release has all the patches already included, so we can
drop them here.
This also fixes issues on 64-bit archs.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
This commit is contained in:
Michael Heimpold 2016-12-21 09:11:15 +01:00
parent 1cee6e8802
commit 200c52e9dd
18 changed files with 3 additions and 5071 deletions

View File

@ -8,9 +8,9 @@ include $(TOPDIR)/rules.mk
PECL_NAME:=dio
PECL_LONGNAME:=Direct I/O functions
PKG_VERSION:=0.0.7
PKG_RELEASE:=2
PKG_MD5SUM:=a1a4df428a17dbe1ab4277b492dfa052
PKG_VERSION:=0.0.9
PKG_RELEASE:=1
PKG_MD5SUM:=2c80b63fbbbaead856cb468955c14dc328d1262621b0c704b122d902053c8156
PKG_NAME:=php7-pecl-$(PECL_NAME)
PKG_SOURCE:=$(PECL_NAME)-$(PKG_VERSION).tgz

File diff suppressed because it is too large Load Diff

View File

@ -1,32 +0,0 @@
From 46d3a1ff2c6e316cf0928a9fd403cb5284bfe863 Mon Sep 17 00:00:00 2001
From: remi <remi@c90b9560-bf6c-de11-be94-00142212c4b1>
Date: Wed, 9 Oct 2013 12:04:16 +0000
Subject: [PATCH 01/16] fix svn prop
git-svn-id: http://svn.php.net/repository/pecl/dio/trunk@331748 c90b9560-bf6c-de11-be94-00142212c4b1
---
dio_posix.c | 0
dio_win32.c | 0
php_dio_posix.h | 0
php_dio_win32.h | 0
4 files changed, 0 insertions(+), 0 deletions(-)
mode change 100755 => 100644 dio_posix.c
mode change 100755 => 100644 dio_win32.c
mode change 100755 => 100644 php_dio_posix.h
mode change 100755 => 100644 php_dio_win32.h
diff --git a/dio_posix.c b/dio_posix.c
old mode 100755
new mode 100644
diff --git a/dio_win32.c b/dio_win32.c
old mode 100755
new mode 100644
diff --git a/php_dio_posix.h b/php_dio_posix.h
old mode 100755
new mode 100644
diff --git a/php_dio_win32.h b/php_dio_win32.h
old mode 100755
new mode 100644
--
2.5.0

View File

@ -1,39 +0,0 @@
From e9261081d447492e7eff3a22601b1de4f1ae550f Mon Sep 17 00:00:00 2001
From: remi <remi@c90b9560-bf6c-de11-be94-00142212c4b1>
Date: Wed, 9 Oct 2013 12:15:51 +0000
Subject: [PATCH 02/16] fix [-Wunused-variable]
git-svn-id: http://svn.php.net/repository/pecl/dio/trunk@331749 c90b9560-bf6c-de11-be94-00142212c4b1
---
dio.c | 2 +-
dio_posix.c | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/dio.c b/dio.c
index e400cf0..408a171 100644
--- a/dio.c
+++ b/dio.c
@@ -775,7 +775,7 @@ ZEND_BEGIN_ARG_INFO_EX(dio_serial_args, 0, 0, 2)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
-static zend_object_handlers dio_raw_object_handlers;
+// not used static zend_object_handlers dio_raw_object_handlers;
static zend_function_entry dio_functions[] = {
/* Class functions. */
diff --git a/dio_posix.c b/dio_posix.c
index 16fb3d6..01e1109 100644
--- a/dio_posix.c
+++ b/dio_posix.c
@@ -266,7 +266,6 @@ size_t dio_common_write(php_dio_stream_data *data, const char *buf, size_t count
* earlier than early time.
*/
static int dio_timeval_subtract(struct timeval *late, struct timeval *early, struct timeval *diff) {
- struct timeval *tmp;
/* Handle negatives */
if (late->tv_sec < early->tv_sec) {
--
2.5.0

View File

@ -1,39 +0,0 @@
From 6cbc1651b6b6f865f9aae1e9adff73743298666f Mon Sep 17 00:00:00 2001
From: remi <remi@c90b9560-bf6c-de11-be94-00142212c4b1>
Date: Wed, 9 Oct 2013 12:18:34 +0000
Subject: [PATCH 03/16] Fix [-Wmaybe-uninitialized]
git-svn-id: http://svn.php.net/repository/pecl/dio/trunk@331750 c90b9560-bf6c-de11-be94-00142212c4b1
---
dio_stream_wrappers.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/dio_stream_wrappers.c b/dio_stream_wrappers.c
index 844b006..811bc07 100644
--- a/dio_stream_wrappers.c
+++ b/dio_stream_wrappers.c
@@ -228,9 +228,8 @@ PHP_FUNCTION(dio_raw) {
efree(data);
RETURN_FALSE;
}
+ php_stream_to_zval(stream, return_value);
}
-
- php_stream_to_zval(stream, return_value);
}
/* }}} */
@@ -390,9 +389,8 @@ PHP_FUNCTION(dio_serial) {
efree(data);
RETURN_FALSE;
}
+ php_stream_to_zval(stream, return_value);
}
-
- php_stream_to_zval(stream, return_value);
}
/* }}} */
--
2.5.0

View File

@ -1,42 +0,0 @@
From 1e6f98d9fb65b9c052e6d555eab573d7e5073dae Mon Sep 17 00:00:00 2001
From: remi <remi@c90b9560-bf6c-de11-be94-00142212c4b1>
Date: Wed, 9 Oct 2013 12:24:28 +0000
Subject: [PATCH 04/16] Fix last build warning [-Wunused-but-set-variable]
(sorry for legibility...)
git-svn-id: http://svn.php.net/repository/pecl/dio/trunk@331751 c90b9560-bf6c-de11-be94-00142212c4b1
---
dio_posix.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dio_posix.c b/dio_posix.c
index 01e1109..6ed8630 100644
--- a/dio_posix.c
+++ b/dio_posix.c
@@ -28,7 +28,10 @@
* Convert an fopen() mode string to open() flags
*/
static int dio_stream_mode_to_flags(const char *mode) {
- int flags = 0, ch = 0, bin = 1;
+ int flags = 0, ch = 0;
+#if defined(_O_TEXT) && defined(O_BINARY)
+ int bin = 1;
+#endif
switch(mode[ch++]) {
case 'r':
@@ -45,9 +48,11 @@ static int dio_stream_mode_to_flags(const char *mode) {
break;
}
+#if defined(_O_TEXT) && defined(O_BINARY)
if (mode[ch] != '+') {
bin = (mode[ch++] == 'b');
}
+#endif
if (mode[ch] == '+') {
flags |= O_RDWR;
--
2.5.0

View File

@ -1,91 +0,0 @@
From 7c85a44880d9d748e7554f8fe7448505fa86aa28 Mon Sep 17 00:00:00 2001
From: cyberspice <cyberspice@c90b9560-bf6c-de11-be94-00142212c4b1>
Date: Sat, 12 Oct 2013 22:20:19 +0000
Subject: [PATCH 05/16] Added LICENCE file as requested in Request #65869
Files added:
LICENCE
git-svn-id: http://svn.php.net/repository/pecl/dio/trunk@331788 c90b9560-bf6c-de11-be94-00142212c4b1
---
LICENSE | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
create mode 100644 LICENSE
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d376afe
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,68 @@
+--------------------------------------------------------------------
+ The PHP License, version 3.01
+Copyright (c) 2008 - 2013 The PHP Group. All rights reserved.
+--------------------------------------------------------------------
+
+Redistribution and use in source and binary forms, with or without
+modification, is permitted provided that the following conditions
+are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ 3. The name "PHP" must not be used to endorse or promote products
+ derived from this software without prior written permission. For
+ written permission, please contact group@php.net.
+
+ 4. Products derived from this software may not be called "PHP", nor
+ may "PHP" appear in their name, without prior written permission
+ from group@php.net. You may indicate that your software works in
+ conjunction with PHP by saying "Foo for PHP" instead of calling
+ it "PHP Foo" or "phpfoo"
+
+ 5. The PHP Group may publish revised and/or new versions of the
+ license from time to time. Each version will be given a
+ distinguishing version number.
+ Once covered code has been published under a particular version
+ of the license, you may always continue to use it under the terms
+ of that version. You may also choose to use such covered code
+ under the terms of any subsequent version of the license
+ published by the PHP Group. No one other than the PHP Group has
+ the right to modify the terms applicable to covered code created
+ under this License.
+
+ 6. Redistributions of any form whatsoever must retain the following
+ acknowledgment:
+ "This product includes PHP software, freely available from
+ <http://www.php.net/software/>".
+
+THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
+ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
+DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+--------------------------------------------------------------------
+
+This software consists of voluntary contributions made by many
+individuals on behalf of the PHP Group.
+
+The PHP Group can be contacted via Email at group@php.net.
+
+For more information on the PHP Group and the PHP project,
+please see <http://www.php.net>.
+
+PHP includes the Zend Engine, freely available at
+<http://www.zend.com>.
--
2.5.0

View File

@ -1,117 +0,0 @@
From b69e1067f70ef293587b72979193e68b01d90902 Mon Sep 17 00:00:00 2001
From: Michael Heimpold <mhei@heimpold.de>
Date: Wed, 13 Jul 2016 00:23:29 +0200
Subject: [PATCH 06/16] Replace ZEND_FETCH_RESOURCE macro with
zend_fetch_resource
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
dio.c | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/dio.c b/dio.c
index 408a171..6b687ac 100644
--- a/dio.c
+++ b/dio.c
@@ -161,7 +161,9 @@ PHP_FUNCTION(dio_dup)
return;
}
- ZEND_FETCH_RESOURCE(f, php_fd_t *, &r_fd, -1, le_fd_name, le_fd);
+ if ((f = (php_fd_t *)zend_fetch_resource(Z_RES_P(r_fd), le_fd_name, le_fd)) == NULL) {
+ RETURN_FALSE;
+ }
dfd = dup(f->fd);
if (dfd == -1) {
@@ -192,7 +194,9 @@ PHP_FUNCTION(dio_read)
return;
}
- ZEND_FETCH_RESOURCE(f, php_fd_t *, &r_fd, -1, le_fd_name, le_fd);
+ if ((f = (php_fd_t *)zend_fetch_resource(Z_RES_P(r_fd), le_fd_name, le_fd)) == NULL) {
+ RETURN_FALSE;
+ }
if (bytes <= 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be greater than 0.");
@@ -233,7 +237,9 @@ PHP_FUNCTION(dio_write)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(f, php_fd_t *, &r_fd, -1, le_fd_name, le_fd);
+ if ((f = (php_fd_t *)zend_fetch_resource(Z_RES_P(r_fd), le_fd_name, le_fd)) == NULL) {
+ RETURN_FALSE;
+ }
res = write(f->fd, data, trunc_len ? trunc_len : data_len);
if (res == -1) {
@@ -258,7 +264,9 @@ PHP_FUNCTION(dio_truncate)
return;
}
- ZEND_FETCH_RESOURCE(f, php_fd_t *, &r_fd, -1, le_fd_name, le_fd);
+ if ((f = (php_fd_t *)zend_fetch_resource(Z_RES_P(r_fd), le_fd_name, le_fd)) == NULL) {
+ RETURN_FALSE;
+ }
if (ftruncate(f->fd, offset) == -1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "couldn't truncate %d to %ld bytes: %s", f->fd, offset, strerror(errno));
@@ -284,7 +292,9 @@ PHP_FUNCTION(dio_stat)
return;
}
- ZEND_FETCH_RESOURCE(f, php_fd_t *, &r_fd, -1, le_fd_name, le_fd);
+ if ((f = (php_fd_t *)zend_fetch_resource(Z_RES_P(r_fd), le_fd_name, le_fd)) == NULL) {
+ RETURN_FALSE;
+ }
if (fstat(f->fd, &s) == -1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot stat %d: %s", f->fd, strerror(errno));
@@ -323,7 +333,9 @@ PHP_FUNCTION(dio_seek)
return;
}
- ZEND_FETCH_RESOURCE(f, php_fd_t *, &r_fd, -1, le_fd_name, le_fd);
+ if ((f = (php_fd_t *)zend_fetch_resource(Z_RES_P(r_fd), le_fd_name, le_fd)) == NULL) {
+ RETURN_FALSE;
+ }
RETURN_LONG(lseek(f->fd, offset, whence));
}
@@ -344,7 +356,9 @@ PHP_FUNCTION(dio_fcntl)
return;
}
- ZEND_FETCH_RESOURCE(f, php_fd_t *, &r_fd, -1, le_fd_name, le_fd);
+ if ((f = (php_fd_t *)zend_fetch_resource(Z_RES_P(r_fd), le_fd_name, le_fd)) == NULL) {
+ RETURN_FALSE;
+ }
switch (cmd) {
case F_SETLK:
@@ -454,7 +468,9 @@ PHP_FUNCTION(dio_tcsetattr)
return;
}
- ZEND_FETCH_RESOURCE(f, php_fd_t *, &r_fd, -1, le_fd_name, le_fd);
+ if ((f = (php_fd_t *)zend_fetch_resource(Z_RES_P(r_fd), le_fd_name, le_fd)) == NULL) {
+ RETURN_FALSE;
+ }
if (Z_TYPE_P(arg) != IS_ARRAY) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,"tcsetattr, third argument should be an associative array");
@@ -639,7 +655,9 @@ PHP_FUNCTION(dio_close)
return;
}
- ZEND_FETCH_RESOURCE(f, php_fd_t *, &r_fd, -1, le_fd_name, le_fd);
+ if ((f = (php_fd_t *)zend_fetch_resource(Z_RES_P(r_fd), le_fd_name, le_fd)) == NULL) {
+ RETURN_FALSE;
+ }
zend_list_delete(Z_LVAL_P(r_fd));
}
--
2.5.0

View File

@ -1,66 +0,0 @@
From dbf03eb09bf1a41bcd140c4edba351121ac24729 Mon Sep 17 00:00:00 2001
From: Michael Heimpold <mhei@heimpold.de>
Date: Wed, 13 Jul 2016 00:36:46 +0200
Subject: [PATCH 07/16] Replace ZEND_REGISTER_RESOURCE with
zend_register_resource
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
dio.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/dio.c b/dio.c
index 6b687ac..6f2d58c 100644
--- a/dio.c
+++ b/dio.c
@@ -72,9 +72,9 @@ static int new_php_fd(php_fd_t **f, int fd)
return 1;
}
-static void _dio_close_fd(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+static void _dio_close_fd(zend_resource *res)
{
- php_fd_t *f = (php_fd_t *) rsrc->ptr;
+ php_fd_t *f = (php_fd_t *)zend_fetch_resource(res, NULL, le_fd);
if (f) {
close(f->fd);
free(f);
@@ -115,7 +115,7 @@ PHP_FUNCTION(dio_open)
RETURN_FALSE;
}
- ZEND_REGISTER_RESOURCE(return_value, f, le_fd);
+ RETVAL_RES(zend_register_resource(f, le_fd));
}
/* }}} */
@@ -144,7 +144,7 @@ PHP_FUNCTION(dio_fdopen)
RETURN_FALSE;
}
- ZEND_REGISTER_RESOURCE(return_value, f, le_fd);
+ RETVAL_RES(zend_register_resource(f, le_fd));
}
/* }}} */
@@ -175,7 +175,7 @@ PHP_FUNCTION(dio_dup)
RETURN_FALSE;
}
- ZEND_REGISTER_RESOURCE(return_value, df, le_fd);
+ RETVAL_RES(zend_register_resource(f, le_fd));
}
/* }}} */
#endif
@@ -434,7 +434,7 @@ PHP_FUNCTION(dio_fcntl)
if (!new_php_fd(&new_f, fcntl(f->fd, cmd, Z_LVAL_P(arg)))) {
RETURN_FALSE;
}
- ZEND_REGISTER_RESOURCE(return_value, new_f, le_fd);
+ RETVAL_RES(zend_register_resource(new_f, le_fd));
break;
}
default:
--
2.5.0

View File

@ -1,34 +0,0 @@
From 47422cf01f0a352c3f5f015585a28c99dba79862 Mon Sep 17 00:00:00 2001
From: Michael Heimpold <mhei@heimpold.de>
Date: Wed, 13 Jul 2016 00:40:08 +0200
Subject: [PATCH 08/16] RETURN_STRINGL takes only 2 arguments
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
dio.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dio.c b/dio.c
index 6f2d58c..e8660f8 100644
--- a/dio.c
+++ b/dio.c
@@ -24,6 +24,7 @@
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
+#include "ext/standard/php_string.h"
#include "php_dio.h"
#include "php_dio_stream_wrappers.h"
@@ -213,7 +214,7 @@ PHP_FUNCTION(dio_read)
data = erealloc(data, res + 1);
data[res] = 0;
- RETURN_STRINGL(data, res, 0);
+ RETURN_STRINGL(data, res);
}
/* }}} */
--
2.5.0

View File

@ -1,125 +0,0 @@
From 7533f64b19006262fae7c6a4769392c67078166b Mon Sep 17 00:00:00 2001
From: Michael Heimpold <mhei@heimpold.de>
Date: Wed, 13 Jul 2016 01:07:22 +0200
Subject: [PATCH 09/16] Replace zend_hash_find with zend_hash_str_find
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
dio.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/dio.c b/dio.c
index e8660f8..b489747 100644
--- a/dio.c
+++ b/dio.c
@@ -364,7 +364,7 @@ PHP_FUNCTION(dio_fcntl)
switch (cmd) {
case F_SETLK:
case F_SETLKW: {
- zval **element;
+ zval *element;
struct flock lk = {0};
HashTable *fh;
@@ -374,28 +374,28 @@ PHP_FUNCTION(dio_fcntl)
}
if (Z_TYPE_P(arg) == IS_ARRAY) {
fh = HASH_OF(arg);
- if (zend_hash_find(fh, "start", sizeof("start"), (void **) &element) == FAILURE) {
+ if ((element = zend_hash_str_find(fh, "start", sizeof("start"))) == NULL) {
lk.l_start = 0;
} else {
- lk.l_start = Z_LVAL_PP(element);
+ lk.l_start = Z_LVAL_P(element);
}
- if (zend_hash_find(fh, "length", sizeof("length"), (void **) &element) == FAILURE) {
+ if ((element = zend_hash_str_find(fh, "length", sizeof("length"))) == NULL) {
lk.l_len = 0;
} else {
- lk.l_len = Z_LVAL_PP(element);
+ lk.l_len = Z_LVAL_P(element);
}
- if (zend_hash_find(fh, "whence", sizeof("whence"), (void **) &element) == FAILURE) {
+ if ((element = zend_hash_str_find(fh, "whence", sizeof("whence"))) == NULL) {
lk.l_whence = 0;
} else {
- lk.l_whence = Z_LVAL_PP(element);
+ lk.l_whence = Z_LVAL_P(element);
}
- if (zend_hash_find(fh, "type", sizeof("type"), (void **) &element) == FAILURE) {
+ if ((element = zend_hash_str_find(fh, "type", sizeof("type"))) == NULL) {
lk.l_type = 0;
} else {
- lk.l_type = Z_LVAL_PP(element);
+ lk.l_type = Z_LVAL_P(element);
}
} else if (Z_TYPE_P(arg) == IS_LONG) {
lk.l_start = 0;
@@ -463,7 +463,7 @@ PHP_FUNCTION(dio_tcsetattr)
int Baud_Rate, Data_Bits=8, Stop_Bits=1, Parity=0, Flow_Control=1, Is_Canonical=1;
long BAUD,DATABITS,STOPBITS,PARITYON,PARITY;
HashTable *fh;
- zval **element;
+ zval *element;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz", &r_fd, &arg) == FAILURE) {
return;
@@ -480,40 +480,40 @@ PHP_FUNCTION(dio_tcsetattr)
fh = HASH_OF(arg);
- if (zend_hash_find(fh, "baud", sizeof("baud"), (void **) &element) == FAILURE) {
+ if ((element = zend_hash_str_find(fh, "baud", sizeof("baud"))) == NULL) {
Baud_Rate = 9600;
} else {
- Baud_Rate = Z_LVAL_PP(element);
+ Baud_Rate = Z_LVAL_P(element);
}
- if (zend_hash_find(fh, "bits", sizeof("bits"), (void **) &element) == FAILURE) {
+ if ((element = zend_hash_str_find(fh, "bits", sizeof("bits"))) == NULL) {
Data_Bits = 8;
} else {
- Data_Bits = Z_LVAL_PP(element);
+ Data_Bits = Z_LVAL_P(element);
}
- if (zend_hash_find(fh, "stop", sizeof("stop"), (void **) &element) == FAILURE) {
+ if ((element = zend_hash_str_find(fh, "stop", sizeof("stop"))) == NULL) {
Stop_Bits = 1;
} else {
- Stop_Bits = Z_LVAL_PP(element);
+ Stop_Bits = Z_LVAL_P(element);
}
- if (zend_hash_find(fh, "parity", sizeof("parity"), (void **) &element) == FAILURE) {
+ if ((element = zend_hash_str_find(fh, "parity", sizeof("parity"))) == NULL) {
Parity = 0;
} else {
- Parity = Z_LVAL_PP(element);
+ Parity = Z_LVAL_P(element);
}
- if (zend_hash_find(fh, "flow_control", sizeof("flow_control"), (void **) &element) == FAILURE) {
+ if ((element = zend_hash_str_find(fh, "flow_control", sizeof("flow_control"))) == NULL) {
Flow_Control = 1;
} else {
- Flow_Control = Z_LVAL_PP(element);
+ Flow_Control = Z_LVAL_P(element);
}
- if (zend_hash_find(fh, "is_canonical", sizeof("is_canonical"), (void **) &element) == FAILURE) {
+ if ((element = zend_hash_str_find(fh, "is_canonical", sizeof("is_canonical"))) == NULL) {
Is_Canonical = 0;
} else {
- Is_Canonical = Z_LVAL_PP(element);
+ Is_Canonical = Z_LVAL_P(element);
}
/* assign to correct values... */
--
2.5.0

View File

@ -1,240 +0,0 @@
From fb31b1cf4da2bfd0830d0a83754f5ecb125d1c4a Mon Sep 17 00:00:00 2001
From: Michael Heimpold <mhei@heimpold.de>
Date: Thu, 14 Jul 2016 00:38:52 +0200
Subject: [PATCH 10/16] Replace dio_convert_to_long
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
dio_common.c | 106 +++++++++++++++++++++++--------------------------------
php_dio_common.h | 2 --
2 files changed, 44 insertions(+), 64 deletions(-)
diff --git a/dio_common.c b/dio_common.c
index c50f56d..a5f4c63 100644
--- a/dio_common.c
+++ b/dio_common.c
@@ -52,29 +52,12 @@ void dio_init_stream_data(php_dio_stream_data *data) {
}
/* }}} */
-/* {{{ dio_convert_to_long
- * Returns as a long, the value of the zval regardless of its type.
- */
-long dio_convert_to_long(zval *val) {
- zval *copyval;
- long longval;
-
- ALLOC_INIT_ZVAL(copyval);
- *copyval = *val;
- convert_to_long(copyval);
- longval = Z_LVAL_P(copyval);
- zval_ptr_dtor(&copyval);
-
- return longval;
-}
-/* }}} */
-
/* {{{ dio_assoc_array_get_basic_options
* Retrieves the basic open option values from an associative array
*/
void dio_assoc_array_get_basic_options(zval *options, php_dio_stream_data *data TSRMLS_DC) {
#if defined(DIO_HAS_FILEPERMS) || defined(DIO_NONBLOCK)
- zval **tmpzval;
+ zval *tmpzval;
HashTable *opthash;
opthash = HASH_OF(options);
@@ -82,8 +65,8 @@ void dio_assoc_array_get_basic_options(zval *options, php_dio_stream_data *data
#ifdef DIO_HAS_FILEPERMS
/* This is the file mode flags used by open(). */
- if (zend_hash_find(opthash, "perms", sizeof("perms"), (void **)&tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->perms = (int)dio_convert_to_long(*tmpzval);
+ if ((tmpzval = zend_hash_str_find(opthash, "perms", sizeof("perms"))) != NULL) {
+ data->perms = (int)zval_get_long(tmpzval);
data->has_perms = 1;
}
#endif
@@ -91,20 +74,20 @@ void dio_assoc_array_get_basic_options(zval *options, php_dio_stream_data *data
#ifdef DIO_NONBLOCK
/* This sets the underlying stream to be blocking/non
block (i.e. O_NONBLOCK) */
- if (zend_hash_find(opthash, "is_blocking", sizeof("is_blocking"), (void **)&tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->is_blocking = dio_convert_to_long(*tmpzval) ? 1 : 0;
+ if ((tmpzval = zend_hash_str_find(opthash, "is_blocking", sizeof("is_blocking"))) != NULL) {
+ data->is_blocking = zval_get_long(tmpzval) ? 1 : 0;
}
/* This is the timeout value for reads in seconds. Only one of
timeout_secs or timeout_usecs need be defined to define a timeout. */
- if (zend_hash_find(opthash, "timeout_secs", sizeof("timeout_secs"), (void **)&tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->timeout_sec = dio_convert_to_long(*tmpzval);
+ if ((tmpzval = zend_hash_str_find(opthash, "timeout_secs", sizeof("timeout_secs"))) != NULL) {
+ data->timeout_sec = zval_get_long(tmpzval);
}
/* This is the timeout value for reads in microseconds. Only one of
timeout_secs or timeout_usecs need be defined to define a timeout. */
- if (zend_hash_find(opthash, "timeout_usecs", sizeof("timeout_usecs"), (void **)&tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->timeout_usec = dio_convert_to_long(*tmpzval);
+ if ((tmpzval = zend_hash_str_find(opthash, "timeout_usecs", sizeof("timeout_usecs"))) != NULL) {
+ data->timeout_usec = zval_get_long(tmpzval);
}
data->has_timeout = (data->timeout_sec | data->timeout_usec) ? 1 : 0;
@@ -116,33 +99,33 @@ void dio_assoc_array_get_basic_options(zval *options, php_dio_stream_data *data
* Retrieves the serial open option values from an associative array
*/
void dio_assoc_array_get_serial_options(zval *options, php_dio_stream_data *data TSRMLS_DC) {
- zval **tmpzval;
+ zval *tmpzval;
HashTable *opthash;
opthash = HASH_OF(options);
- if (zend_hash_find(opthash, "data_rate", sizeof("data_rate"), (void **)&tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->data_rate = dio_convert_to_long(*tmpzval);
+ if ((tmpzval = zend_hash_str_find(opthash, "data_rate", sizeof("data_rate"))) != NULL) {
+ data->data_rate = zval_get_long(tmpzval);
}
- if (zend_hash_find(opthash, "data_bits", sizeof("data_bits"), (void **)&tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->data_bits = (int)dio_convert_to_long(*tmpzval);
+ if ((tmpzval = zend_hash_str_find(opthash, "data_bits", sizeof("data_bits"))) != NULL) {
+ data->data_bits = (int)zval_get_long(tmpzval);
}
- if (zend_hash_find(opthash, "stop_bits", sizeof("stop_bits"), (void **)&tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->stop_bits = (int)dio_convert_to_long(*tmpzval);
+ if ((tmpzval = zend_hash_str_find(opthash, "stop_bits", sizeof("stop_bits"))) != NULL) {
+ data->stop_bits = (int)zval_get_long(tmpzval);
}
- if (zend_hash_find(opthash, "parity", sizeof("parity"), (void **)&tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->parity = (int)dio_convert_to_long(*tmpzval);
+ if ((tmpzval = zend_hash_str_find(opthash, "parity", sizeof("parity"))) != NULL) {
+ data->parity = (int)zval_get_long(tmpzval);
}
- if (zend_hash_find(opthash, "flow_control", sizeof("flow_control"), (void **)&tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->flow_control = (int)(dio_convert_to_long(*tmpzval) ? 1 : 0);
+ if ((tmpzval = zend_hash_str_find(opthash, "flow_control", sizeof("flow_control"))) != NULL) {
+ data->flow_control = zval_get_long(tmpzval) ? 1 : 0;
}
- if (zend_hash_find(opthash, "is_canonical", sizeof("is_canonical"), (void **)&tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->canonical = (int)(dio_convert_to_long(*tmpzval) ? 1 : 0);
+ if ((tmpzval = zend_hash_str_find(opthash, "is_canonical", sizeof("is_canonical"))) != NULL) {
+ data->canonical = zval_get_long(tmpzval) ? 1 : 0;
}
}
/* }}} */
@@ -152,13 +135,13 @@ void dio_assoc_array_get_serial_options(zval *options, php_dio_stream_data *data
*/
void dio_stream_context_get_basic_options(php_stream_context *context, php_dio_stream_data *data TSRMLS_DC) {
#if defined(DIO_HAS_FILEPERMS) || defined(DIO_NONBLOCK)
- zval **tmpzval;
+ zval *tmpzval;
#endif
#ifdef DIO_HAS_FILEPERMS
/* This is the file mode flags used by open(). */
- if (php_stream_context_get_option(context, "dio", "perms", &tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->perms = (int)dio_convert_to_long(*tmpzval);
+ if ((tmpzval = php_stream_context_get_option(context, "dio", "perms")) != NULL) {
+ data->perms = (int)zval_get_long(tmpzval);
data->has_perms = 1;
}
#endif
@@ -166,20 +149,20 @@ void dio_stream_context_get_basic_options(php_stream_context *context, php_dio_s
#ifdef DIO_NONBLOCK
/* This sets the underlying stream to be blocking/non
block (i.e. O_NONBLOCK) */
- if (php_stream_context_get_option(context, "dio", "is_blocking", &tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->is_blocking = dio_convert_to_long(*tmpzval) ? 1 : 0;
+ if ((tmpzval = php_stream_context_get_option(context, "dio", "is_blocking")) != NULL) {
+ data->is_blocking = zval_get_long(tmpzval) ? 1 : 0;
}
/* This is the timeout value for reads in seconds. Only one of
timeout_secs or timeout_usecs need be defined to define a timeout. */
- if (php_stream_context_get_option(context, "dio", "timeout_secs", &tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->timeout_sec = dio_convert_to_long(*tmpzval);
+ if ((tmpzval = php_stream_context_get_option(context, "dio", "timeout_secs")) != NULL) {
+ data->timeout_sec = zval_get_long(tmpzval);
}
/* This is the timeout value for reads in microseconds. Only one of
timeout_secs or timeout_usecs need be defined to define a timeout. */
- if (php_stream_context_get_option(context, "dio", "timeout_usecs", &tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->timeout_usec = dio_convert_to_long(*tmpzval);
+ if ((tmpzval = php_stream_context_get_option(context, "dio", "timeout_usecs")) != NULL) {
+ data->timeout_usec = zval_get_long(tmpzval);
}
data->has_timeout = (data->timeout_sec | data->timeout_usec) ? 1 : 0;
@@ -191,30 +174,30 @@ void dio_stream_context_get_basic_options(php_stream_context *context, php_dio_s
* Extracts the option values for dio.serial mode from a context
*/
void dio_stream_context_get_serial_options(php_stream_context *context, php_dio_stream_data *data TSRMLS_DC) {
- zval **tmpzval;
+ zval *tmpzval;
- if (php_stream_context_get_option(context, "dio", "data_rate", &tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->data_rate = dio_convert_to_long(*tmpzval);
+ if ((tmpzval = php_stream_context_get_option(context, "dio", "data_rate")) != NULL) {
+ data->data_rate = zval_get_long(tmpzval);
}
- if (php_stream_context_get_option(context, "dio", "data_bits", &tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->data_bits = (int)dio_convert_to_long(*tmpzval);
+ if ((tmpzval = php_stream_context_get_option(context, "dio", "data_bits")) != NULL) {
+ data->data_bits = (int)zval_get_long(tmpzval);
}
- if (php_stream_context_get_option(context, "dio", "stop_bits", &tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->stop_bits = (int)dio_convert_to_long(*tmpzval);
+ if ((tmpzval = php_stream_context_get_option(context, "dio", "stop_bits")) != NULL) {
+ data->stop_bits = (int)zval_get_long(tmpzval);
}
- if (php_stream_context_get_option(context, "dio", "parity", &tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->parity = (int)dio_convert_to_long(*tmpzval);
+ if ((tmpzval = php_stream_context_get_option(context, "dio", "parity")) != NULL) {
+ data->parity = (int)zval_get_long(tmpzval);
}
- if (php_stream_context_get_option(context, "dio", "flow_control", &tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->flow_control = (int)(dio_convert_to_long(*tmpzval) ? 1 : 0);
+ if ((tmpzval = php_stream_context_get_option(context, "dio", "flow_control")) != NULL) {
+ data->flow_control = zval_get_long(tmpzval) ? 1 : 0;
}
- if (php_stream_context_get_option(context, "dio", "is_canonical", &tmpzval) == SUCCESS && tmpzval && *tmpzval) {
- data->canonical = (int)(dio_convert_to_long(*tmpzval) ? 1 : 0);
+ if ((tmpzval = php_stream_context_get_option(context, "dio", "is_canonical")) != NULL) {
+ data->canonical = zval_get_long(tmpzval) ? 1 : 0;
}
}
/* }}} */
@@ -227,4 +210,3 @@ void dio_stream_context_get_serial_options(php_stream_context *context, php_dio_
* vim600: fdm=marker
* vim: sw=4 ts=4 noet
*/
-
diff --git a/php_dio_common.h b/php_dio_common.h
index f6e4d98..6b14040 100644
--- a/php_dio_common.h
+++ b/php_dio_common.h
@@ -35,8 +35,6 @@
#define DIO_STREAM_TYPE_RAW 1
#define DIO_STREAM_TYPE_SERIAL 2
-long dio_convert_to_long(zval *val);
-
php_dio_stream_data * dio_create_stream_data(void);
void dio_init_stream_data(php_dio_stream_data *data);
--
2.5.0

View File

@ -1,89 +0,0 @@
From 3d71063ada4f1a4ef90611d263aa8e1d4f275359 Mon Sep 17 00:00:00 2001
From: Michael Heimpold <mhei@heimpold.de>
Date: Thu, 14 Jul 2016 00:50:12 +0200
Subject: [PATCH 11/16] Adopt to changed stream API interface
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
dio_posix.c | 2 +-
dio_stream_wrappers.c | 14 +++++++-------
dio_win32.c | 2 +-
php_dio_common.h | 2 +-
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/dio_posix.c b/dio_posix.c
index 6ed8630..527d683 100644
--- a/dio_posix.c
+++ b/dio_posix.c
@@ -474,7 +474,7 @@ int dio_common_set_option(php_dio_stream_data *data, int option, int value, void
/* {{{ dio_raw_open_stream
* Opens the underlying stream.
*/
-int dio_raw_open_stream(char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC) {
+int dio_raw_open_stream(const char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC) {
php_dio_posix_stream_data *pdata = (php_dio_posix_stream_data*)data;
pdata->flags = dio_stream_mode_to_flags(mode);
diff --git a/dio_stream_wrappers.c b/dio_stream_wrappers.c
index 811bc07..817b0d1 100644
--- a/dio_stream_wrappers.c
+++ b/dio_stream_wrappers.c
@@ -126,12 +126,12 @@ php_stream_ops dio_raw_stream_ops = {
* fopen for the dio.raw stream.
*/
static php_stream *dio_raw_fopen_wrapper(php_stream_wrapper *wrapper,
- char *path, char *mode,
- int options, char **opened_path,
- php_stream_context *context STREAMS_DC TSRMLS_DC) {
+ const char *path, const char *mode, int options,
+ zend_string **opened_path, php_stream_context *context STREAMS_DC)
+{
php_dio_stream_data *data;
php_stream *stream;
- char *filename;
+ const char *filename;
/* Check it was actually for us (not a corrupted function pointer
somewhere!). */
@@ -287,9 +287,9 @@ php_stream_ops dio_serial_stream_ops = {
* fopen for the dio.raw stream.
*/
static php_stream *dio_serial_fopen_wrapper(php_stream_wrapper *wrapper,
- char *path, char *mode,
- int options, char **opened_path,
- php_stream_context *context STREAMS_DC TSRMLS_DC) {
+ const char *path, const char *mode, int options,
+ zend_string **opened_path, php_stream_context *context STREAMS_DC)
+{
php_dio_stream_data *data;
php_stream *stream;
char *filename;
diff --git a/dio_win32.c b/dio_win32.c
index e7ccedd..1023d36 100644
--- a/dio_win32.c
+++ b/dio_win32.c
@@ -505,7 +505,7 @@ int dio_common_set_option(php_dio_stream_data *data, int option, int value, void
/* {{{ dio_raw_open_stream
* Opens the underlying stream.
*/
-int dio_raw_open_stream(char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC) {
+int dio_raw_open_stream(const char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC) {
php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data;
DWORD err;
diff --git a/php_dio_common.h b/php_dio_common.h
index 6b14040..7a75370 100644
--- a/php_dio_common.h
+++ b/php_dio_common.h
@@ -55,7 +55,7 @@ int dio_common_close(php_dio_stream_data *data);
int dio_common_set_option(php_dio_stream_data *data, int option, int value, void *ptrparam);
-int dio_raw_open_stream(char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC);
+int dio_raw_open_stream(const char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC);
int dio_serial_uninit(php_dio_stream_data *data);
--
2.5.0

View File

@ -1,829 +0,0 @@
From 760ec7072cbba2cbbb6e4e17b0c54ee3c7b661a8 Mon Sep 17 00:00:00 2001
From: Michael Heimpold <mhei@heimpold.de>
Date: Thu, 14 Jul 2016 00:59:42 +0200
Subject: [PATCH 12/16] Remove ancient macros TSRMLS_CC and TSRMLS_DC
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
dio.c | 70 +++++++++++++++++++++++++--------------------------
dio_common.c | 8 +++---
dio_posix.c | 22 ++++++++--------
dio_stream_wrappers.c | 48 +++++++++++++++++------------------
dio_win32.c | 46 ++++++++++++++++-----------------
php_dio_common.h | 12 ++++-----
6 files changed, 103 insertions(+), 103 deletions(-)
diff --git a/dio.c b/dio.c
index b489747..7bad575 100644
--- a/dio.c
+++ b/dio.c
@@ -93,11 +93,11 @@ PHP_FUNCTION(dio_open)
long mode = 0;
int fd;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|l", &file_name, &file_name_length, &flags, &mode) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|l", &file_name, &file_name_length, &flags, &mode) == FAILURE) {
return;
}
- if (php_check_open_basedir(file_name TSRMLS_CC) || DIO_SAFE_MODE_CHECK(file_name, "wb+")) {
+ if (php_check_open_basedir(file_name) || DIO_SAFE_MODE_CHECK(file_name, "wb+")) {
RETURN_FALSE;
}
@@ -108,7 +108,7 @@ PHP_FUNCTION(dio_open)
}
if (fd == -1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot open file %s with flags %ld and permissions %ld: %s", file_name, flags, mode, strerror(errno));
+ php_error_docref(NULL, E_WARNING, "cannot open file %s with flags %ld and permissions %ld: %s", file_name, flags, mode, strerror(errno));
RETURN_FALSE;
}
@@ -130,14 +130,14 @@ PHP_FUNCTION(dio_fdopen)
long lfd;
int fd;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &lfd) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "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);
+ php_error_docref(NULL, E_WARNING, "Bad file descriptor %d", fd);
RETURN_FALSE;
}
@@ -158,7 +158,7 @@ PHP_FUNCTION(dio_dup)
php_fd_t *f, *df;
int dfd;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &r_fd) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &r_fd) == FAILURE) {
return;
}
@@ -168,7 +168,7 @@ PHP_FUNCTION(dio_dup)
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));
+ php_error_docref(NULL, E_WARNING, "cannot duplication file descriptor %d: %s", f->fd, strerror(errno));
RETURN_FALSE;
}
@@ -191,7 +191,7 @@ PHP_FUNCTION(dio_read)
long bytes = 1024;
ssize_t res;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &r_fd, &bytes) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &r_fd, &bytes) == FAILURE) {
return;
}
@@ -200,7 +200,7 @@ PHP_FUNCTION(dio_read)
}
if (bytes <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be greater than 0.");
+ php_error_docref(NULL, E_WARNING, "Length parameter must be greater than 0.");
RETURN_FALSE;
}
@@ -229,12 +229,12 @@ PHP_FUNCTION(dio_write)
long trunc_len = 0;
ssize_t res;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &r_fd, &data, &data_len, &trunc_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|l", &r_fd, &data, &data_len, &trunc_len) == FAILURE) {
return;
}
if (trunc_len < 0 || trunc_len > data_len) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "length must be greater or equal to zero and less then the length of the specified string.");
+ php_error_docref(NULL, E_WARNING, "length must be greater or equal to zero and less then the length of the specified string.");
RETURN_FALSE;
}
@@ -244,7 +244,7 @@ PHP_FUNCTION(dio_write)
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, E_WARNING, "cannot write data to file descriptor %d: %s", f->fd, strerror(errno));
}
RETURN_LONG(res);
@@ -261,7 +261,7 @@ PHP_FUNCTION(dio_truncate)
php_fd_t *f;
long offset;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &r_fd, &offset) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &r_fd, &offset) == FAILURE) {
return;
}
@@ -270,7 +270,7 @@ PHP_FUNCTION(dio_truncate)
}
if (ftruncate(f->fd, offset) == -1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "couldn't truncate %d to %ld bytes: %s", f->fd, offset, strerror(errno));
+ php_error_docref(NULL, E_WARNING, "couldn't truncate %d to %ld bytes: %s", f->fd, offset, strerror(errno));
RETURN_FALSE;
}
@@ -289,7 +289,7 @@ PHP_FUNCTION(dio_stat)
php_fd_t *f;
struct stat s;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &r_fd) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &r_fd) == FAILURE) {
return;
}
@@ -298,7 +298,7 @@ PHP_FUNCTION(dio_stat)
}
if (fstat(f->fd, &s) == -1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot stat %d: %s", f->fd, strerror(errno));
+ php_error_docref(NULL, E_WARNING, "cannot stat %d: %s", f->fd, strerror(errno));
RETURN_FALSE;
}
@@ -330,7 +330,7 @@ PHP_FUNCTION(dio_seek)
long offset;
long whence = SEEK_SET;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &r_fd, &offset, &whence) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl|l", &r_fd, &offset, &whence) == FAILURE) {
return;
}
@@ -353,7 +353,7 @@ PHP_FUNCTION(dio_fcntl)
php_fd_t *f;
long cmd;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z", &r_fd, &cmd, &arg) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl|z", &r_fd, &cmd, &arg) == FAILURE) {
return;
}
@@ -369,7 +369,7 @@ PHP_FUNCTION(dio_fcntl)
HashTable *fh;
if (!arg) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "expects argument 3 to be array or int, none given");
+ php_error_docref(NULL, E_WARNING, "expects argument 3 to be array or int, none given");
RETURN_FALSE;
}
if (Z_TYPE_P(arg) == IS_ARRAY) {
@@ -403,7 +403,7 @@ PHP_FUNCTION(dio_fcntl)
lk.l_whence = SEEK_SET;
lk.l_type = Z_LVAL_P(arg);
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "expects argument 3 to be array or int, %s given", zend_zval_type_name(arg));
+ php_error_docref(NULL, E_WARNING, "expects argument 3 to be array or int, %s given", zend_zval_type_name(arg));
RETURN_FALSE;
}
@@ -428,7 +428,7 @@ PHP_FUNCTION(dio_fcntl)
php_fd_t *new_f;
if (!arg || Z_TYPE_P(arg) != IS_LONG) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "expects argument 3 to be int");
+ php_error_docref(NULL, E_WARNING, "expects argument 3 to be int");
RETURN_FALSE;
}
@@ -440,7 +440,7 @@ PHP_FUNCTION(dio_fcntl)
}
default:
if (!arg || Z_TYPE_P(arg) != IS_LONG) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "expects argument 3 to be int");
+ php_error_docref(NULL, E_WARNING, "expects argument 3 to be int");
RETURN_FALSE;
}
@@ -465,7 +465,7 @@ PHP_FUNCTION(dio_tcsetattr)
HashTable *fh;
zval *element;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz", &r_fd, &arg) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz", &r_fd, &arg) == FAILURE) {
return;
}
@@ -474,7 +474,7 @@ PHP_FUNCTION(dio_tcsetattr)
}
if (Z_TYPE_P(arg) != IS_ARRAY) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"tcsetattr, third argument should be an associative array");
+ php_error_docref(NULL, E_WARNING,"tcsetattr, third argument should be an associative array");
return;
}
@@ -564,7 +564,7 @@ PHP_FUNCTION(dio_tcsetattr)
BAUD = B50;
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid baud rate %d", Baud_Rate);
+ php_error_docref(NULL, E_WARNING, "invalid baud rate %d", Baud_Rate);
RETURN_FALSE;
}
switch (Data_Bits) {
@@ -581,7 +581,7 @@ PHP_FUNCTION(dio_tcsetattr)
DATABITS = CS5;
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid data bits %d", Data_Bits);
+ php_error_docref(NULL, E_WARNING, "invalid data bits %d", Data_Bits);
RETURN_FALSE;
}
switch (Stop_Bits) {
@@ -592,7 +592,7 @@ PHP_FUNCTION(dio_tcsetattr)
STOPBITS = CSTOPB;
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid stop bits %d", Stop_Bits);
+ php_error_docref(NULL, E_WARNING, "invalid stop bits %d", Stop_Bits);
RETURN_FALSE;
}
@@ -610,7 +610,7 @@ PHP_FUNCTION(dio_tcsetattr)
PARITY = 0;
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid parity %d", Parity);
+ php_error_docref(NULL, E_WARNING, "invalid parity %d", Parity);
RETURN_FALSE;
}
@@ -652,7 +652,7 @@ PHP_FUNCTION(dio_close)
zval *r_fd;
php_fd_t *f;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &r_fd) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &r_fd) == FAILURE) {
return;
}
@@ -669,7 +669,7 @@ PHP_FUNCTION(dio_close)
/* {{{ dio_init_legacy_defines
* Initialises the legacy PHP defines
*/
-static void dio_init_legacy_defines(int module_number TSRMLS_DC) {
+static void dio_init_legacy_defines(int module_number) {
RDIOC(O_RDONLY);
RDIOC(O_WRONLY);
RDIOC(O_RDWR);
@@ -852,11 +852,11 @@ PHP_MINIT_FUNCTION(dio)
/* Legacy resource destructor. */
le_fd = zend_register_list_destructors_ex(_dio_close_fd, NULL, le_fd_name, module_number);
- dio_init_legacy_defines(module_number TSRMLS_CC);
+ dio_init_legacy_defines(module_number);
/* Register the stream wrappers */
- return (php_register_url_stream_wrapper(DIO_RAW_STREAM_NAME, &php_dio_raw_stream_wrapper TSRMLS_CC) == SUCCESS &&
- php_register_url_stream_wrapper(DIO_SERIAL_STREAM_NAME, &php_dio_serial_stream_wrapper TSRMLS_CC) == SUCCESS) ? SUCCESS : FAILURE;
+ return (php_register_url_stream_wrapper(DIO_RAW_STREAM_NAME, &php_dio_raw_stream_wrapper) == SUCCESS &&
+ php_register_url_stream_wrapper(DIO_SERIAL_STREAM_NAME, &php_dio_serial_stream_wrapper) == SUCCESS) ? SUCCESS : FAILURE;
}
/* }}} */
@@ -864,8 +864,8 @@ PHP_MINIT_FUNCTION(dio)
*/
PHP_MSHUTDOWN_FUNCTION(dio)
{
- return (php_unregister_url_stream_wrapper(DIO_RAW_STREAM_NAME TSRMLS_CC) == SUCCESS &&
- php_unregister_url_stream_wrapper(DIO_SERIAL_STREAM_NAME TSRMLS_CC) == SUCCESS) ? SUCCESS : FAILURE;
+ return (php_unregister_url_stream_wrapper(DIO_RAW_STREAM_NAME) == SUCCESS &&
+ php_unregister_url_stream_wrapper(DIO_SERIAL_STREAM_NAME) == SUCCESS) ? SUCCESS : FAILURE;
}
/* }}} */
diff --git a/dio_common.c b/dio_common.c
index a5f4c63..d09c0ec 100644
--- a/dio_common.c
+++ b/dio_common.c
@@ -55,7 +55,7 @@ void dio_init_stream_data(php_dio_stream_data *data) {
/* {{{ dio_assoc_array_get_basic_options
* Retrieves the basic open option values from an associative array
*/
-void dio_assoc_array_get_basic_options(zval *options, php_dio_stream_data *data TSRMLS_DC) {
+void dio_assoc_array_get_basic_options(zval *options, php_dio_stream_data *data) {
#if defined(DIO_HAS_FILEPERMS) || defined(DIO_NONBLOCK)
zval *tmpzval;
HashTable *opthash;
@@ -98,7 +98,7 @@ void dio_assoc_array_get_basic_options(zval *options, php_dio_stream_data *data
/* {{{ dio_assoc_array_get_serial_options
* Retrieves the serial open option values from an associative array
*/
-void dio_assoc_array_get_serial_options(zval *options, php_dio_stream_data *data TSRMLS_DC) {
+void dio_assoc_array_get_serial_options(zval *options, php_dio_stream_data *data) {
zval *tmpzval;
HashTable *opthash;
@@ -133,7 +133,7 @@ void dio_assoc_array_get_serial_options(zval *options, php_dio_stream_data *data
/* {{{ dio_stream_context_get_raw_options
* Extracts the option values for dio.raw mode from a context
*/
-void dio_stream_context_get_basic_options(php_stream_context *context, php_dio_stream_data *data TSRMLS_DC) {
+void dio_stream_context_get_basic_options(php_stream_context *context, php_dio_stream_data *data) {
#if defined(DIO_HAS_FILEPERMS) || defined(DIO_NONBLOCK)
zval *tmpzval;
#endif
@@ -173,7 +173,7 @@ void dio_stream_context_get_basic_options(php_stream_context *context, php_dio_s
/* {{{ dio_stream_context_get_serial_options
* Extracts the option values for dio.serial mode from a context
*/
-void dio_stream_context_get_serial_options(php_stream_context *context, php_dio_stream_data *data TSRMLS_DC) {
+void dio_stream_context_get_serial_options(php_stream_context *context, php_dio_stream_data *data) {
zval *tmpzval;
if ((tmpzval = php_stream_context_get_option(context, "dio", "data_rate")) != NULL) {
diff --git a/dio_posix.c b/dio_posix.c
index 527d683..843e234 100644
--- a/dio_posix.c
+++ b/dio_posix.c
@@ -474,7 +474,7 @@ int dio_common_set_option(php_dio_stream_data *data, int option, int value, void
/* {{{ dio_raw_open_stream
* Opens the underlying stream.
*/
-int dio_raw_open_stream(const char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC) {
+int dio_raw_open_stream(const char *filename, const char *mode, php_dio_stream_data *data) {
php_dio_posix_stream_data *pdata = (php_dio_posix_stream_data*)data;
pdata->flags = dio_stream_mode_to_flags(mode);
@@ -498,7 +498,7 @@ int dio_raw_open_stream(const char *filename, char *mode, php_dio_stream_data *d
if (pdata->fd < 0) {
switch (errno) {
case EEXIST:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "File exists!");
+ php_error_docref(NULL, E_WARNING, "File exists!");
return 0;
default:
return 0;
@@ -512,36 +512,36 @@ int dio_raw_open_stream(const char *filename, char *mode, php_dio_stream_data *d
/* {{{ dio_serial_init
* Initialises the serial settings storing the original settings before hand.
*/
-static int dio_serial_init(php_dio_stream_data *data TSRMLS_DC) {
+static int dio_serial_init(php_dio_stream_data *data) {
php_dio_posix_stream_data *pdata = (php_dio_posix_stream_data*)data;
int ret = 0, data_bits_def, stop_bits_def, parity_def;
struct termios tio;
speed_t rate_def;
if (!dio_data_rate_to_define(data->data_rate, &rate_def)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid data_rate value (%ld)", data->data_rate);
+ php_error_docref(NULL, E_WARNING, "invalid data_rate value (%ld)", data->data_rate);
return 0;
}
if (!dio_data_bits_to_define(data->data_bits, &data_bits_def)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid data_bits value (%d)", data->data_bits);
+ php_error_docref(NULL, E_WARNING, "invalid data_bits value (%d)", data->data_bits);
return 0;
}
if (!dio_stop_bits_to_define(data->stop_bits, &stop_bits_def)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid stop_bits value (%d)", data->stop_bits);
+ php_error_docref(NULL, E_WARNING, "invalid stop_bits value (%d)", data->stop_bits);
return 0;
}
if (!dio_parity_to_define(data->parity, &parity_def)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid parity value (%d)", data->parity);
+ php_error_docref(NULL, E_WARNING, "invalid parity value (%d)", data->parity);
return 0;
}
ret = tcgetattr(pdata->fd, &(pdata->oldtio));
if (ret < 0) {
if ((errno == ENOTTY) || (errno == ENODEV)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not a serial port or terminal!");
+ php_error_docref(NULL, E_WARNING, "Not a serial port or terminal!");
}
return 0;
}
@@ -632,7 +632,7 @@ int dio_serial_purge(php_dio_stream_data *data) {
/* {{{ dio_serial_open_stream
* Opens the underlying stream.
*/
-int dio_serial_open_stream(char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC) {
+int dio_serial_open_stream(char *filename, char *mode, php_dio_stream_data *data) {
php_dio_posix_stream_data *pdata = (php_dio_posix_stream_data*)data;
#ifdef O_NOCTTY
@@ -640,11 +640,11 @@ int dio_serial_open_stream(char *filename, char *mode, php_dio_stream_data *data
pdata->flags |= O_NOCTTY;
#endif
- if (!dio_raw_open_stream(filename, mode, data TSRMLS_CC)) {
+ if (!dio_raw_open_stream(filename, mode, data)) {
return 0;
}
- if (!dio_serial_init(data TSRMLS_CC)) {
+ if (!dio_serial_init(data)) {
close(pdata->fd);
return 0;
}
diff --git a/dio_stream_wrappers.c b/dio_stream_wrappers.c
index 817b0d1..eb23752 100644
--- a/dio_stream_wrappers.c
+++ b/dio_stream_wrappers.c
@@ -36,7 +36,7 @@
/* {{{ dio_stream_write
* Write to the stream
*/
-static size_t dio_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
+static size_t dio_stream_write(php_stream *stream, const char *buf, size_t count)
{
return dio_common_write((php_dio_stream_data*)stream->abstract, buf, count);
}
@@ -45,7 +45,7 @@ static size_t dio_stream_write(php_stream *stream, const char *buf, size_t count
/* {{{ dio_stream_read
* Read from the stream
*/
-static size_t dio_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
+static size_t dio_stream_read(php_stream *stream, char *buf, size_t count)
{
php_dio_stream_data* data = (php_dio_stream_data*)stream->abstract;
size_t bytes = dio_common_read(data, buf, count);
@@ -58,7 +58,7 @@ static size_t dio_stream_read(php_stream *stream, char *buf, size_t count TSRMLS
/* {{{ dio_stream_flush
* Flush the stream. For raw streams this does nothing.
*/
-static int dio_stream_flush(php_stream *stream TSRMLS_DC)
+static int dio_stream_flush(php_stream *stream)
{
return 1;
}
@@ -67,7 +67,7 @@ static int dio_stream_flush(php_stream *stream TSRMLS_DC)
/* {{{ dio_stream_close
* Close the stream
*/
-static int dio_stream_close(php_stream *stream, int close_handle TSRMLS_DC)
+static int dio_stream_close(php_stream *stream, int close_handle)
{
php_dio_stream_data *abstract = (php_dio_stream_data*)stream->abstract;
@@ -83,7 +83,7 @@ static int dio_stream_close(php_stream *stream, int close_handle TSRMLS_DC)
/* {{{ dio_stream_set_option
* Set the stream options.
*/
-static int dio_stream_set_option(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC)
+static int dio_stream_set_option(php_stream *stream, int option, int value, void *ptrparam)
{
php_dio_stream_data *abstract = (php_dio_stream_data*)stream->abstract;
@@ -143,7 +143,7 @@ static php_stream *dio_raw_fopen_wrapper(php_stream_wrapper *wrapper,
filename = path + sizeof(DIO_RAW_STREAM_PROTOCOL) - 1;
/* Check we can actually access it. */
- if (php_check_open_basedir(filename TSRMLS_CC) || DIO_SAFE_MODE_CHECK(filename, mode)) {
+ if (php_check_open_basedir(filename) || DIO_SAFE_MODE_CHECK(filename, mode)) {
return NULL;
}
@@ -152,11 +152,11 @@ static php_stream *dio_raw_fopen_wrapper(php_stream_wrapper *wrapper,
/* Parse the context. */
if (context) {
- dio_stream_context_get_basic_options(context, data TSRMLS_CC);
+ dio_stream_context_get_basic_options(context, data);
}
/* Try and open a raw stream. */
- if (!dio_raw_open_stream(filename, mode, data TSRMLS_CC)) {
+ if (!dio_raw_open_stream(filename, mode, data)) {
return NULL;
}
@@ -199,7 +199,7 @@ PHP_FUNCTION(dio_raw) {
char *mode;
int mode_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|z", &filename, &filename_len, &mode, &mode_len, &options) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|z", &filename, &filename_len, &mode, &mode_len, &options) == FAILURE) {
RETURN_FALSE;
}
@@ -209,7 +209,7 @@ PHP_FUNCTION(dio_raw) {
}
/* Check we can actually access the file. */
- if (php_check_open_basedir(filename TSRMLS_CC) || DIO_SAFE_MODE_CHECK(filename, mode)) {
+ if (php_check_open_basedir(filename) || DIO_SAFE_MODE_CHECK(filename, mode)) {
RETURN_FALSE;
}
@@ -217,11 +217,11 @@ PHP_FUNCTION(dio_raw) {
data->stream_type = DIO_STREAM_TYPE_RAW;
if (options) {
- dio_assoc_array_get_basic_options(options, data TSRMLS_CC);
+ dio_assoc_array_get_basic_options(options, data);
}
/* Try and open a raw stream. */
- if (dio_raw_open_stream(filename, mode, data TSRMLS_CC)) {
+ if (dio_raw_open_stream(filename, mode, data)) {
stream = php_stream_alloc(&dio_raw_stream_ops, data, 0, mode);
if (!stream) {
(void) dio_common_close(data);
@@ -244,7 +244,7 @@ PHP_FUNCTION(dio_raw) {
* stream, if it is write only it flushes the write, otherwise it flushes
* both.
*/
-static int dio_serial_stream_flush(php_stream *stream TSRMLS_DC)
+static int dio_serial_stream_flush(php_stream *stream)
{
return dio_serial_purge((php_dio_stream_data*)stream->abstract);
}
@@ -254,7 +254,7 @@ static int dio_serial_stream_flush(php_stream *stream TSRMLS_DC)
* Close the stream. Restores the serial settings to their value before
* the stream was open.
*/
-static int dio_serial_stream_close(php_stream *stream, int close_handle TSRMLS_DC)
+static int dio_serial_stream_close(php_stream *stream, int close_handle)
{
php_dio_stream_data *abstract = (php_dio_stream_data*)stream->abstract;
@@ -304,7 +304,7 @@ static php_stream *dio_serial_fopen_wrapper(php_stream_wrapper *wrapper,
filename = path + sizeof(DIO_SERIAL_STREAM_PROTOCOL) - 1;
/* Check we can actually access it. */
- if (php_check_open_basedir(filename TSRMLS_CC) || DIO_SAFE_MODE_CHECK(filename, mode)) {
+ if (php_check_open_basedir(filename) || DIO_SAFE_MODE_CHECK(filename, mode)) {
return NULL;
}
@@ -313,12 +313,12 @@ static php_stream *dio_serial_fopen_wrapper(php_stream_wrapper *wrapper,
/* Parse the context. */
if (context) {
- dio_stream_context_get_basic_options(context, data TSRMLS_CC);
- dio_stream_context_get_serial_options(context, data TSRMLS_CC);
+ dio_stream_context_get_basic_options(context, data);
+ dio_stream_context_get_serial_options(context, data);
}
/* Try and open a serial stream. */
- if (!dio_serial_open_stream(filename, mode, data TSRMLS_CC)) {
+ if (!dio_serial_open_stream(filename, mode, data)) {
return NULL;
}
@@ -359,18 +359,18 @@ PHP_FUNCTION(dio_serial) {
char *mode;
int mode_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|z", &filename, &filename_len, &mode, &mode_len, &options) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|z", &filename, &filename_len, &mode, &mode_len, &options) == FAILURE) {
RETURN_FALSE;
}
/* Check the third argument is an array. */
if (options && (Z_TYPE_P(options) != IS_ARRAY)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"dio_serial, the third argument should be an array of options");
+ php_error_docref(NULL, E_WARNING,"dio_serial, the third argument should be an array of options");
RETURN_FALSE;
}
/* Check we can actually access the file. */
- if (php_check_open_basedir(filename TSRMLS_CC) || DIO_SAFE_MODE_CHECK(filename, mode)) {
+ if (php_check_open_basedir(filename) || DIO_SAFE_MODE_CHECK(filename, mode)) {
RETURN_FALSE;
}
@@ -378,12 +378,12 @@ PHP_FUNCTION(dio_serial) {
data->stream_type = DIO_STREAM_TYPE_SERIAL;
if (options) {
- dio_assoc_array_get_basic_options(options, data TSRMLS_CC);
- dio_assoc_array_get_serial_options(options, data TSRMLS_CC);
+ dio_assoc_array_get_basic_options(options, data);
+ dio_assoc_array_get_serial_options(options, data);
}
/* Try and open a serial stream. */
- if (dio_serial_open_stream(filename, mode, data TSRMLS_CC)) {
+ if (dio_serial_open_stream(filename, mode, data)) {
stream = php_stream_alloc(&dio_serial_stream_ops, data, 0, mode);
if (!stream) {
efree(data);
diff --git a/dio_win32.c b/dio_win32.c
index 1023d36..25c838a 100644
--- a/dio_win32.c
+++ b/dio_win32.c
@@ -30,7 +30,7 @@
/* {{{ dio_last_error_php_error
* Generates a PHP error message based upon the last Windows error.
*/
-static void dio_last_error_php_error(int level, char * message TSRMLS_DC) {
+static void dio_last_error_php_error(int level, char * message) {
LPVOID msgbuf;
DWORD msgbuflen;
char * errmsg;
@@ -68,7 +68,7 @@ static void dio_last_error_php_error(int level, char * message TSRMLS_DC) {
/* Allocate a buffer */
errmsg = emalloc(errmsglen);
if (!errmsg) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Out of memory in dio_last_error_php_error()!");
+ php_error_docref(NULL, E_ERROR, "Out of memory in dio_last_error_php_error()!");
LocalFree(msgbuf);
return;
}
@@ -88,7 +88,7 @@ static void dio_last_error_php_error(int level, char * message TSRMLS_DC) {
errmsg = (char *)msgbuf;
#endif
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s[ERROR %d] %s", message, err, errmsg);
+ php_error_docref(NULL, E_WARNING, "%s[ERROR %d] %s", message, err, errmsg);
LocalFree(msgbuf);
#ifdef UNICODE
@@ -505,7 +505,7 @@ int dio_common_set_option(php_dio_stream_data *data, int option, int value, void
/* {{{ dio_raw_open_stream
* Opens the underlying stream.
*/
-int dio_raw_open_stream(const char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC) {
+int dio_raw_open_stream(const char *filename, const char *mode, php_dio_stream_data *data) {
php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data;
DWORD err;
@@ -543,29 +543,29 @@ int dio_raw_open_stream(const char *filename, char *mode, php_dio_stream_data *d
err = GetLastError();
switch (err) {
case ERROR_FILE_EXISTS:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "File exists!");
+ php_error_docref(NULL, E_WARNING, "File exists!");
return 0;
case ERROR_FILE_NOT_FOUND:
/* ERROR_FILE_NOT_FOUND with TRUNCATE_EXISTING means that
* the file doesn't exist so now try to create it. */
if (TRUNCATE_EXISTING == wdata->creation_disposition) {
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "File does not exist, creating new file!");
+ php_error_docref(NULL, E_NOTICE, "File does not exist, creating new file!");
wdata->handle = CreateFile(filename, wdata->desired_access, 0,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (INVALID_HANDLE_VALUE == wdata->handle) {
- dio_last_error_php_error(E_WARNING, "CreateFile() failed:" TSRMLS_CC);
+ dio_last_error_php_error(E_WARNING, "CreateFile() failed:");
return 0;
}
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "File not found!");
+ php_error_docref(NULL, E_WARNING, "File not found!");
return 0;
}
break;
default:
- dio_last_error_php_error(E_WARNING, "CreateFile() failed:" TSRMLS_CC);
+ dio_last_error_php_error(E_WARNING, "CreateFile() failed:");
return 0;
}
}
@@ -584,33 +584,33 @@ int dio_raw_open_stream(const char *filename, char *mode, php_dio_stream_data *d
/* {{{ dio_serial_init
* Initialises the serial port
*/
-static int dio_serial_init(php_dio_stream_data *data TSRMLS_DC) {
+static int dio_serial_init(php_dio_stream_data *data) {
php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data;
DWORD rate_def, data_bits_def, stop_bits_def, parity_def;
DCB dcb;
if (!dio_data_rate_to_define(data->data_rate, &rate_def)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid data_rate value (%d)", data->data_rate);
+ php_error_docref(NULL, E_WARNING, "invalid data_rate value (%d)", data->data_rate);
return 0;
}
if (!dio_data_bits_to_define(data->data_bits, &data_bits_def)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid data_bits value (%d)", data->data_bits);
+ php_error_docref(NULL, E_WARNING, "invalid data_bits value (%d)", data->data_bits);
return 0;
}
if (!dio_stop_bits_to_define(data->stop_bits, &stop_bits_def)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid stop_bits value (%d)", data->stop_bits);
+ php_error_docref(NULL, E_WARNING, "invalid stop_bits value (%d)", data->stop_bits);
return 0;
}
if (!dio_parity_to_define(data->parity, &parity_def)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid parity value (%d)", data->parity);
+ php_error_docref(NULL, E_WARNING, "invalid parity value (%d)", data->parity);
return 0;
}
if (!GetCommState(wdata->handle, &(wdata->olddcb))) {
- dio_last_error_php_error(E_WARNING, "GetCommState() failed:" TSRMLS_CC);
+ dio_last_error_php_error(E_WARNING, "GetCommState() failed:");
return 0;
}
@@ -646,7 +646,7 @@ static int dio_serial_init(php_dio_stream_data *data TSRMLS_DC) {
}
if (!SetCommState(wdata->handle, &dcb)) {
- dio_last_error_php_error(E_WARNING, "SetCommState() failed:" TSRMLS_CC);
+ dio_last_error_php_error(E_WARNING, "SetCommState() failed:");
return 0;
}
@@ -698,23 +698,23 @@ int dio_serial_purge(php_dio_stream_data *data) {
/* {{{ dio_serial_open_stream
* Opens the underlying stream.
*/
-int dio_serial_open_stream(char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC) {
+int dio_serial_open_stream(char *filename, char *mode, php_dio_stream_data *data) {
php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data;
COMMTIMEOUTS cto = { 0, 0, 0, 0, 0 };
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Opening \"%s\" as a serial port (mode=\"%s\").", filename, mode);
+ php_error_docref(NULL, E_NOTICE, "Opening \"%s\" as a serial port (mode=\"%s\").", filename, mode);
if (*mode != 'r') {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must open serial ports in read or read/write mode!");
+ php_error_docref(NULL, E_WARNING, "You must open serial ports in read or read/write mode!");
return 0;
}
- if (!dio_raw_open_stream(filename, mode, data TSRMLS_CC)) {
+ if (!dio_raw_open_stream(filename, mode, data)) {
return 0;
}
if (!GetCommTimeouts(wdata->handle, &(wdata->oldcto))) {
- dio_last_error_php_error(E_WARNING, "GetCommTimeouts() failed (Not a comm port?):" TSRMLS_CC);
+ dio_last_error_php_error(E_WARNING, "GetCommTimeouts() failed (Not a comm port?):");
CloseHandle(wdata->handle);
return 0;
}
@@ -735,12 +735,12 @@ int dio_serial_open_stream(char *filename, char *mode, php_dio_stream_data *data
}
if (!SetCommTimeouts(wdata->handle, &cto)) {
- dio_last_error_php_error(E_WARNING, "SetCommTimeouts() failed:" TSRMLS_CC);
+ dio_last_error_php_error(E_WARNING, "SetCommTimeouts() failed:");
CloseHandle(wdata->handle);
return 0;
}
- if (!dio_serial_init(data TSRMLS_CC)) {
+ if (!dio_serial_init(data)) {
CloseHandle(wdata->handle);
return 0;
}
diff --git a/php_dio_common.h b/php_dio_common.h
index 7a75370..6af202f 100644
--- a/php_dio_common.h
+++ b/php_dio_common.h
@@ -39,13 +39,13 @@ php_dio_stream_data * dio_create_stream_data(void);
void dio_init_stream_data(php_dio_stream_data *data);
-void dio_assoc_array_get_basic_options(zval *options, php_dio_stream_data *data TSRMLS_DC);
+void dio_assoc_array_get_basic_options(zval *options, php_dio_stream_data *data);
-void dio_assoc_array_get_serial_options(zval *options, php_dio_stream_data *data TSRMLS_DC);
+void dio_assoc_array_get_serial_options(zval *options, php_dio_stream_data *data);
-void dio_stream_context_get_basic_options(php_stream_context *context, php_dio_stream_data *data TSRMLS_DC);
+void dio_stream_context_get_basic_options(php_stream_context *context, php_dio_stream_data *data);
-void dio_stream_context_get_serial_options(php_stream_context *context, php_dio_stream_data *data TSRMLS_DC);
+void dio_stream_context_get_serial_options(php_stream_context *context, php_dio_stream_data *data);
size_t dio_common_write(php_dio_stream_data *data, const char *buf, size_t count);
@@ -55,13 +55,13 @@ int dio_common_close(php_dio_stream_data *data);
int dio_common_set_option(php_dio_stream_data *data, int option, int value, void *ptrparam);
-int dio_raw_open_stream(const char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC);
+int dio_raw_open_stream(const char *filename, const char *mode, php_dio_stream_data *data);
int dio_serial_uninit(php_dio_stream_data *data);
int dio_serial_purge(php_dio_stream_data *data);
-int dio_serial_open_stream(char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC);
+int dio_serial_open_stream(char *filename, char *mode, php_dio_stream_data *data);
#endif /* PHP_DIO_COMMON_H_ */
--
2.5.0

View File

@ -1,69 +0,0 @@
From 942b77d84417298fb9e99c216029f22fbd1e2d98 Mon Sep 17 00:00:00 2001
From: Michael Heimpold <mhei@heimpold.de>
Date: Thu, 14 Jul 2016 01:47:05 +0200
Subject: [PATCH 13/16] Fix tests for legacy interface
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
dio.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/dio.c b/dio.c
index 7bad575..1a130a2 100644
--- a/dio.c
+++ b/dio.c
@@ -73,9 +73,9 @@ static int new_php_fd(php_fd_t **f, int fd)
return 1;
}
-static void _dio_close_fd(zend_resource *res)
+static void _dio_close_fd(zend_resource *rsrc)
{
- php_fd_t *f = (php_fd_t *)zend_fetch_resource(res, NULL, le_fd);
+ php_fd_t *f = (php_fd_t *)rsrc->ptr;
if (f) {
close(f->fd);
free(f);
@@ -87,8 +87,8 @@ static void _dio_close_fd(zend_resource *res)
PHP_FUNCTION(dio_open)
{
php_fd_t *f;
- char *file_name;
- int file_name_length;
+ char *file_name = NULL;
+ size_t file_name_length = 0;
long flags;
long mode = 0;
int fd;
@@ -97,6 +97,10 @@ PHP_FUNCTION(dio_open)
return;
}
+ if (!file_name || file_name[0] == '\0') {
+ RETURN_FALSE;
+ }
+
if (php_check_open_basedir(file_name) || DIO_SAFE_MODE_CHECK(file_name, "wb+")) {
RETURN_FALSE;
}
@@ -176,7 +180,7 @@ PHP_FUNCTION(dio_dup)
RETURN_FALSE;
}
- RETVAL_RES(zend_register_resource(f, le_fd));
+ RETVAL_RES(zend_register_resource(df, le_fd));
}
/* }}} */
#endif
@@ -660,7 +664,7 @@ PHP_FUNCTION(dio_close)
RETURN_FALSE;
}
- zend_list_delete(Z_LVAL_P(r_fd));
+ zend_list_delete(Z_RES_P(r_fd));
}
/* }}} */
--
2.5.0

View File

@ -1,54 +0,0 @@
From ff469d3a11409e9b043dc10ddfc44792c5359ff1 Mon Sep 17 00:00:00 2001
From: Michael Heimpold <mhei@heimpold.de>
Date: Thu, 14 Jul 2016 01:47:05 +0200
Subject: [PATCH 14/16] Add missing changes from changed stream API interface
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
dio_posix.c | 2 +-
dio_stream_wrappers.c | 2 +-
php_dio_common.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/dio_posix.c b/dio_posix.c
index 843e234..b2aa228 100644
--- a/dio_posix.c
+++ b/dio_posix.c
@@ -632,7 +632,7 @@ int dio_serial_purge(php_dio_stream_data *data) {
/* {{{ dio_serial_open_stream
* Opens the underlying stream.
*/
-int dio_serial_open_stream(char *filename, char *mode, php_dio_stream_data *data) {
+int dio_serial_open_stream(const char *filename, const char *mode, php_dio_stream_data *data) {
php_dio_posix_stream_data *pdata = (php_dio_posix_stream_data*)data;
#ifdef O_NOCTTY
diff --git a/dio_stream_wrappers.c b/dio_stream_wrappers.c
index eb23752..0a00daa 100644
--- a/dio_stream_wrappers.c
+++ b/dio_stream_wrappers.c
@@ -292,7 +292,7 @@ static php_stream *dio_serial_fopen_wrapper(php_stream_wrapper *wrapper,
{
php_dio_stream_data *data;
php_stream *stream;
- char *filename;
+ const char *filename;
/* Check it was actually for us (not a corrupted function pointer
somewhere!). */
diff --git a/php_dio_common.h b/php_dio_common.h
index 6af202f..7068ea7 100644
--- a/php_dio_common.h
+++ b/php_dio_common.h
@@ -61,7 +61,7 @@ int dio_serial_uninit(php_dio_stream_data *data);
int dio_serial_purge(php_dio_stream_data *data);
-int dio_serial_open_stream(char *filename, char *mode, php_dio_stream_data *data);
+int dio_serial_open_stream(const char *filename, const char *mode, php_dio_stream_data *data);
#endif /* PHP_DIO_COMMON_H_ */
--
2.5.0

View File

@ -1,48 +0,0 @@
From def92a2db269d4ea6d2e8b7f8fe9dd473886a6b1 Mon Sep 17 00:00:00 2001
From: Michael Heimpold <mhei@heimpold.de>
Date: Sun, 17 Jul 2016 01:08:47 +0200
Subject: [PATCH 15/16] Add .gitignore
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
.gitignore | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 .gitignore
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..dae52e8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,28 @@
+.deps
+.libs
+Makefile
+Makefile.fragments
+Makefile.global
+Makefile.objects
+acinclude.m4
+aclocal.m4
+autom4te.cache
+build
+config.guess
+config.h
+config.h.in
+config.log
+config.nice
+config.status
+config.sub
+configure
+configure.in
+*.la
+*.lo
+install-sh
+libtool
+ltmain.sh
+missing
+mkinstalldirs
+modules
+run-tests.php
--
2.5.0

View File

@ -1,44 +0,0 @@
From 0f8df09a8008eed8a7ac0c6400bce523014ff770 Mon Sep 17 00:00:00 2001
From: Michael Heimpold <mhei@heimpold.de>
Date: Mon, 18 Jul 2016 22:45:04 +0200
Subject: [PATCH 16/16] Add additional baudrates
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
---
dio.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/dio.c b/dio.c
index 1a130a2..a4e8e7d 100644
--- a/dio.c
+++ b/dio.c
@@ -522,6 +522,26 @@ PHP_FUNCTION(dio_tcsetattr)
/* assign to correct values... */
switch (Baud_Rate) {
+#ifdef B460800
+ case 460800:
+ BAUD = B460800;
+ break;
+#endif
+#ifdef B230400
+ case 230400:
+ BAUD = B230400;
+ break;
+#endif
+#ifdef B115200
+ case 115200:
+ BAUD = B115200;
+ break;
+#endif
+#ifdef B57600
+ case 57600:
+ BAUD = B57600;
+ break;
+#endif
case 38400:
BAUD = B38400;
break;
--
2.5.0