/* Uncompressed size of the resource, in bytes. */
le64 uncompressed_size;
-} _packed_attribute;
+} __attribute__((packed));
/* In-memory version of a WIM resource header (`struct wim_reshdr_disk'). */
struct wim_reshdr {
memset(reshdr, 0, sizeof(struct wim_reshdr));
}
-extern void
+void
wim_reshdr_to_desc(const struct wim_reshdr *reshdr, WIMStruct *wim,
struct wim_resource_descriptor *rdesc);
-extern void
+void
wim_reshdr_to_desc_and_blob(const struct wim_reshdr *reshdr, WIMStruct *wim,
struct wim_resource_descriptor *rdesc,
struct blob_descriptor *blob);
-extern void
+void
get_wim_reshdr(const struct wim_reshdr_disk *disk_reshdr,
struct wim_reshdr *reshdr);
-extern void
+void
put_wim_reshdr(const struct wim_reshdr *reshdr,
struct wim_reshdr_disk *disk_reshdr);
/* This header is directly followed by a table of compressed sizes of
* the chunks (4 bytes per entry). */
-} _packed_attribute;
+} __attribute__((packed));
static inline unsigned int
get_chunk_entry_size(u64 res_size, bool is_alt)
/* Functions to read blobs */
-extern int
+int
read_partial_wim_blob_into_buf(const struct blob_descriptor *blob,
u64 offset, size_t size, void *buf);
-extern int
+int
read_blob_into_buf(const struct blob_descriptor *blob, void *buf);
-extern int
+int
read_blob_into_alloc_buf(const struct blob_descriptor *blob, void **buf_ret);
-extern int
+int
wim_reshdr_to_data(const struct wim_reshdr *reshdr, WIMStruct *wim,
void **buf_ret);
-extern int
+int
wim_reshdr_to_hash(const struct wim_reshdr *reshdr, WIMStruct *wim,
u8 hash[SHA1_HASH_SIZE]);
-extern int
+int
skip_wim_resource(const struct wim_resource_descriptor *rdesc);
+/*
+ * Callback function for reading chunks. Called whenever the next chunk of
+ * uncompressed data is available, passing 'ctx' as the last argument. 'size' is
+ * guaranteed to be nonzero. Must return 0 on success, or a positive wimlib
+ * error code on failure.
+ */
+struct consume_chunk_callback {
+ int (*func)(const void *chunk, size_t size, void *ctx);
+ void *ctx;
+};
+
+/* Pass a chunk of data to the specified consume_chunk callback */
+static inline int
+consume_chunk(const struct consume_chunk_callback *cb,
+ const void *chunk, size_t size)
+{
+ return (*cb->func)(chunk, size, cb->ctx);
+}
+
/* Callback functions for reading blobs */
struct read_blob_callbacks {
/* Called when the next chunk of uncompressed data is available. 'size'
* is guaranteed to be nonzero. Must return 0 on success, or a positive
* wimlib error code on failure. */
- int (*consume_chunk)(const void *chunk, size_t size, void *ctx);
+ int (*continue_blob)(const struct blob_descriptor *blob, u64 offset,
+ const void *chunk, size_t size, void *ctx);
/* Called when a blob has been successfully read (status=0), or when
* begin_blob() was successfully called but an error occurred before the
return (*cbs->begin_blob)(blob, cbs->ctx);
}
-/* Call cbs->consume_chunk() if present. */
+/* Call cbs->continue_blob() if present. */
static inline int
-call_consume_chunk(const void *chunk, size_t size,
+call_continue_blob(const struct blob_descriptor *blob, u64 offset,
+ const void *chunk, size_t size,
const struct read_blob_callbacks *cbs)
{
- if (!cbs->consume_chunk)
+ if (!cbs->continue_blob)
return 0;
- return (*cbs->consume_chunk)(chunk, size, cbs->ctx);
+ return (*cbs->continue_blob)(blob, offset, chunk, size, cbs->ctx);
}
/* Call cbs->end_blob() if present. */
#define VERIFY_BLOB_HASHES 0x1
#define COMPUTE_MISSING_BLOB_HASHES 0x2
#define BLOB_LIST_ALREADY_SORTED 0x4
+#define RECOVER_DATA 0x8
-extern int
+int
read_blob_list(struct list_head *blob_list, size_t list_head_offset,
const struct read_blob_callbacks *cbs, int flags);
-extern int
+int
read_blob_with_cbs(struct blob_descriptor *blob,
- const struct read_blob_callbacks *cbs);
+ const struct read_blob_callbacks *cbs, bool recover_data);
-extern int
+int
read_blob_with_sha1(struct blob_descriptor *blob,
- const struct read_blob_callbacks *cbs);
+ const struct read_blob_callbacks *cbs, bool recover_data);
-extern int
+int
extract_blob_prefix_to_fd(struct blob_descriptor *blob, u64 size,
struct filedes *fd);
-extern int
-extract_blob_to_fd(struct blob_descriptor *blob, struct filedes *fd);
+int
+extract_blob_to_fd(struct blob_descriptor *blob, struct filedes *fd,
+ bool recover_data);
/* Miscellaneous blob functions. */
-extern int
+int
sha1_blob(struct blob_descriptor *blob);
/* Functions to read/write metadata resources. */
-extern int
+int
read_metadata_resource(struct wim_image_metadata *imd);
-extern int
+int
write_metadata_resource(WIMStruct *wim, int image, int write_resource_flags);
/* Definitions specific to pipable WIM resources. */
u8 hash[SHA1_HASH_SIZE]; /* +16 */
le32 flags; /* +36 */
/* +40 */
-} _packed_attribute;
+} __attribute__((packed));
/* Header that precedes each chunk of a compressed resource in a pipable WIM.
*/
struct pwm_chunk_hdr {
le32 compressed_size;
-} _packed_attribute;
+} __attribute__((packed));
#endif /* _WIMLIB_RESOURCE_H */