Convert a pathname and a project identifier to a System V IPC key */
PHP_FUNCTION(ftok)
{
- zval **pathname, **proj;
+ char *pathname, *proj;
+ int pathname_len, proj_len;
key_t k;
- if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &pathname, &proj) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, &pathname, &pathname_len, &proj, &proj_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(pathname);
- convert_to_string_ex(proj);
-
- if (Z_STRLEN_PP(pathname)==0){
+ if (pathname_len == 0){
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Pathname is invalid");
RETURN_LONG(-1);
}
- if (Z_STRLEN_PP(proj)!=1){
+ if (proj_len != 1){
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Project identifier is invalid");
RETURN_LONG(-1);
}
- if ((PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(pathname), NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(Z_STRVAL_PP(pathname) TSRMLS_CC)) {
+ if ((PG(safe_mode) && (!php_checkuid(pathname, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(pathname TSRMLS_CC)) {
RETURN_LONG(-1);
}
- k = ftok(Z_STRVAL_PP(pathname),Z_STRVAL_PP(proj)[0]);
+ k = ftok(pathname, proj[0]);
if (k == -1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "ftok() failed - %s", strerror(errno));
}
Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype */
PHP_FUNCTION(image_type_to_mime_type)
{
- zval **p_image_type;
- int arg_c = ZEND_NUM_ARGS();
+ long p_image_type;
- if ((arg_c!=1) || zend_get_parameters_ex(arg_c, &p_image_type) == FAILURE) {
- RETVAL_FALSE;
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &p_image_type) == FAILURE) {
+ return;
}
- convert_to_long_ex(p_image_type);
- ZVAL_STRING(return_value, (char*)php_image_type_to_mime_type(Z_LVAL_PP(p_image_type)), 1);
+
+ ZVAL_STRING(return_value, (char*)php_image_type_to_mime_type(p_image_type), 1);
}
/* }}} */
Get the size of an image as 4-element array */
PHP_FUNCTION(getimagesize)
{
- zval **arg1, **info = NULL;
- int itype = 0;
- char *temp;
+ zval **info = NULL;
+ char *arg1, *temp;
+ int arg1_len, itype = 0, argc = ZEND_NUM_ARGS();
struct gfxinfo *result = NULL;
php_stream * stream = NULL;
- switch(ZEND_NUM_ARGS()) {
-
- case 1:
- if (zend_get_parameters_ex(1, &arg1) == FAILURE) {
- RETVAL_FALSE;
- WRONG_PARAM_COUNT;
- }
- convert_to_string_ex(arg1);
- break;
-
- case 2:
- if (zend_get_parameters_ex(2, &arg1, &info) == FAILURE) {
- RETVAL_FALSE;
- WRONG_PARAM_COUNT;
- }
+ if (zend_parse_parameters(argc TSRMLS_CC, "s|Z", &arg1, &arg1_len, &info) == FAILURE) {
+ return;
+ }
+
+ if (argc == 2) {
zval_dtor(*info);
-
array_init(*info);
-
- convert_to_string_ex(arg1);
- break;
-
- default:
- RETVAL_FALSE;
- WRONG_PARAM_COUNT;
}
- stream = php_stream_open_wrapper(Z_STRVAL_PP(arg1), "rb", STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE, NULL);
+ stream = php_stream_open_wrapper(arg1, "rb", STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE, NULL);
if (!stream) {
RETURN_FALSE;
itype = php_getimagetype(stream, NULL TSRMLS_CC);
switch( itype) {
case IMAGE_FILETYPE_GIF:
- result = php_handle_gif (stream TSRMLS_CC);
+ result = php_handle_gif(stream TSRMLS_CC);
break;
case IMAGE_FILETYPE_JPEG:
if (info) {
PHP_FUNCTION(phpversion)
{
zval **arg;
+ const char *version;
int argc = ZEND_NUM_ARGS();
if (argc == 0) {
RETURN_STRING(PHP_VERSION, 1);
- } else if (argc == 1 && zend_get_parameters_ex(1, &arg) == SUCCESS) {
- const char *version;
+ } else {
+ if (zend_parse_parameters(argc TSRMLS_CC, "Z", &arg) == FAILURE) {
+ return;
+ }
+
convert_to_string_ex(arg);
version = zend_get_module_version(Z_STRVAL_PP(arg));
+
if (version == NULL) {
RETURN_FALSE;
}
RETURN_STRING(version, 1);
- } else {
- WRONG_PARAM_COUNT;
}
}
/* }}} */
Unpack binary string into named array elements according to format argument */
PHP_FUNCTION(unpack)
{
- zval **formatarg;
- zval **inputarg;
- char *format;
- char *input;
- int formatlen;
- int inputpos, inputlen;
- int i;
+ char *format, *input, *formatarg, *inputarg;
+ int formatlen, formatarg_len, inputarg_len;
+ int inputpos, inputlen, i;
- if (ZEND_NUM_ARGS() != 2 ||
- zend_get_parameters_ex(2, &formatarg, &inputarg) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &formatarg, &formatarg_len,
+ &inputarg, &inputarg_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(formatarg);
- convert_to_string_ex(inputarg);
-
- format = Z_STRVAL_PP(formatarg);
- formatlen = Z_STRLEN_PP(formatarg);
- input = Z_STRVAL_PP(inputarg);
- inputlen = Z_STRLEN_PP(inputarg);
+ format = formatarg;
+ formatlen = formatarg_len;
+ input = inputarg;
+ inputlen = inputarg_len;
inputpos = 0;
array_init(return_value);
Convert a quoted-printable string to an 8 bit string */
PHP_FUNCTION(quoted_printable_decode)
{
- zval **arg1;
- char *str_in, *str_out;
- int i = 0, j = 0, k;
+ char *arg1, *str_in, *str_out;
+ int arg1_len, i = 0, j = 0, k;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg1, &arg1_len) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string_ex(arg1);
- if (Z_STRLEN_PP(arg1) == 0) {
+ if (arg1_len == 0) {
/* shortcut */
RETURN_EMPTY_STRING();
}
- str_in = Z_STRVAL_PP(arg1);
- str_out = emalloc(Z_STRLEN_PP(arg1) + 1);
+ str_in = arg1;
+ str_out = emalloc(arg1_len + 1);
while (str_in[i]) {
switch (str_in[i]) {
case '=':
Retrieves header/meta data from streams/file pointers */
PHP_FUNCTION(stream_get_meta_data)
{
- zval **arg1;
+ zval *arg1;
php_stream *stream;
zval *newval;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) {
+ return;
}
- php_stream_from_zval(stream, arg1);
+ php_stream_from_zval(stream, &arg1);
array_init(return_value);
Set blocking/non-blocking mode on a socket or stream */
PHP_FUNCTION(stream_set_blocking)
{
- zval **arg1, **arg2;
+ zval *arg1;
int block;
+ long arg2;
php_stream *stream;
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &arg2) == FAILURE) {
+ return;
}
- php_stream_from_zval(stream, arg1);
+ php_stream_from_zval(stream, &arg1);
- convert_to_long_ex(arg2);
- block = Z_LVAL_PP(arg2);
+ block = arg2;
- if (php_stream_set_option(stream, PHP_STREAM_OPTION_BLOCKING, block == 0 ? 0 : 1, NULL) == -1)
+ if (php_stream_set_option(stream, PHP_STREAM_OPTION_BLOCKING, block == 0 ? 0 : 1, NULL) == -1) {
RETURN_FALSE;
+ }
+
RETURN_TRUE;
}
/* }}} */
-/* {{{ proto bool stream_set_timeout(resource stream, int seconds, int microseconds)
+/* {{{ proto bool stream_set_timeout(resource stream, int seconds [, int microseconds])
Set timeout on stream read to seconds + microseonds */
#if HAVE_SYS_TIME_H || defined(PHP_WIN32)
PHP_FUNCTION(stream_set_timeout)
{
- zval **socket, **seconds, **microseconds;
+ zval *socket;
+ long seconds, microseconds;
struct timeval t;
php_stream *stream;
+ int argc = ZEND_NUM_ARGS();
- if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > 3 ||
- zend_get_parameters_ex(ZEND_NUM_ARGS(), &socket, &seconds, µseconds)==FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(argc TSRMLS_CC, "rl|l", &socket, &seconds, µseconds) == FAILURE) {
+ return;
}
- php_stream_from_zval(stream, socket);
+ php_stream_from_zval(stream, &socket);
- convert_to_long_ex(seconds);
- t.tv_sec = Z_LVAL_PP(seconds);
+ t.tv_sec = seconds;
- if (ZEND_NUM_ARGS() == 3) {
- convert_to_long_ex(microseconds);
- t.tv_usec = Z_LVAL_PP(microseconds) % 1000000;
- t.tv_sec += Z_LVAL_PP(microseconds) / 1000000;
- }
- else
+ if (argc == 3) {
+ t.tv_usec = microseconds % 1000000;
+ t.tv_sec += microseconds / 1000000;
+ } else {
t.tv_usec = 0;
+ }
if (PHP_STREAM_OPTION_RETURN_OK == php_stream_set_option(stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &t)) {
RETURN_TRUE;
Set file write buffer */
PHP_FUNCTION(stream_set_write_buffer)
{
- zval **arg1, **arg2;
+ zval *arg1;
int ret;
+ long arg2;
size_t buff;
php_stream *stream;
switch (ZEND_NUM_ARGS()) {
case 2:
- if (zend_get_parameters_ex(2, &arg1, &arg2)==FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &arg2) == FAILURE) {
RETURN_FALSE;
}
break;
break;
}
- php_stream_from_zval(stream, arg1);
-
- convert_to_long_ex(arg2);
- buff = Z_LVAL_PP(arg2);
+ php_stream_from_zval(stream, &arg1);
+
+ buff = arg2;
/* if buff is 0 then set to non-buffered */
if (buff == 0) {
NULL
Warning: fopen(data://): failed to open stream: rfc2397: no comma in URL in %sstream_rfc2397_002.php on line %d
-bool(false)
+NULL
NULL
array(7) {
["wrapper_type"]=>
NULL
Warning: fopen(data://;base64): failed to open stream: rfc2397: no comma in URL in %sstream_rfc2397_002.php on line %d
-bool(false)
+NULL
NULL
Warning: fopen(data://foo,): failed to open stream: rfc2397: illegal media type in %sstream_rfc2397_002.php on line %d
-bool(false)
+NULL
NULL
Warning: fopen(data://foo=bar,): failed to open stream: rfc2397: illegal media type in %sstream_rfc2397_002.php on line %d
-bool(false)
+NULL
NULL
array(8) {
["wrapper_type"]=>
NULL
Warning: fopen(data://text/plain;foo,): failed to open stream: rfc2397: illegal parameter in %sstream_rfc2397_002.php on line %d
-bool(false)
+NULL
NULL
array(9) {
["wrapper_type"]=>
string(3) "bar"
Warning: fopen(data://text/plain;foo=bar;bla,): failed to open stream: rfc2397: illegal parameter in %sstream_rfc2397_002.php on line %d
-bool(false)
+NULL
NULL
array(9) {
["wrapper_type"]=>
string(3) "bar"
Warning: fopen(data://text/plain;foo=bar;bar=baz): failed to open stream: rfc2397: no comma in URL in %sstream_rfc2397_002.php on line %d
-bool(false)
+NULL
NULL
array(10) {
["wrapper_type"]=>
*** Testing error conditions ***
-Warning: Wrong parameter count for floatval() in %s on line %d
+Warning: floatval() expects exactly 1 parameter, 0 given in %s on line %d
NULL
-Warning: Wrong parameter count for doubleval() in %s on line %d
+Warning: doubleval() expects exactly 1 parameter, 0 given in %s on line %d
NULL
-Warning: Wrong parameter count for floatval() in %s on line %d
+Warning: floatval() expects exactly 1 parameter, 2 given in %s on line %d
NULL
-Warning: Wrong parameter count for doubleval() in %s on line %d
+Warning: doubleval() expects exactly 1 parameter, 2 given in %s on line %d
NULL
Done
*** Testing gettype(): error conditions ***
-Warning: Wrong parameter count for gettype() in %s on line %d
+Warning: gettype() expects exactly 1 parameter, 0 given in %s on line %d
NULL
-Warning: Wrong parameter count for gettype() in %s on line %d
+Warning: gettype() expects exactly 1 parameter, 2 given in %s on line %d
NULL
*** Testing settype(): error conditions ***
-Warning: Wrong parameter count for settype() in %s on line %d
+Warning: settype() expects exactly 2 parameters, 0 given in %s on line %d
NULL
-Warning: Wrong parameter count for settype() in %s on line %d
+Warning: settype() expects exactly 2 parameters, 3 given in %s on line %d
NULL
Warning: settype(): Invalid type in %s on line %d
*** Testing error conditions ***
-Warning: Wrong parameter count for strval() in %s on line %d
+Warning: strval() expects exactly 1 parameter, 0 given in %s on line %d
NULL
-Warning: Wrong parameter count for strval() in %s on line %d
+Warning: strval() expects exactly 1 parameter, 2 given in %s on line %d
NULL
Done
--EXPECTF--
*** Testing serialize()/unserialize() : error conditions ***
-Warning: Wrong parameter count for serialize() in %s on line 16
+Warning: serialize() expects exactly 1 parameter, 0 given in %s on line 16
NULL
Warning: unserialize() expects exactly 1 parameter, 0 given in %s on line 17
bool(false)
-Warning: Wrong parameter count for serialize() in %s on line 20
+Warning: serialize() expects exactly 1 parameter, 2 given in %s on line 20
NULL
Warning: unserialize() expects exactly 1 parameter, 2 given in %s on line 21
bool(false)
-Done
\ No newline at end of file
+Done
-- Testing stream_get_meta_data() function with Zero arguments --
-Warning: Wrong parameter count for stream_get_meta_data() in %s on line %i
+Warning: stream_get_meta_data() expects exactly 1 parameter, 0 given in %s on line %i
NULL
-- Testing stream_get_meta_data() function with more than expected no. of arguments --
-Warning: Wrong parameter count for stream_get_meta_data() in %s on line %i
+Warning: stream_get_meta_data() expects exactly 1 parameter, 2 given in %s on line %i
NULL
-- Testing stream_get_meta_data() function with invalid stream resource --
-Warning: stream_get_meta_data(): supplied argument is not a valid stream resource in %s on line %i
-bool(false)
+Warning: stream_get_meta_data() expects parameter 1 to be resource, null given in %s on line %i
+NULL
-- Testing stream_get_meta_data() function with closed stream resource --
-- Testing stream_set_timeout() function with more than expected no. of arguments --
-Warning: Wrong parameter count for stream_set_timeout() in %s on line %i
+Warning: stream_set_timeout() expects at most 3 parameters, 4 given in %s on line %i
NULL
-- Testing stream_set_timeout() function with less than expected no. of arguments --
-Warning: Wrong parameter count for stream_set_timeout() in %s on line %i
+Warning: stream_set_timeout() expects at least 2 parameters, 1 given in %s on line %i
NULL
-- Testing stream_set_timeout() function with a closed socket --
-- Testing stream_set_timeout() function with an invalid stream --
-Warning: stream_set_timeout(): supplied argument is not a valid stream resource in %s on line %i
-bool(false)
+Warning: stream_set_timeout() expects parameter 1 to be resource, integer given in %s on line %i
+NULL
-- Testing stream_set_timeout() function with a stream that does not support timeouts --
bool(false)
php_serialize_data_t var_hash;
smart_str buf = {0};
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &struc) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &struc) == FAILURE) {
+ return;
}
Z_TYPE_P(return_value) = IS_STRING;