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_resource_manager.h
File editor
#ifndef WP_RESOURCE_MANAGER_H #define WP_RESOURCE_MANAGER_H #include <stdbool.h> #include <stddef.h> #include <stdint.h> #define WP_RES_MACRO_TITLE_CAPACITY 64U #define WP_RES_MACRO_PREVIEW_CAPACITY 96U #define WP_RES_MACRO_COMMAND_OPCODE_COUNT 256U #define WP_RES_PRINTER_NAME_CAPACITY 64U #define WP_RES_BYTE_BITMAP_BYTES 32U #define WP_RES_KEYBOARD_DESCRIPTOR_CAPACITY 96U #define WP_RES_GENERIC_TEXT_CAPACITY 96U /* WP 5.1 Resource Headers (.PRS, .VRS). */ #pragma pack(push, 1) typedef struct WpResourceHeader { uint8_t signature[4]; /* Expected bytes: 0xFF 'W' 'P' 'C' */ uint32_t data_offset; uint8_t product_type; uint8_t file_type; uint8_t major_version; uint8_t minor_version; } WpResourceHeader; #pragma pack(pop) typedef enum WpResourceFamily { WP_RES_FAMILY_UNKNOWN = 0, WP_RES_FAMILY_MACRO, WP_RES_FAMILY_VIDEO_RESOURCE, WP_RES_FAMILY_KEYBOARD, WP_RES_FAMILY_DOCUMENT_STYLE, WP_RES_FAMILY_SPELLER, WP_RES_FAMILY_PRINTER, WP_RES_FAMILY_OVERLAY_HELP, WP_RES_FAMILY_GRAPHIC, WP_RES_FAMILY_MACRO_RESOURCE, WP_RES_FAMILY_QUICK_REFERENCE, WP_RES_FAMILY_INDEX_RESOURCE, WP_RES_FAMILY_COUNT } WpResourceFamily; typedef struct WpResourceFileInfo { WpResourceHeader header; uint32_t file_size; uint32_t prefix_size; uint32_t body_size; WpResourceFamily family; bool has_body; } WpResourceFileInfo; typedef struct WpMacroStreamSummary { size_t words; size_t literal_words; size_t control_words; size_t command_words; size_t extended_words; size_t zero_words; size_t title_length; size_t title_bytes; size_t literal_preview_length; size_t unique_command_opcodes; size_t most_common_command_count; uint32_t title_offset; uint8_t most_common_command_opcode; char title[WP_RES_MACRO_TITLE_CAPACITY]; char literal_preview[WP_RES_MACRO_PREVIEW_CAPACITY]; size_t command_histogram[WP_RES_MACRO_COMMAND_OPCODE_COUNT]; bool odd_body_size; bool has_title; } WpMacroStreamSummary; typedef struct WpMacroDryRunStats { size_t words; size_t events; size_t literal_events; size_t control_events; size_t command_events; size_t implemented_command_events; size_t unsupported_command_events; size_t extended_events; size_t zero_events; size_t unique_command_opcodes; size_t unique_unsupported_command_opcodes; uint8_t first_command_opcode; uint8_t last_command_opcode; size_t command_histogram[WP_RES_MACRO_COMMAND_OPCODE_COUNT]; bool odd_body_size; bool has_command; } WpMacroDryRunStats; typedef struct WpKeyboardLayoutSummary { size_t slots; size_t empty_slots; size_t bound_slots; size_t literal_refs; size_t macro_refs; size_t command_refs; size_t macro_command_refs; size_t other_refs; size_t trailing_bytes; size_t unique_literal_refs; size_t unique_macro_refs; size_t unique_command_refs; size_t unique_macro_command_refs; size_t unique_entry_classes; size_t descriptor_records; size_t descriptor_bytes; size_t longest_descriptor_length; size_t section_entries; size_t valid_sections; size_t invalid_sections; size_t section_payload_bytes; size_t binding_section_bytes; size_t descriptor_section_bytes; uint8_t first_descriptor_id; uint8_t last_descriptor_id; uint8_t literal_ref_bitmap[WP_RES_BYTE_BITMAP_BYTES]; uint8_t macro_ref_bitmap[WP_RES_BYTE_BITMAP_BYTES]; uint8_t command_ref_bitmap[WP_RES_BYTE_BITMAP_BYTES]; uint8_t macro_command_ref_bitmap[WP_RES_BYTE_BITMAP_BYTES]; uint8_t entry_class_bitmap[WP_RES_BYTE_BITMAP_BYTES]; char first_descriptor[WP_RES_KEYBOARD_DESCRIPTOR_CAPACITY]; char longest_descriptor[WP_RES_KEYBOARD_DESCRIPTOR_CAPACITY]; bool has_descriptor; bool has_binding_section; bool has_descriptor_section; } WpKeyboardLayoutSummary; typedef struct WpPrinterResourceSummary { size_t body_words; size_t zero_words; size_t ffff_words; size_t offset_like_words; size_t name_length; uint16_t header_word0; uint16_t header_word1; uint16_t header_word2; uint16_t name_offset; uint16_t highest_offset_like_word; char name[WP_RES_PRINTER_NAME_CAPACITY]; bool odd_body_size; bool name_offset_valid; bool has_name; } WpPrinterResourceSummary; typedef struct WpGenericResourceSummary { size_t prefix_bytes; size_t body_bytes; size_t body_words; size_t zero_words; size_t ffff_words; size_t offset_like_words; size_t printable_runs; size_t printable_bytes; size_t length_prefixed_strings; size_t length_prefixed_string_bytes; size_t longest_string_length; uint16_t highest_offset_like_word; char first_string[WP_RES_GENERIC_TEXT_CAPACITY]; char longest_string[WP_RES_GENERIC_TEXT_CAPACITY]; bool odd_body_size; bool has_string; } WpGenericResourceSummary; typedef struct WpResourceFileAnalysis { WpResourceFileInfo info; WpMacroStreamSummary macro; WpKeyboardLayoutSummary keyboard; WpPrinterResourceSummary printer; WpGenericResourceSummary generic; bool has_macro_summary; bool has_keyboard_summary; bool has_printer_summary; bool has_generic_summary; } WpResourceFileAnalysis; /* WP Extended Character (e.g. 4,3 = o with umlaut) */ typedef struct WpExtendedChar { uint8_t set; uint8_t index; uint32_t unicode; } WpExtendedChar; /* Resource functions */ bool wp_res_read_header(const char *filename, WpResourceHeader *out_header); bool wp_res_describe_file(const char *filename, WpResourceFileInfo *out_info); bool wp_res_analyze_file(const char *filename, WpResourceFileAnalysis *out_analysis); bool wp_res_macro_dry_run_file(const char *filename, WpMacroDryRunStats *out_stats); WpResourceFamily wp_res_family_for_type(uint8_t file_type); const char *wp_res_family_name(WpResourceFamily family); void wp_res_load_printer(const char *filename); void wp_res_load_video(const char *filename); uint32_t wp_char_to_unicode(uint8_t set, uint8_t index); bool wp_unicode_to_char(uint32_t unicode, uint8_t *out_set, uint8_t *out_index); #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