summaryrefslogtreecommitdiff
path: root/ext/zip/php_zip.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/zip/php_zip.c')
-rw-r--r--ext/zip/php_zip.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 7c17fb983a..85bc51f152 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -213,7 +213,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
return 1;
}
- len = spprintf(&fullpath, 0, "%s/%s", file_dirname_fullpath, file_basename->val);
+ len = spprintf(&fullpath, 0, "%s/%s", file_dirname_fullpath, ZSTR_VAL(file_basename));
if (!len) {
efree(file_dirname_fullpath);
zend_string_release(file_basename);
@@ -650,10 +650,10 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val
char fullpath[MAXPATHLEN];
int ovector[3];
int matches;
- int namelist_len = namelist[i]->len;
+ int namelist_len = ZSTR_LEN(namelist[i]);
- if ((namelist_len == 1 && namelist[i]->val[0] == '.') ||
- (namelist_len == 2 && namelist[i]->val[0] == '.' && namelist[i]->val[1] == '.')) {
+ if ((namelist_len == 1 && ZSTR_VAL(namelist[i])[0] == '.') ||
+ (namelist_len == 2 && ZSTR_VAL(namelist[i])[0] == '.' && ZSTR_VAL(namelist[i])[1] == '.')) {
zend_string_release(namelist[i]);
continue;
}
@@ -665,7 +665,7 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val
break;
}
- snprintf(fullpath, MAXPATHLEN, "%s%c%s", path, DEFAULT_SLASH, namelist[i]->val);
+ snprintf(fullpath, MAXPATHLEN, "%s%c%s", path, DEFAULT_SLASH, ZSTR_VAL(namelist[i]));
if (0 != VCWD_STAT(fullpath, &s)) {
php_error_docref(NULL, E_WARNING, "Cannot read <%s>", fullpath);
@@ -678,7 +678,7 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val
continue;
}
- matches = pcre_exec(re, NULL, namelist[i]->val, namelist[i]->len, 0, 0, ovector, 3);
+ matches = pcre_exec(re, NULL, ZSTR_VAL(namelist[i]), ZSTR_LEN(namelist[i]), 0, 0, ovector, 3);
/* 0 means that the vector is too small to hold all the captured substring offsets */
if (matches < 0) {
zend_string_release(namelist[i]);
@@ -1114,16 +1114,16 @@ static PHP_NAMED_FUNCTION(zif_zip_open)
return;
}
- if (filename->len == 0) {
+ if (ZSTR_LEN(filename) == 0) {
php_error_docref(NULL, E_WARNING, "Empty string as source");
RETURN_FALSE;
}
- if (ZIP_OPENBASEDIR_CHECKPATH(filename->val)) {
+ if (ZIP_OPENBASEDIR_CHECKPATH(ZSTR_VAL(filename))) {
RETURN_FALSE;
}
- if(!expand_filepath(filename->val, resolved_path)) {
+ if(!expand_filepath(ZSTR_VAL(filename), resolved_path)) {
RETURN_FALSE;
}
@@ -1283,10 +1283,10 @@ static PHP_NAMED_FUNCTION(zif_zip_entry_read)
if (zr_rsrc->zf) {
buffer = zend_string_alloc(len, 0);
- n = zip_fread(zr_rsrc->zf, buffer->val, buffer->len);
+ n = zip_fread(zr_rsrc->zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
if (n > 0) {
- buffer->val[n] = '\0';
- buffer->len = n;
+ ZSTR_VAL(buffer)[n] = '\0';
+ ZSTR_LEN(buffer) = n;
RETURN_NEW_STR(buffer);
} else {
zend_string_free(buffer);
@@ -1417,16 +1417,16 @@ static ZIPARCHIVE_METHOD(open)
ze_obj = Z_ZIP_P(self);
}
- if (filename->len == 0) {
+ if (ZSTR_LEN(filename) == 0) {
php_error_docref(NULL, E_WARNING, "Empty string as source");
RETURN_FALSE;
}
- if (ZIP_OPENBASEDIR_CHECKPATH(filename->val)) {
+ if (ZIP_OPENBASEDIR_CHECKPATH(ZSTR_VAL(filename))) {
RETURN_FALSE;
}
- if (!(resolved_path = expand_filepath(filename->val, NULL))) {
+ if (!(resolved_path = expand_filepath(ZSTR_VAL(filename), NULL))) {
RETURN_FALSE;
}
@@ -1634,7 +1634,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
}
}
- if (pattern->len == 0) {
+ if (ZSTR_LEN(pattern) == 0) {
php_error_docref(NULL, E_NOTICE, "Empty string as pattern");
RETURN_FALSE;
}
@@ -1651,7 +1651,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
}
if (type == 1) {
- found = php_zip_glob(pattern->val, pattern->len, flags, return_value);
+ found = php_zip_glob(ZSTR_VAL(pattern), ZSTR_LEN(pattern), flags, return_value);
} else {
found = php_zip_pcre(pattern, path, path_len, return_value);
}
@@ -1669,8 +1669,8 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
if ((zval_file = zend_hash_index_find(Z_ARRVAL_P(return_value), i)) != NULL) {
if (remove_all_path) {
basename = php_basename(Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file), NULL, 0);
- file_stripped = basename->val;
- file_stripped_len = basename->len;
+ file_stripped = ZSTR_VAL(basename);
+ file_stripped_len = ZSTR_LEN(basename);
} else if (remove_path && strstr(Z_STRVAL_P(zval_file), remove_path) != NULL) {
file_stripped = Z_STRVAL_P(zval_file) + remove_path_len + 1;
file_stripped_len = Z_STRLEN_P(zval_file) - remove_path_len - 1;
@@ -1747,17 +1747,17 @@ static ZIPARCHIVE_METHOD(addFile)
return;
}
- if (filename->len == 0) {
+ if (ZSTR_LEN(filename) == 0) {
php_error_docref(NULL, E_NOTICE, "Empty string as filename");
RETURN_FALSE;
}
if (entry_name_len == 0) {
- entry_name = filename->val;
- entry_name_len = filename->len;
+ entry_name = ZSTR_VAL(filename);
+ entry_name_len = ZSTR_LEN(filename);
}
- if (php_zip_add_file(intern, filename->val, filename->len, entry_name, entry_name_len, 0, 0) < 0) {
+ if (php_zip_add_file(intern, ZSTR_VAL(filename), ZSTR_LEN(filename), entry_name, entry_name_len, 0, 0) < 0) {
RETURN_FALSE;
} else {
RETURN_TRUE;
@@ -1799,10 +1799,10 @@ static ZIPARCHIVE_METHOD(addFromString)
ze_obj->buffers_cnt++;
pos = 0;
}
- ze_obj->buffers[pos] = (char *)emalloc(buffer->len + 1);
- memcpy(ze_obj->buffers[pos], buffer->val, buffer->len + 1);
+ ze_obj->buffers[pos] = (char *)emalloc(ZSTR_LEN(buffer) + 1);
+ memcpy(ze_obj->buffers[pos], ZSTR_VAL(buffer), ZSTR_LEN(buffer) + 1);
- zs = zip_source_buffer(intern, ze_obj->buffers[pos], buffer->len, 0);
+ zs = zip_source_buffer(intern, ze_obj->buffers[pos], ZSTR_LEN(buffer), 0);
if (zs == NULL) {
RETURN_FALSE;
@@ -1847,7 +1847,7 @@ static ZIPARCHIVE_METHOD(statName)
return;
}
- PHP_ZIP_STAT_PATH(intern, name->val, name->len, flags, sb);
+ PHP_ZIP_STAT_PATH(intern, ZSTR_VAL(name), ZSTR_LEN(name), flags, sb);
RETURN_SB(&sb);
}
@@ -1901,11 +1901,11 @@ static ZIPARCHIVE_METHOD(locateName)
return;
}
- if (name->len < 1) {
+ if (ZSTR_LEN(name) < 1) {
RETURN_FALSE;
}
- idx = (zend_long)zip_name_locate(intern, (const char *)name->val, flags);
+ idx = (zend_long)zip_name_locate(intern, (const char *)ZSTR_VAL(name), flags);
if (idx >= 0) {
RETURN_LONG(idx);
@@ -2698,7 +2698,7 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|ll", &filename, &len, &flags) == FAILURE) {
return;
}
- PHP_ZIP_STAT_PATH(intern, filename->val, filename->len, flags, sb);
+ PHP_ZIP_STAT_PATH(intern, ZSTR_VAL(filename), ZSTR_LEN(filename), flags, sb);
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|ll", &index, &len, &flags) == FAILURE) {
return;
@@ -2716,7 +2716,7 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
if (index >= 0) {
zf = zip_fopen_index(intern, index, flags);
} else {
- zf = zip_fopen(intern, filename->val, flags);
+ zf = zip_fopen(intern, ZSTR_VAL(filename), flags);
}
if (zf == NULL) {
@@ -2724,15 +2724,15 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
}
buffer = zend_string_alloc(len, 0);
- n = zip_fread(zf, buffer->val, buffer->len);
+ n = zip_fread(zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
if (n < 1) {
zend_string_free(buffer);
RETURN_EMPTY_STRING();
}
zip_fclose(zf);
- buffer->val[n] = '\0';
- buffer->len = n;
+ ZSTR_VAL(buffer)[n] = '\0';
+ ZSTR_LEN(buffer) = n;
RETURN_NEW_STR(buffer);
}
/* }}} */
@@ -2775,13 +2775,13 @@ static ZIPARCHIVE_METHOD(getStream)
return;
}
- if (zip_stat(intern, filename->val, 0, &sb) != 0) {
+ if (zip_stat(intern, ZSTR_VAL(filename), 0, &sb) != 0) {
RETURN_FALSE;
}
obj = Z_ZIP_P(self);
- stream = php_stream_zip_open(obj->filename, filename->val, mode STREAMS_CC);
+ stream = php_stream_zip_open(obj->filename, ZSTR_VAL(filename), mode STREAMS_CC);
if (stream) {
php_stream_to_zval(stream, return_value);
} else {