diff options
Diffstat (limited to 'ext/posix/posix.c')
-rw-r--r-- | ext/posix/posix.c | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/ext/posix/posix.c b/ext/posix/posix.c index 32db6705f5..ca7d34c645 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -1,8 +1,8 @@ /* +----------------------------------------------------------------------+ - | PHP Version 5 | + | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 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 | @@ -380,7 +380,7 @@ ZEND_GET_MODULE(posix) RETURN_LONG(func_name()); #define PHP_POSIX_SINGLE_ARG_FUNC(func_name) \ - long val; \ + zend_long val; \ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) RETURN_FALSE; \ if (func_name(val) < 0) { \ POSIX_G(last_error) = errno; \ @@ -393,7 +393,7 @@ ZEND_GET_MODULE(posix) PHP_FUNCTION(posix_kill) { - long pid, sig; + zend_long pid, sig; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &pid, &sig) == FAILURE) { RETURN_FALSE; @@ -531,7 +531,7 @@ PHP_FUNCTION(posix_getlogin) RETURN_FALSE; } - RETURN_STRING(p, 1); + RETURN_STRING(p); } #endif /* }}} */ @@ -558,7 +558,7 @@ PHP_FUNCTION(posix_setsid) Set process group id for job control (POSIX.1, 4.3.3) */ PHP_FUNCTION(posix_setpgid) { - long pid, pgid; + zend_long pid, pgid; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &pid, &pgid) == FAILURE) { RETURN_FALSE; @@ -578,7 +578,7 @@ PHP_FUNCTION(posix_setpgid) #ifdef HAVE_GETPGID PHP_FUNCTION(posix_getpgid) { - long val; + zend_long val; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) { RETURN_FALSE; } @@ -597,7 +597,7 @@ PHP_FUNCTION(posix_getpgid) #ifdef HAVE_GETSID PHP_FUNCTION(posix_getsid) { - long val; + zend_long val; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &val) == FAILURE) { RETURN_FALSE; } @@ -626,14 +626,14 @@ PHP_FUNCTION(posix_uname) array_init(return_value); - add_assoc_string(return_value, "sysname", u.sysname, 1); - add_assoc_string(return_value, "nodename", u.nodename, 1); - add_assoc_string(return_value, "release", u.release, 1); - add_assoc_string(return_value, "version", u.version, 1); - add_assoc_string(return_value, "machine", u.machine, 1); + add_assoc_string(return_value, "sysname", u.sysname); + add_assoc_string(return_value, "nodename", u.nodename); + add_assoc_string(return_value, "release", u.release); + add_assoc_string(return_value, "version", u.version); + add_assoc_string(return_value, "machine", u.machine); #if defined(_GNU_SOURCE) && !defined(DARWIN) && defined(HAVE_UTSNAME_DOMAINNAME) - add_assoc_string(return_value, "domainname", u.domainname, 1); + add_assoc_string(return_value, "domainname", u.domainname); #endif } /* }}} */ @@ -687,7 +687,7 @@ PHP_FUNCTION(posix_ctermid) RETURN_FALSE; } - RETURN_STRING(buffer, 1); + RETURN_STRING(buffer); } #endif /* }}} */ @@ -697,7 +697,7 @@ static int php_posix_stream_get_fd(zval *zfp, int *fd TSRMLS_DC) /* {{{ */ { php_stream *stream; - php_stream_from_zval_no_verify(stream, &zfp); + php_stream_from_zval_no_verify(stream, zfp); if (stream == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "expects argument 1 to be a valid stream resource"); @@ -720,26 +720,26 @@ static int php_posix_stream_get_fd(zval *zfp, int *fd TSRMLS_DC) /* {{{ */ Determine terminal device name (POSIX.1, 4.7.2) */ PHP_FUNCTION(posix_ttyname) { - zval **z_fd; + zval *z_fd; char *p; int fd; #if defined(ZTS) && defined(HAVE_TTYNAME_R) && defined(_SC_TTY_NAME_MAX) - long buflen; + zend_long buflen; #endif - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &z_fd) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &z_fd) == FAILURE) { RETURN_FALSE; } - switch (Z_TYPE_PP(z_fd)) { + switch (Z_TYPE_P(z_fd)) { case IS_RESOURCE: - if (!php_posix_stream_get_fd(*z_fd, &fd TSRMLS_CC)) { + if (!php_posix_stream_get_fd(z_fd, &fd TSRMLS_CC)) { RETURN_FALSE; } break; default: convert_to_long_ex(z_fd); - fd = Z_LVAL_PP(z_fd); + fd = Z_LVAL_P(z_fd); } #if defined(ZTS) && defined(HAVE_TTYNAME_R) && defined(_SC_TTY_NAME_MAX) buflen = sysconf(_SC_TTY_NAME_MAX); @@ -753,14 +753,15 @@ PHP_FUNCTION(posix_ttyname) efree(p); RETURN_FALSE; } - RETURN_STRING(p, 0); + RETURN_STRING(p); + efree(p); #else if (NULL == (p = ttyname(fd))) { POSIX_G(last_error) = errno; RETURN_FALSE; } #endif - RETURN_STRING(p, 1); + RETURN_STRING(p); } /* }}} */ @@ -768,22 +769,22 @@ PHP_FUNCTION(posix_ttyname) Determine if filedesc is a tty (POSIX.1, 4.7.1) */ PHP_FUNCTION(posix_isatty) { - zval **z_fd; + zval *z_fd; int fd; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &z_fd) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &z_fd) == FAILURE) { RETURN_FALSE; } - switch (Z_TYPE_PP(z_fd)) { + switch (Z_TYPE_P(z_fd)) { case IS_RESOURCE: - if (!php_posix_stream_get_fd(*z_fd, &fd TSRMLS_CC)) { + if (!php_posix_stream_get_fd(z_fd, &fd TSRMLS_CC)) { RETURN_FALSE; } break; default: convert_to_long_ex(z_fd); - fd = Z_LVAL_PP(z_fd); + fd = Z_LVAL_P(z_fd); } if (isatty(fd)) { @@ -818,7 +819,7 @@ PHP_FUNCTION(posix_getcwd) RETURN_FALSE; } - RETURN_STRING(buffer, 1); + RETURN_STRING(buffer); } /* }}} */ @@ -834,8 +835,8 @@ PHP_FUNCTION(posix_getcwd) PHP_FUNCTION(posix_mkfifo) { char *path; - int path_len; - long mode; + size_t path_len; + zend_long mode; int result; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pl", &path, &path_len, &mode) == FAILURE) { @@ -863,9 +864,9 @@ PHP_FUNCTION(posix_mkfifo) PHP_FUNCTION(posix_mknod) { char *path; - int path_len; - long mode; - long major = 0, minor = 0; + size_t path_len; + zend_long mode; + zend_long major = 0, minor = 0; int result; dev_t php_dev; @@ -913,7 +914,7 @@ PHP_FUNCTION(posix_mknod) * array container and fills the array with the posix group member data. */ int php_posix_group_to_array(struct group *g, zval *array_group) /* {{{ */ { - zval *array_members; + zval array_members; int count; if (NULL == g) @@ -922,15 +923,14 @@ int php_posix_group_to_array(struct group *g, zval *array_group) /* {{{ */ if (array_group == NULL || Z_TYPE_P(array_group) != IS_ARRAY) return 0; - MAKE_STD_ZVAL(array_members); - array_init(array_members); + array_init(&array_members); - add_assoc_string(array_group, "name", g->gr_name, 1); - add_assoc_string(array_group, "passwd", g->gr_passwd, 1); + add_assoc_string(array_group, "name", g->gr_name); + add_assoc_string(array_group, "passwd", g->gr_passwd); for (count=0; g->gr_mem[count] != NULL; count++) { - add_next_index_string(array_members, g->gr_mem[count], 1); + add_next_index_string(&array_members, g->gr_mem[count]); } - zend_hash_update(Z_ARRVAL_P(array_group), "members", sizeof("members"), (void*)&array_members, sizeof(zval*), NULL); + zend_hash_str_update(Z_ARRVAL_P(array_group), "members", sizeof("members")-1, &array_members); add_assoc_long(array_group, "gid", g->gr_gid); return 1; } @@ -947,8 +947,8 @@ int php_posix_group_to_array(struct group *g, zval *array_group) /* {{{ */ Determine accessibility of a file (POSIX.1 5.6.3) */ PHP_FUNCTION(posix_access) { - long mode = 0; - int filename_len, ret; + zend_long mode = 0; + size_t filename_len, ret; char *filename, *path; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &filename, &filename_len, &mode) == FAILURE) { @@ -992,7 +992,7 @@ PHP_FUNCTION(posix_getgrnam) { char *name; struct group *g; - int name_len; + size_t name_len; #if defined(ZTS) && defined(HAVE_GETGRNAM_R) && defined(_SC_GETGR_R_SIZE_MAX) struct group gbuf; long buflen; @@ -1039,7 +1039,7 @@ PHP_FUNCTION(posix_getgrnam) Group database access (POSIX.1, 9.2.1) */ PHP_FUNCTION(posix_getgrgid) { - long gid; + zend_long gid; #if defined(ZTS) && defined(HAVE_GETGRGID_R) && defined(_SC_GETGR_R_SIZE_MAX) int ret; struct group _g; @@ -1094,13 +1094,13 @@ int php_posix_passwd_to_array(struct passwd *pw, zval *return_value) /* {{{ */ if (NULL == return_value || Z_TYPE_P(return_value) != IS_ARRAY) return 0; - add_assoc_string(return_value, "name", pw->pw_name, 1); - add_assoc_string(return_value, "passwd", pw->pw_passwd, 1); + add_assoc_string(return_value, "name", pw->pw_name); + add_assoc_string(return_value, "passwd", pw->pw_passwd); add_assoc_long (return_value, "uid", pw->pw_uid); add_assoc_long (return_value, "gid", pw->pw_gid); - add_assoc_string(return_value, "gecos", pw->pw_gecos, 1); - add_assoc_string(return_value, "dir", pw->pw_dir, 1); - add_assoc_string(return_value, "shell", pw->pw_shell, 1); + add_assoc_string(return_value, "gecos", pw->pw_gecos); + add_assoc_string(return_value, "dir", pw->pw_dir); + add_assoc_string(return_value, "shell", pw->pw_shell); return 1; } /* }}} */ @@ -1111,7 +1111,7 @@ PHP_FUNCTION(posix_getpwnam) { struct passwd *pw; char *name; - int name_len; + size_t name_len; #if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWNAM_R) struct passwd pwbuf; long buflen; @@ -1158,7 +1158,7 @@ PHP_FUNCTION(posix_getpwnam) User database access (POSIX.1, 9.2.2) */ PHP_FUNCTION(posix_getpwuid) { - long uid; + zend_long uid; #if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWUID_R) struct passwd _pw; struct passwd *retpwptr = NULL; @@ -1227,13 +1227,13 @@ static int posix_addlimit(int limit, char *name, zval *return_value TSRMLS_DC) { } if (rl.rlim_cur == RLIM_INFINITY) { - add_assoc_stringl(return_value, soft, UNLIMITED_STRING, sizeof(UNLIMITED_STRING)-1, 1); + add_assoc_stringl(return_value, soft, UNLIMITED_STRING, sizeof(UNLIMITED_STRING)-1); } else { add_assoc_long(return_value, soft, rl.rlim_cur); } if (rl.rlim_max == RLIM_INFINITY) { - add_assoc_stringl(return_value, hard, UNLIMITED_STRING, sizeof(UNLIMITED_STRING)-1, 1); + add_assoc_stringl(return_value, hard, UNLIMITED_STRING, sizeof(UNLIMITED_STRING)-1); } else { add_assoc_long(return_value, hard, rl.rlim_max); } @@ -1336,13 +1336,13 @@ PHP_FUNCTION(posix_get_last_error) Retrieve the system error message associated with the given errno. */ PHP_FUNCTION(posix_strerror) { - long error; + zend_long error; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &error) == FAILURE) { RETURN_FALSE; } - RETURN_STRING(strerror(error), 1); + RETURN_STRING(strerror(error)); } /* }}} */ @@ -1353,9 +1353,9 @@ PHP_FUNCTION(posix_strerror) Calculate the group access list for the user specified in name. */ PHP_FUNCTION(posix_initgroups) { - long basegid; + zend_long basegid; char *name; - int name_len; + size_t name_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &name, &name_len, &basegid) == FAILURE) { RETURN_FALSE; |