diff options
author | Sterling Hughes <sterling@php.net> | 2001-10-12 19:16:39 +0000 |
---|---|---|
committer | Sterling Hughes <sterling@php.net> | 2001-10-12 19:16:39 +0000 |
commit | cdc56008808358463548d2046dcd5f54cf5a6193 (patch) | |
tree | 8a200681b0d6df172aee1af4773751a9cb8fd4d3 /ext/zip/zip.c | |
parent | 01850714eedb9def968de5022c3767ec4fc07b0b (diff) | |
download | php-git-cdc56008808358463548d2046dcd5f54cf5a6193.tar.gz |
revert removal of zend_parse_parameters and properly use
zend_parse_parameters (ie zval * instead of zval **).
Diffstat (limited to 'ext/zip/zip.c')
-rw-r--r-- | ext/zip/zip.c | 82 |
1 files changed, 36 insertions, 46 deletions
diff --git a/ext/zip/zip.c b/ext/zip/zip.c index 800bbae1e2..da078ccaaa 100644 --- a/ext/zip/zip.c +++ b/ext/zip/zip.c @@ -142,15 +142,15 @@ PHP_FUNCTION(zip_open) Returns the next file in the archive */ PHP_FUNCTION(zip_read) { - zval **zzip_dp; + zval *zzip_dp; ZZIP_DIR *archive_p = NULL; php_zzip_dirent *entry = NULL; int ret; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zzip_dp) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zzip_dp) == FAILURE) { + return; } - ZEND_FETCH_RESOURCE(archive_p, ZZIP_DIR *, zzip_dp, -1, le_zip_dir_name, le_zip_dir); + ZEND_FETCH_RESOURCE(archive_p, ZZIP_DIR *, &zzip_dp, -1, le_zip_dir_name, le_zip_dir); entry = emalloc(sizeof(php_zzip_dirent)); ret = zzip_dir_read(archive_p, &entry->dirent); @@ -168,14 +168,13 @@ PHP_FUNCTION(zip_read) Close a Zip archive */ PHP_FUNCTION(zip_close) { - zval **zzip_dp; + zval *zzip_dp; ZZIP_DIR *archive_p = NULL; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zzip_dp) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zzip_dp) == FAILURE) { + return; } - - ZEND_FETCH_RESOURCE(archive_p, ZZIP_DIR *, zzip_dp, -1, le_zip_dir_name, le_zip_dir); + ZEND_FETCH_RESOURCE(archive_p, ZZIP_DIR *, &zzip_dp, -1, le_zip_dir_name, le_zip_dir); zend_list_delete(Z_LVAL_PP(zzip_dp)); } @@ -185,13 +184,13 @@ PHP_FUNCTION(zip_close) */ static void php_zzip_get_entry(INTERNAL_FUNCTION_PARAMETERS, int opt) { - zval **zzip_ent; + zval *zzip_ent; php_zzip_dirent *entry = NULL; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zzip_ent) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zzip_ent) == FAILURE) { + return; } - ZEND_FETCH_RESOURCE(entry, php_zzip_dirent *, zzip_ent, -1, le_zip_entry_name, le_zip_entry); + ZEND_FETCH_RESOURCE(entry, php_zzip_dirent *, &zzip_ent, -1, le_zip_entry_name, le_zip_entry); switch (opt) { case 0: @@ -207,6 +206,7 @@ static void php_zzip_get_entry(INTERNAL_FUNCTION_PARAMETERS, int opt) RETURN_STRING((char *) zzip_compr_str(entry->dirent.d_compr), 1); break; } + } /* }}} */ @@ -242,50 +242,41 @@ PHP_FUNCTION(zip_entry_compressionmethod) } /* }}} */ -/* {{{ proto bool zip_entry_open(resource zip_dp, resource zip_entry[, string mode]) +/* {{{ proto bool zip_entry_open(resource zip_dp, resource zip_entry, string mode) Open a Zip File, pointed by the resource entry */ PHP_FUNCTION(zip_entry_open) { - zval **zzip_dp; - zval **zzip_ent; - zval **z_mode; + zval *zzip_dp; + zval *zzip_ent; ZZIP_DIR *archive_p = NULL; php_zzip_dirent *entry = NULL; - int argc = ZEND_NUM_ARGS(); + int mode; - if (argc < 2 || argc > 3 || - zend_get_parameters_ex(argc, &zzip_dp, &zzip_ent, &mode) == FAILURE) { - WRONG_PARAM_COUNT; - } - ZEND_FETCH_RESOURCE(archive_p, ZZIP_DIR *, zzip_dp, -1, le_zip_dir_name, le_zip_dir); - ZEND_FETCH_RESOURCE(entry, php_zzip_dirent *, zzip_ent, -1, le_zip_entry_name, le_zip_entry); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l", &zzip_dp, &zzip_ent, &mode) == FAILURE) + return; + ZEND_FETCH_RESOURCE(archive_p, ZZIP_DIR *, &zzip_dp, -1, le_zip_dir_name, le_zip_dir); + ZEND_FETCH_RESOURCE(entry, php_zzip_dirent *, &zzip_ent, -1, le_zip_entry_name, le_zip_entry); entry->fp = zzip_file_open(archive_p, entry->dirent.d_name, O_RDONLY | O_BINARY); + RETURN_BOOL(entry->fp); } /* }}} */ -/* {{{ proto string zip_read(resource zip_ent[, int len]) +/* {{{ proto string zip_read(resource zip_ent) Read X bytes from an opened zip entry */ PHP_FUNCTION(zip_entry_read) { - zval **zzip_ent; - zval **z_len; - php_zzip_dirent *entry = NULL; - char *buf = NULL; - int len = 1024; - int ret = 0; - int argc = ZEND_NUM_ARGS(); - - if (argc < 1 || argc > 2 || - zend_get_parameters_ex(argc, &zzip_ent, &z_len) == FAILURE) { - WRONG_PARAM_COUNT; - } - ZEND_FETCH_RESOURCE(entry, php_zzip_dirent *, zzip_ent, -1, le_zip_entry_name, le_zip_entry); + zval *zzip_ent; + php_zzip_dirent *entry = NULL; + char *buf = NULL; + int len = 1024; + int ret = 0; - if (argc > 1) { - len = Z_LVAL_PP(z_len); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &zzip_ent, &len) == FAILURE) { + return; } + ZEND_FETCH_RESOURCE(entry, php_zzip_dirent *, &zzip_ent, -1, le_zip_entry_name, le_zip_entry); buf = emalloc(len + 1); ret = zzip_read(entry->fp, buf, len); @@ -301,16 +292,15 @@ PHP_FUNCTION(zip_entry_read) Close a zip entry */ PHP_FUNCTION(zip_entry_close) { - zval **zzip_ent; + zval *zzip_ent; php_zzip_dirent *entry = NULL; - if (ZEND_NUM_ARGS() != 1 || - zend_get_parameters_ex(1, &zzip_ent) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zzip_ent) == FAILURE) { + return; } - ZEND_FETCH_RESOURCE(entry, php_zzip_dirent *, zzip_ent, -1, le_zip_entry_name, le_zip_entry); + ZEND_FETCH_RESOURCE(entry, php_zzip_dirent *, &zzip_ent, -1, le_zip_entry_name, le_zip_entry); - zend_list_delete(Z_LVAL_PP(zzip_ent)); + zend_list_delete(Z_LVAL_P(zzip_ent)); } /* }}} */ |