19#ifndef LIBAARUFORMAT_DECLS_H
20#define LIBAARUFORMAT_DECLS_H
32#define EXTERNC extern "C"
38#define AARU_CALL __stdcall
39#define AARU_EXPORT EXTERNC __declspec(dllexport)
42#define PATH_MAX _MAX_PATH
47#define AARU_EXPORT EXTERNC __attribute__((visibility("default")))
48#define AARU_LOCAL __attribute__((visibility("hidden")))
51#define AARU_EXPORT EXTERNC __attribute__((visibility("default")))
52#define AARU_LOCAL __attribute__((visibility("hidden")))
54#define AARU_EXPORT EXTERNC
61#define FORCE_INLINE static inline
63#define FORCE_INLINE static inline __attribute__((always_inline))
73 uint64_t user_sectors, uint64_t negative_sectors, uint64_t overflow_sectors,
74 const char *options,
const uint8_t *application_name,
75 uint8_t application_name_length, uint8_t application_major_version,
76 uint8_t application_minor_version,
bool is_tape);
93 uint32_t *length, uint8_t *sector_status);
95 uint8_t *data, uint32_t *length, uint8_t *sector_status);
98 const uint8_t *data, uint8_t sector_status, uint32_t length);
100 const uint8_t *data, uint8_t sector_status, uint32_t length);
103 const uint8_t *data,
size_t length, int32_t tag);
118 uint32_t major_count, uint32_t minor_count, uint32_t major_mult,
119 uint32_t minor_inc,
const uint8_t *ecc, int32_t address_offset,
120 int32_t data_offset, int32_t ecc_offset);
123 uint32_t major_count, uint32_t minor_count, uint32_t major_mult,
124 uint32_t minor_inc, uint8_t *ecc, int32_t address_offset,
125 int32_t data_offset, int32_t ecc_offset);
128 uint8_t *ecc, int32_t address_offset, int32_t data_offset,
140 uint32_t *length, uint8_t track, uint8_t *sector_status);
142 uint8_t *buffer, uint32_t *length, int32_t tag);
149 uint32_t *sectors_per_track);
151 uint32_t sectors_per_track);
202 uint64_t *starting_block, uint64_t *ending_block);
204 uint64_t starting_block, uint64_t ending_block);
206 uint64_t *ending_block);
208 uint64_t ending_block);
226 const uint8_t *src_buffer,
size_t src_size);
229 uint8_t *dst_buffer,
size_t dst_size,
const uint8_t *src_buffer,
size_t src_size, uint32_t blocksize,
230 int32_t do_mid_side_stereo, int32_t loose_mid_side_stereo,
const char *apodization, uint32_t max_lpc_order,
231 uint32_t qlp_coeff_precision, int32_t do_qlp_coeff_prec_search, int32_t do_exhaustive_model_search,
232 uint32_t min_residual_partition_order, uint32_t max_residual_partition_order,
const char *application_id,
233 uint32_t application_id_len);
236 size_t *src_size,
const uint8_t *props,
size_t props_size);
239 size_t src_size, uint8_t *out_props,
size_t *out_props_size,
240 int32_t level, uint32_t dict_size, int32_t lc, int32_t lp,
241 int32_t pb, int32_t fb, int32_t num_threads);
258#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
259 defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86)
265AARU_EXPORT CLMUL uint64_t
AARU_CALL aaruf_crc64_clmul(uint64_t crc,
const uint8_t *data,
long length);
268#if defined(__aarch64__) || defined(_M_ARM64) || defined(__arm__) || defined(_M_ARM)
273AARU_EXPORT TARGET_WITH_SIMD uint64_t
AARU_CALL aaruf_crc64_vmull(uint64_t previous_crc,
const uint8_t *data,
long len);
Public high-level API types: media classifications, per-sector / per-media tag enums and image summar...
CRC64 (ECMA-182) core context and precomputed slicing-by-4 tables.
int32_t aaruf_set_media_sequence(void *context, int32_t sequence, int32_t last_sequence)
Sets the media sequence information for multi-volume media sets.
int32_t aaruf_set_tape_file(void *context, uint8_t partition, uint32_t file, uint64_t starting_block, uint64_t ending_block)
Sets or updates the block range for a specific tape file in an Aaru tape image.
int32_t aaruf_get_aaru_json_metadata(const void *context, uint8_t *buffer, size_t *length)
Retrieves the embedded Aaru metadata JSON from the image.
int32_t aaruf_clear_media_sequence(void *context)
Clears the media sequence information from the image metadata.
void aaruf_cd_lba_to_msf(int64_t pos, uint8_t *minute, uint8_t *second, uint8_t *frame)
Converts a CD LBA (Logical Block Address) to MSF (Minute:Second:Frame) format.
void aaruf_sha1_final(sha1_ctx *ctx, unsigned char *result)
int32_t aaruf_set_media_part_number(void *context, const uint8_t *data, int32_t length)
Sets the media part number or model designation for the image.
void aaruf_sha256_init(sha256_ctx *ctx)
int32_t aaruf_cst_transform(const uint8_t *interleaved, uint8_t *sequential, size_t length)
Transforms interleaved subchannel data to sequential format.
int32_t aaruf_clear_drive_firmware_revision(void *context)
Clears the drive firmware revision from the image metadata.
int32_t aaruf_lzma_encode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer, size_t src_size, uint8_t *out_props, size_t *out_props_size, int32_t level, uint32_t dict_size, int32_t lc, int32_t lp, int32_t pb, int32_t fb, int32_t num_threads)
Encodes a buffer using LZMA compression.
uint64_t aaruf_crc64_data(const uint8_t *data, uint32_t len)
size_t aaruf_flac_encode_redbook_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size, uint32_t blocksize, int32_t do_mid_side_stereo, int32_t loose_mid_side_stereo, const char *apodization, uint32_t max_lpc_order, uint32_t qlp_coeff_precision, int32_t do_qlp_coeff_prec_search, int32_t do_exhaustive_model_search, uint32_t min_residual_partition_order, uint32_t max_residual_partition_order, const char *application_id, uint32_t application_id_len)
Encodes a Red Book audio buffer to FLAC format.
int32_t aaruf_lzma_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer, size_t *src_size, const uint8_t *props, size_t props_size)
Decodes an LZMA-compressed buffer.
int32_t aaruf_get_drive_serial_number(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the imaging drive's serial number metadata.
int32_t aaruf_set_drive_model(void *context, const uint8_t *data, int32_t length)
Sets the drive model information for the image.
int32_t aaruf_get_tape_file(const void *context, uint8_t partition, uint32_t file, uint64_t *starting_block, uint64_t *ending_block)
Retrieves the block range for a specific tape file from an Aaru tape image.
int32_t aaruf_set_creator(void *context, const uint8_t *data, int32_t length)
Sets the creator (person/operator) information for the image.
void aaruf_md5_init(md5_ctx *ctx)
void aaruf_sha1_buffer(const void *data, unsigned long size, unsigned char *result)
int aaruf_crc64_update(crc64_ctx *ctx, const uint8_t *data, uint32_t len)
Updates the CRC64 context with new data.
int32_t aaruf_clear_media_serial_number(void *context)
Clears the media serial number from the image metadata.
int32_t aaruf_set_geometry(void *context, uint32_t cylinders, uint32_t heads, uint32_t sectors_per_track)
Sets the logical CHS geometry for the AaruFormat image.
int32_t aaruf_read_sector(void *context, uint64_t sector_address, bool negative, uint8_t *data, uint32_t *length, uint8_t *sector_status)
Reads a sector from the AaruFormat image.
void fuzzy_try_fork_blockhash(spamsum_ctx *ctx)
int32_t aaruf_clear_media_barcode(void *context)
Clears the media barcode information from the image metadata.
int32_t aaruf_get_all_tape_partitions(const void *context, uint8_t *buffer, size_t *length)
Retrieves all tape partition entries from the image.
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_media_serial_number(void *context, const uint8_t *data, int32_t length)
Sets the media serial number for the image.
void aaruf_ecc_cd_write_sector(void *context, const uint8_t *address, const uint8_t *data, uint8_t *ecc, int32_t address_offset, int32_t data_offset, int32_t ecc_offset)
Writes ECC for a full CD sector (both P and Q ECC).
int32_t aaruf_get_dumphw(void *context, uint8_t *buffer, size_t *length)
Retrieves the dump hardware block containing acquisition environment information.
int32_t aaruf_set_media_title(void *context, const uint8_t *data, int32_t length)
Sets the media title or label for the image.
int32_t aaruf_get_creator(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the recorded creator (operator) name from the MetadataBlock.
int32_t aaruf_set_drive_manufacturer(void *context, const uint8_t *data, int32_t length)
Sets the drive manufacturer information for the image.
int32_t aaruf_set_media_manufacturer(void *context, const uint8_t *data, int32_t length)
Sets the media manufacturer information for the image.
int32_t aaruf_get_drive_firmware_revision(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the firmware revision metadata for the imaging drive.
int32_t aaruf_clear_media_title(void *context)
Clears the media title or label from the image metadata.
int32_t aaruf_clear_media_manufacturer(void *context)
Clears the media manufacturer information from the image metadata.
int32_t aaruf_get_cicm_metadata(const void *context, uint8_t *buffer, size_t *length)
Retrieves the embedded CICM XML metadata sidecar from the image.
int32_t aaruf_clear_drive_model(void *context)
Clears the drive model information from the image metadata.
int32_t aaruf_set_media_barcode(void *context, const uint8_t *data, int32_t length)
Sets the media barcode information for the image.
int32_t aaruf_read_media_tag(void *context, uint8_t *data, int32_t tag, uint32_t *length)
Reads a media tag from the AaruFormat image.
void aaruf_crc64_free(crc64_ctx *ctx)
Frees a CRC64 context.
int32_t aaruf_write_sector(void *context, uint64_t sector_address, bool negative, const uint8_t *data, uint8_t sector_status, uint32_t length)
Writes a sector to the AaruFormat image.
int32_t aaruf_get_media_serial_number(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the media serial number recorded in the image metadata.
int32_t aaruf_get_media_part_number(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the media part number recorded in the MetadataBlock.
int32_t aaruf_get_media_model(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the media model or product designation metadata.
int32_t aaruf_get_media_manufacturer(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the recorded media manufacturer name.
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.
int32_t aaruf_get_drive_model(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the device model information for the imaging drive.
int32_t aaruf_get_media_tag_type_for_datatype(int32_t type)
Converts an image data type to an Aaru media tag type.
bool aaruf_ecc_cd_check(void *context, const uint8_t *address, const uint8_t *data, uint32_t major_count, uint32_t minor_count, uint32_t major_mult, uint32_t minor_inc, const uint8_t *ecc, int32_t address_offset, int32_t data_offset, int32_t ecc_offset)
Checks the ECC of a CD sector.
int32_t aaruf_get_media_barcode(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the barcode assigned to the physical media or its packaging.
int aaruf_spamsum_update(spamsum_ctx *ctx, const uint8_t *data, uint32_t len)
Updates the spamsum context with new data.
int32_t aaruf_get_drive_manufacturer(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the drive manufacturer metadata captured during imaging.
int32_t aaruf_clear_drive_manufacturer(void *context)
Clears the drive manufacturer information from the image metadata.
void aaruf_sha256_final(sha256_ctx *ctx, unsigned char *result)
int32_t aaruf_get_image_info(const void *context, ImageInfo *image_info)
Retrieves a deep copy of the ImageInfo structure from the AaruFormat image.
crc64_ctx * aaruf_crc64_init()
Initializes a CRC64 context.
uint32_t aaruf_edc_cd_compute(void *context, uint32_t edc, const uint8_t *src, int size, int pos)
Computes the EDC (Error Detection Code) for a CD sector.
void fuzzy_engine_step(spamsum_ctx *ctx, uint8_t c)
int aaruf_close(void *context)
Close an Aaru image context, flushing pending data structures and releasing resources.
int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool negative, const uint8_t *data, uint8_t sector_status, uint32_t length)
Writes a full ("long") raw sector from optical or block media, parsing structure and validating conte...
int32_t aaruf_write_sector_tag(void *context, uint64_t sector_address, bool negative, const uint8_t *data, size_t length, int32_t tag)
Writes per-sector tag data (auxiliary metadata) for a specific sector.
void aaruf_md5_final(md5_ctx *ctx, unsigned char *result)
void aaruf_md5_update(md5_ctx *ctx, const void *data, unsigned long size)
int aaruf_identify_stream(FILE *image_stream)
Identifies a file as an AaruFormat image using an open stream.
void aaruf_spamsum_free(spamsum_ctx *ctx)
Frees a spamsum (fuzzy hash) context.
void * aaruf_create(const char *filepath, uint32_t media_type, uint32_t sector_size, uint64_t user_sectors, uint64_t negative_sectors, uint64_t overflow_sectors, const char *options, const uint8_t *application_name, uint8_t application_name_length, uint8_t application_major_version, uint8_t application_minor_version, bool is_tape)
Creates a new AaruFormat image file.
void aaruf_ecc_cd_reconstruct_prefix(uint8_t *sector, uint8_t type, int64_t lba)
Reconstructs the prefix (sync, address, mode) of a CD sector.
int aaruf_identify(const char *filename)
Identifies a file as an AaruFormat image using a file path.
spamsum_ctx * aaruf_spamsum_init(void)
void aaruf_sha256_buffer(const void *data, unsigned long size, unsigned char *result)
int32_t aaruf_get_user_sectors(const void *context, uint64_t *sectors)
Retrieves the total number of user-accessible sectors in the AaruFormat image.
int32_t aaruf_set_aaru_json_metadata(void *context, uint8_t *data, size_t length)
Sets the Aaru metadata JSON for the image during creation.
void aaruf_crc64_slicing(uint64_t *previous_crc, const uint8_t *data, uint32_t len)
Updates a CRC64 value using the slicing-by-8 algorithm.
int32_t aaruf_clear_media_part_number(void *context)
Clears the media part number or model designation from the image metadata.
int32_t aaruf_clear_comments(void *context)
Clears user comments or notes from the image metadata.
void aaruf_ecc_cd_write(void *context, const uint8_t *address, const uint8_t *data, uint32_t major_count, uint32_t minor_count, uint32_t major_mult, uint32_t minor_inc, uint8_t *ecc, int32_t address_offset, int32_t data_offset, int32_t ecc_offset)
Writes ECC for a CD sector.
int32_t aaruf_verify_image(void *context)
Verifies the integrity of an AaruFormat image file.
int32_t aaruf_get_datatype_for_media_tag_type(int32_t tag_type)
Converts an Aaru media tag type to an image data type.
int32_t aaruf_get_negative_sectors(const void *context, uint16_t *sectors)
Retrieves the number of negative (pre-gap) sectors in the AaruFormat image.
int32_t aaruf_set_media_model(void *context, const uint8_t *data, int32_t length)
Sets the media model or product designation for the image.
void fuzzy_try_reduce_blockhash(spamsum_ctx *ctx)
int32_t aaruf_clear_media_model(void *context)
Clears the media model or product designation from the image metadata.
int32_t aaruf_get_comments(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the user comments or notes stored in the MetadataBlock.
void aaruf_sha1_init(sha1_ctx *ctx)
void aaruf_ecc_cd_reconstruct(void *context, uint8_t *sector, uint8_t type)
Reconstructs the EDC and ECC fields of a CD sector.
int32_t aaruf_get_readable_media_tags(const void *context, uint8_t *buffer, size_t *length)
Retrieves which media tags are present in the AaruFormat image.
int32_t aaruf_set_tape_partition(void *context, uint8_t partition, uint64_t starting_block, uint64_t ending_block)
Sets or updates the block range for a specific tape partition in an Aaru tape image.
void roll_hash(spamsum_ctx *ctx, uint8_t c)
int32_t aaruf_write_media_tag(void *context, const uint8_t *data, int32_t type, uint32_t length)
Writes a media tag to the AaruFormat image, storing medium-specific metadata and descriptors.
int32_t aaruf_get_media_sequence(const void *context, int32_t *sequence, int32_t *last_sequence)
Retrieves the media sequence metadata for multi-volume image sets.
int32_t aaruf_clear_drive_serial_number(void *context)
Clears the drive serial number from the image metadata.
int32_t aaruf_get_readable_sector_tags(const void *context, uint8_t *buffer, size_t *length)
Retrieves which sector tags are readable in the AaruFormat image.
int32_t aaruf_get_tape_partition(const void *context, uint8_t partition, uint64_t *starting_block, uint64_t *ending_block)
Retrieves the block range for a specific tape partition from an Aaru tape image.
int aaruf_spamsum_final(spamsum_ctx *ctx, uint8_t *result)
void aaruf_sha256_update(sha256_ctx *ctx, const void *data, unsigned long size)
bool aaruf_ecc_cd_is_suffix_correct_mode2(void *context, const uint8_t *sector)
Checks if the suffix (EDC/ECC) of a CD sector is correct (Mode 2).
int32_t aaruf_get_geometry(const void *context, uint32_t *cylinders, uint32_t *heads, uint32_t *sectors_per_track)
Retrieves the logical CHS geometry from the AaruFormat image.
void aaruf_md5_buffer(const void *data, unsigned long size, unsigned char *result)
void aaruf_sha1_update(sha1_ctx *ctx, const void *data, unsigned long size)
void * aaruf_ecc_cd_init()
Initializes a Compact Disc ECC context.
int32_t aaruf_clear_creator(void *context)
Clears the creator (person/operator) information from the image metadata.
int32_t aaruf_get_xml_mediatype(int32_t type)
int32_t aaruf_get_all_tape_files(const void *context, uint8_t *buffer, size_t *length)
Retrieves all tape file entries from the image.
int32_t aaruf_set_dumphw(void *context, uint8_t *data, size_t length)
Sets the dump hardware block for the image during creation.
int32_t aaruf_set_drive_firmware_revision(void *context, const uint8_t *data, int32_t length)
Sets the drive firmware revision for the image.
int32_t aaruf_cst_untransform(const uint8_t *sequential, uint8_t *interleaved, size_t length)
Reverses the CST (Claunia's Subchannel Transform) transformation from sequential to interleaved data.
int32_t aaruf_read_track_sector(void *context, uint8_t *data, uint64_t sector_address, uint32_t *length, uint8_t track, uint8_t *sector_status)
Reads a sector from a specific track in the AaruFormat image.
int aaruf_crc64_final(crc64_ctx *ctx, uint64_t *crc)
Computes the final CRC64 value from the context.
int32_t aaruf_read_sector_tag(const void *context, uint64_t sector_address, bool negative, uint8_t *buffer, uint32_t *length, int32_t tag)
Reads a specific sector tag from the AaruFormat image.
int32_t aaruf_read_sector_long(void *context, uint64_t sector_address, bool negative, uint8_t *data, uint32_t *length, uint8_t *sector_status)
Reads a complete sector with all metadata from the AaruFormat image.
int32_t aaruf_get_overflow_sectors(const void *context, uint16_t *sectors)
Retrieves the number of overflow (post-gap) sectors in the AaruFormat image.
int32_t aaruf_set_drive_serial_number(void *context, const uint8_t *data, int32_t length)
Sets the drive serial number for the image.
void * aaruf_open(const char *filepath, bool resume_mode, char *options)
size_t aaruf_flac_decode_redbook_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size)
Decodes a FLAC-compressed Red Book audio buffer.
int32_t aaruf_get_media_title(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the media title or label captured during image creation.
int32_t aaruf_set_comments(void *context, const uint8_t *data, int32_t length)
Sets user comments or notes for the image.
bool aaruf_ecc_cd_is_suffix_correct(void *context, const uint8_t *sector)
Checks if the suffix (EDC/ECC) of a CD sector is correct (Mode 1).
On-disk structures describing optical disc tracks (Track list block).
High-level summary of an opened Aaru image containing metadata and media characteristics.
Single optical disc track descriptor (sequence, type, LBAs, session, ISRC, flags).
Minimal ECMA-182 CRC64 incremental state container (running value only).