From 9b35f95076ff8c7cbac51293252a02ee3e49205f Mon Sep 17 00:00:00 2001 From: iWas-Coder Date: Sun, 9 Jun 2024 22:26:57 +0200 Subject: [PATCH] Add number of image idxs written to the SKAP in the header section (#31) --- tools/skap/include/skap_header.h | 3 ++- tools/skap/src/skap.c | 2 +- tools/skap/src/skap_header.c | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/skap/include/skap_header.h b/tools/skap/include/skap_header.h index 0ecf827..bf45a3a 100644 --- a/tools/skap/include/skap_header.h +++ b/tools/skap/include/skap_header.h @@ -27,8 +27,9 @@ typedef struct { char signature[4]; u8 fmt_ver; u64 build_ver; + usz idx_image_count; } skap_header; -skap_header skap_header_create(void); +skap_header skap_header_create(usz idx_image_count); u8 skap_header_append(FILE *fd, skap_header *h); diff --git a/tools/skap/src/skap.c b/tools/skap/src/skap.c index b170993..0432d7f 100644 --- a/tools/skap/src/skap.c +++ b/tools/skap/src/skap.c @@ -40,7 +40,7 @@ int main(void) { SetTraceLogLevel(LOG_WARNING); skap_idx_image_loadall(imgs, img_paths, IMG_COUNT); FILE *fd = skap_file_create(); - skap_header header = skap_header_create(); + skap_header header = skap_header_create(IMG_COUNT); if (!skap_header_append(fd, &header)) skap_return_defer(1); for (usz i = 0; i < IMG_COUNT; ++i) { img_idxs[i] = skap_idx_image_create(img_paths[i], &imgs[i]); diff --git a/tools/skap/src/skap_header.c b/tools/skap/src/skap_header.c index 652886c..4700d59 100644 --- a/tools/skap/src/skap_header.c +++ b/tools/skap/src/skap_header.c @@ -46,11 +46,12 @@ static u64 compute_build_ver(void) { return build_ver; } -skap_header skap_header_create(void) { +skap_header skap_header_create(usz idx_image_count) { return (skap_header) { .signature = { 'S', 'K', 'A', 'P' }, .fmt_ver = 1, - .build_ver = compute_build_ver() + .build_ver = compute_build_ver(), + .idx_image_count = idx_image_count }; }