|
libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
|
#include <limits.h>#include <stdbool.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include "aaruformat.h"#include "internal.h"#include "log.h"#include "utarray.h"Go to the source code of this file.
Functions | |
| static bool | add_subindex_entries (aaruformat_context *ctx, UT_array *index_entries, const IndexEntry *subindex_entry) |
| Adds entries from a subindex block (version 3) to the main index entries array. | |
| UT_array * | process_index_v3 (aaruformat_context *ctx) |
| Processes an index block (version 3) from the image stream. | |
| int32_t | verify_index_v3 (aaruformat_context *ctx) |
| Verifies the integrity of an index block (version 3) in the image stream. | |
|
static |
Adds entries from a subindex block (version 3) to the main index entries array.
Recursively reads subindex blocks and appends their entries to the main index entries array. This function is a critical component of the hierarchical index system in AaruFormat version 3, enabling scalable index organization for large image files. It performs recursive traversal of subindex structures, flattening the hierarchy into a single array while maintaining entry order and handling nested subindex references.
| ctx | Pointer to the aaruformat context containing the image stream. |
| index_entries | Pointer to the UT_array of main index entries to append to. |
| subindex_entry | Pointer to the IndexEntry describing the subindex location and metadata. |
Definition at line 247 of file index_v3.c.
References add_subindex_entries(), IndexEntry::blockType, IndexHeader3::entries, FATAL, IndexHeader3::identifier, aaruformat_context::imageStream, IndexBlock3, IndexEntry::offset, and TRACE.
Referenced by add_subindex_entries(), and process_index_v3().
| UT_array * process_index_v3 | ( | aaruformat_context * | ctx | ) |
Processes an index block (version 3) from the image stream.
Reads and parses an index block (version 3) from the image, returning an array of index entries. This function handles the advanced index format used in current AaruFormat versions, supporting hierarchical subindex structures for improved scalability. It reads the IndexHeader3 structure followed by index entries, recursively processing any subindex blocks encountered to create a flattened array of all index entries.
| ctx | Pointer to the aaruformat context containing the image stream and header information. |
| UT_array* | Successfully processed the index block and all subindexes. This is returned when:
|
| NULL | Index processing failed. This occurs when:
|
Definition at line 98 of file index_v3.c.
References add_subindex_entries(), IndexEntry::blockType, IndexHeader3::entries, FATAL, aaruformat_context::header, IndexHeader3::identifier, aaruformat_context::imageStream, IndexBlock3, AaruHeaderV2::indexOffset, and TRACE.
Referenced by aaruf_open(), and aaruf_verify_image().
| int32_t verify_index_v3 | ( | aaruformat_context * | ctx | ) |
Verifies the integrity of an index block (version 3) in the image stream.
Checks the CRC64 of the index block and all subindexes without decompressing them. This function performs comprehensive validation of the advanced version 3 index structure including header validation, data integrity verification, and version-specific CRC calculation. Note that this function validates only the main index block's CRC and does not recursively validate subindex CRCs, focusing on the primary index structure integrity.
| ctx | Pointer to the aaruformat context containing image stream and header information. |
| AARUF_STATUS_OK | (0) Successfully verified index integrity. This is returned when:
|
| AARUF_ERROR_NOT_AARUFORMAT | (-1) Invalid context or stream. This occurs when:
|
| AARUF_ERROR_CANNOT_READ_HEADER | (-6) Index header reading failed. This occurs when:
|
| AARUF_ERROR_CANNOT_READ_INDEX | (-19) Index format or data access errors. This occurs when:
|
| AARUF_ERROR_NOT_ENOUGH_MEMORY | (-9) Memory allocation failed. This occurs when:
|
| AARUF_ERROR_INVALID_BLOCK_CRC | (-18) CRC64 validation failed. This occurs when:
|
Definition at line 408 of file index_v3.c.
References aaruf_crc64_final(), aaruf_crc64_free(), aaruf_crc64_init(), aaruf_crc64_update(), AARUF_ERROR_CANNOT_READ_HEADER, AARUF_ERROR_CANNOT_READ_INDEX, AARUF_ERROR_INVALID_BLOCK_CRC, AARUF_ERROR_NOT_AARUFORMAT, AARUF_ERROR_NOT_ENOUGH_MEMORY, AARUF_STATUS_OK, AARUF_VERSION_V1, bswap_64, IndexHeader3::crc64, IndexHeader3::entries, FATAL, aaruformat_context::header, IndexHeader3::identifier, AaruHeaderV2::imageMajorVersion, aaruformat_context::imageStream, IndexBlock3, AaruHeaderV2::indexOffset, and TRACE.
Referenced by aaruf_verify_image().