]> wimlib.net Git - wimlib/commitdiff
print_lookup_table_entry(): add FILE* parameter
authorEric Biggers <ebiggers3@gmail.com>
Sun, 3 Mar 2013 20:29:24 +0000 (14:29 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 3 Mar 2013 21:56:47 +0000 (15:56 -0600)
src/dentry.c
src/lookup_table.c
src/lookup_table.h
src/resource.c
src/verify.c
src/write.c

index 81a04d2b1534408e7c44580fb40c9cee991e5c86..35a89d11e06238f98a8c5e68584dc0c291091062 100644 (file)
@@ -745,7 +745,7 @@ int print_dentry(struct wim_dentry *dentry, void *lookup_table)
        printf("Full Path (UTF-8) = \"%s\"\n", dentry->full_path_utf8);
        lte = inode_stream_lte(dentry->d_inode, 0, lookup_table);
        if (lte) {
        printf("Full Path (UTF-8) = \"%s\"\n", dentry->full_path_utf8);
        lte = inode_stream_lte(dentry->d_inode, 0, lookup_table);
        if (lte) {
-               print_lookup_table_entry(lte);
+               print_lookup_table_entry(lte, stdout);
        } else {
                hash = inode_stream_hash(inode, 0);
                if (hash) {
        } else {
                hash = inode_stream_hash(inode, 0);
                if (hash) {
@@ -766,8 +766,8 @@ int print_dentry(struct wim_dentry *dentry, void *lookup_table)
                        print_hash(hash);
                        putchar('\n');
                }
                        print_hash(hash);
                        putchar('\n');
                }
-               print_lookup_table_entry(inode_stream_lte(inode, i + 1,
-                                                         lookup_table));
+               print_lookup_table_entry(inode_stream_lte(inode, i + 1, lookup_table),
+                                        stdout);
        }
        return 0;
 }
        }
        return 0;
 }
index 7e1155b1ef376a4adbd280de89f2fedecf07981f..390f63c5934401ebf810466254d90ff6b6ac0305 100644 (file)
@@ -348,9 +348,9 @@ int read_lookup_table(WIMStruct *w)
                        ERROR("The WIM lookup table contains two entries with the "
                              "same SHA1 message digest!");
                        ERROR("The first entry is:");
                        ERROR("The WIM lookup table contains two entries with the "
                              "same SHA1 message digest!");
                        ERROR("The first entry is:");
-                       print_lookup_table_entry(duplicate_entry);
+                       print_lookup_table_entry(duplicate_entry, stderr);
                        ERROR("The second entry is:");
                        ERROR("The second entry is:");
-                       print_lookup_table_entry(cur_entry);
+                       print_lookup_table_entry(cur_entry, stderr);
                #endif
                        ret = WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY;
                        goto out_free_cur_entry;
                #endif
                        ret = WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY;
                        goto out_free_cur_entry;
@@ -364,7 +364,7 @@ int read_lookup_table(WIMStruct *w)
                        ERROR("Found uncompressed resource with original size "
                              "not the same as compressed size");
                        ERROR("The lookup table entry for the resource is as follows:");
                        ERROR("Found uncompressed resource with original size "
                              "not the same as compressed size");
                        ERROR("The lookup table entry for the resource is as follows:");
-                       print_lookup_table_entry(cur_entry);
+                       print_lookup_table_entry(cur_entry, stderr);
                #endif
                        ret = WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY;
                        goto out_free_cur_entry;
                #endif
                        ret = WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY;
                        goto out_free_cur_entry;
@@ -374,7 +374,7 @@ int read_lookup_table(WIMStruct *w)
                {
                #ifdef ENABLE_ERROR_MESSAGES
                        ERROR("Found metadata resource with refcnt != 1:");
                {
                #ifdef ENABLE_ERROR_MESSAGES
                        ERROR("Found metadata resource with refcnt != 1:");
-                       print_lookup_table_entry(cur_entry);
+                       print_lookup_table_entry(cur_entry, stderr);
                #endif
                        ret = WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY;
                        goto out_free_cur_entry;
                #endif
                        ret = WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY;
                        goto out_free_cur_entry;
@@ -475,57 +475,58 @@ int lte_free_extracted_file(struct wim_lookup_table_entry *lte, void *ignore)
        return 0;
 }
 
        return 0;
 }
 
-void print_lookup_table_entry(const struct wim_lookup_table_entry *lte)
+void print_lookup_table_entry(const struct wim_lookup_table_entry *lte,
+                             FILE *out)
 {
        if (!lte) {
 {
        if (!lte) {
-               putchar('\n');
+               putc('\n', out);
                return;
        }
                return;
        }
-       printf("Offset            = %"PRIu64" bytes\n",
+       fprintf(out, "Offset            = %"PRIu64" bytes\n",
               lte->resource_entry.offset);
               lte->resource_entry.offset);
-       printf("Size              = %"PRIu64" bytes\n",
+       fprintf(out, "Size              = %"PRIu64" bytes\n",
               (u64)lte->resource_entry.size);
               (u64)lte->resource_entry.size);
-       printf("Original size     = %"PRIu64" bytes\n",
+       fprintf(out, "Original size     = %"PRIu64" bytes\n",
               lte->resource_entry.original_size);
               lte->resource_entry.original_size);
-       printf("Part Number       = %hu\n", lte->part_number);
-       printf("Reference Count   = %u\n", lte->refcnt);
-       printf("Hash              = 0x");
+       fprintf(out, "Part Number       = %hu\n", lte->part_number);
+       fprintf(out, "Reference Count   = %u\n", lte->refcnt);
+       fprintf(out, "Hash              = 0x");
        print_hash(lte->hash);
        print_hash(lte->hash);
-       putchar('\n');
-       printf("Flags             = ");
+       putc('\n', out);
+       fprintf(out, "Flags             = ");
        u8 flags = lte->resource_entry.flags;
        if (flags & WIM_RESHDR_FLAG_COMPRESSED)
        u8 flags = lte->resource_entry.flags;
        if (flags & WIM_RESHDR_FLAG_COMPRESSED)
-               fputs("WIM_RESHDR_FLAG_COMPRESSED, ", stdout);
+               fputs("WIM_RESHDR_FLAG_COMPRESSED, ", out);
        if (flags & WIM_RESHDR_FLAG_FREE)
        if (flags & WIM_RESHDR_FLAG_FREE)
-               fputs("WIM_RESHDR_FLAG_FREE, ", stdout);
+               fputs("WIM_RESHDR_FLAG_FREE, ", out);
        if (flags & WIM_RESHDR_FLAG_METADATA)
        if (flags & WIM_RESHDR_FLAG_METADATA)
-               fputs("WIM_RESHDR_FLAG_METADATA, ", stdout);
+               fputs("WIM_RESHDR_FLAG_METADATA, ", out);
        if (flags & WIM_RESHDR_FLAG_SPANNED)
        if (flags & WIM_RESHDR_FLAG_SPANNED)
-               fputs("WIM_RESHDR_FLAG_SPANNED, ", stdout);
-       putchar('\n');
+               fputs("WIM_RESHDR_FLAG_SPANNED, ", out);
+       putc('\n', out);
        switch (lte->resource_location) {
        case RESOURCE_IN_WIM:
                if (lte->wim->filename) {
        switch (lte->resource_location) {
        case RESOURCE_IN_WIM:
                if (lte->wim->filename) {
-                       printf("WIM file          = `%s'\n",
+                       fprintf(out, "WIM file          = `%s'\n",
                               lte->wim->filename);
                }
                break;
        case RESOURCE_IN_FILE_ON_DISK:
                               lte->wim->filename);
                }
                break;
        case RESOURCE_IN_FILE_ON_DISK:
-               printf("File on Disk      = `%s'\n", lte->file_on_disk);
+               fprintf(out, "File on Disk      = `%s'\n", lte->file_on_disk);
                break;
        case RESOURCE_IN_STAGING_FILE:
                break;
        case RESOURCE_IN_STAGING_FILE:
-               printf("Staging File      = `%s'\n", lte->staging_file_name);
+               fprintf(out, "Staging File      = `%s'\n", lte->staging_file_name);
                break;
        default:
                break;
        }
                break;
        default:
                break;
        }
-       putchar('\n');
+       putc('\n', out);
 }
 
 static int do_print_lookup_table_entry(struct wim_lookup_table_entry *lte,
 }
 
 static int do_print_lookup_table_entry(struct wim_lookup_table_entry *lte,
-                                      void *ignore)
+                                      void *fp)
 {
 {
-       print_lookup_table_entry(lte);
+       print_lookup_table_entry(lte, (FILE*)fp);
        return 0;
 }
 
        return 0;
 }
 
@@ -536,7 +537,7 @@ WIMLIBAPI void wimlib_print_lookup_table(WIMStruct *w)
 {
        for_lookup_table_entry(w->lookup_table,
                               do_print_lookup_table_entry,
 {
        for_lookup_table_entry(w->lookup_table,
                               do_print_lookup_table_entry,
-                              NULL);
+                              stdout);
 }
 
 /* Given a SHA1 message digest, return the corresponding entry in the WIM's
 }
 
 /* Given a SHA1 message digest, return the corresponding entry in the WIM's
index 8de9f075683aa0934bb3271e1d7170f9c4f9035b..92428b124d9dff1ba9ab05f7e3c3084c3a02a75d 100644 (file)
@@ -271,7 +271,8 @@ extern struct wim_lookup_table_entry *
 clone_lookup_table_entry(const struct wim_lookup_table_entry *lte);
 
 extern void
 clone_lookup_table_entry(const struct wim_lookup_table_entry *lte);
 
 extern void
-print_lookup_table_entry(const struct wim_lookup_table_entry *entry);
+print_lookup_table_entry(const struct wim_lookup_table_entry *entry,
+                        FILE *out);
 
 extern void
 free_lookup_table_entry(struct wim_lookup_table_entry *lte);
 
 extern void
 free_lookup_table_entry(struct wim_lookup_table_entry *lte);
index 3c0804b0d3a98c4f9f5e83b8afe21f8c90cf769b..e8f1114412b5940b07fe8db69caba304772eb6ae 100644 (file)
@@ -644,7 +644,7 @@ int extract_wim_resource(const struct wim_lookup_table_entry *lte,
                if (!hashes_equal(hash, lte->hash)) {
                #ifdef ENABLE_ERROR_MESSAGES
                        ERROR("Invalid checksum on the following WIM resource:");
                if (!hashes_equal(hash, lte->hash)) {
                #ifdef ENABLE_ERROR_MESSAGES
                        ERROR("Invalid checksum on the following WIM resource:");
-                       print_lookup_table_entry(lte);
+                       print_lookup_table_entry(lte, stderr);
                #endif
                        return WIMLIB_ERR_INVALID_RESOURCE_HASH;
                }
                #endif
                        return WIMLIB_ERR_INVALID_RESOURCE_HASH;
                }
index dd9d4f7e6fbeafdbda7809ff6b650df1757c883f..b6bdbe63b8ae68acd5821bc9c462454e545c36b5 100644 (file)
@@ -212,11 +212,13 @@ static int image_run_full_verifications(WIMStruct *w)
 static int lte_fix_refcnt(struct wim_lookup_table_entry *lte, void *ctr)
 {
        if (lte->refcnt != lte->real_refcnt) {
 static int lte_fix_refcnt(struct wim_lookup_table_entry *lte, void *ctr)
 {
        if (lte->refcnt != lte->real_refcnt) {
+       #ifdef ENABLE_ERROR_MESSAGES
                WARNING("The following lookup table entry has a reference "
                        "count of %u, but", lte->refcnt);
                WARNING("We found %u references to it",
                        lte->real_refcnt);
                WARNING("The following lookup table entry has a reference "
                        "count of %u, but", lte->refcnt);
                WARNING("We found %u references to it",
                        lte->real_refcnt);
-               print_lookup_table_entry(lte);
+               print_lookup_table_entry(lte, stderr);
+       #endif
                lte->refcnt = lte->real_refcnt;
                ++*(unsigned long *)ctr;
        }
                lte->refcnt = lte->real_refcnt;
                ++*(unsigned long *)ctr;
        }
index 86730ff7fec7a1158b6ed8bed305ec784b9375aa..1f471d6fead32e046b969efa428b7abf1094b04e 100644 (file)
@@ -1353,8 +1353,10 @@ static int lte_overwrite_prepare(struct wim_lookup_table_entry *lte, void *arg)
            lte->wim == args->wim &&
            lte->resource_entry.offset + lte->resource_entry.size > args->end_offset)
        {
            lte->wim == args->wim &&
            lte->resource_entry.offset + lte->resource_entry.size > args->end_offset)
        {
+       #ifdef ENABLE_ERROR_MESSAGES
                ERROR("The following resource is after the XML data:");
                ERROR("The following resource is after the XML data:");
-               print_lookup_table_entry(lte);
+               print_lookup_table_entry(lte, stderr);
+       #endif
                return WIMLIB_ERR_RESOURCE_ORDER;
        }
 
                return WIMLIB_ERR_RESOURCE_ORDER;
        }