diff --git a/lang/php7-pecl-dio/Makefile b/lang/php7-pecl-dio/Makefile new file mode 100644 index 000000000..1f77c0137 --- /dev/null +++ b/lang/php7-pecl-dio/Makefile @@ -0,0 +1,34 @@ +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PECL_NAME:=dio +PECL_LONGNAME:=Direct I/O functions + +PKG_VERSION:=0.0.7 +PKG_RELEASE:=1 +PKG_MD5SUM:=a1a4df428a17dbe1ab4277b492dfa052 + +PKG_NAME:=php7-pecl-$(PECL_NAME) +PKG_SOURCE:=$(PECL_NAME)-$(PKG_VERSION).tgz +PKG_SOURCE_URL:=http://pecl.php.net/get/ + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PECL_NAME)-$(PKG_VERSION) +PKG_BUILD_PARALLEL:=1 + +PKG_MAINTAINER:=Michael Heimpold + +PKG_LICENSE:=PHPv3.01 +PKG_LICENSE_FILES:= + +PKG_FIXUP:=autoreconf + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/nls.mk +include ../php7/pecl.mk + +$(eval $(call PECLPackage,$(PECL_NAME),$(PECL_LONGNAME))) +$(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/lang/php7-pecl-dio/patches/0000-unify-line-endings.patch b/lang/php7-pecl-dio/patches/0000-unify-line-endings.patch new file mode 100644 index 000000000..b6c275040 --- /dev/null +++ b/lang/php7-pecl-dio/patches/0000-unify-line-endings.patch @@ -0,0 +1,3110 @@ +--- 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 | +- +----------------------------------------------------------------------+ +- */ +- +-#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 | ++ +----------------------------------------------------------------------+ ++ */ ++ ++#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 | +- +----------------------------------------------------------------------+ +- */ +- +-#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 | ++ +----------------------------------------------------------------------+ ++ */ ++ ++#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 | +- +----------------------------------------------------------------------+ +- */ +- +-#ifndef PHP_DIO_POSIX_H_ +-#define PHP_DIO_POSIX_H_ +- +-#include +-#include +-#include +-#include +- +-#ifdef HAVE_UNISTD_H +-#include +-#endif +- +-#include +-#include +- +- +-/** ++/* ++ +----------------------------------------------------------------------+ ++ | 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 | ++ +----------------------------------------------------------------------+ ++ */ ++ ++#ifndef PHP_DIO_POSIX_H_ ++#define PHP_DIO_POSIX_H_ ++ ++#include ++#include ++#include ++#include ++ ++#ifdef HAVE_UNISTD_H ++#include ++#endif ++ ++#include ++#include ++ ++ ++/** + * 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 | +- +----------------------------------------------------------------------+ +- */ +- +-#ifndef PHP_DIO_WIN32_H_ +-#define PHP_DIO_WIN32_H_ +- +-#include +- +-/* 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 | ++ +----------------------------------------------------------------------+ ++ */ ++ ++#ifndef PHP_DIO_WIN32_H_ ++#define PHP_DIO_WIN32_H_ ++ ++#include ++ ++/* 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 new file mode 100644 index 000000000..e8a56fb9c --- /dev/null +++ b/lang/php7-pecl-dio/patches/0001-fix-svn-prop.patch @@ -0,0 +1,32 @@ +From 46d3a1ff2c6e316cf0928a9fd403cb5284bfe863 Mon Sep 17 00:00:00 2001 +From: remi +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 new file mode 100644 index 000000000..662417442 --- /dev/null +++ b/lang/php7-pecl-dio/patches/0002-fix-Wunused-variable.patch @@ -0,0 +1,39 @@ +From e9261081d447492e7eff3a22601b1de4f1ae550f Mon Sep 17 00:00:00 2001 +From: remi +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 new file mode 100644 index 000000000..21f4cffce --- /dev/null +++ b/lang/php7-pecl-dio/patches/0003-Fix-Wmaybe-uninitialized.patch @@ -0,0 +1,39 @@ +From 6cbc1651b6b6f865f9aae1e9adff73743298666f Mon Sep 17 00:00:00 2001 +From: remi +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 new file mode 100644 index 000000000..ba69d223d --- /dev/null +++ b/lang/php7-pecl-dio/patches/0004-Fix-last-build-warning-Wunused-but-set-variable-sorr.patch @@ -0,0 +1,42 @@ +From 1e6f98d9fb65b9c052e6d555eab573d7e5073dae Mon Sep 17 00:00:00 2001 +From: remi +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 new file mode 100644 index 000000000..fc9961acf --- /dev/null +++ b/lang/php7-pecl-dio/patches/0005-Added-LICENCE-file-as-requested-in-Request-65869.patch @@ -0,0 +1,91 @@ +From 7c85a44880d9d748e7554f8fe7448505fa86aa28 Mon Sep 17 00:00:00 2001 +From: cyberspice +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 ++ ". ++ ++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 . ++ ++PHP includes the Zend Engine, freely available at ++. +-- +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 new file mode 100644 index 000000000..6d9c483a9 --- /dev/null +++ b/lang/php7-pecl-dio/patches/0006-Replace-ZEND_FETCH_RESOURCE-macro-with-zend_fetch_re.patch @@ -0,0 +1,117 @@ +From b69e1067f70ef293587b72979193e68b01d90902 Mon Sep 17 00:00:00 2001 +From: Michael Heimpold +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 +--- + 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 new file mode 100644 index 000000000..c676a252e --- /dev/null +++ b/lang/php7-pecl-dio/patches/0007-Replace-ZEND_REGISTER_RESOURCE-with-zend_register_re.patch @@ -0,0 +1,66 @@ +From dbf03eb09bf1a41bcd140c4edba351121ac24729 Mon Sep 17 00:00:00 2001 +From: Michael Heimpold +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 +--- + 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 new file mode 100644 index 000000000..2197d12ae --- /dev/null +++ b/lang/php7-pecl-dio/patches/0008-RETURN_STRINGL-takes-only-2-arguments.patch @@ -0,0 +1,34 @@ +From 47422cf01f0a352c3f5f015585a28c99dba79862 Mon Sep 17 00:00:00 2001 +From: Michael Heimpold +Date: Wed, 13 Jul 2016 00:40:08 +0200 +Subject: [PATCH 08/16] RETURN_STRINGL takes only 2 arguments + +Signed-off-by: Michael Heimpold +--- + 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 new file mode 100644 index 000000000..85a8a07ca --- /dev/null +++ b/lang/php7-pecl-dio/patches/0009-Replace-zend_hash_find-with-zend_hash_str_find.patch @@ -0,0 +1,125 @@ +From 7533f64b19006262fae7c6a4769392c67078166b Mon Sep 17 00:00:00 2001 +From: Michael Heimpold +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 +--- + 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 new file mode 100644 index 000000000..b5d7b6168 --- /dev/null +++ b/lang/php7-pecl-dio/patches/0010-Replace-dio_convert_to_long.patch @@ -0,0 +1,240 @@ +From fb31b1cf4da2bfd0830d0a83754f5ecb125d1c4a Mon Sep 17 00:00:00 2001 +From: Michael Heimpold +Date: Thu, 14 Jul 2016 00:38:52 +0200 +Subject: [PATCH 10/16] Replace dio_convert_to_long + +Signed-off-by: Michael Heimpold +--- + 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 new file mode 100644 index 000000000..dde856533 --- /dev/null +++ b/lang/php7-pecl-dio/patches/0011-Adopt-to-changed-stream-API-interface.patch @@ -0,0 +1,89 @@ +From 3d71063ada4f1a4ef90611d263aa8e1d4f275359 Mon Sep 17 00:00:00 2001 +From: Michael Heimpold +Date: Thu, 14 Jul 2016 00:50:12 +0200 +Subject: [PATCH 11/16] Adopt to changed stream API interface + +Signed-off-by: Michael Heimpold +--- + 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 new file mode 100644 index 000000000..c15fd89f8 --- /dev/null +++ b/lang/php7-pecl-dio/patches/0012-Remove-ancient-macros-TSRMLS_CC-and-TSRMLS_DC.patch @@ -0,0 +1,829 @@ +From 760ec7072cbba2cbbb6e4e17b0c54ee3c7b661a8 Mon Sep 17 00:00:00 2001 +From: Michael Heimpold +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 +--- + 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 new file mode 100644 index 000000000..e632552a3 --- /dev/null +++ b/lang/php7-pecl-dio/patches/0013-Fix-tests-for-legacy-interface.patch @@ -0,0 +1,69 @@ +From 942b77d84417298fb9e99c216029f22fbd1e2d98 Mon Sep 17 00:00:00 2001 +From: Michael Heimpold +Date: Thu, 14 Jul 2016 01:47:05 +0200 +Subject: [PATCH 13/16] Fix tests for legacy interface + +Signed-off-by: Michael Heimpold +--- + 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 new file mode 100644 index 000000000..b9e2e00c1 --- /dev/null +++ b/lang/php7-pecl-dio/patches/0014-Add-missing-changes-from-changed-stream-API-interfac.patch @@ -0,0 +1,54 @@ +From ff469d3a11409e9b043dc10ddfc44792c5359ff1 Mon Sep 17 00:00:00 2001 +From: Michael Heimpold +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 +--- + 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 new file mode 100644 index 000000000..ef675deeb --- /dev/null +++ b/lang/php7-pecl-dio/patches/0015-Add-.gitignore.patch @@ -0,0 +1,48 @@ +From def92a2db269d4ea6d2e8b7f8fe9dd473886a6b1 Mon Sep 17 00:00:00 2001 +From: Michael Heimpold +Date: Sun, 17 Jul 2016 01:08:47 +0200 +Subject: [PATCH 15/16] Add .gitignore + +Signed-off-by: Michael Heimpold +--- + .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 new file mode 100644 index 000000000..16cceea5c --- /dev/null +++ b/lang/php7-pecl-dio/patches/0016-Add-additional-baudrates.patch @@ -0,0 +1,44 @@ +From 0f8df09a8008eed8a7ac0c6400bce523014ff770 Mon Sep 17 00:00:00 2001 +From: Michael Heimpold +Date: Mon, 18 Jul 2016 22:45:04 +0200 +Subject: [PATCH 16/16] Add additional baudrates + +Signed-off-by: Michael Heimpold +--- + 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 + diff --git a/lang/php7-pecl-propro/Makefile b/lang/php7-pecl-propro/Makefile new file mode 100644 index 000000000..005dd4384 --- /dev/null +++ b/lang/php7-pecl-propro/Makefile @@ -0,0 +1,37 @@ +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PECL_NAME:=propro +PECL_LONGNAME:=Property proxy + +PKG_VERSION:=2.0.1 +PKG_RELEASE:=1 +PKG_MD5SUM:=19f9517210a87e18cc09faed262e1522 + +PKG_NAME:=php7-pecl-propro +PKG_SOURCE:=$(PECL_NAME)-$(PKG_VERSION).tgz +PKG_SOURCE_URL:=http://pecl.php.net/get/ + +PKG_MAINTAINER:=Michael Heimpold + +PKG_LICENSE:=BSD-2-Clause +PKG_LICENSE_FILES:=LICENSE + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PECL_NAME)-$(PKG_VERSION) +PKG_BUILD_PARALLEL:=1 + +PKG_FIXUP:=autoreconf + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/nls.mk +include ../php7/pecl.mk + +CONFIGURE_ARGS+= \ + --enable-propro + +$(eval $(call PECLPackage,$(PECL_NAME),$(PECL_LONGNAME))) +$(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/lang/php7-pecl-raphf/Makefile b/lang/php7-pecl-raphf/Makefile new file mode 100644 index 000000000..6471e165e --- /dev/null +++ b/lang/php7-pecl-raphf/Makefile @@ -0,0 +1,37 @@ +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PECL_NAME:=raphf +PECL_LONGNAME:=Resource and persistent handles factory + +PKG_VERSION:=2.0.0 +PKG_RELEASE:=1 +PKG_MD5SUM:=bc465eb5caa9d0f09cced121a8ac2e8e + +PKG_NAME:=php7-pecl-raphf +PKG_SOURCE:=$(PECL_NAME)-$(PKG_VERSION).tgz +PKG_SOURCE_URL:=http://pecl.php.net/get/ + +PKG_MAINTAINER:=Michael Heimpold + +PKG_LICENSE:=BSD-2-Clause +PKG_LICENSE_FILES:=LICENSE + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PECL_NAME)-$(PKG_VERSION) +PKG_BUILD_PARALLEL:=1 + +PKG_FIXUP:=autoreconf + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/nls.mk +include ../php7/pecl.mk + +CONFIGURE_ARGS+= \ + --enable-raphf + +$(eval $(call PECLPackage,$(PECL_NAME),$(PECL_LONGNAME))) +$(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/lang/php7/Makefile b/lang/php7/Makefile new file mode 100644 index 000000000..f8adb3be4 --- /dev/null +++ b/lang/php7/Makefile @@ -0,0 +1,587 @@ +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=php +PKG_VERSION:=7.0.10 +PKG_RELEASE:=1 + +PKG_MAINTAINER:=Michael Heimpold + +PKG_LICENSE:=PHPv3.01 +PKG_LICENSE_FILES:=LICENSE + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=http://www.php.net/distributions/ +PKG_MD5SUM:=6f087f16514b6c442e8009a5828827b7 + +PKG_FIXUP:=libtool autoreconf +PKG_BUILD_PARALLEL:=1 +PKG_USE_MIPS16:=0 + +PHP7_MODULES = \ + calendar ctype curl \ + fileinfo \ + dom \ + exif \ + ftp \ + gettext gd gmp \ + hash \ + iconv intl \ + json \ + ldap \ + mbstring mcrypt mysqli \ + opcache openssl \ + pcntl pdo pdo-mysql pdo-pgsql pdo-sqlite pgsql \ + session shmop simplexml soap sockets sqlite3 sysvmsg sysvsem sysvshm \ + tokenizer \ + xml xmlreader xmlwriter zip \ + +PKG_CONFIG_DEPENDS:= \ + $(patsubst %,CONFIG_PACKAGE_php7-mod-%,$(PHP7_MODULES)) \ + CONFIG_PHP7_FILTER CONFIG_PHP7_LIBXML CONFIG_PHP7_SYSTEMTZDATA + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/nls.mk + +define Package/php7/Default + SUBMENU:=PHP + SECTION:=lang + CATEGORY:=Languages + TITLE:=PHP7 Hypertext preprocessor + URL:=http://www.php.net/ + DEPENDS:=php7 +endef + +define Package/php7/Default/description + PHP is a widely-used general-purpose scripting language that is especially + suited for Web development and can be embedded into HTML. +endef + +define Package/php7/config + config PHP7_FILTER + bool "PHP7 Filter support" + depends on PACKAGE_php7-cli || PACKAGE_php7-cgi + + config PHP7_LIBXML + bool "PHP7 LIBXML support" + depends on PACKAGE_php7-cli || PACKAGE_php7-cgi + + config PHP7_SYSTEMTZDATA + bool "Use system timezone data instead of php's built-in database" + depends on PACKAGE_php7-cli || PACKAGE_php7-cgi + select PACKAGE_zoneinfo-core + default y + help + Enabling this feature automatically selects the zoneinfo-core package + which contains data for UTC timezone. To use other timezones you have + to install the corresponding zoneinfo-... package(s). +endef + +define Package/php7 + $(call Package/php7/Default) + + DEPENDS:=+libpcre +zlib \ + +PHP7_LIBXML:libxml2 +endef + +define Package/php7/description + $(call Package/php7/Default/description) + This package contains only the PHP config file. You must actually choose + your PHP flavour (cli, cgi or fastcgi). + + Please note, that installing php5 and php7 in parallel on the same target + is not supported in OpenWrt/LEDE. +endef + +define Package/php7-cli + $(call Package/php7/Default) + DEPENDS+= +PACKAGE_php7-mod-intl:libstdcpp + TITLE+= (CLI) +endef + +define Package/php7-cli/description + $(call Package/php7/Default/description) + This package contains the CLI version of the PHP7 interpreter. +endef + +define Package/php7-cgi + $(call Package/php7/Default) + DEPENDS+= +PACKAGE_php7-mod-intl:libstdcpp + TITLE+= (CGI & FastCGI) +endef + +define Package/php7-cgi/description + $(call Package/php7/Default/description) + This package contains the CGI version of the PHP7 interpreter. +endef + +define Package/php7-fastcgi + $(call Package/php7/Default) + DEPENDS+= +php7-cgi + TITLE:=FastCGI startup script +endef + +define Package/php7-fastcgi/description + As FastCGI support is now a core feature the php7-fastcgi package now depends + on the php7-cgi package, containing just the startup script. +endef + +define Package/php7-fpm + $(call Package/php7/Default) + DEPENDS+= +php7-cgi + TITLE+= (FPM) +endef + +define Package/php7-fpm/description + $(call Package/php7/Default/description) + This package contains the FastCGI Process Manager of the PHP7 interpreter. +endef + +CONFIGURE_ARGS+= \ + --enable-cli \ + --enable-cgi \ + --enable-fpm \ + --enable-shared \ + --disable-static \ + --disable-rpath \ + --disable-debug \ + --disable-phpdbg \ + --without-pear \ + \ + --with-config-file-path=/etc \ + --with-config-file-scan-dir=/etc/php7 \ + --disable-short-tags \ + \ + --with-zlib="$(STAGING_DIR)/usr" \ + --with-zlib-dir="$(STAGING_DIR)/usr" \ + --disable-phar + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-calendar),) + CONFIGURE_ARGS+= --enable-calendar=shared +else + CONFIGURE_ARGS+= --disable-calendar +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-ctype),) + CONFIGURE_ARGS+= --enable-ctype=shared +else + CONFIGURE_ARGS+= --disable-ctype +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-curl),) + CONFIGURE_ARGS+= --with-curl=shared,"$(STAGING_DIR)/usr" +else + CONFIGURE_ARGS+= --without-curl +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-fileinfo),) + CONFIGURE_ARGS+= --enable-fileinfo=shared +else + CONFIGURE_ARGS+= --disable-fileinfo +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-gettext),) + CONFIGURE_ARGS+= --with-gettext=shared,"$(STAGING_DIR)/usr/lib/libintl-full" +else + CONFIGURE_ARGS+= --without-gettext +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-dom),) + CONFIGURE_ARGS+= --enable-dom=shared +else + CONFIGURE_ARGS+= --disable-dom +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-exif),) + CONFIGURE_ARGS+= --enable-exif=shared +else + CONFIGURE_ARGS+= --disable-exif +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-ftp),) + CONFIGURE_ARGS+= --enable-ftp=shared +else + CONFIGURE_ARGS+= --disable-ftp +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-gd),) + CONFIGURE_ARGS+= \ + --with-gd=shared \ + --without-freetype-dir \ + --with-jpeg-dir="$(STAGING_DIR)/usr" \ + --with-png-dir="$(STAGING_DIR)/usr" \ + --without-xpm-dir \ + --without-t1lib \ + --enable-gd-native-ttf \ + --disable-gd-jis-conv +else + CONFIGURE_ARGS+= --without-gd +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-gmp),) + CONFIGURE_ARGS+= --with-gmp=shared,"$(STAGING_DIR)/usr" +else + CONFIGURE_ARGS+= --without-gmp +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-hash),) + CONFIGURE_ARGS+= --enable-hash=shared +else + CONFIGURE_ARGS+= --disable-hash +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-iconv),) + CONFIGURE_ARGS+= --with-iconv=shared,"$(ICONV_PREFIX)" +else + CONFIGURE_ARGS+= --without-iconv +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-intl),) + CONFIGURE_ARGS+= --enable-intl=shared +else + CONFIGURE_ARGS+= --disable-intl +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-json),) + CONFIGURE_ARGS+= --enable-json=shared +else + CONFIGURE_ARGS+= --disable-json +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-ldap),) + CONFIGURE_ARGS+= \ + --with-ldap=shared,"$(STAGING_DIR)/usr" \ + --with-ldap-sasl="$(STAGING_DIR)/usr" +else + CONFIGURE_ARGS+= --without-ldap +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-mbstring),) + CONFIGURE_ARGS+= --enable-mbstring=shared --enable-mbregex +else + CONFIGURE_ARGS+= --disable-mbstring +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-mcrypt),) + CONFIGURE_ARGS+= --with-mcrypt=shared,"$(STAGING_DIR)/usr" +else + CONFIGURE_ARGS+= --without-mcrypt +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-mysqli),) + CONFIGURE_ARGS+= --with-mysqli=shared,"$(STAGING_DIR)/usr/bin/mysql_config" +else + CONFIGURE_ARGS+= --without-mysqli +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-opcache),) + CONFIGURE_ARGS+= --enable-opcache=shared +else + CONFIGURE_ARGS+= --disable-opcache +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-openssl),) + CONFIGURE_ARGS+= \ + --with-openssl=shared,"$(STAGING_DIR)/usr" \ + --with-kerberos=no \ + --with-openssl-dir="$(STAGING_DIR)/usr" +else + CONFIGURE_ARGS+= --without-openssl +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-pcntl),) + CONFIGURE_ARGS+= --enable-pcntl=shared +else + CONFIGURE_ARGS+= --disable-pcntl +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-pdo),) + CONFIGURE_ARGS+= --enable-pdo=shared + ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-pdo-mysql),) + CONFIGURE_ARGS+= --with-pdo-mysql=shared,"$(STAGING_DIR)/usr" + else + CONFIGURE_ARGS+= --without-pdo-mysql + endif + ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-pdo-pgsql),) + CONFIGURE_ARGS+= --with-pdo-pgsql=shared,"$(STAGING_DIR)/usr" + else + CONFIGURE_ARGS+= --without-pdo-pgsql + endif + ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-pdo-sqlite),) + CONFIGURE_ARGS+= --with-pdo-sqlite=shared,"$(STAGING_DIR)/usr" + else + CONFIGURE_ARGS+= --without-pdo-sqlite + endif +else + CONFIGURE_ARGS+= --disable-pdo +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-pgsql),) + CONFIGURE_ARGS+= --with-pgsql=shared,"$(STAGING_DIR)/usr" +else + CONFIGURE_ARGS+= --without-pgsql +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-session),) + CONFIGURE_ARGS+= --enable-session=shared +else + CONFIGURE_ARGS+= --disable-session +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-shmop),) + CONFIGURE_ARGS+= --enable-shmop=shared +else + CONFIGURE_ARGS+= --disable-shmop +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-simplexml),) + CONFIGURE_ARGS+= --enable-simplexml=shared +else + CONFIGURE_ARGS+= --disable-simplexml +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-soap),) + CONFIGURE_ARGS+= --enable-soap=shared +else + CONFIGURE_ARGS+= --disable-soap +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-sockets),) + CONFIGURE_ARGS+= --enable-sockets=shared +else + CONFIGURE_ARGS+= --disable-sockets +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-sqlite3),) + CONFIGURE_ARGS+= --with-sqlite3=shared,"$(STAGING_DIR)/usr" +else + CONFIGURE_ARGS+= --without-sqlite3 +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-sysvmsg),) + CONFIGURE_ARGS+= --enable-sysvmsg=shared +else + CONFIGURE_ARGS+= --disable-sysvmsg +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-sysvsem),) + CONFIGURE_ARGS+= --enable-sysvsem=shared +else + CONFIGURE_ARGS+= --disable-sysvsem +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-sysvshm),) + CONFIGURE_ARGS+= --enable-sysvshm=shared +else + CONFIGURE_ARGS+= --disable-sysvshm +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-tokenizer),) + CONFIGURE_ARGS+= --enable-tokenizer=shared +else + CONFIGURE_ARGS+= --disable-tokenizer +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-xml),) + CONFIGURE_ARGS+= --enable-xml=shared,"$(STAGING_DIR)/usr" + ifneq ($(CONFIG_PHP7_LIBXML),) + CONFIGURE_ARGS+= --with-libxml-dir="$(STAGING_DIR)/usr/include/libxml2" + else + CONFIGURE_ARGS+= --with-libexpat-dir="$(STAGING_DIR)/usr" + endif +else + CONFIGURE_ARGS+= --disable-xml +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-xmlreader),) + CONFIGURE_ARGS+= --enable-xmlreader=shared,"$(STAGING_DIR)/usr" +else + CONFIGURE_ARGS+= --disable-xmlreader +endif + +ifneq ($(SDK)$(CONFIG_PACKAGE_php7-mod-xmlwriter),) + CONFIGURE_ARGS+= --enable-xmlwriter=shared,"$(STAGING_DIR)/usr" +else + CONFIGURE_ARGS+= --disable-xmlwriter +endif + +ifneq ($(CONFIG_PACKAGE_php7-mod-zip),) + CONFIGURE_ARGS+= --enable-zip=shared +else + CONFIGURE_ARGS+= --disable-zip +endif + +ifneq ($(SDK)$(CONFIG_PHP7_FILTER),) + CONFIGURE_ARGS+= --enable-filter +else + CONFIGURE_ARGS+= --disable-filter +endif + +ifneq ($(SDK)$(CONFIG_PHP7_LIBXML),) + CONFIGURE_ARGS+= --enable-libxml + CONFIGURE_ARGS+= --with-libxml-dir="$(STAGING_DIR)/usr/include/libxml2" +else + CONFIGURE_ARGS+= --disable-libxml +endif + +#ifneq ($(CONFIG_PHP7_SYSTEMTZDATA),) +# CONFIGURE_ARGS+= --with-system-tzdata +#else +# CONFIGURE_ARGS+= --without-system-tzdata +#endif + +CONFIGURE_VARS+= \ + ac_cv_c_bigendian_php=$(if $(CONFIG_BIG_ENDIAN),yes,no) \ + php_cv_cc_rpath="no" \ + iconv_impl_name="gnu_libiconv" \ + ac_cv_php_xml2_config_path="$(STAGING_DIR)/host/bin/xml2-config" \ + +define Package/php7/conffiles +/etc/php.ini +endef + +define Package/php7/install + $(INSTALL_DIR) $(1)/etc + $(INSTALL_DATA) ./files/php.ini $(1)/etc/ +endef + +define Package/php7-cli/install + $(INSTALL_DIR) $(1)/usr/bin + $(CP) $(PKG_BUILD_DIR)/sapi/cli/php $(1)/usr/bin/php-cli +endef + +define Package/php7-cgi/install + $(INSTALL_DIR) $(1)/usr/bin + $(CP) $(PKG_BUILD_DIR)/sapi/cgi/php-cgi $(1)/usr/bin/php-cgi + ln -sf php-cgi $(1)/usr/bin/php-fcgi +endef + +define Package/php7-fastcgi/install + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/php7-fastcgi.config $(1)/etc/config/php7-fastcgi + + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/php7-fastcgi.init $(1)/etc/init.d/php7-fastcgi +endef + +define Package/php7-fpm/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/sapi/fpm/php-fpm $(1)/usr/bin/php-fpm + + $(INSTALL_DIR) $(1)/etc + $(INSTALL_DATA) ./files/php7-fpm.conf $(1)/etc/php7-fpm.conf + + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/php7-fpm.config $(1)/etc/config/php7-fpm + + $(INSTALL_DIR) $(1)/etc/php7-fpm.d + $(INSTALL_DATA) ./files/php7-fpm-www.conf $(1)/etc/php7-fpm.d/www.conf + + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/php7-fpm.init $(1)/etc/init.d/php7-fpm +endef + +define Build/Prepare + $(call Build/Prepare/Default) + ( cd $(PKG_BUILD_DIR); touch configure.in; ./buildconf --force ) +endef + +define Build/InstallDev +# mkdir -p $(PKG_BUILD_DIR)/staging/usr/bin + make -C $(PKG_BUILD_DIR) install INSTALL_ROOT=$(PKG_BUILD_DIR)/staging + rm -rf $(PKG_BUILD_DIR)/staging/usr/{share,man,sbin} + rm -f $(PKG_BUILD_DIR)/staging/usr/bin/{php,php-cgi,php-cli} + mv $(PKG_BUILD_DIR)/staging/usr/bin/phpize $(PKG_BUILD_DIR)/staging/usr/bin/phpize7 + mv $(PKG_BUILD_DIR)/staging/usr/bin/php-config $(PKG_BUILD_DIR)/staging/usr/bin/php7-config + mv $(PKG_BUILD_DIR)/staging/usr/include/php $(PKG_BUILD_DIR)/staging/usr/include/php7 + mv $(PKG_BUILD_DIR)/staging/usr/lib/php $(PKG_BUILD_DIR)/staging/usr/lib/php7 + + $(CP) $(PKG_BUILD_DIR)/staging/usr $(STAGING_DIR)/ + + sed -i -e "s#prefix='/usr'#prefix='$(STAGING_DIR)/usr'#" $(STAGING_DIR)/usr/bin/phpize7 + sed -i -e "s#exec_prefix=\"\`eval echo /usr\`\"#exec_prefix='$(STAGING_DIR)/usr'#" $(STAGING_DIR)/usr/bin/phpize7 + sed -i -e "s#/include\`/php\"#/include\`/php7\"#" $(STAGING_DIR)/usr/bin/phpize7 + sed -i -e "s#/lib/php\`/build\"#/lib/php7\`/build\"#" $(STAGING_DIR)/usr/bin/phpize7 + + sed -i -e "s#prefix=\"/usr\"#prefix=\"$(STAGING_DIR)/usr\"#" $(STAGING_DIR)/usr/bin/php7-config + sed -i -e "s#/include/php\"#/include/php7\"#" $(STAGING_DIR)/usr/bin/php7-config +endef + +define BuildModule + + define Package/php7-mod-$(1) + $(call Package/php7/Default) + + ifneq ($(3),) + DEPENDS+=$(3) + endif + + TITLE:=$(2) shared module + endef + + define Package/php7-mod-$(1)/install + $(INSTALL_DIR) $$(1)/usr/lib/php + $(INSTALL_BIN) $(PKG_BUILD_DIR)/modules/$(subst -,_,$(1)).so $$(1)/usr/lib/php/ + $(INSTALL_DIR) $$(1)/etc/php7 + ifeq ($(4),zend) + echo "zend_extension=/usr/lib/php/$(subst -,_,$(1)).so" > $$(1)/etc/php7/$(subst -,_,$(1)).ini + else + echo "extension=$(subst -,_,$(1)).so" > $$(1)/etc/php7/$(subst -,_,$(1)).ini + endif + endef + + $$(eval $$(call BuildPackage,php7-mod-$(1))) + +endef + +$(eval $(call BuildPackage,php7)) +$(eval $(call BuildPackage,php7-cgi)) +$(eval $(call BuildPackage,php7-cli)) +$(eval $(call BuildPackage,php7-fastcgi)) +$(eval $(call BuildPackage,php7-fpm)) + +#$(eval $(call BuildModule,NAME,TITLE[,PKG DEPENDS])) +$(eval $(call BuildModule,calendar,Calendar)) +$(eval $(call BuildModule,ctype,Ctype)) +$(eval $(call BuildModule,curl,cURL,+PACKAGE_php7-mod-curl:libcurl)) +$(eval $(call BuildModule,dom,DOM,+@PHP7_LIBXML +PACKAGE_php7-mod-dom:libxml2)) +$(eval $(call BuildModule,exif,EXIF)) +$(eval $(call BuildModule,fileinfo,Fileinfo)) +$(eval $(call BuildModule,ftp,FTP,+PACKAGE_php7-mod-ftp:libopenssl)) +$(eval $(call BuildModule,gd,GD graphics,+PACKAGE_php7-mod-gd:libjpeg +PACKAGE_php7-mod-gd:libpng)) +$(eval $(call BuildModule,gettext,Gettext,+PACKAGE_php7-mod-gettext:libintl-full)) +$(eval $(call BuildModule,gmp,GMP,+PACKAGE_php7-mod-gmp:libgmp)) +$(eval $(call BuildModule,hash,Hash)) +$(eval $(call BuildModule,iconv,iConv,$(ICONV_DEPENDS))) +$(eval $(call BuildModule,intl,Internationalization Functions,+PACKAGE_php7-mod-intl:icu)) +$(eval $(call BuildModule,json,JSON)) +$(eval $(call BuildModule,ldap,LDAP,+PACKAGE_php7-mod-ldap:libopenldap +PACKAGE_php7-mod-ldap:libsasl2)) +$(eval $(call BuildModule,mbstring,MBString)) +$(eval $(call BuildModule,mcrypt,Mcrypt,+PACKAGE_php7-mod-mcrypt:libmcrypt +PACKAGE_php7-mod-mcrypt:libltdl)) +$(eval $(call BuildModule,mysqli,MySQL Improved Extension,+PACKAGE_php7-mod-mysqli:libmysqlclient)) +$(eval $(call BuildModule,opcache,OPcache,,zend)) +$(eval $(call BuildModule,openssl,OpenSSL,+PACKAGE_php7-mod-openssl:libopenssl)) +$(eval $(call BuildModule,pcntl,PCNTL)) +$(eval $(call BuildModule,pdo,PHP Data Objects)) +$(eval $(call BuildModule,pdo-mysql,PDO driver for MySQL,+php7-mod-pdo +PACKAGE_php7-mod-pdo-mysql:libmysqlclient)) +$(eval $(call BuildModule,pdo-pgsql,PDO driver for PostgreSQL,+php7-mod-pdo +PACKAGE_php7-mod-pdo-pgsql:libpq)) +$(eval $(call BuildModule,pdo-sqlite,PDO driver for SQLite 3.x,+php7-mod-pdo +PACKAGE_php7-mod-pdo-sqlite:libsqlite3 +PACKAGE_php7-mod-pdo-sqlite:librt)) +$(eval $(call BuildModule,pgsql,PostgreSQL,+PACKAGE_php7-mod-pgsql:libpq)) +$(eval $(call BuildModule,session,Session)) +$(eval $(call BuildModule,shmop,Shared Memory)) +$(eval $(call BuildModule,simplexml,SimpleXML,+@PHP7_LIBXML +PACKAGE_php7-mod-simplexml:libxml2)) +$(eval $(call BuildModule,soap,SOAP,+@PHP7_LIBXML +PACKAGE_php7-mod-soap:libxml2)) +$(eval $(call BuildModule,sockets,Sockets)) +$(eval $(call BuildModule,sqlite3,SQLite3,+PACKAGE_php7-mod-sqlite3:libsqlite3)) +$(eval $(call BuildModule,sysvmsg,System V messages)) +$(eval $(call BuildModule,sysvsem,System V shared memory)) +$(eval $(call BuildModule,sysvshm,System V semaphore)) +$(eval $(call BuildModule,tokenizer,Tokenizer)) +$(eval $(call BuildModule,xml,XML,+PHP7_LIBXML:libxml2 +!PHP7_LIBXML:libexpat)) +$(eval $(call BuildModule,xmlreader,XMLReader,+@PHP7_LIBXML +PACKAGE_php7-mod-xmlreader:libxml2)) +$(eval $(call BuildModule,xmlwriter,XMLWriter,+@PHP7_LIBXML +PACKAGE_php7-mod-xmlwriter:libxml2)) +$(eval $(call BuildModule,zip,ZIP,+PACKAGE_php7-mod-zip:zlib)) diff --git a/lang/php7/files/php.ini b/lang/php7/files/php.ini new file mode 100644 index 000000000..c88ab0a44 --- /dev/null +++ b/lang/php7/files/php.ini @@ -0,0 +1,152 @@ +[PHP] +zend.ze1_compatibility_mode = Off + +; Language Options + +engine = On +;short_open_tag = Off +precision = 12 +y2k_compliance = On +output_buffering = Off +;output_handler = +zlib.output_compression = Off +;zlib.output_compression_level = -1 +;zlib.output_handler = +implicit_flush = Off +unserialize_callback_func = +serialize_precision = 100 + +;open_basedir = +disable_functions = +disable_classes = + +; Colors for Syntax Highlighting mode. Anything that's acceptable in +; would work. +;highlight.string = #DD0000 +;highlight.comment = #FF9900 +;highlight.keyword = #007700 +;highlight.bg = #FFFFFF +;highlight.default = #0000BB +;highlight.html = #000000 + +;ignore_user_abort = On +;realpath_cache_size = 16k +;realpath_cache_ttl = 120 + +; Miscellaneous + +expose_php = On + +; Resource Limits + +max_execution_time = 30 ; Maximum execution time of each script, in seconds. +max_input_time = 60 ; Maximum amount of time each script may spend parsing request data. +;max_input_nesting_level = 64 +memory_limit = 8M ; Maximum amount of memory a script may consume. + +; Error handling and logging + +; Error Level Constants: +; E_ALL - All errors and warnings (includes E_STRICT as of PHP 6.0.0) +; E_ERROR - fatal run-time errors +; E_RECOVERABLE_ERROR - almost fatal run-time errors +; E_WARNING - run-time warnings (non-fatal errors) +; E_PARSE - compile-time parse errors +; E_NOTICE - run-time notices (these are warnings which often result +; from a bug in your code, but it's possible that it was +; intentional (e.g., using an uninitialized variable and +; relying on the fact it's automatically initialized to an +; empty string) +; E_STRICT - run-time notices, enable to have PHP suggest changes +; to your code which will ensure the best interoperability +; and forward compatibility of your code +; E_CORE_ERROR - fatal errors that occur during PHP's initial startup +; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's +; initial startup +; E_COMPILE_ERROR - fatal compile-time errors +; E_COMPILE_WARNING - compile-time warnings (non-fatal errors) +; E_USER_ERROR - user-generated error message +; E_USER_WARNING - user-generated warning message +; E_USER_NOTICE - user-generated notice message +; E_DEPRECATED - warn about code that will not work in future versions +; of PHP +; E_USER_DEPRECATED - user-generated deprecation warnings +; +; Common Values: +; E_ALL & ~E_NOTICE (Show all errors, except for notices and coding standards warnings.) +; E_ALL & ~E_NOTICE | E_STRICT (Show all errors, except for notices) +; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors) +; E_ALL | E_STRICT (Show all errors, warnings and notices including coding standards.) +; Default Value: E_ALL & ~E_NOTICE +error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT + +display_errors = On +display_startup_errors = Off +log_errors = Off +log_errors_max_len = 1024 +ignore_repeated_errors = Off +ignore_repeated_source = Off +report_memleaks = On +;report_zend_debug = 0 +track_errors = Off +;html_errors = Off +;docref_root = "/phpmanual/" +;docref_ext = .html +;error_prepend_string = "" +;error_append_string = "" +; Log errors to specified file. +;error_log = /var/log/php_errors.log +; Log errors to syslog. +;error_log = syslog + +; Data Handling + +;arg_separator.output = "&" +;arg_separator.input = ";&" +variables_order = "EGPCS" +request_order = "GP" +register_globals = Off +register_long_arrays = Off +register_argc_argv = On +auto_globals_jit = On +post_max_size = 8M +;magic_quotes_gpc = Off +magic_quotes_runtime = Off +magic_quotes_sybase = Off +auto_prepend_file = +auto_append_file = +default_mimetype = "text/html" +;default_charset = "iso-8859-1" +;always_populate_raw_post_data = On + +; Paths and Directories + +; UNIX: "/path1:/path2" +;include_path = ".:/php/includes" +doc_root = "/www" +user_dir = +extension_dir = "/usr/lib/php" +enable_dl = On +;cgi.force_redirect = 1 +;cgi.nph = 1 +;cgi.redirect_status_env = ; +cgi.fix_pathinfo=1 +;fastcgi.impersonate = 1; +;fastcgi.logging = 0 +;cgi.rfc2616_headers = 0 + +; File Uploads + +file_uploads = On +upload_tmp_dir = "/tmp" +upload_max_filesize = 2M +max_file_uploads = 20 + +; Fopen wrappers + +allow_url_fopen = On +allow_url_include = Off +;from="john@doe.com" +;user_agent="PHP" +default_socket_timeout = 60 +;auto_detect_line_endings = Off diff --git a/lang/php7/files/php7-fastcgi.config b/lang/php7/files/php7-fastcgi.config new file mode 100644 index 000000000..22e9998c0 --- /dev/null +++ b/lang/php7/files/php7-fastcgi.config @@ -0,0 +1,3 @@ +config php7-fastcgi + option enabled 1 + option port '1026' diff --git a/lang/php7/files/php7-fastcgi.init b/lang/php7/files/php7-fastcgi.init new file mode 100644 index 000000000..21f5b09e1 --- /dev/null +++ b/lang/php7/files/php7-fastcgi.init @@ -0,0 +1,29 @@ +#!/bin/sh /etc/rc.common + +START=50 + +SERVICE_DAEMONIZE=1 +SERVICE_WRITE_PID=1 + +start_instance() { + local section="$1" + local enabled + local port + + config_get_bool enabled "$section" 'enabled' 0 + config_get port "$section" 'port' 1026 + + [ $enabled -gt 0 ] || return 1 + + PHP_FCGI_CHILDREN='' \ + service_start /usr/bin/php-fcgi -b $port +} + +start() { + config_load 'php7-fastcgi' + config_foreach start_instance 'php7-fastcgi' +} + +stop() { + service_stop /usr/bin/php-fcgi +} diff --git a/lang/php7/files/php7-fpm-www.conf b/lang/php7/files/php7-fpm-www.conf new file mode 100644 index 000000000..d3a32224f --- /dev/null +++ b/lang/php7/files/php7-fpm-www.conf @@ -0,0 +1,392 @@ +; Start a new pool named 'www'. +; the variable $pool can we used in any directive and will be replaced by the +; pool name ('www' here) +[www] + +; Per pool prefix +; It only applies on the following directives: +; - 'slowlog' +; - 'listen' (unixsocket) +; - 'chroot' +; - 'chdir' +; - 'php_values' +; - 'php_admin_values' +; When not set, the global prefix (or /usr) applies instead. +; Note: This directive can also be relative to the global prefix. +; Default Value: none +;prefix = /path/to/pools/$pool + +; Unix user/group of processes +; Note: The user is mandatory. If the group is not set, the default user's group +; will be used. +user = nobody +;group = + +; The address on which to accept FastCGI requests. +; Valid syntaxes are: +; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on +; a specific port; +; 'port' - to listen on a TCP socket to all addresses on a +; specific port; +; '/path/to/unix/socket' - to listen on a unix socket. +; Note: This value is mandatory. +listen = /var/run/php7-fpm.sock + +; Set listen(2) backlog. +; Default Value: 128 (-1 on FreeBSD and OpenBSD) +;listen.backlog = 128 + +; Set permissions for unix socket, if one is used. In Linux, read/write +; permissions must be set in order to allow connections from a web server. Many +; BSD-derived systems allow connections regardless of permissions. +; Default Values: user and group are set as the running user +; mode is set to 0666 +;listen.owner = www-data +;listen.group = www-data +;listen.mode = 0666 + +; List of ipv4 addresses of FastCGI clients which are allowed to connect. +; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original +; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address +; must be separated by a comma. If this value is left blank, connections will be +; accepted from any ip address. +; Default Value: any +;listen.allowed_clients = 127.0.0.1 + +; Specify the nice(2) priority to apply to the pool processes (only if set) +; The value can vary from -19 (highest priority) to 20 (lower priority) +; Note: - It will only work if the FPM master process is launched as root +; - The pool processes will inherit the master process priority +; unless it specified otherwise +; Default Value: no set +; priority = -19 + +; Choose how the process manager will control the number of child processes. +; Possible Values: +; static - a fixed number (pm.max_children) of child processes; +; dynamic - the number of child processes are set dynamically based on the +; following directives. With this process management, there will be +; always at least 1 children. +; pm.max_children - the maximum number of children that can +; be alive at the same time. +; pm.start_servers - the number of children created on startup. +; pm.min_spare_servers - the minimum number of children in 'idle' +; state (waiting to process). If the number +; of 'idle' processes is less than this +; number then some children will be created. +; pm.max_spare_servers - the maximum number of children in 'idle' +; state (waiting to process). If the number +; of 'idle' processes is greater than this +; number then some children will be killed. +; ondemand - no children are created at startup. Children will be forked when +; new requests will connect. The following parameter are used: +; pm.max_children - the maximum number of children that +; can be alive at the same time. +; pm.process_idle_timeout - The number of seconds after which +; an idle process will be killed. +; Note: This value is mandatory. +pm = dynamic + +; The number of child processes to be created when pm is set to 'static' and the +; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. +; This value sets the limit on the number of simultaneous requests that will be +; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. +; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP +; CGI. The below defaults are based on a server without much resources. Don't +; forget to tweak pm.* to fit your needs. +; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' +; Note: This value is mandatory. +pm.max_children = 5 + +; The number of child processes created on startup. +; Note: Used only when pm is set to 'dynamic' +; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 +pm.start_servers = 2 + +; The desired minimum number of idle server processes. +; Note: Used only when pm is set to 'dynamic' +; Note: Mandatory when pm is set to 'dynamic' +pm.min_spare_servers = 1 + +; The desired maximum number of idle server processes. +; Note: Used only when pm is set to 'dynamic' +; Note: Mandatory when pm is set to 'dynamic' +pm.max_spare_servers = 3 + +; The number of seconds after which an idle process will be killed. +; Note: Used only when pm is set to 'ondemand' +; Default Value: 10s +;pm.process_idle_timeout = 10s; + +; The number of requests each child process should execute before respawning. +; This can be useful to work around memory leaks in 3rd party libraries. For +; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. +; Default Value: 0 +;pm.max_requests = 500 + +; The URI to view the FPM status page. If this value is not set, no URI will be +; recognized as a status page. It shows the following informations: +; pool - the name of the pool; +; process manager - static, dynamic or ondemand; +; start time - the date and time FPM has started; +; start since - number of seconds since FPM has started; +; accepted conn - the number of request accepted by the pool; +; listen queue - the number of request in the queue of pending +; connections (see backlog in listen(2)); +; max listen queue - the maximum number of requests in the queue +; of pending connections since FPM has started; +; listen queue len - the size of the socket queue of pending connections; +; idle processes - the number of idle processes; +; active processes - the number of active processes; +; total processes - the number of idle + active processes; +; max active processes - the maximum number of active processes since FPM +; has started; +; max children reached - number of times, the process limit has been reached, +; when pm tries to start more children (works only for +; pm 'dynamic' and 'ondemand'); +; Value are updated in real time. +; Example output: +; pool: www +; process manager: static +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 62636 +; accepted conn: 190460 +; listen queue: 0 +; max listen queue: 1 +; listen queue len: 42 +; idle processes: 4 +; active processes: 11 +; total processes: 15 +; max active processes: 12 +; max children reached: 0 +; +; By default the status page output is formatted as text/plain. Passing either +; 'html', 'xml' or 'json' in the query string will return the corresponding +; output syntax. Example: +; http://www.foo.bar/status +; http://www.foo.bar/status?json +; http://www.foo.bar/status?html +; http://www.foo.bar/status?xml +; +; By default the status page only outputs short status. Passing 'full' in the +; query string will also return status for each pool process. +; Example: +; http://www.foo.bar/status?full +; http://www.foo.bar/status?json&full +; http://www.foo.bar/status?html&full +; http://www.foo.bar/status?xml&full +; The Full status returns for each process: +; pid - the PID of the process; +; state - the state of the process (Idle, Running, ...); +; start time - the date and time the process has started; +; start since - the number of seconds since the process has started; +; requests - the number of requests the process has served; +; request duration - the duration in µs of the requests; +; request method - the request method (GET, POST, ...); +; request URI - the request URI with the query string; +; content length - the content length of the request (only with POST); +; user - the user (PHP_AUTH_USER) (or '-' if not set); +; script - the main script called (or '-' if not set); +; last request cpu - the %cpu the last request consumed +; it's always 0 if the process is not in Idle state +; because CPU calculation is done when the request +; processing has terminated; +; last request memory - the max amount of memory the last request consumed +; it's always 0 if the process is not in Idle state +; because memory calculation is done when the request +; processing has terminated; +; If the process is in Idle state, then informations are related to the +; last request the process has served. Otherwise informations are related to +; the current request being served. +; Example output: +; ************************ +; pid: 31330 +; state: Running +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 63087 +; requests: 12808 +; request duration: 1250261 +; request method: GET +; request URI: /test_mem.php?N=10000 +; content length: 0 +; user: - +; script: /home/fat/web/docs/php/test_mem.php +; last request cpu: 0.00 +; last request memory: 0 +; +; Note: There is a real-time FPM status monitoring sample web page available +; It's available in: ${prefix}/share/fpm/status.html +; +; Note: The value must start with a leading slash (/). The value can be +; anything, but it may not be a good idea to use the .php extension or it +; may conflict with a real PHP file. +; Default Value: not set +;pm.status_path = /status + +; The ping URI to call the monitoring page of FPM. If this value is not set, no +; URI will be recognized as a ping page. This could be used to test from outside +; that FPM is alive and responding, or to +; - create a graph of FPM availability (rrd or such); +; - remove a server from a group if it is not responding (load balancing); +; - trigger alerts for the operating team (24/7). +; Note: The value must start with a leading slash (/). The value can be +; anything, but it may not be a good idea to use the .php extension or it +; may conflict with a real PHP file. +; Default Value: not set +;ping.path = /ping + +; This directive may be used to customize the response of a ping request. The +; response is formatted as text/plain with a 200 response code. +; Default Value: pong +;ping.response = pong + +; The access log file +; Default: not set +;access.log = log/$pool.access.log + +; The access log format. +; The following syntax is allowed +; %%: the '%' character +; %C: %CPU used by the request +; it can accept the following format: +; - %{user}C for user CPU only +; - %{system}C for system CPU only +; - %{total}C for user + system CPU (default) +; %d: time taken to serve the request +; it can accept the following format: +; - %{seconds}d (default) +; - %{miliseconds}d +; - %{mili}d +; - %{microseconds}d +; - %{micro}d +; %e: an environment variable (same as $_ENV or $_SERVER) +; it must be associated with embraces to specify the name of the env +; variable. Some exemples: +; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e +; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e +; %f: script filename +; %l: content-length of the request (for POST request only) +; %m: request method +; %M: peak of memory allocated by PHP +; it can accept the following format: +; - %{bytes}M (default) +; - %{kilobytes}M +; - %{kilo}M +; - %{megabytes}M +; - %{mega}M +; %n: pool name +; %o: ouput header +; it must be associated with embraces to specify the name of the header: +; - %{Content-Type}o +; - %{X-Powered-By}o +; - %{Transfert-Encoding}o +; - .... +; %p: PID of the child that serviced the request +; %P: PID of the parent of the child that serviced the request +; %q: the query string +; %Q: the '?' character if query string exists +; %r: the request URI (without the query string, see %q and %Q) +; %R: remote IP address +; %s: status (response code) +; %t: server time the request was received +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; %T: time the log has been written (the request has finished) +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; %u: remote user +; +; Default: "%R - %u %t \"%m %r\" %s" +;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" + +; The log file for slow requests +; Default Value: not set +; Note: slowlog is mandatory if request_slowlog_timeout is set +;slowlog = log/$pool.log.slow + +; The timeout for serving a single request after which a PHP backtrace will be +; dumped to the 'slowlog' file. A value of '0s' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +;request_slowlog_timeout = 0 + +; The timeout for serving a single request after which the worker process will +; be killed. This option should be used when the 'max_execution_time' ini option +; does not stop script execution for some reason. A value of '0' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +;request_terminate_timeout = 0 + +; Set open file descriptor rlimit. +; Default Value: system defined value +;rlimit_files = 1024 + +; Set max core size rlimit. +; Possible Values: 'unlimited' or an integer greater or equal to 0 +; Default Value: system defined value +;rlimit_core = 0 + +; Chroot to this directory at the start. This value must be defined as an +; absolute path. When this value is not set, chroot is not used. +; Note: you can prefix with '$prefix' to chroot to the pool prefix or one +; of its subdirectories. If the pool prefix is not set, the global prefix +; will be used instead. +; Note: chrooting is a great security feature and should be used whenever +; possible. However, all PHP paths will be relative to the chroot +; (error_log, sessions.save_path, ...). +; Default Value: not set +;chroot = + +; Chdir to this directory at the start. +; Note: relative path can be used. +; Default Value: current directory or / when chroot +chdir = / + +; Redirect worker stdout and stderr into main error log. If not set, stdout and +; stderr will be redirected to /dev/null according to FastCGI specs. +; Note: on highloaded environement, this can cause some delay in the page +; process time (several ms). +; Default Value: no +;catch_workers_output = yes + +; Limits the extensions of the main script FPM will allow to parse. This can +; prevent configuration mistakes on the web server side. You should only limit +; FPM to .php extensions to prevent malicious users to use other extensions to +; exectute php code. +; Note: set an empty value to allow all extensions. +; Default Value: .php +;security.limit_extensions = .php .php3 .php4 .php5 + +; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from +; the current environment. +; Default Value: clean env +;env[HOSTNAME] = $HOSTNAME +;env[PATH] = /usr/local/bin:/usr/bin:/bin +;env[TMP] = /tmp +;env[TMPDIR] = /tmp +;env[TEMP] = /tmp + +; Additional php.ini defines, specific to this pool of workers. These settings +; overwrite the values previously defined in the php.ini. The directives are the +; same as the PHP SAPI: +; php_value/php_flag - you can set classic ini defines which can +; be overwritten from PHP call 'ini_set'. +; php_admin_value/php_admin_flag - these directives won't be overwritten by +; PHP call 'ini_set' +; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. + +; Defining 'extension' will load the corresponding shared extension from +; extension_dir. Defining 'disable_functions' or 'disable_classes' will not +; overwrite previously defined php.ini values, but will append the new value +; instead. + +; Note: path INI options can be relative and will be expanded with the prefix +; (pool, global or /usr) + +; Default Value: nothing is defined by default except the values in php.ini and +; specified at startup with the -d argument +;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com +;php_flag[display_errors] = off +;php_admin_value[error_log] = /var/log/fpm-php.www.log +;php_admin_flag[log_errors] = on +;php_admin_value[memory_limit] = 32M diff --git a/lang/php7/files/php7-fpm.conf b/lang/php7/files/php7-fpm.conf new file mode 100644 index 000000000..c980b2190 --- /dev/null +++ b/lang/php7/files/php7-fpm.conf @@ -0,0 +1,121 @@ +;;;;;;;;;;;;;;;;;;;;; +; FPM Configuration ; +;;;;;;;;;;;;;;;;;;;;; + +; All relative paths in this configuration file are relative to PHP's install +; prefix (/usr). This prefix can be dynamically changed by using the +; '-p' argument from the command line. + +; Include one or more files. If glob(3) exists, it is used to include a bunch of +; files from a glob(3) pattern. This directive can be used everywhere in the +; file. +; Relative path can also be used. They will be prefixed by: +; - the global prefix if it's been set (-p argument) +; - /usr otherwise +;include=/etc/php7/fpm/*.conf + +;;;;;;;;;;;;;;;;;; +; Global Options ; +;;;;;;;;;;;;;;;;;; + +[global] +; Pid file +; Note: the default prefix is /var +; Default Value: none +pid = /var/run/php7-fpm.pid + +; Error log file +; If it's set to "syslog", log is sent to syslogd instead of being written +; in a local file. +; Note: the default prefix is /var +; Default Value: log/php-fpm.log +error_log = /var/log/php7-fpm.log + +; syslog_facility is used to specify what type of program is logging the +; message. This lets syslogd specify that messages from different facilities +; will be handled differently. +; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON) +; Default Value: daemon +;syslog.facility = daemon + +; syslog_ident is prepended to every message. If you have multiple FPM +; instances running on the same server, you can change the default value +; which must suit common needs. +; Default Value: php-fpm +;syslog.ident = php-fpm + +; Log level +; Possible Values: alert, error, warning, notice, debug +; Default Value: notice +;log_level = notice + +; If this number of child processes exit with SIGSEGV or SIGBUS within the time +; interval set by emergency_restart_interval then FPM will restart. A value +; of '0' means 'Off'. +; Default Value: 0 +;emergency_restart_threshold = 0 + +; Interval of time used by emergency_restart_interval to determine when +; a graceful restart will be initiated. This can be useful to work around +; accidental corruptions in an accelerator's shared memory. +; Available Units: s(econds), m(inutes), h(ours), or d(ays) +; Default Unit: seconds +; Default Value: 0 +;emergency_restart_interval = 0 + +; Time limit for child processes to wait for a reaction on signals from master. +; Available units: s(econds), m(inutes), h(ours), or d(ays) +; Default Unit: seconds +; Default Value: 0 +;process_control_timeout = 0 + +; The maximum number of processes FPM will fork. This has been design to control +; the global number of processes when using dynamic PM within a lot of pools. +; Use it with caution. +; Note: A value of 0 indicates no limit +; Default Value: 0 +; process.max = 128 + +; Specify the nice(2) priority to apply to the master process (only if set) +; The value can vary from -19 (highest priority) to 20 (lower priority) +; Note: - It will only work if the FPM master process is launched as root +; - The pool process will inherit the master process priority +; unless it specified otherwise +; Default Value: no set +; process.priority = -19 + +; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging. +; Default Value: yes +;daemonize = yes + +; Set open file descriptor rlimit for the master process. +; Default Value: system defined value +;rlimit_files = 1024 + +; Set max core size rlimit for the master process. +; Possible Values: 'unlimited' or an integer greater or equal to 0 +; Default Value: system defined value +;rlimit_core = 0 + +; Specify the event mechanism FPM will use. The following is available: +; - select (any POSIX os) +; - poll (any POSIX os) +; - epoll (linux >= 2.5.44) +; - kqueue (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0) +; - /dev/poll (Solaris >= 7) +; - port (Solaris >= 10) +; Default Value: not set (auto detection) +; events.mechanism = epoll + +;;;;;;;;;;;;;;;;;;;; +; Pool Definitions ; +;;;;;;;;;;;;;;;;;;;; + +; Multiple pools of child processes may be started with different listening +; ports and different management options. The name of the pool will be +; used in logs and stats. There is no limitation on the number of pools which +; FPM can handle. Your system will tell you anyway :) + +; To configure the pools it is recommended to have one .conf file per +; pool in the following directory: +include=/etc/php7-fpm.d/*.conf diff --git a/lang/php7/files/php7-fpm.config b/lang/php7/files/php7-fpm.config new file mode 100644 index 000000000..3a893c6f2 --- /dev/null +++ b/lang/php7/files/php7-fpm.config @@ -0,0 +1,2 @@ +config php7-fpm + option enabled 1 diff --git a/lang/php7/files/php7-fpm.init b/lang/php7/files/php7-fpm.init new file mode 100644 index 000000000..c913a2b6f --- /dev/null +++ b/lang/php7/files/php7-fpm.init @@ -0,0 +1,28 @@ +#!/bin/sh /etc/rc.common + +START=50 + +PROG=/usr/bin/php-fpm +CONFIG=/etc/php7-fpm.conf + +SERVICE_PID_FILE=/var/run/php7-fpm.pid + +start_instance() { + local section="$1" + local enabled + + config_get_bool enabled "$section" 'enabled' 0 + + [ $enabled -gt 0 ] || return 1 + + service_start $PROG -y $CONFIG -g $SERVICE_PID_FILE +} + +start() { + config_load 'php7-fpm' + config_foreach start_instance 'php7-fpm' +} + +stop() { + service_stop $PROG +} diff --git a/lang/php7/patches/0013-Add-support-for-use-of-the-system-timezone-database.patch b/lang/php7/patches/0013-Add-support-for-use-of-the-system-timezone-database.patch new file mode 100644 index 000000000..9d8f989f0 --- /dev/null +++ b/lang/php7/patches/0013-Add-support-for-use-of-the-system-timezone-database.patch @@ -0,0 +1,673 @@ +From: Joe Orton +Date: Sun, 18 Oct 2015 02:15:17 +0200 +Subject: Add support for use of the system timezone database + +Add support for use of the system timezone database, rather +than embedding a copy. Discussed upstream but was not desired. + +History: +r13: adapt for upstream changes to use PHP allocator +r12: adapt for upstream changes for new zic +r11: use canonical names to avoid more case sensitivity issues + round lat/long from zone.tab towards zero per builtin db +r10: make timezone case insensitive +r9: fix another compile error without --with-system-tzdata configured (Michael Heimpold) +r8: fix compile error without --with-system-tzdata configured +r7: improve check for valid timezone id to exclude directories +r6: fix fd leak in r5, fix country code/BC flag use in + timezone_identifiers_list() using system db, + fix use of PECL timezonedb to override system db, +r5: reverts addition of "System/Localtime" fake tzname. + updated for 5.3.0, parses zone.tab to pick up mapping between + timezone name, country code and long/lat coords +r4: added "System/Localtime" tzname which uses /etc/localtime +r3: fix a crash if /usr/share/zoneinfo doesn't exist (Raphael Geissert) +r2: add filesystem trawl to set up name alias index +r1: initial revision +--- + ext/date/lib/parse_tz.c | 549 +++++++++++++++++++++++++++++++++++++++++++++++- + ext/date/lib/timelib.m4 | 14 ++ + 2 files changed, 552 insertions(+), 11 deletions(-) + +diff --git a/ext/date/lib/parse_tz.c b/ext/date/lib/parse_tz.c +index 20d7eea..6301dc5 100644 +--- a/ext/date/lib/parse_tz.c ++++ b/ext/date/lib/parse_tz.c +@@ -24,6 +24,16 @@ + + #include "timelib.h" + ++#ifdef HAVE_SYSTEM_TZDATA ++#include ++#include ++#include ++#include ++#include ++ ++#include "php_scandir.h" ++#endif ++ + #include + + #ifdef HAVE_LOCALE_H +@@ -36,8 +46,12 @@ + #include + #endif + ++#ifndef HAVE_SYSTEM_TZDATA + #define TIMELIB_SUPPORTS_V2DATA + #include "timezonedb.h" ++#endif ++ ++#include + + #if (defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__)) + # if defined(__LITTLE_ENDIAN__) +@@ -59,6 +73,11 @@ static int read_preamble(const unsigned char **tzf, timelib_tzinfo *tz) + { + uint32_t version; + ++ if (memcmp(*tzf, "TZif", 4) == 0) { ++ *tzf += 20; ++ return 0; ++ } ++ + /* read ID */ + version = (*tzf)[3] - '0'; + *tzf += 4; +@@ -302,7 +321,418 @@ void timelib_dump_tzinfo(timelib_tzinfo *tz) + } + } + +-static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const timelib_tzdb *tzdb) ++#ifdef HAVE_SYSTEM_TZDATA ++ ++#ifdef HAVE_SYSTEM_TZDATA_PREFIX ++#define ZONEINFO_PREFIX HAVE_SYSTEM_TZDATA_PREFIX ++#else ++#define ZONEINFO_PREFIX "/usr/share/zoneinfo" ++#endif ++ ++/* System timezone database pointer. */ ++static const timelib_tzdb *timezonedb_system; ++ ++/* Hash table entry for the cache of the zone.tab mapping table. */ ++struct location_info { ++ char code[2]; ++ double latitude, longitude; ++ char name[64]; ++ char *comment; ++ struct location_info *next; ++}; ++ ++/* Cache of zone.tab. */ ++static struct location_info **system_location_table; ++ ++/* Size of the zone.tab hash table; a random-ish prime big enough to ++ * prevent too many collisions. */ ++#define LOCINFO_HASH_SIZE (1021) ++ ++/* Compute a case insensitive hash of str */ ++static uint32_t tz_hash(const char *str) ++{ ++ const unsigned char *p = (const unsigned char *)str; ++ uint32_t hash = 5381; ++ int c; ++ ++ while ((c = tolower(*p++)) != '\0') { ++ hash = (hash << 5) ^ hash ^ c; ++ } ++ ++ return hash % LOCINFO_HASH_SIZE; ++} ++ ++/* Parse an ISO-6709 date as used in zone.tab. Returns end of the ++ * parsed string on success, or NULL on parse error. On success, ++ * writes the parsed number to *result. */ ++static char *parse_iso6709(char *p, double *result) ++{ ++ double v, sign; ++ char *pend; ++ size_t len; ++ ++ if (*p == '+') ++ sign = 1.0; ++ else if (*p == '-') ++ sign = -1.0; ++ else ++ return NULL; ++ ++ p++; ++ for (pend = p; *pend >= '0' && *pend <= '9'; pend++) ++ ;; ++ ++ /* Annoying encoding used by zone.tab has no decimal point, so use ++ * the length to determine the format: ++ * ++ * 4 = DDMM ++ * 5 = DDDMM ++ * 6 = DDMMSS ++ * 7 = DDDMMSS ++ */ ++ len = pend - p; ++ if (len < 4 || len > 7) { ++ return NULL; ++ } ++ ++ /* p => [D]DD */ ++ v = (p[0] - '0') * 10.0 + (p[1] - '0'); ++ p += 2; ++ if (len == 5 || len == 7) ++ v = v * 10.0 + (*p++ - '0'); ++ /* p => MM[SS] */ ++ v += (10.0 * (p[0] - '0') ++ + p[1] - '0') / 60.0; ++ p += 2; ++ /* p => [SS] */ ++ if (len > 5) { ++ v += (10.0 * (p[0] - '0') ++ + p[1] - '0') / 3600.0; ++ p += 2; ++ } ++ ++ /* Round to five decimal place, not because it's a good idea, ++ * but, because the builtin data uses rounded data, so, match ++ * that. */ ++ *result = trunc(v * sign * 100000.0) / 100000.0; ++ ++ return p; ++} ++ ++/* This function parses the zone.tab file to build up the mapping of ++ * timezone to country code and geographic location, and returns a ++ * hash table. The hash table is indexed by the function: ++ * ++ * tz_hash(timezone-name) ++ */ ++static struct location_info **create_location_table(void) ++{ ++ struct location_info **li, *i; ++ char zone_tab[PATH_MAX]; ++ char line[512]; ++ FILE *fp; ++ ++ strncpy(zone_tab, ZONEINFO_PREFIX "/zone.tab", sizeof zone_tab); ++ ++ fp = fopen(zone_tab, "r"); ++ if (!fp) { ++ return NULL; ++ } ++ ++ li = calloc(LOCINFO_HASH_SIZE, sizeof *li); ++ ++ while (fgets(line, sizeof line, fp)) { ++ char *p = line, *code, *name, *comment; ++ uint32_t hash; ++ double latitude, longitude; ++ ++ while (isspace(*p)) ++ p++; ++ ++ if (*p == '#' || *p == '\0' || *p == '\n') ++ continue; ++ ++ if (!isalpha(p[0]) || !isalpha(p[1]) || p[2] != '\t') ++ continue; ++ ++ /* code => AA */ ++ code = p; ++ p[2] = 0; ++ p += 3; ++ ++ /* coords => [+-][D]DDMM[SS][+-][D]DDMM[SS] */ ++ p = parse_iso6709(p, &latitude); ++ if (!p) { ++ continue; ++ } ++ p = parse_iso6709(p, &longitude); ++ if (!p) { ++ continue; ++ } ++ ++ if (!p || *p != '\t') { ++ continue; ++ } ++ ++ /* name = string */ ++ name = ++p; ++ while (*p != '\t' && *p && *p != '\n') ++ p++; ++ ++ *p++ = '\0'; ++ ++ /* comment = string */ ++ comment = p; ++ while (*p != '\t' && *p && *p != '\n') ++ p++; ++ ++ if (*p == '\n' || *p == '\t') ++ *p = '\0'; ++ ++ hash = tz_hash(name); ++ i = malloc(sizeof *i); ++ memcpy(i->code, code, 2); ++ strncpy(i->name, name, sizeof i->name); ++ i->comment = strdup(comment); ++ i->longitude = longitude; ++ i->latitude = latitude; ++ i->next = li[hash]; ++ li[hash] = i; ++ /* printf("%s [%u, %f, %f]\n", name, hash, latitude, longitude); */ ++ } ++ ++ fclose(fp); ++ ++ return li; ++} ++ ++/* Return location info from hash table, using given timezone name. ++ * Returns NULL if the name could not be found. */ ++const struct location_info *find_zone_info(struct location_info **li, ++ const char *name) ++{ ++ uint32_t hash = tz_hash(name); ++ const struct location_info *l; ++ ++ if (!li) { ++ return NULL; ++ } ++ ++ for (l = li[hash]; l; l = l->next) { ++ if (strcasecmp(l->name, name) == 0) ++ return l; ++ } ++ ++ return NULL; ++} ++ ++/* Filter out some non-tzdata files and the posix/right databases, if ++ * present. */ ++static int index_filter(const struct dirent *ent) ++{ ++ return strcmp(ent->d_name, ".") != 0 ++ && strcmp(ent->d_name, "..") != 0 ++ && strcmp(ent->d_name, "posix") != 0 ++ && strcmp(ent->d_name, "posixrules") != 0 ++ && strcmp(ent->d_name, "right") != 0 ++ && strstr(ent->d_name, ".tab") == NULL; ++} ++ ++static int sysdbcmp(const void *first, const void *second) ++{ ++ const timelib_tzdb_index_entry *alpha = first, *beta = second; ++ ++ return strcasecmp(alpha->id, beta->id); ++} ++ ++ ++/* Create the zone identifier index by trawling the filesystem. */ ++static void create_zone_index(timelib_tzdb *db) ++{ ++ size_t dirstack_size, dirstack_top; ++ size_t index_size, index_next; ++ timelib_tzdb_index_entry *db_index; ++ char **dirstack; ++ ++ /* LIFO stack to hold directory entries to scan; each slot is a ++ * directory name relative to the zoneinfo prefix. */ ++ dirstack_size = 32; ++ dirstack = malloc(dirstack_size * sizeof *dirstack); ++ dirstack_top = 1; ++ dirstack[0] = strdup(""); ++ ++ /* Index array. */ ++ index_size = 64; ++ db_index = malloc(index_size * sizeof *db_index); ++ index_next = 0; ++ ++ do { ++ struct dirent **ents; ++ char name[PATH_MAX], *top; ++ int count; ++ ++ /* Pop the top stack entry, and iterate through its contents. */ ++ top = dirstack[--dirstack_top]; ++ snprintf(name, sizeof name, ZONEINFO_PREFIX "/%s", top); ++ ++ count = php_scandir(name, &ents, index_filter, php_alphasort); ++ ++ while (count > 0) { ++ struct stat st; ++ const char *leaf = ents[count - 1]->d_name; ++ ++ snprintf(name, sizeof name, ZONEINFO_PREFIX "/%s/%s", ++ top, leaf); ++ ++ if (strlen(name) && stat(name, &st) == 0) { ++ /* Name, relative to the zoneinfo prefix. */ ++ const char *root = top; ++ ++ if (root[0] == '/') root++; ++ ++ snprintf(name, sizeof name, "%s%s%s", root, ++ *root ? "/": "", leaf); ++ ++ if (S_ISDIR(st.st_mode)) { ++ if (dirstack_top == dirstack_size) { ++ dirstack_size *= 2; ++ dirstack = realloc(dirstack, ++ dirstack_size * sizeof *dirstack); ++ } ++ dirstack[dirstack_top++] = strdup(name); ++ } ++ else { ++ if (index_next == index_size) { ++ index_size *= 2; ++ db_index = realloc(db_index, ++ index_size * sizeof *db_index); ++ } ++ ++ db_index[index_next++].id = strdup(name); ++ } ++ } ++ ++ free(ents[--count]); ++ } ++ ++ if (count != -1) free(ents); ++ free(top); ++ } while (dirstack_top); ++ ++ qsort(db_index, index_next, sizeof *db_index, sysdbcmp); ++ ++ db->index = db_index; ++ db->index_size = index_next; ++ ++ free(dirstack); ++} ++ ++#define FAKE_HEADER "1234\0??\1??" ++#define FAKE_UTC_POS (7 - 4) ++ ++/* Create a fake data segment for database 'sysdb'. */ ++static void fake_data_segment(timelib_tzdb *sysdb, ++ struct location_info **info) ++{ ++ size_t n; ++ char *data, *p; ++ ++ data = malloc(3 * sysdb->index_size + 7); ++ ++ p = mempcpy(data, FAKE_HEADER, sizeof(FAKE_HEADER) - 1); ++ ++ for (n = 0; n < sysdb->index_size; n++) { ++ const struct location_info *li; ++ timelib_tzdb_index_entry *ent; ++ ++ ent = (timelib_tzdb_index_entry *)&sysdb->index[n]; ++ ++ /* Lookup the timezone name in the hash table. */ ++ if (strcmp(ent->id, "UTC") == 0) { ++ ent->pos = FAKE_UTC_POS; ++ continue; ++ } ++ ++ li = find_zone_info(info, ent->id); ++ if (li) { ++ /* If found, append the BC byte and the ++ * country code; set the position for this ++ * section of timezone data. */ ++ ent->pos = (p - data) - 4; ++ *p++ = '\1'; ++ *p++ = li->code[0]; ++ *p++ = li->code[1]; ++ } ++ else { ++ /* If not found, the timezone data can ++ * point at the header. */ ++ ent->pos = 0; ++ } ++ } ++ ++ sysdb->data = (unsigned char *)data; ++} ++ ++/* Returns true if the passed-in stat structure describes a ++ * probably-valid timezone file. */ ++static int is_valid_tzfile(const struct stat *st) ++{ ++ return S_ISREG(st->st_mode) && st->st_size > 20; ++} ++ ++/* To allow timezone names to be used case-insensitively, find the ++ * canonical name for this timezone, if possible. */ ++static const char *canonical_tzname(const char *timezone) ++{ ++ if (timezonedb_system) { ++ timelib_tzdb_index_entry *ent, lookup; ++ ++ lookup.id = (char *)timezone; ++ ++ ent = bsearch(&lookup, timezonedb_system->index, ++ timezonedb_system->index_size, sizeof lookup, ++ sysdbcmp); ++ if (ent) { ++ return ent->id; ++ } ++ } ++ ++ return timezone; ++} ++ ++/* Return the mmap()ed tzfile if found, else NULL. On success, the ++ * length of the mapped data is placed in *length. */ ++static char *map_tzfile(const char *timezone, size_t *length) ++{ ++ char fname[PATH_MAX]; ++ struct stat st; ++ char *p; ++ int fd; ++ ++ if (timezone[0] == '\0' || strstr(timezone, "..") != NULL) { ++ return NULL; ++ } ++ ++ snprintf(fname, sizeof fname, ZONEINFO_PREFIX "/%s", canonical_tzname(timezone)); ++ ++ fd = open(fname, O_RDONLY); ++ if (fd == -1) { ++ return NULL; ++ } else if (fstat(fd, &st) != 0 || !is_valid_tzfile(&st)) { ++ close(fd); ++ return NULL; ++ } ++ ++ *length = st.st_size; ++ p = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); ++ close(fd); ++ ++ return p != MAP_FAILED ? p : NULL; ++} ++ ++#endif ++ ++static int inmem_seek_to_tz_position(const unsigned char **tzf, char *timezone, const timelib_tzdb *tzdb) + { + int left = 0, right = tzdb->index_size - 1; + #ifdef HAVE_SETLOCALE +@@ -341,21 +771,88 @@ static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const + return 0; + } + ++static int seek_to_tz_position(const unsigned char **tzf, char *timezone, ++ char **map, size_t *maplen, ++ const timelib_tzdb *tzdb) ++{ ++#ifdef HAVE_SYSTEM_TZDATA ++ if (tzdb == timezonedb_system) { ++ char *orig; ++ ++ orig = map_tzfile(timezone, maplen); ++ if (orig == NULL) { ++ return 0; ++ } ++ ++ (*tzf) = (unsigned char *)orig; ++ *map = orig; ++ return 1; ++ } ++ else ++#endif ++ { ++ return inmem_seek_to_tz_position(tzf, timezone, tzdb); ++ } ++} ++ + const timelib_tzdb *timelib_builtin_db(void) + { ++#ifdef HAVE_SYSTEM_TZDATA ++ if (timezonedb_system == NULL) { ++ timelib_tzdb *tmp = malloc(sizeof *tmp); ++ ++ tmp->version = "0.system"; ++ tmp->data = NULL; ++ create_zone_index(tmp); ++ system_location_table = create_location_table(); ++ fake_data_segment(tmp, system_location_table); ++ timezonedb_system = tmp; ++ } ++ ++ return timezonedb_system; ++#else + return &timezonedb_builtin; ++#endif + } + + const timelib_tzdb_index_entry *timelib_timezone_builtin_identifiers_list(int *count) + { ++#ifdef HAVE_SYSTEM_TZDATA ++ *count = timezonedb_system->index_size; ++ return timezonedb_system->index; ++#else + *count = sizeof(timezonedb_idx_builtin) / sizeof(*timezonedb_idx_builtin); + return timezonedb_idx_builtin; ++#endif + } + + int timelib_timezone_id_is_valid(char *timezone, const timelib_tzdb *tzdb) + { + const unsigned char *tzf; +- return (seek_to_tz_position(&tzf, timezone, tzdb)); ++ ++#ifdef HAVE_SYSTEM_TZDATA ++ if (tzdb == timezonedb_system) { ++ char fname[PATH_MAX]; ++ struct stat st; ++ ++ if (timezone[0] == '\0' || strstr(timezone, "..") != NULL) { ++ return 0; ++ } ++ ++ if (system_location_table) { ++ if (find_zone_info(system_location_table, timezone) != NULL) { ++ /* found in cache */ ++ return 1; ++ } ++ } ++ ++ snprintf(fname, sizeof fname, ZONEINFO_PREFIX "/%s", canonical_tzname(timezone)); ++ ++ return stat(fname, &st) == 0 && is_valid_tzfile(&st); ++ } ++#endif ++ ++ return (inmem_seek_to_tz_position(&tzf, timezone, tzdb)); + } + + static void skip_64bit_preamble(const unsigned char **tzf, timelib_tzinfo *tz) +@@ -380,24 +877,54 @@ static void read_64bit_header(const unsigned char **tzf, timelib_tzinfo *tz) + timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb) + { + const unsigned char *tzf; ++ char *memmap = NULL; ++ size_t maplen; + timelib_tzinfo *tmp; + int version; + +- if (seek_to_tz_position(&tzf, timezone, tzdb)) { ++ if (seek_to_tz_position(&tzf, timezone, &memmap, &maplen, tzdb)) { + tmp = timelib_tzinfo_ctor(timezone); + + version = read_preamble(&tzf, tmp); + read_header(&tzf, tmp); + read_transistions(&tzf, tmp); + read_types(&tzf, tmp); +- if (version == 2) { +- skip_64bit_preamble(&tzf, tmp); +- read_64bit_header(&tzf, tmp); +- skip_64bit_transistions(&tzf, tmp); +- skip_64bit_types(&tzf, tmp); +- skip_posix_string(&tzf, tmp); +- } +- read_location(&tzf, tmp); ++ ++#ifdef HAVE_SYSTEM_TZDATA ++ if (memmap) { ++ const struct location_info *li; ++ ++ /* TZif-style - grok the location info from the system database, ++ * if possible. */ ++ ++ if ((li = find_zone_info(system_location_table, timezone)) != NULL) { ++ tmp->location.comments = timelib_strdup(li->comment); ++ strncpy(tmp->location.country_code, li->code, 2); ++ tmp->location.longitude = li->longitude; ++ tmp->location.latitude = li->latitude; ++ tmp->bc = 1; ++ } ++ else { ++ strcpy(tmp->location.country_code, "??"); ++ tmp->bc = 0; ++ tmp->location.comments = timelib_strdup(""); ++ } ++ ++ /* Now done with the mmap segment - discard it. */ ++ munmap(memmap, maplen); ++ } else ++#endif ++ { ++ /* PHP-style - use the embedded info. */ ++ if (version == 2) { ++ skip_64bit_preamble(&tzf, tmp); ++ read_64bit_header(&tzf, tmp); ++ skip_64bit_transistions(&tzf, tmp); ++ skip_64bit_types(&tzf, tmp); ++ skip_posix_string(&tzf, tmp); ++ } ++ read_location(&tzf, tmp); ++ } + } else { + tmp = NULL; + } +diff --git a/ext/date/lib/timelib.m4 b/ext/date/lib/timelib.m4 +index c725572..4c837c7 100644 +--- a/ext/date/lib/timelib.m4 ++++ b/ext/date/lib/timelib.m4 +@@ -78,3 +78,17 @@ stdlib.h + + dnl Check for strtoll, atoll + AC_CHECK_FUNCS(strtoll atoll strftime) ++ ++PHP_ARG_WITH(system-tzdata, for use of system timezone data, ++[ --with-system-tzdata[=DIR] to specify use of system timezone data], ++no, no) ++ ++if test "$PHP_SYSTEM_TZDATA" != "no"; then ++ AC_DEFINE(HAVE_SYSTEM_TZDATA, 1, [Define if system timezone data is used]) ++ ++ if test "$PHP_SYSTEM_TZDATA" != "yes"; then ++ AC_DEFINE_UNQUOTED(HAVE_SYSTEM_TZDATA_PREFIX, "$PHP_SYSTEM_TZDATA", ++ [Define for location of system timezone data]) ++ fi ++fi ++ diff --git a/lang/php7/patches/0014-force_libmysqlclient_r.patch b/lang/php7/patches/0014-force_libmysqlclient_r.patch new file mode 100644 index 000000000..8f15181c3 --- /dev/null +++ b/lang/php7/patches/0014-force_libmysqlclient_r.patch @@ -0,0 +1,35 @@ +From: Debian PHP Maintainers +Date: Sat, 2 May 2015 10:26:53 +0200 +Subject: force_libmysqlclient_r + +--- + ext/mysqli/config.m4 | 2 +- + ext/pdo_mysql/config.m4 | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/ext/mysqli/config.m4 b/ext/mysqli/config.m4 +index c700dac..8932005 100644 +--- a/ext/mysqli/config.m4 ++++ b/ext/mysqli/config.m4 +@@ -59,7 +59,7 @@ elif test "$PHP_MYSQLI" != "no"; then + MYSQL_LIB_CFG='--libmysqld-libs' + dnl mysqlnd doesn't support embedded, so we have to add some extra stuff + mysqli_extra_sources="mysqli_embedded.c" +- elif test "$enable_maintainer_zts" = "yes"; then ++ elif true || test "$enable_maintainer_zts" = "yes"; then + MYSQL_LIB_CFG='--libs_r' + MYSQL_LIB_NAME='mysqlclient_r' + else +diff --git a/ext/pdo_mysql/config.m4 b/ext/pdo_mysql/config.m4 +index c165fb6..2e391eb 100755 +--- a/ext/pdo_mysql/config.m4 ++++ b/ext/pdo_mysql/config.m4 +@@ -67,7 +67,7 @@ if test "$PHP_PDO_MYSQL" != "no"; then + if test "x$SED" = "x"; then + AC_PATH_PROG(SED, sed) + fi +- if test "$enable_maintainer_zts" = "yes"; then ++ if true || test "$enable_maintainer_zts" = "yes"; then + PDO_MYSQL_LIBNAME=mysqlclient_r + PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs_r | $SED -e "s/'//g"` + else diff --git a/lang/php7/patches/0016-dont-gitclean-in-build.patch b/lang/php7/patches/0016-dont-gitclean-in-build.patch new file mode 100644 index 000000000..32de5579f --- /dev/null +++ b/lang/php7/patches/0016-dont-gitclean-in-build.patch @@ -0,0 +1,19 @@ +From: Debian PHP Maintainers +Date: Sat, 2 May 2015 10:26:53 +0200 +Subject: dont-gitclean-in-build + +--- + build/build.mk | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/build/build.mk b/build/build.mk +index 9452984..b964def 100644 +--- a/build/build.mk ++++ b/build/build.mk +@@ -63,6 +63,5 @@ gitclean-work: + @if (test ! -f '.git/info/exclude' || grep -s "git-ls-files" .git/info/exclude); then \ + (echo "Rebuild .git/info/exclude" && echo '*.o' > .git/info/exclude && git svn propget svn:ignore | grep -v config.nice >> .git/info/exclude); \ + fi; \ +- git clean -X -f -d; + + .PHONY: $(ALWAYS) snapshot diff --git a/lang/php7/patches/0032-Use-system-timezone.patch b/lang/php7/patches/0032-Use-system-timezone.patch new file mode 100644 index 000000000..11a6393bf --- /dev/null +++ b/lang/php7/patches/0032-Use-system-timezone.patch @@ -0,0 +1,43 @@ +From: Debian PHP Maintainers +Date: Sat, 2 May 2015 10:26:56 +0200 +Subject: Use system timezone + +Upstream don't want this patch. See +http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=730771 for a summary. + +This delta is recovered from previous versions of the system timezone patch in +Debian, and appears to have inadvertently been dropped. Author unknown. + +To be used in tandem with use_embedded_timezonedb.patch and use_embedded_timezonedb_fixes.patch. +--- + ext/date/php_date.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/ext/date/php_date.c b/ext/date/php_date.c +index e780b2e..2b5a528 100644 +--- a/ext/date/php_date.c ++++ b/ext/date/php_date.c +@@ -992,6 +992,23 @@ static char* guess_timezone(const timelib_tzdb *tzdb) + DATEG(timezone_valid) = 1; + return DATEG(default_timezone); + } ++ /* Try to guess timezone from system information */ ++ { ++ struct tm *ta, tmbuf; ++ time_t the_time; ++ char *tzid = NULL; ++ ++ the_time = time(NULL); ++ ta = php_localtime_r(&the_time, &tmbuf); ++ if (ta) { ++ tzid = timelib_timezone_id_from_abbr(ta->tm_zone, ta->tm_gmtoff, ta->tm_isdst); ++ } ++ if (! tzid) { ++ tzid = "UTC"; ++ } ++ ++ return tzid; ++ } + /* Fallback to UTC */ + return "UTC"; + } diff --git a/lang/php7/patches/0041-Add-patch-to-remove-build-timestamps-from-generated-.patch b/lang/php7/patches/0041-Add-patch-to-remove-build-timestamps-from-generated-.patch new file mode 100644 index 000000000..7639e5672 --- /dev/null +++ b/lang/php7/patches/0041-Add-patch-to-remove-build-timestamps-from-generated-.patch @@ -0,0 +1,131 @@ +From: Thijs Kinkhorst +Date: Wed, 15 Jun 2016 09:18:03 +0200 +Subject: Add patch to remove build timestamps from generated binaries. + +--- + ext/standard/info.c | 1 - + sapi/apache2handler/config.m4 | 15 +++------------ + sapi/cgi/cgi_main.c | 4 ++-- + sapi/cli/php_cli.c | 4 ++-- + sapi/fpm/fpm/fpm_main.c | 4 ++-- + sapi/litespeed/lsapi_main.c | 4 ++-- + sapi/phpdbg/phpdbg.c | 4 +--- + 7 files changed, 12 insertions(+), 24 deletions(-) + +diff --git a/ext/standard/info.c b/ext/standard/info.c +index e6eaac3..024e5c9 100644 +--- a/ext/standard/info.c ++++ b/ext/standard/info.c +@@ -863,7 +863,6 @@ PHPAPI void php_print_info(int flag) + php_info_print_box_end(); + php_info_print_table_start(); + php_info_print_table_row(2, "System", ZSTR_VAL(php_uname)); +- php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__); + #ifdef COMPILER + php_info_print_table_row(2, "Compiler", COMPILER); + #endif +diff --git a/sapi/apache2handler/config.m4 b/sapi/apache2handler/config.m4 +index f286b1a..fba92b8 100644 +--- a/sapi/apache2handler/config.m4 ++++ b/sapi/apache2handler/config.m4 +@@ -59,18 +59,9 @@ if test "$PHP_APXS2" != "no"; then + APACHE_CFLAGS="$APACHE_CPPFLAGS -I$APXS_INCLUDEDIR $APR_CFLAGS $APU_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" + + APXS_LIBEXECDIR='$(INSTALL_ROOT)'`$APXS -q LIBEXECDIR` +- if test -z `$APXS -q SYSCONFDIR`; then +- INSTALL_IT="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \ +- $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \ +- -i -n php7" +- else +- APXS_SYSCONFDIR='$(INSTALL_ROOT)'`$APXS -q SYSCONFDIR` +- INSTALL_IT="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \ +- \$(mkinstalldirs) '$APXS_SYSCONFDIR' && \ +- $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \ +- -S SYSCONFDIR='$APXS_SYSCONFDIR' \ +- -i -a -n php7" +- fi ++ INSTALL_IT="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \ ++ $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \ ++ -i -n php7" + + case $host_alias in + *aix*) +diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c +index 8983b53..589e299 100644 +--- a/sapi/cgi/cgi_main.c ++++ b/sapi/cgi/cgi_main.c +@@ -2216,9 +2216,9 @@ consult the installation file that came with this distribution, or visit \n\ + SG(request_info).no_headers = 1; + } + #if ZEND_DEBUG +- php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2016 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); ++ php_printf("PHP %s (%s) (DEBUG)\nCopyright (c) 1997-2016 The PHP Group\n%s", PHP_VERSION, sapi_module.name, get_zend_version()); + #else +- php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2016 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); ++ php_printf("PHP %s (%s)\nCopyright (c) 1997-2016 The PHP Group\n%s", PHP_VERSION, sapi_module.name, get_zend_version()); + #endif + php_request_shutdown((void *) 0); + fcgi_shutdown(); +diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c +index 978c8b3..3ee61a4 100644 +--- a/sapi/cli/php_cli.c ++++ b/sapi/cli/php_cli.c +@@ -682,8 +682,8 @@ static int do_cli(int argc, char **argv) /* {{{ */ + goto out; + + case 'v': /* show php version & quit */ +- php_printf("PHP %s (%s) (built: %s %s) ( %s)\nCopyright (c) 1997-2016 The PHP Group\n%s", +- PHP_VERSION, cli_sapi_module.name, __DATE__, __TIME__, ++ php_printf("PHP %s (%s) ( %s)\nCopyright (c) 1997-2016 The PHP Group\n%s", ++ PHP_VERSION, cli_sapi_module.name, + #if ZTS + "ZTS " + #else +diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c +index 5adeb63..5e60255 100644 +--- a/sapi/fpm/fpm/fpm_main.c ++++ b/sapi/fpm/fpm/fpm_main.c +@@ -1757,9 +1757,9 @@ int main(int argc, char *argv[]) + SG(request_info).no_headers = 1; + + #if ZEND_DEBUG +- php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2016 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); ++ php_printf("PHP %s (%s) (DEBUG)\nCopyright (c) 1997-2016 The PHP Group\n%s", PHP_VERSION, sapi_module.name, get_zend_version()); + #else +- php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2016 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); ++ php_printf("PHP %s (%s)\nCopyright (c) 1997-2016 The PHP Group\n%s", PHP_VERSION, sapi_module.name, get_zend_version()); + #endif + php_request_shutdown((void *) 0); + fcgi_shutdown(); +diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c +index b0ea105..4feb8f3 100644 +--- a/sapi/litespeed/lsapi_main.c ++++ b/sapi/litespeed/lsapi_main.c +@@ -811,9 +811,9 @@ static int cli_main( int argc, char * argv[] ) + case 'v': + if (php_request_startup() != FAILURE) { + #if ZEND_DEBUG +- php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2016 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); ++ php_printf("PHP %s (%s) (DEBUG)\nCopyright (c) 1997-2016 The PHP Group\n%s", PHP_VERSION, sapi_module.name, get_zend_version()); + #else +- php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2016 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); ++ php_printf("PHP %s (%s)\nCopyright (c) 1997-2016 The PHP Group\n%s", PHP_VERSION, sapi_module.name, get_zend_version()); + #endif + #ifdef PHP_OUTPUT_NEWAPI + php_output_end_all(); +diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c +index 68a164c..82565d8 100644 +--- a/sapi/phpdbg/phpdbg.c ++++ b/sapi/phpdbg/phpdbg.c +@@ -1520,10 +1520,8 @@ phpdbg_main: + sapi_startup(phpdbg); + phpdbg->startup(phpdbg); + printf( +- "phpdbg %s (built: %s %s)\nPHP %s, Copyright (c) 1997-2016 The PHP Group\n%s", ++ "phpdbg %s\nPHP %s, Copyright (c) 1997-2016 The PHP Group\n%s", + PHPDBG_VERSION, +- __DATE__, +- __TIME__, + PHP_VERSION, + get_zend_version() + ); diff --git a/lang/php7/patches/0042-Remove-W3C-validation-icon-to-not-expose-the-reader-.patch b/lang/php7/patches/0042-Remove-W3C-validation-icon-to-not-expose-the-reader-.patch new file mode 100644 index 000000000..78f7dca4b --- /dev/null +++ b/lang/php7/patches/0042-Remove-W3C-validation-icon-to-not-expose-the-reader-.patch @@ -0,0 +1,25 @@ +From: =?utf-8?q?Ond=C5=99ej_Sur=C3=BD?= +Date: Wed, 29 Jul 2015 14:37:55 +0200 +Subject: Remove W3C validation icon to not expose the reader's IP address to + potential tracking. + +--- + sapi/fpm/status.html.in | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/sapi/fpm/status.html.in b/sapi/fpm/status.html.in +index 86492d7..31c31ff 100644 +--- a/sapi/fpm/status.html.in ++++ b/sapi/fpm/status.html.in +@@ -71,11 +71,6 @@ + PID↓Start TimeStart SinceRequests ServedRequest DurationRequest methodRequest URIContent LengthUserScriptLast Request %CPULast Request Memory + + +-

+- +- Valid XHTML 1.0 Transitional +- +-

+