Word Unperfect
public
Read
Owner: themaster
Branch: main
Commits: 0
Git CLI clone URL
git clone https://www.xt-emporium.com/git/word-unperfect.git
Fullscreen desktop URL
Code
Commits
History
Branches
Bug Reports
Discussions
Compare
Settings
word-unperfect
/
rev
/
wp_file_format.h
File editor
#ifndef WP_FILE_FORMAT_H #define WP_FILE_FORMAT_H #include "wp_layout_shared.h" #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #define WP_FILE_PREFIX_SIZE 16U enum { WP_FILE_VALIDATE_OK = 0x00000000U, WP_FILE_VALIDATE_NULL_FILE = 0x00000001U, WP_FILE_VALIDATE_BAD_SIGNATURE = 0x00000002U, WP_FILE_VALIDATE_PREFIX_NULL = 0x00000004U, WP_FILE_VALIDATE_PREFIX_TOO_SMALL = 0x00000008U, WP_FILE_VALIDATE_BODY_NULL = 0x00000010U, WP_FILE_VALIDATE_OFFSET_MISMATCH = 0x00000020U, WP_FILE_VALIDATE_SIZE_MISMATCH = 0x00000040U, WP_FILE_VALIDATE_HEADER_BYTES_MISMATCH = 0x00000080U, WP_FILE_VALIDATE_SIZE_OVERFLOW = 0x00000100U }; typedef struct WpFilePreservationInfo { size_t prefix_size; size_t body_size; uint32_t data_offset; uint32_t file_size; uint32_t prefix_hash; uint32_t body_hash; uint32_t full_hash; uint32_t validation_flags; bool byte_stable; bool has_body; } WpFilePreservationInfo; /* Common prefix used by WP 5.x documents, macros, printer resources, styles, * and other companion files. Fields are decoded explicitly as little-endian * bytes so the host build is not tied to x86 alignment or byte order. */ typedef struct WpFileHeader { uint8_t signature[4]; /* Expected bytes: 0xFF 'W' 'P' 'C'. */ uint32_t data_offset; /* Offset of the first data/packet region. */ uint8_t product_type; uint8_t file_type; uint8_t major_version; uint8_t minor_version; uint32_t file_size; /* Host-observed file length, not on-disk. */ } WpFileHeader; typedef struct WpLoadedFile { WpFileHeader header; uint8_t *prefix_bytes; /* Raw bytes before data_offset, preserved verbatim. */ uint8_t *logical_bytes; /* Body bytes in file order. */ uint8_t *lifo_storage; /* Same body arranged for primary LIFO cursor. */ size_t prefix_size; size_t logical_size; } WpLoadedFile; bool wp_file_signature_is_valid(const uint8_t signature[4]); const char *wp_file_type_name(uint8_t file_type); bool wp_file_read_header(const char *filename, WpFileHeader *out_header); bool wp_file_load_body(const char *filename, WpLoadedFile *out_file); bool wp_file_validate_loaded(const WpLoadedFile *file, uint32_t *out_flags); bool wp_file_preservation_info(const WpLoadedFile *file, WpFilePreservationInfo *out_info); bool wp_file_rebuild_lifo(WpLoadedFile *file); bool wp_file_replace_body(WpLoadedFile *file, const uint8_t *body, size_t body_size); bool wp_file_write_stream(FILE *stream, const WpLoadedFile *file); bool wp_file_save(const char *filename, const WpLoadedFile *file); bool wp_file_save_atomic(const char *filename, const WpLoadedFile *file); void wp_file_free(WpLoadedFile *file); bool wp_file_bind_primary_stream(WpLoadedFile *file, WpLayoutGlobals *wl, uint32_t buffer_space); #endif
Commit message
This repository is read-only for this account.
Repository snapshot
Current branch
main
Visibility
public
Your access
Read
Remote
None
File activity
View file history