start packing some binary image structures

This commit is contained in:
2025-02-01 22:12:46 +00:00
parent 4f3fe09440
commit fea949f1f4
2 changed files with 58 additions and 40 deletions

View File

@@ -2,6 +2,7 @@
#define BIN_H_
#include <blue/core/endian.h>
#include "misc.h"
#define EC3_SIGNATURE 0x45433358
@@ -34,7 +35,7 @@
#define EC3_TAG_ENCRYPTED 0x00000004u
/* 32K per cluster group */
#define EC3_CLUSTERS_PER_GROUP 1635
#define EC3_CLUSTERS_PER_GROUP 1637
/* 1K per extent group */
#define EC3_EXTENTS_PER_GROUP 36
@@ -67,6 +68,7 @@
typedef uint8_t ec3_chunk_id[EC3_CHUNK_ID_SIZE];
PACK(
struct ec3_header {
b_i32 h_magic;
b_i16 h_version;
@@ -81,8 +83,10 @@ struct ec3_header {
b_i16 h_encryption;
b_i64 h_app_magic;
uint8_t h_reserved[8];
};
}
);
PACK(
struct ec3_cluster {
/* cluster identifier */
b_i32 c_id;
@@ -94,8 +98,10 @@ struct ec3_cluster {
b_i16 c_checksum;
/* flags that apply to this cluster */
b_i16 c_flags;
};
}
);
PACK(
struct ec3_cluster_group {
/* the number of clusters that this group contains */
b_i16 g_nr_clusters;
@@ -105,9 +111,9 @@ struct ec3_cluster_group {
/* offsets to other cluster groups, relative to the start of the
* cluster group table. the cluster groups form a B-tree. */
b_i32 g_child_offsets[EC3_CLUSTERS_PER_GROUP + 1];
/* pad the group out to an even 32K */
uint8_t g_padding[20];
};
}
);
struct ec3_tag_table_entry {
b_i32 tag_type;

12
src/misc.h Normal file
View File

@@ -0,0 +1,12 @@
#ifndef MISC_H_
#define MISC_H_
#ifdef __GNUC__
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
#endif
#ifdef _MSC_VER
#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop))
#endif
#endif