Skip to content

Instantly share code, notes, and snippets.

@tony2001
Created April 2, 2013 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tony2001/5290671 to your computer and use it in GitHub Desktop.
Save tony2001/5290671 to your computer and use it in GitHub Desktop.
Index: rar_stream.c
===================================================================
--- rar_stream.c (revision 329976)
+++ rar_stream.c (working copy)
@@ -754,7 +754,7 @@
if ((*archive = expand_filepath(tmp_archive, NULL TSRMLS_CC))
== NULL) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC,
- "Could not expand the path %s", archive);
+ "Could not expand the path %s", *archive);
goto cleanup;
}
}
@@ -1060,6 +1060,8 @@
/* copied from main/streams/streams.c because it's an internal function */
static void _rar_stream_tidy_wrapper_error_log(php_stream_wrapper *wrapper TSRMLS_DC)
{
+/* these members are missing in 5.5+. removed or to be added later? */
+#if PHP_VERSION_ID < 50500
if (wrapper) {
/* tidy up the error stack */
int i;
@@ -1073,6 +1075,7 @@
wrapper->err_stack = NULL;
wrapper->err_count = 0;
}
+#endif
}
/* }}} */
Index: rarentry.c
===================================================================
--- rarentry.c (revision 329976)
+++ rarentry.c (working copy)
@@ -49,7 +49,7 @@
static int _rar_decl_priv_prop_null(zend_class_entry *ce, const char *name,
int name_length, char *doc_comment,
int doc_comment_len TSRMLS_DC);
-static zval **_rar_entry_get_property(zval *entry_obj, char *name, int namelen TSRMLS_DC);
+static zval *_rar_entry_get_property(zval *entry_obj, char *name, int namelen TSRMLS_DC);
static void _rar_dos_date_to_text(int dos_time, char *date_string);
static zend_object_value rarentry_ce_create_object(zend_class_entry *class_type TSRMLS_DC);
/* }}} */
@@ -160,28 +160,14 @@
}
/* }}} */
-static zval **_rar_entry_get_property(zval *entry_obj, char *name, int namelen TSRMLS_DC) /* {{{ */
+static zval *_rar_entry_get_property(zval *entry_obj, char *name, int namelen TSRMLS_DC) /* {{{ */
{
- zval **tmp;
- zval member;
+ zval *tmp;
zend_class_entry *orig_scope = EG(scope);
EG(scope) = rar_class_entry_ptr;
- INIT_ZVAL(member);
- Z_TYPE(member) = IS_STRING;
- Z_STRVAL(member) = name;
- Z_STRLEN(member) = namelen;
-
- /* probably should be replaced by zend_read_property */
-
-#if PHP_VERSION_ID < 50399
- tmp = Z_OBJ_HANDLER_P(entry_obj, get_property_ptr_ptr)(entry_obj, &member
- TSRMLS_CC);
-#else
- tmp = Z_OBJ_HANDLER_P(entry_obj, get_property_ptr_ptr)(entry_obj, &member,
- NULL TSRMLS_CC);
-#endif
+ tmp = zend_read_property(Z_OBJCE_P(entry_obj), entry_obj, name, namelen, 1 TSRMLS_CC);
if (tmp == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"Bug: unable to find property '%s'. Please report.", name);
@@ -248,8 +234,8 @@
int with_second_arg;
zend_bool process_ed = 0;
- zval **tmp,
- **tmp_position;
+ zval *tmp,
+ *tmp_position;
rar_file_t *rar = NULL;
zval *entry_obj = getThis();
struct RARHeaderDataEx entry;
@@ -267,7 +253,7 @@
}
RAR_GET_PROPERTY(tmp, "rarfile");
- if (_rar_get_file_resource(*tmp, &rar TSRMLS_CC) == FAILURE) {
+ if (_rar_get_file_resource(tmp, &rar TSRMLS_CC) == FAILURE) {
RETURN_FALSE;
}
@@ -304,7 +290,7 @@
memcpy(&cb_udata, &rar->cb_userdata, sizeof cb_udata);
result = _rar_find_file_p(rar->extract_open_data,
- (size_t) Z_LVAL_PP(tmp_position), &cb_udata, &extract_handle, &found,
+ (size_t) Z_LVAL_P(tmp_position), &cb_udata, &extract_handle, &found,
&entry);
if (_rar_handle_error(result TSRMLS_CC) == FAILURE) {
@@ -314,7 +300,7 @@
if (!found) {
_rar_handle_ext_error("Can't find file with index %d in archive %s"
- TSRMLS_CC, Z_LVAL_PP(tmp_position),
+ TSRMLS_CC, Z_LVAL_P(tmp_position),
rar->extract_open_data->ArcName);
RETVAL_FALSE;
goto cleanup;
@@ -352,14 +338,14 @@
Return position for the entry */
PHP_METHOD(rarentry, getPosition)
{
- zval **tmp;
+ zval *tmp;
zval *entry_obj = getThis();
RAR_RETNULL_ON_ARGS();
RAR_GET_PROPERTY(tmp, "position");
- RETURN_LONG(Z_LVAL_PP(tmp));
+ RETURN_LONG(Z_LVAL_P(tmp));
}
/* }}} */
@@ -367,14 +353,14 @@
Return entry name */
PHP_METHOD(rarentry, getName)
{
- zval **tmp;
+ zval *tmp;
zval *entry_obj = getThis();
RAR_RETNULL_ON_ARGS();
RAR_GET_PROPERTY(tmp, "name");
- RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
+ RETURN_STRINGL(Z_STRVAL_P(tmp), Z_STRLEN_P(tmp), 1);
}
/* }}} */
@@ -382,14 +368,14 @@
Return unpacked size of the entry */
PHP_METHOD(rarentry, getUnpackedSize)
{
- zval **tmp;
+ zval *tmp;
zval *entry_obj = getThis();
RAR_RETNULL_ON_ARGS();
RAR_GET_PROPERTY(tmp, "unpacked_size");
- RETURN_LONG(Z_LVAL_PP(tmp));
+ RETURN_LONG(Z_LVAL_P(tmp));
}
/* }}} */
@@ -397,14 +383,14 @@
Return packed size of the entry */
PHP_METHOD(rarentry, getPackedSize)
{
- zval **tmp;
+ zval *tmp;
zval *entry_obj = getThis();
RAR_RETNULL_ON_ARGS();
RAR_GET_PROPERTY(tmp, "packed_size");
- RETURN_LONG(Z_LVAL_PP(tmp));
+ RETURN_LONG(Z_LVAL_P(tmp));
}
/* }}} */
@@ -412,14 +398,14 @@
Return host OS of the entry */
PHP_METHOD(rarentry, getHostOs)
{
- zval **tmp;
+ zval *tmp;
zval *entry_obj = getThis();
RAR_RETNULL_ON_ARGS();
RAR_GET_PROPERTY(tmp, "host_os");
- RETURN_LONG(Z_LVAL_PP(tmp));
+ RETURN_LONG(Z_LVAL_P(tmp));
}
/* }}} */
@@ -427,14 +413,14 @@
Return modification time of the entry */
PHP_METHOD(rarentry, getFileTime)
{
- zval **tmp;
+ zval *tmp;
zval *entry_obj = getThis();
RAR_RETNULL_ON_ARGS();
RAR_GET_PROPERTY(tmp, "file_time");
- RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
+ RETURN_STRINGL(Z_STRVAL_P(tmp), Z_STRLEN_P(tmp), 1);
}
/* }}} */
@@ -442,14 +428,14 @@
Return CRC of the entry */
PHP_METHOD(rarentry, getCrc)
{
- zval **tmp;
+ zval *tmp;
zval *entry_obj = getThis();
RAR_RETNULL_ON_ARGS();
RAR_GET_PROPERTY(tmp, "crc");
- RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
+ RETURN_STRINGL(Z_STRVAL_P(tmp), Z_STRLEN_P(tmp), 1);
}
/* }}} */
@@ -457,14 +443,14 @@
Return attributes of the entry */
PHP_METHOD(rarentry, getAttr)
{
- zval **tmp;
+ zval *tmp;
zval *entry_obj = getThis();
RAR_RETNULL_ON_ARGS();
RAR_GET_PROPERTY(tmp, "attr");
- RETURN_LONG(Z_LVAL_PP(tmp));
+ RETURN_LONG(Z_LVAL_P(tmp));
}
/* }}} */
@@ -472,14 +458,14 @@
Return version of the archiver, used to create this entry */
PHP_METHOD(rarentry, getVersion)
{
- zval **tmp;
+ zval *tmp;
zval *entry_obj = getThis();
RAR_RETNULL_ON_ARGS();
RAR_GET_PROPERTY(tmp, "version");
- RETURN_LONG(Z_LVAL_PP(tmp));
+ RETURN_LONG(Z_LVAL_P(tmp));
}
/* }}} */
@@ -487,14 +473,14 @@
Return packing method */
PHP_METHOD(rarentry, getMethod)
{
- zval **tmp;
+ zval *tmp;
zval *entry_obj = getThis();
RAR_RETNULL_ON_ARGS();
RAR_GET_PROPERTY(tmp, "method");
- RETURN_LONG(Z_LVAL_PP(tmp));
+ RETURN_LONG(Z_LVAL_P(tmp));
}
/* }}} */
@@ -502,8 +488,8 @@
Return stream for current entry */
PHP_METHOD(rarentry, getStream)
{
- zval **tmp,
- **position;
+ zval *tmp,
+ *position;
rar_file_t *rar = NULL;
zval *entry_obj = getThis();
php_stream *stream = NULL;
@@ -519,7 +505,7 @@
RAR_GET_PROPERTY(position, "position");
RAR_GET_PROPERTY(tmp, "rarfile");
- if (_rar_get_file_resource(*tmp, &rar TSRMLS_CC) == FAILURE) {
+ if (_rar_get_file_resource(tmp, &rar TSRMLS_CC) == FAILURE) {
RETURN_FALSE;
}
@@ -530,7 +516,7 @@
/* doesn't matter that cb_udata is stack allocated, it will be copied */
stream = php_stream_rar_open(rar->extract_open_data->ArcName,
- Z_LVAL_PP(position), &cb_udata, "r" STREAMS_CC TSRMLS_CC);
+ Z_LVAL_P(position), &cb_udata, "r" STREAMS_CC TSRMLS_CC);
if (stream != NULL) {
php_stream_to_zval(stream, return_value);
@@ -544,7 +530,7 @@
Return whether the entry represents a directory */
PHP_METHOD(rarentry, isDirectory)
{
- zval **tmp;
+ zval *tmp;
zval *entry_obj = getThis();
long flags;
int is_dir;
@@ -552,7 +538,7 @@
RAR_RETNULL_ON_ARGS();
RAR_GET_PROPERTY(tmp, "flags");
- flags = Z_LVAL_PP(tmp);
+ flags = Z_LVAL_P(tmp);
is_dir = ((flags & LHD_WINDOWMASK) == LHD_DIRECTORY);
RETURN_BOOL(is_dir);
@@ -563,7 +549,7 @@
Return whether the entry is encrypted and needs a password */
PHP_METHOD(rarentry, isEncrypted)
{
- zval **tmp;
+ zval *tmp;
zval *entry_obj = getThis();
long flags;
int is_encrypted;
@@ -571,7 +557,7 @@
RAR_RETNULL_ON_ARGS();
RAR_GET_PROPERTY(tmp, "flags");
- flags = Z_LVAL_PP(tmp);
+ flags = Z_LVAL_P(tmp);
is_encrypted = (flags & 0x04);
RETURN_BOOL(is_encrypted);
@@ -582,9 +568,9 @@
Return string representation for entry */
PHP_METHOD(rarentry, __toString)
{
- zval **flags_zval,
- **name_zval,
- **crc_zval;
+ zval *flags_zval,
+ *name_zval,
+ *crc_zval;
zval *entry_obj = getThis();
long flags;
int is_dir;
@@ -597,14 +583,14 @@
RAR_RETNULL_ON_ARGS();
RAR_GET_PROPERTY(flags_zval, "flags");
- flags = Z_LVAL_PP(flags_zval);
+ flags = Z_LVAL_P(flags_zval);
is_dir = ((flags & 0xE0) == 0xE0);
RAR_GET_PROPERTY(name_zval, "name");
- name = Z_STRVAL_PP(name_zval);
+ name = Z_STRVAL_P(name_zval);
RAR_GET_PROPERTY(crc_zval, "crc");
- crc = Z_STRVAL_PP(crc_zval);
+ crc = Z_STRVAL_P(crc_zval);
/* 2 is size of %s, 8 is size of crc */
restring_len = (sizeof(format)-1) - 2 * 3 + (sizeof("directory")-1) +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment