diff options
Diffstat (limited to 'ext/standard/php_fopen_wrapper.c')
-rw-r--r-- | ext/standard/php_fopen_wrapper.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index 53a0e2ec24..af8e5b60aa 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -1,8 +1,8 @@ /* +----------------------------------------------------------------------+ - | PHP Version 5 | + | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -31,21 +31,21 @@ #include "php_fopen_wrappers.h" #include "SAPI.h" -static size_t php_stream_output_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) /* {{{ */ +static size_t php_stream_output_write(php_stream *stream, const char *buf, size_t count) /* {{{ */ { PHPWRITE(buf, count); return count; } /* }}} */ -static size_t php_stream_output_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) /* {{{ */ +static size_t php_stream_output_read(php_stream *stream, char *buf, size_t count) /* {{{ */ { stream->eof = 1; return 0; } /* }}} */ -static int php_stream_output_close(php_stream *stream, int close_handle TSRMLS_DC) /* {{{ */ +static int php_stream_output_close(php_stream *stream, int close_handle) /* {{{ */ { return 0; } @@ -65,24 +65,24 @@ php_stream_ops php_stream_output_ops = { typedef struct php_stream_input { /* {{{ */ php_stream *body; - off_t position; + zend_off_t position; } php_stream_input_t; /* }}} */ -static size_t php_stream_input_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) /* {{{ */ +static size_t php_stream_input_write(php_stream *stream, const char *buf, size_t count) /* {{{ */ { return -1; } /* }}} */ -static size_t php_stream_input_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) /* {{{ */ +static size_t php_stream_input_read(php_stream *stream, char *buf, size_t count) /* {{{ */ { php_stream_input_t *input = stream->abstract; size_t read; - if (!SG(post_read) && SG(read_post_bytes) < input->position + count) { + if (!SG(post_read) && SG(read_post_bytes) < (int64_t)(input->position + count)) { /* read requested data from SAPI */ - int read_bytes = sapi_read_post_block(buf, count TSRMLS_CC); + int read_bytes = sapi_read_post_block(buf, count); if (read_bytes > 0) { php_stream_seek(input->body, 0, SEEK_END); @@ -103,7 +103,7 @@ static size_t php_stream_input_read(php_stream *stream, char *buf, size_t count } /* }}} */ -static int php_stream_input_close(php_stream *stream, int close_handle TSRMLS_DC) /* {{{ */ +static int php_stream_input_close(php_stream *stream, int close_handle) /* {{{ */ { efree(stream->abstract); stream->abstract = NULL; @@ -112,13 +112,13 @@ static int php_stream_input_close(php_stream *stream, int close_handle TSRMLS_DC } /* }}} */ -static int php_stream_input_flush(php_stream *stream TSRMLS_DC) /* {{{ */ +static int php_stream_input_flush(php_stream *stream) /* {{{ */ { return -1; } /* }}} */ -static int php_stream_input_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) /* {{{ */ +static int php_stream_input_seek(php_stream *stream, zend_off_t offset, int whence, zend_off_t *newoffset) /* {{{ */ { php_stream_input_t *input = stream->abstract; @@ -144,26 +144,26 @@ php_stream_ops php_stream_input_ops = { NULL /* set_option */ }; -static void php_stream_apply_filter_list(php_stream *stream, char *filterlist, int read_chain, int write_chain TSRMLS_DC) /* {{{ */ +static void php_stream_apply_filter_list(php_stream *stream, char *filterlist, int read_chain, int write_chain) /* {{{ */ { - char *p, *token; + char *p, *token = NULL; php_stream_filter *temp_filter; p = php_strtok_r(filterlist, "|", &token); while (p) { php_url_decode(p, strlen(p)); if (read_chain) { - if ((temp_filter = php_stream_filter_create(p, NULL, php_stream_is_persistent(stream) TSRMLS_CC))) { + if ((temp_filter = php_stream_filter_create(p, NULL, php_stream_is_persistent(stream)))) { php_stream_filter_append(&stream->readfilters, temp_filter); } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create filter (%s)", p); + php_error_docref(NULL, E_WARNING, "Unable to create filter (%s)", p); } } if (write_chain) { - if ((temp_filter = php_stream_filter_create(p, NULL, php_stream_is_persistent(stream) TSRMLS_CC))) { + if ((temp_filter = php_stream_filter_create(p, NULL, php_stream_is_persistent(stream)))) { php_stream_filter_append(&stream->writefilters, temp_filter); } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create filter (%s)", p); + php_error_docref(NULL, E_WARNING, "Unable to create filter (%s)", p); } } p = php_strtok_r(NULL, "|", &token); @@ -172,13 +172,13 @@ static void php_stream_apply_filter_list(php_stream *stream, char *filterlist, i /* }}} */ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, - char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */ + char **opened_path, php_stream_context *context STREAMS_DC) /* {{{ */ { int fd = -1; int mode_rw = 0; php_stream * stream = NULL; char *p, *token, *pathdup; - long max_memory; + zend_long max_memory; FILE *file = NULL; if (!strncasecmp(path, "php://", 6)) { @@ -190,9 +190,9 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa max_memory = PHP_STREAM_MAX_MEM; if (!strncasecmp(path, "/maxmemory:", 11)) { path += 11; - max_memory = strtol(path, NULL, 10); + max_memory = ZEND_STRTOL(path, NULL, 10); if (max_memory < 0) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Max memory must be >= 0"); + php_error_docref(NULL, E_RECOVERABLE_ERROR, "Max memory must be >= 0"); return NULL; } } @@ -222,7 +222,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa if ((options & STREAM_OPEN_FOR_INCLUDE) && !PG(allow_url_include) ) { if (options & REPORT_ERRORS) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "URL file-access is disabled in the server configuration"); + php_error_docref(NULL, E_WARNING, "URL file-access is disabled in the server configuration"); } return NULL; } @@ -241,7 +241,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa if (!strcasecmp(path, "stdin")) { if ((options & STREAM_OPEN_FOR_INCLUDE) && !PG(allow_url_include) ) { if (options & REPORT_ERRORS) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "URL file-access is disabled in the server configuration"); + php_error_docref(NULL, E_WARNING, "URL file-access is disabled in the server configuration"); } return NULL; } @@ -286,27 +286,27 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa } else if (!strncasecmp(path, "fd/", 3)) { const char *start; char *end; - long fildes_ori; + zend_long fildes_ori; int dtablesize; if (strcmp(sapi_module.name, "cli")) { if (options & REPORT_ERRORS) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Direct access to file descriptors is only available from command-line PHP"); + php_error_docref(NULL, E_WARNING, "Direct access to file descriptors is only available from command-line PHP"); } return NULL; } if ((options & STREAM_OPEN_FOR_INCLUDE) && !PG(allow_url_include) ) { if (options & REPORT_ERRORS) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "URL file-access is disabled in the server configuration"); + php_error_docref(NULL, E_WARNING, "URL file-access is disabled in the server configuration"); } return NULL; } start = &path[3]; - fildes_ori = strtol(start, &end, 10); + fildes_ori = ZEND_STRTOL(start, &end, 10); if (end == start || *end != '\0') { - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, + php_stream_wrapper_log_error(wrapper, options, "php://fd/ stream must be specified in the form php://fd/<orig fd>"); return NULL; } @@ -318,15 +318,15 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa #endif if (fildes_ori < 0 || fildes_ori >= dtablesize) { - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, + php_stream_wrapper_log_error(wrapper, options, "The file descriptors must be non-negative numbers smaller than %d", dtablesize); return NULL; } - - fd = dup(fildes_ori); + + fd = dup((int)fildes_ori); if (fd == -1) { - php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, - "Error duping file descriptor %ld; possibly it doesn't exist: " + php_stream_wrapper_log_error(wrapper, options, + "Error duping file descriptor " ZEND_LONG_FMT "; possibly it doesn't exist: " "[%d]: %s", fildes_ori, errno, strerror(errno)); return NULL; } @@ -341,7 +341,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa pathdup = estrndup(path + 6, strlen(path + 6)); p = strstr(pathdup, "/resource="); if (!p) { - php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "No URL resource specified"); + php_error_docref(NULL, E_RECOVERABLE_ERROR, "No URL resource specified"); efree(pathdup); return NULL; } @@ -355,11 +355,11 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa p = php_strtok_r(pathdup + 1, "/", &token); while (p) { if (!strncasecmp(p, "read=", 5)) { - php_stream_apply_filter_list(stream, p + 5, 1, 0 TSRMLS_CC); + php_stream_apply_filter_list(stream, p + 5, 1, 0); } else if (!strncasecmp(p, "write=", 6)) { - php_stream_apply_filter_list(stream, p + 6, 0, 1 TSRMLS_CC); + php_stream_apply_filter_list(stream, p + 6, 0, 1); } else { - php_stream_apply_filter_list(stream, p, mode_rw & PHP_STREAM_FILTER_READ, mode_rw & PHP_STREAM_FILTER_WRITE TSRMLS_CC); + php_stream_apply_filter_list(stream, p, mode_rw & PHP_STREAM_FILTER_READ, mode_rw & PHP_STREAM_FILTER_WRITE); } p = php_strtok_r(NULL, "/", &token); } @@ -368,7 +368,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa return stream; } else { /* invalid php://thingy */ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid php:// URL specified"); + php_error_docref(NULL, E_WARNING, "Invalid php:// URL specified"); return NULL; } @@ -380,9 +380,9 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa #if defined(S_IFSOCK) && !defined(WIN32) && !defined(__BEOS__) do { - struct stat st; + zend_stat_t st; memset(&st, 0, sizeof(st)); - if (fstat(fd, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) { + if (zend_fstat(fd, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) { stream = php_stream_sock_open_from_socket(fd, NULL); if (stream) { stream->ops = &php_stream_socket_ops; @@ -418,7 +418,7 @@ static php_stream_wrapper_ops php_stdio_wops = { NULL /* rmdir */ }; -php_stream_wrapper php_stream_php_wrapper = { +PHPAPI php_stream_wrapper php_stream_php_wrapper = { &php_stdio_wops, NULL, 0, /* is_url */ |