summaryrefslogtreecommitdiff
path: root/ext/standard/filestat.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/filestat.c')
-rw-r--r--ext/standard/filestat.c80
1 files changed, 37 insertions, 43 deletions
diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c
index adbed69931..b0d6a9813f 100644
--- a/ext/standard/filestat.c
+++ b/ext/standard/filestat.c
@@ -186,9 +186,9 @@ PHP_FUNCTION(disk_total_space)
char *path;
size_t path_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &path, &path_len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_PATH(path, path_len)
+ ZEND_PARSE_PARAMETERS_END();
if (php_check_open_basedir(path)) {
RETURN_FALSE;
@@ -261,12 +261,8 @@ static int php_disk_free_space(char *path, double *space) /* {{{ */
php_error_docref(NULL, E_WARNING, "%s", strerror(errno));
return FAILURE;
}
-#ifdef NETWARE
- bytesfree = (((double)buf.f_bsize) * ((double)buf.f_bfree));
-#else
bytesfree = (((double)buf.f_bsize) * ((double)buf.f_bavail));
#endif
-#endif
*space = bytesfree;
return SUCCESS;
@@ -283,9 +279,9 @@ PHP_FUNCTION(disk_free_space)
char *path;
size_t path_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &path, &path_len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_PATH(path, path_len)
+ ZEND_PARSE_PARAMETERS_END();
if (php_check_open_basedir(path)) {
RETURN_FALSE;
@@ -298,7 +294,7 @@ PHP_FUNCTION(disk_free_space)
}
/* }}} */
-#if !defined(WINDOWS) && !defined(NETWARE)
+#ifndef PHP_WIN32
PHPAPI int php_get_gid_by_name(const char *name, gid_t *gid)
{
#if defined(ZTS) && defined(HAVE_GETGRNAM_R) && defined(_SC_GETGR_R_SIZE_MAX)
@@ -341,9 +337,10 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
#endif
php_stream_wrapper *wrapper;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "pz/", &filename, &filename_len, &group) == FAILURE) {
- RETURN_FALSE;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_PATH(filename, filename_len)
+ Z_PARAM_ZVAL(group)
+ ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
wrapper = php_stream_locate_url_wrapper(filename, NULL, 0);
if(wrapper != &php_plain_files_wrapper || strncasecmp("file://", filename, 7) == 0) {
@@ -411,7 +408,6 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
}
/* }}} */
-#ifndef NETWARE
/* {{{ proto bool chgrp(string filename, mixed group)
Change file group */
PHP_FUNCTION(chgrp)
@@ -433,9 +429,8 @@ PHP_FUNCTION(lchgrp)
}
#endif
/* }}} */
-#endif /* !NETWARE */
-#if !defined(WINDOWS) && !defined(NETWARE)
+#ifndef PHP_WIN32
PHPAPI uid_t php_get_uid_by_name(const char *name, uid_t *uid)
{
#if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWNAM_R)
@@ -478,9 +473,10 @@ static void php_do_chown(INTERNAL_FUNCTION_PARAMETERS, int do_lchown) /* {{{ */
#endif
php_stream_wrapper *wrapper;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "pz/", &filename, &filename_len, &user) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_PATH(filename, filename_len)
+ Z_PARAM_ZVAL(user)
+ ZEND_PARSE_PARAMETERS_END();
wrapper = php_stream_locate_url_wrapper(filename, NULL, 0);
if(wrapper != &php_plain_files_wrapper || strncasecmp("file://", filename, 7) == 0) {
@@ -550,7 +546,6 @@ static void php_do_chown(INTERNAL_FUNCTION_PARAMETERS, int do_lchown) /* {{{ */
/* }}} */
-#ifndef NETWARE
/* {{{ proto bool chown (string filename, mixed user)
Change file owner */
PHP_FUNCTION(chown)
@@ -573,7 +568,6 @@ PHP_FUNCTION(lchown)
}
#endif
/* }}} */
-#endif /* !NETWARE */
/* {{{ proto bool chmod(string filename, int mode)
Change file mode */
@@ -586,9 +580,10 @@ PHP_FUNCTION(chmod)
mode_t imode;
php_stream_wrapper *wrapper;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "pl", &filename, &filename_len, &mode) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_PATH(filename, filename_len)
+ Z_PARAM_LONG(mode)
+ ZEND_PARSE_PARAMETERS_END();
wrapper = php_stream_locate_url_wrapper(filename, NULL, 0);
if(wrapper != &php_plain_files_wrapper || strncasecmp("file://", filename, 7) == 0) {
@@ -634,9 +629,12 @@ PHP_FUNCTION(touch)
struct utimbuf *newtime = &newtimebuf;
php_stream_wrapper *wrapper;
- if (zend_parse_parameters(argc, "p|ll", &filename, &filename_len, &filetime, &fileatime) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(1, 3)
+ Z_PARAM_PATH(filename, filename_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(filetime)
+ Z_PARAM_LONG(fileatime)
+ ZEND_PARSE_PARAMETERS_END();
if (!filename_len) {
RETURN_FALSE;
@@ -713,7 +711,7 @@ PHP_FUNCTION(touch)
/* {{{ php_clear_stat_cache()
*/
-PHPAPI void php_clear_stat_cache(zend_bool clear_realpath_cache, const char *filename, int filename_len)
+PHPAPI void php_clear_stat_cache(zend_bool clear_realpath_cache, const char *filename, size_t filename_len)
{
/* always clear CurrentStatFile and CurrentLStatFile even if filename is not NULL
* as it may contain outdated data (e.g. "nlink" for a directory when deleting a file
@@ -744,11 +742,13 @@ PHP_FUNCTION(clearstatcache)
char *filename = NULL;
size_t filename_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|bp", &clear_realpath_cache, &filename, &filename_len) == FAILURE) {
- return;
- }
+ ZEND_PARSE_PARAMETERS_START(0, 2)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(clear_realpath_cache)
+ Z_PARAM_PATH(filename, filename_len)
+ ZEND_PARSE_PARAMETERS_END();
- php_clear_stat_cache(clear_realpath_cache, filename, (int)filename_len);
+ php_clear_stat_cache(clear_realpath_cache, filename, filename_len);
}
/* }}} */
@@ -759,7 +759,7 @@ PHP_FUNCTION(clearstatcache)
/* {{{ php_stat
*/
-PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int type, zval *return_value)
+PHPAPI void php_stat(const char *filename, size_t filename_length, int type, zval *return_value)
{
zval stat_dev, stat_ino, stat_mode, stat_nlink, stat_uid, stat_gid, stat_rdev,
stat_size, stat_atime, stat_mtime, stat_ctime, stat_blksize, stat_blocks;
@@ -826,8 +826,6 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ
stat_sb = &ssb.sb;
-
-#ifndef NETWARE
if (type >= FS_IS_W && type <= FS_IS_X) {
if(ssb.sb.st_uid==getuid()) {
rmask=S_IRUSR;
@@ -857,12 +855,9 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ
}
}
}
-#endif
-#ifndef NETWARE
if (IS_ABLE_CHECK(type) && getuid() == 0) {
- /* root has special perms on plain_wrapper
- But we don't know about root under Netware */
+ /* root has special perms on plain_wrapper */
if (wrapper == &php_plain_files_wrapper) {
if (type == FS_IS_X) {
xmask = S_IXROOT;
@@ -871,7 +866,6 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ
}
}
}
-#endif
switch (type) {
case FS_PERMS:
@@ -1002,7 +996,7 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ
/* another quickie macro to make defining similar functions easier */
/* {{{ FileFunction(name, funcnum) */
#define FileFunction(name, funcnum) \
-void name(INTERNAL_FUNCTION_PARAMETERS) { \
+ZEND_NAMED_FUNCTION(name) { \
char *filename; \
size_t filename_len; \
\
@@ -1010,7 +1004,7 @@ void name(INTERNAL_FUNCTION_PARAMETERS) { \
Z_PARAM_PATH(filename, filename_len) \
ZEND_PARSE_PARAMETERS_END(); \
\
- php_stat(filename, (php_stat_len) filename_len, funcnum, return_value); \
+ php_stat(filename, filename_len, funcnum, return_value); \
}
/* }}} */