mirror of
https://github.com/php/php-src.git
synced 2024-11-29 04:46:07 +08:00
- whitespace fix
This commit is contained in:
parent
6b0196b652
commit
9d4c81e925
228
ext/zip/zip.c
228
ext/zip/zip.c
@ -39,31 +39,31 @@ static int le_zip_entry;
|
||||
/* {{{ zip_functions[]
|
||||
*/
|
||||
function_entry zip_functions[] = {
|
||||
PHP_FE(zip_open, NULL)
|
||||
PHP_FE(zip_read, NULL)
|
||||
PHP_FE(zip_close, NULL)
|
||||
PHP_FE(zip_entry_name, NULL)
|
||||
PHP_FE(zip_entry_compressedsize, NULL)
|
||||
PHP_FE(zip_entry_filesize, NULL)
|
||||
PHP_FE(zip_entry_compressionmethod, NULL)
|
||||
PHP_FE(zip_entry_open, NULL)
|
||||
PHP_FE(zip_entry_read, NULL)
|
||||
PHP_FE(zip_entry_close, NULL)
|
||||
{NULL, NULL, NULL}
|
||||
PHP_FE(zip_open, NULL)
|
||||
PHP_FE(zip_read, NULL)
|
||||
PHP_FE(zip_close, NULL)
|
||||
PHP_FE(zip_entry_name, NULL)
|
||||
PHP_FE(zip_entry_compressedsize, NULL)
|
||||
PHP_FE(zip_entry_filesize, NULL)
|
||||
PHP_FE(zip_entry_compressionmethod, NULL)
|
||||
PHP_FE(zip_entry_open, NULL)
|
||||
PHP_FE(zip_entry_read, NULL)
|
||||
PHP_FE(zip_entry_close, NULL)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/* {{{ zip_module_entry
|
||||
*/
|
||||
zend_module_entry zip_module_entry = {
|
||||
"zip",
|
||||
zip_functions,
|
||||
PHP_MINIT(zip),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
PHP_MINFO(zip),
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
"zip",
|
||||
zip_functions,
|
||||
PHP_MINIT(zip),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
PHP_MINFO(zip),
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
@ -75,8 +75,8 @@ ZEND_GET_MODULE(zip)
|
||||
*/
|
||||
static void php_zip_free_dir(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
{
|
||||
ZZIP_DIR *z_dir = (ZZIP_DIR *) rsrc->ptr;
|
||||
zzip_closedir(z_dir);
|
||||
ZZIP_DIR *z_dir = (ZZIP_DIR *) rsrc->ptr;
|
||||
zzip_closedir(z_dir);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -84,12 +84,12 @@ static void php_zip_free_dir(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
*/
|
||||
static void php_zip_free_entry(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
{
|
||||
php_zzip_dirent *entry = (php_zzip_dirent *) rsrc->ptr;
|
||||
php_zzip_dirent *entry = (php_zzip_dirent *) rsrc->ptr;
|
||||
|
||||
if (entry->fp)
|
||||
zzip_close(entry->fp);
|
||||
if (entry->fp)
|
||||
zzip_close(entry->fp);
|
||||
|
||||
efree(entry);
|
||||
efree(entry);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -97,10 +97,10 @@ static void php_zip_free_entry(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
*/
|
||||
PHP_MINIT_FUNCTION(zip)
|
||||
{
|
||||
le_zip_dir = zend_register_list_destructors_ex(php_zip_free_dir, NULL, le_zip_dir_name, module_number);
|
||||
le_zip_entry = zend_register_list_destructors_ex(php_zip_free_entry, NULL, le_zip_entry_name, module_number);
|
||||
le_zip_dir = zend_register_list_destructors_ex(php_zip_free_dir, NULL, le_zip_dir_name, module_number);
|
||||
le_zip_entry = zend_register_list_destructors_ex(php_zip_free_entry, NULL, le_zip_entry_name, module_number);
|
||||
|
||||
return SUCCESS;
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -108,9 +108,9 @@ PHP_MINIT_FUNCTION(zip)
|
||||
*/
|
||||
PHP_MINFO_FUNCTION(zip)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_row(2, "Zip support", "enabled");
|
||||
php_info_print_table_end();
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_row(2, "Zip support", "enabled");
|
||||
php_info_print_table_end();
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -118,21 +118,21 @@ PHP_MINFO_FUNCTION(zip)
|
||||
Open a new zip archive for reading */
|
||||
PHP_FUNCTION(zip_open)
|
||||
{
|
||||
char *filename;
|
||||
ZZIP_DIR *archive_p = NULL;
|
||||
int filename_len;
|
||||
char *filename;
|
||||
ZZIP_DIR *archive_p = NULL;
|
||||
int filename_len;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
|
||||
return;
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
archive_p = zzip_opendir(filename);
|
||||
if (archive_p == NULL) {
|
||||
php_error(E_WARNING, "Cannot open zip archive %s", filename);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
archive_p = zzip_opendir(filename);
|
||||
if (archive_p == NULL) {
|
||||
php_error(E_WARNING, "Cannot open zip archive %s", filename);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, archive_p, le_zip_dir);
|
||||
ZEND_REGISTER_RESOURCE(return_value, archive_p, le_zip_dir);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -140,26 +140,26 @@ PHP_FUNCTION(zip_open)
|
||||
Returns the next file in the archive */
|
||||
PHP_FUNCTION(zip_read)
|
||||
{
|
||||
zval **zzip_dp;
|
||||
ZZIP_DIR *archive_p = NULL;
|
||||
php_zzip_dirent *entry = NULL;
|
||||
int ret;
|
||||
zval **zzip_dp;
|
||||
ZZIP_DIR *archive_p = NULL;
|
||||
php_zzip_dirent *entry = NULL;
|
||||
int ret;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zzip_dp) == FAILURE) {
|
||||
return;
|
||||
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);
|
||||
if (ret == 0) {
|
||||
efree(entry);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
entry->fp = NULL;
|
||||
entry = emalloc(sizeof(php_zzip_dirent));
|
||||
ret = zzip_dir_read(archive_p, &entry->dirent);
|
||||
if (ret == 0) {
|
||||
efree(entry);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
entry->fp = NULL;
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, entry, le_zip_entry);
|
||||
ZEND_REGISTER_RESOURCE(return_value, entry, le_zip_entry);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -167,16 +167,16 @@ PHP_FUNCTION(zip_read)
|
||||
Close a Zip archive */
|
||||
PHP_FUNCTION(zip_close)
|
||||
{
|
||||
zval **zzip_dp;
|
||||
ZZIP_DIR *archive_p = NULL;
|
||||
zval **zzip_dp;
|
||||
ZZIP_DIR *archive_p = NULL;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zzip_dp) == FAILURE) {
|
||||
return;
|
||||
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));
|
||||
zend_list_delete(Z_LVAL_PP(zzip_dp));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -184,29 +184,29 @@ PHP_FUNCTION(zip_close)
|
||||
*/
|
||||
static void php_zzip_get_entry(INTERNAL_FUNCTION_PARAMETERS, int opt)
|
||||
{
|
||||
zval **zzip_ent;
|
||||
php_zzip_dirent *entry = NULL;
|
||||
zval **zzip_ent;
|
||||
php_zzip_dirent *entry = NULL;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zzip_ent) == FAILURE) {
|
||||
return;
|
||||
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:
|
||||
RETURN_STRING(entry->dirent.d_name, 1);
|
||||
break;
|
||||
case 1:
|
||||
RETURN_LONG(entry->dirent.d_csize);
|
||||
break;
|
||||
case 2:
|
||||
RETURN_LONG(entry->dirent.st_size);
|
||||
break;
|
||||
case 3:
|
||||
RETURN_STRING((char *) zzip_compr_str(entry->dirent.d_compr), 1);
|
||||
break;
|
||||
}
|
||||
switch (opt) {
|
||||
case 0:
|
||||
RETURN_STRING(entry->dirent.d_name, 1);
|
||||
break;
|
||||
case 1:
|
||||
RETURN_LONG(entry->dirent.d_csize);
|
||||
break;
|
||||
case 2:
|
||||
RETURN_LONG(entry->dirent.st_size);
|
||||
break;
|
||||
case 3:
|
||||
RETURN_STRING((char *) zzip_compr_str(entry->dirent.d_compr), 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -214,7 +214,7 @@ static void php_zzip_get_entry(INTERNAL_FUNCTION_PARAMETERS, int opt)
|
||||
Return the name given a ZZip entry */
|
||||
PHP_FUNCTION(zip_entry_name)
|
||||
{
|
||||
php_zzip_get_entry(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
|
||||
php_zzip_get_entry(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -222,7 +222,7 @@ PHP_FUNCTION(zip_entry_name)
|
||||
Return the compressed size of a ZZip entry */
|
||||
PHP_FUNCTION(zip_entry_compressedsize)
|
||||
{
|
||||
php_zzip_get_entry(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
|
||||
php_zzip_get_entry(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -230,7 +230,7 @@ PHP_FUNCTION(zip_entry_compressedsize)
|
||||
Return the actual filesize of a ZZip entry */
|
||||
PHP_FUNCTION(zip_entry_filesize)
|
||||
{
|
||||
php_zzip_get_entry(INTERNAL_FUNCTION_PARAM_PASSTHRU, 2);
|
||||
php_zzip_get_entry(INTERNAL_FUNCTION_PARAM_PASSTHRU, 2);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -238,7 +238,7 @@ PHP_FUNCTION(zip_entry_filesize)
|
||||
Return a string containing the compression method used on a particular entry */
|
||||
PHP_FUNCTION(zip_entry_compressionmethod)
|
||||
{
|
||||
php_zzip_get_entry(INTERNAL_FUNCTION_PARAM_PASSTHRU, 3);
|
||||
php_zzip_get_entry(INTERNAL_FUNCTION_PARAM_PASSTHRU, 3);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -246,19 +246,19 @@ PHP_FUNCTION(zip_entry_compressionmethod)
|
||||
Open a Zip File, pointed by the resource entry */
|
||||
PHP_FUNCTION(zip_entry_open)
|
||||
{
|
||||
zval **zzip_dp;
|
||||
zval **zzip_ent;
|
||||
ZZIP_DIR *archive_p = NULL;
|
||||
php_zzip_dirent *entry = NULL;
|
||||
int mode;
|
||||
zval **zzip_dp;
|
||||
zval **zzip_ent;
|
||||
ZZIP_DIR *archive_p = NULL;
|
||||
php_zzip_dirent *entry = NULL;
|
||||
int mode;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l", &zzip_dp, &zzip_ent, &mode) == FAILURE)
|
||||
return;
|
||||
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);
|
||||
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);
|
||||
entry->fp = zzip_file_open(archive_p, entry->dirent.d_name, O_RDONLY | O_BINARY);
|
||||
|
||||
RETURN_BOOL(entry->fp);
|
||||
}
|
||||
@ -268,22 +268,22 @@ PHP_FUNCTION(zip_entry_open)
|
||||
Read X bytes from an opened zip entry */
|
||||
PHP_FUNCTION(zip_entry_read)
|
||||
{
|
||||
zval **zzip_ent;
|
||||
php_zzip_dirent *entry = NULL;
|
||||
char *buf = NULL;
|
||||
int len = 1024;
|
||||
int ret = 0;
|
||||
zval **zzip_ent;
|
||||
php_zzip_dirent *entry = NULL;
|
||||
char *buf = NULL;
|
||||
int len = 1024;
|
||||
int ret = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &zzip_ent, &len) == FAILURE) {
|
||||
return;
|
||||
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);
|
||||
|
||||
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);
|
||||
if (ret == 0) {
|
||||
RETURN_FALSE;
|
||||
buf = emalloc(len + 1);
|
||||
ret = zzip_read(entry->fp, buf, len);
|
||||
if (ret == 0) {
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
RETURN_STRINGL(buf, len, 0);
|
||||
}
|
||||
@ -294,16 +294,16 @@ PHP_FUNCTION(zip_entry_read)
|
||||
Close a zip entry */
|
||||
PHP_FUNCTION(zip_entry_close)
|
||||
{
|
||||
zval **zzip_ent;
|
||||
php_zzip_dirent *entry = NULL;
|
||||
zval **zzip_ent;
|
||||
php_zzip_dirent *entry = NULL;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zzip_ent) == FAILURE) {
|
||||
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_PP(zzip_ent));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user