119 size_t read_bytes = 0;
126 FATAL(
"Invalid context or image stream.");
134 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...\n", entry->
offset);
145 TRACE(
"Could not read tracks header, continuing...\n");
152 TRACE(
"Incorrect identifier for data block at position %" PRIu64
"\n", entry->
offset);
162 FATAL(
"Could not allocate memory for metadata block, continuing...\n");
173 FATAL(
"Could not read metadata block, continuing...\n");
185 TRACE(
"Incorrect CRC found: 0x%" PRIx64
" found, expected 0x%" PRIx64, crc64,
189 uint8_t *recovered = NULL;
190 uint32_t rec_size = 0;
193 TRACE(
"EC recovery succeeded for tracks block at offset %" PRIu64, entry->
offset);
238 FATAL(
"Could not allocate memory for data tracks, continuing without filtered list.\n");
319 TRACE(
"Entering aaruf_get_tracks(%p, %p, %zu)", context, buffer, (length ? *length : 0));
324 FATAL(
"Invalid context");
326 TRACE(
"Exiting aaruf_get_tracks() = AARUF_ERROR_NOT_AARUFORMAT");
335 FATAL(
"Invalid context");
337 TRACE(
"Exiting aaruf_get_tracks() = AARUF_ERROR_NOT_AARUFORMAT");
343 FATAL(
"Image contains no tracks");
345 TRACE(
"Exiting aaruf_get_tracks() = AARUF_ERROR_TRACK_NOT_FOUND");
351 if(buffer == NULL || length == NULL || *length < required_length)
353 if(length) *length = required_length;
354 TRACE(
"Buffer too small for tracks, required %zu bytes", required_length);
356 TRACE(
"Exiting aaruf_get_tracks() = AARUF_ERROR_BUFFER_TOO_SMALL");
361 *length = required_length;
363 TRACE(
"Exiting aaruf_get_tracks(%p, %p, %zu) = AARUF_STATUS_OK", context, buffer, *length);
430 TRACE(
"Entering aaruf_set_tracks(%p, %p, %d)", context, tracks, count);
435 FATAL(
"Invalid context");
437 TRACE(
"Exiting aaruf_get_tracks() = AARUF_ERROR_NOT_AARUFORMAT");
446 FATAL(
"Invalid context");
448 TRACE(
"Exiting aaruf_get_tracks() = AARUF_ERROR_NOT_AARUFORMAT");
462 TRACE(
"Exiting aaruf_set_tracks() = AARUF_STATUS_OK");
466 if(tracks == NULL || count < 0)
468 FATAL(
"Invalid tracks data");
470 TRACE(
"Exiting aaruf_set_tracks() = AARUF_ERROR_INVALID_TRACK_FORMAT");
481 FATAL(
"Could not allocate memory for tracks");
483 TRACE(
"Exiting aaruf_set_tracks() = AARUF_ERROR_NOT_ENOUGH_MEMORY");
510 FATAL(
"Could not allocate memory for data tracks");
512 TRACE(
"Exiting aaruf_set_tracks() = AARUF_ERROR_NOT_ENOUGH_MEMORY");
525 TRACE(
"Exiting aaruf_set_tracks() = AARUF_STATUS_OK");
#define AARU_MAGIC
Magic identifier for AaruFormat container (ASCII "AARUFRMT").
#define AARUF_VERSION_V1
First on‑disk version (C# implementation).
uint64_t aaruf_crc64_data(const uint8_t *data, uint32_t len)
int32_t aaruf_get_tracks(const void *context, uint8_t *buffer, size_t *length)
Retrieve the array of track descriptors contained in an opened AaruFormat image.
int32_t aaruf_set_tracks(void *context, TrackEntry *tracks, const int count)
Replace (or clear) the in-memory track table for an AaruFormat image context.
@ TracksBlock
Block containing optical disc tracks.
int32_t ec_recover_meta_block(aaruformat_context *ctx, uint64_t block_offset, uint8_t **recovered_data, uint32_t *recovered_size)
Attempt to recover a metadata/media-tag block at a given file offset.
#define AARUF_STATUS_OK
Sector present and read without uncorrectable errors.
#define AARUF_ERROR_TRACK_NOT_FOUND
Referenced track number not present.
#define AARUF_ERROR_NOT_ENOUGH_MEMORY
Memory allocation failure (critical).
#define AARUF_ERROR_INVALID_TRACK_FORMAT
Track metadata internally inconsistent or malformed.
#define AARUF_ERROR_NOT_AARUFORMAT
Input file/stream failed magic or structural validation.
#define AARUF_ERROR_BUFFER_TOO_SMALL
Caller-supplied buffer insufficient for data.
void process_tracks_block(aaruformat_context *ctx, const IndexEntry *entry)
Parse and integrate a Tracks block from the image stream into the context.
static int aaruf_fseek(FILE *stream, aaru_off_t offset, int origin)
static aaru_off_t aaruf_ftell(FILE *stream)
uint8_t HasPartitions
Image contains partitions (or tracks for optical media); 0=no, non-zero=yes.
uint8_t HasSessions
Image contains multiple sessions (optical media); 0=single/none, non-zero=multi.
uint64_t ImageSize
Size of the image payload in bytes (excludes headers/metadata).
Single index entry describing a block's type, (optional) data classification, and file offset.
uint64_t offset
Absolute byte offset in the image where the referenced block header begins.
Single optical disc track descriptor (sequence, type, LBAs, session, ISRC, flags).
uint8_t sequence
Track number (1..99 typical for CD audio/data).
Master context representing an open or in‑creation Aaru image.
TrackEntry * data_tracks
Filtered list of data tracks (subset of trackEntries).
bool dirty_tracks_block
True if tracks block should be written during close.
AaruHeaderV2 header
Parsed container header (v2).
uint64_t magic
File magic (AARU_MAGIC) post-open.
FILE * imageStream
Underlying FILE* stream (binary mode).
ImageInfo image_info
Exposed high-level image info summary.
TrackEntry * track_entries
Full track list (tracksHeader.entries elements).
uint8_t number_of_data_tracks
Count of tracks considered "data" (sequence 1..99 heuristics).
TracksHeader tracks_header
Tracks header (optical) if present.