-void
-print_lookup_table_entry(const struct wim_lookup_table_entry *lte, FILE *out)
-{
- if (!lte) {
- tputc(T('\n'), out);
- return;
- }
- tfprintf(out, T("Offset = %"PRIu64" bytes\n"),
- lte->resource_entry.offset);
-
- tfprintf(out, T("Size = %"PRIu64" bytes\n"),
- (u64)lte->resource_entry.size);
-
- tfprintf(out, T("Original size = %"PRIu64" bytes\n"),
- lte->resource_entry.original_size);
-
- tfprintf(out, T("Part Number = %hu\n"), lte->part_number);
- tfprintf(out, T("Reference Count = %u\n"), lte->refcnt);
-
- if (lte->unhashed) {
- tfprintf(out, T("(Unhashed: inode %p, stream_id = %u)\n"),
- lte->back_inode, lte->back_stream_id);
- } else {
- tfprintf(out, T("Hash = 0x"));
- print_hash(lte->hash, out);
- tputc(T('\n'), out);
- }
-
- tfprintf(out, T("Flags = "));
- u8 flags = lte->resource_entry.flags;
- if (flags & WIM_RESHDR_FLAG_COMPRESSED)
- tfputs(T("WIM_RESHDR_FLAG_COMPRESSED, "), out);
- if (flags & WIM_RESHDR_FLAG_FREE)
- tfputs(T("WIM_RESHDR_FLAG_FREE, "), out);
- if (flags & WIM_RESHDR_FLAG_METADATA)
- tfputs(T("WIM_RESHDR_FLAG_METADATA, "), out);
- if (flags & WIM_RESHDR_FLAG_SPANNED)
- tfputs(T("WIM_RESHDR_FLAG_SPANNED, "), out);
- tputc(T('\n'), out);
- switch (lte->resource_location) {
- case RESOURCE_IN_WIM:
- if (lte->wim->filename) {
- tfprintf(out, T("WIM file = `%"TS"'\n"),
- lte->wim->filename);
- }
- break;
-#ifdef __WIN32__
- case RESOURCE_WIN32:
- case RESOURCE_WIN32_ENCRYPTED:
-#else
- case RESOURCE_IN_FILE_ON_DISK:
-#endif
- tfprintf(out, T("File on Disk = `%"TS"'\n"),
- lte->file_on_disk);
- break;
-#ifdef WITH_FUSE
- case RESOURCE_IN_STAGING_FILE:
- tfprintf(out, T("Staging File = `%"TS"'\n"),
- lte->staging_file_name);
- break;
-#endif
- default:
- break;
- }
- tputc(T('\n'), out);
-}
-
-void
-lte_to_wimlib_resource_entry(const struct wim_lookup_table_entry *lte,
- struct wimlib_resource_entry *wentry)
-{
- wentry->uncompressed_size = lte->resource_entry.original_size;
- wentry->compressed_size = lte->resource_entry.size;
- wentry->offset = lte->resource_entry.offset;
- copy_hash(wentry->sha1_hash, lte->hash);
- wentry->part_number = lte->part_number;
- wentry->reference_count = lte->refcnt;
- wentry->is_compressed = (lte->resource_entry.flags & WIM_RESHDR_FLAG_COMPRESSED) != 0;
- wentry->is_metadata = (lte->resource_entry.flags & WIM_RESHDR_FLAG_METADATA) != 0;
- wentry->is_free = (lte->resource_entry.flags & WIM_RESHDR_FLAG_FREE) != 0;
- wentry->is_spanned = (lte->resource_entry.flags & WIM_RESHDR_FLAG_SPANNED) != 0;
-}
-
-struct iterate_lte_context {
- wimlib_iterate_lookup_table_callback_t cb;
- void *user_ctx;
-};
-
-static int
-do_iterate_lte(struct wim_lookup_table_entry *lte, void *_ctx)
-{
- struct iterate_lte_context *ctx = _ctx;
- struct wimlib_resource_entry entry;
-
- lte_to_wimlib_resource_entry(lte, &entry);
- return (*ctx->cb)(&entry, ctx->user_ctx);
-}
-
-WIMLIBAPI int
-wimlib_iterate_lookup_table(WIMStruct *wim, int flags,
- wimlib_iterate_lookup_table_callback_t cb,
- void *user_ctx)
-{
- struct iterate_lte_context ctx = {
- .cb = cb,
- .user_ctx = user_ctx,
- };
- if (wim->hdr.part_number == 1) {
- int ret;
- for (int i = 0; i < wim->hdr.image_count; i++) {
- ret = do_iterate_lte(wim->image_metadata[i]->metadata_lte,
- &ctx);
- if (ret)
- return ret;
- }
- }
- return for_lookup_table_entry(wim->lookup_table, do_iterate_lte, &ctx);
-}
-
-static int
-do_print_lookup_table_entry(struct wim_lookup_table_entry *lte, void *fp)
-{
- print_lookup_table_entry(lte, (FILE*)fp);
- return 0;
-}
-
-/*
- * Deprecated
- */
-WIMLIBAPI void
-wimlib_print_lookup_table(WIMStruct *wim)
-{
- for (int i = 0; i < wim->hdr.image_count; i++)
- print_lookup_table_entry(wim->image_metadata[i]->metadata_lte, stdout);
- for_lookup_table_entry(wim->lookup_table,
- do_print_lookup_table_entry,
- stdout);
-}
-
-/* Given a SHA1 message digest, return the corresponding entry in the WIM's
- * lookup table, or NULL if there is none. */