Permalink
Browse files

- Fixed a build failure on gcc.

- Changed // comments into /* ones on C portions.
- Simplified the output of some stat tests.

git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@306221 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent da39115 commit b92bcc5d5fca31fefbec2f42718ca941df6108b9 cataphract committed Dec 11, 2010
Showing with 168 additions and 396 deletions.
  1. +9 −9 php_rar.h
  2. +10 −10 rar.c
  3. +3 −3 rar_error.c
  4. +5 −5 rar_navigation.c
  5. +17 −17 rar_stream.c
  6. +11 −11 rararch.c
  7. +10 −10 rarentry.c
  8. +17 −55 tests/056.phpt
  9. +51 −165 tests/059.phpt
  10. +34 −110 tests/062.phpt
  11. +1 −1 unrar/rdwrfn.hpp
View
@@ -80,22 +80,22 @@ enum HOST_SYSTEM {
#define LHD_WINDOWMASK 0x00e0U
#define LHD_DIRECTORY 0x00e0U
-//maximum comment size if 64KB
+/* maximum comment size if 64KB */
#define RAR_MAX_COMMENT_SIZE 65536
typedef struct _rar_cb_user_data {
- char *password; //can be NULL
- zval *callable; //can be NULL
+ char *password; /* can be NULL */
+ zval *callable; /* can be NULL */
} rar_cb_user_data;
typedef struct rar {
zend_object_handle id;
struct _rar_entries *entries;
struct RAROpenArchiveDataEx *list_open_data;
struct RAROpenArchiveDataEx *extract_open_data;
- //archive handle opened with RAR_OM_LIST_INCSPLIT open mode
+ /* archive handle opened with RAR_OM_LIST_INCSPLIT open mode */
void *arch_handle;
- //user data to pass the RAR callback
+ /* user data to pass the RAR callback */
rar_cb_user_data cb_userdata;
int allow_broken;
} rar_file_t;
@@ -131,7 +131,7 @@ typedef struct rar {
*/
typedef struct _rar_contents_cache {
int max_size;
- HashTable *data; //persistent HashTable, will hold rar_cache_entry
+ HashTable *data; /* persistent HashTable, will hold rar_cache_entry */
int hits;
int misses;
/* args: cache key, cache key size, cached object) */
@@ -247,15 +247,15 @@ void _rar_entry_search_end(rar_find_output *state);
void _rar_entry_search_seek(rar_find_output *state, size_t pos);
void _rar_entry_search_rewind(rar_find_output *state);
void _rar_entry_search_advance(rar_find_output *state,
- const wchar_t * const file, //NULL = give next
- size_t file_size, //length + 1
+ const wchar_t * const file, /* NULL = give next */
+ size_t file_size, /* length + 1 */
int directory_match);
/* end entry search API }}} */
/* rararch.c */
int _rar_create_rararch_obj(const char* resolved_path,
const char* open_password,
- zval *volume_callback, //must be callable or NULL
+ zval *volume_callback, /* must be callable or NULL */
zval *object,
int *err_code TSRMLS_DC);
void _rar_close_file_resource(rar_file_t *rar);
View
20 rar.c
@@ -250,7 +250,7 @@ int _rar_find_file_w(struct RAROpenArchiveDataEx *open_data, /* IN */
}
if (result != 0 && result != 1) {
- //0 indicates success, 1 indicates normal end of file
+ /* 0 indicates success, 1 indicates normal end of file */
retval = result;
goto cleanup;
}
@@ -308,7 +308,7 @@ int _rar_find_file_p(struct RAROpenArchiveDataEx *open_data, /* IN */
}
if (result != 0 && result != 1) {
- //0 indicates success, 1 indicates normal end of file
+ /* 0 indicates success, 1 indicates normal end of file */
retval = result;
goto cleanup;
}
@@ -331,7 +331,7 @@ int CALLBACK _rar_unrar_callback(UINT msg, LPARAM UserData, LPARAM P1, LPARAM P2
rar_cb_user_data *userdata = (rar_cb_user_data*) UserData;
if (msg == UCM_NEEDPASSWORD) {
- //user data is the password or null if none
+ /* user data is the password or null if none */
char *password = userdata->password;
if (password == NULL || password[0] == '\0') {
@@ -462,7 +462,7 @@ static int _rar_unrar_volume_user_callback(char* dst_buffer,
assert(*fci->retval_ptr_ptr == retval_ptr);
if (Z_TYPE_P(retval_ptr) == IS_NULL) {
- //let return -1
+ /* let return -1 */
}
else if (Z_TYPE_P(retval_ptr) == IS_STRING) {
char *filename = Z_STRVAL_P(retval_ptr);
@@ -489,13 +489,13 @@ static int _rar_unrar_volume_user_callback(char* dst_buffer,
strncpy(dst_buffer, resolved_path, NM);
dst_buffer[NM - 1] = '\0';
- ret = 1; //try this new filename
+ ret = 1; /* try this new filename */
}
else {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"Wrong type returned by volume find callback, "
"expected string or NULL");
- //let return -1
+ /* let return -1 */
}
cleanup:
@@ -705,7 +705,7 @@ ZEND_MODULE_STARTUP_D(rar)
REGISTER_LONG_CONSTANT("RAR_HOST_UNIX", HOST_UNIX, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("RAR_HOST_MACOS", HOST_MACOS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("RAR_HOST_BEOS", HOST_BEOS, CONST_CS | CONST_PERSISTENT);
- //PHP < 5.3 doesn't have the PHP_MAXPATHLEN constant
+ /* PHP < 5.3 doesn't have the PHP_MAXPATHLEN constant */
#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 3
REGISTER_LONG_CONSTANT("RAR_MAXPATHLEN", MAXPATHLEN, CONST_CS | CONST_PERSISTENT);
#endif
@@ -759,17 +759,17 @@ zend_module_entry rar_module_entry = {
"rar",
rar_functions,
ZEND_MODULE_STARTUP_N(rar),
- //ZEND_MODULE_SHUTDOWN_N(rar),
+ /* ZEND_MODULE_SHUTDOWN_N(rar), */
NULL,
- //ZEND_MODULE_ACTIVATE_N(rar),
+ /* ZEND_MODULE_ACTIVATE_N(rar), */
NULL,
ZEND_MODULE_DEACTIVATE_N(rar),
ZEND_MODULE_INFO_N(rar),
PHP_RAR_VERSION,
ZEND_MODULE_GLOBALS(rar),
ZEND_MODULE_GLOBALS_CTOR_N(rar),
ZEND_MODULE_GLOBALS_DTOR_N(rar),
- NULL, //post_deactivate_func
+ NULL, /* post_deactivate_func */
STANDARD_MODULE_PROPERTIES_EX,
};
/* }}} */
View
@@ -96,7 +96,7 @@ int _rar_using_exceptions(TSRMLS_D)
return Z_BVAL_P(pval);
}
-//returns a string or NULL if not an error
+/* returns a string or NULL if not an error */
const char * _rar_error_to_string(int errcode) /* {{{ */
{
const char *ret;
@@ -188,15 +188,15 @@ PHP_METHOD(rarexception, isUsingExceptions)
return;
}
- //or zend_read_static_property, which calls zend_std_get... after chg scope
+ /* or zend_read_static_property, which calls zend_std_get... after chg scope */
#if PHP_VERSION_ID < 50399
pval = zend_std_get_static_property(rarexception_ce_ptr, "usingExceptions",
sizeof("usingExceptions") -1, (zend_bool) 0 TSRMLS_CC);
#else
pval = zend_std_get_static_property(rarexception_ce_ptr, "usingExceptions",
sizeof("usingExceptions") -1, (zend_bool) 0, NULL TSRMLS_CC);
#endif
- //property always exists
+ /* property always exists */
assert(pval != NULL);
assert(Z_TYPE_PP(pval) == IS_BOOL);
View
@@ -156,7 +156,7 @@ void _rar_entry_search_rewind(rar_find_output *state)
/* {{{ _rar_entry_search_advance */
void _rar_entry_search_advance(rar_find_output *state,
- const wchar_t * const file, //NULL = give next
+ const wchar_t * const file, /* NULL = give next */
size_t file_size, /* length + 1; 0 if unknown */
int directory_match)
{
@@ -175,7 +175,7 @@ void _rar_entry_search_advance(rar_find_output *state,
if ((file != NULL) && (file_size == 0))
file_size = wcslen(file) + 1;
- //reset output
+ /* reset output */
memset(&rstate->out, 0, sizeof rstate->out);
filenamewsize = sizeof(entries->entries_array[0]->entry.FileNameW) /
@@ -342,7 +342,7 @@ int _rar_list_files(rar_file_t *rar TSRMLS_DC) /* {{{ */
while (result == 0) {
struct RARHeaderDataEx entry;
result = RARReadHeaderEx(rar->arch_handle, &entry);
- //value of 2nd argument is irrelevant in RAR_OM_LIST_[SPLIT] mode
+ /* value of 2nd argument is irrelevant in RAR_OM_LIST_[SPLIT] mode */
if (result == 0) {
result = RARProcessFile(rar->arch_handle, RAR_SKIP, NULL, NULL);
}
@@ -371,7 +371,7 @@ int _rar_list_files(rar_file_t *rar TSRMLS_DC) /* {{{ */
#if ULONG_MAX > 0xffffffffUL
packed_size += ((unsigned long) entry.PackSizeHigh) << 32;
#else
- packed_size = ULONG_MAX; //cap
+ packed_size = ULONG_MAX; /* cap */
#endif
}
}
@@ -381,7 +381,7 @@ int _rar_list_files(rar_file_t *rar TSRMLS_DC) /* {{{ */
/* commit the entry */
assert(capacity >= ents->num_entries);
- if (capacity == ents->num_entries) { //0, 2, 6, 14, 30...
+ if (capacity == ents->num_entries) { /* 0, 2, 6, 14, 30... */
capacity = (capacity + 1) * 2;
ents->entries_array = safe_erealloc(ents->entries_array, capacity,
sizeof(*ents->entries_array), 0);
View
@@ -112,7 +112,7 @@ static size_t php_rar_ops_read(php_stream *stream, char *buf, size_t count TSRML
if (self->buffer != NULL && self->rar_handle != NULL) {
while (left > 0) {
size_t this_read_size;
- //if nothing in the buffer or buffer already read, fill buffer
+ /* if nothing in the buffer or buffer already read, fill buffer */
if (/*self->buffer_cont_size == 0 || > condition not necessary */
self->buffer_pos == self->buffer_cont_size)
{
@@ -131,14 +131,14 @@ static size_t php_rar_ops_read(php_stream *stream, char *buf, size_t count TSRML
self->buffer_size, &self->buffer_cont_size,
&self->no_more_data);
if (_rar_handle_error(res TSRMLS_CC) == FAILURE) {
- break; //finish in case of failure
+ break; /* finish in case of failure */
}
assert(self->buffer_cont_size <= self->buffer_size);
- //we did not read anything. no need to continue
+ /* we did not read anything. no need to continue */
if (self->buffer_cont_size == 0)
break;
}
- //if we get here we have data to be read in the buffer
+ /* if we get here we have data to be read in the buffer */
this_read_size = MIN(left,
self->buffer_cont_size - self->buffer_pos);
assert(this_read_size > 0);
@@ -202,7 +202,7 @@ static int php_rar_ops_close(php_stream *stream, int close_handle TSRMLS_DC)
if (close_handle) {
int res = RARCloseArchive(self->rar_handle);
if (_rar_handle_error(res TSRMLS_CC) == FAILURE) {
- ; //not much we can do...
+ ; /* not much we can do... */
}
}
self->rar_handle = NULL;
@@ -367,7 +367,7 @@ static int _rar_stat_from_header(struct RARHeaderDataEx *header,
ssb->sb.st_blocks = 0;
#endif
/* php_stat in filestat.c doesn't check this one, so don't touch it */
- //ssb->sb.st_attr = ;
+ /* ssb->sb.st_attr = ; */
return SUCCESS;
}
@@ -470,7 +470,7 @@ static int php_rar_dir_ops_stat(php_stream *stream, php_stream_statbuf *ssb TSRM
{
STREAM_DIR_DATA_FROM_STREAM
- if (self->self_header == NULL) { //root
+ if (self->self_header == NULL) { /* root */
/* RAR root has no entry, so we make something up.
* We could use the RAR archive itself instead, but I think that would
* not be very consistent */
@@ -511,7 +511,7 @@ php_stream *php_stream_rar_open(char *arc_name,
int result,
found;
- //mode must be exactly "r"
+ /* mode must be exactly "r" */
if (strncmp(mode, "r", sizeof("r")) != 0) {
goto cleanup;
}
@@ -538,7 +538,7 @@ php_stream *php_stream_rar_open(char *arc_name,
_rar_handle_ext_error("Can't find file with index %u in archive %s"
TSRMLS_CC, position, arc_name);
else {
- //no need to allocate a buffer bigger than the file uncomp size
+ /* no need to allocate a buffer bigger than the file uncomp size */
size_t buffer_size = (size_t)
MIN((uint64) RAR_CHUNK_BUFFER_SIZE,
INT32TO64(self->header_data.UnpSizeHigh,
@@ -556,7 +556,7 @@ php_stream *php_stream_rar_open(char *arc_name,
}
cleanup:
- if (stream == NULL) { //failed
+ if (stream == NULL) { /* failed */
if (self != NULL) {
if (self->open_data.ArcName != NULL)
efree(self->open_data.ArcName);
@@ -642,7 +642,7 @@ static void php_rar_process_context(php_stream_context *context,
php_stream_wrapper *wrapper,
int options,
char **open_password,
- char **file_password, //can be NULL
+ char **file_password, /* can be NULL */
zval **volume_cb TSRMLS_DC)
{
zval **ctx_opt = NULL;
@@ -762,7 +762,7 @@ static int _rar_get_archive_and_fragment(php_stream_wrapper *wrapper,
if (!(options & STREAM_DISABLE_OPEN_BASEDIR) &&
php_check_open_basedir(*archive TSRMLS_CC)) {
- //php_check_open_basedir already emits the error
+ /* php_check_open_basedir already emits the error */
goto cleanup;
}
@@ -842,7 +842,7 @@ static php_stream *php_stream_rar_opener(php_stream_wrapper *wrapper,
return NULL;
}
- //mode must be exactly "r"
+ /* mode must be exactly "r" */
if (strncmp(mode, "r", sizeof("r")) != 0) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC,
"Only the \"r\" open mode is permitted, given %s", mode);
@@ -903,7 +903,7 @@ static php_stream *php_stream_rar_opener(php_stream_wrapper *wrapper,
{
- //no need to allocate a buffer bigger than the file uncomp size
+ /* no need to allocate a buffer bigger than the file uncomp size */
size_t buffer_size = (size_t)
MIN((uint64) RAR_CHUNK_BUFFER_SIZE,
INT32TO64(self->header_data.UnpSizeHigh,
@@ -938,7 +938,7 @@ static php_stream *php_stream_rar_opener(php_stream_wrapper *wrapper,
if (fragment != NULL)
efree(fragment);
- if (stream == NULL) { //failed
+ if (stream == NULL) { /* failed */
if (self != NULL) {
if (self->open_data.ArcName != NULL)
efree(self->open_data.ArcName);
@@ -1189,7 +1189,7 @@ static php_stream *php_stream_rar_dir_opener(php_stream_wrapper *wrapper,
return NULL;
}
- //mode must be exactly "r"
+ /* mode must be exactly "r" */
if (strncmp(mode, "r", sizeof("r")) != 0) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC,
"Only the \"r\" open mode is permitted, given %s", mode);
@@ -1273,7 +1273,7 @@ static php_stream *php_stream_rar_dir_opener(php_stream_wrapper *wrapper,
if (fragment != NULL)
efree(fragment);
- if (stream == NULL) { //failed
+ if (stream == NULL) { /* failed */
if (self != NULL) {
if (self->rar_obj != NULL)
zval_ptr_dtor(&self->rar_obj);
Oops, something went wrong.

0 comments on commit b92bcc5

Please sign in to comment.