Skip to content

Commit b632778

Browse files
committed
1 parent 1508cd9 commit b632778

File tree

4 files changed

+23
-20
lines changed

4 files changed

+23
-20
lines changed

config.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ if test "$PHP_XZ" != "no"; then
2121
])
2222
PHP_SUBST(XZ_SHARED_LIBADD)
2323

24-
PHP_NEW_EXTENSION(xz, xz.c xz_fopen_wrapper.c utils.c, $ext_shared)
24+
PHP_NEW_EXTENSION(xz, xz.c xz_fopen_wrapper.c utils.c, $ext_shared, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
2525
fi

php_xz.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ extern php_stream_wrapper php_stream_xz_wrapper;
3636
# define PHP_XZ_API
3737
#endif
3838

39-
# if defined(ZTS) && defined(COMPILE_DL_XZ)
40-
ZEND_TSRMLS_CACHE_EXTERN()
41-
# endif
42-
4339
#ifdef ZTS
4440
# include "TSRM.h"
4541
#endif
@@ -53,15 +49,7 @@ PHP_FUNCTION(xzopen);
5349
PHP_FUNCTION(xzencode);
5450
PHP_FUNCTION(xzdecode);
5551

56-
php_stream *php_stream_xzopen(php_stream_wrapper *wrapper, const char *path,
57-
const char *mode_pass, int options, zend_string **opened_path,
58-
php_stream_context *context STREAMS_DC);
59-
60-
#ifdef ZTS
61-
# define XZ_G(v) TSRMG(xz_globals_id, zend_xz_globals *, v)
62-
#else
63-
# define XZ_G(v) (xz_globals.v)
64-
#endif
52+
php_stream *php_stream_xzopen(php_stream_wrapper *wrapper, const char *path, const char *mode_pass, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC);
6553

6654
#endif /* PHP_XZ_H */
6755

xz.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ PHP_MINFO_FUNCTION(xz)
146146
PHP_FUNCTION(xzopen)
147147
{
148148
char *filename = NULL, *mode = NULL;
149-
size_t filename_len = 0, mode_len = 0;
150-
unsigned long compression_level = INI_INT("xz.compression_level");
149+
zend_long filename_len = 0, mode_len = 0;
150+
zend_ulong compression_level = INI_INT("xz.compression_level");
151151

152152
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|l", &filename, &filename_len, &mode, &mode_len, &compression_level) == FAILURE) {
153153
return;

xz_fopen_wrapper.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ static int php_xz_init_encoder(struct php_xz_stream_data_t *self)
172172

173173
/* {{{ php_xziop_read
174174
Reads from the stream. */
175+
#if PHP_VERSION_ID >= 70400
175176
static ssize_t php_xziop_read(php_stream *stream, char *buf, size_t count)
177+
#else
178+
static size_t php_xziop_read(php_stream *stream, char *buf, size_t count)
179+
#endif
176180
{
177181
struct php_xz_stream_data_t *self = (struct php_xz_stream_data_t *) stream->abstract;
178182
lzma_stream *strm = &self->strm;
@@ -210,7 +214,11 @@ static ssize_t php_xziop_read(php_stream *stream, char *buf, size_t count)
210214

211215
/* {{{ php_xziop_write
212216
Writes to the stream. */
217+
#if PHP_VERSION_ID >= 70400
213218
static ssize_t php_xziop_write(php_stream *stream, const char *buf, size_t count)
219+
#else
220+
static size_t php_xziop_write(php_stream *stream, const char *buf, size_t count)
221+
#endif
214222
{
215223
struct php_xz_stream_data_t *self = (struct php_xz_stream_data_t *) stream->abstract;
216224
int wrote = 0, bytes_consumed = 0;
@@ -305,14 +313,21 @@ php_stream_ops php_stream_xzio_ops = {
305313
NULL, /* cast */
306314
NULL, /* stat */
307315
NULL /* set_option */
316+
.label = "XZ",
317+
.write = php_xziop_write,
318+
.read = php_xziop_read,
319+
.close = php_xziop_close,
320+
.flush = php_xziop_flush,
321+
.seek = NULL,
322+
.cast = NULL,
323+
.stat = NULL,
324+
.set_option = NULL
308325
};
309326
/* }}} */
310327

311328
/* {{{ php_stream_xzopen
312329
Opens a stream. */
313-
php_stream *php_stream_xzopen(php_stream_wrapper *wrapper, const char *path,
314-
const char *mode_pass, int options, zend_string **opened_path,
315-
php_stream_context *context STREAMS_DC)
330+
php_stream *php_stream_xzopen(php_stream_wrapper *wrapper, const char *path, const char *mode_pass, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC)
316331
{
317332
char mode[64];
318333
unsigned long level = 6;
@@ -323,7 +338,7 @@ php_stream *php_stream_xzopen(php_stream_wrapper *wrapper, const char *path,
323338

324339
/* The pointer below is freed even though it is `const` because it was
325340
manually allocated in `xzopen`.. */
326-
efree((void *) mode_pass);
341+
efree((char *) mode_pass);
327342

328343
/* Split compression level and mode. */
329344
char *colonp = strchr(mode, ':');

0 commit comments

Comments
 (0)