diff options
author | Michael Heimpold <mhei@heimpold.de> | 2016-12-21 09:11:15 +0100 |
---|---|---|
committer | Michael Heimpold <mhei@heimpold.de> | 2016-12-22 10:27:26 +0100 |
commit | 200c52e9dd77bc3f42a91ece8f600baa2c240fd7 (patch) | |
tree | 8c4c38ed111ba3a5564c2381b1494b85133f5ac3 /lang/php7-pecl-dio | |
parent | 1cee6e8802e96fe2c9032c682e8284063f33c3e0 (diff) |
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>
Diffstat (limited to 'lang/php7-pecl-dio')
18 files changed, 3 insertions, 5071 deletions
diff --git a/lang/php7-pecl-dio/Makefile b/lang/php7-pecl-dio/Makefile index bcf32a164..9c1d52e00 100644 --- a/lang/php7-pecl-dio/Makefile +++ b/lang/php7-pecl-dio/Makefile @@ -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 diff --git a/lang/php7-pecl-dio/patches/0000-unify-line-endings.patch b/lang/php7-pecl-dio/patches/0000-unify-line-endings.patch deleted file mode 100644 index b6c275040..000000000 --- a/lang/php7-pecl-dio/patches/0000-unify-line-endings.patch +++ /dev/null @@ -1,3110 +0,0 @@ ---- a/dio_posix.c -+++ b/dio_posix.c -@@ -1,659 +1,659 @@ --/*
-- +----------------------------------------------------------------------+
-- | PHP Version 5 |
-- +----------------------------------------------------------------------+
-- | Copyright (c) 2009 Melanie Rhianna Lewis |
-- +----------------------------------------------------------------------+
-- | 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: Melanie Rhianna Lewis <cyberspice@php.net> |
-- +----------------------------------------------------------------------+
-- */
--
--#ifdef HAVE_CONFIG_H
--#include "config.h"
--#endif
--
--#include "php.h"
--
--#include "php_dio_common.h"
--
--/* {{{ dio_stream_mode_to_flags
-- * 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;
--
-- switch(mode[ch++]) {
-- case 'r':
-- flags = 0;
-- break;
-- case 'w':
-- flags = O_TRUNC | O_CREAT;
-- break;
-- case 'a':
-- flags = O_APPEND | O_CREAT;
-- break;
-- case 'x':
-- flags = O_EXCL | O_CREAT;
-- break;
-- }
--
-- if (mode[ch] != '+') {
-- bin = (mode[ch++] == 'b');
-- }
--
-- if (mode[ch] == '+') {
-- flags |= O_RDWR;
-- } else if (flags) {
-- flags |= O_WRONLY;
-- } else {
-- flags |= O_RDONLY;
-- }
--
--#if defined(_O_TEXT) && defined(O_BINARY)
-- if (bin) {
-- flags |= O_BINARY;
-- } else {
-- flags |= _O_TEXT;
-- }
--#endif
--
-- return flags;
--}
--/* }}} */
--
--/* {{{ dio_data_rate_to_define
-- * Converts a numeric data rate to a termios define
-- */
--static int dio_data_rate_to_define(long rate, speed_t *def) {
-- speed_t val;
--
-- switch (rate) {
-- case 0:
-- val = 0;
-- break;
-- case 50:
-- val = B50;
-- break;
-- case 75:
-- val = B75;
-- break;
-- case 110:
-- val = B110;
-- break;
-- case 134:
-- val = B134;
-- break;
-- case 150:
-- val = B150;
-- break;
-- case 200:
-- val = B200;
-- break;
-- case 300:
-- val = B300;
-- break;
-- case 600:
-- val = B600;
-- break;
-- case 1200:
-- val = B1200;
-- break;
-- case 1800:
-- val = B1800;
-- break;
-- case 2400:
-- val = B2400;
-- break;
-- case 4800:
-- val = B4800;
-- break;
-- case 9600:
-- val = B9600;
-- break;
-- case 19200:
-- val = B19200;
-- break;
-- case 38400:
-- val = B38400;
-- break;
--#ifdef B57600
-- case 57600:
-- val = B57600;
-- break;
--#endif
--#ifdef B115200
-- case 115200:
-- val = B115200;
-- break;
--#endif
--#ifdef B230400
-- case 230400:
-- val = B230400;
-- break;
--#endif
--#ifdef B460800
-- case 460800:
-- val = B460800;
-- break;
--#endif
-- default:
-- return 0;
-- }
--
-- *def = val;
-- return 1;
--}
--
--/* {{{ dio_data_bits_to_define
-- * Converts a number of data bits to a termios define
-- */
--static int dio_data_bits_to_define(int data_bits, int *def) {
-- int val;
--
-- switch (data_bits) {
-- case 8:
-- val = CS8;
-- break;
-- case 7:
-- val = CS7;
-- break;
-- case 6:
-- val = CS6;
-- break;
-- case 5:
-- val = CS5;
-- break;
-- default:
-- return 0;
-- }
--
-- *def = val;
-- return 1;
--}
--/* }}} */
--
--/* {{{ dio_stop_bits_to_define
-- * Converts a number of stop bits to a termios define
-- */
--static int dio_stop_bits_to_define(int stop_bits, int *def) {
-- int val;
--
-- switch (stop_bits) {
-- case 1:
-- val = 0;
-- break;
-- case 2:
-- val = CSTOPB;
-- break;
-- default:
-- return 0;
-- }
--
-- *def = val;
-- return 1;
--}
--/* }}} */
--
--/* {{{ dio_parity_to_define
-- * Converts a parity type to a termios define
-- */
--static int dio_parity_to_define(int parity, int *def) {
-- int val;
--
-- switch (parity) {
-- case 0:
-- val = 0;
-- break;
-- case 1:
-- val = PARENB | PARODD;
-- break;
-- case 2:
-- val = PARENB;
-- break;
-- default:
-- return 0;
-- }
--
-- *def = val;
-- return 1;
--}
--/* }}} */
--
--/* {{{ dio_create_stream_data
-- * Creates an initialised stream data structure. Free with efree().
-- */
--php_dio_stream_data * dio_create_stream_data(void) {
-- php_dio_posix_stream_data * data = emalloc(sizeof(php_dio_posix_stream_data));
-- dio_init_stream_data(&(data->common));
-- data->fd = -1;
-- data->flags = 0;
--
-- return (php_dio_stream_data *)data;
--}
--/* }}} */
--
--/* {{{ dio_common_write
-- * Writes count chars from the buffer to the stream described by the stream data.
-- */
--size_t dio_common_write(php_dio_stream_data *data, const char *buf, size_t count) {
-- size_t ret;
--
-- /* Blocking writes can be interrupted by signals etc. If
-- * interrupted try again. Not sure about non-blocking
-- * writes but it doesn't hurt to check. */
-- do {
-- ret = write(((php_dio_posix_stream_data*)data)->fd, buf, count);
-- if (ret > 0) {
-- return ret;
-- }
-- } while (errno == EINTR);
-- return 0;
--}
--/* }}} */
--
--#ifdef DIO_NONBLOCK
--/* {{{ dio_timeval_subtract
-- * Calculates the difference between two timevals returning the result in the
-- * structure pointed to by diffptr. Returns -1 as error if late time is
-- * 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) {
-- return 0;
-- }
--
-- if ((late->tv_sec == early->tv_sec) && (late->tv_usec < early->tv_usec)) {
-- return 0;
-- }
--
-- /* Handle any carry. If later usec is smaller than earlier usec simple
-- * subtraction will result in negative value. Since usec has a maximum
-- * of one second by adding another second before the subtraction the
-- * result will always be positive. */
-- if (late->tv_usec < early->tv_usec) {
-- late->tv_usec += 1000000;
-- late->tv_sec--;
-- }
--
-- /* Once adjusted can just subtract values. */
-- diff->tv_sec = late->tv_sec - early->tv_sec;
-- diff->tv_usec = late->tv_usec - early->tv_usec;
--
-- return 1;
--}
--#endif
--
--/* {{{ dio_common_read
-- * Reads count chars to the buffer to the stream described by the stream data.
-- */
--size_t dio_common_read(php_dio_stream_data *data, const char *buf, size_t count) {
-- int fd = ((php_dio_posix_stream_data*)data)->fd;
-- size_t ret, total = 0;
-- char *ptr = (char*)buf;
--
-- struct timeval timeout, timeouttmp, before, after, diff;
-- fd_set rfds;
--
-- if (!data->has_timeout) {
-- /* Blocking reads can be interrupted by signals etc. If
-- * interrupted try again. Not sure about non-blocking
-- * reads but it doesn't hurt to check. */
-- do {
-- ret = read(fd, (char*)ptr, count);
-- if (ret > 0) {
-- return ret;
-- } else if (!ret) {
-- data->end_of_file = 1;
-- }
-- } while ((errno == EINTR) && !data->end_of_file);
-- return 0;
-- }
--#ifdef DIO_NONBLOCK
-- else {
-- /* Clear timed out flag */
-- data->timed_out = 0;
--
-- /* The initial timeout value */
-- timeout.tv_sec = data->timeout_sec;
-- timeout.tv_usec = data->timeout_usec;
--
-- do {
-- /* The semantics of select() are that you cannot guarantee
-- * that the timeval structure passed in has not been changed by
-- * the select call. So you keep a copy. */
-- timeouttmp = timeout;
--
-- /* The time before we wait for data. */
-- (void) gettimeofday(&before, NULL);
--
-- /* Wait for an event on our file descriptor. */
-- FD_ZERO(&rfds);
-- FD_SET(fd, &rfds);
--
-- ret = select(fd + 1, &rfds, NULL, NULL, &timeouttmp);
-- /* An error. */
-- if ((ret < 0) && (errno != EINTR) && (errno != EAGAIN)) {
-- return 0;
-- }
--
-- /* We have data to read. */
-- if ((ret > 0) && FD_ISSET(fd, &rfds)) {
-- ret = read(fd, ptr, count);
-- /* Another error */
-- if ((ret < 0) && (errno != EINTR) && (errno != EAGAIN)) {
-- return 0;
-- }
--
-- if (ret > 0) {
-- /* Got data, add it to the buffer. */
-- ptr += ret;
-- total += ret;
-- count -= ret;
-- } else if (!ret) {
-- /* This should never happen since how can we have
-- * data to read at an end of file, but still
-- * just in case! */
-- data->end_of_file = 1;
-- break;
-- }
-- }
--
-- /* If not timed out and not end of file and not all data read
-- * calculate how long it took us and loop if we still have time
-- * out time left. */
-- if (count) {
-- (void) gettimeofday(&after, NULL);
--
-- /* Diff the timevals */
-- (void) dio_timeval_subtract(&after, &before, &diff);
--
-- /* Now adjust the timeout. */
-- if (!dio_timeval_subtract(&timeout, &diff, &timeout)) {
-- /* If it errors we've run out of time. */
-- data->timed_out = 1;
-- break;
-- } else if (!timeout.tv_sec && !(timeout.tv_usec / 1000)) {
-- /* Check for rounding issues (millisecond accuracy) */
-- data->timed_out = 1;
-- break;
-- }
-- }
-- } while (count); /* Until time out or end of file or all data read. */
--
-- return total;
-- }
--#endif
--}
--/* }}} */
--
--/* {{{ php_dio_stream_data
-- * Closes the php_stream.
-- */
--int dio_common_close(php_dio_stream_data *data) {
-- if (close(((php_dio_posix_stream_data*)data)->fd) < 0) {
-- return 0;
-- }
--
-- return 1;
--}
--/* }}} */
--
--/* {{{ dio_common_set_option
-- * Sets/gets stream options
-- */
--int dio_common_set_option(php_dio_stream_data *data, int option, int value, void *ptrparam) {
-- int fd = ((php_dio_posix_stream_data*)data)->fd;
-- int old_is_blocking;
-- int flags;
--
-- switch (option) {
--#ifdef DIO_NONBLOCK
-- case PHP_STREAM_OPTION_READ_TIMEOUT:
-- if (ptrparam) {
-- struct timeval *tv = (struct timeval*)ptrparam;
--
-- flags = fcntl(fd, F_GETFL, 0);
--
-- /* A timeout of zero seconds and zero microseconds disables
-- any existing timeout. */
-- if (tv->tv_sec || tv->tv_usec) {
-- data->timeout_sec = tv->tv_sec;
-- data->timeout_usec = tv->tv_usec;
-- data->has_timeout = -1;
-- (void) fcntl(fd, F_SETFL, flags & ~DIO_NONBLOCK);
-- } else {
-- data->timeout_sec = 0;
-- data->timeout_usec = 0;
-- data->has_timeout = 0;
-- data->timed_out = 0;
-- (void) fcntl(fd, F_SETFL, flags | DIO_NONBLOCK);
-- }
--
-- return PHP_STREAM_OPTION_RETURN_OK;
-- } else {
-- return PHP_STREAM_OPTION_RETURN_ERR;
-- }
--
-- case PHP_STREAM_OPTION_BLOCKING:
-- flags = fcntl(fd, F_GETFL, 0);
-- if (value) {
-- flags &= ~DIO_NONBLOCK;
-- } else {
-- flags |= DIO_NONBLOCK;
-- }
-- (void) fcntl(fd, F_SETFL, flags);
--
-- old_is_blocking = data->is_blocking;
-- data->is_blocking = value;
-- return old_is_blocking ? PHP_STREAM_OPTION_RETURN_OK : PHP_STREAM_OPTION_RETURN_ERR;
--#endif /* O_NONBLOCK */
--
-- default:
-- break;
-- }
--
-- return 1;
--}
--/* }}} */
--
--/* {{{ dio_raw_open_stream
-- * Opens the underlying stream.
-- */
--int dio_raw_open_stream(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);
--
--#ifdef DIO_NONBLOCK
-- if (!data->is_blocking || data->has_timeout) {
-- pdata->flags |= DIO_NONBLOCK;
-- }
--#endif
--
-- /* Open the file and handle any errors. */
--#ifdef DIO_HAS_FILEPERMS
-- if (data->has_perms) {
-- pdata->fd = open(filename, pdata->flags, (mode_t)data->perms);
-- } else {
-- pdata->fd = open(filename, pdata->flags);
-- }
--#else
-- pdata->fd = open(filename, pdata->flags);
--#endif
--
-- if (pdata->fd < 0) {
-- switch (errno) {
-- case EEXIST:
-- php_error_docref(NULL TSRMLS_CC, E_WARNING, "File exists!");
-- return 0;
-- default:
-- return 0;
-- }
-- }
--
-- return 1;
--}
--/* }}} */
--
--/* {{{ 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) {
-- 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);
-- 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);
-- 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);
-- 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);
-- 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!");
-- }
-- return 0;
-- }
--
-- ret = tcgetattr(pdata->fd, &tio);
-- if (ret < 0) {
-- return 0;
-- }
--
-- if (data->canonical) {
-- tio.c_iflag = IGNPAR | ICRNL;
-- tio.c_oflag = 0;
-- tio.c_lflag = ICANON;
-- } else {
-- cfmakeraw(&tio);
-- }
--
-- cfsetispeed(&tio, rate_def);
-- cfsetospeed(&tio, rate_def);
--
-- tio.c_cflag &= ~CSIZE;
-- tio.c_cflag |= data_bits_def;
-- tio.c_cflag &= ~CSTOPB;
-- tio.c_cflag |= stop_bits_def;
-- tio.c_cflag &= ~(PARENB|PARODD);
-- tio.c_cflag |= parity_def;
--
--#ifdef CRTSCTS
-- tio.c_cflag &= ~(CLOCAL | CRTSCTS);
--#else
-- tio.c_cflag &= ~CLOCAL;
--#endif
-- if (!data->flow_control) {
-- tio.c_cflag |= CLOCAL;
--#ifdef CRTSCTS
-- } else {
-- tio.c_cflag |= CRTSCTS;
--#endif
-- }
--
-- ret = tcsetattr(pdata->fd, TCSANOW, &tio);
-- if (ret < 0) {
-- return 0;
-- }
--
-- return 1;
--}
--/* }}} */
--
--/* {{{ dio_serial_uninit
-- * Restores the serial settings back to their original state.
-- */
--int dio_serial_uninit(php_dio_stream_data *data) {
-- php_dio_posix_stream_data *pdata = (php_dio_posix_stream_data*)data;
-- int ret;
--
-- do {
-- ret = tcsetattr(pdata->fd, TCSANOW, &(pdata->oldtio));
-- } while ((ret < 0) && (errno == EINTR));
--
-- return 1;
--}
--/* }}} */
--
--/* {{{ dio_serial_flush
-- * Purges the serial buffers of data.
-- */
--int dio_serial_purge(php_dio_stream_data *data) {
-- php_dio_posix_stream_data *pdata = (php_dio_posix_stream_data*)data;
-- int ret;
--
-- if ((pdata->flags & O_RDWR) == O_RDWR) {
-- ret = tcflush(pdata->fd, TCIOFLUSH);
-- } else if ((pdata->flags & O_WRONLY) == O_WRONLY) {
-- ret = tcflush(pdata->fd, TCOFLUSH);
-- } else if ((pdata->flags & O_RDONLY) == O_RDONLY) {
-- ret = tcflush(pdata->fd, TCIFLUSH);
-- }
--
-- if (ret < 0) {
-- return 0;
-- }
--
-- return 1;
--}
--/* }}} */
--
--/* {{{ dio_serial_open_stream
-- * Opens the underlying stream.
-- */
--int dio_serial_open_stream(char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC) {
-- php_dio_posix_stream_data *pdata = (php_dio_posix_stream_data*)data;
--
--#ifdef O_NOCTTY
-- /* We don't want a controlling TTY */
-- pdata->flags |= O_NOCTTY;
--#endif
--
-- if (!dio_raw_open_stream(filename, mode, data TSRMLS_CC)) {
-- return 0;
-- }
--
-- if (!dio_serial_init(data TSRMLS_CC)) {
-- close(pdata->fd);
-- return 0;
-- }
--
-- return 1;
--}
--/* }}} */
--
--/*
-- * Local variables:
-- * c-basic-offset: 4
-- * tab-width: 4
-- * End:
-- * vim600: fdm=marker
-- * vim: sw=4 ts=4 noet
-- */
-+/* -+ +----------------------------------------------------------------------+ -+ | PHP Version 5 | -+ +----------------------------------------------------------------------+ -+ | Copyright (c) 2009 Melanie Rhianna Lewis | -+ +----------------------------------------------------------------------+ -+ | 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: Melanie Rhianna Lewis <cyberspice@php.net> | -+ +----------------------------------------------------------------------+ -+ */ -+ -+#ifdef HAVE_CONFIG_H -+#include "config.h" -+#endif -+ -+#include "php.h" -+ -+#include "php_dio_common.h" -+ -+/* {{{ dio_stream_mode_to_flags -+ * 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; -+ -+ switch(mode[ch++]) { -+ case 'r': -+ flags = 0; -+ break; -+ case 'w': -+ flags = O_TRUNC | O_CREAT; -+ break; -+ case 'a': -+ flags = O_APPEND | O_CREAT; -+ break; -+ case 'x': -+ flags = O_EXCL | O_CREAT; -+ break; -+ } -+ -+ if (mode[ch] != '+') { -+ bin = (mode[ch++] == 'b'); -+ } -+ -+ if (mode[ch] == '+') { -+ flags |= O_RDWR; -+ } else if (flags) { -+ flags |= O_WRONLY; -+ } else { -+ flags |= O_RDONLY; -+ } -+ -+#if defined(_O_TEXT) && defined(O_BINARY) -+ if (bin) { -+ flags |= O_BINARY; -+ } else { -+ flags |= _O_TEXT; -+ } -+#endif -+ -+ return flags; -+} -+/* }}} */ -+ -+/* {{{ dio_data_rate_to_define -+ * Converts a numeric data rate to a termios define -+ */ -+static int dio_data_rate_to_define(long rate, speed_t *def) { -+ speed_t val; -+ -+ switch (rate) { -+ case 0: -+ val = 0; -+ break; -+ case 50: -+ val = B50; -+ break; -+ case 75: -+ val = B75; -+ break; -+ case 110: -+ val = B110; -+ break; -+ case 134: -+ val = B134; -+ break; -+ case 150: -+ val = B150; -+ break; -+ case 200: -+ val = B200; -+ break; -+ case 300: -+ val = B300; -+ break; -+ case 600: -+ val = B600; -+ break; -+ case 1200: -+ val = B1200; -+ break; -+ case 1800: -+ val = B1800; -+ break; -+ case 2400: -+ val = B2400; -+ break; -+ case 4800: -+ val = B4800; -+ break; -+ case 9600: -+ val = B9600; -+ break; -+ case 19200: -+ val = B19200; -+ break; -+ case 38400: -+ val = B38400; -+ break; -+#ifdef B57600 -+ case 57600: -+ val = B57600; -+ break; -+#endif -+#ifdef B115200 -+ case 115200: -+ val = B115200; -+ break; -+#endif -+#ifdef B230400 -+ case 230400: -+ val = B230400; -+ break; -+#endif -+#ifdef B460800 -+ case 460800: -+ val = B460800; -+ break; -+#endif -+ default: -+ return 0; -+ } -+ -+ *def = val; -+ return 1; -+} -+ -+/* {{{ dio_data_bits_to_define -+ * Converts a number of data bits to a termios define -+ */ -+static int dio_data_bits_to_define(int data_bits, int *def) { -+ int val; -+ -+ switch (data_bits) { -+ case 8: -+ val = CS8; -+ break; -+ case 7: -+ val = CS7; -+ break; -+ case 6: -+ val = CS6; -+ break; -+ case 5: -+ val = CS5; -+ break; -+ default: -+ return 0; -+ } -+ -+ *def = val; -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ dio_stop_bits_to_define -+ * Converts a number of stop bits to a termios define -+ */ -+static int dio_stop_bits_to_define(int stop_bits, int *def) { -+ int val; -+ -+ switch (stop_bits) { -+ case 1: -+ val = 0; -+ break; -+ case 2: -+ val = CSTOPB; -+ break; -+ default: -+ return 0; -+ } -+ -+ *def = val; -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ dio_parity_to_define -+ * Converts a parity type to a termios define -+ */ -+static int dio_parity_to_define(int parity, int *def) { -+ int val; -+ -+ switch (parity) { -+ case 0: -+ val = 0; -+ break; -+ case 1: -+ val = PARENB | PARODD; -+ break; -+ case 2: -+ val = PARENB; -+ break; -+ default: -+ return 0; -+ } -+ -+ *def = val; -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ dio_create_stream_data -+ * Creates an initialised stream data structure. Free with efree(). -+ */ -+php_dio_stream_data * dio_create_stream_data(void) { -+ php_dio_posix_stream_data * data = emalloc(sizeof(php_dio_posix_stream_data)); -+ dio_init_stream_data(&(data->common)); -+ data->fd = -1; -+ data->flags = 0; -+ -+ return (php_dio_stream_data *)data; -+} -+/* }}} */ -+ -+/* {{{ dio_common_write -+ * Writes count chars from the buffer to the stream described by the stream data. -+ */ -+size_t dio_common_write(php_dio_stream_data *data, const char *buf, size_t count) { -+ size_t ret; -+ -+ /* Blocking writes can be interrupted by signals etc. If -+ * interrupted try again. Not sure about non-blocking -+ * writes but it doesn't hurt to check. */ -+ do { -+ ret = write(((php_dio_posix_stream_data*)data)->fd, buf, count); -+ if (ret > 0) { -+ return ret; -+ } -+ } while (errno == EINTR); -+ return 0; -+} -+/* }}} */ -+ -+#ifdef DIO_NONBLOCK -+/* {{{ dio_timeval_subtract -+ * Calculates the difference between two timevals returning the result in the -+ * structure pointed to by diffptr. Returns -1 as error if late time is -+ * 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) { -+ return 0; -+ } -+ -+ if ((late->tv_sec == early->tv_sec) && (late->tv_usec < early->tv_usec)) { -+ return 0; -+ } -+ -+ /* Handle any carry. If later usec is smaller than earlier usec simple -+ * subtraction will result in negative value. Since usec has a maximum -+ * of one second by adding another second before the subtraction the -+ * result will always be positive. */ -+ if (late->tv_usec < early->tv_usec) { -+ late->tv_usec += 1000000; -+ late->tv_sec--; -+ } -+ -+ /* Once adjusted can just subtract values. */ -+ diff->tv_sec = late->tv_sec - early->tv_sec; -+ diff->tv_usec = late->tv_usec - early->tv_usec; -+ -+ return 1; -+} -+#endif -+ -+/* {{{ dio_common_read -+ * Reads count chars to the buffer to the stream described by the stream data. -+ */ -+size_t dio_common_read(php_dio_stream_data *data, const char *buf, size_t count) { -+ int fd = ((php_dio_posix_stream_data*)data)->fd; -+ size_t ret, total = 0; -+ char *ptr = (char*)buf; -+ -+ struct timeval timeout, timeouttmp, before, after, diff; -+ fd_set rfds; -+ -+ if (!data->has_timeout) { -+ /* Blocking reads can be interrupted by signals etc. If -+ * interrupted try again. Not sure about non-blocking -+ * reads but it doesn't hurt to check. */ -+ do { -+ ret = read(fd, (char*)ptr, count); -+ if (ret > 0) { -+ return ret; -+ } else if (!ret) { -+ data->end_of_file = 1; -+ } -+ } while ((errno == EINTR) && !data->end_of_file); -+ return 0; -+ } -+#ifdef DIO_NONBLOCK -+ else { -+ /* Clear timed out flag */ -+ data->timed_out = 0; -+ -+ /* The initial timeout value */ -+ timeout.tv_sec = data->timeout_sec; -+ timeout.tv_usec = data->timeout_usec; -+ -+ do { -+ /* The semantics of select() are that you cannot guarantee -+ * that the timeval structure passed in has not been changed by -+ * the select call. So you keep a copy. */ -+ timeouttmp = timeout; -+ -+ /* The time before we wait for data. */ -+ (void) gettimeofday(&before, NULL); -+ -+ /* Wait for an event on our file descriptor. */ -+ FD_ZERO(&rfds); -+ FD_SET(fd, &rfds); -+ -+ ret = select(fd + 1, &rfds, NULL, NULL, &timeouttmp); -+ /* An error. */ -+ if ((ret < 0) && (errno != EINTR) && (errno != EAGAIN)) { -+ return 0; -+ } -+ -+ /* We have data to read. */ -+ if ((ret > 0) && FD_ISSET(fd, &rfds)) { -+ ret = read(fd, ptr, count); -+ /* Another error */ -+ if ((ret < 0) && (errno != EINTR) && (errno != EAGAIN)) { -+ return 0; -+ } -+ -+ if (ret > 0) { -+ /* Got data, add it to the buffer. */ -+ ptr += ret; -+ total += ret; -+ count -= ret; -+ } else if (!ret) { -+ /* This should never happen since how can we have -+ * data to read at an end of file, but still -+ * just in case! */ -+ data->end_of_file = 1; -+ break; -+ } -+ } -+ -+ /* If not timed out and not end of file and not all data read -+ * calculate how long it took us and loop if we still have time -+ * out time left. */ -+ if (count) { -+ (void) gettimeofday(&after, NULL); -+ -+ /* Diff the timevals */ -+ (void) dio_timeval_subtract(&after, &before, &diff); -+ -+ /* Now adjust the timeout. */ -+ if (!dio_timeval_subtract(&timeout, &diff, &timeout)) { -+ /* If it errors we've run out of time. */ -+ data->timed_out = 1; -+ break; -+ } else if (!timeout.tv_sec && !(timeout.tv_usec / 1000)) { -+ /* Check for rounding issues (millisecond accuracy) */ -+ data->timed_out = 1; -+ break; -+ } -+ } -+ } while (count); /* Until time out or end of file or all data read. */ -+ -+ return total; -+ } -+#endif -+} -+/* }}} */ -+ -+/* {{{ php_dio_stream_data -+ * Closes the php_stream. -+ */ -+int dio_common_close(php_dio_stream_data *data) { -+ if (close(((php_dio_posix_stream_data*)data)->fd) < 0) { -+ return 0; -+ } -+ -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ dio_common_set_option -+ * Sets/gets stream options -+ */ -+int dio_common_set_option(php_dio_stream_data *data, int option, int value, void *ptrparam) { -+ int fd = ((php_dio_posix_stream_data*)data)->fd; -+ int old_is_blocking; -+ int flags; -+ -+ switch (option) { -+#ifdef DIO_NONBLOCK -+ case PHP_STREAM_OPTION_READ_TIMEOUT: -+ if (ptrparam) { -+ struct timeval *tv = (struct timeval*)ptrparam; -+ -+ flags = fcntl(fd, F_GETFL, 0); -+ -+ /* A timeout of zero seconds and zero microseconds disables -+ any existing timeout. */ -+ if (tv->tv_sec || tv->tv_usec) { -+ data->timeout_sec = tv->tv_sec; -+ data->timeout_usec = tv->tv_usec; -+ data->has_timeout = -1; -+ (void) fcntl(fd, F_SETFL, flags & ~DIO_NONBLOCK); -+ } else { -+ data->timeout_sec = 0; -+ data->timeout_usec = 0; -+ data->has_timeout = 0; -+ data->timed_out = 0; -+ (void) fcntl(fd, F_SETFL, flags | DIO_NONBLOCK); -+ } -+ -+ return PHP_STREAM_OPTION_RETURN_OK; -+ } else { -+ return PHP_STREAM_OPTION_RETURN_ERR; -+ } -+ -+ case PHP_STREAM_OPTION_BLOCKING: -+ flags = fcntl(fd, F_GETFL, 0); -+ if (value) { -+ flags &= ~DIO_NONBLOCK; -+ } else { -+ flags |= DIO_NONBLOCK; -+ } -+ (void) fcntl(fd, F_SETFL, flags); -+ -+ old_is_blocking = data->is_blocking; -+ data->is_blocking = value; -+ return old_is_blocking ? PHP_STREAM_OPTION_RETURN_OK : PHP_STREAM_OPTION_RETURN_ERR; -+#endif /* O_NONBLOCK */ -+ -+ default: -+ break; -+ } -+ -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ dio_raw_open_stream -+ * Opens the underlying stream. -+ */ -+int dio_raw_open_stream(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); -+ -+#ifdef DIO_NONBLOCK -+ if (!data->is_blocking || data->has_timeout) { -+ pdata->flags |= DIO_NONBLOCK; -+ } -+#endif -+ -+ /* Open the file and handle any errors. */ -+#ifdef DIO_HAS_FILEPERMS -+ if (data->has_perms) { -+ pdata->fd = open(filename, pdata->flags, (mode_t)data->perms); -+ } else { -+ pdata->fd = open(filename, pdata->flags); -+ } -+#else -+ pdata->fd = open(filename, pdata->flags); -+#endif -+ -+ if (pdata->fd < 0) { -+ switch (errno) { -+ case EEXIST: -+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "File exists!"); -+ return 0; -+ default: -+ return 0; -+ } -+ } -+ -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ 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) { -+ 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); -+ 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); -+ 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); -+ 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); -+ 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!"); -+ } -+ return 0; -+ } -+ -+ ret = tcgetattr(pdata->fd, &tio); -+ if (ret < 0) { -+ return 0; -+ } -+ -+ if (data->canonical) { -+ tio.c_iflag = IGNPAR | ICRNL; -+ tio.c_oflag = 0; -+ tio.c_lflag = ICANON; -+ } else { -+ cfmakeraw(&tio); -+ } -+ -+ cfsetispeed(&tio, rate_def); -+ cfsetospeed(&tio, rate_def); -+ -+ tio.c_cflag &= ~CSIZE; -+ tio.c_cflag |= data_bits_def; -+ tio.c_cflag &= ~CSTOPB; -+ tio.c_cflag |= stop_bits_def; -+ tio.c_cflag &= ~(PARENB|PARODD); -+ tio.c_cflag |= parity_def; -+ -+#ifdef CRTSCTS -+ tio.c_cflag &= ~(CLOCAL | CRTSCTS); -+#else -+ tio.c_cflag &= ~CLOCAL; -+#endif -+ if (!data->flow_control) { -+ tio.c_cflag |= CLOCAL; -+#ifdef CRTSCTS -+ } else { -+ tio.c_cflag |= CRTSCTS; -+#endif -+ } -+ -+ ret = tcsetattr(pdata->fd, TCSANOW, &tio); -+ if (ret < 0) { -+ return 0; -+ } -+ -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ dio_serial_uninit -+ * Restores the serial settings back to their original state. -+ */ -+int dio_serial_uninit(php_dio_stream_data *data) { -+ php_dio_posix_stream_data *pdata = (php_dio_posix_stream_data*)data; -+ int ret; -+ -+ do { -+ ret = tcsetattr(pdata->fd, TCSANOW, &(pdata->oldtio)); -+ } while ((ret < 0) && (errno == EINTR)); -+ -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ dio_serial_flush -+ * Purges the serial buffers of data. -+ */ -+int dio_serial_purge(php_dio_stream_data *data) { -+ php_dio_posix_stream_data *pdata = (php_dio_posix_stream_data*)data; -+ int ret; -+ -+ if ((pdata->flags & O_RDWR) == O_RDWR) { -+ ret = tcflush(pdata->fd, TCIOFLUSH); -+ } else if ((pdata->flags & O_WRONLY) == O_WRONLY) { -+ ret = tcflush(pdata->fd, TCOFLUSH); -+ } else if ((pdata->flags & O_RDONLY) == O_RDONLY) { -+ ret = tcflush(pdata->fd, TCIFLUSH); -+ } -+ -+ if (ret < 0) { -+ return 0; -+ } -+ -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ dio_serial_open_stream -+ * Opens the underlying stream. -+ */ -+int dio_serial_open_stream(char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC) { -+ php_dio_posix_stream_data *pdata = (php_dio_posix_stream_data*)data; -+ -+#ifdef O_NOCTTY -+ /* We don't want a controlling TTY */ -+ pdata->flags |= O_NOCTTY; -+#endif -+ -+ if (!dio_raw_open_stream(filename, mode, data TSRMLS_CC)) { -+ return 0; -+ } -+ -+ if (!dio_serial_init(data TSRMLS_CC)) { -+ close(pdata->fd); -+ return 0; -+ } -+ -+ return 1; -+} -+/* }}} */ -+ -+/* -+ * Local variables: -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * End: -+ * vim600: fdm=marker -+ * vim: sw=4 ts=4 noet -+ */ ---- a/dio_win32.c -+++ b/dio_win32.c -@@ -1,759 +1,759 @@ --/*
-- +----------------------------------------------------------------------+
-- | PHP Version 5 |
-- +----------------------------------------------------------------------+
-- | Copyright (c) 2009 Melanie Rhianna Lewis |
-- +----------------------------------------------------------------------+
-- | 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: Melanie Rhianna Lewis <cyberspice@php.net> |
-- +----------------------------------------------------------------------+
-- */
--
--#ifdef HAVE_CONFIG_H
--#include "config.h"
--#endif
--
--#include "php.h"
--#include "php_dio_common.h"
--
--#ifndef ZEND_WIN32
--#error ZEND_WIN32 not defined!
--#endif
--
--/* {{{ 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) {
-- LPVOID msgbuf;
-- DWORD msgbuflen;
-- char * errmsg;
-- DWORD err;
--
--#ifdef UNICODE
-- DWORD errmsglen;
--#endif
--
-- err = GetLastError();
-- msgbuflen = FormatMessage(
-- FORMAT_MESSAGE_ALLOCATE_BUFFER|
-- FORMAT_MESSAGE_FROM_SYSTEM|
-- FORMAT_MESSAGE_IGNORE_INSERTS,
-- NULL,
-- err,
-- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-- (LPTSTR)&msgbuf,
-- 0,
-- NULL);
--
--#ifdef UNICODE
--
-- /* Get the length of the converted message */
-- errmsglen = WideCharToMultibyte(
-- CP_ACP,
-- 0
-- (LPCWSTR)msgbuf,
-- -1,
-- (LPSTR)errmsg,
-- 0,
-- NULL,
-- NULL);
--
-- /* 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()!");
-- LocalFree(msgbuf);
-- return;
-- }
--
-- /* Convert the message */
-- errmsglen = WideCharToMultibyte(
-- CP_ACP,
-- 0
-- (LPCWSTR)msgbuf,
-- -1,
-- (LPSTR)errmsg,
-- errmsglen,
-- NULL,
-- NULL);
--
--#else
-- errmsg = (char *)msgbuf;
--#endif
--
-- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s[ERROR %d] %s", message, err, errmsg);
--
-- LocalFree(msgbuf);
--#ifdef UNICODE
-- efree(errmsg);
--#endif
--}
--
--/* {{{ dio_data_rate_to_define
-- * Converts a numeric data rate to a termios define
-- */
--static int dio_data_rate_to_define(long rate, DWORD *def) {
-- switch (rate) {
-- case 75:
-- case 110:
-- case 134:
-- case 150:
-- case 300:
-- case 600:
-- case 1200:
-- case 1800:
-- case 2400:
-- case 4800:
-- case 7200:
-- case 9600:
-- case 14400:
-- case 19200:
-- case 38400:
-- case 57600:
-- case 115200:
-- case 56000:
-- case 128000:
-- case 256000:
-- break;
-- default:
-- return 0;
-- }
--
-- *def = (DWORD)rate;
-- return 1;
--}
--/* }}} */
--
--
--/* {{{ dio_data_bits_to_define
-- * Converts a number of data bits to a termios define
-- */
--static int dio_data_bits_to_define(int data_bits, DWORD *def) {
-- switch (data_bits) {
-- case 8:
-- case 7:
-- case 6:
-- case 5:
-- case 4:
-- break;
-- default:
-- return 0;
-- }
--
-- *def = (DWORD)data_bits;
-- return 1;
--}
--/* }}} */
--
--/* {{{ dio_stop_bits_to_define
-- * Converts a number of stop bits to a termios define
-- */
--static int dio_stop_bits_to_define(int stop_bits, DWORD *def) {
-- DWORD val;
--
-- switch (stop_bits) {
-- case 1:
-- val = ONESTOPBIT;
-- break;
-- case 2:
-- val = TWOSTOPBITS;
-- break;
-- case 3:
-- val = ONE5STOPBITS;
-- break;
-- default:
-- return 0;
-- }
--
-- *def = val;
-- return 1;
--}
--/* }}} */
--
--/* {{{ dio_parity_to_define
-- * Converts a parity type to a termios define
-- */
--static int dio_parity_to_define(int parity, DWORD *def) {
-- DWORD val;
--
-- switch (parity) {
-- case 0:
-- val = NOPARITY;
-- break;
-- case 1:
-- val = ODDPARITY;
-- break;
-- case 2:
-- val = EVENPARITY;
-- break;
-- default:
-- return 0;
-- }
--
-- *def = val;
-- return 1;
--}
--/* }}} */
--
--/* {{{ dio_create_stream_data
-- * Creates an initialised stream data structure. Free with efree().
-- */
--php_dio_stream_data * dio_create_stream_data(void) {
-- php_dio_win32_stream_data * data = emalloc(sizeof(php_dio_win32_stream_data));
-- memset(data, 0, sizeof(php_dio_win32_stream_data));
-- dio_init_stream_data(&(data->common));
-- data->handle = INVALID_HANDLE_VALUE;
-- data->desired_access = 0;
-- data->creation_disposition = 0;
-- data->olddcb.DCBlength = sizeof(DCB);
--
-- return (php_dio_stream_data *)data;
--}
--/* }}} */
--
--/* {{{ dio_common_write
-- * Writes count chars from the buffer to the stream described by the stream data.
-- */
--size_t dio_common_write(php_dio_stream_data *data, const char *buf, size_t count) {
-- php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data;
-- DWORD total = 0;
--
-- if (WriteFile(wdata->handle, buf, (DWORD)count, &total, NULL)) {
-- return (size_t)total;
-- }
--
-- return 0;
--}
--/* }}} */
--
--/* {{{ dio_buffer_read
-- * Reads any available chars from the canonical buffer.
-- */
--static size_t dio_buffer_read(php_dio_win32_stream_data *wdata, const char *buf, size_t count) {
-- php_dio_win32_canon_data *canon_data = wdata->canon_data;
-- size_t total = 0;
--
-- /* Read always follows write. I.e. if read ptr > write ptr buffer has
-- wrapped and so we need to copy two blocks of data. */
-- if (canon_data->read_pos > canon_data->write_pos) {
--
-- /* Check we actually need to copy both blocks */
-- if ((canon_data->size - canon_data->read_pos) > count) {
--
-- /* No we don't. Just copy as much as we were asked for. */
-- memcpy((char*)buf,
-- &(canon_data->buf[canon_data->read_pos]),
-- count);
-- /* Update the read pointer. */
-- canon_data->read_pos += count;
--
-- /* Return the amount read. */
-- return count;
-- } else {
--
-- /* We need to copy both blocks so copy data up to the end of
-- the buffer. */
-- total = canon_data->size - canon_data->read_pos;
-- memcpy((char*)buf,
-- &(canon_data->buf[canon_data->read_pos]),
-- total);
-- canon_data->read_pos = 0;
-- count -= total;
--
-- /* Now copy the data from the start of the buffer either up
-- count or the number of bytes in the buffer. */
--
-- if (canon_data->write_pos > count) {
-- memcpy((char*)buf, canon_data->buf, count);
-- canon_data->read_pos = count;
-- total += count;
--
-- return total;
-- } else {
-- memcpy((char*)buf, canon_data->buf, canon_data->write_pos);
-- canon_data->read_pos = canon_data->write_pos;
-- total += canon_data->write_pos;
--
-- return total;
-- }
-- }
--
-- /* Else if write follows read. This is a simpler case. We just copy
-- either all the data buffered or count, which ever is smaller. */
-- } else if (canon_data->write_pos > canon_data->read_pos) {
-- if ((canon_data->write_pos - canon_data->read_pos) > count) {
-- memcpy((char*)buf,
-- &(canon_data->buf[canon_data->read_pos]),
-- count);
-- canon_data->read_pos += count;
--
-- return count;
-- } else {
-- total = canon_data->write_pos - canon_data->read_pos;
-- memcpy((char*)buf,
-- &(canon_data->buf[canon_data->read_pos]),
-- total);
-- canon_data->read_pos += total;
--
-- return total;
-- }
-- }
--
-- /* Else we need to read more data from the data port. */
-- return 0;
--}
--
--/* {{{ dio_com_read
-- * Read chars from the data port.
-- */
--static size_t dio_com_read(php_dio_stream_data *data, const char *buf, size_t count) {
-- php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data;
-- DWORD err, total = 0;
--
-- if (ReadFile(wdata->handle, (void*)buf, (DWORD)count, &total, NULL)) {
--
-- if (total) {
-- return (size_t)total;
-- }
--
-- data->end_of_file = 1;
-- }
--
-- if (!data->end_of_file) {
-- err = GetLastError();
--
-- if (ERROR_HANDLE_EOF == err) {
-- data->end_of_file = 1;
-- }
-- }
--
-- return 0;
--}
--
--/* {{{ dio_canonical_read
-- * Reads chars from the input stream until the internal buffer is full or a new
-- * line is reached.
-- */
--static size_t dio_canonical_read(php_dio_win32_stream_data *wdata, const char *buf, size_t count) {
-- php_dio_win32_canon_data *canon_data = wdata->canon_data;
-- size_t total = 0;
-- char ch;
--
-- /* See if there's any buffered data and copy it. */
-- total = dio_buffer_read(wdata, buf, count);
-- if (total) {
-- return total;
-- }
--
-- /* Need to read more data from the data port. Buffer should be empty(er)
-- by now. */
-- do {
-- /* Is the buffer full? */
-- if (((canon_data->write_pos + 1) % canon_data->size) ==
-- canon_data->read_pos) {
-- break;
-- }
--
-- /* Read a byte from the input checking for EOF. */
-- if (!dio_com_read((php_dio_stream_data*)wdata, &ch, 1)) {
-- break;
-- }
--
-- /* Translate CR to newlines (same as ICRNL in POSIX) */
-- ch = (ch != '\r') ? ch : '\n';
--
-- /* We read a character! So buffer it. */
-- canon_data->buf[canon_data->write_pos++] = ch;
-- if (canon_data->write_pos >= canon_data->size) {
-- canon_data->write_pos = 0;
-- }
--
-- /* End of line/input (^D)? */
-- } while ((ch != '\n') && (ch != 0x04));
--
-- return dio_buffer_read(wdata, buf, count);
--}
--/* }}} */
--
--/* {{{ dio_common_read
-- * Reads count chars to the buffer to the stream described by the stream data.
-- */
--size_t dio_common_read(php_dio_stream_data *data, const char *buf, size_t count) {
--
-- /* You ask for no bytes you'll get none :-) */
-- if (!count) {
-- return 0;
-- }
--
-- if (data->canonical) {
-- return dio_canonical_read((php_dio_win32_stream_data*)data, buf, count);
-- } else {
-- return dio_com_read(data, buf, count);
-- }
--}
--/* }}} */
--
--/* {{{ php_dio_stream_data
-- * Closes the php_stream.
-- */
--int dio_common_close(php_dio_stream_data *data) {
-- php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data;
--
-- if (data->canonical) {
-- efree(wdata->canon_data);
-- }
--
-- if (!CloseHandle(wdata->handle)) {
-- return 0;
-- }
--
-- return 1;
--}
--/* }}} */
--
--/* {{{ dio_common_set_option
-- * Sets/gets stream options
-- */
--int dio_common_set_option(php_dio_stream_data *data, int option, int value, void *ptrparam) {
-- COMMTIMEOUTS cto = { 0, 0, 0, 0, 0 };
-- int old_is_blocking = 0;
--
-- /* Can't do timeouts or non blocking with raw windows streams :-( */
-- if (DIO_STREAM_TYPE_SERIAL == data->stream_type) {
-- switch (option) {
-- case PHP_STREAM_OPTION_BLOCKING:
-- old_is_blocking = data->is_blocking;
-- data->is_blocking = value ? 1 : 0;
--
-- /* Only change values if we need to change them. */
-- if (data->is_blocking != old_is_blocking) {
-- /* If we're not blocking but don't have a timeout
-- set to return immediately */
-- if (!data->is_blocking && !data->has_timeout) {
-- cto.ReadIntervalTimeout = MAXDWORD;
-- }
--
-- /* If we have a timeout ignore the blocking and set
-- the total time in which to read the data */
-- if (data->has_timeout) {
-- cto.ReadIntervalTimeout = MAXDWORD;
-- cto.ReadTotalTimeoutMultiplier = MAXDWORD;
-- cto.ReadTotalTimeoutConstant = (data->timeout_usec / 1000) +
-- (data->timeout_sec * 1000);
-- }
--
-- if (!SetCommTimeouts(((php_dio_win32_stream_data*)data)->handle, &cto)) {
-- return PHP_STREAM_OPTION_RETURN_ERR;
-- }
-- }
-- return old_is_blocking ? PHP_STREAM_OPTION_RETURN_OK : PHP_STREAM_OPTION_RETURN_ERR;
--
-- case PHP_STREAM_OPTION_READ_TIMEOUT:
-- if (ptrparam) {
-- /* struct timeval is supported with PHP_WIN32 defined. */
-- struct timeval *tv = (struct timeval*)ptrparam;
--
-- /* A timeout of zero seconds and zero microseconds disables
-- any existing timeout. */
-- if (tv->tv_sec || tv->tv_usec) {
-- data->timeout_sec = tv->tv_sec;
-- data->timeout_usec = tv->tv_usec;
-- data->has_timeout = -1;
--
-- cto.ReadIntervalTimeout = MAXDWORD;
-- cto.ReadTotalTimeoutMultiplier = MAXDWORD;
-- cto.ReadTotalTimeoutConstant = (data->timeout_usec / 1000) +
-- (data->timeout_sec * 1000);
-- } else {
-- data->timeout_sec = 0;
-- data->timeout_usec = 0;
-- data->has_timeout = 0;
-- data->timed_out = 0;
--
-- /* If we're not blocking but don't have a timeout
-- set to return immediately */
-- if (!data->is_blocking) {
-- cto.ReadIntervalTimeout = MAXDWORD;
-- }
-- }
--
-- if (!SetCommTimeouts(((php_dio_win32_stream_data*)data)->handle, &cto)) {
-- return PHP_STREAM_OPTION_RETURN_ERR;
-- } else {
-- return PHP_STREAM_OPTION_RETURN_OK;
-- }
-- } else {
-- return PHP_STREAM_OPTION_RETURN_ERR;
-- }
--
-- default:
-- break;
-- }
-- }
--
-- return 1;
--}
--/* }}} */
--
--/* {{{ dio_raw_open_stream
-- * Opens the underlying stream.
-- */
--int dio_raw_open_stream(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;
--
-- switch(*mode) {
-- case 'r':
-- wdata->creation_disposition = OPEN_EXISTING;
-- break;
-- case 'w':
-- wdata->creation_disposition = TRUNCATE_EXISTING;
-- break;
-- case 'a':
-- wdata->creation_disposition = OPEN_ALWAYS;
-- break;
-- case 'x':
-- wdata->creation_disposition = CREATE_NEW;
-- break;
-- }
-- mode ++;
--
-- if (*mode && (*mode != '+')) {
-- mode++;
-- }
--
-- if (*mode && (*mode == '+')) {
-- wdata->desired_access = GENERIC_READ | GENERIC_WRITE;
-- } else if (OPEN_EXISTING == wdata->creation_disposition) {
-- wdata->desired_access = GENERIC_READ;
-- } else {
-- wdata->desired_access = GENERIC_WRITE;
-- }
--
-- wdata->handle = CreateFile(filename, wdata->desired_access, 0,
-- NULL, wdata->creation_disposition, FILE_ATTRIBUTE_NORMAL, NULL);
-- if (INVALID_HANDLE_VALUE == wdata->handle) {
-- err = GetLastError();
-- switch (err) {
-- case ERROR_FILE_EXISTS:
-- php_error_docref(NULL TSRMLS_CC, 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!");
--
-- 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);
-- return 0;
-- }
-- } else {
-- php_error_docref(NULL TSRMLS_CC, E_WARNING, "File not found!");
-- return 0;
-- }
-- break;
--
-- default:
-- dio_last_error_php_error(E_WARNING, "CreateFile() failed:" TSRMLS_CC);
-- return 0;
-- }
-- }
--
-- /* If canonical allocate the canonical buffer. */
-- if (data->canonical) {
-- wdata->canon_data = emalloc(sizeof(php_dio_win32_canon_data));
-- memset(wdata->canon_data, 0, sizeof(php_dio_win32_canon_data));
-- wdata->canon_data->size = DIO_WIN32_CANON_BUF_SIZE;
-- }
--
-- return 1;
--}
--/* }}} */
--
--/* {{{ dio_serial_init
-- * Initialises the serial port
-- */
--static int dio_serial_init(php_dio_stream_data *data TSRMLS_DC) {
-- 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);
-- 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);
-- 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);
-- 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);
-- return 0;
-- }
--
-- if (!GetCommState(wdata->handle, &(wdata->olddcb))) {
-- dio_last_error_php_error(E_WARNING, "GetCommState() failed:" TSRMLS_CC);
-- return 0;
-- }
--
-- /* Init the DCB structure */
-- memset(&dcb, 0, sizeof(DCB));
-- dcb.DCBlength = sizeof(DCB);
--
-- /* Set the communication parameters */
-- dcb.fBinary = 1;
-- dcb.BaudRate = rate_def;
-- dcb.ByteSize = (BYTE)data_bits_def;
-- dcb.StopBits = (BYTE)stop_bits_def;
-- dcb.Parity = (BYTE)parity_def;
--
-- /* Set the control line parameters */
-- dcb.fDtrControl = DTR_CONTROL_DISABLE;
-- dcb.fDsrSensitivity = FALSE;
-- dcb.fOutxDsrFlow = FALSE;
-- dcb.fTXContinueOnXoff = FALSE;
-- dcb.fOutX = FALSE;
-- dcb.fInX = FALSE;
-- dcb.fErrorChar = FALSE;
-- dcb.fNull = FALSE;
-- dcb.fAbortOnError = FALSE;
--
-- /* Hardware flow control */
-- if (data->flow_control) {
-- dcb.fOutxCtsFlow = TRUE;
-- dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
-- } else {
-- dcb.fOutxCtsFlow = FALSE;
-- dcb.fRtsControl = RTS_CONTROL_DISABLE;
-- }
--
-- if (!SetCommState(wdata->handle, &dcb)) {
-- dio_last_error_php_error(E_WARNING, "SetCommState() failed:" TSRMLS_CC);
-- return 0;
-- }
--
-- return 1;
--}
--/* }}} */
--
--
--/* {{{ dio_serial_uninit
-- * Restores the serial settings back to their original state.
-- */
--int dio_serial_uninit(php_dio_stream_data *data) {
-- php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data;
--
-- if (!SetCommState(wdata->handle, &(wdata->olddcb))) {
-- return 0;
-- }
--
-- return 1;
--}
--/* }}} */
--
--/* {{{ dio_serial_flush
-- * Purges the serial buffers of data.
-- */
--int dio_serial_purge(php_dio_stream_data *data) {
-- php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data;
-- BOOL ret;
--
-- /* Purge the canonical buffer if required */
-- if (data->canonical && ((wdata->desired_access & GENERIC_READ) == GENERIC_READ)) {
-- wdata->canon_data->read_pos = 0;
-- wdata->canon_data->write_pos = 0;
-- }
--
-- /* Purge the com port */
-- if ((wdata->desired_access & (GENERIC_READ|GENERIC_WRITE)) == (GENERIC_READ|GENERIC_WRITE)) {
-- ret = PurgeComm(wdata->handle, PURGE_RXCLEAR|PURGE_TXCLEAR);
-- } else if ((wdata->desired_access & GENERIC_WRITE) == GENERIC_WRITE) {
-- ret = PurgeComm(wdata->handle, PURGE_TXCLEAR);
-- } else if ((wdata->desired_access & GENERIC_READ) == GENERIC_READ) {
-- ret = PurgeComm(wdata->handle, PURGE_RXCLEAR);
-- }
--
-- return ret;
--}
--/* }}} */
--
--/* {{{ dio_serial_open_stream
-- * Opens the underlying stream.
-- */
--int dio_serial_open_stream(char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC) {
-- 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);
--
-- if (*mode != 'r') {
-- php_error_docref(NULL TSRMLS_CC, 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)) {
-- return 0;
-- }
--
-- if (!GetCommTimeouts(wdata->handle, &(wdata->oldcto))) {
-- dio_last_error_php_error(E_WARNING, "GetCommTimeouts() failed (Not a comm port?):" TSRMLS_CC);
-- CloseHandle(wdata->handle);
-- return 0;
-- }
--
-- /* If we're not blocking but don't have a timeout
-- set to return immediately */
-- if (!data->is_blocking && !data->has_timeout) {
-- cto.ReadIntervalTimeout = MAXDWORD;
-- }
--
-- /* If we have a timeout ignore the blocking and set
-- the total time in which to read the data */
-- if (data->has_timeout) {
-- cto.ReadIntervalTimeout = MAXDWORD;
-- cto.ReadTotalTimeoutMultiplier = MAXDWORD;
-- cto.ReadTotalTimeoutConstant = (data->timeout_usec / 1000) +
-- (data->timeout_sec * 1000);
-- }
--
-- if (!SetCommTimeouts(wdata->handle, &cto)) {
-- dio_last_error_php_error(E_WARNING, "SetCommTimeouts() failed:" TSRMLS_CC);
-- CloseHandle(wdata->handle);
-- return 0;
-- }
--
-- if (!dio_serial_init(data TSRMLS_CC)) {
-- CloseHandle(wdata->handle);
-- return 0;
-- }
--
-- return 1;
--}
--/* }}} */
--
--/*
-- * Local variables:
-- * c-basic-offset: 4
-- * tab-width: 4
-- * End:
-- * vim600: fdm=marker
-- * vim: sw=4 ts=4 noet
-- */
-+/* -+ +----------------------------------------------------------------------+ -+ | PHP Version 5 | -+ +----------------------------------------------------------------------+ -+ | Copyright (c) 2009 Melanie Rhianna Lewis | -+ +----------------------------------------------------------------------+ -+ | 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: Melanie Rhianna Lewis <cyberspice@php.net> | -+ +----------------------------------------------------------------------+ -+ */ -+ -+#ifdef HAVE_CONFIG_H -+#include "config.h" -+#endif -+ -+#include "php.h" -+#include "php_dio_common.h" -+ -+#ifndef ZEND_WIN32 -+#error ZEND_WIN32 not defined! -+#endif -+ -+/* {{{ 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) { -+ LPVOID msgbuf; -+ DWORD msgbuflen; -+ char * errmsg; -+ DWORD err; -+ -+#ifdef UNICODE -+ DWORD errmsglen; -+#endif -+ -+ err = GetLastError(); -+ msgbuflen = FormatMessage( -+ FORMAT_MESSAGE_ALLOCATE_BUFFER| -+ FORMAT_MESSAGE_FROM_SYSTEM| -+ FORMAT_MESSAGE_IGNORE_INSERTS, -+ NULL, -+ err, -+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), -+ (LPTSTR)&msgbuf, -+ 0, -+ NULL); -+ -+#ifdef UNICODE -+ -+ /* Get the length of the converted message */ -+ errmsglen = WideCharToMultibyte( -+ CP_ACP, -+ 0 -+ (LPCWSTR)msgbuf, -+ -1, -+ (LPSTR)errmsg, -+ 0, -+ NULL, -+ NULL); -+ -+ /* 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()!"); -+ LocalFree(msgbuf); -+ return; -+ } -+ -+ /* Convert the message */ -+ errmsglen = WideCharToMultibyte( -+ CP_ACP, -+ 0 -+ (LPCWSTR)msgbuf, -+ -1, -+ (LPSTR)errmsg, -+ errmsglen, -+ NULL, -+ NULL); -+ -+#else -+ errmsg = (char *)msgbuf; -+#endif -+ -+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s[ERROR %d] %s", message, err, errmsg); -+ -+ LocalFree(msgbuf); -+#ifdef UNICODE -+ efree(errmsg); -+#endif -+} -+ -+/* {{{ dio_data_rate_to_define -+ * Converts a numeric data rate to a termios define -+ */ -+static int dio_data_rate_to_define(long rate, DWORD *def) { -+ switch (rate) { -+ case 75: -+ case 110: -+ case 134: -+ case 150: -+ case 300: -+ case 600: -+ case 1200: -+ case 1800: -+ case 2400: -+ case 4800: -+ case 7200: -+ case 9600: -+ case 14400: -+ case 19200: -+ case 38400: -+ case 57600: -+ case 115200: -+ case 56000: -+ case 128000: -+ case 256000: -+ break; -+ default: -+ return 0; -+ } -+ -+ *def = (DWORD)rate; -+ return 1; -+} -+/* }}} */ -+ -+ -+/* {{{ dio_data_bits_to_define -+ * Converts a number of data bits to a termios define -+ */ -+static int dio_data_bits_to_define(int data_bits, DWORD *def) { -+ switch (data_bits) { -+ case 8: -+ case 7: -+ case 6: -+ case 5: -+ case 4: -+ break; -+ default: -+ return 0; -+ } -+ -+ *def = (DWORD)data_bits; -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ dio_stop_bits_to_define -+ * Converts a number of stop bits to a termios define -+ */ -+static int dio_stop_bits_to_define(int stop_bits, DWORD *def) { -+ DWORD val; -+ -+ switch (stop_bits) { -+ case 1: -+ val = ONESTOPBIT; -+ break; -+ case 2: -+ val = TWOSTOPBITS; -+ break; -+ case 3: -+ val = ONE5STOPBITS; -+ break; -+ default: -+ return 0; -+ } -+ -+ *def = val; -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ dio_parity_to_define -+ * Converts a parity type to a termios define -+ */ -+static int dio_parity_to_define(int parity, DWORD *def) { -+ DWORD val; -+ -+ switch (parity) { -+ case 0: -+ val = NOPARITY; -+ break; -+ case 1: -+ val = ODDPARITY; -+ break; -+ case 2: -+ val = EVENPARITY; -+ break; -+ default: -+ return 0; -+ } -+ -+ *def = val; -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ dio_create_stream_data -+ * Creates an initialised stream data structure. Free with efree(). -+ */ -+php_dio_stream_data * dio_create_stream_data(void) { -+ php_dio_win32_stream_data * data = emalloc(sizeof(php_dio_win32_stream_data)); -+ memset(data, 0, sizeof(php_dio_win32_stream_data)); -+ dio_init_stream_data(&(data->common)); -+ data->handle = INVALID_HANDLE_VALUE; -+ data->desired_access = 0; -+ data->creation_disposition = 0; -+ data->olddcb.DCBlength = sizeof(DCB); -+ -+ return (php_dio_stream_data *)data; -+} -+/* }}} */ -+ -+/* {{{ dio_common_write -+ * Writes count chars from the buffer to the stream described by the stream data. -+ */ -+size_t dio_common_write(php_dio_stream_data *data, const char *buf, size_t count) { -+ php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data; -+ DWORD total = 0; -+ -+ if (WriteFile(wdata->handle, buf, (DWORD)count, &total, NULL)) { -+ return (size_t)total; -+ } -+ -+ return 0; -+} -+/* }}} */ -+ -+/* {{{ dio_buffer_read -+ * Reads any available chars from the canonical buffer. -+ */ -+static size_t dio_buffer_read(php_dio_win32_stream_data *wdata, const char *buf, size_t count) { -+ php_dio_win32_canon_data *canon_data = wdata->canon_data; -+ size_t total = 0; -+ -+ /* Read always follows write. I.e. if read ptr > write ptr buffer has -+ wrapped and so we need to copy two blocks of data. */ -+ if (canon_data->read_pos > canon_data->write_pos) { -+ -+ /* Check we actually need to copy both blocks */ -+ if ((canon_data->size - canon_data->read_pos) > count) { -+ -+ /* No we don't. Just copy as much as we were asked for. */ -+ memcpy((char*)buf, -+ &(canon_data->buf[canon_data->read_pos]), -+ count); -+ /* Update the read pointer. */ -+ canon_data->read_pos += count; -+ -+ /* Return the amount read. */ -+ return count; -+ } else { -+ -+ /* We need to copy both blocks so copy data up to the end of -+ the buffer. */ -+ total = canon_data->size - canon_data->read_pos; -+ memcpy((char*)buf, -+ &(canon_data->buf[canon_data->read_pos]), -+ total); -+ canon_data->read_pos = 0; -+ count -= total; -+ -+ /* Now copy the data from the start of the buffer either up -+ count or the number of bytes in the buffer. */ -+ -+ if (canon_data->write_pos > count) { -+ memcpy((char*)buf, canon_data->buf, count); -+ canon_data->read_pos = count; -+ total += count; -+ -+ return total; -+ } else { -+ memcpy((char*)buf, canon_data->buf, canon_data->write_pos); -+ canon_data->read_pos = canon_data->write_pos; -+ total += canon_data->write_pos; -+ -+ return total; -+ } -+ } -+ -+ /* Else if write follows read. This is a simpler case. We just copy -+ either all the data buffered or count, which ever is smaller. */ -+ } else if (canon_data->write_pos > canon_data->read_pos) { -+ if ((canon_data->write_pos - canon_data->read_pos) > count) { -+ memcpy((char*)buf, -+ &(canon_data->buf[canon_data->read_pos]), -+ count); -+ canon_data->read_pos += count; -+ -+ return count; -+ } else { -+ total = canon_data->write_pos - canon_data->read_pos; -+ memcpy((char*)buf, -+ &(canon_data->buf[canon_data->read_pos]), -+ total); -+ canon_data->read_pos += total; -+ -+ return total; -+ } -+ } -+ -+ /* Else we need to read more data from the data port. */ -+ return 0; -+} -+ -+/* {{{ dio_com_read -+ * Read chars from the data port. -+ */ -+static size_t dio_com_read(php_dio_stream_data *data, const char *buf, size_t count) { -+ php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data; -+ DWORD err, total = 0; -+ -+ if (ReadFile(wdata->handle, (void*)buf, (DWORD)count, &total, NULL)) { -+ -+ if (total) { -+ return (size_t)total; -+ } -+ -+ data->end_of_file = 1; -+ } -+ -+ if (!data->end_of_file) { -+ err = GetLastError(); -+ -+ if (ERROR_HANDLE_EOF == err) { -+ data->end_of_file = 1; -+ } -+ } -+ -+ return 0; -+} -+ -+/* {{{ dio_canonical_read -+ * Reads chars from the input stream until the internal buffer is full or a new -+ * line is reached. -+ */ -+static size_t dio_canonical_read(php_dio_win32_stream_data *wdata, const char *buf, size_t count) { -+ php_dio_win32_canon_data *canon_data = wdata->canon_data; -+ size_t total = 0; -+ char ch; -+ -+ /* See if there's any buffered data and copy it. */ -+ total = dio_buffer_read(wdata, buf, count); -+ if (total) { -+ return total; -+ } -+ -+ /* Need to read more data from the data port. Buffer should be empty(er) -+ by now. */ -+ do { -+ /* Is the buffer full? */ -+ if (((canon_data->write_pos + 1) % canon_data->size) == -+ canon_data->read_pos) { -+ break; -+ } -+ -+ /* Read a byte from the input checking for EOF. */ -+ if (!dio_com_read((php_dio_stream_data*)wdata, &ch, 1)) { -+ break; -+ } -+ -+ /* Translate CR to newlines (same as ICRNL in POSIX) */ -+ ch = (ch != '\r') ? ch : '\n'; -+ -+ /* We read a character! So buffer it. */ -+ canon_data->buf[canon_data->write_pos++] = ch; -+ if (canon_data->write_pos >= canon_data->size) { -+ canon_data->write_pos = 0; -+ } -+ -+ /* End of line/input (^D)? */ -+ } while ((ch != '\n') && (ch != 0x04)); -+ -+ return dio_buffer_read(wdata, buf, count); -+} -+/* }}} */ -+ -+/* {{{ dio_common_read -+ * Reads count chars to the buffer to the stream described by the stream data. -+ */ -+size_t dio_common_read(php_dio_stream_data *data, const char *buf, size_t count) { -+ -+ /* You ask for no bytes you'll get none :-) */ -+ if (!count) { -+ return 0; -+ } -+ -+ if (data->canonical) { -+ return dio_canonical_read((php_dio_win32_stream_data*)data, buf, count); -+ } else { -+ return dio_com_read(data, buf, count); -+ } -+} -+/* }}} */ -+ -+/* {{{ php_dio_stream_data -+ * Closes the php_stream. -+ */ -+int dio_common_close(php_dio_stream_data *data) { -+ php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data; -+ -+ if (data->canonical) { -+ efree(wdata->canon_data); -+ } -+ -+ if (!CloseHandle(wdata->handle)) { -+ return 0; -+ } -+ -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ dio_common_set_option -+ * Sets/gets stream options -+ */ -+int dio_common_set_option(php_dio_stream_data *data, int option, int value, void *ptrparam) { -+ COMMTIMEOUTS cto = { 0, 0, 0, 0, 0 }; -+ int old_is_blocking = 0; -+ -+ /* Can't do timeouts or non blocking with raw windows streams :-( */ -+ if (DIO_STREAM_TYPE_SERIAL == data->stream_type) { -+ switch (option) { -+ case PHP_STREAM_OPTION_BLOCKING: -+ old_is_blocking = data->is_blocking; -+ data->is_blocking = value ? 1 : 0; -+ -+ /* Only change values if we need to change them. */ -+ if (data->is_blocking != old_is_blocking) { -+ /* If we're not blocking but don't have a timeout -+ set to return immediately */ -+ if (!data->is_blocking && !data->has_timeout) { -+ cto.ReadIntervalTimeout = MAXDWORD; -+ } -+ -+ /* If we have a timeout ignore the blocking and set -+ the total time in which to read the data */ -+ if (data->has_timeout) { -+ cto.ReadIntervalTimeout = MAXDWORD; -+ cto.ReadTotalTimeoutMultiplier = MAXDWORD; -+ cto.ReadTotalTimeoutConstant = (data->timeout_usec / 1000) + -+ (data->timeout_sec * 1000); -+ } -+ -+ if (!SetCommTimeouts(((php_dio_win32_stream_data*)data)->handle, &cto)) { -+ return PHP_STREAM_OPTION_RETURN_ERR; -+ } -+ } -+ return old_is_blocking ? PHP_STREAM_OPTION_RETURN_OK : PHP_STREAM_OPTION_RETURN_ERR; -+ -+ case PHP_STREAM_OPTION_READ_TIMEOUT: -+ if (ptrparam) { -+ /* struct timeval is supported with PHP_WIN32 defined. */ -+ struct timeval *tv = (struct timeval*)ptrparam; -+ -+ /* A timeout of zero seconds and zero microseconds disables -+ any existing timeout. */ -+ if (tv->tv_sec || tv->tv_usec) { -+ data->timeout_sec = tv->tv_sec; -+ data->timeout_usec = tv->tv_usec; -+ data->has_timeout = -1; -+ -+ cto.ReadIntervalTimeout = MAXDWORD; -+ cto.ReadTotalTimeoutMultiplier = MAXDWORD; -+ cto.ReadTotalTimeoutConstant = (data->timeout_usec / 1000) + -+ (data->timeout_sec * 1000); -+ } else { -+ data->timeout_sec = 0; -+ data->timeout_usec = 0; -+ data->has_timeout = 0; -+ data->timed_out = 0; -+ -+ /* If we're not blocking but don't have a timeout -+ set to return immediately */ -+ if (!data->is_blocking) { -+ cto.ReadIntervalTimeout = MAXDWORD; -+ } -+ } -+ -+ if (!SetCommTimeouts(((php_dio_win32_stream_data*)data)->handle, &cto)) { -+ return PHP_STREAM_OPTION_RETURN_ERR; -+ } else { -+ return PHP_STREAM_OPTION_RETURN_OK; -+ } -+ } else { -+ return PHP_STREAM_OPTION_RETURN_ERR; -+ } -+ -+ default: -+ break; -+ } -+ } -+ -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ dio_raw_open_stream -+ * Opens the underlying stream. -+ */ -+int dio_raw_open_stream(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; -+ -+ switch(*mode) { -+ case 'r': -+ wdata->creation_disposition = OPEN_EXISTING; -+ break; -+ case 'w': -+ wdata->creation_disposition = TRUNCATE_EXISTING; -+ break; -+ case 'a': -+ wdata->creation_disposition = OPEN_ALWAYS; -+ break; -+ case 'x': -+ wdata->creation_disposition = CREATE_NEW; -+ break; -+ } -+ mode ++; -+ -+ if (*mode && (*mode != '+')) { -+ mode++; -+ } -+ -+ if (*mode && (*mode == '+')) { -+ wdata->desired_access = GENERIC_READ | GENERIC_WRITE; -+ } else if (OPEN_EXISTING == wdata->creation_disposition) { -+ wdata->desired_access = GENERIC_READ; -+ } else { -+ wdata->desired_access = GENERIC_WRITE; -+ } -+ -+ wdata->handle = CreateFile(filename, wdata->desired_access, 0, -+ NULL, wdata->creation_disposition, FILE_ATTRIBUTE_NORMAL, NULL); -+ if (INVALID_HANDLE_VALUE == wdata->handle) { -+ err = GetLastError(); -+ switch (err) { -+ case ERROR_FILE_EXISTS: -+ php_error_docref(NULL TSRMLS_CC, 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!"); -+ -+ 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); -+ return 0; -+ } -+ } else { -+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "File not found!"); -+ return 0; -+ } -+ break; -+ -+ default: -+ dio_last_error_php_error(E_WARNING, "CreateFile() failed:" TSRMLS_CC); -+ return 0; -+ } -+ } -+ -+ /* If canonical allocate the canonical buffer. */ -+ if (data->canonical) { -+ wdata->canon_data = emalloc(sizeof(php_dio_win32_canon_data)); -+ memset(wdata->canon_data, 0, sizeof(php_dio_win32_canon_data)); -+ wdata->canon_data->size = DIO_WIN32_CANON_BUF_SIZE; -+ } -+ -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ dio_serial_init -+ * Initialises the serial port -+ */ -+static int dio_serial_init(php_dio_stream_data *data TSRMLS_DC) { -+ 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); -+ 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); -+ 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); -+ 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); -+ return 0; -+ } -+ -+ if (!GetCommState(wdata->handle, &(wdata->olddcb))) { -+ dio_last_error_php_error(E_WARNING, "GetCommState() failed:" TSRMLS_CC); -+ return 0; -+ } -+ -+ /* Init the DCB structure */ -+ memset(&dcb, 0, sizeof(DCB)); -+ dcb.DCBlength = sizeof(DCB); -+ -+ /* Set the communication parameters */ -+ dcb.fBinary = 1; -+ dcb.BaudRate = rate_def; -+ dcb.ByteSize = (BYTE)data_bits_def; -+ dcb.StopBits = (BYTE)stop_bits_def; -+ dcb.Parity = (BYTE)parity_def; -+ -+ /* Set the control line parameters */ -+ dcb.fDtrControl = DTR_CONTROL_DISABLE; -+ dcb.fDsrSensitivity = FALSE; -+ dcb.fOutxDsrFlow = FALSE; -+ dcb.fTXContinueOnXoff = FALSE; -+ dcb.fOutX = FALSE; -+ dcb.fInX = FALSE; -+ dcb.fErrorChar = FALSE; -+ dcb.fNull = FALSE; -+ dcb.fAbortOnError = FALSE; -+ -+ /* Hardware flow control */ -+ if (data->flow_control) { -+ dcb.fOutxCtsFlow = TRUE; -+ dcb.fRtsControl = RTS_CONTROL_HANDSHAKE; -+ } else { -+ dcb.fOutxCtsFlow = FALSE; -+ dcb.fRtsControl = RTS_CONTROL_DISABLE; -+ } -+ -+ if (!SetCommState(wdata->handle, &dcb)) { -+ dio_last_error_php_error(E_WARNING, "SetCommState() failed:" TSRMLS_CC); -+ return 0; -+ } -+ -+ return 1; -+} -+/* }}} */ -+ -+ -+/* {{{ dio_serial_uninit -+ * Restores the serial settings back to their original state. -+ */ -+int dio_serial_uninit(php_dio_stream_data *data) { -+ php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data; -+ -+ if (!SetCommState(wdata->handle, &(wdata->olddcb))) { -+ return 0; -+ } -+ -+ return 1; -+} -+/* }}} */ -+ -+/* {{{ dio_serial_flush -+ * Purges the serial buffers of data. -+ */ -+int dio_serial_purge(php_dio_stream_data *data) { -+ php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data; -+ BOOL ret; -+ -+ /* Purge the canonical buffer if required */ -+ if (data->canonical && ((wdata->desired_access & GENERIC_READ) == GENERIC_READ)) { -+ wdata->canon_data->read_pos = 0; -+ wdata->canon_data->write_pos = 0; -+ } -+ -+ /* Purge the com port */ -+ if ((wdata->desired_access & (GENERIC_READ|GENERIC_WRITE)) == (GENERIC_READ|GENERIC_WRITE)) { -+ ret = PurgeComm(wdata->handle, PURGE_RXCLEAR|PURGE_TXCLEAR); -+ } else if ((wdata->desired_access & GENERIC_WRITE) == GENERIC_WRITE) { -+ ret = PurgeComm(wdata->handle, PURGE_TXCLEAR); -+ } else if ((wdata->desired_access & GENERIC_READ) == GENERIC_READ) { -+ ret = PurgeComm(wdata->handle, PURGE_RXCLEAR); -+ } -+ -+ return ret; -+} -+/* }}} */ -+ -+/* {{{ dio_serial_open_stream -+ * Opens the underlying stream. -+ */ -+int dio_serial_open_stream(char *filename, char *mode, php_dio_stream_data *data TSRMLS_DC) { -+ 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); -+ -+ if (*mode != 'r') { -+ php_error_docref(NULL TSRMLS_CC, 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)) { -+ return 0; -+ } -+ -+ if (!GetCommTimeouts(wdata->handle, &(wdata->oldcto))) { -+ dio_last_error_php_error(E_WARNING, "GetCommTimeouts() failed (Not a comm port?):" TSRMLS_CC); -+ CloseHandle(wdata->handle); -+ return 0; -+ } -+ -+ /* If we're not blocking but don't have a timeout -+ set to return immediately */ -+ if (!data->is_blocking && !data->has_timeout) { -+ cto.ReadIntervalTimeout = MAXDWORD; -+ } -+ -+ /* If we have a timeout ignore the blocking and set -+ the total time in which to read the data */ -+ if (data->has_timeout) { -+ cto.ReadIntervalTimeout = MAXDWORD; -+ cto.ReadTotalTimeoutMultiplier = MAXDWORD; -+ cto.ReadTotalTimeoutConstant = (data->timeout_usec / 1000) + -+ (data->timeout_sec * 1000); -+ } -+ -+ if (!SetCommTimeouts(wdata->handle, &cto)) { -+ dio_last_error_php_error(E_WARNING, "SetCommTimeouts() failed:" TSRMLS_CC); -+ CloseHandle(wdata->handle); -+ return 0; -+ } -+ -+ if (!dio_serial_init(data TSRMLS_CC)) { -+ CloseHandle(wdata->handle); -+ return 0; -+ } -+ -+ return 1; -+} -+/* }}} */ -+ -+/* -+ * Local variables: -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * End: -+ * vim600: fdm=marker -+ * vim: sw=4 ts=4 noet -+ */ ---- a/php_dio_posix.h -+++ b/php_dio_posix.h -@@ -1,70 +1,70 @@ --/*
-- +----------------------------------------------------------------------+
-- | PHP Version 5 |
-- +----------------------------------------------------------------------+
-- | Copyright (c) 2009 Melanie Rhianna Lewis |
-- +----------------------------------------------------------------------+
-- | 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: Melanie Rhianna Lewis <cyberspice@php.net> |
-- +----------------------------------------------------------------------+
-- */
--
--#ifndef PHP_DIO_POSIX_H_
--#define PHP_DIO_POSIX_H_
--
--#include <sys/stat.h>
--#include <sys/types.h>
--#include <sys/select.h>
--#include <sys/time.h>
--
--#ifdef HAVE_UNISTD_H
--#include <unistd.h>
--#endif
--
--#include <fcntl.h>
--#include <termios.h>
--
--
--/**
-+/* -+ +----------------------------------------------------------------------+ -+ | PHP Version 5 | -+ +----------------------------------------------------------------------+ -+ | Copyright (c) 2009 Melanie Rhianna Lewis | -+ +----------------------------------------------------------------------+ -+ | 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: Melanie Rhianna Lewis <cyberspice@php.net> | -+ +----------------------------------------------------------------------+ -+ */ -+ -+#ifndef PHP_DIO_POSIX_H_ -+#define PHP_DIO_POSIX_H_ -+ -+#include <sys/stat.h> -+#include <sys/types.h> -+#include <sys/select.h> -+#include <sys/time.h> -+ -+#ifdef HAVE_UNISTD_H -+#include <unistd.h> -+#endif -+ -+#include <fcntl.h> -+#include <termios.h> -+ -+ -+/** - * Detect if we can support non blocking IO. -- */
--#ifdef O_NONBLOCK
--#define DIO_NONBLOCK O_NONBLOCK
--#else
--#ifdef O_NDELAY
--#define DIO_NONBLOCK O_NDELAY
--#endif
--#endif
--
--/**
-+ */ -+#ifdef O_NONBLOCK -+#define DIO_NONBLOCK O_NONBLOCK -+#else -+#ifdef O_NDELAY -+#define DIO_NONBLOCK O_NDELAY -+#endif -+#endif -+ -+/** - * POSIXy platforms have file permissions -- */
--#define DIO_HAS_FILEPERMS
--
--#include "php_dio_common_data.h"
--
--typedef struct _php_dio_posix_stream_data {
-- php_dio_stream_data common;
-- int fd;
-- int flags;
-- /* Serial options */
-- struct termios oldtio;
--} php_dio_posix_stream_data ;
--
--#endif /* PHP_DIO_POSIX_H_ */
--
--/*
-- * Local variables:
-- * c-basic-offset: 4
-- * tab-width: 4
-- * End:
-- * vim600: fdm=marker
-- * vim: sw=4 ts=4 noet
-- */
-+ */ -+#define DIO_HAS_FILEPERMS -+ -+#include "php_dio_common_data.h" -+ -+typedef struct _php_dio_posix_stream_data { -+ php_dio_stream_data common; -+ int fd; -+ int flags; -+ /* Serial options */ -+ struct termios oldtio; -+} php_dio_posix_stream_data ; -+ -+#endif /* PHP_DIO_POSIX_H_ */ -+ -+/* -+ * Local variables: -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * End: -+ * vim600: fdm=marker -+ * vim: sw=4 ts=4 noet -+ */ ---- a/php_dio_win32.h -+++ b/php_dio_win32.h -@@ -1,62 +1,62 @@ --/*
-- +----------------------------------------------------------------------+
-- | PHP Version 5 |
-- +----------------------------------------------------------------------+
-- | Copyright (c) 2009 Melanie Rhianna Lewis |
-- +----------------------------------------------------------------------+
-- | 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: Melanie Rhianna Lewis <cyberspice@php.net> |
-- +----------------------------------------------------------------------+
-- */
--
--#ifndef PHP_DIO_WIN32_H_
--#define PHP_DIO_WIN32_H_
--
--#include <windows.h>
--
--/* Windows platform can do non blocking. */
--#define DIO_NONBLOCK
--
--#include "php_dio_common_data.h"
--
--#define DIO_WIN32_CANON_BUF_SIZE 8192
--
--/* This is the buffer information when reading in canonical mode. Data is
-- read right up to either buffer being full or a newline being read. Excess
-- data will be retained in the buffer until the next read. */
--typedef struct _php_dio_win32_canon_data {
-- size_t size;
-- size_t read_pos;
-- size_t write_pos;
-- char buf[DIO_WIN32_CANON_BUF_SIZE];
--
--} php_dio_win32_canon_data;
--
--typedef struct _php_dio_win32_stream_data {
-- php_dio_stream_data common;
-- HANDLE handle;
-- DWORD desired_access;
-- DWORD creation_disposition;
-- DCB olddcb;
-- COMMTIMEOUTS oldcto;
-- php_dio_win32_canon_data *canon_data;
--
--} php_dio_win32_stream_data ;
--
--#endif /* PHP_DIO_WIN32_H_ */
--
--/*
-- * Local variables:
-- * c-basic-offset: 4
-- * tab-width: 4
-- * End:
-- * vim600: fdm=marker
-- * vim: sw=4 ts=4 noet
-- */
-+/* -+ +----------------------------------------------------------------------+ -+ | PHP Version 5 | -+ +----------------------------------------------------------------------+ -+ | Copyright (c) 2009 Melanie Rhianna Lewis | -+ +----------------------------------------------------------------------+ -+ | 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: Melanie Rhianna Lewis <cyberspice@php.net> | -+ +----------------------------------------------------------------------+ -+ */ -+ -+#ifndef PHP_DIO_WIN32_H_ -+#define PHP_DIO_WIN32_H_ -+ -+#include <windows.h> -+ -+/* Windows platform can do non blocking. */ -+#define DIO_NONBLOCK -+ -+#include "php_dio_common_data.h" -+ -+#define DIO_WIN32_CANON_BUF_SIZE 8192 -+ -+/* This is the buffer information when reading in canonical mode. Data is -+ read right up to either buffer being full or a newline being read. Excess -+ data will be retained in the buffer until the next read. */ -+typedef struct _php_dio_win32_canon_data { -+ size_t size; -+ size_t read_pos; -+ size_t write_pos; -+ char buf[DIO_WIN32_CANON_BUF_SIZE]; -+ -+} php_dio_win32_canon_data; -+ -+typedef struct _php_dio_win32_stream_data { -+ php_dio_stream_data common; -+ HANDLE handle; -+ DWORD desired_access; -+ DWORD creation_disposition; -+ DCB olddcb; -+ COMMTIMEOUTS oldcto; -+ php_dio_win32_canon_data *canon_data; -+ -+} php_dio_win32_stream_data ; -+ -+#endif /* PHP_DIO_WIN32_H_ */ -+ -+/* -+ * Local variables: -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * End: -+ * vim600: fdm=marker -+ * vim: sw=4 ts=4 noet -+ */ diff --git a/lang/php7-pecl-dio/patches/0001-fix-svn-prop.patch b/lang/php7-pecl-dio/patches/0001-fix-svn-prop.patch deleted file mode 100644 index e8a56fb9c..000000000 --- a/lang/php7-pecl-dio/patches/0001-fix-svn-prop.patch +++ /dev/null @@ -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 - diff --git a/lang/php7-pecl-dio/patches/0002-fix-Wunused-variable.patch b/lang/php7-pecl-dio/patches/0002-fix-Wunused-variable.patch deleted file mode 100644 index 662417442..000000000 --- a/lang/php7-pecl-dio/patches/0002-fix-Wunused-variable.patch +++ /dev/null @@ -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 - diff --git a/lang/php7-pecl-dio/patches/0003-Fix-Wmaybe-uninitialized.patch b/lang/php7-pecl-dio/patches/0003-Fix-Wmaybe-uninitialized.patch deleted file mode 100644 index 21f4cffce..000000000 --- a/lang/php7-pecl-dio/patches/0003-Fix-Wmaybe-uninitialized.patch +++ /dev/null @@ -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 - diff --git a/lang/php7-pecl-dio/patches/0004-Fix-last-build-warning-Wunused-but-set-variable-sorr.patch b/lang/php7-pecl-dio/patches/0004-Fix-last-build-warning-Wunused-but-set-variable-sorr.patch deleted file mode 100644 index ba69d223d..000000000 --- a/lang/php7-pecl-dio/patches/0004-Fix-last-build-warning-Wunused-but-set-variable-sorr.patch +++ /dev/null @@ -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 - diff --git a/lang/php7-pecl-dio/patches/0005-Added-LICENCE-file-as-requested-in-Request-65869.patch b/lang/php7-pecl-dio/patches/0005-Added-LICENCE-file-as-requested-in-Request-65869.patch deleted file mode 100644 index fc9961acf..000000000 --- a/lang/php7-pecl-dio/patches/0005-Added-LICENCE-file-as-requested-in-Request-65869.patch +++ /dev/null @@ -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 - diff --git a/lang/php7-pecl-dio/patches/0006-Replace-ZEND_FETCH_RESOURCE-macro-with-zend_fetch_re.patch b/lang/php7-pecl-dio/patches/0006-Replace-ZEND_FETCH_RESOURCE-macro-with-zend_fetch_re.patch deleted file mode 100644 index 6d9c483a9..000000000 --- a/lang/php7-pecl-dio/patches/0006-Replace-ZEND_FETCH_RESOURCE-macro-with-zend_fetch_re.patch +++ /dev/null @@ -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 - diff --git a/lang/php7-pecl-dio/patches/0007-Replace-ZEND_REGISTER_RESOURCE-with-zend_register_re.patch b/lang/php7-pecl-dio/patches/0007-Replace-ZEND_REGISTER_RESOURCE-with-zend_register_re.patch deleted file mode 100644 index c676a252e..000000000 --- a/lang/php7-pecl-dio/patches/0007-Replace-ZEND_REGISTER_RESOURCE-with-zend_register_re.patch +++ /dev/null @@ -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 - diff --git a/lang/php7-pecl-dio/patches/0008-RETURN_STRINGL-takes-only-2-arguments.patch b/lang/php7-pecl-dio/patches/0008-RETURN_STRINGL-takes-only-2-arguments.patch deleted file mode 100644 index 2197d12ae..000000000 --- a/lang/php7-pecl-dio/patches/0008-RETURN_STRINGL-takes-only-2-arguments.patch +++ /dev/null @@ -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 - diff --git a/lang/php7-pecl-dio/patches/0009-Replace-zend_hash_find-with-zend_hash_str_find.patch b/lang/php7-pecl-dio/patches/0009-Replace-zend_hash_find-with-zend_hash_str_find.patch deleted file mode 100644 index 85a8a07ca..000000000 --- a/lang/php7-pecl-dio/patches/0009-Replace-zend_hash_find-with-zend_hash_str_find.patch +++ /dev/null @@ -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 - diff --git a/lang/php7-pecl-dio/patches/0010-Replace-dio_convert_to_long.patch b/lang/php7-pecl-dio/patches/0010-Replace-dio_convert_to_long.patch deleted file mode 100644 index b5d7b6168..000000000 --- a/lang/php7-pecl-dio/patches/0010-Replace-dio_convert_to_long.patch +++ /dev/null @@ -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(©val); -- -- 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 - diff --git a/lang/php7-pecl-dio/patches/0011-Adopt-to-changed-stream-API-interface.patch b/lang/php7-pecl-dio/patches/0011-Adopt-to-changed-stream-API-interface.patch deleted file mode 100644 index dde856533..000000000 --- a/lang/php7-pecl-dio/patches/0011-Adopt-to-changed-stream-API-interface.patch +++ /dev/null @@ -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 - diff --git a/lang/php7-pecl-dio/patches/0012-Remove-ancient-macros-TSRMLS_CC-and-TSRMLS_DC.patch b/lang/php7-pecl-dio/patches/0012-Remove-ancient-macros-TSRMLS_CC-and-TSRMLS_DC.patch deleted file mode 100644 index c15fd89f8..000000000 --- a/lang/php7-pecl-dio/patches/0012-Remove-ancient-macros-TSRMLS_CC-and-TSRMLS_DC.patch +++ /dev/null @@ -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 - diff --git a/lang/php7-pecl-dio/patches/0013-Fix-tests-for-legacy-interface.patch b/lang/php7-pecl-dio/patches/0013-Fix-tests-for-legacy-interface.patch deleted file mode 100644 index e632552a3..000000000 --- a/lang/php7-pecl-dio/patches/0013-Fix-tests-for-legacy-interface.patch +++ /dev/null @@ -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 - diff --git a/lang/php7-pecl-dio/patches/0014-Add-missing-changes-from-changed-stream-API-interfac.patch b/lang/php7-pecl-dio/patches/0014-Add-missing-changes-from-changed-stream-API-interfac.patch deleted file mode 100644 index b9e2e00c1..000000000 --- a/lang/php7-pecl-dio/patches/0014-Add-missing-changes-from-changed-stream-API-interfac.patch +++ /dev/null @@ -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 - diff --git a/lang/php7-pecl-dio/patches/0015-Add-.gitignore.patch b/lang/php7-pecl-dio/patches/0015-Add-.gitignore.patch deleted file mode 100644 index ef675deeb..000000000 --- a/lang/php7-pecl-dio/patches/0015-Add-.gitignore.patch +++ /dev/null @@ -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 - diff --git a/lang/php7-pecl-dio/patches/0016-Add-additional-baudrates.patch b/lang/php7-pecl-dio/patches/0016-Add-additional-baudrates.patch deleted file mode 100644 index 16cceea5c..000000000 --- a/lang/php7-pecl-dio/patches/0016-Add-additional-baudrates.patch +++ /dev/null @@ -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 - |