Skip to content

Commit

Permalink
Constify streams API and a few other calls down the rabbit hole.
Browse files Browse the repository at this point in the history
(`char *` to `const char *` for parameters and few return values)
In a few places int len moved to size_t len.
  • Loading branch information
faizshukri committed Jul 30, 2013
1 parent 5e1ac55 commit 92d27cc
Show file tree
Hide file tree
Showing 38 changed files with 202 additions and 189 deletions.
2 changes: 1 addition & 1 deletion README.STREAMS
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Opening Streams
=============== ===============
In most cases, you should use this API: In most cases, you should use this API:


PHPAPI php_stream *php_stream_open_wrapper(char *path, char *mode, PHPAPI php_stream *php_stream_open_wrapper(const char *path, const char *mode,
int options, char **opened_path TSRMLS_DC); int options, char **opened_path TSRMLS_DC);


Where: Where:
Expand Down
2 changes: 1 addition & 1 deletion TSRM/tsrm_virtual_cwd.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1673,7 +1673,7 @@ CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC) /* {{{ */
} }
/* }}} */ /* }}} */


CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC) /* {{{ */ CWD_API int virtual_rename(const char *oldname, const char *newname TSRMLS_DC) /* {{{ */
{ {
cwd_state old_state; cwd_state old_state;
cwd_state new_state; cwd_state new_state;
Expand Down
2 changes: 1 addition & 1 deletion TSRM/tsrm_virtual_cwd.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC);
CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC); CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC);
CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...); CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...);
CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC); CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC);
CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC); CWD_API int virtual_rename(const char *oldname, const char *newname TSRMLS_DC);
CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC); CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC);
CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC); CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC);
CWD_API int virtual_unlink(const char *path TSRMLS_DC); CWD_API int virtual_unlink(const char *path TSRMLS_DC);
Expand Down
8 changes: 4 additions & 4 deletions Zend/zend_operators.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@ static inline zend_uchar is_numeric_string(const char *str, int length, long *lv
return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL); return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL);
} }


static inline char * static inline const char *
zend_memnstr(char *haystack, char *needle, int needle_len, char *end) zend_memnstr(const char *haystack, const char *needle, int needle_len, char *end)
{ {
char *p = haystack; const char *p = haystack;
char ne = needle[needle_len-1]; const char ne = needle[needle_len-1];


if (needle_len == 1) { if (needle_len == 1) {
return (char *)memchr(p, *needle, (end-p)); return (char *)memchr(p, *needle, (end-p));
Expand Down
6 changes: 3 additions & 3 deletions ext/bz2/bz2.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ php_stream_ops php_stream_bz2io_ops = {


/* {{{ Bzip2 stream openers */ /* {{{ Bzip2 stream openers */
PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz, PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz,
char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC) const char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC)
{ {
struct php_bz2_stream_data_t *self; struct php_bz2_stream_data_t *self;


Expand All @@ -205,8 +205,8 @@ PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz,
} }


PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
char *path, const char *path,
char *mode, const char *mode,
int options, int options,
char **opened_path, char **opened_path,
php_stream_context *context STREAMS_DC TSRMLS_DC) php_stream_context *context STREAMS_DC TSRMLS_DC)
Expand Down
4 changes: 2 additions & 2 deletions ext/bz2/php_bz2.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ extern zend_module_entry bz2_module_entry;
# define PHP_BZ2_API # define PHP_BZ2_API
#endif #endif


PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz, char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC); PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz, const char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC);


#define php_stream_bz2open_from_BZFILE(bz, mode, innerstream) _php_stream_bz2open_from_BZFILE((bz), (mode), (innerstream) STREAMS_CC TSRMLS_CC) #define php_stream_bz2open_from_BZFILE(bz, mode, innerstream) _php_stream_bz2open_from_BZFILE((bz), (mode), (innerstream) STREAMS_CC TSRMLS_CC)
#define php_stream_bz2open(wrapper, path, mode, options, opened_path) _php_stream_bz2open((wrapper), (path), (mode), (options), (opened_path), NULL STREAMS_CC TSRMLS_CC) #define php_stream_bz2open(wrapper, path, mode, options, opened_path) _php_stream_bz2open((wrapper), (path), (mode), (options), (opened_path), NULL STREAMS_CC TSRMLS_CC)
Expand Down
2 changes: 1 addition & 1 deletion ext/fileinfo/fileinfo.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
case FILEINFO_MODE_FILE: case FILEINFO_MODE_FILE:
{ {
/* determine if the file is a local file or remote URL */ /* determine if the file is a local file or remote URL */
char *tmp2; const char *tmp2;
php_stream_wrapper *wrap; php_stream_wrapper *wrap;
php_stream_statbuf ssb; php_stream_statbuf ssb;


Expand Down
3 changes: 2 additions & 1 deletion ext/libxml/libxml.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char
php_stream_statbuf ssbuf; php_stream_statbuf ssbuf;
php_stream_context *context = NULL; php_stream_context *context = NULL;
php_stream_wrapper *wrapper = NULL; php_stream_wrapper *wrapper = NULL;
char *resolved_path, *path_to_open = NULL; char *resolved_path;
const char *path_to_open = NULL;
void *ret_val = NULL; void *ret_val = NULL;
int isescaped=0; int isescaped=0;
xmlURI *uri; xmlURI *uri;
Expand Down
8 changes: 4 additions & 4 deletions ext/openssl/xp_ssl.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ static inline int php_openssl_setup_crypto(php_stream *stream,
php_stream_xport_crypto_param *cparam php_stream_xport_crypto_param *cparam
TSRMLS_DC) TSRMLS_DC)
{ {
SSL_METHOD *method; const SSL_METHOD *method;
long ssl_ctx_options = SSL_OP_ALL; long ssl_ctx_options = SSL_OP_ALL;


if (sslsock->ssl_handle) { if (sslsock->ssl_handle) {
Expand Down Expand Up @@ -853,7 +853,7 @@ php_stream_ops php_openssl_socket_ops = {
php_openssl_sockop_set_option, php_openssl_sockop_set_option,
}; };


static char * get_sni(php_stream_context *ctx, char *resourcename, long resourcenamelen, int is_persistent TSRMLS_DC) { static char * get_sni(php_stream_context *ctx, const char *resourcename, size_t resourcenamelen, int is_persistent TSRMLS_DC) {


php_url *url; php_url *url;


Expand Down Expand Up @@ -900,8 +900,8 @@ static char * get_sni(php_stream_context *ctx, char *resourcename, long resource
return NULL; return NULL;
} }


php_stream *php_openssl_ssl_socket_factory(const char *proto, long protolen, php_stream *php_openssl_ssl_socket_factory(const char *proto, size_t protolen,
char *resourcename, long resourcenamelen, const char *resourcename, size_t resourcenamelen,
const char *persistent_id, int options, int flags, const char *persistent_id, int options, int flags,
struct timeval *timeout, struct timeval *timeout,
php_stream_context *context STREAMS_DC TSRMLS_DC) php_stream_context *context STREAMS_DC TSRMLS_DC)
Expand Down
6 changes: 3 additions & 3 deletions ext/phar/dirstream.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
/** /**
* Open a directory handle within a phar archive * Open a directory handle within a phar archive
*/ */
php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */
{ {
php_url *resource = NULL; php_url *resource = NULL;
php_stream *ret; php_stream *ret;
Expand Down Expand Up @@ -432,7 +432,7 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char
/** /**
* Make a new directory within a phar archive * Make a new directory within a phar archive
*/ */
int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC) /* {{{ */ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
{ {
phar_entry_info entry, *e; phar_entry_info entry, *e;
phar_archive_data *phar = NULL; phar_archive_data *phar = NULL;
Expand Down Expand Up @@ -564,7 +564,7 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, in
/** /**
* Remove a directory within a phar archive * Remove a directory within a phar archive
*/ */
int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
{ {
phar_entry_info *entry; phar_entry_info *entry;
phar_archive_data *phar = NULL; phar_archive_data *phar = NULL;
Expand Down
8 changes: 4 additions & 4 deletions ext/phar/dirstream.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
/* $Id$ */ /* $Id$ */


BEGIN_EXTERN_C() BEGIN_EXTERN_C()
int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC); int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC);
int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC); int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC);


#ifdef PHAR_DIRSTREAM #ifdef PHAR_DIRSTREAM
php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC); php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options TSRMLS_DC);


/* directory handlers */ /* directory handlers */
static size_t phar_dir_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC); static size_t phar_dir_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC);
Expand All @@ -33,7 +33,7 @@ static int phar_dir_close(php_stream *stream, int close_handle TSRMLS_DC);
static int phar_dir_flush(php_stream *stream TSRMLS_DC); static int phar_dir_flush(php_stream *stream TSRMLS_DC);
static int phar_dir_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC); static int phar_dir_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
#else #else
php_stream* phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); php_stream* phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
#endif #endif
END_EXTERN_C() END_EXTERN_C()


Expand Down
18 changes: 8 additions & 10 deletions ext/phar/phar.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2251,13 +2251,13 @@ char *phar_fix_filepath(char *path, int *new_len, int use_cwd TSRMLS_DC) /* {{{
* *
* This is used by phar_parse_url() * This is used by phar_parse_url()
*/ */
int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create TSRMLS_DC) /* {{{ */ int phar_split_fname(const char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create TSRMLS_DC) /* {{{ */
{ {
const char *ext_str; const char *ext_str;
#ifdef PHP_WIN32 #ifdef PHP_WIN32
char *save; char *save;
#endif #endif
int ext_len, free_filename = 0; int ext_len;


if (!strncasecmp(filename, "phar://", 7)) { if (!strncasecmp(filename, "phar://", 7)) {
filename += 7; filename += 7;
Expand All @@ -2266,7 +2266,6 @@ int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_le


ext_len = 0; ext_len = 0;
#ifdef PHP_WIN32 #ifdef PHP_WIN32
free_filename = 1;
save = filename; save = filename;
filename = estrndup(filename, filename_len); filename = estrndup(filename, filename_len);
phar_unixify_path_separators(filename, filename_len); phar_unixify_path_separators(filename, filename_len);
Expand All @@ -2282,10 +2281,9 @@ int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_le
#endif #endif
} }


if (free_filename) { #ifdef PHP_WIN32
efree(filename); efree(filename);
} #endif

return FAILURE; return FAILURE;
} }


Expand All @@ -2308,9 +2306,9 @@ int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_le
*entry = estrndup("/", 1); *entry = estrndup("/", 1);
} }


if (free_filename) { #ifdef PHP_WIN32
efree(filename); efree(filename);
} #endif


return SUCCESS; return SUCCESS;
} }
Expand Down
6 changes: 3 additions & 3 deletions ext/phar/phar_internal.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -690,11 +690,11 @@ int phar_entry_delref(phar_entry_data *idata TSRMLS_DC);


phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int path_len, char **error, int security TSRMLS_DC); phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int path_len, char **error, int security TSRMLS_DC);
phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, int path_len, char dir, char **error, int security TSRMLS_DC); phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, int path_len, char dir, char **error, int security TSRMLS_DC);
phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, char *mode, char allow_dir, char **error, int security TSRMLS_DC); phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC);
int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, char *mode, char allow_dir, char **error, int security TSRMLS_DC); int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC);
int phar_flush(phar_archive_data *archive, char *user_stub, long len, int convert, char **error TSRMLS_DC); int phar_flush(phar_archive_data *archive, char *user_stub, long len, int convert, char **error TSRMLS_DC);
int phar_detect_phar_fname_ext(const char *filename, int filename_len, const char **ext_str, int *ext_len, int executable, int for_create, int is_complete TSRMLS_DC); int phar_detect_phar_fname_ext(const char *filename, int filename_len, const char **ext_str, int *ext_len, int executable, int for_create, int is_complete TSRMLS_DC);
int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create TSRMLS_DC); int phar_split_fname(const char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create TSRMLS_DC);


typedef enum { typedef enum {
pcr_use_query, pcr_use_query,
Expand Down
10 changes: 5 additions & 5 deletions ext/phar/stream.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ php_stream_wrapper php_stream_phar_wrapper = {
/** /**
* Open a phar file for streams API * Open a phar file for streams API
*/ */
php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC) /* {{{ */ php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options TSRMLS_DC) /* {{{ */
{ {
php_url *resource; php_url *resource;
char *arch = NULL, *entry = NULL, *error; char *arch = NULL, *entry = NULL, *error;
Expand Down Expand Up @@ -155,7 +155,7 @@ php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode,
/** /**
* used for fopen('phar://...') and company * used for fopen('phar://...') and company
*/ */
static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */
{ {
phar_archive_data *phar; phar_archive_data *phar;
phar_entry_data *idata; phar_entry_data *idata;
Expand Down Expand Up @@ -563,7 +563,7 @@ static int phar_stream_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D
/** /**
* Stream wrapper stat implementation of stat() * Stream wrapper stat implementation of stat()
*/ */
static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags, static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int flags,
php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC) /* {{{ */ php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC) /* {{{ */
{ {
php_url *resource = NULL; php_url *resource = NULL;
Expand Down Expand Up @@ -686,7 +686,7 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags,
/** /**
* Unlink a file within a phar archive * Unlink a file within a phar archive
*/ */
static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
{ {
php_url *resource; php_url *resource;
char *internal_file, *error; char *internal_file, *error;
Expand Down Expand Up @@ -762,7 +762,7 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int optio
} }
/* }}} */ /* }}} */


static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC) /* {{{ */ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from, const char *url_to, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
{ {
php_url *resource_from, *resource_to; php_url *resource_from, *resource_to;
char *error; char *error;
Expand Down
10 changes: 5 additions & 5 deletions ext/phar/stream.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@


BEGIN_EXTERN_C() BEGIN_EXTERN_C()


php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC); php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options TSRMLS_DC);
void phar_entry_remove(phar_entry_data *idata, char **error TSRMLS_DC); void phar_entry_remove(phar_entry_data *idata, char **error TSRMLS_DC);


static php_stream* phar_wrapper_open_url(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); static php_stream* phar_wrapper_open_url(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC); static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from, const char *url_to, int options, php_stream_context *context TSRMLS_DC);
static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC); static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC);
static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC); static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC);


/* file/stream handlers */ /* file/stream handlers */
static size_t phar_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC); static size_t phar_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC);
Expand Down
4 changes: 2 additions & 2 deletions ext/phar/util.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ char *phar_find_in_include_path(char *filename, int filename_len, phar_archive_d
* appended, truncated, or read. For read, if the entry is marked unmodified, it is * appended, truncated, or read. For read, if the entry is marked unmodified, it is
* assumed that the file pointer, if present, is opened for reading * assumed that the file pointer, if present, is opened for reading
*/ */
int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, char *mode, char allow_dir, char **error, int security TSRMLS_DC) /* {{{ */ int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC) /* {{{ */
{ {
phar_archive_data *phar; phar_archive_data *phar;
phar_entry_info *entry; phar_entry_info *entry;
Expand Down Expand Up @@ -733,7 +733,7 @@ int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char
/** /**
* Create a new dummy file slot within a writeable phar for a newly created file * Create a new dummy file slot within a writeable phar for a newly created file
*/ */
phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, char *mode, char allow_dir, char **error, int security TSRMLS_DC) /* {{{ */ phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC) /* {{{ */
{ {
phar_archive_data *phar; phar_archive_data *phar;
phar_entry_info *entry, etemp; phar_entry_info *entry, etemp;
Expand Down
10 changes: 5 additions & 5 deletions ext/standard/file.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ PHPAPI PHP_FUNCTION(fseek)
*/ */


/* DEPRECATED APIs: Use php_stream_mkdir() instead */ /* DEPRECATED APIs: Use php_stream_mkdir() instead */
PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC) PHPAPI int php_mkdir_ex(const char *dir, long mode, int options TSRMLS_DC)
{ {
int ret; int ret;


Expand All @@ -1299,7 +1299,7 @@ PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC)
return ret; return ret;
} }


PHPAPI int php_mkdir(char *dir, long mode TSRMLS_DC) PHPAPI int php_mkdir(const char *dir, long mode TSRMLS_DC)
{ {
return php_mkdir_ex(dir, mode, REPORT_ERRORS TSRMLS_CC); return php_mkdir_ex(dir, mode, REPORT_ERRORS TSRMLS_CC);
} }
Expand Down Expand Up @@ -1623,23 +1623,23 @@ PHP_FUNCTION(copy)


/* {{{ php_copy_file /* {{{ php_copy_file
*/ */
PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC) PHPAPI int php_copy_file(const char *src, const char *dest TSRMLS_DC)
{ {
return php_copy_file_ctx(src, dest, 0, NULL TSRMLS_CC); return php_copy_file_ctx(src, dest, 0, NULL TSRMLS_CC);
} }
/* }}} */ /* }}} */


/* {{{ php_copy_file_ex /* {{{ php_copy_file_ex
*/ */
PHPAPI int php_copy_file_ex(char *src, char *dest, int src_flg TSRMLS_DC) PHPAPI int php_copy_file_ex(const char *src, const char *dest, int src_flg TSRMLS_DC)
{ {
return php_copy_file_ctx(src, dest, 0, NULL TSRMLS_CC); return php_copy_file_ctx(src, dest, 0, NULL TSRMLS_CC);
} }
/* }}} */ /* }}} */


/* {{{ php_copy_file_ctx /* {{{ php_copy_file_ctx
*/ */
PHPAPI int php_copy_file_ctx(char *src, char *dest, int src_flg, php_stream_context *ctx TSRMLS_DC) PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_flg, php_stream_context *ctx TSRMLS_DC)
{ {
php_stream *srcstream = NULL, *deststream = NULL; php_stream *srcstream = NULL, *deststream = NULL;
int ret = FAILURE; int ret = FAILURE;
Expand Down
12 changes: 6 additions & 6 deletions ext/standard/file.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ PHP_MINIT_FUNCTION(user_streams);


PHPAPI int php_le_stream_context(TSRMLS_D); PHPAPI int php_le_stream_context(TSRMLS_D);
PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC); PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC);
PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC); PHPAPI int php_copy_file(const char *src, const char *dest TSRMLS_DC);
PHPAPI int php_copy_file_ex(char *src, char *dest, int src_chk TSRMLS_DC); PHPAPI int php_copy_file_ex(const char *src, const char *dest, int src_chk TSRMLS_DC);
PHPAPI int php_copy_file_ctx(char *src, char *dest, int src_chk, php_stream_context *ctx TSRMLS_DC); PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_chk, php_stream_context *ctx TSRMLS_DC);
PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC); PHPAPI int php_mkdir_ex(const char *dir, long mode, int options TSRMLS_DC);
PHPAPI int php_mkdir(char *dir, long mode TSRMLS_DC); PHPAPI int php_mkdir(const char *dir, long mode TSRMLS_DC);
PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char escape_char, size_t buf_len, char *buf, zval *return_value TSRMLS_DC); PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char escape_char, size_t buf_len, char *buf, zval *return_value TSRMLS_DC);
PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC); PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC);


Expand Down Expand Up @@ -121,7 +121,7 @@ typedef struct {
long default_socket_timeout; long default_socket_timeout;
char *user_agent; /* for the http wrapper */ char *user_agent; /* for the http wrapper */
char *from_address; /* for the ftp and http wrappers */ char *from_address; /* for the ftp and http wrappers */
char *user_stream_current_filename; /* for simple recursion protection */ const char *user_stream_current_filename; /* for simple recursion protection */
php_stream_context *default_context; php_stream_context *default_context;
HashTable *stream_wrappers; /* per-request copy of url_stream_wrappers_hash */ HashTable *stream_wrappers; /* per-request copy of url_stream_wrappers_hash */
HashTable *stream_filters; /* per-request copy of stream_filters_hash */ HashTable *stream_filters; /* per-request copy of stream_filters_hash */
Expand Down
Loading

0 comments on commit 92d27cc

Please sign in to comment.