summaryrefslogtreecommitdiffstats
path: root/xattr-php7.patch
diff options
context:
space:
mode:
Diffstat (limited to 'xattr-php7.patch')
-rw-r--r--xattr-php7.patch222
1 files changed, 222 insertions, 0 deletions
diff --git a/xattr-php7.patch b/xattr-php7.patch
new file mode 100644
index 0000000..fbd2285
--- /dev/null
+++ b/xattr-php7.patch
@@ -0,0 +1,222 @@
+--- pecl/xattr/trunk/php_xattr.h 2015/04/06 16:58:20 336402
++++ pecl/xattr/trunk/php_xattr.h 2015/04/06 17:01:25 336403
+@@ -1,13 +1,13 @@
+ /*
+ +----------------------------------------------------------------------+
+- | PHP Version 5 |
++ | PHP Version 5, 7 |
+ +----------------------------------------------------------------------+
+- | Copyright (c) 1997-2004 The PHP Group |
++ | Copyright (c) 1997-2015 The PHP Group |
+ +----------------------------------------------------------------------+
+- | This source file is subject to version 3.0 of the PHP license, |
++ | This source file is subject to version 3.01 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. |
++ | http://www.php.net/license/3_01.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. |
+@@ -45,6 +45,17 @@
+ PHP_FUNCTION(xattr_list);
+ PHP_FUNCTION(xattr_supported);
+
++#if PHP_MAJOR_VERSION < 7
++typedef long zend_long;
++typedef int strsize_t;
++#define _RETVAL_STRINGL(s,l,d) RETVAL_STRINGL(s,l,d)
++#define _RETURN_STRINGL(s,l,d) RETURN_STRINGL(s,l,d)
++#else
++typedef size_t strsize_t;
++#define _RETVAL_STRINGL(s,l,d) { RETVAL_STRINGL(s,l); if (!d) efree(s); }
++#define _RETURN_STRINGL(s,l,d) { _RETVAL_STRINGL(s,l,d); return; }
++#endif
++
+ #endif /* PHP_XATTR_H */
+
+
+--- pecl/xattr/trunk/xattr.c 2015/04/06 16:58:20 336402
++++ pecl/xattr/trunk/xattr.c 2015/04/06 17:01:25 336403
+@@ -1,13 +1,13 @@
+ /*
+ +----------------------------------------------------------------------+
+- | PHP Version 5 |
++ | PHP Version 5, 7 |
+ +----------------------------------------------------------------------+
+- | Copyright (c) 1997-2004 The PHP Group |
++ | Copyright (c) 1997-2015 The PHP Group |
+ +----------------------------------------------------------------------+
+- | This source file is subject to version 3.0 of the PHP license, |
++ | This source file is subject to version 3.01 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. |
++ | http://www.php.net/license/3_01.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. |
+@@ -43,17 +43,39 @@
+ #include <sys/types.h>
+ #include <attr/xattr.h>
+
++ZEND_BEGIN_ARG_INFO_EX(xattr_set_arginfo, 0, 0, 3)
++ ZEND_ARG_INFO(0, path)
++ ZEND_ARG_INFO(0, name)
++ ZEND_ARG_INFO(0, value)
++ ZEND_ARG_INFO(0, flags)
++ZEND_END_ARG_INFO()
++
++ZEND_BEGIN_ARG_INFO_EX(xattr_get_arginfo, 0, 0, 2)
++ ZEND_ARG_INFO(0, path)
++ ZEND_ARG_INFO(0, name)
++ ZEND_ARG_INFO(0, flags)
++ZEND_END_ARG_INFO()
++
++ZEND_BEGIN_ARG_INFO_EX(xattr_list_arginfo, 0, 0, 1)
++ ZEND_ARG_INFO(0, path)
++ ZEND_ARG_INFO(0, flags)
++ZEND_END_ARG_INFO()
++
+ /* {{{ xattr_functions[]
+ *
+ * Every user visible function must have an entry in xattr_functions[].
+ */
+ zend_function_entry xattr_functions[] = {
+- PHP_FE(xattr_set, NULL)
+- PHP_FE(xattr_get, NULL)
+- PHP_FE(xattr_remove, NULL)
+- PHP_FE(xattr_list, NULL)
+- PHP_FE(xattr_supported, NULL)
+- {NULL, NULL, NULL} /* Must be the last line in xattr_functions[] */
++ PHP_FE(xattr_set, xattr_set_arginfo)
++ PHP_FE(xattr_get, xattr_get_arginfo)
++ PHP_FE(xattr_remove, xattr_get_arginfo)
++ PHP_FE(xattr_list, xattr_list_arginfo)
++ PHP_FE(xattr_supported, xattr_list_arginfo)
++#ifdef PHP_FE_END
++ PHP_FE_END
++#else
++ { NULL, NULL, NULL }
++#endif
+ };
+ /* }}} */
+
+@@ -112,7 +134,9 @@
+ char *attr_name = NULL;
+ char *attr_value = NULL;
+ char *path = NULL;
+- int error, tmp, value_len, flags = 0;
++ int error;
++ zend_long flags = 0;
++ strsize_t tmp, value_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|l", &path, &tmp, &attr_name, &tmp, &attr_value, &value_len, &flags) == FAILURE) {
+ return;
+@@ -131,7 +155,7 @@
+ flags &= ATTR_ROOT | ATTR_DONTFOLLOW | ATTR_CREATE | ATTR_REPLACE;
+
+ /* Attempt to set an attribute, warn if failed. */
+- error = attr_set(path, attr_name, attr_value, value_len, flags);
++ error = attr_set(path, attr_name, attr_value, (int)value_len, (int)flags);
+ if (error == -1) {
+ switch (errno) {
+ case E2BIG:
+@@ -164,8 +188,10 @@
+ char *attr_name = NULL;
+ char *attr_value = NULL;
+ char *path = NULL;
+- int error, tmp, flags = 0;
+- size_t buffer_size = XATTR_BUFFER_SIZE;
++ int error;
++ strsize_t tmp;
++ zend_long flags = 0;
++ int buffer_size = XATTR_BUFFER_SIZE;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &path, &tmp, &attr_name, &tmp, &flags) == FAILURE) {
+ return;
+@@ -192,7 +218,7 @@
+ * If buffer is too small then attr_get sets errno to E2BIG and tells us
+ * how many bytes are required by setting buffer_size variable.
+ */
+- error = attr_get(path, attr_name, attr_value, &buffer_size, flags);
++ error = attr_get(path, attr_name, attr_value, &buffer_size, (int)flags);
+
+ /*
+ * Loop is necessary in case that someone edited extended attributes
+@@ -203,13 +229,14 @@
+ if (!attr_value)
+ RETURN_FALSE;
+
+- error = attr_get(path, attr_name, attr_value, &buffer_size, flags);
++ error = attr_get(path, attr_name, attr_value, &buffer_size, (int)flags);
+ }
+
+ /* Return a string if everything is ok */
+ if (!error) {
+- attr_value = erealloc(attr_value, buffer_size);
+- RETURN_STRINGL(attr_value, buffer_size, 0);
++ _RETVAL_STRINGL(attr_value, buffer_size, 1); /* copy + free instead of realloc */
++ efree(attr_value);
++ return;
+ }
+
+ /* Error handling part */
+@@ -240,8 +267,10 @@
+ Checks if filesystem supports extended attributes */
+ PHP_FUNCTION(xattr_supported)
+ {
+- char *buffer, *path = NULL;
+- int error, tmp, flags = 0;
++ char *buffer="", *path = NULL;
++ int error;
++ strsize_t tmp;
++ zend_long flags = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &path, &tmp, &flags) == FAILURE) {
+ return;
+@@ -290,7 +319,9 @@
+ {
+ char *attr_name = NULL;
+ char *path = NULL;
+- int error, tmp, flags = 0;
++ int error;
++ strsize_t tmp;
++ zend_long flags = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &path, &tmp, &attr_name, &tmp, &flags) == FAILURE) {
+ return;
+@@ -309,7 +340,7 @@
+ flags &= ATTR_ROOT | ATTR_DONTFOLLOW;
+
+ /* Attempt to remove an attribute, warn if failed. */
+- error = attr_remove(path, attr_name, flags);
++ error = attr_remove(path, attr_name, (int)flags);
+ if (error == -1) {
+ switch (errno) {
+ case E2BIG:
+@@ -341,8 +372,10 @@
+ {
+ char *buffer, *path = NULL;
+ char *p, *prefix;
+- int error, tmp, flags = 0;
+- ssize_t i = 0, buffer_size = XATTR_BUFFER_SIZE;
++ int error;
++ strsize_t tmp;
++ zend_long flags = 0;
++ size_t i = 0, buffer_size = XATTR_BUFFER_SIZE;
+ size_t len, prefix_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &path, &tmp, &flags) == FAILURE) {
+@@ -442,7 +475,11 @@
+ while (i != buffer_size) {
+ len = strlen(p) + 1; /* +1 for NULL */
+ if (strstr(p, prefix) == p) {
++#if PHP_MAJOR_VERSION < 7
+ add_next_index_stringl(return_value, p + prefix_len, len - 1 - prefix_len, 1);
++#else
++ add_next_index_stringl(return_value, p + prefix_len, len - 1 - prefix_len);
++#endif
+ }
+
+ p += len;