1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
From 479c32d63619e3164f3a49bca856eed0c7cef333 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Tue, 23 Jul 2019 16:52:30 +0200
Subject: [PATCH 1/2] fix for stream changes in 7.4.0beta1
---
zstd.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/zstd.c b/zstd.c
index 46bfc8e..8319abb 100644
--- a/zstd.c
+++ b/zstd.c
@@ -488,9 +488,16 @@ static int php_zstd_comp_close(php_stream *stream, int close_handle TSRMLS_DC)
}
+#if PHP_VERSION_ID < 70400
static size_t php_zstd_decomp_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
{
- size_t x, res, ret = 0;
+ size_t ret = 0;
+#else
+static ssize_t php_zstd_decomp_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
+{
+ ssize_t ret = 0;
+#endif
+ size_t x, res;
STREAM_DATA_FROM_STREAM();
while (count > 0) {
@@ -536,9 +543,16 @@ static size_t php_zstd_decomp_read(php_stream *stream, char *buf, size_t count T
}
+#if PHP_VERSION_ID < 70400
static size_t php_zstd_comp_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
{
- size_t res, x, ret = 0;
+ size_t ret = 0;
+#else
+static ssize_t php_zstd_comp_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
+{
+ ssize_t ret = 0;
+#endif
+ size_t x, res;
STREAM_DATA_FROM_STREAM();
From 419542ad635c0aa8fdfc5f49ea6c2ae1ea815220 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Tue, 23 Jul 2019 16:58:39 +0200
Subject: [PATCH 2/2] report error to PHP stream wrapper
---
zstd.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/zstd.c b/zstd.c
index 8319abb..b8f851e 100644
--- a/zstd.c
+++ b/zstd.c
@@ -525,6 +525,9 @@ static ssize_t php_zstd_decomp_read(php_stream *stream, char *buf, size_t count
res = ZSTD_decompressStream(self->dctx, &self->output , &self->input);
if (ZSTD_isError(res)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "libzstd error %s\n", ZSTD_getErrorName(res));
+#if PHP_VERSION_ID >= 70400
+ return -1;
+#endif
}
/* for us */
self->output.size = self->output.pos;
@@ -586,6 +589,9 @@ static ssize_t php_zstd_comp_write(php_stream *stream, const char *buf, size_t c
#endif
if (ZSTD_isError(res)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "libzstd error %s\n", ZSTD_getErrorName(res));
+#if PHP_VERSION_ID >= 70400
+ return -1;
+#endif
}
php_stream_write(self->stream, self->bufout, self->output.pos);
} while (self->input.pos != self->input.size);
|