mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
TSRMLS related work on streams, as discussed with Zeev.
# Should be the last "broad" commit for a while # Don't forget to make clean ; make
This commit is contained in:
@@ -3271,7 +3271,7 @@ PHP_FUNCTION(exif_imagetype)
|
||||
|
||||
rsrc_id = ZEND_REGISTER_RESOURCE(NULL, stream, php_file_le_stream());
|
||||
|
||||
itype = itype = php_getimagetype(stream, NULL);
|
||||
itype = itype = php_getimagetype(stream, NULL TSRMLS_CC);
|
||||
|
||||
zend_list_delete(rsrc_id);
|
||||
|
||||
|
||||
@@ -547,6 +547,7 @@ ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type)
|
||||
char *ptr;
|
||||
int lastch;
|
||||
int rcvd;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (ftp == NULL)
|
||||
return 0;
|
||||
@@ -619,6 +620,7 @@ ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type)
|
||||
int size;
|
||||
char *ptr;
|
||||
int ch;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (ftp == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -153,6 +153,7 @@ static void mailparse_rfc822t_errfunc(const char * msg, int num)
|
||||
static void mailparse_do_uudecode(php_stream * instream, php_stream * outstream)
|
||||
{
|
||||
int A, B, C, D, n;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
while(!php_stream_eof(instream)) {
|
||||
UU_NEXT(n);
|
||||
@@ -375,10 +376,13 @@ PHP_FUNCTION(mailparse_determine_best_xfer_encoding)
|
||||
static int mailparse_stream_output(int c, void *stream)
|
||||
{
|
||||
char buf = c;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
return php_stream_write((php_stream*)stream, &buf, 1);
|
||||
}
|
||||
static int mailparse_stream_flush(void *stream)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
return php_stream_flush((php_stream*)stream);
|
||||
}
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ PHP_FUNCTION(get_meta_tags)
|
||||
|
||||
tok_last = TOK_EOF;
|
||||
|
||||
while (!done && (tok = php_next_meta_token(&md)) != TOK_EOF) {
|
||||
while (!done && (tok = php_next_meta_token(&md TSRMLS_CC)) != TOK_EOF) {
|
||||
if (tok == TOK_ID) {
|
||||
if (tok_last == TOK_OPENTAG) {
|
||||
md.in_meta = !strcasecmp("meta", md.token_data);
|
||||
@@ -785,7 +785,7 @@ PHP_FUNCTION(socket_set_blocking)
|
||||
if (php_set_sock_blocking(socketd, block) == FAILURE)
|
||||
RETURN_FALSE;
|
||||
|
||||
php_stream_sock_set_blocking((php_stream*)what, block == 0 ? 0 : 1);
|
||||
php_stream_sock_set_blocking((php_stream*)what, block == 0 ? 0 : 1 TSRMLS_CC);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
RETURN_FALSE;
|
||||
@@ -832,7 +832,7 @@ PHP_FUNCTION(socket_set_timeout)
|
||||
t.tv_usec = 0;
|
||||
|
||||
if (php_stream_is((php_stream*)what, PHP_STREAM_IS_SOCKET)) {
|
||||
php_stream_sock_set_timeout((php_stream*)what, &t);
|
||||
php_stream_sock_set_timeout((php_stream*)what, &t TSRMLS_CC);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
@@ -1947,7 +1947,7 @@ PHP_FUNCTION(realpath)
|
||||
|
||||
/* {{{ php_next_meta_token
|
||||
Tokenizes an HTML file for get_meta_tags */
|
||||
php_meta_tags_token php_next_meta_token(php_meta_tags_data *md)
|
||||
php_meta_tags_token php_next_meta_token(php_meta_tags_data *md TSRMLS_DC)
|
||||
{
|
||||
int ch = 0, compliment;
|
||||
char buff[META_DEF_BUFSIZE + 1];
|
||||
|
||||
@@ -100,7 +100,7 @@ typedef struct _php_meta_tags_data {
|
||||
int in_meta;
|
||||
} php_meta_tags_data;
|
||||
|
||||
php_meta_tags_token php_next_meta_token(php_meta_tags_data *);
|
||||
php_meta_tags_token php_next_meta_token(php_meta_tags_data * TSRMLS_DC);
|
||||
|
||||
typedef struct {
|
||||
int fgetss_state;
|
||||
|
||||
@@ -205,10 +205,10 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
|
||||
int ssl_ret = FAILURE;
|
||||
switch(ssl_flags) {
|
||||
case php_ssl_v23:
|
||||
ssl_ret = php_stream_sock_ssl_activate_with_method(stream, 1, SSLv23_client_method());
|
||||
ssl_ret = php_stream_sock_ssl_activate_with_method(stream, 1, SSLv23_client_method() TSRMLS_CC);
|
||||
break;
|
||||
case php_ssl_tls:
|
||||
ssl_ret = php_stream_sock_ssl_activate_with_method(stream, 1, TLSv1_client_method());
|
||||
ssl_ret = php_stream_sock_ssl_activate_with_method(stream, 1, TLSv1_client_method() TSRMLS_CC);
|
||||
break;
|
||||
default:
|
||||
/* unknown ?? */
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
|
||||
#include "php_fopen_wrappers.h"
|
||||
|
||||
static int php_get_ftp_result(php_stream *stream)
|
||||
static int php_get_ftp_result(php_stream *stream TSRMLS_DC)
|
||||
{
|
||||
char tmp_line[513];
|
||||
|
||||
@@ -85,7 +85,7 @@ php_stream_wrapper php_stream_ftp_wrapper = {
|
||||
|
||||
/* {{{ php_fopen_url_wrap_ftp
|
||||
*/
|
||||
php_stream * php_stream_url_wrap_ftp(char *path, char *mode, int options, char **opened_path STREAMS_DC)
|
||||
php_stream * php_stream_url_wrap_ftp(char *path, char *mode, int options, char **opened_path STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
php_stream *stream=NULL;
|
||||
php_url *resource=NULL;
|
||||
@@ -109,7 +109,7 @@ php_stream * php_stream_url_wrap_ftp(char *path, char *mode, int options, char *
|
||||
goto errexit;
|
||||
|
||||
/* Start talking to ftp server */
|
||||
result = php_get_ftp_result(stream);
|
||||
result = php_get_ftp_result(stream TSRMLS_CC);
|
||||
if (result > 299 || result < 200)
|
||||
goto errexit;
|
||||
|
||||
@@ -124,7 +124,7 @@ php_stream * php_stream_url_wrap_ftp(char *path, char *mode, int options, char *
|
||||
php_stream_write_string(stream, "\r\n");
|
||||
|
||||
/* get the response */
|
||||
result = php_get_ftp_result(stream);
|
||||
result = php_get_ftp_result(stream TSRMLS_CC);
|
||||
|
||||
/* if a password is required, send it */
|
||||
if (result >= 300 && result <= 399) {
|
||||
@@ -144,14 +144,14 @@ php_stream * php_stream_url_wrap_ftp(char *path, char *mode, int options, char *
|
||||
php_stream_write_string(stream, "\r\n");
|
||||
|
||||
/* read the response */
|
||||
result = php_get_ftp_result(stream);
|
||||
result = php_get_ftp_result(stream TSRMLS_CC);
|
||||
}
|
||||
if (result > 299 || result < 200)
|
||||
goto errexit;
|
||||
|
||||
/* set the connection to be binary */
|
||||
php_stream_write_string(stream, "TYPE I\r\n");
|
||||
result = php_get_ftp_result(stream);
|
||||
result = php_get_ftp_result(stream TSRMLS_CC);
|
||||
if (result > 299 || result < 200)
|
||||
goto errexit;
|
||||
|
||||
@@ -161,7 +161,7 @@ php_stream * php_stream_url_wrap_ftp(char *path, char *mode, int options, char *
|
||||
php_stream_write_string(stream, "\r\n");
|
||||
|
||||
/* read the response */
|
||||
result = php_get_ftp_result(stream);
|
||||
result = php_get_ftp_result(stream TSRMLS_CC);
|
||||
if (mode[0] == 'r') {
|
||||
/* when reading file, it must exist */
|
||||
if (result > 299 || result < 200) {
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
#define HTTP_HEADER_BLOCK_SIZE 1024
|
||||
|
||||
|
||||
php_stream *php_stream_url_wrap_http(char *path, char *mode, int options, char **opened_path STREAMS_DC)
|
||||
php_stream *php_stream_url_wrap_http(char *path, char *mode, int options, char **opened_path STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
php_stream *stream = NULL;
|
||||
php_url *resource = NULL;
|
||||
@@ -268,7 +268,7 @@ php_stream *php_stream_url_wrap_http(char *path, char *mode, int options, char *
|
||||
else {
|
||||
strlcpy(new_path, location, sizeof(new_path));
|
||||
}
|
||||
stream = php_stream_url_wrap_http(new_path, mode, options, opened_path STREAMS_CC);
|
||||
stream = php_stream_url_wrap_http(new_path, mode, options, opened_path STREAMS_CC TSRMLS_CC);
|
||||
if (stream->wrapperdata) {
|
||||
entryp = &entry;
|
||||
MAKE_STD_ZVAL(entry);
|
||||
|
||||
@@ -73,7 +73,7 @@ struct gfxinfo {
|
||||
|
||||
/* {{{ php_handle_gif
|
||||
* routine to handle GIF files. If only everything were that easy... ;} */
|
||||
static struct gfxinfo *php_handle_gif (php_stream * stream)
|
||||
static struct gfxinfo *php_handle_gif (php_stream * stream TSRMLS_DC)
|
||||
{
|
||||
struct gfxinfo *result = NULL;
|
||||
unsigned char a[2];
|
||||
@@ -94,7 +94,7 @@ static struct gfxinfo *php_handle_gif (php_stream * stream)
|
||||
|
||||
/* {{{ php_handle_psd
|
||||
*/
|
||||
static struct gfxinfo *php_handle_psd (php_stream * stream)
|
||||
static struct gfxinfo *php_handle_psd (php_stream * stream TSRMLS_DC)
|
||||
{
|
||||
struct gfxinfo *result = NULL;
|
||||
unsigned char a[8];
|
||||
@@ -121,7 +121,7 @@ static struct gfxinfo *php_handle_psd (php_stream * stream)
|
||||
|
||||
/* {{{ php_handle_bmp
|
||||
*/
|
||||
static struct gfxinfo *php_handle_bmp (php_stream * stream)
|
||||
static struct gfxinfo *php_handle_bmp (php_stream * stream TSRMLS_DC)
|
||||
{
|
||||
struct gfxinfo *result = NULL;
|
||||
char temp[15];
|
||||
@@ -159,7 +159,7 @@ static unsigned long int php_swf_get_bits (unsigned char* buffer, unsigned int p
|
||||
|
||||
/* {{{ php_handle_swf
|
||||
*/
|
||||
static struct gfxinfo *php_handle_swf (php_stream * stream)
|
||||
static struct gfxinfo *php_handle_swf (php_stream * stream TSRMLS_DC)
|
||||
{
|
||||
struct gfxinfo *result = NULL;
|
||||
long bits;
|
||||
@@ -180,7 +180,7 @@ static struct gfxinfo *php_handle_swf (php_stream * stream)
|
||||
|
||||
/* {{{ php_handle_png
|
||||
* routine to handle PNG files */
|
||||
static struct gfxinfo *php_handle_png (php_stream * stream)
|
||||
static struct gfxinfo *php_handle_png (php_stream * stream TSRMLS_DC)
|
||||
{
|
||||
struct gfxinfo *result = NULL;
|
||||
unsigned long in_width, in_height;
|
||||
@@ -245,7 +245,7 @@ static struct gfxinfo *php_handle_png (php_stream * stream)
|
||||
|
||||
/* {{{ php_read2
|
||||
*/
|
||||
static unsigned short php_read2(php_stream * stream)
|
||||
static unsigned short php_read2(php_stream * stream TSRMLS_DC)
|
||||
{
|
||||
unsigned char a[2];
|
||||
|
||||
@@ -258,7 +258,7 @@ static unsigned short php_read2(php_stream * stream)
|
||||
|
||||
/* {{{ php_next_marker
|
||||
* get next marker byte from file */
|
||||
static unsigned int php_next_marker(php_stream * stream, int last_marker, int comment_correction, int ff_read)
|
||||
static unsigned int php_next_marker(php_stream * stream, int last_marker, int comment_correction, int ff_read TSRMLS_DC)
|
||||
{
|
||||
int a=0, marker;
|
||||
|
||||
@@ -311,9 +311,9 @@ static unsigned int php_next_marker(php_stream * stream, int last_marker, int co
|
||||
|
||||
/* {{{ php_skip_variable
|
||||
* skip over a variable-length block; assumes proper length marker */
|
||||
static void php_skip_variable(php_stream * stream)
|
||||
static void php_skip_variable(php_stream * stream TSRMLS_DC)
|
||||
{
|
||||
off_t length = ((unsigned int)php_read2(stream));
|
||||
off_t length = ((unsigned int)php_read2(stream TSRMLS_CC));
|
||||
|
||||
length = length-2;
|
||||
if (length)
|
||||
@@ -325,14 +325,14 @@ static void php_skip_variable(php_stream * stream)
|
||||
|
||||
/* {{{ php_read_APP
|
||||
*/
|
||||
static void php_read_APP(php_stream * stream, unsigned int marker, zval *info)
|
||||
static void php_read_APP(php_stream * stream, unsigned int marker, zval *info TSRMLS_DC)
|
||||
{
|
||||
unsigned short length;
|
||||
unsigned char *buffer;
|
||||
unsigned char markername[ 16 ];
|
||||
zval *tmp;
|
||||
|
||||
length = php_read2(stream);
|
||||
length = php_read2(stream TSRMLS_CC);
|
||||
length -= 2; /* length includes itself */
|
||||
|
||||
buffer = emalloc(length);
|
||||
@@ -356,14 +356,14 @@ static void php_read_APP(php_stream * stream, unsigned int marker, zval *info)
|
||||
|
||||
/* {{{ php_handle_jpeg
|
||||
main loop to parse JPEG structure */
|
||||
static struct gfxinfo *php_handle_jpeg (php_stream * stream, pval *info)
|
||||
static struct gfxinfo *php_handle_jpeg (php_stream * stream, pval *info TSRMLS_DC)
|
||||
{
|
||||
struct gfxinfo *result = NULL;
|
||||
unsigned int marker = M_PSEUDO;
|
||||
unsigned short length, ff_read=1;
|
||||
|
||||
for (;;) {
|
||||
marker = php_next_marker(stream, marker, 1, ff_read);
|
||||
marker = php_next_marker(stream, marker, 1, ff_read TSRMLS_CC);
|
||||
ff_read = 0;
|
||||
switch (marker) {
|
||||
case M_SOF0:
|
||||
@@ -384,16 +384,16 @@ static struct gfxinfo *php_handle_jpeg (php_stream * stream, pval *info)
|
||||
result = (struct gfxinfo *) ecalloc(1, sizeof(struct gfxinfo));
|
||||
if ( !result)
|
||||
return NULL;
|
||||
length = php_read2(stream);
|
||||
length = php_read2(stream TSRMLS_CC);
|
||||
result->bits = php_stream_getc(stream);
|
||||
result->height = php_read2(stream);
|
||||
result->width = php_read2(stream);
|
||||
result->height = php_read2(stream TSRMLS_CC);
|
||||
result->width = php_read2(stream TSRMLS_CC);
|
||||
result->channels = php_stream_getc(stream);
|
||||
if (!info || length<8) /* if we don't want an extanded info -> return */
|
||||
return result;
|
||||
php_stream_seek(stream, length-8, SEEK_CUR);
|
||||
} else {
|
||||
php_skip_variable(stream);
|
||||
php_skip_variable(stream TSRMLS_CC);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -414,9 +414,9 @@ static struct gfxinfo *php_handle_jpeg (php_stream * stream, pval *info)
|
||||
case M_APP14:
|
||||
case M_APP15:
|
||||
if (info) {
|
||||
php_read_APP(stream, marker, info); /* read all the app markes... */
|
||||
php_read_APP(stream, marker, info TSRMLS_CC); /* read all the app markes... */
|
||||
} else {
|
||||
php_skip_variable(stream);
|
||||
php_skip_variable(stream TSRMLS_CC);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -426,7 +426,7 @@ static struct gfxinfo *php_handle_jpeg (php_stream * stream, pval *info)
|
||||
break;
|
||||
|
||||
default:
|
||||
php_skip_variable(stream); /* anything else isn't interesting */
|
||||
php_skip_variable(stream TSRMLS_CC); /* anything else isn't interesting */
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -443,7 +443,7 @@ static struct gfxinfo *php_handle_jpeg (php_stream * stream, pval *info)
|
||||
|
||||
/* {{{ php_read4
|
||||
*/
|
||||
static unsigned int php_read4(php_stream * stream)
|
||||
static unsigned int php_read4(php_stream * stream TSRMLS_DC)
|
||||
{
|
||||
unsigned char a[4];
|
||||
|
||||
@@ -459,32 +459,32 @@ static unsigned int php_read4(php_stream * stream)
|
||||
|
||||
/* {{{ php_handle_tiff
|
||||
main loop to parse TIFF structure */
|
||||
static struct gfxinfo *php_handle_jpc(php_stream * stream)
|
||||
static struct gfxinfo *php_handle_jpc(php_stream * stream TSRMLS_DC)
|
||||
{
|
||||
struct gfxinfo *result = NULL;
|
||||
unsigned int marker, dummy;
|
||||
unsigned short length, ff_read = 1;
|
||||
|
||||
marker = php_next_marker(stream, 0, 0, ff_read);
|
||||
marker = php_next_marker(stream, 0, 0, ff_read TSRMLS_CC);
|
||||
ff_read = 0;
|
||||
if ( marker == JC_SIZ)
|
||||
{
|
||||
length = php_read2(stream); /* Lsiz: length of segment */
|
||||
length = php_read2(stream TSRMLS_CC); /* Lsiz: length of segment */
|
||||
if ( length<42 || length>49191) /* read the spec */
|
||||
return NULL;
|
||||
result = (struct gfxinfo *) ecalloc(1, sizeof(struct gfxinfo));
|
||||
if ( !result)
|
||||
return NULL;
|
||||
dummy = php_read2(stream); /* Rsiz: capabilities */
|
||||
result->height = php_read4(stream); /* Xsiz */
|
||||
result->width = php_read4(stream); /* Ysiz */
|
||||
dummy = php_read4(stream); /* X0siz */
|
||||
dummy = php_read4(stream); /* Y0siz */
|
||||
dummy = php_read4(stream); /* XTsiz */
|
||||
dummy = php_read4(stream); /* YTsiz */
|
||||
dummy = php_read4(stream); /* XT0siz */
|
||||
dummy = php_read4(stream); /* YT0siz */
|
||||
result->bits = php_read2(stream); /* Csiz: precision in bitss */
|
||||
dummy = php_read2(stream TSRMLS_CC); /* Rsiz: capabilities */
|
||||
result->height = php_read4(stream TSRMLS_CC); /* Xsiz */
|
||||
result->width = php_read4(stream TSRMLS_CC); /* Ysiz */
|
||||
dummy = php_read4(stream TSRMLS_CC); /* X0siz */
|
||||
dummy = php_read4(stream TSRMLS_CC); /* Y0siz */
|
||||
dummy = php_read4(stream TSRMLS_CC); /* XTsiz */
|
||||
dummy = php_read4(stream TSRMLS_CC); /* YTsiz */
|
||||
dummy = php_read4(stream TSRMLS_CC); /* XT0siz */
|
||||
dummy = php_read4(stream TSRMLS_CC); /* YT0siz */
|
||||
result->bits = php_read2(stream TSRMLS_CC); /* Csiz: precision in bitss */
|
||||
result->channels = 0; /* don't know yet */
|
||||
return result;
|
||||
}
|
||||
@@ -563,7 +563,7 @@ static unsigned php_ifd_get32u(void *Long, int motorola_intel)
|
||||
|
||||
/* {{{ php_handle_tiff
|
||||
main loop to parse TIFF structure */
|
||||
static struct gfxinfo *php_handle_tiff (php_stream * stream, pval *info, int motorola_intel)
|
||||
static struct gfxinfo *php_handle_tiff (php_stream * stream, pval *info, int motorola_intel TSRMLS_DC)
|
||||
{
|
||||
struct gfxinfo *result = NULL;
|
||||
int i, num_entries;
|
||||
@@ -635,7 +635,7 @@ static struct gfxinfo *php_handle_tiff (php_stream * stream, pval *info, int mot
|
||||
|
||||
/* {{{ php_imagetype
|
||||
detect filetype from first bytes */
|
||||
int php_getimagetype(php_stream * stream, char *filetype)
|
||||
PHPAPI int php_getimagetype(php_stream * stream, char *filetype TSRMLS_DC)
|
||||
{
|
||||
char tmp[8];
|
||||
|
||||
@@ -725,38 +725,38 @@ PHP_FUNCTION(getimagesize)
|
||||
|
||||
rsrc_id = ZEND_REGISTER_RESOURCE(NULL, stream, php_file_le_stream());
|
||||
|
||||
itype = php_getimagetype(stream, NULL);
|
||||
itype = php_getimagetype(stream, NULL TSRMLS_CC);
|
||||
switch( itype) {
|
||||
case IMAGE_FILETYPE_GIF:
|
||||
result = php_handle_gif (stream);
|
||||
result = php_handle_gif (stream TSRMLS_CC);
|
||||
break;
|
||||
case IMAGE_FILETYPE_JPEG:
|
||||
if (info) {
|
||||
result = php_handle_jpeg(stream, *info);
|
||||
result = php_handle_jpeg(stream, *info TSRMLS_CC);
|
||||
} else {
|
||||
result = php_handle_jpeg(stream, NULL);
|
||||
result = php_handle_jpeg(stream, NULL TSRMLS_CC);
|
||||
}
|
||||
break;
|
||||
case IMAGE_FILETYPE_PNG:
|
||||
result = php_handle_png(stream);
|
||||
result = php_handle_png(stream TSRMLS_CC);
|
||||
break;
|
||||
case IMAGE_FILETYPE_SWF:
|
||||
result = php_handle_swf(stream);
|
||||
result = php_handle_swf(stream TSRMLS_CC);
|
||||
break;
|
||||
case IMAGE_FILETYPE_PSD:
|
||||
result = php_handle_psd(stream);
|
||||
result = php_handle_psd(stream TSRMLS_CC);
|
||||
break;
|
||||
case IMAGE_FILETYPE_BMP:
|
||||
result = php_handle_bmp(stream);
|
||||
result = php_handle_bmp(stream TSRMLS_CC);
|
||||
break;
|
||||
case IMAGE_FILETYPE_TIFF_II:
|
||||
result = php_handle_tiff(stream, NULL, 0);
|
||||
result = php_handle_tiff(stream, NULL, 0 TSRMLS_CC);
|
||||
break;
|
||||
case IMAGE_FILETYPE_TIFF_MM:
|
||||
result = php_handle_tiff(stream, NULL, 1);
|
||||
result = php_handle_tiff(stream, NULL, 1 TSRMLS_CC);
|
||||
break;
|
||||
case IMAGE_FILETYPE_JPC:
|
||||
result = php_handle_jpc(stream);
|
||||
result = php_handle_jpc(stream TSRMLS_CC);
|
||||
break;
|
||||
default:
|
||||
case IMAGE_FILETYPE_UNKNOWN:
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "php_standard.h"
|
||||
#include "php_fopen_wrappers.h"
|
||||
|
||||
php_stream * php_stream_url_wrap_php(char * path, char * mode, int options, char ** opened_path STREAMS_DC)
|
||||
php_stream * php_stream_url_wrap_php(char * path, char * mode, int options, char ** opened_path STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
FILE * fp = NULL;
|
||||
php_stream * stream = NULL;
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#ifndef PHP_FOPEN_WRAPPERS_H
|
||||
#define PHP_FOPEN_WRAPPERS_H
|
||||
|
||||
php_stream *php_stream_url_wrap_http(char *path, char *mode, int options, char **opened_path STREAMS_DC);
|
||||
php_stream *php_stream_url_wrap_ftp(char *path, char *mode, int options, char **opened_path STREAMS_DC);
|
||||
php_stream *php_stream_url_wrap_http(char *path, char *mode, int options, char **opened_path STREAMS_DC TSRMLS_DC);
|
||||
php_stream *php_stream_url_wrap_ftp(char *path, char *mode, int options, char **opened_path STREAMS_DC TSRMLS_DC);
|
||||
php_stream_wrapper php_stream_http_wrapper;
|
||||
php_stream_wrapper php_stream_ftp_wrapper;
|
||||
php_stream_wrapper php_stream_php_wrapper;
|
||||
|
||||
@@ -45,6 +45,6 @@ typedef enum
|
||||
} image_filetype;
|
||||
/* }}} */
|
||||
|
||||
extern int php_getimagetype(php_stream *stream, char *filetype);
|
||||
PHPAPI int php_getimagetype(php_stream *stream, char *filetype TSRMLS_DC);
|
||||
|
||||
#endif /* PHP_IMAGE_H */
|
||||
|
||||
@@ -66,7 +66,7 @@ PHP_FUNCTION(ob_gzhandler);
|
||||
|
||||
int php_enable_output_compression(int buffer_size TSRMLS_DC);
|
||||
|
||||
php_stream *php_stream_gzopen(char *path, char *mode, int options, char **opened_path STREAMS_DC);
|
||||
php_stream *php_stream_gzopen(char *path, char *mode, int options, char **opened_path STREAMS_DC TSRMLS_DC);
|
||||
extern php_stream_ops php_stream_gzio_ops;
|
||||
extern php_stream_wrapper php_stream_gzip_wrapper;
|
||||
|
||||
|
||||
@@ -302,7 +302,7 @@ PHP_FUNCTION(gzfile)
|
||||
convert_to_string_ex(filename);
|
||||
|
||||
/* using a stream here is a bit more efficient (resource wise) than php_gzopen_wrapper */
|
||||
stream = php_stream_gzopen(Z_STRVAL_PP(filename), "rb", use_include_path|ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL STREAMS_CC);
|
||||
stream = php_stream_gzopen(Z_STRVAL_PP(filename), "rb", use_include_path|ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL STREAMS_CC TSRMLS_CC);
|
||||
if (stream == NULL) {
|
||||
php_error(E_WARNING,"gzFile(\"%s\") - %s",Z_STRVAL_PP(filename),strerror(errno));
|
||||
RETURN_FALSE;
|
||||
|
||||
@@ -28,7 +28,7 @@ struct php_gz_stream_data_t {
|
||||
php_stream *stream;
|
||||
};
|
||||
|
||||
static size_t php_gziop_read(php_stream *stream, char *buf, size_t count)
|
||||
static size_t php_gziop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
struct php_gz_stream_data_t *self = (struct php_gz_stream_data_t *)stream->abstract;
|
||||
|
||||
@@ -41,33 +41,33 @@ static size_t php_gziop_read(php_stream *stream, char *buf, size_t count)
|
||||
return gzread(self->gz_file, buf, count);
|
||||
}
|
||||
|
||||
static char *php_gziop_gets(php_stream *stream, char *buf, size_t size)
|
||||
static char *php_gziop_gets(php_stream *stream, char *buf, size_t size TSRMLS_DC)
|
||||
{
|
||||
struct php_gz_stream_data_t *self = (struct php_gz_stream_data_t *)stream->abstract;
|
||||
return gzgets(self->gz_file, buf, size);
|
||||
}
|
||||
|
||||
|
||||
static size_t php_gziop_write(php_stream *stream, const char *buf, size_t count)
|
||||
static size_t php_gziop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
struct php_gz_stream_data_t *self = (struct php_gz_stream_data_t *)stream->abstract;
|
||||
return gzwrite(self->gz_file, (char*)buf, count);
|
||||
}
|
||||
|
||||
static int php_gziop_seek(php_stream *stream, off_t offset, int whence)
|
||||
static int php_gziop_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC)
|
||||
{
|
||||
struct php_gz_stream_data_t *self = (struct php_gz_stream_data_t *)stream->abstract;
|
||||
return gzseek(self->gz_file, offset, whence);
|
||||
}
|
||||
|
||||
static int php_gziop_close(php_stream *stream, int close_handle)
|
||||
static int php_gziop_close(php_stream *stream, int close_handle TSRMLS_DC)
|
||||
{
|
||||
struct php_gz_stream_data_t *self = (struct php_gz_stream_data_t *)stream->abstract;
|
||||
int ret = EOF;
|
||||
|
||||
if (close_handle)
|
||||
ret = gzclose(self->gz_file);
|
||||
php_stream_free(self->stream, close_handle);
|
||||
php_stream_free(self->stream, PHP_STREAM_FREE_CLOSE | (close_handle == 0 ? PHP_STREAM_FREE_PRESERVE_HANDLE : 0));
|
||||
efree(self);
|
||||
|
||||
return ret;
|
||||
@@ -80,7 +80,7 @@ php_stream_ops php_stream_gzio_ops = {
|
||||
NULL, "ZLIB"
|
||||
};
|
||||
|
||||
php_stream *php_stream_gzopen(char *path, char *mode, int options, char **opened_path STREAMS_DC)
|
||||
php_stream *php_stream_gzopen(char *path, char *mode, int options, char **opened_path STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
struct php_gz_stream_data_t *self;
|
||||
php_stream *stream = NULL;
|
||||
|
||||
@@ -570,7 +570,7 @@ static FILE *php_fopen_wrapper_for_zend(const char *filename, char **opened_path
|
||||
stream = php_stream_open_wrapper((char *)filename, "rb", USE_PATH|IGNORE_URL_WIN|REPORT_ERRORS, opened_path);
|
||||
if (stream) {
|
||||
/* no need for us to check the stream type here */
|
||||
php_stream_sock_set_chunk_size(stream, 1);
|
||||
php_stream_sock_set_chunk_size(stream, 1 TSRMLS_CC);
|
||||
|
||||
/* when this succeeds, stream either has or will be freed automatically */
|
||||
if (php_stream_cast(stream, PHP_STREAM_AS_STDIO|PHP_STREAM_CAST_TRY_HARD|PHP_STREAM_CAST_RELEASE,
|
||||
|
||||
@@ -40,7 +40,7 @@ typedef struct {
|
||||
int mode;
|
||||
} php_stream_memory_data;
|
||||
|
||||
static size_t php_stream_memory_write(php_stream *stream, const char *buf, size_t count) { /* {{{ */
|
||||
static size_t php_stream_memory_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) { /* {{{ */
|
||||
php_stream_memory_data *ms;
|
||||
|
||||
assert(stream != NULL);
|
||||
@@ -75,7 +75,7 @@ static size_t php_stream_memory_write(php_stream *stream, const char *buf, size_
|
||||
return count;
|
||||
} /* }}} */
|
||||
|
||||
static size_t php_stream_memory_read(php_stream *stream, char *buf, size_t count) { /* {{{ */
|
||||
static size_t php_stream_memory_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) { /* {{{ */
|
||||
php_stream_memory_data *ms;
|
||||
|
||||
assert(stream != NULL);
|
||||
@@ -103,7 +103,7 @@ static size_t php_stream_memory_read(php_stream *stream, char *buf, size_t count
|
||||
} /* }}} */
|
||||
|
||||
|
||||
static int php_stream_memory_close(php_stream *stream, int close_handle) { /* {{{ */
|
||||
static int php_stream_memory_close(php_stream *stream, int close_handle TSRMLS_DC) { /* {{{ */
|
||||
php_stream_memory_data *ms;
|
||||
|
||||
assert(stream != NULL);
|
||||
@@ -120,13 +120,13 @@ static int php_stream_memory_close(php_stream *stream, int close_handle) { /* {{
|
||||
} /* }}} */
|
||||
|
||||
|
||||
static int php_stream_memory_flush(php_stream *stream) { /* {{{ */
|
||||
static int php_stream_memory_flush(php_stream *stream TSRMLS_DC) { /* {{{ */
|
||||
/* nothing to do here */
|
||||
return 0;
|
||||
} /* }}} */
|
||||
|
||||
|
||||
static int php_stream_memory_seek(php_stream *stream, off_t offset, int whence) { /* {{{ */
|
||||
static int php_stream_memory_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC) { /* {{{ */
|
||||
php_stream_memory_data *ms;
|
||||
|
||||
assert(stream != NULL);
|
||||
@@ -178,7 +178,7 @@ static int php_stream_memory_seek(php_stream *stream, off_t offset, int whence)
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
static char *php_stream_memory_gets(php_stream *stream, char *buf, size_t maxlen) { /* {{{ */
|
||||
static char *php_stream_memory_gets(php_stream *stream, char *buf, size_t maxlen TSRMLS_DC) { /* {{{ */
|
||||
size_t n = 1;
|
||||
char *c = buf;
|
||||
|
||||
@@ -202,7 +202,7 @@ static char *php_stream_memory_gets(php_stream *stream, char *buf, size_t maxlen
|
||||
return buf;
|
||||
} /* }}} */
|
||||
|
||||
static int php_stream_memory_cast(php_stream *stream, int castas, void **ret) { /* {{{ */
|
||||
static int php_stream_memory_cast(php_stream *stream, int castas, void **ret TSRMLS_DC) { /* {{{ */
|
||||
return FAILURE;
|
||||
} /* }}} */
|
||||
|
||||
@@ -215,7 +215,7 @@ php_stream_ops php_stream_memory_ops = {
|
||||
"MEMORY"
|
||||
};
|
||||
|
||||
PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC) { /* {{{ */
|
||||
PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC TSRMLS_DC) { /* {{{ */
|
||||
php_stream_memory_data *self;
|
||||
|
||||
self = emalloc(sizeof(*self));
|
||||
@@ -228,7 +228,7 @@ PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC) { /* {{{ */
|
||||
return php_stream_alloc(&php_stream_memory_ops, self, 0, "rwb");
|
||||
} /* }}} */
|
||||
|
||||
PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC) { /* {{{ */
|
||||
PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC TSRMLS_DC) { /* {{{ */
|
||||
php_stream *stream;
|
||||
php_stream_memory_data *ms;
|
||||
|
||||
@@ -242,7 +242,7 @@ PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length ST
|
||||
return stream;
|
||||
} /* }}} */
|
||||
|
||||
PHPAPI char *_php_stream_memory_get_buffer(php_stream *stream, size_t *length STREAMS_DC) { /* {{{ */
|
||||
PHPAPI char *_php_stream_memory_get_buffer(php_stream *stream, size_t *length STREAMS_DC TSRMLS_DC) { /* {{{ */
|
||||
php_stream_memory_data *ms;
|
||||
|
||||
assert(stream != NULL);
|
||||
@@ -264,9 +264,8 @@ typedef struct {
|
||||
int mode;
|
||||
} php_stream_temp_data;
|
||||
|
||||
static size_t php_stream_temp_write(php_stream *stream, const char *buf, size_t count) { /* {{{ */
|
||||
static size_t php_stream_temp_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) { /* {{{ */
|
||||
php_stream_temp_data *ts;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
assert(stream != NULL);
|
||||
ts = stream->abstract;
|
||||
@@ -286,7 +285,7 @@ static size_t php_stream_temp_write(php_stream *stream, const char *buf, size_t
|
||||
return php_stream_write(ts->innerstream, buf, count);
|
||||
} /* }}} */
|
||||
|
||||
static size_t php_stream_temp_read(php_stream *stream, char *buf, size_t count) { /* {{{ */
|
||||
static size_t php_stream_temp_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) { /* {{{ */
|
||||
php_stream_temp_data *ts;
|
||||
|
||||
assert(stream != NULL);
|
||||
@@ -297,7 +296,7 @@ static size_t php_stream_temp_read(php_stream *stream, char *buf, size_t count)
|
||||
} /* }}} */
|
||||
|
||||
|
||||
static int php_stream_temp_close(php_stream *stream, int close_handle) { /* {{{ */
|
||||
static int php_stream_temp_close(php_stream *stream, int close_handle TSRMLS_DC) { /* {{{ */
|
||||
php_stream_temp_data *ts;
|
||||
|
||||
assert(stream != NULL);
|
||||
@@ -308,7 +307,7 @@ static int php_stream_temp_close(php_stream *stream, int close_handle) { /* {{{
|
||||
} /* }}} */
|
||||
|
||||
|
||||
static int php_stream_temp_flush(php_stream *stream) { /* {{{ */
|
||||
static int php_stream_temp_flush(php_stream *stream TSRMLS_DC) { /* {{{ */
|
||||
php_stream_temp_data *ts;
|
||||
|
||||
assert(stream != NULL);
|
||||
@@ -319,7 +318,7 @@ static int php_stream_temp_flush(php_stream *stream) { /* {{{ */
|
||||
} /* }}} */
|
||||
|
||||
|
||||
static int php_stream_temp_seek(php_stream *stream, off_t offset, int whence) { /* {{{ */
|
||||
static int php_stream_temp_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC) { /* {{{ */
|
||||
php_stream_temp_data *ts;
|
||||
|
||||
assert(stream != NULL);
|
||||
@@ -329,7 +328,7 @@ static int php_stream_temp_seek(php_stream *stream, off_t offset, int whence) {
|
||||
return php_stream_seek(ts->innerstream, offset, whence);
|
||||
} /* }}} */
|
||||
|
||||
char *php_stream_temp_gets(php_stream *stream, char *buf, size_t maxlen) { /* {{{ */
|
||||
char *php_stream_temp_gets(php_stream *stream, char *buf, size_t maxlen TSRMLS_DC) { /* {{{ */
|
||||
php_stream_temp_data *ts;
|
||||
|
||||
assert(stream != NULL);
|
||||
@@ -339,7 +338,7 @@ char *php_stream_temp_gets(php_stream *stream, char *buf, size_t maxlen) { /* {{
|
||||
return php_stream_gets(ts->innerstream, buf, maxlen);
|
||||
} /* }}} */
|
||||
|
||||
static int php_stream_temp_cast(php_stream *stream, int castas, void **ret) { /* {{{ */
|
||||
static int php_stream_temp_cast(php_stream *stream, int castas, void **ret TSRMLS_DC) { /* {{{ */
|
||||
php_stream_temp_data *ts;
|
||||
|
||||
assert(stream != NULL);
|
||||
@@ -358,7 +357,7 @@ php_stream_ops php_stream_temp_ops = {
|
||||
"TEMP"
|
||||
};
|
||||
|
||||
PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC) { /* {{{ */
|
||||
PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC TSRMLS_DC) { /* {{{ */
|
||||
php_stream_temp_data *self;
|
||||
php_stream *stream;
|
||||
|
||||
@@ -368,18 +367,18 @@ PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STR
|
||||
self->mode = mode;
|
||||
stream = php_stream_alloc(&php_stream_temp_ops, self, 0, "rwb");
|
||||
self->innerstream = php_stream_memory_create(mode);
|
||||
php_stream_temp_write(stream, NULL, 0);
|
||||
php_stream_temp_write(stream, NULL, 0 TSRMLS_CC);
|
||||
return stream;
|
||||
} /* }}} */
|
||||
|
||||
PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC) { /* {{{ */
|
||||
PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC TSRMLS_DC) { /* {{{ */
|
||||
php_stream *stream;
|
||||
php_stream_temp_data *ms;
|
||||
|
||||
if ((stream = php_stream_temp_create_rel(mode & ~TEMP_STREAM_READONLY, max_memory_usage)) != NULL) {
|
||||
if (length) {
|
||||
assert(buf != NULL);
|
||||
php_stream_temp_write(stream, buf, length);
|
||||
php_stream_temp_write(stream, buf, length TSRMLS_CC);
|
||||
}
|
||||
ms = stream->abstract;
|
||||
assert(ms != NULL);
|
||||
|
||||
@@ -413,7 +413,7 @@ int php_sockaddr_size(php_sockaddr_storage *addr)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
PHPAPI php_stream *_php_stream_sock_open_from_socket(int socket, int persistent STREAMS_DC)
|
||||
PHPAPI php_stream *_php_stream_sock_open_from_socket(int socket, int persistent STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
php_stream *stream;
|
||||
php_netstream_data_t *sock;
|
||||
@@ -435,7 +435,7 @@ PHPAPI php_stream *_php_stream_sock_open_from_socket(int socket, int persistent
|
||||
}
|
||||
|
||||
PHPAPI php_stream *_php_stream_sock_open_host(const char *host, unsigned short port,
|
||||
int socktype, int timeout, int persistent STREAMS_DC)
|
||||
int socktype, int timeout, int persistent STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
int socket;
|
||||
|
||||
@@ -448,7 +448,7 @@ PHPAPI php_stream *_php_stream_sock_open_host(const char *host, unsigned short p
|
||||
}
|
||||
|
||||
PHPAPI php_stream *_php_stream_sock_open_unix(const char *path, int pathlen, int persistent,
|
||||
struct timeval *timeout STREAMS_DC)
|
||||
struct timeval *timeout STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
#if defined(AF_UNIX)
|
||||
int socketd;
|
||||
@@ -484,7 +484,7 @@ PHPAPI php_stream *_php_stream_sock_open_unix(const char *path, int pathlen, int
|
||||
}
|
||||
|
||||
#if HAVE_OPENSSL_EXT
|
||||
PHPAPI int php_stream_sock_ssl_activate_with_method(php_stream *stream, int activate, SSL_METHOD *method)
|
||||
PHPAPI int php_stream_sock_ssl_activate_with_method(php_stream *stream, int activate, SSL_METHOD *method TSRMLS_DC)
|
||||
{
|
||||
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
|
||||
SSL_CTX *ctx = NULL;
|
||||
@@ -524,7 +524,7 @@ PHPAPI int php_stream_sock_ssl_activate_with_method(php_stream *stream, int acti
|
||||
}
|
||||
#endif
|
||||
|
||||
PHPAPI void php_stream_sock_set_timeout(php_stream *stream, struct timeval *timeout)
|
||||
PHPAPI void php_stream_sock_set_timeout(php_stream *stream, struct timeval *timeout TSRMLS_DC)
|
||||
{
|
||||
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
|
||||
|
||||
@@ -535,7 +535,7 @@ PHPAPI void php_stream_sock_set_timeout(php_stream *stream, struct timeval *time
|
||||
sock->timeout_event = 0;
|
||||
}
|
||||
|
||||
PHPAPI int php_stream_sock_set_blocking(php_stream *stream, int mode)
|
||||
PHPAPI int php_stream_sock_set_blocking(php_stream *stream, int mode TSRMLS_DC)
|
||||
{
|
||||
int oldmode;
|
||||
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
|
||||
@@ -549,7 +549,7 @@ PHPAPI int php_stream_sock_set_blocking(php_stream *stream, int mode)
|
||||
return oldmode;
|
||||
}
|
||||
|
||||
PHPAPI size_t php_stream_sock_set_chunk_size(php_stream *stream, size_t size)
|
||||
PHPAPI size_t php_stream_sock_set_chunk_size(php_stream *stream, size_t size TSRMLS_DC)
|
||||
{
|
||||
size_t oldsize;
|
||||
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
|
||||
@@ -567,7 +567,7 @@ PHPAPI size_t php_stream_sock_set_chunk_size(php_stream *stream, size_t size)
|
||||
#define READPTR(sock) ((sock)->readbuf + (sock)->readpos)
|
||||
#define WRITEPTR(sock) ((sock)->readbuf + (sock)->writepos)
|
||||
|
||||
static size_t php_sockop_write(php_stream *stream, const char *buf, size_t count)
|
||||
static size_t php_sockop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
|
||||
#if HAVE_OPENSSL_EXT
|
||||
@@ -576,7 +576,7 @@ static size_t php_sockop_write(php_stream *stream, const char *buf, size_t count
|
||||
#endif
|
||||
return send(sock->socket, buf, count, 0);
|
||||
}
|
||||
static void php_sock_stream_wait_for_data(php_stream *stream, php_netstream_data_t *sock)
|
||||
static void php_sock_stream_wait_for_data(php_stream *stream, php_netstream_data_t *sock TSRMLS_DC)
|
||||
{
|
||||
fd_set fdr, tfdr;
|
||||
int retval;
|
||||
@@ -605,7 +605,7 @@ static void php_sock_stream_wait_for_data(php_stream *stream, php_netstream_data
|
||||
}
|
||||
}
|
||||
|
||||
static size_t php_sock_stream_read_internal(php_stream *stream, php_netstream_data_t *sock)
|
||||
static size_t php_sock_stream_read_internal(php_stream *stream, php_netstream_data_t *sock TSRMLS_DC)
|
||||
{
|
||||
char buf[PHP_SOCK_CHUNK_SIZE];
|
||||
int nr_bytes;
|
||||
@@ -620,7 +620,7 @@ static size_t php_sock_stream_read_internal(php_stream *stream, php_netstream_da
|
||||
|
||||
|
||||
if(sock->is_blocked) {
|
||||
php_sock_stream_wait_for_data(stream, sock);
|
||||
php_sock_stream_wait_for_data(stream, sock TSRMLS_CC);
|
||||
if (sock->timeout_event)
|
||||
return 0;
|
||||
}
|
||||
@@ -649,14 +649,14 @@ static size_t php_sock_stream_read_internal(php_stream *stream, php_netstream_da
|
||||
|
||||
}
|
||||
|
||||
static size_t php_sock_stream_read(php_stream *stream, php_netstream_data_t *sock)
|
||||
static size_t php_sock_stream_read(php_stream *stream, php_netstream_data_t *sock TSRMLS_DC)
|
||||
{
|
||||
size_t nr_bytes;
|
||||
size_t nr_read = 0;
|
||||
int i;
|
||||
|
||||
for(i = 0; !sock->eof && i < MAX_CHUNKS_PER_READ; i++) {
|
||||
nr_bytes = php_sock_stream_read_internal(stream, sock);
|
||||
nr_bytes = php_sock_stream_read_internal(stream, sock TSRMLS_CC);
|
||||
if(nr_bytes == 0) break;
|
||||
nr_read += nr_bytes;
|
||||
}
|
||||
@@ -664,17 +664,17 @@ static size_t php_sock_stream_read(php_stream *stream, php_netstream_data_t *soc
|
||||
return nr_read;
|
||||
}
|
||||
|
||||
static size_t php_sockop_read(php_stream *stream, char *buf, size_t count)
|
||||
static size_t php_sockop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
|
||||
size_t ret = 0;
|
||||
|
||||
if (sock->is_blocked) {
|
||||
while(!sock->eof && TOREAD(sock) < count && !sock->timeout_event)
|
||||
php_sock_stream_read_internal(stream, sock);
|
||||
php_sock_stream_read_internal(stream, sock TSRMLS_CC);
|
||||
}
|
||||
else
|
||||
php_sock_stream_read(stream, sock);
|
||||
php_sock_stream_read(stream, sock TSRMLS_CC);
|
||||
|
||||
if(count < 0)
|
||||
return ret;
|
||||
@@ -688,7 +688,7 @@ static size_t php_sockop_read(php_stream *stream, char *buf, size_t count)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int php_sockop_close(php_stream *stream, int close_handle)
|
||||
static int php_sockop_close(php_stream *stream, int close_handle TSRMLS_DC)
|
||||
{
|
||||
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
|
||||
|
||||
@@ -714,16 +714,15 @@ static int php_sockop_close(php_stream *stream, int close_handle)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int php_sockop_flush(php_stream *stream)
|
||||
static int php_sockop_flush(php_stream *stream TSRMLS_DC)
|
||||
{
|
||||
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
|
||||
return fsync(sock->socket);
|
||||
}
|
||||
|
||||
static int php_sockop_cast(php_stream *stream, int castas, void **ret)
|
||||
static int php_sockop_cast(php_stream *stream, int castas, void **ret TSRMLS_DC)
|
||||
{
|
||||
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
switch(castas) {
|
||||
case PHP_STREAM_AS_STDIO:
|
||||
@@ -768,7 +767,7 @@ static int php_sockop_cast(php_stream *stream, int castas, void **ret)
|
||||
} while (0)
|
||||
|
||||
|
||||
static char *php_sockop_gets(php_stream *stream, char *buf, size_t maxlen)
|
||||
static char *php_sockop_gets(php_stream *stream, char *buf, size_t maxlen TSRMLS_DC)
|
||||
{
|
||||
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
|
||||
char *p = NULL, *pe;
|
||||
@@ -785,11 +784,11 @@ static char *php_sockop_gets(php_stream *stream, char *buf, size_t maxlen)
|
||||
if(!p) {
|
||||
if(sock->is_blocked) {
|
||||
while(!p && !sock->eof && !sock->timeout_event && TOREAD(sock) < maxlen) {
|
||||
php_sock_stream_read_internal(stream, sock);
|
||||
php_sock_stream_read_internal(stream, sock TSRMLS_CC);
|
||||
SEARCHCR();
|
||||
}
|
||||
} else {
|
||||
php_sock_stream_read(stream, sock);
|
||||
php_sock_stream_read(stream, sock TSRMLS_CC);
|
||||
SEARCHCR();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +131,14 @@ struct _php_core_globals {
|
||||
zend_bool allow_url_fopen;
|
||||
|
||||
zend_bool always_populate_raw_post_data;
|
||||
|
||||
#if ZEND_DEBUG
|
||||
long streams_call_depth;
|
||||
char * streams_orig_filename;
|
||||
long streams_orig_lineno;
|
||||
char * streams_filename;
|
||||
long streams_lineno;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -21,22 +21,22 @@
|
||||
|
||||
#include "php_streams.h"
|
||||
|
||||
#define php_stream_memory_create(mode) _php_stream_memory_create((mode) STREAMS_CC)
|
||||
#define php_stream_memory_create_rel(mode) _php_stream_memory_create((mode) STREAMS_REL_CC)
|
||||
#define php_stream_memory_open(mode, buf, length) _php_stream_memory_open((mode), (buf), (length) STREAMS_CC)
|
||||
#define php_stream_memory_get_buffer(stream, length) _php_stream_memory_get_buffer((stream), (length) STREAMS_CC)
|
||||
#define php_stream_memory_create(mode) _php_stream_memory_create((mode) STREAMS_CC TSRMLS_CC)
|
||||
#define php_stream_memory_create_rel(mode) _php_stream_memory_create((mode) STREAMS_REL_CC TSRMLS_CC)
|
||||
#define php_stream_memory_open(mode, buf, length) _php_stream_memory_open((mode), (buf), (length) STREAMS_CC TSRMLS_CC)
|
||||
#define php_stream_memory_get_buffer(stream, length) _php_stream_memory_get_buffer((stream), (length) STREAMS_CC TSRMLS_CC)
|
||||
|
||||
#define php_stream_temp_create(mode, max_memory_usage) _php_stream_temp_create((mode), (max_memory_usage) STREAMS_CC)
|
||||
#define php_stream_temp_create_rel(mode, max_memory_usage) _php_stream_temp_create((mode), (max_memory_usage) STREAMS_REL_CC)
|
||||
#define php_stream_temp_open(mode, max_memory_usage, buf, length) _php_stream_temp_open((mode), (max_memory_usage), (buf), (length) STREAMS_CC)
|
||||
#define php_stream_temp_create(mode, max_memory_usage) _php_stream_temp_create((mode), (max_memory_usage) STREAMS_CC TSRMLS_CC)
|
||||
#define php_stream_temp_create_rel(mode, max_memory_usage) _php_stream_temp_create((mode), (max_memory_usage) STREAMS_REL_CC TSRMLS_CC)
|
||||
#define php_stream_temp_open(mode, max_memory_usage, buf, length) _php_stream_temp_open((mode), (max_memory_usage), (buf), (length) STREAMS_CC TSRMLS_CC)
|
||||
|
||||
|
||||
PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC);
|
||||
PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC);
|
||||
PHPAPI char *_php_stream_memory_get_buffer(php_stream *stream, size_t *length STREAMS_DC);
|
||||
PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC TSRMLS_DC);
|
||||
PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC TSRMLS_DC);
|
||||
PHPAPI char *_php_stream_memory_get_buffer(php_stream *stream, size_t *length STREAMS_DC TSRMLS_DC);
|
||||
|
||||
PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC);
|
||||
PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC);
|
||||
PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC TSRMLS_DC);
|
||||
PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC TSRMLS_DC);
|
||||
|
||||
#define TEMP_STREAM_DEFAULT 0
|
||||
#define TEMP_STREAM_READONLY 1
|
||||
|
||||
@@ -112,32 +112,32 @@ typedef struct _php_netstream_data_t php_netstream_data_t;
|
||||
extern php_stream_ops php_stream_socket_ops;
|
||||
#define PHP_STREAM_IS_SOCKET (&php_stream_socket_ops)
|
||||
|
||||
PHPAPI php_stream *_php_stream_sock_open_from_socket(int socket, int persistent STREAMS_DC);
|
||||
PHPAPI php_stream *_php_stream_sock_open_from_socket(int socket, int persistent STREAMS_DC TSRMLS_DC );
|
||||
/* open a connection to a host using php_hostconnect and return a stream */
|
||||
PHPAPI php_stream *_php_stream_sock_open_host(const char *host, unsigned short port,
|
||||
int socktype, int timeout, int persistent STREAMS_DC);
|
||||
int socktype, int timeout, int persistent STREAMS_DC TSRMLS_DC);
|
||||
PHPAPI php_stream *_php_stream_sock_open_unix(const char *path, int pathlen, int persistent,
|
||||
struct timeval *timeout STREAMS_DC);
|
||||
struct timeval *timeout STREAMS_DC TSRMLS_DC);
|
||||
|
||||
#define php_stream_sock_open_from_socket(socket, persistent) _php_stream_sock_open_from_socket((socket), (persistent) STREAMS_CC)
|
||||
#define php_stream_sock_open_host(host, port, socktype, timeout, persistent) _php_stream_sock_open_host((host), (port), (socktype), (timeout), (persistent) STREAMS_CC)
|
||||
#define php_stream_sock_open_unix(path, pathlen, persistent, timeval) _php_stream_sock_open_unix((path), (pathlen), (persistent), (timeval) STREAMS_CC)
|
||||
#define php_stream_sock_open_from_socket(socket, persistent) _php_stream_sock_open_from_socket((socket), (persistent) STREAMS_CC TSRMLS_CC)
|
||||
#define php_stream_sock_open_host(host, port, socktype, timeout, persistent) _php_stream_sock_open_host((host), (port), (socktype), (timeout), (persistent) STREAMS_CC TSRMLS_CC)
|
||||
#define php_stream_sock_open_unix(path, pathlen, persistent, timeval) _php_stream_sock_open_unix((path), (pathlen), (persistent), (timeval) STREAMS_CC TSRMLS_CC)
|
||||
|
||||
/* {{{ memory debug */
|
||||
#define php_stream_sock_open_from_socket_rel(socket, persistent) _php_stream_sock_open_from_socket((socket), (persistent) STREAMS_REL_CC)
|
||||
#define php_stream_sock_open_host_rel(host, port, socktype, timeout, persistent) _php_stream_sock_open_host((host), (port), (socktype), (timeout), (persistent) STREAMS_REL_CC)
|
||||
#define php_stream_sock_open_unix_rel(path, pathlen, persistent, timeval) _php_stream_sock_open_unix((path), (pathlen), (persistent), (timeval) STREAMS_REL_CC)
|
||||
#define php_stream_sock_open_from_socket_rel(socket, persistent) _php_stream_sock_open_from_socket((socket), (persistent) STREAMS_REL_CC TSRMLS_CC)
|
||||
#define php_stream_sock_open_host_rel(host, port, socktype, timeout, persistent) _php_stream_sock_open_host((host), (port), (socktype), (timeout), (persistent) STREAMS_REL_CC TSRMLS_CC)
|
||||
#define php_stream_sock_open_unix_rel(path, pathlen, persistent, timeval) _php_stream_sock_open_unix((path), (pathlen), (persistent), (timeval) STREAMS_REL_CC TSRMLS_CC)
|
||||
|
||||
/* }}} */
|
||||
|
||||
PHPAPI void php_stream_sock_set_timeout(php_stream *stream, struct timeval *timeout);
|
||||
PHPAPI int php_stream_sock_set_blocking(php_stream *stream, int mode);
|
||||
PHPAPI void php_stream_sock_set_timeout(php_stream *stream, struct timeval *timeout TSRMLS_DC);
|
||||
PHPAPI int php_stream_sock_set_blocking(php_stream *stream, int mode TSRMLS_DC);
|
||||
/* set the chunk size for the stream; return the old chunk size */
|
||||
PHPAPI size_t php_stream_sock_set_chunk_size(php_stream *stream, size_t size);
|
||||
PHPAPI size_t php_stream_sock_set_chunk_size(php_stream *stream, size_t size TSRMLS_DC);
|
||||
|
||||
#if HAVE_OPENSSL_EXT
|
||||
PHPAPI int php_stream_sock_ssl_activate_with_method(php_stream *stream, int activate, SSL_METHOD *method);
|
||||
#define php_stream_sock_ssl_activate(stream, activate) php_stream_sock_ssl_activate_with_method((stream), (activate), SSLv23_client_method())
|
||||
PHPAPI int php_stream_sock_ssl_activate_with_method(php_stream *stream, int activate, SSL_METHOD *method TSRMLS_DC);
|
||||
#define php_stream_sock_ssl_activate(stream, activate) php_stream_sock_ssl_activate_with_method((stream), (activate), SSLv23_client_method() TSRMLS_CC)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -30,16 +30,16 @@
|
||||
#if ZEND_DEBUG
|
||||
/* these have more of a dependency on the definitions of the zend macros than
|
||||
* I would prefer, but doing it this way saves loads of idefs :-/ */
|
||||
# define STREAMS_D int __php_stream_call_depth ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC
|
||||
# define STREAMS_C 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC
|
||||
# define STREAMS_D int __php_stream_call_depth ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC
|
||||
# define STREAMS_C 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC
|
||||
# define STREAMS_REL_C __php_stream_call_depth + 1 ZEND_FILE_LINE_CC, \
|
||||
__php_stream_call_depth ? __zend_orig_filename : __zend_filename, \
|
||||
__php_stream_call_depth ? __zend_orig_lineno : __zend_lineno \
|
||||
TSRMLS_CC
|
||||
__php_stream_call_depth ? __zend_orig_lineno : __zend_lineno
|
||||
|
||||
# define STREAMS_DC , STREAMS_D
|
||||
# define STREAMS_CC , STREAMS_C
|
||||
# define STREAMS_REL_CC , STREAMS_REL_C
|
||||
|
||||
#else
|
||||
# define STREAMS_D TSRMLS_D
|
||||
# define STREAMS_C TSRMLS_C
|
||||
@@ -51,25 +51,25 @@
|
||||
|
||||
/* these functions relay the file/line number information. They are depth aware, so they will pass
|
||||
* the ultimate ancestor, which is useful, because there can be several layers of calls */
|
||||
#define php_stream_alloc_rel(ops, thisptr, persistent, mode) _php_stream_alloc((ops), (thisptr), (persistent), (mode) STREAMS_REL_CC)
|
||||
#define php_stream_alloc_rel(ops, thisptr, persistent, mode) _php_stream_alloc((ops), (thisptr), (persistent), (mode) STREAMS_REL_CC TSRMLS_CC)
|
||||
|
||||
#define php_stream_copy_to_mem_rel(src, buf, maxlen, persistent) _php_stream_copy_to_mem((src), (buf), (maxlen), (persistent) STREAMS_REL_CC)
|
||||
#define php_stream_copy_to_mem_rel(src, buf, maxlen, persistent) _php_stream_copy_to_mem((src), (buf), (maxlen), (persistent) STREAMS_REL_CC TSRMLS_CC)
|
||||
|
||||
#define php_stream_fopen_rel(filename, mode, opened) _php_stream_fopen((filename), (mode), (opened) STREAMS_REL_CC)
|
||||
#define php_stream_fopen_rel(filename, mode, opened) _php_stream_fopen((filename), (mode), (opened) STREAMS_REL_CC TSRMLS_CC)
|
||||
|
||||
#define php_stream_fopen_with_path_rel(filename, mode, path, opened) _php_stream_fopen_with_path((filename), (mode), (path), (opened) STREAMS_REL_CC)
|
||||
#define php_stream_fopen_with_path_rel(filename, mode, path, opened) _php_stream_fopen_with_path((filename), (mode), (path), (opened) STREAMS_REL_CC TSRMLS_CC)
|
||||
|
||||
#define php_stream_fopen_from_file_rel(file, mode) _php_stream_fopen_from_file((file), (mode) STREAMS_REL_CC)
|
||||
#define php_stream_fopen_from_file_rel(file, mode) _php_stream_fopen_from_file((file), (mode) STREAMS_REL_CC TSRMLS_CC)
|
||||
|
||||
#define php_stream_fopen_from_pipe_rel(file, mode) _php_stream_fopen_from_pipe((file), (mode) STREAMS_REL_CC)
|
||||
#define php_stream_fopen_from_pipe_rel(file, mode) _php_stream_fopen_from_pipe((file), (mode) STREAMS_REL_CC TSRMLS_CC)
|
||||
|
||||
#define php_stream_fopen_tmpfile_rel() _php_stream_fopen_tmpfile(STREAMS_REL_C)
|
||||
#define php_stream_fopen_tmpfile_rel() _php_stream_fopen_tmpfile(STREAMS_REL_C TSRMLS_CC)
|
||||
|
||||
#define php_stream_fopen_temporary_file_rel(dir, pfx, opened_path) _php_stream_fopen_temporary_file((dir), (pfx), (opened_path) STREAMS_REL_CC)
|
||||
#define php_stream_fopen_temporary_file_rel(dir, pfx, opened_path) _php_stream_fopen_temporary_file((dir), (pfx), (opened_path) STREAMS_REL_CC TSRMLS_CC)
|
||||
|
||||
#define php_stream_open_wrapper_rel(path, mode, options, opened) _php_stream_open_wrapper((path), (mode), (options), (opened) STREAMS_REL_CC)
|
||||
#define php_stream_open_wrapper_rel(path, mode, options, opened) _php_stream_open_wrapper((path), (mode), (options), (opened) STREAMS_REL_CC TSRMLS_CC)
|
||||
|
||||
#define php_stream_make_seekable_rel(origstream, newstream) _php_stream_make_seekable(origstream, newstream STREAMS_REL_CC)
|
||||
#define php_stream_make_seekable_rel(origstream, newstream) _php_stream_make_seekable(origstream, newstream STREAMS_REL_CC TSRMLS_CC)
|
||||
|
||||
/* }}} */
|
||||
|
||||
@@ -89,20 +89,20 @@ typedef struct _php_stream php_stream;
|
||||
|
||||
typedef struct _php_stream_ops {
|
||||
/* stdio like functions - these are mandatory! */
|
||||
size_t (*write)(php_stream *stream, const char *buf, size_t count);
|
||||
size_t (*read)(php_stream *stream, char *buf, size_t count);
|
||||
int (*close)(php_stream *stream, int close_handle);
|
||||
int (*flush)(php_stream *stream);
|
||||
size_t (*write)(php_stream *stream, const char *buf, size_t count TSRMLS_DC);
|
||||
size_t (*read)(php_stream *stream, char *buf, size_t count TSRMLS_DC);
|
||||
int (*close)(php_stream *stream, int close_handle TSRMLS_DC);
|
||||
int (*flush)(php_stream *stream TSRMLS_DC);
|
||||
/* these are optional */
|
||||
int (*seek)(php_stream *stream, off_t offset, int whence);
|
||||
char *(*gets)(php_stream *stream, char *buf, size_t size);
|
||||
int (*cast)(php_stream *stream, int castas, void **ret);
|
||||
int (*seek)(php_stream *stream, off_t offset, int whence TSRMLS_DC);
|
||||
char *(*gets)(php_stream *stream, char *buf, size_t size TSRMLS_DC);
|
||||
int (*cast)(php_stream *stream, int castas, void **ret TSRMLS_DC);
|
||||
const char *label; /* label for this ops structure */
|
||||
} php_stream_ops;
|
||||
|
||||
/* options uses the IGNORE_URL family of defines from fopen_wrappers.h */
|
||||
typedef php_stream *(*php_stream_factory_func_t)(char *filename, char *mode, int options, char **opened_path STREAMS_DC);
|
||||
typedef void (*php_stream_wrapper_dtor_func_t)(php_stream *stream);
|
||||
typedef php_stream *(*php_stream_factory_func_t)(char *filename, char *mode, int options, char **opened_path STREAMS_DC TSRMLS_DC);
|
||||
typedef void (*php_stream_wrapper_dtor_func_t)(php_stream *stream TSRMLS_DC);
|
||||
|
||||
typedef struct _php_stream_wrapper {
|
||||
php_stream_factory_func_t create;
|
||||
@@ -129,37 +129,62 @@ struct _php_stream {
|
||||
#define PHP_STREAM_FCLOSE_FDOPEN 1
|
||||
#define PHP_STREAM_FCLOSE_FOPENCOOKIE 2
|
||||
|
||||
|
||||
/* allocate a new stream for a particular ops */
|
||||
PHPAPI php_stream *_php_stream_alloc(php_stream_ops *ops, void *abstract,
|
||||
int persistent, const char *mode STREAMS_DC);
|
||||
#define php_stream_alloc(ops, thisptr, persistent, mode) _php_stream_alloc((ops), (thisptr), (persistent), (mode) STREAMS_CC)
|
||||
int persistent, const char *mode STREAMS_DC TSRMLS_DC);
|
||||
#define php_stream_alloc(ops, thisptr, persistent, mode) _php_stream_alloc((ops), (thisptr), (persistent), (mode) STREAMS_CC TSRMLS_CC)
|
||||
|
||||
PHPAPI int php_stream_free(php_stream *stream, int call_dtor);
|
||||
#define php_stream_close(stream) php_stream_free(stream, 1)
|
||||
#define PHP_STREAM_FREE_CALL_DTOR 1 /* call ops->close */
|
||||
#define PHP_STREAM_FREE_RELEASE_STREAM 2 /* pefree(stream) */
|
||||
#define PHP_STREAM_FREE_PRESERVE_HANDLE 4 /* tell ops->close to not close it's underlying handle */
|
||||
#define PHP_STREAM_FREE_CLOSE (PHP_STREAM_FREE_CALL_DTOR | PHP_STREAM_FREE_RELEASE_STREAM)
|
||||
PHPAPI int _php_stream_free(php_stream *stream, int close_options TSRMLS_DC);
|
||||
#define php_stream_free(stream, close_options) _php_stream_free((stream), (close_options) TSRMLS_CC)
|
||||
#define php_stream_close(stream) _php_stream_free((stream), PHP_STREAM_FREE_CLOSE TSRMLS_CC)
|
||||
|
||||
PHPAPI int php_stream_seek(php_stream *stream, off_t offset, int whence);
|
||||
#define php_stream_rewind(stream) php_stream_seek(stream, 0L, SEEK_SET)
|
||||
PHPAPI off_t php_stream_tell(php_stream *stream);
|
||||
PHPAPI size_t php_stream_read(php_stream *stream, char *buf, size_t count);
|
||||
PHPAPI size_t php_stream_write(php_stream *stream, const char *buf, size_t count);
|
||||
#define php_stream_write_string(stream, str) php_stream_write(stream, str, strlen(str))
|
||||
PHPAPI int php_stream_eof(php_stream *stream);
|
||||
PHPAPI int php_stream_getc(php_stream *stream);
|
||||
PHPAPI int php_stream_putc(php_stream *stream, int c);
|
||||
PHPAPI int php_stream_flush(php_stream *stream);
|
||||
PHPAPI char *php_stream_gets(php_stream *stream, char *buf, size_t maxlen);
|
||||
PHPAPI int php_stream_puts(php_stream *stream, char *buf);
|
||||
PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC);
|
||||
#define php_stream_rewind(stream) _php_stream_seek((stream), 0L, SEEK_SET TSRMLS_CC)
|
||||
#define php_stream_seek(stream, offset, whence) _php_stream_seek((stream), (offset), (whence) TSRMLS_CC)
|
||||
|
||||
PHPAPI off_t _php_stream_tell(php_stream *stream TSRMLS_DC);
|
||||
#define php_stream_tell(stream) _php_stream_tell((stream) TSRMLS_CC)
|
||||
|
||||
PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC);
|
||||
#define php_stream_read(stream, buf, count) _php_stream_read((stream), (buf), (count) TSRMLS_CC)
|
||||
|
||||
PHPAPI size_t _php_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC);
|
||||
#define php_stream_write_string(stream, str) _php_stream_write(stream, str, strlen(str) TSRMLS_CC)
|
||||
#define php_stream_write(stream, buf, count) _php_stream_write(stream, (buf), (count) TSRMLS_CC)
|
||||
|
||||
PHPAPI int _php_stream_eof(php_stream *stream TSRMLS_DC);
|
||||
#define php_stream_eof(stream) _php_stream_eof((stream) TSRMLS_CC)
|
||||
|
||||
PHPAPI int _php_stream_getc(php_stream *stream TSRMLS_DC);
|
||||
#define php_stream_getc(stream) _php_stream_getc((stream) TSRMLS_CC)
|
||||
|
||||
PHPAPI int _php_stream_putc(php_stream *stream, int c TSRMLS_DC);
|
||||
#define php_stream_putc(stream, c) _php_stream_putc((stream), (c) TSRMLS_CC)
|
||||
|
||||
PHPAPI int _php_stream_flush(php_stream *stream TSRMLS_DC);
|
||||
#define php_stream_flush(stream) _php_stream_flush((stream) TSRMLS_CC)
|
||||
|
||||
PHPAPI char *_php_stream_gets(php_stream *stream, char *buf, size_t maxlen TSRMLS_DC);
|
||||
#define php_stream_gets(stream, buf, maxlen) _php_stream_gets((stream), (buf), (maxlen) TSRMLS_CC)
|
||||
|
||||
PHPAPI int _php_stream_puts(php_stream *stream, char *buf TSRMLS_DC);
|
||||
#define php_stream_puts(stream, buf) _php_stream_puts((stream), (buf) TSRMLS_CC)
|
||||
|
||||
/* copy up to maxlen bytes from src to dest. If maxlen is PHP_STREAM_COPY_ALL, copy until eof(src).
|
||||
* Uses mmap if the src is a plain file and at offset 0 */
|
||||
#define PHP_STREAM_COPY_ALL -1
|
||||
PHPAPI size_t php_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen);
|
||||
PHPAPI size_t _php_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen STREAMS_DC TSRMLS_DC);
|
||||
#define php_stream_copy_to_stream(src, dest, maxlen) _php_stream_copy_to_stream((src), (dest), (maxlen) STREAMS_CC TSRMLS_CC)
|
||||
|
||||
/* read all data from stream and put into a buffer. Caller must free buffer when done.
|
||||
* The copy will use mmap if available. */
|
||||
PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen,
|
||||
int persistent STREAMS_DC);
|
||||
#define php_stream_copy_to_mem(src, buf, maxlen, persistent) _php_stream_copy_to_mem((src), (buf), (maxlen), (persistent) STREAMS_CC)
|
||||
int persistent STREAMS_DC TSRMLS_DC);
|
||||
#define php_stream_copy_to_mem(src, buf, maxlen, persistent) _php_stream_copy_to_mem((src), (buf), (maxlen), (persistent) STREAMS_CC TSRMLS_CC)
|
||||
|
||||
|
||||
/* maybe implement someday */
|
||||
@@ -168,23 +193,23 @@ PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen
|
||||
/* operations for a stdio FILE; use the php_stream_fopen_XXX funcs below */
|
||||
extern php_stream_ops php_stream_stdio_ops;
|
||||
/* like fopen, but returns a stream */
|
||||
PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, char **opened_path STREAMS_DC);
|
||||
#define php_stream_fopen(filename, mode, opened) _php_stream_fopen((filename), (mode), (opened) STREAMS_CC)
|
||||
PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, char **opened_path STREAMS_DC TSRMLS_DC);
|
||||
#define php_stream_fopen(filename, mode, opened) _php_stream_fopen((filename), (mode), (opened) STREAMS_CC TSRMLS_CC)
|
||||
|
||||
PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char *path, char **opened_path STREAMS_DC);
|
||||
#define php_stream_fopen_with_path(filename, mode, path, opened) _php_stream_fopen_with_path((filename), (mode), (path), (opened) STREAMS_CC)
|
||||
PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char *path, char **opened_path STREAMS_DC TSRMLS_DC);
|
||||
#define php_stream_fopen_with_path(filename, mode, path, opened) _php_stream_fopen_with_path((filename), (mode), (path), (opened) STREAMS_CC TSRMLS_CC)
|
||||
|
||||
PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STREAMS_DC);
|
||||
#define php_stream_fopen_from_file(file, mode) _php_stream_fopen_from_file((file), (mode) STREAMS_CC)
|
||||
PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STREAMS_DC TSRMLS_DC);
|
||||
#define php_stream_fopen_from_file(file, mode) _php_stream_fopen_from_file((file), (mode) STREAMS_CC TSRMLS_CC)
|
||||
|
||||
PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode STREAMS_DC);
|
||||
#define php_stream_fopen_from_pipe(file, mode) _php_stream_fopen_from_pipe((file), (mode) STREAMS_CC)
|
||||
PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode STREAMS_DC TSRMLS_DC);
|
||||
#define php_stream_fopen_from_pipe(file, mode) _php_stream_fopen_from_pipe((file), (mode) STREAMS_CC TSRMLS_CC)
|
||||
|
||||
PHPAPI php_stream *_php_stream_fopen_tmpfile(STREAMS_D);
|
||||
#define php_stream_fopen_tmpfile() _php_stream_fopen_tmpfile(STREAMS_C)
|
||||
PHPAPI php_stream *_php_stream_fopen_tmpfile(STREAMS_D TSRMLS_DC);
|
||||
#define php_stream_fopen_tmpfile() _php_stream_fopen_tmpfile(STREAMS_C TSRMLS_CC)
|
||||
|
||||
PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char *pfx, char **opened_path STREAMS_DC);
|
||||
#define php_stream_fopen_temporary_file(dir, pfx, opened_path) _php_stream_fopen_temporary_file((dir), (pfx), (opened_path) STREAMS_CC)
|
||||
PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char *pfx, char **opened_path STREAMS_DC TSRMLS_DC);
|
||||
#define php_stream_fopen_temporary_file(dir, pfx, opened_path) _php_stream_fopen_temporary_file((dir), (pfx), (opened_path) STREAMS_CC TSRMLS_CC)
|
||||
|
||||
/* coerce the stream into some other form */
|
||||
/* cast as a stdio FILE * */
|
||||
@@ -198,9 +223,10 @@ PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char
|
||||
#define PHP_STREAM_CAST_TRY_HARD 0x80000000
|
||||
#define PHP_STREAM_CAST_RELEASE 0x40000000 /* stream becomes invalid on success */
|
||||
#define PHP_STREAM_CAST_MASK (PHP_STREAM_CAST_TRY_HARD | PHP_STREAM_CAST_RELEASE)
|
||||
PHPAPI int php_stream_cast(php_stream *stream, int castas, void **ret, int show_err);
|
||||
PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err TSRMLS_DC);
|
||||
/* use this to check if a stream can be cast into another form */
|
||||
#define php_stream_can_cast(stream, as) php_stream_cast(stream, as, NULL, 0)
|
||||
#define php_stream_can_cast(stream, as) _php_stream_cast((stream), (as), NULL, 0 TSRMLS_CC)
|
||||
#define php_stream_cast(stream, as, ret, show_err) _php_stream_cast((stream), (as), (ret), (show_err) TSRMLS_CC)
|
||||
|
||||
/* use this to check if a stream is of a particular type:
|
||||
* PHPAPI int php_stream_is(php_stream *stream, php_stream_ops *ops); */
|
||||
@@ -231,16 +257,16 @@ int php_init_stream_wrappers(TSRMLS_D);
|
||||
int php_shutdown_stream_wrappers(TSRMLS_D);
|
||||
PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC);
|
||||
PHPAPI int php_unregister_url_stream_wrapper(char *protocol TSRMLS_DC);
|
||||
PHPAPI php_stream *_php_stream_open_wrapper(char *path, char *mode, int options, char **opened_path STREAMS_DC);
|
||||
#define php_stream_open_wrapper(path, mode, options, opened) _php_stream_open_wrapper((path), (mode), (options), (opened) STREAMS_CC)
|
||||
PHPAPI php_stream *_php_stream_open_wrapper(char *path, char *mode, int options, char **opened_path STREAMS_DC TSRMLS_DC);
|
||||
#define php_stream_open_wrapper(path, mode, options, opened) _php_stream_open_wrapper((path), (mode), (options), (opened) STREAMS_CC TSRMLS_CC)
|
||||
|
||||
#define PHP_STREAM_UNCHANGED 0 /* orig stream was seekable anyway */
|
||||
#define PHP_STREAM_RELEASED 1 /* newstream should be used; origstream is no longer valid */
|
||||
#define PHP_STREAM_FAILED 2 /* an error occurred while attempting conversion */
|
||||
#define PHP_STREAM_CRITICAL 3 /* an error occurred; origstream is in an unknown state; you should close origstream */
|
||||
/* DO NOT call this on streams that are referenced by resources! */
|
||||
PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstream STREAMS_DC);
|
||||
#define php_stream_make_seekable(origstream, newstream) _php_stream_make_seekable(origstream, newstream STREAMS_CC)
|
||||
PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstream STREAMS_DC TSRMLS_DC);
|
||||
#define php_stream_make_seekable(origstream, newstream) _php_stream_make_seekable(origstream, newstream STREAMS_CC TSRMLS_CC)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
133
main/streams.c
133
main/streams.c
@@ -46,12 +46,12 @@
|
||||
/* some macros to help track leaks */
|
||||
#define emalloc_rel_orig(size) \
|
||||
( __php_stream_call_depth == 0 \
|
||||
? _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC) \
|
||||
? _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_RELAY_CC) \
|
||||
: _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC) )
|
||||
|
||||
#define erealloc_rel_orig(ptr, size) \
|
||||
( __php_stream_call_depth == 0 \
|
||||
? _erealloc((ptr), (size), 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC) \
|
||||
? _erealloc((ptr), (size), 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_RELAY_CC) \
|
||||
: _erealloc((ptr), (size), 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC) )
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
static HashTable url_stream_wrappers_hash;
|
||||
|
||||
/* allocate a new stream for a particular ops */
|
||||
PHPAPI php_stream *_php_stream_alloc(php_stream_ops *ops, void *abstract, int persistent, const char *mode STREAMS_DC) /* {{{ */
|
||||
PHPAPI php_stream *_php_stream_alloc(php_stream_ops *ops, void *abstract, int persistent, const char *mode STREAMS_DC TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
php_stream *ret;
|
||||
|
||||
@@ -84,16 +84,11 @@ PHPAPI php_stream *_php_stream_alloc(php_stream_ops *ops, void *abstract, int pe
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
PHPAPI int php_stream_free(php_stream *stream, int call_dtor) /* {{{ */
|
||||
PHPAPI int _php_stream_free(php_stream *stream, int close_options TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
int ret = 1;
|
||||
|
||||
if (stream->wrapper && stream->wrapper->destroy) {
|
||||
stream->wrapper->destroy(stream);
|
||||
stream->wrapper = NULL;
|
||||
}
|
||||
|
||||
if (call_dtor) {
|
||||
if (close_options & PHP_STREAM_FREE_CALL_DTOR) {
|
||||
if (stream->fclose_stdiocast == PHP_STREAM_FCLOSE_FOPENCOOKIE) {
|
||||
/* calling fclose on an fopencookied stream will ultimately
|
||||
call this very same function. If we were called via fclose,
|
||||
@@ -106,12 +101,10 @@ PHPAPI int php_stream_free(php_stream *stream, int call_dtor) /* {{{ */
|
||||
}
|
||||
|
||||
php_stream_flush(stream);
|
||||
}
|
||||
|
||||
ret = stream->ops->close(stream, call_dtor);
|
||||
stream->abstract = NULL;
|
||||
ret = stream->ops->close(stream, close_options & PHP_STREAM_FREE_PRESERVE_HANDLE ? 0 : 1 TSRMLS_CC);
|
||||
stream->abstract = NULL;
|
||||
|
||||
if (call_dtor) {
|
||||
/* tidy up any FILE* that might have been fdopened */
|
||||
if (stream->fclose_stdiocast == PHP_STREAM_FCLOSE_FDOPEN && stream->stdiocast) {
|
||||
fclose(stream->stdiocast);
|
||||
@@ -119,31 +112,40 @@ PHPAPI int php_stream_free(php_stream *stream, int call_dtor) /* {{{ */
|
||||
}
|
||||
}
|
||||
|
||||
if (stream->wrapperdata) {
|
||||
FREE_ZVAL(stream->wrapperdata);
|
||||
stream->wrapperdata = NULL;
|
||||
if (close_options & PHP_STREAM_FREE_RELEASE_STREAM) {
|
||||
|
||||
if (stream->wrapper && stream->wrapper->destroy) {
|
||||
stream->wrapper->destroy(stream TSRMLS_CC);
|
||||
stream->wrapper = NULL;
|
||||
}
|
||||
|
||||
if (stream->wrapperdata) {
|
||||
FREE_ZVAL(stream->wrapperdata);
|
||||
stream->wrapperdata = NULL;
|
||||
}
|
||||
|
||||
pefree(stream, stream->is_persistent);
|
||||
}
|
||||
pefree(stream, stream->is_persistent);
|
||||
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ generic stream operations */
|
||||
PHPAPI size_t php_stream_read(php_stream *stream, char *buf, size_t size)
|
||||
PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t size TSRMLS_DC)
|
||||
{
|
||||
return stream->ops->read(stream, buf, size);
|
||||
return stream->ops->read(stream, buf, size TSRMLS_CC);
|
||||
}
|
||||
|
||||
PHPAPI int php_stream_eof(php_stream *stream)
|
||||
PHPAPI int _php_stream_eof(php_stream *stream TSRMLS_DC)
|
||||
{
|
||||
/* we define our stream reading function so that it
|
||||
must return EOF when an EOF condition occurs, when
|
||||
working in unbuffered mode and called with these args */
|
||||
return stream->ops->read(stream, NULL, 0) == EOF ? 1 : 0;
|
||||
return stream->ops->read(stream, NULL, 0 TSRMLS_CC) == EOF ? 1 : 0;
|
||||
}
|
||||
|
||||
PHPAPI int php_stream_putc(php_stream *stream, int c)
|
||||
PHPAPI int _php_stream_putc(php_stream *stream, int c TSRMLS_DC)
|
||||
{
|
||||
unsigned char buf = c;
|
||||
|
||||
@@ -153,7 +155,7 @@ PHPAPI int php_stream_putc(php_stream *stream, int c)
|
||||
return EOF;
|
||||
}
|
||||
|
||||
PHPAPI int php_stream_getc(php_stream *stream)
|
||||
PHPAPI int _php_stream_getc(php_stream *stream TSRMLS_DC)
|
||||
{
|
||||
char buf;
|
||||
|
||||
@@ -163,7 +165,7 @@ PHPAPI int php_stream_getc(php_stream *stream)
|
||||
return EOF;
|
||||
}
|
||||
|
||||
PHPAPI int php_stream_puts(php_stream *stream, char *buf)
|
||||
PHPAPI int _php_stream_puts(php_stream *stream, char *buf TSRMLS_DC)
|
||||
{
|
||||
int len;
|
||||
char newline[2] = "\n"; /* is this OK for Win? */
|
||||
@@ -175,7 +177,7 @@ PHPAPI int php_stream_puts(php_stream *stream, char *buf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
PHPAPI char *php_stream_gets(php_stream *stream, char *buf, size_t maxlen)
|
||||
PHPAPI char *_php_stream_gets(php_stream *stream, char *buf, size_t maxlen TSRMLS_DC)
|
||||
{
|
||||
|
||||
if (maxlen == 0) {
|
||||
@@ -184,7 +186,7 @@ PHPAPI char *php_stream_gets(php_stream *stream, char *buf, size_t maxlen)
|
||||
}
|
||||
|
||||
if (stream->ops->gets) {
|
||||
return stream->ops->gets(stream, buf, maxlen);
|
||||
return stream->ops->gets(stream, buf, maxlen TSRMLS_CC);
|
||||
} else {
|
||||
/* unbuffered fgets - poor performance ! */
|
||||
size_t n = 1;
|
||||
@@ -192,7 +194,7 @@ PHPAPI char *php_stream_gets(php_stream *stream, char *buf, size_t maxlen)
|
||||
|
||||
/* TODO: look at error returns? */
|
||||
|
||||
while(n < maxlen && stream->ops->read(stream, c, 1) > 0) {
|
||||
while(n < maxlen && stream->ops->read(stream, c, 1 TSRMLS_CC) > 0) {
|
||||
n++;
|
||||
if (*c == '\n') {
|
||||
c++;
|
||||
@@ -205,33 +207,33 @@ PHPAPI char *php_stream_gets(php_stream *stream, char *buf, size_t maxlen)
|
||||
}
|
||||
}
|
||||
|
||||
PHPAPI int php_stream_flush(php_stream *stream)
|
||||
PHPAPI int _php_stream_flush(php_stream *stream TSRMLS_DC)
|
||||
{
|
||||
if (stream->ops->flush) {
|
||||
return stream->ops->flush(stream);
|
||||
return stream->ops->flush(stream TSRMLS_CC);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
PHPAPI size_t php_stream_write(php_stream *stream, const char *buf, size_t count)
|
||||
PHPAPI size_t _php_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
return stream->ops->write(stream, buf, count);
|
||||
return stream->ops->write(stream, buf, count TSRMLS_CC);
|
||||
}
|
||||
|
||||
PHPAPI off_t php_stream_tell(php_stream *stream)
|
||||
PHPAPI off_t _php_stream_tell(php_stream *stream TSRMLS_DC)
|
||||
{
|
||||
off_t ret = -1;
|
||||
|
||||
if (stream->ops->seek) {
|
||||
ret = stream->ops->seek(stream, 0, SEEK_CUR);
|
||||
ret = stream->ops->seek(stream, 0, SEEK_CUR TSRMLS_CC);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
PHPAPI int php_stream_seek(php_stream *stream, off_t offset, int whence)
|
||||
PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC)
|
||||
{
|
||||
if (stream->ops->seek) {
|
||||
return stream->ops->seek(stream, offset, whence);
|
||||
return stream->ops->seek(stream, offset, whence TSRMLS_CC);
|
||||
}
|
||||
|
||||
/* emulate forward moving seeks with reads */
|
||||
@@ -253,7 +255,7 @@ PHPAPI int php_stream_seek(php_stream *stream, off_t offset, int whence)
|
||||
return -1;
|
||||
}
|
||||
|
||||
PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen, int persistent STREAMS_DC)
|
||||
PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen, int persistent STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
size_t ret = 0;
|
||||
char *ptr;
|
||||
@@ -328,7 +330,7 @@ PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen
|
||||
return len;
|
||||
}
|
||||
|
||||
PHPAPI size_t php_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen)
|
||||
PHPAPI size_t _php_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
char buf[CHUNK_SIZE];
|
||||
size_t readchunk;
|
||||
@@ -427,7 +429,7 @@ typedef struct {
|
||||
#endif
|
||||
} php_stdio_stream_data;
|
||||
|
||||
PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char *pfx, char **opened_path STREAMS_DC)
|
||||
PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char *pfx, char **opened_path STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
FILE *fp = php_open_temporary_file(dir, pfx, opened_path TSRMLS_CC);
|
||||
|
||||
@@ -445,7 +447,7 @@ PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PHPAPI php_stream *_php_stream_fopen_tmpfile(STREAMS_D)
|
||||
PHPAPI php_stream *_php_stream_fopen_tmpfile(STREAMS_D TSRMLS_DC)
|
||||
{
|
||||
FILE *fp;
|
||||
php_stream *stream;
|
||||
@@ -466,7 +468,7 @@ PHPAPI php_stream *_php_stream_fopen_tmpfile(STREAMS_D)
|
||||
|
||||
|
||||
|
||||
PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STREAMS_DC)
|
||||
PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
php_stdio_stream_data *self;
|
||||
|
||||
@@ -476,7 +478,7 @@ PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STRE
|
||||
return php_stream_alloc_rel(&php_stream_stdio_ops, self, 0, mode);
|
||||
}
|
||||
|
||||
PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode STREAMS_DC)
|
||||
PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
php_stdio_stream_data *self;
|
||||
|
||||
@@ -485,7 +487,7 @@ PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode STRE
|
||||
self->is_pipe = 1;
|
||||
return php_stream_alloc_rel(&php_stream_stdio_ops, self, 0, mode);
|
||||
}
|
||||
static size_t php_stdiop_write(php_stream *stream, const char *buf, size_t count)
|
||||
static size_t php_stdiop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
|
||||
|
||||
@@ -501,7 +503,7 @@ static size_t php_stdiop_write(php_stream *stream, const char *buf, size_t count
|
||||
return fwrite(buf, 1, count, data->file);
|
||||
}
|
||||
|
||||
static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
|
||||
static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
|
||||
{
|
||||
php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
|
||||
|
||||
@@ -524,7 +526,7 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
|
||||
return fread(buf, 1, count, data->file);
|
||||
}
|
||||
|
||||
static int php_stdiop_close(php_stream *stream, int close_handle)
|
||||
static int php_stdiop_close(php_stream *stream, int close_handle TSRMLS_DC)
|
||||
{
|
||||
int ret;
|
||||
php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
|
||||
@@ -541,12 +543,13 @@ static int php_stdiop_close(php_stream *stream, int close_handle)
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
/* STDIO streams are never persistent! */
|
||||
efree(data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int php_stdiop_flush(php_stream *stream)
|
||||
static int php_stdiop_flush(php_stream *stream TSRMLS_DC)
|
||||
{
|
||||
php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
|
||||
|
||||
@@ -555,7 +558,7 @@ static int php_stdiop_flush(php_stream *stream)
|
||||
return fflush(data->file);
|
||||
}
|
||||
|
||||
static int php_stdiop_seek(php_stream *stream, off_t offset, int whence)
|
||||
static int php_stdiop_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC)
|
||||
{
|
||||
php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
|
||||
|
||||
@@ -567,7 +570,7 @@ static int php_stdiop_seek(php_stream *stream, off_t offset, int whence)
|
||||
return fseek(data->file, offset, whence);
|
||||
}
|
||||
|
||||
static char *php_stdiop_gets(php_stream *stream, char *buf, size_t size)
|
||||
static char *php_stdiop_gets(php_stream *stream, char *buf, size_t size TSRMLS_DC)
|
||||
{
|
||||
php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
|
||||
|
||||
@@ -581,7 +584,7 @@ static char *php_stdiop_gets(php_stream *stream, char *buf, size_t size)
|
||||
|
||||
return fgets(buf, size, data->file);
|
||||
}
|
||||
static int php_stdiop_cast(php_stream *stream, int castas, void **ret)
|
||||
static int php_stdiop_cast(php_stream *stream, int castas, void **ret TSRMLS_DC)
|
||||
{
|
||||
int fd;
|
||||
php_stdio_stream_data *data = (php_stdio_stream_data*) stream->abstract;
|
||||
@@ -616,7 +619,7 @@ php_stream_ops php_stream_stdio_ops = {
|
||||
"STDIO"
|
||||
};
|
||||
|
||||
PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char *path, char **opened_path STREAMS_DC) /* {{{ */
|
||||
PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char *path, char **opened_path STREAMS_DC TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
/* code ripped off from fopen_wrappers.c */
|
||||
char *pathbuf, *ptr, *end;
|
||||
@@ -733,7 +736,7 @@ PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, char **opened_path STREAMS_DC)
|
||||
PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, char **opened_path STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
FILE *fp;
|
||||
char *realpath = NULL;
|
||||
@@ -767,18 +770,22 @@ PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, cha
|
||||
#if HAVE_FOPENCOOKIE
|
||||
static ssize_t stream_cookie_reader(void *cookie, char *buffer, size_t size)
|
||||
{
|
||||
return php_stream_read(((php_stream *)cookie), buffer, size);
|
||||
TSRMLS_FETCH();
|
||||
return php_stream_read(((php_stream *)cookie), buffer, size);
|
||||
}
|
||||
|
||||
static ssize_t stream_cookie_writer(void *cookie, const char *buffer, size_t size) {
|
||||
return php_stream_write(((php_stream *)cookie), (char *)buffer, size);
|
||||
TSRMLS_FETCH();
|
||||
return php_stream_write(((php_stream *)cookie), (char *)buffer, size);
|
||||
}
|
||||
|
||||
static int stream_cookie_seeker(void *cookie, off_t position, int whence) {
|
||||
return php_stream_seek(((php_stream *)cookie), position, whence);
|
||||
TSRMLS_FETCH();
|
||||
return php_stream_seek(((php_stream *)cookie), position, whence);
|
||||
}
|
||||
|
||||
static int stream_cookie_closer(void *cookie) {
|
||||
TSRMLS_FETCH();
|
||||
php_stream *stream = (php_stream*)cookie;
|
||||
/* prevent recursion */
|
||||
stream->fclose_stdiocast = PHP_STREAM_FCLOSE_NONE;
|
||||
@@ -795,7 +802,7 @@ static COOKIE_IO_FUNCTIONS_T stream_cookie_functions =
|
||||
#endif
|
||||
/* }}} */
|
||||
|
||||
PHPAPI int php_stream_cast(php_stream *stream, int castas, void **ret, int show_err) /* {{{ */
|
||||
PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
int flags = castas & PHP_STREAM_CAST_MASK;
|
||||
castas &= ~PHP_STREAM_CAST_MASK;
|
||||
@@ -808,7 +815,7 @@ PHPAPI int php_stream_cast(php_stream *stream, int castas, void **ret, int show_
|
||||
goto exit_success;
|
||||
}
|
||||
|
||||
if (stream->ops->cast && stream->ops->cast(stream, castas, ret) == SUCCESS)
|
||||
if (stream->ops->cast && stream->ops->cast(stream, castas, ret TSRMLS_CC) == SUCCESS)
|
||||
goto exit_success;
|
||||
|
||||
|
||||
@@ -839,7 +846,7 @@ PHPAPI int php_stream_cast(php_stream *stream, int castas, void **ret, int show_
|
||||
|
||||
goto exit_fail;
|
||||
}
|
||||
if (stream->ops->cast && stream->ops->cast(stream, castas, ret) == SUCCESS)
|
||||
if (stream->ops->cast && stream->ops->cast(stream, castas, ret TSRMLS_CC) == SUCCESS)
|
||||
goto exit_success;
|
||||
|
||||
|
||||
@@ -873,7 +880,7 @@ exit_success:
|
||||
if (stream->fclose_stdiocast != PHP_STREAM_FCLOSE_FOPENCOOKIE) {
|
||||
/* ask the implementation to release resources other than
|
||||
* the underlying handle */
|
||||
php_stream_free(stream, 0);
|
||||
php_stream_free(stream, PHP_STREAM_FREE_PRESERVE_HANDLE | PHP_STREAM_FREE_CLOSE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -913,7 +920,7 @@ PHPAPI int php_unregister_url_stream_wrapper(char *protocol TSRMLS_DC)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
static php_stream *php_stream_open_url(char *path, char *mode, int options, char **opened_path STREAMS_DC)
|
||||
static php_stream *php_stream_open_url(char *path, char *mode, int options, char **opened_path STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
php_stream_wrapper *wrapper;
|
||||
const char *p, *protocol = NULL;
|
||||
@@ -933,7 +940,7 @@ static php_stream *php_stream_open_url(char *path, char *mode, int options, char
|
||||
protocol = NULL;
|
||||
}
|
||||
if (wrapper) {
|
||||
php_stream *stream = wrapper->create(path, mode, options, opened_path STREAMS_REL_CC);
|
||||
php_stream *stream = wrapper->create(path, mode, options, opened_path STREAMS_REL_CC TSRMLS_CC);
|
||||
if (stream)
|
||||
stream->wrapper = wrapper;
|
||||
return stream;
|
||||
@@ -955,7 +962,7 @@ static php_stream *php_stream_open_url(char *path, char *mode, int options, char
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PHPAPI php_stream *_php_stream_open_wrapper(char *path, char *mode, int options, char **opened_path STREAMS_DC)
|
||||
PHPAPI php_stream *_php_stream_open_wrapper(char *path, char *mode, int options, char **opened_path STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
php_stream *stream = NULL;
|
||||
|
||||
@@ -966,7 +973,7 @@ PHPAPI php_stream *_php_stream_open_wrapper(char *path, char *mode, int options,
|
||||
return NULL;
|
||||
|
||||
if (PG(allow_url_fopen) && !(options & IGNORE_URL)) {
|
||||
stream = php_stream_open_url(path, mode, options, opened_path STREAMS_REL_CC);
|
||||
stream = php_stream_open_url(path, mode, options, opened_path STREAMS_REL_CC TSRMLS_CC);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -1011,7 +1018,7 @@ out:
|
||||
return stream;
|
||||
}
|
||||
|
||||
PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstream STREAMS_DC)
|
||||
PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstream STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
assert(newstream != NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user