Skip to content

Commit 92d27cc

Browse files
committed
Constify streams API and a few other calls down the rabbit hole.
(`char *` to `const char *` for parameters and few return values) In a few places int len moved to size_t len.
1 parent 5e1ac55 commit 92d27cc

38 files changed

+202
-189
lines changed

Diff for: README.STREAMS

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Opening Streams
4646
===============
4747
In most cases, you should use this API:
4848

49-
PHPAPI php_stream *php_stream_open_wrapper(char *path, char *mode,
49+
PHPAPI php_stream *php_stream_open_wrapper(const char *path, const char *mode,
5050
int options, char **opened_path TSRMLS_DC);
5151

5252
Where:

Diff for: TSRM/tsrm_virtual_cwd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,7 @@ CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC) /* {{{ */
16731673
}
16741674
/* }}} */
16751675

1676-
CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC) /* {{{ */
1676+
CWD_API int virtual_rename(const char *oldname, const char *newname TSRMLS_DC) /* {{{ */
16771677
{
16781678
cwd_state old_state;
16791679
cwd_state new_state;

Diff for: TSRM/tsrm_virtual_cwd.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC);
161161
CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC);
162162
CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...);
163163
CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC);
164-
CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC);
164+
CWD_API int virtual_rename(const char *oldname, const char *newname TSRMLS_DC);
165165
CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC);
166166
CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC);
167167
CWD_API int virtual_unlink(const char *path TSRMLS_DC);

Diff for: Zend/zend_operators.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,11 @@ static inline zend_uchar is_numeric_string(const char *str, int length, long *lv
269269
return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL);
270270
}
271271

272-
static inline char *
273-
zend_memnstr(char *haystack, char *needle, int needle_len, char *end)
272+
static inline const char *
273+
zend_memnstr(const char *haystack, const char *needle, int needle_len, char *end)
274274
{
275-
char *p = haystack;
276-
char ne = needle[needle_len-1];
275+
const char *p = haystack;
276+
const char ne = needle[needle_len-1];
277277

278278
if (needle_len == 1) {
279279
return (char *)memchr(p, *needle, (end-p));

Diff for: ext/bz2/bz2.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ php_stream_ops php_stream_bz2io_ops = {
192192

193193
/* {{{ Bzip2 stream openers */
194194
PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz,
195-
char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC)
195+
const char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC)
196196
{
197197
struct php_bz2_stream_data_t *self;
198198

@@ -205,8 +205,8 @@ PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz,
205205
}
206206

207207
PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
208-
char *path,
209-
char *mode,
208+
const char *path,
209+
const char *mode,
210210
int options,
211211
char **opened_path,
212212
php_stream_context *context STREAMS_DC TSRMLS_DC)

Diff for: ext/bz2/php_bz2.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ extern zend_module_entry bz2_module_entry;
4747
# define PHP_BZ2_API
4848
#endif
4949

50-
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);
51-
PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz, char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC);
50+
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);
51+
PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz, const char *mode, php_stream *innerstream STREAMS_DC TSRMLS_DC);
5252

5353
#define php_stream_bz2open_from_BZFILE(bz, mode, innerstream) _php_stream_bz2open_from_BZFILE((bz), (mode), (innerstream) STREAMS_CC TSRMLS_CC)
5454
#define php_stream_bz2open(wrapper, path, mode, options, opened_path) _php_stream_bz2open((wrapper), (path), (mode), (options), (opened_path), NULL STREAMS_CC TSRMLS_CC)

Diff for: ext/fileinfo/fileinfo.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
497497
case FILEINFO_MODE_FILE:
498498
{
499499
/* determine if the file is a local file or remote URL */
500-
char *tmp2;
500+
const char *tmp2;
501501
php_stream_wrapper *wrap;
502502
php_stream_statbuf ssb;
503503

Diff for: ext/libxml/libxml.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char
292292
php_stream_statbuf ssbuf;
293293
php_stream_context *context = NULL;
294294
php_stream_wrapper *wrapper = NULL;
295-
char *resolved_path, *path_to_open = NULL;
295+
char *resolved_path;
296+
const char *path_to_open = NULL;
296297
void *ret_val = NULL;
297298
int isescaped=0;
298299
xmlURI *uri;

Diff for: ext/openssl/xp_ssl.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ static inline int php_openssl_setup_crypto(php_stream *stream,
309309
php_stream_xport_crypto_param *cparam
310310
TSRMLS_DC)
311311
{
312-
SSL_METHOD *method;
312+
const SSL_METHOD *method;
313313
long ssl_ctx_options = SSL_OP_ALL;
314314

315315
if (sslsock->ssl_handle) {
@@ -853,7 +853,7 @@ php_stream_ops php_openssl_socket_ops = {
853853
php_openssl_sockop_set_option,
854854
};
855855

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

858858
php_url *url;
859859

@@ -900,8 +900,8 @@ static char * get_sni(php_stream_context *ctx, char *resourcename, long resource
900900
return NULL;
901901
}
902902

903-
php_stream *php_openssl_ssl_socket_factory(const char *proto, long protolen,
904-
char *resourcename, long resourcenamelen,
903+
php_stream *php_openssl_ssl_socket_factory(const char *proto, size_t protolen,
904+
const char *resourcename, size_t resourcenamelen,
905905
const char *persistent_id, int options, int flags,
906906
struct timeval *timeout,
907907
php_stream_context *context STREAMS_DC TSRMLS_DC)

Diff for: ext/phar/dirstream.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
319319
/**
320320
* Open a directory handle within a phar archive
321321
*/
322-
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) /* {{{ */
322+
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) /* {{{ */
323323
{
324324
php_url *resource = NULL;
325325
php_stream *ret;
@@ -432,7 +432,7 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char
432432
/**
433433
* Make a new directory within a phar archive
434434
*/
435-
int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
435+
int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
436436
{
437437
phar_entry_info entry, *e;
438438
phar_archive_data *phar = NULL;
@@ -564,7 +564,7 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, in
564564
/**
565565
* Remove a directory within a phar archive
566566
*/
567-
int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
567+
int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
568568
{
569569
phar_entry_info *entry;
570570
phar_archive_data *phar = NULL;

Diff for: ext/phar/dirstream.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
/* $Id$ */
2121

2222
BEGIN_EXTERN_C()
23-
int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC);
24-
int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC);
23+
int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC);
24+
int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC);
2525

2626
#ifdef PHAR_DIRSTREAM
27-
php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC);
27+
php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options TSRMLS_DC);
2828

2929
/* directory handlers */
3030
static size_t phar_dir_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC);
@@ -33,7 +33,7 @@ static int phar_dir_close(php_stream *stream, int close_handle TSRMLS_DC);
3333
static int phar_dir_flush(php_stream *stream TSRMLS_DC);
3434
static int phar_dir_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
3535
#else
36-
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);
36+
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);
3737
#endif
3838
END_EXTERN_C()
3939

Diff for: ext/phar/phar.c

+8-10
Original file line numberDiff line numberDiff line change
@@ -2251,13 +2251,13 @@ char *phar_fix_filepath(char *path, int *new_len, int use_cwd TSRMLS_DC) /* {{{
22512251
*
22522252
* This is used by phar_parse_url()
22532253
*/
2254-
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) /* {{{ */
2254+
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) /* {{{ */
22552255
{
22562256
const char *ext_str;
22572257
#ifdef PHP_WIN32
22582258
char *save;
22592259
#endif
2260-
int ext_len, free_filename = 0;
2260+
int ext_len;
22612261

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

22672267
ext_len = 0;
22682268
#ifdef PHP_WIN32
2269-
free_filename = 1;
22702269
save = filename;
22712270
filename = estrndup(filename, filename_len);
22722271
phar_unixify_path_separators(filename, filename_len);
@@ -2282,10 +2281,9 @@ int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_le
22822281
#endif
22832282
}
22842283

2285-
if (free_filename) {
2286-
efree(filename);
2287-
}
2288-
2284+
#ifdef PHP_WIN32
2285+
efree(filename);
2286+
#endif
22892287
return FAILURE;
22902288
}
22912289

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

2311-
if (free_filename) {
2312-
efree(filename);
2313-
}
2309+
#ifdef PHP_WIN32
2310+
efree(filename);
2311+
#endif
23142312

23152313
return SUCCESS;
23162314
}

Diff for: ext/phar/phar_internal.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -690,11 +690,11 @@ int phar_entry_delref(phar_entry_data *idata TSRMLS_DC);
690690

691691
phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int path_len, char **error, int security TSRMLS_DC);
692692
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);
693-
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);
694-
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);
693+
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);
694+
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);
695695
int phar_flush(phar_archive_data *archive, char *user_stub, long len, int convert, char **error TSRMLS_DC);
696696
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);
697-
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);
697+
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);
698698

699699
typedef enum {
700700
pcr_use_query,

Diff for: ext/phar/stream.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ php_stream_wrapper php_stream_phar_wrapper = {
5656
/**
5757
* Open a phar file for streams API
5858
*/
59-
php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC) /* {{{ */
59+
php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options TSRMLS_DC) /* {{{ */
6060
{
6161
php_url *resource;
6262
char *arch = NULL, *entry = NULL, *error;
@@ -155,7 +155,7 @@ php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode,
155155
/**
156156
* used for fopen('phar://...') and company
157157
*/
158-
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) /* {{{ */
158+
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) /* {{{ */
159159
{
160160
phar_archive_data *phar;
161161
phar_entry_data *idata;
@@ -563,7 +563,7 @@ static int phar_stream_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D
563563
/**
564564
* Stream wrapper stat implementation of stat()
565565
*/
566-
static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags,
566+
static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int flags,
567567
php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC) /* {{{ */
568568
{
569569
php_url *resource = NULL;
@@ -686,7 +686,7 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags,
686686
/**
687687
* Unlink a file within a phar archive
688688
*/
689-
static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
689+
static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
690690
{
691691
php_url *resource;
692692
char *internal_file, *error;
@@ -762,7 +762,7 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int optio
762762
}
763763
/* }}} */
764764

765-
static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
765+
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) /* {{{ */
766766
{
767767
php_url *resource_from, *resource_to;
768768
char *error;

Diff for: ext/phar/stream.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121

2222
BEGIN_EXTERN_C()
2323

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

27-
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);
28-
static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC);
29-
static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC);
30-
static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC);
27+
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);
28+
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);
29+
static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC);
30+
static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC);
3131

3232
/* file/stream handlers */
3333
static size_t phar_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC);

Diff for: ext/phar/util.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ char *phar_find_in_include_path(char *filename, int filename_len, phar_archive_d
572572
* appended, truncated, or read. For read, if the entry is marked unmodified, it is
573573
* assumed that the file pointer, if present, is opened for reading
574574
*/
575-
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) /* {{{ */
575+
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) /* {{{ */
576576
{
577577
phar_archive_data *phar;
578578
phar_entry_info *entry;
@@ -733,7 +733,7 @@ int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char
733733
/**
734734
* Create a new dummy file slot within a writeable phar for a newly created file
735735
*/
736-
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) /* {{{ */
736+
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) /* {{{ */
737737
{
738738
phar_archive_data *phar;
739739
phar_entry_info *entry, etemp;

Diff for: ext/standard/file.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ PHPAPI PHP_FUNCTION(fseek)
12841284
*/
12851285

12861286
/* DEPRECATED APIs: Use php_stream_mkdir() instead */
1287-
PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC)
1287+
PHPAPI int php_mkdir_ex(const char *dir, long mode, int options TSRMLS_DC)
12881288
{
12891289
int ret;
12901290

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

1302-
PHPAPI int php_mkdir(char *dir, long mode TSRMLS_DC)
1302+
PHPAPI int php_mkdir(const char *dir, long mode TSRMLS_DC)
13031303
{
13041304
return php_mkdir_ex(dir, mode, REPORT_ERRORS TSRMLS_CC);
13051305
}
@@ -1623,23 +1623,23 @@ PHP_FUNCTION(copy)
16231623

16241624
/* {{{ php_copy_file
16251625
*/
1626-
PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC)
1626+
PHPAPI int php_copy_file(const char *src, const char *dest TSRMLS_DC)
16271627
{
16281628
return php_copy_file_ctx(src, dest, 0, NULL TSRMLS_CC);
16291629
}
16301630
/* }}} */
16311631

16321632
/* {{{ php_copy_file_ex
16331633
*/
1634-
PHPAPI int php_copy_file_ex(char *src, char *dest, int src_flg TSRMLS_DC)
1634+
PHPAPI int php_copy_file_ex(const char *src, const char *dest, int src_flg TSRMLS_DC)
16351635
{
16361636
return php_copy_file_ctx(src, dest, 0, NULL TSRMLS_CC);
16371637
}
16381638
/* }}} */
16391639

16401640
/* {{{ php_copy_file_ctx
16411641
*/
1642-
PHPAPI int php_copy_file_ctx(char *src, char *dest, int src_flg, php_stream_context *ctx TSRMLS_DC)
1642+
PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_flg, php_stream_context *ctx TSRMLS_DC)
16431643
{
16441644
php_stream *srcstream = NULL, *deststream = NULL;
16451645
int ret = FAILURE;

Diff for: ext/standard/file.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ PHP_MINIT_FUNCTION(user_streams);
7474

7575
PHPAPI int php_le_stream_context(TSRMLS_D);
7676
PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC);
77-
PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC);
78-
PHPAPI int php_copy_file_ex(char *src, char *dest, int src_chk TSRMLS_DC);
79-
PHPAPI int php_copy_file_ctx(char *src, char *dest, int src_chk, php_stream_context *ctx TSRMLS_DC);
80-
PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC);
81-
PHPAPI int php_mkdir(char *dir, long mode TSRMLS_DC);
77+
PHPAPI int php_copy_file(const char *src, const char *dest TSRMLS_DC);
78+
PHPAPI int php_copy_file_ex(const char *src, const char *dest, int src_chk TSRMLS_DC);
79+
PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_chk, php_stream_context *ctx TSRMLS_DC);
80+
PHPAPI int php_mkdir_ex(const char *dir, long mode, int options TSRMLS_DC);
81+
PHPAPI int php_mkdir(const char *dir, long mode TSRMLS_DC);
8282
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);
8383
PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC);
8484

@@ -121,7 +121,7 @@ typedef struct {
121121
long default_socket_timeout;
122122
char *user_agent; /* for the http wrapper */
123123
char *from_address; /* for the ftp and http wrappers */
124-
char *user_stream_current_filename; /* for simple recursion protection */
124+
const char *user_stream_current_filename; /* for simple recursion protection */
125125
php_stream_context *default_context;
126126
HashTable *stream_wrappers; /* per-request copy of url_stream_wrappers_hash */
127127
HashTable *stream_filters; /* per-request copy of stream_filters_hash */

0 commit comments

Comments
 (0)