[aravis] zip: add more debug output.



commit 565a5988b7e7630eac74fa5cd770d2293a1e0b6c
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Thu Jun 28 11:28:26 2012 +0200

    zip: add more debug output.

 src/arvzip.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/arvzip.c b/src/arvzip.c
index 2c738c1..b4e03f3 100644
--- a/src/arvzip.c
+++ b/src/arvzip.c
@@ -87,7 +87,10 @@ arv_zip_build_file_list (ArvZip *zip)
 
 	for (i = 0; i < zip->n_files; i++) {
 		ptr = zip->buffer + zip->header_size + offset;
-		if (GUINT32_FROM_LE_PTR (ptr) != 0x02014b50) return;
+		if (GUINT32_FROM_LE_PTR (ptr) != 0x02014b50) {
+			arv_debug_misc ("[Zip::build_file_list] Magic number of central directory not found (0x02014b50)");
+		       	return;
+		}
 
 		zip_file = g_new0 (ArvZipFile, 1);
                 zip_file->compressed_size = GUINT32_FROM_LE_PTR (ptr + 20);
@@ -95,7 +98,7 @@ arv_zip_build_file_list (ArvZip *zip)
                 zip_file->offset = GUINT32_FROM_LE_PTR (ptr + 42);
 		zip_file->name = g_strndup ((char *) (ptr + 46), GUINT16_FROM_LE_PTR (ptr + 28));
 
-		arv_debug_misc ("[Zip::list_files] %s", zip_file->name);
+		arv_log_misc ("[Zip::list_files] %s", zip_file->name);
 
 		zip->files = g_slist_prepend (zip->files, zip_file);
 
@@ -128,7 +131,10 @@ arv_zip_get_file_data (ArvZip *zip, ArvZipFile *zip_file)
 
 	ptr = zip->buffer + zip_file->offset + zip->header_size;
 
-        if (GUINT32_FROM_LE_PTR (ptr) != 0x04034b50) return -1;
+        if (GUINT32_FROM_LE_PTR (ptr) != 0x04034b50) {
+		arv_debug_misc ("[Zip::get_file_data] Magic number for file header not found (0x04034b50)");
+	       	return -1;
+	}
 
 	return zip_file->offset + zip->header_size +
 		GUINT16_FROM_LE_PTR (ptr + 26) +
@@ -168,12 +174,15 @@ arv_zip_new (const void *buffer, size_t size)
                         break;
                 }
         }
-	if (!directory_found)
+	if (!directory_found) {
+		arv_debug_misc ("[Zip::new] Magic number for end of central directory not found (0x06054b50)");
 		return zip;
+	}
 
 	ptr = zip->buffer + zip->directory_position;
         zip->n_files = GUINT16_FROM_LE_PTR (ptr + 10);
         if (GUINT16_FROM_LE_PTR (ptr + 8) != zip->n_files) {
+		arv_debug_misc ("[Zip::new] Mismatch in number of files");
 		zip->n_files = 0;
 		return zip;
         }
@@ -182,6 +191,8 @@ arv_zip_new (const void *buffer, size_t size)
         zip->directory_offset = GUINT32_FROM_LE_PTR (ptr + 16);
         zip->header_size = zip->directory_position - (zip->directory_offset + zip->directory_size);
 
+	arv_log_misc ("[Zip::new] number of files = %d", zip->n_files);
+
         arv_zip_build_file_list (zip);
 
         return zip;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]