]> wimlib.net Git - wimlib/blobdiff - src/lookup_table.c
Win32: Add untested support for encryted capture
[wimlib] / src / lookup_table.c
index 0ebaf61eb503848ff6d5262e7751013b34715056..f22bfaf7cf7df4c995065b81eb0ba10a9af77b65 100644 (file)
@@ -89,15 +89,16 @@ clone_lookup_table_entry(const struct wim_lookup_table_entry *old)
 #ifdef __WIN32__
        case RESOURCE_WIN32:
        case RESOURCE_WIN32_ENCRYPTED:
+#else
+       case RESOURCE_IN_FILE_ON_DISK:
 #endif
 #ifdef WITH_FUSE
        case RESOURCE_IN_STAGING_FILE:
-#endif
-       case RESOURCE_IN_FILE_ON_DISK:
                BUILD_BUG_ON((void*)&old->file_on_disk !=
                             (void*)&old->staging_file_name);
-               new->staging_file_name = TSTRDUP(old->staging_file_name);
-               if (!new->staging_file_name)
+#endif
+               new->file_on_disk = TSTRDUP(old->file_on_disk);
+               if (!new->file_on_disk)
                        goto out_free;
                break;
        case RESOURCE_IN_ATTACHED_BUFFER:
@@ -144,14 +145,18 @@ free_lookup_table_entry(struct wim_lookup_table_entry *lte)
 {
        if (lte) {
                switch (lte->resource_location) {
-               case RESOURCE_IN_STAGING_FILE:
-               case RESOURCE_IN_ATTACHED_BUFFER:
-               case RESOURCE_IN_FILE_ON_DISK:
-#ifdef __WIN32__
+       #ifdef __WIN32__
                case RESOURCE_WIN32:
-#endif
+               case RESOURCE_WIN32_ENCRYPTED:
+       #else
+               case RESOURCE_IN_FILE_ON_DISK:
+       #endif
+       #ifdef WITH_FUSE
+               case RESOURCE_IN_STAGING_FILE:
                        BUILD_BUG_ON((void*)&lte->file_on_disk !=
                                     (void*)&lte->staging_file_name);
+       #endif
+               case RESOURCE_IN_ATTACHED_BUFFER:
                        BUILD_BUG_ON((void*)&lte->file_on_disk !=
                                     (void*)&lte->attached_buffer);
                        FREE(lte->file_on_disk);
@@ -595,23 +600,22 @@ write_lookup_table(WIMStruct *w, int image, struct resource_entry *out_res_entry
        return 0;
 }
 
-
 int
-lte_zero_real_refcnt(struct wim_lookup_table_entry *lte, void *ignore)
+lte_zero_real_refcnt(struct wim_lookup_table_entry *lte, void *_ignore)
 {
        lte->real_refcnt = 0;
        return 0;
 }
 
 int
-lte_zero_out_refcnt(struct wim_lookup_table_entry *lte, void *ignore)
+lte_zero_out_refcnt(struct wim_lookup_table_entry *lte, void *_ignore)
 {
        lte->out_refcnt = 0;
        return 0;
 }
 
 int
-lte_free_extracted_file(struct wim_lookup_table_entry *lte, void *ignore)
+lte_free_extracted_file(struct wim_lookup_table_entry *lte, void *_ignore)
 {
        if (lte->extracted_file != NULL) {
                FREE(lte->extracted_file);
@@ -668,15 +672,19 @@ print_lookup_table_entry(const struct wim_lookup_table_entry *lte, FILE *out)
                break;
 #ifdef __WIN32__
        case RESOURCE_WIN32:
-#endif
+       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;
        }
@@ -915,6 +923,19 @@ retrieve_lte_pointer(struct wim_lookup_table_entry *lte)
        return NULL;
 }
 
+/* Calculate the SHA1 message digest of a stream and move it from the list of
+ * unhashed streams to the stream lookup table, possibly joining it with an
+ * existing lookup table entry for an identical stream.
+ *
+ * @lte:  An unhashed lookup table entry.
+ * @lookup_table:  Lookup table for the WIM.
+ * @lte_ret:  On success, write a pointer to the resulting lookup table
+ *            entry to this location.  This will be the same as @lte
+ *            if it was inserted into the lookup table, or different if
+ *            a duplicate stream was found.
+ *
+ * Returns 0 on success; nonzero if there is an error reading the stream.
+ */
 int
 hash_unhashed_stream(struct wim_lookup_table_entry *lte,
                     struct wim_lookup_table *lookup_table,
@@ -953,9 +974,7 @@ hash_unhashed_stream(struct wim_lookup_table_entry *lte,
                /* No duplicate stream, so we need to insert
                 * this stream into the lookup table and treat
                 * it as a hashed stream. */
-               list_del(&lte->unhashed_list);
                lookup_table_insert(lookup_table, lte);
-               lte->out_refcnt = lte->refcnt;
                lte->unhashed = 0;
        }
        if (lte_ret)