pajoye Tue Dec 19 02:05:27 2006 UTC
Modified files:
/php-src/ext/zip php_zip.c
Log:
- unicode support for the procedural API
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.32&r2=1.33&diff_format=u
Index: php-src/ext/zip/php_zip.c
diff -u php-src/ext/zip/php_zip.c:1.32 php-src/ext/zip/php_zip.c:1.33
--- php-src/ext/zip/php_zip.c:1.32 Sun Dec 10 03:10:55 2006
+++ php-src/ext/zip/php_zip.c Tue Dec 19 02:05:27 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_zip.c,v 1.32 2006/12/10 03:10:55 pajoye Exp $ */
+/* $Id: php_zip.c,v 1.33 2006/12/19 02:05:27 pajoye Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -587,19 +587,34 @@
ZEND_GET_MODULE(zip)
#endif
-/* {{{ proto resource zip_open(string filename)
+/* {{{ proto resource zip_open(string filename) U
Create new zip using source uri for output */
static PHP_FUNCTION(zip_open)
{
+ zval **filename_zval;
char *filename;
int filename_len;
+ char resolved_path[MAXPATHLEN + 1];
zip_rsrc *rsrc_int;
int err = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename,
&filename_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z",
&filename_zval) == FAILURE) {
return;
}
+ if (FAILURE == php_stream_path_param_encode(filename_zval, &filename,
&filename_len, REPORT_ERRORS, FG(default_context))) {
+ RETURN_FALSE;
+ }
+
+ if (filename_len == 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty string as
source");
+ RETURN_FALSE;
+ }
+
+ if(!expand_filepath(filename, resolved_path TSRMLS_CC)) {
+ RETURN_FALSE;
+ }
+
rsrc_int = (zip_rsrc *)emalloc(sizeof(zip_rsrc));
rsrc_int->za = zip_open(filename, 0, &err);
@@ -615,7 +630,7 @@
}
/* }}} */
-/* {{{ proto void zip_close(resource zip)
+/* {{{ proto void zip_close(resource zip) U
Close a Zip archive */
static PHP_FUNCTION(zip_close)
{
@@ -632,7 +647,7 @@
}
/* }}} */
-/* {{{ proto resource zip_read(resource zip)
+/* {{{ proto resource zip_read(resource zip) U
Returns the next file in the archive */
static PHP_FUNCTION(zip_read)
{
@@ -657,7 +672,7 @@
if (ret != 0) {
efree(zr_rsrc);
- RETURN_LONG((long)ret);
+ RETURN_FALSE;
}
zr_rsrc->zf = zip_fopen_index(rsrc_int->za,
rsrc_int->index_current, 0);
@@ -674,7 +689,7 @@
}
/* }}} */
-/* {{{ 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]) U
Open a Zip File, pointed by the resource entry */
/* Dummy function to follow the old API */
static PHP_FUNCTION(zip_entry_open)
@@ -686,7 +701,8 @@
zip_read_rsrc * zr_rsrc;
zip_rsrc *z_rsrc;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|s", &zip,
&zip_entry, &mode, &mode_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|s&",
+ &zip, &zip_entry, &mode, &mode_len, UG(ascii_conv)) == FAILURE)
{
return;
}
@@ -701,7 +717,7 @@
}
/* }}} */
-/* {{{ proto void zip_entry_close(resource zip_ent)
+/* {{{ proto void zip_entry_close(resource zip_ent) U
Close a zip entry */
/* another dummy function to fit in the old api*/
static PHP_FUNCTION(zip_entry_close)
@@ -719,7 +735,7 @@
}
/* }}} */
-/* {{{ proto mixed zip_entry_read(resource zip_entry [, int len])
+/* {{{ proto mixed zip_entry_read(resource zip_entry [, int len]) U
Read from an open directory entry */
static PHP_FUNCTION(zip_entry_read)
{
@@ -782,31 +798,31 @@
case 3:
switch (zr_rsrc->sb.comp_method) {
case 0:
- RETURN_STRING("stored", 1);
+ RETURN_ASCII_STRING("stored",
ZSTR_DUPLICATE);
break;
case 1:
- RETURN_STRING("shrunk", 1);
+ RETURN_ASCII_STRING("shrunk",
ZSTR_DUPLICATE);
break;
case 2:
case 3:
case 4:
case 5:
- RETURN_STRING("reduced", 1);
+ RETURN_ASCII_STRING("reduced",
ZSTR_DUPLICATE);
break;
case 6:
- RETURN_STRING("imploded", 1);
+ RETURN_ASCII_STRING("imploded",
ZSTR_DUPLICATE);
break;
case 7:
- RETURN_STRING("tokenized", 1);
+ RETURN_ASCII_STRING("tokenized",
ZSTR_DUPLICATE);
break;
case 8:
- RETURN_STRING("deflated", 1);
+ RETURN_ASCII_STRING("deflated",
ZSTR_DUPLICATE);
break;
case 9:
- RETURN_STRING("deflatedX", 1);
+ RETURN_ASCII_STRING("deflatedX",
ZSTR_DUPLICATE);
break;
case 10:
- RETURN_STRING("implodedX", 1);
+ RETURN_ASCII_STRING("implodedX",
ZSTR_DUPLICATE);
break;
default:
RETURN_FALSE;
@@ -818,7 +834,7 @@
}
/* }}} */
-/* {{{ proto string zip_entry_name(resource zip_entry)
+/* {{{ proto string zip_entry_name(resource zip_entry) U
Return the name given a ZZip entry */
static PHP_FUNCTION(zip_entry_name)
{
@@ -826,7 +842,7 @@
}
/* }}} */
-/* {{{ proto int zip_entry_compressedsize(resource zip_entry)
+/* {{{ proto int zip_entry_compressedsize(resource zip_entry) U
Return the compressed size of a ZZip entry */
static PHP_FUNCTION(zip_entry_compressedsize)
{
@@ -834,7 +850,7 @@
}
/* }}} */
-/* {{{ proto int zip_entry_filesize(resource zip_entry)
+/* {{{ proto int zip_entry_filesize(resource zip_entry) U
Return the actual filesize of a ZZip entry */
static PHP_FUNCTION(zip_entry_filesize)
{
@@ -842,7 +858,7 @@
}
/* }}} */
-/* {{{ proto string zip_entry_compressionmethod(resource zip_entry)
+/* {{{ proto string zip_entry_compressionmethod(resource zip_entry) U
Return a string containing the compression method used on a particular
entry */
PHP_FUNCTION(zip_entry_compressionmethod)
{
@@ -1091,11 +1107,6 @@
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
- &name, &name_len, &buffer, &buffer_len) == FAILURE) {
- return;
- }
-
ze_obj = (ze_zip_object*) zend_object_store_get_object(this TSRMLS_CC);
if (ze_obj->buffers_cnt) {
ze_obj->buffers = (char **)erealloc(ze_obj->buffers,
sizeof(char *) * (ze_obj->buffers_cnt+1));
@@ -2060,7 +2071,7 @@
php_info_print_table_start();
php_info_print_table_row(2, "Zip", "enabled");
- php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.32
2006/12/10 03:10:55 pajoye Exp $");
+ php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.33
2006/12/19 02:05:27 pajoye Exp $");
php_info_print_table_row(2, "Zip version", "2.0.0");
php_info_print_table_row(2, "Libzip version", "0.7.1");
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php