From: Remi Collet Date: Thu, 24 Sep 2020 09:58:37 +0000 (+0200) Subject: fix stream for php <= 7.3 X-Git-Tag: v2.1.8~3 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=04574bc5cdd3d0504d2d70de20279a83ea802019;p=m6w6%2Fext-pq fix stream for php <= 7.3 --- diff --git a/src/php_pqlob.c b/src/php_pqlob.c index 0c1fc28..0cb44a8 100644 --- a/src/php_pqlob.c +++ b/src/php_pqlob.c @@ -100,7 +100,11 @@ static void php_pqlob_object_read_stream(void *o, zval *return_value) RETVAL_ZVAL(&zstream, 1, 0); } +#if PHP_VERSION_ID < 70400 +static size_t php_pqlob_stream_write(php_stream *stream, const char *buffer, size_t length) +#else static ssize_t php_pqlob_stream_write(php_stream *stream, const char *buffer, size_t length) +#endif { php_pqlob_object_t *obj = stream->abstract; ssize_t written = 0; @@ -115,10 +119,18 @@ static ssize_t php_pqlob_stream_write(php_stream *stream, const char *buffer, si php_pqconn_notify_listeners(obj->intern->txn->intern->conn); } +#if PHP_VERSION_ID < 70400 + return (written < 0 ? 0 : written); +#else return written; +#endif } +#if PHP_VERSION_ID < 70400 +static size_t php_pqlob_stream_read(php_stream *stream, char *buffer, size_t length) +#else static ssize_t php_pqlob_stream_read(php_stream *stream, char *buffer, size_t length) +#endif { php_pqlob_object_t *obj = stream->abstract; ssize_t read = 0; @@ -140,7 +152,11 @@ static ssize_t php_pqlob_stream_read(php_stream *stream, char *buffer, size_t le php_pqconn_notify_listeners(obj->intern->txn->intern->conn); } +#if PHP_VERSION_ID < 70400 + return (read < 0 ? 0 : read); +#else return read; +#endif } static ZEND_RESULT_CODE php_pqlob_stream_close(php_stream *stream, int close_handle)