libaaruformat 1.0 Aaru Data Preservation Suite - Format Library

Loading...
Searching...
No Matches
decls.h
Go to the documentation of this file.
1/*
2 * This file is part of the Aaru Data Preservation Suite.
3 * Copyright (c) 2019-2025 Natalia Portillo.
4 *
5 * This library is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as
7 * published by the Free Software Foundation; either version 2.1 of the
8 * License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef LIBAARUFORMAT_DECLS_H
20#define LIBAARUFORMAT_DECLS_H
21
22#include "aaru.h"
23#include "crc64.h"
24#include "md5.h"
25#include "sha1.h"
26#include "sha256.h"
27#include "simd.h"
28#include "spamsum.h"
29#include "structs/optical.h"
30
31#ifdef __cplusplus
32#define EXTERNC extern "C"
33#else
34#define EXTERNC
35#endif
36
37#if defined(_WIN32)
38#define AARU_CALL __stdcall
39#define AARU_EXPORT EXTERNC __declspec(dllexport)
40#define AARU_LOCAL
41#ifndef PATH_MAX
42#define PATH_MAX _MAX_PATH
43#endif
44#else
45#define AARU_CALL
46#if defined(__APPLE__)
47#define AARU_EXPORT EXTERNC __attribute__((visibility("default")))
48#define AARU_LOCAL __attribute__((visibility("hidden")))
49#else
50#if __GNUC__ >= 4
51#define AARU_EXPORT EXTERNC __attribute__((visibility("default")))
52#define AARU_LOCAL __attribute__((visibility("hidden")))
53#else
54#define AARU_EXPORT EXTERNC
55#define AARU_LOCAL
56#endif
57#endif
58#endif
59
60#ifdef _MSC_VER
61#define FORCE_INLINE static inline
62#else
63#define FORCE_INLINE static inline __attribute__((always_inline))
64#endif
65
66 AARU_EXPORT int AARU_CALL aaruf_identify(const char *filename);
67
68 AARU_EXPORT int AARU_CALL aaruf_identify_stream(FILE *image_stream);
69
70 AARU_EXPORT void *AARU_CALL aaruf_open(const char *filepath);
71
72 AARU_EXPORT void *AARU_CALL aaruf_create(const char *filepath, uint32_t media_type, uint32_t sector_size,
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);
77
78 AARU_EXPORT int AARU_CALL aaruf_close(void *context);
79
80 AARU_EXPORT int32_t AARU_CALL aaruf_read_media_tag(void *context, uint8_t *data, int32_t tag, uint32_t *length);
81
82 AARU_EXPORT crc64_ctx *AARU_CALL aaruf_crc64_init();
83 AARU_EXPORT int AARU_CALL aaruf_crc64_update(crc64_ctx *ctx, const uint8_t *data, uint32_t len);
84 AARU_EXPORT int AARU_CALL aaruf_crc64_final(crc64_ctx *ctx, uint64_t *crc);
85 AARU_EXPORT void AARU_CALL aaruf_crc64_free(crc64_ctx *ctx);
86 AARU_EXPORT void AARU_CALL aaruf_crc64_slicing(uint64_t *previous_crc, const uint8_t *data, uint32_t len);
87 AARU_EXPORT uint64_t AARU_CALL aaruf_crc64_data(const uint8_t *data, uint32_t len);
88
89 AARU_EXPORT int32_t AARU_CALL aaruf_get_tracks(const void *context, uint8_t *buffer, size_t *length);
90 AARU_EXPORT int32_t AARU_CALL aaruf_set_tracks(void *context, TrackEntry *tracks, const int count);
91
92 AARU_EXPORT int32_t AARU_CALL aaruf_read_sector(void *context, uint64_t sector_address, bool negative, uint8_t *data,
93 uint32_t *length, uint8_t *sector_status);
94 AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_long(void *context, uint64_t sector_address, bool negative,
95 uint8_t *data, uint32_t *length, uint8_t *sector_status);
96
97 AARU_EXPORT int32_t AARU_CALL aaruf_write_sector(void *context, uint64_t sector_address, bool negative,
98 const uint8_t *data, uint8_t sector_status, uint32_t length);
99 AARU_EXPORT int32_t AARU_CALL aaruf_write_sector_long(void *context, uint64_t sector_address, bool negative,
100 const uint8_t *data, uint8_t sector_status, uint32_t length);
101 AARU_EXPORT int32_t AARU_CALL aaruf_write_media_tag(void *context, const uint8_t *data, int32_t type, uint32_t length);
102 AARU_EXPORT int32_t AARU_CALL aaruf_write_sector_tag(void *context, uint64_t sector_address, bool negative,
103 const uint8_t *data, size_t length, int32_t tag);
104
105 AARU_EXPORT int32_t AARU_CALL aaruf_verify_image(void *context);
106
107 AARU_EXPORT int32_t AARU_CALL aaruf_cst_transform(const uint8_t *interleaved, uint8_t *sequential, size_t length);
108
109 AARU_EXPORT int32_t AARU_CALL aaruf_cst_untransform(const uint8_t *sequential, uint8_t *interleaved, size_t length);
110
111 AARU_EXPORT void *AARU_CALL aaruf_ecc_cd_init();
112
113 AARU_EXPORT bool AARU_CALL aaruf_ecc_cd_is_suffix_correct(void *context, const uint8_t *sector);
114
115 AARU_EXPORT bool AARU_CALL aaruf_ecc_cd_is_suffix_correct_mode2(void *context, const uint8_t *sector);
116
117 AARU_EXPORT bool AARU_CALL aaruf_ecc_cd_check(void *context, const uint8_t *address, const uint8_t *data,
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);
121
122 AARU_EXPORT void AARU_CALL aaruf_ecc_cd_write(void *context, const uint8_t *address, const uint8_t *data,
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);
126
127 AARU_EXPORT void AARU_CALL aaruf_ecc_cd_write_sector(void *context, const uint8_t *address, const uint8_t *data,
128 uint8_t *ecc, int32_t address_offset, int32_t data_offset,
129 int32_t ecc_offset);
130
131 AARU_LOCAL void AARU_CALL aaruf_cd_lba_to_msf(int64_t pos, uint8_t *minute, uint8_t *second, uint8_t *frame);
132
133 AARU_EXPORT void AARU_CALL aaruf_ecc_cd_reconstruct_prefix(uint8_t *sector, uint8_t type, int64_t lba);
134
135 AARU_EXPORT void AARU_CALL aaruf_ecc_cd_reconstruct(void *context, uint8_t *sector, uint8_t type);
136
137 AARU_EXPORT uint32_t AARU_CALL aaruf_edc_cd_compute(void *context, uint32_t edc, const uint8_t *src, int size, int pos);
138
139 AARU_EXPORT int32_t AARU_CALL aaruf_read_track_sector(void *context, uint8_t *data, uint64_t sector_address,
140 uint32_t *length, uint8_t track, uint8_t *sector_status);
141 AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_tag(const void *context, uint64_t sector_address, bool negative,
142 uint8_t *buffer, uint32_t *length, int32_t tag);
143
144 AARU_LOCAL int32_t AARU_CALL aaruf_get_media_tag_type_for_datatype(int32_t type);
145 AARU_LOCAL int32_t AARU_CALL aaruf_get_datatype_for_media_tag_type(int32_t tag_type);
146 AARU_LOCAL int32_t AARU_CALL aaruf_get_xml_mediatype(int32_t type);
147
148 AARU_EXPORT int32_t AARU_CALL aaruf_get_geometry(const void *context, uint32_t *cylinders, uint32_t *heads,
149 uint32_t *sectors_per_track);
150 AARU_EXPORT int32_t AARU_CALL aaruf_set_geometry(void *context, uint32_t cylinders, uint32_t heads,
151 uint32_t sectors_per_track);
152 AARU_EXPORT int32_t AARU_CALL aaruf_set_media_sequence(void *context, int32_t sequence, int32_t last_sequence);
153 AARU_EXPORT int32_t AARU_CALL aaruf_set_creator(void *context, const uint8_t *data, int32_t length);
154 AARU_EXPORT int32_t AARU_CALL aaruf_set_comments(void *context, const uint8_t *data, int32_t length);
155 AARU_EXPORT int32_t AARU_CALL aaruf_set_media_title(void *context, const uint8_t *data, int32_t length);
156 AARU_EXPORT int32_t AARU_CALL aaruf_set_media_manufacturer(void *context, const uint8_t *data, int32_t length);
157 AARU_EXPORT int32_t AARU_CALL aaruf_set_media_model(void *context, const uint8_t *data, int32_t length);
158 AARU_EXPORT int32_t AARU_CALL aaruf_set_media_serial_number(void *context, const uint8_t *data, int32_t length);
159 AARU_EXPORT int32_t AARU_CALL aaruf_set_media_barcode(void *context, const uint8_t *data, int32_t length);
160 AARU_EXPORT int32_t AARU_CALL aaruf_set_media_part_number(void *context, const uint8_t *data, int32_t length);
161 AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_manufacturer(void *context, const uint8_t *data, int32_t length);
162 AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_model(void *context, const uint8_t *data, int32_t length);
163 AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_serial_number(void *context, const uint8_t *data, int32_t length);
164 AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_firmware_revision(void *context, const uint8_t *data, int32_t length);
165 AARU_EXPORT int32_t AARU_CALL aaruf_get_media_sequence(const void *context, int32_t *sequence, int32_t *last_sequence);
166 AARU_EXPORT int32_t AARU_CALL aaruf_get_creator(const void *context, uint8_t *buffer, int32_t *length);
167 AARU_EXPORT int32_t AARU_CALL aaruf_get_comments(const void *context, uint8_t *buffer, int32_t *length);
168 AARU_EXPORT int32_t AARU_CALL aaruf_get_media_title(const void *context, uint8_t *buffer, int32_t *length);
169 AARU_EXPORT int32_t AARU_CALL aaruf_get_media_manufacturer(const void *context, uint8_t *buffer, int32_t *length);
170 AARU_EXPORT int32_t AARU_CALL aaruf_get_media_model(const void *context, uint8_t *buffer, int32_t *length);
171 AARU_EXPORT int32_t AARU_CALL aaruf_get_media_serial_number(const void *context, uint8_t *buffer, int32_t *length);
172 AARU_EXPORT int32_t AARU_CALL aaruf_get_media_barcode(const void *context, uint8_t *buffer, int32_t *length);
173 AARU_EXPORT int32_t AARU_CALL aaruf_get_media_part_number(const void *context, uint8_t *buffer, int32_t *length);
174 AARU_EXPORT int32_t AARU_CALL aaruf_get_drive_manufacturer(const void *context, uint8_t *buffer, int32_t *length);
175 AARU_EXPORT int32_t AARU_CALL aaruf_get_drive_model(const void *context, uint8_t *buffer, int32_t *length);
176 AARU_EXPORT int32_t AARU_CALL aaruf_get_drive_serial_number(const void *context, uint8_t *buffer, int32_t *length);
177 AARU_EXPORT int32_t AARU_CALL aaruf_get_drive_firmware_revision(const void *context, uint8_t *buffer, int32_t *length);
178 AARU_EXPORT int32_t AARU_CALL aaruf_get_cicm_metadata(const void *context, uint8_t *buffer, size_t *length);
179 AARU_EXPORT int32_t AARU_CALL aaruf_get_aaru_json_metadata(const void *context, uint8_t *buffer, size_t *length);
180 AARU_EXPORT int32_t AARU_CALL aaruf_set_aaru_json_metadata(void *context, uint8_t *data, size_t length);
181 AARU_EXPORT int32_t AARU_CALL aaruf_get_user_sectors(const void *context, uint64_t *sectors);
182 AARU_EXPORT int32_t AARU_CALL aaruf_get_negative_sectors(const void *context, uint16_t *sectors);
183 AARU_EXPORT int32_t AARU_CALL aaruf_get_overflow_sectors(const void *context, uint16_t *sectors);
184 AARU_EXPORT int32_t AARU_CALL aaruf_get_image_info(const void *context, ImageInfo *image_info);
185 AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_sequence(void *context);
186 AARU_EXPORT int32_t AARU_CALL aaruf_clear_creator(void *context);
187 AARU_EXPORT int32_t AARU_CALL aaruf_clear_comments(void *context);
188 AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_title(void *context);
189 AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_manufacturer(void *context);
190 AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_model(void *context);
191 AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_serial_number(void *context);
192 AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_barcode(void *context);
193 AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_part_number(void *context);
194 AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_manufacturer(void *context);
195 AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_model(void *context);
196 AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_serial_number(void *context);
197 AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_firmware_revision(void *context);
198 AARU_EXPORT int32_t AARU_CALL aaruf_get_readable_sector_tags(const void *context, uint8_t *buffer, size_t *length);
199 AARU_EXPORT int32_t AARU_CALL aaruf_get_readable_media_tags(const void *context, uint8_t *buffer, size_t *length);
200
201 AARU_EXPORT int32_t AARU_CALL aaruf_get_tape_file(const void *context, uint8_t partition, uint32_t file,
202 uint64_t *starting_block, uint64_t *ending_block);
203 AARU_EXPORT int32_t AARU_CALL aaruf_set_tape_file(void *context, uint8_t partition, uint32_t file,
204 uint64_t starting_block, uint64_t ending_block);
205 AARU_EXPORT int32_t AARU_CALL aaruf_get_tape_partition(const void *context, uint8_t partition, uint64_t *starting_block,
206 uint64_t *ending_block);
207 AARU_EXPORT int32_t AARU_CALL aaruf_set_tape_partition(void *context, uint8_t partition, uint64_t starting_block,
208 uint64_t ending_block);
209 AARU_EXPORT int32_t AARU_CALL aaruf_get_all_tape_files(const void *context, uint8_t *buffer, size_t *length);
210 AARU_EXPORT int32_t AARU_CALL aaruf_get_all_tape_partitions(const void *context, uint8_t *buffer, size_t *length);
211
212 AARU_EXPORT int32_t AARU_CALL aaruf_get_dumphw(void *context, uint8_t *buffer, size_t *length);
213 AARU_EXPORT int32_t AARU_CALL aaruf_set_dumphw(void *context, uint8_t *data, size_t length);
214
215 AARU_EXPORT spamsum_ctx *AARU_CALL aaruf_spamsum_init(void);
216 AARU_EXPORT int AARU_CALL aaruf_spamsum_update(spamsum_ctx *ctx, const uint8_t *data, uint32_t len);
217 AARU_EXPORT int AARU_CALL aaruf_spamsum_final(spamsum_ctx *ctx, uint8_t *result);
218 AARU_EXPORT void AARU_CALL aaruf_spamsum_free(spamsum_ctx *ctx);
219
220 AARU_LOCAL void fuzzy_engine_step(spamsum_ctx *ctx, uint8_t c);
221 AARU_LOCAL void roll_hash(spamsum_ctx *ctx, uint8_t c);
222 AARU_LOCAL void fuzzy_try_reduce_blockhash(spamsum_ctx *ctx);
223 AARU_LOCAL void fuzzy_try_fork_blockhash(spamsum_ctx *ctx);
224
225 AARU_EXPORT size_t AARU_CALL aaruf_flac_decode_redbook_buffer(uint8_t *dst_buffer, size_t dst_size,
226 const uint8_t *src_buffer, size_t src_size);
227
228 AARU_EXPORT size_t AARU_CALL aaruf_flac_encode_redbook_buffer(
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);
234
235 AARU_EXPORT int32_t AARU_CALL aaruf_lzma_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
236 size_t *src_size, const uint8_t *props, size_t props_size);
237
238 AARU_EXPORT int32_t AARU_CALL aaruf_lzma_encode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
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);
242
243 AARU_EXPORT void AARU_CALL aaruf_md5_init(md5_ctx *ctx);
244 AARU_EXPORT void AARU_CALL aaruf_md5_update(md5_ctx *ctx, const void *data, unsigned long size);
245 AARU_EXPORT void AARU_CALL aaruf_md5_final(md5_ctx *ctx, unsigned char *result);
246 AARU_EXPORT void AARU_CALL aaruf_md5_buffer(const void *data, unsigned long size, unsigned char *result);
247
248 AARU_EXPORT void AARU_CALL aaruf_sha1_init(sha1_ctx *ctx);
249 AARU_EXPORT void AARU_CALL aaruf_sha1_update(sha1_ctx *ctx, const void *data, unsigned long size);
250 AARU_EXPORT void AARU_CALL aaruf_sha1_final(sha1_ctx *ctx, unsigned char *result);
251 AARU_EXPORT void AARU_CALL aaruf_sha1_buffer(const void *data, unsigned long size, unsigned char *result);
252
253 AARU_EXPORT void AARU_CALL aaruf_sha256_init(sha256_ctx *ctx);
254 AARU_EXPORT void AARU_CALL aaruf_sha256_update(sha256_ctx *ctx, const void *data, unsigned long size);
255 AARU_EXPORT void AARU_CALL aaruf_sha256_final(sha256_ctx *ctx, unsigned char *result);
256 AARU_EXPORT void AARU_CALL aaruf_sha256_buffer(const void *data, unsigned long size, unsigned char *result);
257
258#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \
259 defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86)
260
261 AARU_EXPORT int have_clmul();
262 AARU_EXPORT int have_ssse3();
263 AARU_EXPORT int have_avx2();
264
265 AARU_EXPORT CLMUL uint64_t AARU_CALL aaruf_crc64_clmul(uint64_t crc, const uint8_t *data, long length);
266#endif
267
268#if defined(__aarch64__) || defined(_M_ARM64) || defined(__arm__) || defined(_M_ARM)
269 AARU_EXPORT int have_neon();
270 AARU_EXPORT int have_arm_crc32();
271 AARU_EXPORT int have_arm_crypto();
272
273 AARU_EXPORT TARGET_WITH_SIMD uint64_t AARU_CALL aaruf_crc64_vmull(uint64_t previous_crc, const uint8_t *data, long len);
274#endif
275
276#endif // LIBAARUFORMAT_DECLS_H
aaru.h
Public high-level API types: media classifications, per-sector / per-media tag enums and image summar...
crc64.h
CRC64 (ECMA-182) core context and precomputed slicing-by-4 tables.
aaruf_set_media_sequence
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.
Definition metadata.c:364
AARU_CALL
#define AARU_CALL
Definition decls.h:45
aaruf_set_tape_file
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.
Definition tape.c:770
aaruf_get_aaru_json_metadata
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.
Definition metadata.c:2102
aaruf_clear_media_sequence
int32_t aaruf_clear_media_sequence(void *context)
Clears the media sequence information from the image metadata.
Definition metadata.c:3743
aaruf_cd_lba_to_msf
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.
Definition ecc_cd.c:374
aaruf_sha1_final
void aaruf_sha1_final(sha1_ctx *ctx, unsigned char *result)
Definition sha1.c:124
aaruf_set_media_part_number
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.
Definition metadata.c:1299
aaruf_sha256_init
void aaruf_sha256_init(sha256_ctx *ctx)
Definition sha256.c:76
aaruf_cst_transform
int32_t aaruf_cst_transform(const uint8_t *interleaved, uint8_t *sequential, size_t length)
Transforms interleaved subchannel data to sequential format.
Definition cst.c:35
aaruf_clear_drive_firmware_revision
int32_t aaruf_clear_drive_firmware_revision(void *context)
Clears the drive firmware revision from the image metadata.
Definition metadata.c:4861
aaruf_lzma_encode_buffer
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.
Definition lzma.c:65
aaruf_crc64_data
uint64_t aaruf_crc64_data(const uint8_t *data, uint32_t len)
Definition crc64.c:160
aaruf_flac_encode_redbook_buffer
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.
Definition flac.c:175
aaruf_lzma_decode_buffer
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.
Definition lzma.c:39
aaruf_get_drive_serial_number
int32_t aaruf_get_drive_serial_number(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the imaging drive's serial number metadata.
Definition metadata.c:3111
aaruf_set_drive_model
int32_t aaruf_set_drive_model(void *context, const uint8_t *data, int32_t length)
Sets the drive model information for the image.
Definition metadata.c:1536
aaruf_get_tape_file
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.
Definition tape.c:569
aaruf_set_creator
int32_t aaruf_set_creator(void *context, const uint8_t *data, int32_t length)
Sets the creator (person/operator) information for the image.
Definition metadata.c:495
aaruf_md5_init
void aaruf_md5_init(md5_ctx *ctx)
Definition md5.c:436
aaruf_sha1_buffer
void aaruf_sha1_buffer(const void *data, unsigned long size, unsigned char *result)
Definition sha1.c:155
aaruf_crc64_update
int aaruf_crc64_update(crc64_ctx *ctx, const uint8_t *data, uint32_t len)
Updates the CRC64 context with new data.
Definition crc64.c:55
aaruf_clear_media_serial_number
int32_t aaruf_clear_media_serial_number(void *context)
Clears the media serial number from the image metadata.
Definition metadata.c:4340
aaruf_set_geometry
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.
Definition metadata.c:230
aaruf_read_sector
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.
Definition read.c:253
fuzzy_try_fork_blockhash
void fuzzy_try_fork_blockhash(spamsum_ctx *ctx)
Definition spamsum.c:175
aaruf_clear_media_barcode
int32_t aaruf_clear_media_barcode(void *context)
Clears the media barcode information from the image metadata.
Definition metadata.c:4426
aaruf_get_all_tape_partitions
int32_t aaruf_get_all_tape_partitions(const void *context, uint8_t *buffer, size_t *length)
Retrieves all tape partition entries from the image.
Definition tape.c:1416
aaruf_get_tracks
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.
Definition optical.c:281
aaruf_set_media_serial_number
int32_t aaruf_set_media_serial_number(void *context, const uint8_t *data, int32_t length)
Sets the media serial number for the image.
Definition metadata.c:1056
aaruf_ecc_cd_write_sector
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).
Definition ecc_cd.c:352
aaruf_get_dumphw
int32_t aaruf_get_dumphw(void *context, uint8_t *buffer, size_t *length)
Retrieves the dump hardware block containing acquisition environment information.
Definition dump.c:186
aaruf_set_media_title
int32_t aaruf_set_media_title(void *context, const uint8_t *data, int32_t length)
Sets the media title or label for the image.
Definition metadata.c:722
aaruf_get_creator
int32_t aaruf_get_creator(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the recorded creator (operator) name from the MetadataBlock.
Definition metadata.c:2407
aaruf_set_drive_manufacturer
int32_t aaruf_set_drive_manufacturer(void *context, const uint8_t *data, int32_t length)
Sets the drive manufacturer information for the image.
Definition metadata.c:1414
aaruf_set_media_manufacturer
int32_t aaruf_set_media_manufacturer(void *context, const uint8_t *data, int32_t length)
Sets the media manufacturer information for the image.
Definition metadata.c:834
aaruf_get_drive_firmware_revision
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.
Definition metadata.c:3181
aaruf_clear_media_title
int32_t aaruf_clear_media_title(void *context)
Clears the media title or label from the image metadata.
Definition metadata.c:4086
aaruf_clear_media_manufacturer
int32_t aaruf_clear_media_manufacturer(void *context)
Clears the media manufacturer information from the image metadata.
Definition metadata.c:4170
aaruf_get_cicm_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.
Definition metadata.c:1947
aaruf_clear_drive_model
int32_t aaruf_clear_drive_model(void *context)
Clears the drive model information from the image metadata.
Definition metadata.c:4684
aaruf_set_media_barcode
int32_t aaruf_set_media_barcode(void *context, const uint8_t *data, int32_t length)
Sets the media barcode information for the image.
Definition metadata.c:1178
aaruf_read_media_tag
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.
Definition read.c:85
aaruf_crc64_free
void aaruf_crc64_free(crc64_ctx *ctx)
Frees a CRC64 context.
Definition crc64.c:155
aaruf_write_sector
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.
Definition write.c:98
aaruf_get_media_serial_number
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.
Definition metadata.c:2759
aaruf_get_media_part_number
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.
Definition metadata.c:2899
aaruf_get_media_model
int32_t aaruf_get_media_model(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the media model or product designation metadata.
Definition metadata.c:2689
aaruf_get_media_manufacturer
int32_t aaruf_get_media_manufacturer(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the recorded media manufacturer name.
Definition metadata.c:2619
aaruf_set_tracks
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.
Definition optical.c:392
aaruf_get_drive_model
int32_t aaruf_get_drive_model(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the device model information for the imaging drive.
Definition metadata.c:3041
aaruf_get_media_tag_type_for_datatype
int32_t aaruf_get_media_tag_type_for_datatype(int32_t type)
Converts an image data type to an Aaru media tag type.
Definition helpers.c:39
aaruf_ecc_cd_check
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.
Definition ecc_cd.c:227
aaruf_get_media_barcode
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.
Definition metadata.c:2828
aaruf_spamsum_update
int aaruf_spamsum_update(spamsum_ctx *ctx, const uint8_t *data, uint32_t len)
Updates the spamsum context with new data.
Definition spamsum.c:59
aaruf_get_drive_manufacturer
int32_t aaruf_get_drive_manufacturer(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the drive manufacturer metadata captured during imaging.
Definition metadata.c:2971
aaruf_clear_drive_manufacturer
int32_t aaruf_clear_drive_manufacturer(void *context)
Clears the drive manufacturer information from the image metadata.
Definition metadata.c:4598
aaruf_sha256_final
void aaruf_sha256_final(sha256_ctx *ctx, unsigned char *result)
Definition sha256.c:115
aaruf_get_image_info
int32_t aaruf_get_image_info(const void *context, ImageInfo *image_info)
Retrieves a deep copy of the ImageInfo structure from the AaruFormat image.
Definition metadata.c:3637
aaruf_crc64_init
crc64_ctx * aaruf_crc64_init()
Initializes a CRC64 context.
Definition crc64.c:32
aaruf_edc_cd_compute
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.
Definition ecc_cd.c:547
fuzzy_engine_step
void fuzzy_engine_step(spamsum_ctx *ctx, uint8_t c)
Definition spamsum.c:84
aaruf_close
int aaruf_close(void *context)
Close an Aaru image context, flushing pending data structures and releasing resources.
Definition close.c:3995
aaruf_write_sector_long
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...
Definition write.c:532
aaruf_write_sector_tag
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.
Definition write.c:2059
aaruf_md5_final
void aaruf_md5_final(md5_ctx *ctx, unsigned char *result)
Definition md5.c:485
aaruf_md5_update
void aaruf_md5_update(md5_ctx *ctx, const void *data, unsigned long size)
Definition md5.c:447
aaruf_identify_stream
int aaruf_identify_stream(FILE *image_stream)
Identifies a file as an AaruFormat image using an open stream.
Definition identify.c:163
aaruf_spamsum_free
void aaruf_spamsum_free(spamsum_ctx *ctx)
Frees a spamsum (fuzzy hash) context.
Definition spamsum.c:75
aaruf_create
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.
Definition create.c:279
aaruf_ecc_cd_reconstruct_prefix
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.
Definition ecc_cd.c:392
aaruf_identify
int aaruf_identify(const char *filename)
Identifies a file as an AaruFormat image using a file path.
Definition identify.c:84
aaruf_spamsum_init
spamsum_ctx * aaruf_spamsum_init(void)
Definition spamsum.c:37
aaruf_sha256_buffer
void aaruf_sha256_buffer(const void *data, unsigned long size, unsigned char *result)
Definition sha256.c:141
aaruf_get_user_sectors
int32_t aaruf_get_user_sectors(const void *context, uint64_t *sectors)
Retrieves the total number of user-accessible sectors in the AaruFormat image.
Definition metadata.c:3295
aaruf_set_aaru_json_metadata
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.
Definition metadata.c:2261
aaruf_crc64_slicing
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.
Definition crc64.c:102
aaruf_clear_media_part_number
int32_t aaruf_clear_media_part_number(void *context)
Clears the media part number or model designation from the image metadata.
Definition metadata.c:4512
aaruf_clear_comments
int32_t aaruf_clear_comments(void *context)
Clears user comments or notes from the image metadata.
Definition metadata.c:4003
aaruf_ecc_cd_write
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.
Definition ecc_cd.c:293
AARU_LOCAL
#define AARU_LOCAL
Definition decls.h:55
aaruf_verify_image
int32_t aaruf_verify_image(void *context)
Verifies the integrity of an AaruFormat image file.
Definition verify.c:130
aaruf_get_datatype_for_media_tag_type
int32_t aaruf_get_datatype_for_media_tag_type(int32_t tag_type)
Converts an Aaru media tag type to an image data type.
Definition helpers.c:197
aaruf_get_negative_sectors
int32_t aaruf_get_negative_sectors(const void *context, uint16_t *sectors)
Retrieves the number of negative (pre-gap) sectors in the AaruFormat image.
Definition metadata.c:3420
aaruf_set_media_model
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.
Definition metadata.c:941
AARU_EXPORT
#define AARU_EXPORT
Definition decls.h:54
fuzzy_try_reduce_blockhash
void fuzzy_try_reduce_blockhash(spamsum_ctx *ctx)
Definition spamsum.c:155
aaruf_clear_media_model
int32_t aaruf_clear_media_model(void *context)
Clears the media model or product designation from the image metadata.
Definition metadata.c:4254
aaruf_get_comments
int32_t aaruf_get_comments(const void *context, uint8_t *buffer, int32_t *length)
Retrieves the user comments or notes stored in the MetadataBlock.
Definition metadata.c:2479
aaruf_sha1_init
void aaruf_sha1_init(sha1_ctx *ctx)
Definition sha1.c:34
aaruf_ecc_cd_reconstruct
void aaruf_ecc_cd_reconstruct(void *context, uint8_t *sector, uint8_t type)
Reconstructs the EDC and ECC fields of a CD sector.
Definition ecc_cd.c:459
aaruf_get_readable_media_tags
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.
Definition metadata.c:706
aaruf_set_tape_partition
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.
Definition tape.c:1196
roll_hash
void roll_hash(spamsum_ctx *ctx, uint8_t c)
Definition spamsum.c:137
aaruf_write_media_tag
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.
Definition write.c:1790
aaruf_get_media_sequence
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.
Definition metadata.c:2340
aaruf_clear_drive_serial_number
int32_t aaruf_clear_drive_serial_number(void *context)
Clears the drive serial number from the image metadata.
Definition metadata.c:4773
aaruf_get_readable_sector_tags
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.
Definition metadata.c:618
aaruf_get_tape_partition
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.
Definition tape.c:982
aaruf_spamsum_final
int aaruf_spamsum_final(spamsum_ctx *ctx, uint8_t *result)
Definition spamsum.c:191
aaruf_sha256_update
void aaruf_sha256_update(sha256_ctx *ctx, const void *data, unsigned long size)
Definition sha256.c:90
aaruf_ecc_cd_is_suffix_correct_mode2
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).
Definition ecc_cd.c:165
aaruf_get_geometry
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.
Definition metadata.c:94
aaruf_md5_buffer
void aaruf_md5_buffer(const void *data, unsigned long size, unsigned char *result)
Definition md5.c:518
aaruf_sha1_update
void aaruf_sha1_update(sha1_ctx *ctx, const void *data, unsigned long size)
Definition sha1.c:89
aaruf_ecc_cd_init
void * aaruf_ecc_cd_init()
Initializes a Compact Disc ECC context.
Definition ecc_cd.c:35
aaruf_clear_creator
int32_t aaruf_clear_creator(void *context)
Clears the creator (person/operator) information from the image metadata.
Definition metadata.c:3874
aaruf_get_xml_mediatype
int32_t aaruf_get_xml_mediatype(int32_t type)
Definition helpers.c:347
aaruf_get_all_tape_files
int32_t aaruf_get_all_tape_files(const void *context, uint8_t *buffer, size_t *length)
Retrieves all tape file entries from the image.
Definition tape.c:1314
aaruf_set_dumphw
int32_t aaruf_set_dumphw(void *context, uint8_t *data, size_t length)
Sets the dump hardware block for the image during creation.
Definition dump.c:531
aaruf_set_drive_firmware_revision
int32_t aaruf_set_drive_firmware_revision(void *context, const uint8_t *data, int32_t length)
Sets the drive firmware revision for the image.
Definition metadata.c:1795
aaruf_cst_untransform
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.
Definition cst.c:193
aaruf_read_track_sector
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.
Definition read.c:670
aaruf_crc64_final
int aaruf_crc64_final(crc64_ctx *ctx, uint64_t *crc)
Computes the final CRC64 value from the context.
Definition crc64.c:141
aaruf_read_sector_tag
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.
Definition read.c:1474
aaruf_read_sector_long
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.
Definition read.c:826
aaruf_get_overflow_sectors
int32_t aaruf_get_overflow_sectors(const void *context, uint16_t *sectors)
Retrieves the number of overflow (post-gap) sectors in the AaruFormat image.
Definition metadata.c:3555
aaruf_set_drive_serial_number
int32_t aaruf_set_drive_serial_number(void *context, const uint8_t *data, int32_t length)
Sets the drive serial number for the image.
Definition metadata.c:1660
aaruf_flac_decode_redbook_buffer
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.
Definition flac.c:48
aaruf_get_media_title
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.
Definition metadata.c:2549
aaruf_set_comments
int32_t aaruf_set_comments(void *context, const uint8_t *data, int32_t length)
Sets user comments or notes for the image.
Definition metadata.c:609
aaruf_ecc_cd_is_suffix_correct
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).
Definition ecc_cd.c:101
aaruf_open
void * aaruf_open(const char *filepath)
Opens an existing AaruFormat image file.
Definition open.c:125
md5.h
optical.h
On-disk structures describing optical disc tracks (Track list block).
sha1.h
sha256.h
simd.h
spamsum.h
ImageInfo
High-level summary of an opened Aaru image containing metadata and media characteristics.
Definition aaru.h:870
TrackEntry
Single optical disc track descriptor (sequence, type, LBAs, session, ISRC, flags).
Definition optical.h:72
crc64_ctx
Minimal ECMA-182 CRC64 incremental state container (running value only).
Definition crc64.h:56
md5_ctx
Definition md5.h:32
sha1_ctx
Definition sha1.h:43
sha256_ctx
Definition sha256.h:42
spamsum_ctx
Definition spamsum.h:51