From eb210fa16730102f1ab49cad7a1fed5c2c184b6d Mon Sep 17 00:00:00 2001 From: Max Wash Date: Wed, 18 Dec 2024 18:01:28 +0000 Subject: [PATCH] add binary data structure definitions and image writer function prototypes --- src/bin.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/status.h | 12 ++++++++++++ src/write.h | 22 ++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 src/bin.h create mode 100644 src/status.h create mode 100644 src/write.h diff --git a/src/bin.h b/src/bin.h new file mode 100644 index 0000000..ecacf47 --- /dev/null +++ b/src/bin.h @@ -0,0 +1,52 @@ +#ifndef BIN_H_ +#define BIN_H_ + +#include + +#define EC3_SIGNATURE 0x45433358 + +#define EC3_VERSION_1_0 0x0100 + +#define EC3_CLUSTER_16K 0x00u +#define EC3_CLUSTER_32K 0x01u +#define EC3_CLUSTER_64K 0x02u +#define EC3_CLUSTER_128K 0x03u +#define EC3_CLUSTER_256K 0x04u +#define EC3_CLUSTER_512K 0x05u +#define EC3_CLUSTER_1M 0x06u + +#define EC3_TAG_VOLU 0x564F4C55 +#define EC3_TAG_CTAB 0x43544142 +#define EC3_TAG_XATR 0x58415452 +#define EC3_TAG_STAB 0x53544142 +#define EC3_TAG_MFST 0x4D465354 +#define EC3_TAG_BLOB 0x424C4F42 +#define EC3_TAG_EXEC 0x45584543 +#define EC3_TAG_CERT 0x43455254 +#define EC3_TAG_CSIG 0x43534947 + +#define EC3_TAG_SIGNED 0x00000001u +#define EC3_TAG_COMPRESSED 0x00000002u +#define EC3_TAG_ENCRYPTED 0x00000004u + +struct ec3_header { + b_i32 h_sig; + b_i16 h_version; + b_i16 h_cluster_size; + b_i64 h_tag_table_offset; + b_i64 h_tag_count; + b_i64 h_app_magic; +}; + +struct ec3_tag_table_entry { + b_i32 tag_type; + b_i32 tag_flags; + b_i32 tag_checksum; + b_i32 tag_reserved1; + b_i64 tag_ident; + b_i64 tag_offset; + b_i64 tag_size; + b_i64 tag_reserved2; +}; + +#endif diff --git a/src/status.h b/src/status.h new file mode 100644 index 0000000..0f0a72c --- /dev/null +++ b/src/status.h @@ -0,0 +1,12 @@ +#ifndef STATUS_H_ +#define STATUS_H_ + +enum ec3_status { + EC3_SUCCESS = 0, + EC3_ERR_NO_MEMORY, + EC3_ERR_NO_ENTRY, + EC3_ERR_NOT_SUPPORTED, + EC3_ERR_BAD_STATE, +}; + +#endif diff --git a/src/write.h b/src/write.h new file mode 100644 index 0000000..cda7dcb --- /dev/null +++ b/src/write.h @@ -0,0 +1,22 @@ +#ifndef WRITE_H_ +#define WRITE_H_ + +#include "status.h" + +#include +#include + +struct ec3_writer; +struct ec3_tag_writer; + +extern enum ec3_status ec3_writer_create(void); +extern void ec3_writer_destroy(struct ec3_writer *w); +extern void ec3_writer_write_image(struct ec3_writer *w, FILE *fp); + +extern enum ec3_status ec3_writer_create_tag( + struct ec3_writer *w, + uint32_t tag_type, + uint64_t tag_ident, + struct ec3_tag_writer **out_writer); + +#endif