start packing some binary image structures
This commit is contained in:
86
src/bin.h
86
src/bin.h
@@ -2,6 +2,7 @@
|
|||||||
#define BIN_H_
|
#define BIN_H_
|
||||||
|
|
||||||
#include <blue/core/endian.h>
|
#include <blue/core/endian.h>
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
#define EC3_SIGNATURE 0x45433358
|
#define EC3_SIGNATURE 0x45433358
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@
|
|||||||
#define EC3_TAG_ENCRYPTED 0x00000004u
|
#define EC3_TAG_ENCRYPTED 0x00000004u
|
||||||
|
|
||||||
/* 32K per cluster group */
|
/* 32K per cluster group */
|
||||||
#define EC3_CLUSTERS_PER_GROUP 1635
|
#define EC3_CLUSTERS_PER_GROUP 1637
|
||||||
/* 1K per extent group */
|
/* 1K per extent group */
|
||||||
#define EC3_EXTENTS_PER_GROUP 36
|
#define EC3_EXTENTS_PER_GROUP 36
|
||||||
|
|
||||||
@@ -67,47 +68,52 @@
|
|||||||
|
|
||||||
typedef uint8_t ec3_chunk_id[EC3_CHUNK_ID_SIZE];
|
typedef uint8_t ec3_chunk_id[EC3_CHUNK_ID_SIZE];
|
||||||
|
|
||||||
struct ec3_header {
|
PACK(
|
||||||
b_i32 h_magic;
|
struct ec3_header {
|
||||||
b_i16 h_version;
|
b_i32 h_magic;
|
||||||
b_i16 h_cluster_size;
|
b_i16 h_version;
|
||||||
b_i64 h_tag_table_offset;
|
b_i16 h_cluster_size;
|
||||||
b_i64 h_extent_table_offset;
|
b_i64 h_tag_table_offset;
|
||||||
b_i64 h_cluster_table_offset;
|
b_i64 h_extent_table_offset;
|
||||||
b_i32 h_tag_count;
|
b_i64 h_cluster_table_offset;
|
||||||
b_i32 h_extent_count;
|
b_i32 h_tag_count;
|
||||||
b_i32 h_cluster_group_count;
|
b_i32 h_extent_count;
|
||||||
b_i16 h_compression;
|
b_i32 h_cluster_group_count;
|
||||||
b_i16 h_encryption;
|
b_i16 h_compression;
|
||||||
b_i64 h_app_magic;
|
b_i16 h_encryption;
|
||||||
uint8_t h_reserved[8];
|
b_i64 h_app_magic;
|
||||||
};
|
uint8_t h_reserved[8];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
struct ec3_cluster {
|
PACK(
|
||||||
/* cluster identifier */
|
struct ec3_cluster {
|
||||||
b_i32 c_id;
|
/* cluster identifier */
|
||||||
/* lower 32-bits of the cluster bounds */
|
b_i32 c_id;
|
||||||
b_i32 c_bounds0;
|
/* lower 32-bits of the cluster bounds */
|
||||||
/* upper 32-bits of the cluster bounds */
|
b_i32 c_bounds0;
|
||||||
b_i32 c_bounds1;
|
/* upper 32-bits of the cluster bounds */
|
||||||
/* CRC-16 of the on-disk cluster data */
|
b_i32 c_bounds1;
|
||||||
b_i16 c_checksum;
|
/* CRC-16 of the on-disk cluster data */
|
||||||
/* flags that apply to this cluster */
|
b_i16 c_checksum;
|
||||||
b_i16 c_flags;
|
/* flags that apply to this cluster */
|
||||||
};
|
b_i16 c_flags;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
struct ec3_cluster_group {
|
PACK(
|
||||||
/* the number of clusters that this group contains */
|
struct ec3_cluster_group {
|
||||||
b_i16 g_nr_clusters;
|
/* the number of clusters that this group contains */
|
||||||
uint8_t g_reserved[2];
|
b_i16 g_nr_clusters;
|
||||||
/* array of clusters contained within the group. */
|
uint8_t g_reserved[2];
|
||||||
struct ec3_cluster g_clusters[EC3_CLUSTERS_PER_GROUP];
|
/* array of clusters contained within the group. */
|
||||||
/* offsets to other cluster groups, relative to the start of the
|
struct ec3_cluster g_clusters[EC3_CLUSTERS_PER_GROUP];
|
||||||
* cluster group table. the cluster groups form a B-tree. */
|
/* offsets to other cluster groups, relative to the start of the
|
||||||
b_i32 g_child_offsets[EC3_CLUSTERS_PER_GROUP + 1];
|
* cluster group table. the cluster groups form a B-tree. */
|
||||||
/* pad the group out to an even 32K */
|
b_i32 g_child_offsets[EC3_CLUSTERS_PER_GROUP + 1];
|
||||||
uint8_t g_padding[20];
|
uint8_t g_padding[20];
|
||||||
};
|
}
|
||||||
|
);
|
||||||
|
|
||||||
struct ec3_tag_table_entry {
|
struct ec3_tag_table_entry {
|
||||||
b_i32 tag_type;
|
b_i32 tag_type;
|
||||||
|
|||||||
12
src/misc.h
Normal file
12
src/misc.h
Normal 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
|
||||||
Reference in New Issue
Block a user