libaaruformat 1.0 Aaru Data Preservation Suite - Format Library

Loading...
Searching...
No Matches
metadata.c
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#include <stddef.h>
20#include <stdint.h>
21
22#include "aaruformat.h"
23#include "log.h"
24
94 AARU_EXPORT int32_t AARU_CALL aaruf_get_geometry(const void *context, uint32_t *cylinders, uint32_t *heads,
95 uint32_t *sectors_per_track)
96{
97 TRACE("Entering aaruf_get_geometry(%p, %p, %p, %p)", context, cylinders, heads, sectors_per_track);
98
99 const aaruformat_context *ctx = NULL;
100
101 if(context == NULL)
102 {
103 FATAL("Invalid context");
104
105 TRACE("Exiting aaruf_get_geometry() = AARUF_ERROR_NOT_AARUFORMAT");
106 return AARUF_ERROR_NOT_AARUFORMAT;
107 }
108
109 ctx = context;
110
111 // Not a libaaruformat context
112 if(ctx->magic != AARU_MAGIC)
113 {
114 FATAL("Invalid context");
115
116 TRACE("Exiting aaruf_get_geometry() = AARUF_ERROR_NOT_AARUFORMAT");
117 return AARUF_ERROR_NOT_AARUFORMAT;
118 }
119
120 if(ctx->geometry_block.identifier != GeometryBlock)
121 {
122 FATAL("No geometry block present");
123
124 TRACE("Exiting aaruf_get_geometry() = AARUF_ERROR_CANNOT_READ_BLOCK");
125 return AARUF_ERROR_CANNOT_READ_BLOCK;
126 }
127
128 *cylinders = ctx->geometry_block.cylinders;
129 *heads = ctx->geometry_block.heads;
130 *sectors_per_track = ctx->geometry_block.sectorsPerTrack;
131
132 TRACE("Exiting aaruf_get_geometry(%p, %u, %u, %u) = AARUF_STATUS_OK", context, *cylinders, *heads,
133 *sectors_per_track);
134 return AARUF_STATUS_OK;
135}
136
230 AARU_EXPORT int32_t AARU_CALL aaruf_set_geometry(void *context, const uint32_t cylinders, const uint32_t heads,
231 const uint32_t sectors_per_track)
232{
233 TRACE("Entering aaruf_set_geometry(%p, %u, %u, %u)", context, cylinders, heads, sectors_per_track);
234
235 aaruformat_context *ctx = NULL;
236
237 if(context == NULL)
238 {
239 FATAL("Invalid context");
240
241 TRACE("Exiting aaruf_set_geometry() = AARUF_ERROR_NOT_AARUFORMAT");
242 return AARUF_ERROR_NOT_AARUFORMAT;
243 }
244
245 ctx = context;
246
247 // Not a libaaruformat context
248 if(ctx->magic != AARU_MAGIC)
249 {
250 FATAL("Invalid context");
251
252 TRACE("Exiting aaruf_set_geometry() = AARUF_ERROR_NOT_AARUFORMAT");
253 return AARUF_ERROR_NOT_AARUFORMAT;
254 }
255
256 // Check we are writing
257 if(!ctx->is_writing)
258 {
259 FATAL("Trying to write a read-only image");
260
261 TRACE("Exiting aaruf_write_sector() = AARUF_READ_ONLY");
262 return AARUF_READ_ONLY;
263 }
264
265 ctx->geometry_block.identifier = GeometryBlock;
266 ctx->geometry_block.cylinders = cylinders;
267 ctx->geometry_block.heads = heads;
268 ctx->geometry_block.sectorsPerTrack = sectors_per_track;
269 ctx->cylinders = cylinders;
270 ctx->heads = heads;
271 ctx->sectors_per_track = sectors_per_track;
272
273 TRACE("Exiting aaruf_set_geometry(%p, %u, %u, %u) = AARUF_STATUS_OK", context, cylinders, heads, sectors_per_track);
274 return AARUF_STATUS_OK;
275}
276
364 AARU_EXPORT int32_t AARU_CALL aaruf_set_media_sequence(void *context, const int32_t sequence,
365 const int32_t last_sequence)
366{
367 TRACE("Entering aaruf_set_media_sequence(%p, %d, %d)", context, sequence, last_sequence);
368
369 // Check context is correct AaruFormat context
370 if(context == NULL)
371 {
372 FATAL("Invalid context");
373
374 TRACE("Exiting aaruf_set_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
375 return AARUF_ERROR_NOT_AARUFORMAT;
376 }
377
378 aaruformat_context *ctx = context;
379
380 // Not a libaaruformat context
381 if(ctx->magic != AARU_MAGIC)
382 {
383 FATAL("Invalid context");
384
385 TRACE("Exiting aaruf_set_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
386 return AARUF_ERROR_NOT_AARUFORMAT;
387 }
388
389 // Check we are writing
390 if(!ctx->is_writing)
391 {
392 FATAL("Trying to write a read-only image");
393
394 TRACE("Exiting aaruf_set_media_sequence() = AARUF_READ_ONLY");
395 return AARUF_READ_ONLY;
396 }
397
398 // Initialize
399 if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
400
401 ctx->metadata_block_header.mediaSequence = sequence;
402 ctx->metadata_block_header.lastMediaSequence = last_sequence;
403
404 TRACE("Exiting aaruf_set_media_sequence(%p, %d, %d) = AARUF_STATUS_OK", context, sequence, last_sequence);
405 return AARUF_STATUS_OK;
406}
407
495 AARU_EXPORT int32_t AARU_CALL aaruf_set_creator(void *context, const uint8_t *data, const int32_t length)
496{
497 TRACE("Entering aaruf_set_creator(%p, %p, %d)", context, data, length);
498
499 // Check context is correct AaruFormat context
500 if(context == NULL)
501 {
502 FATAL("Invalid context");
503
504 TRACE("Exiting aaruf_set_creator() = AARUF_ERROR_NOT_AARUFORMAT");
505 return AARUF_ERROR_NOT_AARUFORMAT;
506 }
507
508 aaruformat_context *ctx = context;
509
510 // Not a libaaruformat context
511 if(ctx->magic != AARU_MAGIC)
512 {
513 FATAL("Invalid context");
514
515 TRACE("Exiting aaruf_set_creator() = AARUF_ERROR_NOT_AARUFORMAT");
516 return AARUF_ERROR_NOT_AARUFORMAT;
517 }
518
519 // Check we are writing
520 if(!ctx->is_writing)
521 {
522 FATAL("Trying to write a read-only image");
523
524 TRACE("Exiting aaruf_set_creator() = AARUF_READ_ONLY");
525 return AARUF_READ_ONLY;
526 }
527
528 // Initialize
529 if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
530
531 // Reserve memory
532 uint8_t *copy = malloc(length);
533 if(copy == NULL)
534 {
535 FATAL("Could not allocate memory for creator");
536 return AARUF_ERROR_NOT_ENOUGH_MEMORY;
537 }
538
539 // Copy opaque UTF-16LE string
540 memcpy(copy, data, length);
541 if(ctx->creator != NULL) free(ctx->creator);
542 ctx->creator = copy;
543 ctx->metadata_block_header.creatorLength = length;
544
545 TRACE("Exiting aaruf_set_creator(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
546 return AARUF_STATUS_OK;
547}
548
609 AARU_EXPORT int32_t AARU_CALL aaruf_set_comments(void *context, const uint8_t *data, const int32_t length)
610{
611 TRACE("Entering aaruf_set_comments(%p, %p, %d)", context, data, length);
612
613 // Check context is correct AaruFormat context
614 if(context == NULL)
615 {
616 FATAL("Invalid context");
617
618 TRACE("Exiting aaruf_set_comments() = AARUF_ERROR_NOT_AARUFORMAT");
619 return AARUF_ERROR_NOT_AARUFORMAT;
620 }
621
622 aaruformat_context *ctx = context;
623
624 // Not a libaaruformat context
625 if(ctx->magic != AARU_MAGIC)
626 {
627 FATAL("Invalid context");
628
629 TRACE("Exiting aaruf_set_comments() = AARUF_ERROR_NOT_AARUFORMAT");
630 return AARUF_ERROR_NOT_AARUFORMAT;
631 }
632
633 // Check we are writing
634 if(!ctx->is_writing)
635 {
636 FATAL("Trying to write a read-only image");
637
638 TRACE("Exiting aaruf_set_comments() = AARUF_READ_ONLY");
639 return AARUF_READ_ONLY;
640 }
641
642 // Initialize
643 if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
644
645 // Reserve memory
646 uint8_t *copy = malloc(length);
647 if(copy == NULL)
648 {
649 FATAL("Could not allocate memory for comments");
650 return AARUF_ERROR_NOT_ENOUGH_MEMORY;
651 }
652
653 // Copy opaque UTF-16LE string
654 memcpy(copy, data, length);
655 if(ctx->comments != NULL) free(ctx->comments);
656 ctx->comments = copy;
657 ctx->metadata_block_header.commentsLength = length;
658
659 TRACE("Exiting aaruf_set_comments(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
660 return AARUF_STATUS_OK;
661}
662
722 AARU_EXPORT int32_t AARU_CALL aaruf_set_media_title(void *context, const uint8_t *data, const int32_t length)
723{
724 TRACE("Entering aaruf_set_media_title(%p, %p, %d)", context, data, length);
725
726 // Check context is correct AaruFormat context
727 if(context == NULL)
728 {
729 FATAL("Invalid context");
730
731 TRACE("Exiting aaruf_set_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
732 return AARUF_ERROR_NOT_AARUFORMAT;
733 }
734
735 aaruformat_context *ctx = context;
736
737 // Not a libaaruformat context
738 if(ctx->magic != AARU_MAGIC)
739 {
740 FATAL("Invalid context");
741
742 TRACE("Exiting aaruf_set_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
743 return AARUF_ERROR_NOT_AARUFORMAT;
744 }
745
746 // Check we are writing
747 if(!ctx->is_writing)
748 {
749 FATAL("Trying to write a read-only image");
750
751 TRACE("Exiting aaruf_set_media_title() = AARUF_READ_ONLY");
752 return AARUF_READ_ONLY;
753 }
754
755 // Initialize
756 if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
757
758 // Reserve memory
759 uint8_t *copy = malloc(length);
760 if(copy == NULL)
761 {
762 FATAL("Could not allocate memory for media title");
763 return AARUF_ERROR_NOT_ENOUGH_MEMORY;
764 }
765
766 // Copy opaque UTF-16LE string
767 memcpy(copy, data, length);
768 if(ctx->media_title != NULL) free(ctx->media_title);
769 ctx->media_title = copy;
770 ctx->metadata_block_header.mediaTitleLength = length;
771
772 TRACE("Exiting aaruf_set_media_title(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
773 return AARUF_STATUS_OK;
774}
775
834 AARU_EXPORT int32_t AARU_CALL aaruf_set_media_manufacturer(void *context, const uint8_t *data, const int32_t length)
835{
836 TRACE("Entering aaruf_set_media_manufacturer(%p, %p, %d)", context, data, length);
837
838 // Check context is correct AaruFormat context
839 if(context == NULL)
840 {
841 FATAL("Invalid context");
842
843 TRACE("Exiting aaruf_set_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
844 return AARUF_ERROR_NOT_AARUFORMAT;
845 }
846
847 aaruformat_context *ctx = context;
848
849 // Not a libaaruformat context
850 if(ctx->magic != AARU_MAGIC)
851 {
852 FATAL("Invalid context");
853
854 TRACE("Exiting aaruf_set_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
855 return AARUF_ERROR_NOT_AARUFORMAT;
856 }
857
858 // Check we are writing
859 if(!ctx->is_writing)
860 {
861 FATAL("Trying to write a read-only image");
862
863 TRACE("Exiting aaruf_set_media_manufacturer() = AARUF_READ_ONLY");
864 return AARUF_READ_ONLY;
865 }
866
867 // Initialize
868 if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
869
870 // Reserve memory
871 uint8_t *copy = malloc(length);
872 if(copy == NULL)
873 {
874 FATAL("Could not allocate memory for media manufacturer");
875 return AARUF_ERROR_NOT_ENOUGH_MEMORY;
876 }
877
878 // Copy opaque UTF-16LE string
879 memcpy(copy, data, length);
880 if(ctx->media_manufacturer != NULL) free(ctx->media_manufacturer);
881 ctx->media_manufacturer = copy;
882 ctx->metadata_block_header.mediaManufacturerLength = length;
883
884 TRACE("Exiting aaruf_set_media_manufacturer(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
885 return AARUF_STATUS_OK;
886}
887
941 AARU_EXPORT int32_t AARU_CALL aaruf_set_media_model(void *context, const uint8_t *data, const int32_t length)
942{
943 TRACE("Entering aaruf_set_media_model(%p, %p, %d)", context, data, length);
944
945 // Check context is correct AaruFormat context
946 if(context == NULL)
947 {
948 FATAL("Invalid context");
949
950 TRACE("Exiting aaruf_set_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
951 return AARUF_ERROR_NOT_AARUFORMAT;
952 }
953
954 aaruformat_context *ctx = context;
955
956 // Not a libaaruformat context
957 if(ctx->magic != AARU_MAGIC)
958 {
959 FATAL("Invalid context");
960
961 TRACE("Exiting aaruf_set_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
962 return AARUF_ERROR_NOT_AARUFORMAT;
963 }
964
965 // Check we are writing
966 if(!ctx->is_writing)
967 {
968 FATAL("Trying to write a read-only image");
969
970 TRACE("Exiting aaruf_set_media_model() = AARUF_READ_ONLY");
971 return AARUF_READ_ONLY;
972 }
973
974 // Initialize
975 if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
976
977 // Reserve memory
978 uint8_t *copy = malloc(length);
979 if(copy == NULL)
980 {
981 FATAL("Could not allocate memory for media model");
982 return AARUF_ERROR_NOT_ENOUGH_MEMORY;
983 }
984
985 // Copy opaque UTF-16LE string
986 memcpy(copy, data, length);
987 if(ctx->media_model != NULL) free(ctx->media_model);
988 ctx->media_model = copy;
989 ctx->metadata_block_header.mediaModelLength = length;
990
991 TRACE("Exiting aaruf_set_media_model(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
992 return AARUF_STATUS_OK;
993}
994
1056 AARU_EXPORT int32_t AARU_CALL aaruf_set_media_serial_number(void *context, const uint8_t *data, const int32_t length)
1057{
1058 TRACE("Entering aaruf_set_media_serial_number(%p, %p, %d)", context, data, length);
1059
1060 // Check context is correct AaruFormat context
1061 if(context == NULL)
1062 {
1063 FATAL("Invalid context");
1064
1065 TRACE("Exiting aaruf_set_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
1066 return AARUF_ERROR_NOT_AARUFORMAT;
1067 }
1068
1069 aaruformat_context *ctx = context;
1070
1071 // Not a libaaruformat context
1072 if(ctx->magic != AARU_MAGIC)
1073 {
1074 FATAL("Invalid context");
1075
1076 TRACE("Exiting aaruf_set_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
1077 return AARUF_ERROR_NOT_AARUFORMAT;
1078 }
1079
1080 // Check we are writing
1081 if(!ctx->is_writing)
1082 {
1083 FATAL("Trying to write a read-only image");
1084
1085 TRACE("Exiting aaruf_set_media_serial_number() = AARUF_READ_ONLY");
1086 return AARUF_READ_ONLY;
1087 }
1088
1089 // Initialize
1090 if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
1091
1092 // Reserve memory
1093 uint8_t *copy = malloc(length);
1094 if(copy == NULL)
1095 {
1096 FATAL("Could not allocate memory for media serial number");
1097 return AARUF_ERROR_NOT_ENOUGH_MEMORY;
1098 }
1099
1100 // Copy opaque UTF-16LE string
1101 memcpy(copy, data, length);
1102 if(ctx->media_serial_number != NULL) free(ctx->media_serial_number);
1103 ctx->media_serial_number = copy;
1104 ctx->metadata_block_header.mediaSerialNumberLength = length;
1105
1106 TRACE("Exiting aaruf_set_media_serial_number(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
1107 return AARUF_STATUS_OK;
1108}
1109
1178 AARU_EXPORT int32_t AARU_CALL aaruf_set_media_barcode(void *context, const uint8_t *data, const int32_t length)
1179{
1180 TRACE("Entering aaruf_set_media_barcode(%p, %p, %d)", context, data, length);
1181
1182 // Check context is correct AaruFormat context
1183 if(context == NULL)
1184 {
1185 FATAL("Invalid context");
1186
1187 TRACE("Exiting aaruf_set_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
1188 return AARUF_ERROR_NOT_AARUFORMAT;
1189 }
1190
1191 aaruformat_context *ctx = context;
1192
1193 // Not a libaaruformat context
1194 if(ctx->magic != AARU_MAGIC)
1195 {
1196 FATAL("Invalid context");
1197
1198 TRACE("Exiting aaruf_set_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
1199 return AARUF_ERROR_NOT_AARUFORMAT;
1200 }
1201
1202 // Check we are writing
1203 if(!ctx->is_writing)
1204 {
1205 FATAL("Trying to write a read-only image");
1206
1207 TRACE("Exiting aaruf_set_media_barcode() = AARUF_READ_ONLY");
1208 return AARUF_READ_ONLY;
1209 }
1210
1211 // Initialize
1212 if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
1213
1214 // Reserve memory
1215 uint8_t *copy = malloc(length);
1216 if(copy == NULL)
1217 {
1218 FATAL("Could not allocate memory for media barcode");
1219 return AARUF_ERROR_NOT_ENOUGH_MEMORY;
1220 }
1221
1222 // Copy opaque UTF-16LE string
1223 memcpy(copy, data, length);
1224 if(ctx->media_barcode != NULL) free(ctx->media_barcode);
1225 ctx->media_barcode = copy;
1226 ctx->metadata_block_header.mediaBarcodeLength = length;
1227
1228 TRACE("Exiting aaruf_set_media_barcode(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
1229 return AARUF_STATUS_OK;
1230}
1231
1299 AARU_EXPORT int32_t AARU_CALL aaruf_set_media_part_number(void *context, const uint8_t *data, const int32_t length)
1300{
1301 TRACE("Entering aaruf_set_media_part_number(%p, %p, %d)", context, data, length);
1302
1303 // Check context is correct AaruFormat context
1304 if(context == NULL)
1305 {
1306 FATAL("Invalid context");
1307
1308 TRACE("Exiting aaruf_set_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
1309 return AARUF_ERROR_NOT_AARUFORMAT;
1310 }
1311
1312 aaruformat_context *ctx = context;
1313
1314 // Not a libaaruformat context
1315 if(ctx->magic != AARU_MAGIC)
1316 {
1317 FATAL("Invalid context");
1318
1319 TRACE("Exiting aaruf_set_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
1320 return AARUF_ERROR_NOT_AARUFORMAT;
1321 }
1322
1323 // Check we are writing
1324 if(!ctx->is_writing)
1325 {
1326 FATAL("Trying to write a read-only image");
1327
1328 TRACE("Exiting aaruf_set_media_part_number() = AARUF_READ_ONLY");
1329 return AARUF_READ_ONLY;
1330 }
1331
1332 // Initialize
1333 if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
1334
1335 // Reserve memory
1336 uint8_t *copy = malloc(length);
1337 if(copy == NULL)
1338 {
1339 FATAL("Could not allocate memory for creator");
1340 return AARUF_ERROR_NOT_ENOUGH_MEMORY;
1341 }
1342
1343 // Copy opaque UTF-16LE string
1344 memcpy(copy, data, length);
1345 if(ctx->media_part_number != NULL) free(ctx->media_part_number);
1346 ctx->media_part_number = copy;
1347 ctx->metadata_block_header.mediaPartNumberLength = length;
1348
1349 TRACE("Exiting aaruf_set_media_part_number(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
1350 return AARUF_STATUS_OK;
1351}
1352
1414 AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_manufacturer(void *context, const uint8_t *data, const int32_t length)
1415{
1416 TRACE("Entering aaruf_set_drive_manufacturer(%p, %p, %d)", context, data, length);
1417
1418 // Check context is correct AaruFormat context
1419 if(context == NULL)
1420 {
1421 FATAL("Invalid context");
1422
1423 TRACE("Exiting aaruf_set_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
1424 return AARUF_ERROR_NOT_AARUFORMAT;
1425 }
1426
1427 aaruformat_context *ctx = context;
1428
1429 // Not a libaaruformat context
1430 if(ctx->magic != AARU_MAGIC)
1431 {
1432 FATAL("Invalid context");
1433
1434 TRACE("Exiting aaruf_set_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
1435 return AARUF_ERROR_NOT_AARUFORMAT;
1436 }
1437
1438 // Check we are writing
1439 if(!ctx->is_writing)
1440 {
1441 FATAL("Trying to write a read-only image");
1442
1443 TRACE("Exiting aaruf_set_drive_manufacturer() = AARUF_READ_ONLY");
1444 return AARUF_READ_ONLY;
1445 }
1446
1447 // Initialize
1448 if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
1449
1450 // Reserve memory
1451 uint8_t *copy = malloc(length);
1452 if(copy == NULL)
1453 {
1454 FATAL("Could not allocate memory for drive manufacturer");
1455 return AARUF_ERROR_NOT_ENOUGH_MEMORY;
1456 }
1457
1458 // Copy opaque UTF-16LE string
1459 memcpy(copy, data, length);
1460 if(ctx->drive_manufacturer != NULL) free(ctx->drive_manufacturer);
1461 ctx->drive_manufacturer = copy;
1462 ctx->metadata_block_header.driveManufacturerLength = length;
1463
1464 TRACE("Exiting aaruf_set_drive_manufacturer(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
1465 return AARUF_STATUS_OK;
1466}
1467
1536 AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_model(void *context, const uint8_t *data, const int32_t length)
1537{
1538 TRACE("Entering aaruf_set_drive_model(%p, %p, %d)", context, data, length);
1539
1540 // Check context is correct AaruFormat context
1541 if(context == NULL)
1542 {
1543 FATAL("Invalid context");
1544
1545 TRACE("Exiting aaruf_set_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
1546 return AARUF_ERROR_NOT_AARUFORMAT;
1547 }
1548
1549 aaruformat_context *ctx = context;
1550
1551 // Not a libaaruformat context
1552 if(ctx->magic != AARU_MAGIC)
1553 {
1554 FATAL("Invalid context");
1555
1556 TRACE("Exiting aaruf_set_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
1557 return AARUF_ERROR_NOT_AARUFORMAT;
1558 }
1559
1560 // Check we are writing
1561 if(!ctx->is_writing)
1562 {
1563 FATAL("Trying to write a read-only image");
1564
1565 TRACE("Exiting aaruf_set_drive_model() = AARUF_READ_ONLY");
1566 return AARUF_READ_ONLY;
1567 }
1568
1569 // Initialize
1570 if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
1571
1572 // Reserve memory
1573 uint8_t *copy = malloc(length);
1574 if(copy == NULL)
1575 {
1576 FATAL("Could not allocate memory for media model");
1577 return AARUF_ERROR_NOT_ENOUGH_MEMORY;
1578 }
1579
1580 // Copy opaque UTF-16LE string
1581 memcpy(copy, data, length);
1582 if(ctx->drive_model != NULL) free(ctx->drive_model);
1583 ctx->drive_model = copy;
1584 ctx->metadata_block_header.driveModelLength = length;
1585
1586 TRACE("Exiting aaruf_set_drive_model(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
1587 return AARUF_STATUS_OK;
1588}
1589
1660 AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_serial_number(void *context, const uint8_t *data, const int32_t length)
1661{
1662 TRACE("Entering aaruf_set_drive_serial_number(%p, %p, %d)", context, data, length);
1663
1664 // Check context is correct AaruFormat context
1665 if(context == NULL)
1666 {
1667 FATAL("Invalid context");
1668
1669 TRACE("Exiting aaruf_set_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
1670 return AARUF_ERROR_NOT_AARUFORMAT;
1671 }
1672
1673 aaruformat_context *ctx = context;
1674
1675 // Not a libaaruformat context
1676 if(ctx->magic != AARU_MAGIC)
1677 {
1678 FATAL("Invalid context");
1679
1680 TRACE("Exiting aaruf_set_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
1681 return AARUF_ERROR_NOT_AARUFORMAT;
1682 }
1683
1684 // Check we are writing
1685 if(!ctx->is_writing)
1686 {
1687 FATAL("Trying to write a read-only image");
1688
1689 TRACE("Exiting aaruf_set_drive_serial_number() = AARUF_READ_ONLY");
1690 return AARUF_READ_ONLY;
1691 }
1692
1693 // Initialize
1694 if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
1695
1696 // Reserve memory
1697 uint8_t *copy = malloc(length);
1698 if(copy == NULL)
1699 {
1700 FATAL("Could not allocate memory for drive serial number");
1701 return AARUF_ERROR_NOT_ENOUGH_MEMORY;
1702 }
1703
1704 // Copy opaque UTF-16LE string
1705 memcpy(copy, data, length);
1706 if(ctx->drive_serial_number != NULL) free(ctx->drive_serial_number);
1707 ctx->drive_serial_number = copy;
1708 ctx->metadata_block_header.driveSerialNumberLength = length;
1709
1710 TRACE("Exiting aaruf_set_drive_serial_number(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
1711 return AARUF_STATUS_OK;
1712}
1713
1795 AARU_EXPORT int32_t AARU_CALL aaruf_set_drive_firmware_revision(void *context, const uint8_t *data,
1796 const int32_t length)
1797{
1798 TRACE("Entering aaruf_set_drive_firmware_revision(%p, %p, %d)", context, data, length);
1799
1800 // Check context is correct AaruFormat context
1801 if(context == NULL)
1802 {
1803 FATAL("Invalid context");
1804
1805 TRACE("Exiting aaruf_set_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
1806 return AARUF_ERROR_NOT_AARUFORMAT;
1807 }
1808
1809 aaruformat_context *ctx = context;
1810
1811 // Not a libaaruformat context
1812 if(ctx->magic != AARU_MAGIC)
1813 {
1814 FATAL("Invalid context");
1815
1816 TRACE("Exiting aaruf_set_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
1817 return AARUF_ERROR_NOT_AARUFORMAT;
1818 }
1819
1820 // Check we are writing
1821 if(!ctx->is_writing)
1822 {
1823 FATAL("Trying to write a read-only image");
1824
1825 TRACE("Exiting aaruf_set_drive_firmware_revision() = AARUF_READ_ONLY");
1826 return AARUF_READ_ONLY;
1827 }
1828
1829 // Initialize
1830 if(ctx->metadata_block_header.identifier != MetadataBlock) ctx->metadata_block_header.identifier = MetadataBlock;
1831
1832 // Reserve memory
1833 uint8_t *copy = malloc(length);
1834 if(copy == NULL)
1835 {
1836 FATAL("Could not allocate memory for creator");
1837 return AARUF_ERROR_NOT_ENOUGH_MEMORY;
1838 }
1839
1840 // Copy opaque UTF-16LE string
1841 memcpy(copy, data, length);
1842 if(ctx->drive_firmware_revision != NULL) free(ctx->drive_firmware_revision);
1843 ctx->drive_firmware_revision = copy;
1844 ctx->metadata_block_header.driveFirmwareRevisionLength = length;
1845
1846 TRACE("Exiting aaruf_set_drive_firmware_revision(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
1847 return AARUF_STATUS_OK;
1848}
1849
1947 AARU_EXPORT int32_t AARU_CALL aaruf_get_cicm_metadata(const void *context, uint8_t *buffer, size_t *length)
1948{
1949 TRACE("Entering aaruf_get_cicm_metadata(%p, %p, %p)", context, buffer, length);
1950
1951 // Check context is correct AaruFormat context
1952 if(context == NULL)
1953 {
1954 FATAL("Invalid context");
1955
1956 TRACE("Exiting aaruf_get_cicm_metadata() = AARUF_ERROR_NOT_AARUFORMAT");
1957 return AARUF_ERROR_NOT_AARUFORMAT;
1958 }
1959
1960 const aaruformat_context *ctx = context;
1961
1962 // Not a libaaruformat context
1963 if(ctx->magic != AARU_MAGIC)
1964 {
1965 FATAL("Invalid context");
1966
1967 TRACE("Exiting aaruf_get_cicm_metadata() = AARUF_ERROR_NOT_AARUFORMAT");
1968 return AARUF_ERROR_NOT_AARUFORMAT;
1969 }
1970
1971 if(ctx->cicm_block == NULL || ctx->cicm_block_header.length == 0 || ctx->cicm_block_header.identifier != CicmBlock)
1972 {
1973 TRACE("No CICM XML metadata present");
1974 *length = 0;
1975
1976 TRACE("Exiting aaruf_get_cicm_metadata() = AARUF_ERROR_CANNOT_READ_BLOCK");
1977 return AARUF_ERROR_CANNOT_READ_BLOCK;
1978 }
1979
1980 if(*length < ctx->cicm_block_header.length)
1981 {
1982 TRACE("Buffer too small for CICM XML metadata, required %u bytes", ctx->cicm_block_header.length);
1983 *length = ctx->cicm_block_header.length;
1984
1985 TRACE("Exiting aaruf_get_cicm_metadata() = AARUF_ERROR_BUFFER_TOO_SMALL");
1986 return AARUF_ERROR_BUFFER_TOO_SMALL;
1987 }
1988
1989 *length = ctx->cicm_block_header.length;
1990 memcpy(buffer, ctx->cicm_block, ctx->cicm_block_header.length);
1991
1992 TRACE("CICM XML metadata read successfully, length %u", *length);
1993 TRACE("Exiting aaruf_get_cicm_metadata(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
1994 return AARUF_STATUS_OK;
1995}
1996
2102 AARU_EXPORT int32_t AARU_CALL aaruf_get_aaru_json_metadata(const void *context, uint8_t *buffer, size_t *length)
2103{
2104 TRACE("Entering aaruf_get_aaru_json_metadata(%p, %p, %p)", context, buffer, length);
2105
2106 // Check context is correct AaruFormat context
2107 if(context == NULL)
2108 {
2109 FATAL("Invalid context");
2110
2111 TRACE("Exiting aaruf_get_aaru_json_metadata() = AARUF_ERROR_NOT_AARUFORMAT");
2112 return AARUF_ERROR_NOT_AARUFORMAT;
2113 }
2114
2115 const aaruformat_context *ctx = context;
2116
2117 // Not a libaaruformat context
2118 if(ctx->magic != AARU_MAGIC)
2119 {
2120 FATAL("Invalid context");
2121
2122 TRACE("Exiting aaruf_get_aaru_json_metadata() = AARUF_ERROR_NOT_AARUFORMAT");
2123 return AARUF_ERROR_NOT_AARUFORMAT;
2124 }
2125
2126 if(ctx->json_block == NULL || ctx->json_block_header.length == 0 ||
2127 ctx->json_block_header.identifier != AaruMetadataJsonBlock)
2128 {
2129 TRACE("No Aaru metadata JSON present");
2130 *length = 0;
2131
2132 TRACE("Exiting aaruf_get_aaru_json_metadata() = AARUF_ERROR_CANNOT_READ_BLOCK");
2133 return AARUF_ERROR_CANNOT_READ_BLOCK;
2134 }
2135
2136 if(*length < ctx->json_block_header.length)
2137 {
2138 TRACE("Buffer too small for Aaru metadata JSON, required %u bytes", ctx->json_block_header.length);
2139 *length = ctx->json_block_header.length;
2140
2141 TRACE("Exiting aaruf_get_aaru_json_metadata() = AARUF_ERROR_BUFFER_TOO_SMALL");
2142 return AARUF_ERROR_BUFFER_TOO_SMALL;
2143 }
2144
2145 *length = ctx->json_block_header.length;
2146 memcpy(buffer, ctx->json_block, ctx->json_block_header.length);
2147
2148 TRACE("Aaru metadata JSON read successfully, length %u", *length);
2149 TRACE("Exiting aaruf_get_aaru_json_metadata(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
2150 return AARUF_STATUS_OK;
2151}
2152
2261 AARU_EXPORT int32_t AARU_CALL aaruf_set_aaru_json_metadata(void *context, uint8_t *data, size_t length)
2262{
2263 TRACE("Entering aaruf_set_aaru_json_metadata(%p, %p, %d)", context, data, length);
2264
2265 // Check context is correct AaruFormat context
2266 if(context == NULL)
2267 {
2268 FATAL("Invalid context");
2269
2270 TRACE("Exiting aaruf_set_aaru_json_metadata() = AARUF_ERROR_NOT_AARUFORMAT");
2271 return AARUF_ERROR_NOT_AARUFORMAT;
2272 }
2273
2274 aaruformat_context *ctx = context;
2275
2276 // Not a libaaruformat context
2277 if(ctx->magic != AARU_MAGIC)
2278 {
2279 FATAL("Invalid context");
2280
2281 TRACE("Exiting aaruf_set_aaru_json_metadata() = AARUF_ERROR_NOT_AARUFORMAT");
2282 return AARUF_ERROR_NOT_AARUFORMAT;
2283 }
2284
2285 // Check we are writing
2286 if(!ctx->is_writing)
2287 {
2288 FATAL("Trying to write a read-only image");
2289
2290 TRACE("Exiting aaruf_set_aaru_json_metadata() = AARUF_READ_ONLY");
2291 return AARUF_READ_ONLY;
2292 }
2293
2294 // Reserve memory
2295 uint8_t *copy = malloc(length);
2296 if(copy == NULL)
2297 {
2298 FATAL("Could not allocate memory for Aaru metadata JSON");
2299 return AARUF_ERROR_NOT_ENOUGH_MEMORY;
2300 }
2301
2302 // Copy opaque UTF-8 string
2303 memcpy(copy, data, length);
2304 if(ctx->json_block != NULL) free(ctx->json_block);
2305 ctx->json_block = copy;
2306 ctx->json_block_header.identifier = AaruMetadataJsonBlock;
2307 ctx->json_block_header.length = (uint32_t)length;
2308
2309 TRACE("Exiting aaruf_set_aaru_json_metadata(%p, %p, %d) = AARUF_STATUS_OK", context, data, length);
2310 return AARUF_STATUS_OK;
2311}
2312
2340 AARU_EXPORT int32_t AARU_CALL aaruf_get_media_sequence(const void *context, int32_t *sequence, int32_t *last_sequence)
2341{
2342 TRACE("Entering aaruf_get_media_sequence(%p, %p, %p)", context, sequence, last_sequence);
2343
2344 // Check context is correct AaruFormat context
2345 if(context == NULL)
2346 {
2347 FATAL("Invalid context");
2348
2349 TRACE("Exiting aaruf_set_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
2350 return AARUF_ERROR_NOT_AARUFORMAT;
2351 }
2352
2353 const aaruformat_context *ctx = context;
2354
2355 // Not a libaaruformat context
2356 if(ctx->magic != AARU_MAGIC)
2357 {
2358 FATAL("Invalid context");
2359
2360 TRACE("Exiting aaruf_set_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
2361 return AARUF_ERROR_NOT_AARUFORMAT;
2362 }
2363
2364 if(ctx->metadata_block_header.identifier != MetadataBlock)
2365 {
2366 FATAL("No metadata block present");
2367
2368 TRACE("Exiting aaruf_set_media_sequence() = AARUF_ERROR_METADATA_NOT_PRESENT");
2369 return AARUF_ERROR_METADATA_NOT_PRESENT;
2370 }
2371
2372 *sequence = ctx->metadata_block_header.mediaSequence;
2373 *last_sequence = ctx->metadata_block_header.lastMediaSequence;
2374
2375 TRACE("Exiting aaruf_set_media_sequence(%p, %d, %d) = AARUF_STATUS_OK", context, *sequence, *last_sequence);
2376 return AARUF_STATUS_OK;
2377}
2378
2407 AARU_EXPORT int32_t AARU_CALL aaruf_get_creator(const void *context, uint8_t *buffer, int32_t *length)
2408{
2409 TRACE("Entering aaruf_get_creator(%p, %p, %p)", context, buffer, length);
2410
2411 // Check context is correct AaruFormat context
2412 if(context == NULL)
2413 {
2414 FATAL("Invalid context");
2415
2416 TRACE("Exiting aaruf_get_creator() = AARUF_ERROR_NOT_AARUFORMAT");
2417 return AARUF_ERROR_NOT_AARUFORMAT;
2418 }
2419
2420 const aaruformat_context *ctx = context;
2421
2422 // Not a libaaruformat context
2423 if(ctx->magic != AARU_MAGIC)
2424 {
2425 FATAL("Invalid context");
2426
2427 TRACE("Exiting aaruf_get_creator() = AARUF_ERROR_NOT_AARUFORMAT");
2428 return AARUF_ERROR_NOT_AARUFORMAT;
2429 }
2430
2431 if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->creator == NULL ||
2432 ctx->metadata_block_header.creatorLength == 0)
2433 {
2434 FATAL("No metadata block present");
2435
2436 TRACE("Exiting aaruf_get_creator() = AARUF_ERROR_METADATA_NOT_PRESENT");
2437 return AARUF_ERROR_METADATA_NOT_PRESENT;
2438 }
2439
2440 if(buffer == NULL || *length < ctx->metadata_block_header.creatorLength)
2441 {
2442 *length = ctx->metadata_block_header.creatorLength;
2443
2444 TRACE("Exiting aaruf_get_creator() = AARUF_ERROR_BUFFER_TOO_SMALL");
2445 return AARUF_ERROR_BUFFER_TOO_SMALL;
2446 }
2447
2448 // Copy opaque UTF-16LE string
2449 memcpy(buffer, ctx->creator, ctx->metadata_block_header.creatorLength);
2450 *length = ctx->metadata_block_header.creatorLength;
2451
2452 TRACE("Exiting aaruf_get_creator(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
2453 return AARUF_STATUS_OK;
2454}
2455
2479 AARU_EXPORT int32_t AARU_CALL aaruf_get_comments(const void *context, uint8_t *buffer, int32_t *length)
2480{
2481 TRACE("Entering aaruf_get_comments(%p, %p, %p)", context, buffer, length);
2482
2483 // Check context is correct AaruFormat context
2484 if(context == NULL)
2485 {
2486 FATAL("Invalid context");
2487
2488 TRACE("Exiting aaruf_get_comments() = AARUF_ERROR_NOT_AARUFORMAT");
2489 return AARUF_ERROR_NOT_AARUFORMAT;
2490 }
2491
2492 const aaruformat_context *ctx = context;
2493
2494 // Not a libaaruformat context
2495 if(ctx->magic != AARU_MAGIC)
2496 {
2497 FATAL("Invalid context");
2498
2499 TRACE("Exiting aaruf_get_comments() = AARUF_ERROR_NOT_AARUFORMAT");
2500 return AARUF_ERROR_NOT_AARUFORMAT;
2501 }
2502
2503 if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->comments == NULL ||
2504 ctx->metadata_block_header.commentsLength == 0)
2505 {
2506 FATAL("No metadata block present");
2507
2508 TRACE("Exiting aaruf_get_comments() = AARUF_ERROR_METADATA_NOT_PRESENT");
2509 return AARUF_ERROR_METADATA_NOT_PRESENT;
2510 }
2511
2512 if(buffer == NULL || *length < ctx->metadata_block_header.commentsLength)
2513 {
2514 *length = ctx->metadata_block_header.commentsLength;
2515
2516 TRACE("Exiting aaruf_get_comments() = AARUF_ERROR_BUFFER_TOO_SMALL");
2517 return AARUF_ERROR_BUFFER_TOO_SMALL;
2518 }
2519
2520 // Copy opaque UTF-16LE string
2521 memcpy(buffer, ctx->comments, ctx->metadata_block_header.commentsLength);
2522 *length = ctx->metadata_block_header.commentsLength;
2523
2524 TRACE("Exiting aaruf_get_comments(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
2525 return AARUF_STATUS_OK;
2526}
2527
2549 AARU_EXPORT int32_t AARU_CALL aaruf_get_media_title(const void *context, uint8_t *buffer, int32_t *length)
2550{
2551 TRACE("Entering aaruf_get_media_title(%p, %p, %p)", context, buffer, length);
2552
2553 // Check context is correct AaruFormat context
2554 if(context == NULL)
2555 {
2556 FATAL("Invalid context");
2557
2558 TRACE("Exiting aaruf_get_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
2559 return AARUF_ERROR_NOT_AARUFORMAT;
2560 }
2561
2562 const aaruformat_context *ctx = context;
2563
2564 // Not a libaaruformat context
2565 if(ctx->magic != AARU_MAGIC)
2566 {
2567 FATAL("Invalid context");
2568
2569 TRACE("Exiting aaruf_get_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
2570 return AARUF_ERROR_NOT_AARUFORMAT;
2571 }
2572
2573 if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->media_title == NULL ||
2574 ctx->metadata_block_header.mediaTitleLength == 0)
2575 {
2576 FATAL("No metadata block present");
2577
2578 TRACE("Exiting aaruf_get_media_title() = AARUF_ERROR_METADATA_NOT_PRESENT");
2579 return AARUF_ERROR_METADATA_NOT_PRESENT;
2580 }
2581
2582 if(buffer == NULL || *length < ctx->metadata_block_header.mediaTitleLength)
2583 {
2584 *length = ctx->metadata_block_header.mediaTitleLength;
2585
2586 TRACE("Exiting aaruf_get_media_title() = AARUF_ERROR_BUFFER_TOO_SMALL");
2587 return AARUF_ERROR_BUFFER_TOO_SMALL;
2588 }
2589
2590 // Copy opaque UTF-16LE string
2591 memcpy(buffer, ctx->media_title, ctx->metadata_block_header.mediaTitleLength);
2592 *length = ctx->metadata_block_header.mediaTitleLength;
2593
2594 TRACE("Exiting aaruf_get_media_title(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
2595 return AARUF_STATUS_OK;
2596}
2597
2619 AARU_EXPORT int32_t AARU_CALL aaruf_get_media_manufacturer(const void *context, uint8_t *buffer, int32_t *length)
2620{
2621 TRACE("Entering aaruf_get_media_manufacturer(%p, %p, %p)", context, buffer, length);
2622
2623 // Check context is correct AaruFormat context
2624 if(context == NULL)
2625 {
2626 FATAL("Invalid context");
2627
2628 TRACE("Exiting aaruf_get_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
2629 return AARUF_ERROR_NOT_AARUFORMAT;
2630 }
2631
2632 const aaruformat_context *ctx = context;
2633
2634 // Not a libaaruformat context
2635 if(ctx->magic != AARU_MAGIC)
2636 {
2637 FATAL("Invalid context");
2638
2639 TRACE("Exiting aaruf_get_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
2640 return AARUF_ERROR_NOT_AARUFORMAT;
2641 }
2642
2643 if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->media_manufacturer == NULL ||
2644 ctx->metadata_block_header.mediaManufacturerLength == 0)
2645 {
2646 FATAL("No metadata block present");
2647
2648 TRACE("Exiting aaruf_get_media_manufacturer() = AARUF_ERROR_METADATA_NOT_PRESENT");
2649 return AARUF_ERROR_METADATA_NOT_PRESENT;
2650 }
2651
2652 if(buffer == NULL || *length < ctx->metadata_block_header.mediaManufacturerLength)
2653 {
2654 *length = ctx->metadata_block_header.mediaManufacturerLength;
2655
2656 TRACE("Exiting aaruf_get_media_manufacturer() = AARUF_ERROR_BUFFER_TOO_SMALL");
2657 return AARUF_ERROR_BUFFER_TOO_SMALL;
2658 }
2659
2660 // Copy opaque UTF-16LE string
2661 memcpy(buffer, ctx->media_manufacturer, ctx->metadata_block_header.mediaManufacturerLength);
2662 *length = ctx->metadata_block_header.mediaManufacturerLength;
2663
2664 TRACE("Exiting aaruf_get_media_manufacturer(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
2665 return AARUF_STATUS_OK;
2666}
2667
2689 AARU_EXPORT int32_t AARU_CALL aaruf_get_media_model(const void *context, uint8_t *buffer, int32_t *length)
2690{
2691 TRACE("Entering aaruf_get_media_model(%p, %p, %p)", context, buffer, length);
2692
2693 // Check context is correct AaruFormat context
2694 if(context == NULL)
2695 {
2696 FATAL("Invalid context");
2697
2698 TRACE("Exiting aaruf_get_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
2699 return AARUF_ERROR_NOT_AARUFORMAT;
2700 }
2701
2702 const aaruformat_context *ctx = context;
2703
2704 // Not a libaaruformat context
2705 if(ctx->magic != AARU_MAGIC)
2706 {
2707 FATAL("Invalid context");
2708
2709 TRACE("Exiting aaruf_get_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
2710 return AARUF_ERROR_NOT_AARUFORMAT;
2711 }
2712
2713 if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->media_model == NULL ||
2714 ctx->metadata_block_header.mediaModelLength == 0)
2715 {
2716 FATAL("No metadata block present");
2717
2718 TRACE("Exiting aaruf_get_media_model() = AARUF_ERROR_METADATA_NOT_PRESENT");
2719 return AARUF_ERROR_METADATA_NOT_PRESENT;
2720 }
2721
2722 if(buffer == NULL || *length < ctx->metadata_block_header.mediaModelLength)
2723 {
2724 *length = ctx->metadata_block_header.mediaModelLength;
2725
2726 TRACE("Exiting aaruf_get_media_model() = AARUF_ERROR_BUFFER_TOO_SMALL");
2727 return AARUF_ERROR_BUFFER_TOO_SMALL;
2728 }
2729
2730 // Copy opaque UTF-16LE string
2731 memcpy(buffer, ctx->media_model, ctx->metadata_block_header.mediaModelLength);
2732 *length = ctx->metadata_block_header.mediaModelLength;
2733
2734 TRACE("Exiting aaruf_get_media_model(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
2735 return AARUF_STATUS_OK;
2736}
2737
2759 AARU_EXPORT int32_t AARU_CALL aaruf_get_media_serial_number(const void *context, uint8_t *buffer, int32_t *length)
2760{
2761 TRACE("Entering aaruf_get_media_serial_number(%p, %p, %p)", context, buffer, length);
2762
2763 // Check context is correct AaruFormat context
2764 if(context == NULL)
2765 {
2766 FATAL("Invalid context");
2767
2768 TRACE("Exiting aaruf_get_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
2769 return AARUF_ERROR_NOT_AARUFORMAT;
2770 }
2771
2772 const aaruformat_context *ctx = context;
2773
2774 // Not a libaaruformat context
2775 if(ctx->magic != AARU_MAGIC)
2776 {
2777 FATAL("Invalid context");
2778
2779 TRACE("Exiting aaruf_get_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
2780 return AARUF_ERROR_NOT_AARUFORMAT;
2781 }
2782
2783 if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->media_serial_number == NULL ||
2784 ctx->metadata_block_header.mediaSerialNumberLength == 0)
2785 {
2786 FATAL("No metadata block present");
2787
2788 TRACE("Exiting aaruf_get_media_serial_number() = AARUF_ERROR_METADATA_NOT_PRESENT");
2789 return AARUF_ERROR_METADATA_NOT_PRESENT;
2790 }
2791
2792 if(buffer == NULL || *length < ctx->metadata_block_header.mediaSerialNumberLength)
2793 {
2794 *length = ctx->metadata_block_header.mediaSerialNumberLength;
2795
2796 TRACE("Exiting aaruf_get_media_serial_number() = AARUF_ERROR_BUFFER_TOO_SMALL");
2797 return AARUF_ERROR_BUFFER_TOO_SMALL;
2798 }
2799
2800 // Copy opaque UTF-16LE string
2801 memcpy(buffer, ctx->media_serial_number, ctx->metadata_block_header.mediaSerialNumberLength);
2802 *length = ctx->metadata_block_header.mediaSerialNumberLength;
2803
2804 TRACE("Exiting aaruf_get_media_serial_number(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
2805 return AARUF_STATUS_OK;
2806}
2807
2828 AARU_EXPORT int32_t AARU_CALL aaruf_get_media_barcode(const void *context, uint8_t *buffer, int32_t *length)
2829{
2830 TRACE("Entering aaruf_get_media_barcode(%p, %p, %p)", context, buffer, length);
2831
2832 // Check context is correct AaruFormat context
2833 if(context == NULL)
2834 {
2835 FATAL("Invalid context");
2836
2837 TRACE("Exiting aaruf_get_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
2838 return AARUF_ERROR_NOT_AARUFORMAT;
2839 }
2840
2841 const aaruformat_context *ctx = context;
2842
2843 // Not a libaaruformat context
2844 if(ctx->magic != AARU_MAGIC)
2845 {
2846 FATAL("Invalid context");
2847
2848 TRACE("Exiting aaruf_get_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
2849 return AARUF_ERROR_NOT_AARUFORMAT;
2850 }
2851
2852 if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->media_barcode == NULL ||
2853 ctx->metadata_block_header.mediaBarcodeLength == 0)
2854 {
2855 FATAL("No metadata block present");
2856
2857 TRACE("Exiting aaruf_get_media_barcode() = AARUF_ERROR_METADATA_NOT_PRESENT");
2858 return AARUF_ERROR_METADATA_NOT_PRESENT;
2859 }
2860
2861 if(buffer == NULL || *length < ctx->metadata_block_header.mediaBarcodeLength)
2862 {
2863 *length = ctx->metadata_block_header.mediaBarcodeLength;
2864
2865 TRACE("Exiting aaruf_get_media_barcode() = AARUF_ERROR_BUFFER_TOO_SMALL");
2866 return AARUF_ERROR_BUFFER_TOO_SMALL;
2867 }
2868
2869 // Copy opaque UTF-16LE string
2870 memcpy(buffer, ctx->media_barcode, ctx->metadata_block_header.mediaBarcodeLength);
2871 *length = ctx->metadata_block_header.mediaBarcodeLength;
2872
2873 TRACE("Exiting aaruf_get_media_barcode(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
2874 return AARUF_STATUS_OK;
2875}
2876
2899 AARU_EXPORT int32_t AARU_CALL aaruf_get_media_part_number(const void *context, uint8_t *buffer, int32_t *length)
2900{
2901 TRACE("Entering aaruf_get_media_part_number(%p, %p, %p)", context, buffer, length);
2902
2903 // Check context is correct AaruFormat context
2904 if(context == NULL)
2905 {
2906 FATAL("Invalid context");
2907
2908 TRACE("Exiting aaruf_get_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
2909 return AARUF_ERROR_NOT_AARUFORMAT;
2910 }
2911
2912 const aaruformat_context *ctx = context;
2913
2914 // Not a libaaruformat context
2915 if(ctx->magic != AARU_MAGIC)
2916 {
2917 FATAL("Invalid context");
2918
2919 TRACE("Exiting aaruf_get_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
2920 return AARUF_ERROR_NOT_AARUFORMAT;
2921 }
2922
2923 if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->media_part_number == NULL ||
2924 ctx->metadata_block_header.mediaPartNumberLength == 0)
2925 {
2926 FATAL("No metadata block present");
2927
2928 TRACE("Exiting aaruf_get_media_part_number() = AARUF_ERROR_METADATA_NOT_PRESENT");
2929 return AARUF_ERROR_METADATA_NOT_PRESENT;
2930 }
2931
2932 if(buffer == NULL || *length < ctx->metadata_block_header.mediaPartNumberLength)
2933 {
2934 *length = ctx->metadata_block_header.mediaPartNumberLength;
2935
2936 TRACE("Exiting aaruf_get_media_part_number() = AARUF_ERROR_BUFFER_TOO_SMALL");
2937 return AARUF_ERROR_BUFFER_TOO_SMALL;
2938 }
2939
2940 // Copy opaque UTF-16LE string
2941 memcpy(buffer, ctx->media_part_number, ctx->metadata_block_header.mediaPartNumberLength);
2942 *length = ctx->metadata_block_header.mediaPartNumberLength;
2943
2944 TRACE("Exiting aaruf_get_media_part_number(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
2945 return AARUF_STATUS_OK;
2946}
2947
2971 AARU_EXPORT int32_t AARU_CALL aaruf_get_drive_manufacturer(const void *context, uint8_t *buffer, int32_t *length)
2972{
2973 TRACE("Entering aaruf_get_drive_manufacturer(%p, %p, %p)", context, buffer, length);
2974
2975 // Check context is correct AaruFormat context
2976 if(context == NULL)
2977 {
2978 FATAL("Invalid context");
2979
2980 TRACE("Exiting aaruf_get_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
2981 return AARUF_ERROR_NOT_AARUFORMAT;
2982 }
2983
2984 const aaruformat_context *ctx = context;
2985
2986 // Not a libaaruformat context
2987 if(ctx->magic != AARU_MAGIC)
2988 {
2989 FATAL("Invalid context");
2990
2991 TRACE("Exiting aaruf_get_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
2992 return AARUF_ERROR_NOT_AARUFORMAT;
2993 }
2994
2995 if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->drive_manufacturer == NULL ||
2996 ctx->metadata_block_header.driveManufacturerLength == 0)
2997 {
2998 FATAL("No metadata block present");
2999
3000 TRACE("Exiting aaruf_get_drive_manufacturer() = AARUF_ERROR_METADATA_NOT_PRESENT");
3001 return AARUF_ERROR_METADATA_NOT_PRESENT;
3002 }
3003
3004 if(buffer == NULL || *length < ctx->metadata_block_header.driveManufacturerLength)
3005 {
3006 *length = ctx->metadata_block_header.driveManufacturerLength;
3007
3008 TRACE("Exiting aaruf_get_drive_manufacturer() = AARUF_ERROR_BUFFER_TOO_SMALL");
3009 return AARUF_ERROR_BUFFER_TOO_SMALL;
3010 }
3011
3012 // Copy opaque UTF-16LE string
3013 memcpy(buffer, ctx->drive_manufacturer, ctx->metadata_block_header.driveManufacturerLength);
3014 *length = ctx->metadata_block_header.driveManufacturerLength;
3015
3016 TRACE("Exiting aaruf_get_drive_manufacturer(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
3017 return AARUF_STATUS_OK;
3018}
3019
3041 AARU_EXPORT int32_t AARU_CALL aaruf_get_drive_model(const void *context, uint8_t *buffer, int32_t *length)
3042{
3043 TRACE("Entering aaruf_get_drive_model(%p, %p, %p)", context, buffer, length);
3044
3045 // Check context is correct AaruFormat context
3046 if(context == NULL)
3047 {
3048 FATAL("Invalid context");
3049
3050 TRACE("Exiting aaruf_get_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
3051 return AARUF_ERROR_NOT_AARUFORMAT;
3052 }
3053
3054 const aaruformat_context *ctx = context;
3055
3056 // Not a libaaruformat context
3057 if(ctx->magic != AARU_MAGIC)
3058 {
3059 FATAL("Invalid context");
3060
3061 TRACE("Exiting aaruf_get_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
3062 return AARUF_ERROR_NOT_AARUFORMAT;
3063 }
3064
3065 if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->drive_model == NULL ||
3066 ctx->metadata_block_header.driveModelLength == 0)
3067 {
3068 FATAL("No metadata block present");
3069
3070 TRACE("Exiting aaruf_get_drive_model() = AARUF_ERROR_METADATA_NOT_PRESENT");
3071 return AARUF_ERROR_METADATA_NOT_PRESENT;
3072 }
3073
3074 if(buffer == NULL || *length < ctx->metadata_block_header.driveModelLength)
3075 {
3076 *length = ctx->metadata_block_header.driveModelLength;
3077
3078 TRACE("Exiting aaruf_get_drive_model() = AARUF_ERROR_BUFFER_TOO_SMALL");
3079 return AARUF_ERROR_BUFFER_TOO_SMALL;
3080 }
3081
3082 // Copy opaque UTF-16LE string
3083 memcpy(buffer, ctx->drive_model, ctx->metadata_block_header.driveModelLength);
3084 *length = ctx->metadata_block_header.driveModelLength;
3085
3086 TRACE("Exiting aaruf_get_drive_model(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
3087 return AARUF_STATUS_OK;
3088}
3089
3111 AARU_EXPORT int32_t AARU_CALL aaruf_get_drive_serial_number(const void *context, uint8_t *buffer, int32_t *length)
3112{
3113 TRACE("Entering aaruf_get_drive_serial_number(%p, %p, %p)", context, buffer, length);
3114
3115 // Check context is correct AaruFormat context
3116 if(context == NULL)
3117 {
3118 FATAL("Invalid context");
3119
3120 TRACE("Exiting aaruf_get_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
3121 return AARUF_ERROR_NOT_AARUFORMAT;
3122 }
3123
3124 const aaruformat_context *ctx = context;
3125
3126 // Not a libaaruformat context
3127 if(ctx->magic != AARU_MAGIC)
3128 {
3129 FATAL("Invalid context");
3130
3131 TRACE("Exiting aaruf_get_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
3132 return AARUF_ERROR_NOT_AARUFORMAT;
3133 }
3134
3135 if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->drive_serial_number == NULL ||
3136 ctx->metadata_block_header.driveSerialNumberLength == 0)
3137 {
3138 FATAL("No metadata block present");
3139
3140 TRACE("Exiting aaruf_get_drive_serial_number() = AARUF_ERROR_METADATA_NOT_PRESENT");
3141 return AARUF_ERROR_METADATA_NOT_PRESENT;
3142 }
3143
3144 if(buffer == NULL || *length < ctx->metadata_block_header.driveSerialNumberLength)
3145 {
3146 *length = ctx->metadata_block_header.driveSerialNumberLength;
3147
3148 TRACE("Exiting aaruf_get_drive_serial_number() = AARUF_ERROR_BUFFER_TOO_SMALL");
3149 return AARUF_ERROR_BUFFER_TOO_SMALL;
3150 }
3151
3152 // Copy opaque UTF-16LE string
3153 memcpy(buffer, ctx->drive_serial_number, ctx->metadata_block_header.driveSerialNumberLength);
3154 *length = ctx->metadata_block_header.driveSerialNumberLength;
3155
3156 TRACE("Exiting aaruf_get_drive_serial_number(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
3157 return AARUF_STATUS_OK;
3158}
3159
3181 AARU_EXPORT int32_t AARU_CALL aaruf_get_drive_firmware_revision(const void *context, uint8_t *buffer, int32_t *length)
3182{
3183 TRACE("Entering aaruf_get_drive_firmware_revision(%p, %p, %p)", context, buffer, length);
3184
3185 // Check context is correct AaruFormat context
3186 if(context == NULL)
3187 {
3188 FATAL("Invalid context");
3189
3190 TRACE("Exiting aaruf_get_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
3191 return AARUF_ERROR_NOT_AARUFORMAT;
3192 }
3193
3194 const aaruformat_context *ctx = context;
3195
3196 // Not a libaaruformat context
3197 if(ctx->magic != AARU_MAGIC)
3198 {
3199 FATAL("Invalid context");
3200
3201 TRACE("Exiting aaruf_get_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
3202 return AARUF_ERROR_NOT_AARUFORMAT;
3203 }
3204
3205 if(ctx->metadata_block_header.identifier != MetadataBlock || ctx->drive_firmware_revision == NULL ||
3206 ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
3207 {
3208 FATAL("No metadata block present");
3209
3210 TRACE("Exiting aaruf_get_drive_firmware_revision() = AARUF_ERROR_METADATA_NOT_PRESENT");
3211 return AARUF_ERROR_METADATA_NOT_PRESENT;
3212 }
3213
3214 if(buffer == NULL || *length < ctx->metadata_block_header.driveFirmwareRevisionLength)
3215 {
3216 *length = ctx->metadata_block_header.driveFirmwareRevisionLength;
3217
3218 TRACE("Exiting aaruf_get_drive_firmware_revision() = AARUF_ERROR_BUFFER_TOO_SMALL");
3219 return AARUF_ERROR_BUFFER_TOO_SMALL;
3220 }
3221
3222 // Copy opaque UTF-16LE string
3223 memcpy(buffer, ctx->drive_firmware_revision, ctx->metadata_block_header.driveFirmwareRevisionLength);
3224 *length = ctx->metadata_block_header.driveFirmwareRevisionLength;
3225
3226 TRACE("Exiting aaruf_get_drive_firmware_revision(%p, %p, %d) = AARUF_STATUS_OK", context, buffer, *length);
3227 return AARUF_STATUS_OK;
3228}
3229
3295 AARU_EXPORT int32_t AARU_CALL aaruf_get_user_sectors(const void *context, uint64_t *sectors)
3296{
3297 TRACE("Entering aaruf_get_user_sectors(%p, %p)", context, sectors);
3298
3299 // Check context is correct AaruFormat context
3300 if(context == NULL)
3301 {
3302 FATAL("Invalid context");
3303
3304 TRACE("Exiting aaruf_get_user_sectors() = AARUF_ERROR_NOT_AARUFORMAT");
3305 return AARUF_ERROR_NOT_AARUFORMAT;
3306 }
3307
3308 const aaruformat_context *ctx = context;
3309
3310 // Not a libaaruformat context
3311 if(ctx->magic != AARU_MAGIC)
3312 {
3313 FATAL("Invalid context");
3314
3315 TRACE("Exiting aaruf_get_user_sectors() = AARUF_ERROR_NOT_AARUFORMAT");
3316 return AARUF_ERROR_NOT_AARUFORMAT;
3317 }
3318
3319 *sectors = ctx->user_data_ddt_header.blocks;
3320
3321 TRACE("Exiting aaruf_get_user_sectors(%p, %llu) = AARUF_STATUS_OK", context, *sectors);
3322 return AARUF_STATUS_OK;
3323}
3324
3420 AARU_EXPORT int32_t AARU_CALL aaruf_get_negative_sectors(const void *context, uint16_t *sectors)
3421{
3422 TRACE("Entering aaruf_get_negative_sectors(%p, %p)", context, sectors);
3423
3424 // Check context is correct AaruFormat context
3425 if(context == NULL)
3426 {
3427 FATAL("Invalid context");
3428
3429 TRACE("Exiting aaruf_get_negative_sectors() = AARUF_ERROR_NOT_AARUFORMAT");
3430 return AARUF_ERROR_NOT_AARUFORMAT;
3431 }
3432
3433 const aaruformat_context *ctx = context;
3434
3435 // Not a libaaruformat context
3436 if(ctx->magic != AARU_MAGIC)
3437 {
3438 FATAL("Invalid context");
3439
3440 TRACE("Exiting aaruf_get_negative_sectors() = AARUF_ERROR_NOT_AARUFORMAT");
3441 return AARUF_ERROR_NOT_AARUFORMAT;
3442 }
3443
3444 *sectors = ctx->user_data_ddt_header.negative;
3445
3446 TRACE("Exiting aaruf_get_negative_sectors(%p, %u) = AARUF_STATUS_OK", context, *sectors);
3447 return AARUF_STATUS_OK;
3448}
3449
3555 AARU_EXPORT int32_t AARU_CALL aaruf_get_overflow_sectors(const void *context, uint16_t *sectors)
3556{
3557 TRACE("Entering aaruf_get_overflow_sectors(%p, %p)", context, sectors);
3558
3559 // Check context is correct AaruFormat context
3560 if(context == NULL)
3561 {
3562 FATAL("Invalid context");
3563
3564 TRACE("Exiting aaruf_get_overflow_sectors() = AARUF_ERROR_NOT_AARUFORMAT");
3565 return AARUF_ERROR_NOT_AARUFORMAT;
3566 }
3567
3568 const aaruformat_context *ctx = context;
3569
3570 // Not a libaaruformat context
3571 if(ctx->magic != AARU_MAGIC)
3572 {
3573 FATAL("Invalid context");
3574
3575 TRACE("Exiting aaruf_get_overflow_sectors() = AARUF_ERROR_NOT_AARUFORMAT");
3576 return AARUF_ERROR_NOT_AARUFORMAT;
3577 }
3578
3579 *sectors = ctx->user_data_ddt_header.overflow;
3580
3581 TRACE("Exiting aaruf_get_overflow_sectors(%p, %u) = AARUF_STATUS_OK", context, *sectors);
3582 return AARUF_STATUS_OK;
3583}
3584
3637 AARU_EXPORT int32_t AARU_CALL aaruf_get_image_info(const void *context, ImageInfo *image_info)
3638{
3639 TRACE("Entering aaruf_get_image_info(%p, %p)", context, image_info);
3640
3641 // Check context is correct AaruFormat context
3642 if(context == NULL)
3643 {
3644 FATAL("Invalid context");
3645
3646 TRACE("Exiting aaruf_get_image_info() = AARUF_ERROR_NOT_AARUFORMAT");
3647 return AARUF_ERROR_NOT_AARUFORMAT;
3648 }
3649
3650 const aaruformat_context *ctx = context;
3651
3652 // Not a libaaruformat context
3653 if(ctx->magic != AARU_MAGIC)
3654 {
3655 FATAL("Invalid context");
3656
3657 TRACE("Exiting aaruf_get_image_info() = AARUF_ERROR_NOT_AARUFORMAT");
3658 return AARUF_ERROR_NOT_AARUFORMAT;
3659 }
3660
3661 if(image_info == NULL)
3662 {
3663 FATAL("image_info parameter is NULL");
3664
3665 TRACE("Exiting aaruf_get_image_info() = AARUF_ERROR_INCORRECT_DATA_SIZE");
3666 return AARUF_ERROR_INCORRECT_DATA_SIZE;
3667 }
3668
3669 // Perform deep copy of the image_info structure
3670 memcpy(image_info, &ctx->image_info, sizeof(ImageInfo));
3671
3672 TRACE("Exiting aaruf_get_image_info() = AARUF_STATUS_OK");
3673 return AARUF_STATUS_OK;
3674}
3675
3743 AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_sequence(void *context)
3744{
3745 TRACE("Entering aaruf_clear_media_sequence(%p)", context);
3746
3747 // Check context is correct AaruFormat context
3748 if(context == NULL)
3749 {
3750 FATAL("Invalid context");
3751
3752 TRACE("Exiting aaruf_clear_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
3753 return AARUF_ERROR_NOT_AARUFORMAT;
3754 }
3755
3756 aaruformat_context *ctx = context;
3757
3758 // Not a libaaruformat context
3759 if(ctx->magic != AARU_MAGIC)
3760 {
3761 FATAL("Invalid context");
3762
3763 TRACE("Exiting aaruf_clear_media_sequence() = AARUF_ERROR_NOT_AARUFORMAT");
3764 return AARUF_ERROR_NOT_AARUFORMAT;
3765 }
3766
3767 // Check we are writing
3768 if(!ctx->is_writing)
3769 {
3770 FATAL("Trying to write a read-only image");
3771
3772 TRACE("Exiting aaruf_clear_media_sequence() = AARUF_READ_ONLY");
3773 return AARUF_READ_ONLY;
3774 }
3775
3776 if(ctx->metadata_block_header.identifier != MetadataBlock)
3777 {
3778 TRACE("Exiting aaruf_clear_media_sequence() = AARUF_STATUS_OK");
3779 return AARUF_STATUS_OK;
3780 }
3781
3782 ctx->metadata_block_header.mediaSequence = 0;
3783 ctx->metadata_block_header.lastMediaSequence = 0;
3784
3785 // Check if all metadata is clear
3786 if(ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
3787 ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
3788 ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaSerialNumberLength == 0 &&
3789 ctx->metadata_block_header.mediaBarcodeLength == 0 && ctx->metadata_block_header.mediaPartNumberLength == 0 &&
3790 ctx->metadata_block_header.driveModelLength == 0 && ctx->metadata_block_header.driveManufacturerLength == 0 &&
3791 ctx->metadata_block_header.driveSerialNumberLength == 0 &&
3792 ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
3793 ctx->metadata_block_header.identifier = 0;
3794
3795 TRACE("Exiting aaruf_clear_media_sequence() = AARUF_STATUS_OK");
3796 return AARUF_STATUS_OK;
3797}
3798
3874 AARU_EXPORT int32_t AARU_CALL aaruf_clear_creator(void *context)
3875{
3876 TRACE("Entering aaruf_clear_creator(%p)", context);
3877
3878 // Check context is correct AaruFormat context
3879 if(context == NULL)
3880 {
3881 FATAL("Invalid context");
3882
3883 TRACE("Exiting aaruf_clear_creator() = AARUF_ERROR_NOT_AARUFORMAT");
3884 return AARUF_ERROR_NOT_AARUFORMAT;
3885 }
3886
3887 aaruformat_context *ctx = context;
3888
3889 // Not a libaaruformat context
3890 if(ctx->magic != AARU_MAGIC)
3891 {
3892 FATAL("Invalid context");
3893
3894 TRACE("Exiting aaruf_clear_creator() = AARUF_ERROR_NOT_AARUFORMAT");
3895 return AARUF_ERROR_NOT_AARUFORMAT;
3896 }
3897
3898 // Check we are writing
3899 if(!ctx->is_writing)
3900 {
3901 FATAL("Trying to write a read-only image");
3902
3903 TRACE("Exiting aaruf_clear_creator() = AARUF_READ_ONLY");
3904 return AARUF_READ_ONLY;
3905 }
3906
3907 if(ctx->metadata_block_header.identifier != MetadataBlock)
3908 {
3909 TRACE("Exiting aaruf_clear_creator() = AARUF_STATUS_OK");
3910 return AARUF_STATUS_OK;
3911 }
3912
3913 if(ctx->creator != NULL) free(ctx->creator);
3914
3915 ctx->creator = NULL;
3916 ctx->metadata_block_header.creatorLength = 0;
3917
3918 // Check if all metadata is clear
3919 if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
3920 ctx->metadata_block_header.commentsLength == 0 && ctx->metadata_block_header.mediaTitleLength == 0 &&
3921 ctx->metadata_block_header.mediaManufacturerLength == 0 && ctx->metadata_block_header.mediaModelLength == 0 &&
3922 ctx->metadata_block_header.mediaSerialNumberLength == 0 && ctx->metadata_block_header.mediaBarcodeLength == 0 &&
3923 ctx->metadata_block_header.mediaPartNumberLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
3924 ctx->metadata_block_header.driveManufacturerLength == 0 &&
3925 ctx->metadata_block_header.driveSerialNumberLength == 0 &&
3926 ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
3927 ctx->metadata_block_header.identifier = 0;
3928
3929 TRACE("Exiting aaruf_clear_creator() = AARUF_STATUS_OK");
3930 return AARUF_STATUS_OK;
3931}
3932
4003 AARU_EXPORT int32_t AARU_CALL aaruf_clear_comments(void *context)
4004{
4005 TRACE("Entering aaruf_clear_comments(%p)", context);
4006
4007 // Check context is correct AaruFormat context
4008 if(context == NULL)
4009 {
4010 FATAL("Invalid context");
4011
4012 TRACE("Exiting aaruf_clear_comments() = AARUF_ERROR_NOT_AARUFORMAT");
4013 return AARUF_ERROR_NOT_AARUFORMAT;
4014 }
4015
4016 aaruformat_context *ctx = context;
4017
4018 // Not a libaaruformat context
4019 if(ctx->magic != AARU_MAGIC)
4020 {
4021 FATAL("Invalid context");
4022
4023 TRACE("Exiting aaruf_clear_comments() = AARUF_ERROR_NOT_AARUFORMAT");
4024 return AARUF_ERROR_NOT_AARUFORMAT;
4025 }
4026
4027 // Check we are writing
4028 if(!ctx->is_writing)
4029 {
4030 FATAL("Trying to write a read-only image");
4031
4032 TRACE("Exiting aaruf_clear_comments() = AARUF_READ_ONLY");
4033 return AARUF_READ_ONLY;
4034 }
4035
4036 if(ctx->metadata_block_header.identifier != MetadataBlock)
4037 {
4038 TRACE("Exiting aaruf_clear_comments() = AARUF_STATUS_OK");
4039 return AARUF_STATUS_OK;
4040 }
4041
4042 if(ctx->comments != NULL) free(ctx->comments);
4043
4044 ctx->comments = NULL;
4045 ctx->metadata_block_header.commentsLength = 0;
4046
4047 // Check if all metadata is clear
4048 if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
4049 ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.mediaTitleLength == 0 &&
4050 ctx->metadata_block_header.mediaManufacturerLength == 0 && ctx->metadata_block_header.mediaModelLength == 0 &&
4051 ctx->metadata_block_header.mediaSerialNumberLength == 0 && ctx->metadata_block_header.mediaBarcodeLength == 0 &&
4052 ctx->metadata_block_header.mediaPartNumberLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
4053 ctx->metadata_block_header.driveManufacturerLength == 0 &&
4054 ctx->metadata_block_header.driveSerialNumberLength == 0 &&
4055 ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
4056 ctx->metadata_block_header.identifier = 0;
4057
4058 TRACE("Exiting aaruf_clear_comments() = AARUF_STATUS_OK");
4059 return AARUF_STATUS_OK;
4060}
4061
4086 AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_title(void *context)
4087{
4088 TRACE("Entering aaruf_clear_media_title(%p)", context);
4089
4090 // Check context is correct AaruFormat context
4091 if(context == NULL)
4092 {
4093 FATAL("Invalid context");
4094
4095 TRACE("Exiting aaruf_clear_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
4096 return AARUF_ERROR_NOT_AARUFORMAT;
4097 }
4098
4099 aaruformat_context *ctx = context;
4100
4101 // Not a libaaruformat context
4102 if(ctx->magic != AARU_MAGIC)
4103 {
4104 FATAL("Invalid context");
4105
4106 TRACE("Exiting aaruf_clear_media_title() = AARUF_ERROR_NOT_AARUFORMAT");
4107 return AARUF_ERROR_NOT_AARUFORMAT;
4108 }
4109
4110 // Check we are writing
4111 if(!ctx->is_writing)
4112 {
4113 FATAL("Trying to write a read-only image");
4114
4115 TRACE("Exiting aaruf_clear_media_title() = AARUF_READ_ONLY");
4116 return AARUF_READ_ONLY;
4117 }
4118
4119 if(ctx->metadata_block_header.identifier != MetadataBlock)
4120 {
4121 TRACE("Exiting aaruf_clear_media_title() = AARUF_STATUS_OK");
4122 return AARUF_STATUS_OK;
4123 }
4124
4125 if(ctx->media_title != NULL) free(ctx->media_title);
4126
4127 ctx->media_title = NULL;
4128 ctx->metadata_block_header.mediaTitleLength = 0;
4129
4130 // Check if all metadata is clear
4131 if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
4132 ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
4133 ctx->metadata_block_header.mediaManufacturerLength == 0 && ctx->metadata_block_header.mediaModelLength == 0 &&
4134 ctx->metadata_block_header.mediaSerialNumberLength == 0 && ctx->metadata_block_header.mediaBarcodeLength == 0 &&
4135 ctx->metadata_block_header.mediaPartNumberLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
4136 ctx->metadata_block_header.driveManufacturerLength == 0 &&
4137 ctx->metadata_block_header.driveSerialNumberLength == 0 &&
4138 ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
4139 ctx->metadata_block_header.identifier = 0;
4140
4141 TRACE("Exiting aaruf_clear_media_title() = AARUF_STATUS_OK");
4142 return AARUF_STATUS_OK;
4143}
4144
4170 AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_manufacturer(void *context)
4171{
4172 TRACE("Entering aaruf_clear_media_manufacturer(%p)", context);
4173
4174 // Check context is correct AaruFormat context
4175 if(context == NULL)
4176 {
4177 FATAL("Invalid context");
4178
4179 TRACE("Exiting aaruf_clear_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
4180 return AARUF_ERROR_NOT_AARUFORMAT;
4181 }
4182
4183 aaruformat_context *ctx = context;
4184
4185 // Not a libaaruformat context
4186 if(ctx->magic != AARU_MAGIC)
4187 {
4188 FATAL("Invalid context");
4189
4190 TRACE("Exiting aaruf_clear_media_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
4191 return AARUF_ERROR_NOT_AARUFORMAT;
4192 }
4193
4194 // Check we are writing
4195 if(!ctx->is_writing)
4196 {
4197 FATAL("Trying to write a read-only image");
4198
4199 TRACE("Exiting aaruf_clear_media_manufacturer() = AARUF_READ_ONLY");
4200 return AARUF_READ_ONLY;
4201 }
4202
4203 if(ctx->metadata_block_header.identifier != MetadataBlock)
4204 {
4205 TRACE("Exiting aaruf_clear_media_manufacturer() = AARUF_STATUS_OK");
4206 return AARUF_STATUS_OK;
4207 }
4208
4209 if(ctx->media_manufacturer != NULL) free(ctx->media_manufacturer);
4210
4211 ctx->media_manufacturer = NULL;
4212 ctx->metadata_block_header.mediaManufacturerLength = 0;
4213
4214 // Check if all metadata is clear
4215 if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
4216 ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
4217 ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaModelLength == 0 &&
4218 ctx->metadata_block_header.mediaSerialNumberLength == 0 && ctx->metadata_block_header.mediaBarcodeLength == 0 &&
4219 ctx->metadata_block_header.mediaPartNumberLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
4220 ctx->metadata_block_header.driveManufacturerLength == 0 &&
4221 ctx->metadata_block_header.driveSerialNumberLength == 0 &&
4222 ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
4223 ctx->metadata_block_header.identifier = 0;
4224
4225 TRACE("Exiting aaruf_clear_media_manufacturer() = AARUF_STATUS_OK");
4226 return AARUF_STATUS_OK;
4227}
4228
4254 AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_model(void *context)
4255{
4256 TRACE("Entering aaruf_clear_media_model(%p)", context);
4257
4258 // Check context is correct AaruFormat context
4259 if(context == NULL)
4260 {
4261 FATAL("Invalid context");
4262
4263 TRACE("Exiting aaruf_clear_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
4264 return AARUF_ERROR_NOT_AARUFORMAT;
4265 }
4266
4267 aaruformat_context *ctx = context;
4268
4269 // Not a libaaruformat context
4270 if(ctx->magic != AARU_MAGIC)
4271 {
4272 FATAL("Invalid context");
4273
4274 TRACE("Exiting aaruf_clear_media_model() = AARUF_ERROR_NOT_AARUFORMAT");
4275 return AARUF_ERROR_NOT_AARUFORMAT;
4276 }
4277
4278 // Check we are writing
4279 if(!ctx->is_writing)
4280 {
4281 FATAL("Trying to write a read-only image");
4282
4283 TRACE("Exiting aaruf_clear_media_model() = AARUF_READ_ONLY");
4284 return AARUF_READ_ONLY;
4285 }
4286
4287 if(ctx->metadata_block_header.identifier != MetadataBlock)
4288 {
4289 TRACE("Exiting aaruf_clear_media_model() = AARUF_STATUS_OK");
4290 return AARUF_STATUS_OK;
4291 }
4292
4293 if(ctx->media_model != NULL) free(ctx->media_model);
4294
4295 ctx->media_model = NULL;
4296 ctx->metadata_block_header.mediaModelLength = 0;
4297
4298 // Check if all metadata is clear
4299 if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
4300 ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
4301 ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
4302 ctx->metadata_block_header.mediaSerialNumberLength == 0 && ctx->metadata_block_header.mediaBarcodeLength == 0 &&
4303 ctx->metadata_block_header.mediaPartNumberLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
4304 ctx->metadata_block_header.driveManufacturerLength == 0 &&
4305 ctx->metadata_block_header.driveSerialNumberLength == 0 &&
4306 ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
4307 ctx->metadata_block_header.identifier = 0;
4308
4309 TRACE("Exiting aaruf_clear_media_model() = AARUF_STATUS_OK");
4310 return AARUF_STATUS_OK;
4311}
4312
4340 AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_serial_number(void *context)
4341{
4342 TRACE("Entering aaruf_clear_media_serial_number(%p)", context);
4343
4344 // Check context is correct AaruFormat context
4345 if(context == NULL)
4346 {
4347 FATAL("Invalid context");
4348
4349 TRACE("Exiting aaruf_clear_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
4350 return AARUF_ERROR_NOT_AARUFORMAT;
4351 }
4352
4353 aaruformat_context *ctx = context;
4354
4355 // Not a libaaruformat context
4356 if(ctx->magic != AARU_MAGIC)
4357 {
4358 FATAL("Invalid context");
4359
4360 TRACE("Exiting aaruf_clear_media_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
4361 return AARUF_ERROR_NOT_AARUFORMAT;
4362 }
4363
4364 // Check we are writing
4365 if(!ctx->is_writing)
4366 {
4367 FATAL("Trying to write a read-only image");
4368
4369 TRACE("Exiting aaruf_clear_media_serial_number() = AARUF_READ_ONLY");
4370 return AARUF_READ_ONLY;
4371 }
4372
4373 if(ctx->metadata_block_header.identifier != MetadataBlock)
4374 {
4375 TRACE("Exiting aaruf_clear_media_serial_number() = AARUF_STATUS_OK");
4376 return AARUF_STATUS_OK;
4377 }
4378
4379 if(ctx->media_serial_number != NULL) free(ctx->media_serial_number);
4380
4381 ctx->media_serial_number = NULL;
4382 ctx->metadata_block_header.mediaSerialNumberLength = 0;
4383
4384 // Check if all metadata is clear
4385 if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
4386 ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
4387 ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
4388 ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaBarcodeLength == 0 &&
4389 ctx->metadata_block_header.mediaPartNumberLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
4390 ctx->metadata_block_header.driveManufacturerLength == 0 &&
4391 ctx->metadata_block_header.driveSerialNumberLength == 0 &&
4392 ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
4393 ctx->metadata_block_header.identifier = 0;
4394
4395 TRACE("Exiting aaruf_clear_media_serial_number() = AARUF_STATUS_OK");
4396 return AARUF_STATUS_OK;
4397}
4398
4426 AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_barcode(void *context)
4427{
4428 TRACE("Entering aaruf_clear_media_barcode(%p)", context);
4429
4430 // Check context is correct AaruFormat context
4431 if(context == NULL)
4432 {
4433 FATAL("Invalid context");
4434
4435 TRACE("Exiting aaruf_clear_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
4436 return AARUF_ERROR_NOT_AARUFORMAT;
4437 }
4438
4439 aaruformat_context *ctx = context;
4440
4441 // Not a libaaruformat context
4442 if(ctx->magic != AARU_MAGIC)
4443 {
4444 FATAL("Invalid context");
4445
4446 TRACE("Exiting aaruf_clear_media_barcode() = AARUF_ERROR_NOT_AARUFORMAT");
4447 return AARUF_ERROR_NOT_AARUFORMAT;
4448 }
4449
4450 // Check we are writing
4451 if(!ctx->is_writing)
4452 {
4453 FATAL("Trying to write a read-only image");
4454
4455 TRACE("Exiting aaruf_clear_media_barcode() = AARUF_READ_ONLY");
4456 return AARUF_READ_ONLY;
4457 }
4458
4459 if(ctx->metadata_block_header.identifier != MetadataBlock)
4460 {
4461 TRACE("Exiting aaruf_clear_media_barcode() = AARUF_STATUS_OK");
4462 return AARUF_STATUS_OK;
4463 }
4464
4465 if(ctx->media_barcode != NULL) free(ctx->media_barcode);
4466
4467 ctx->media_barcode = NULL;
4468 ctx->metadata_block_header.mediaBarcodeLength = 0;
4469
4470 // Check if all metadata is clear
4471 if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
4472 ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
4473 ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
4474 ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaSerialNumberLength == 0 &&
4475 ctx->metadata_block_header.mediaPartNumberLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
4476 ctx->metadata_block_header.driveManufacturerLength == 0 &&
4477 ctx->metadata_block_header.driveSerialNumberLength == 0 &&
4478 ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
4479 ctx->metadata_block_header.identifier = 0;
4480
4481 TRACE("Exiting aaruf_clear_media_barcode() = AARUF_STATUS_OK");
4482 return AARUF_STATUS_OK;
4483}
4484
4512 AARU_EXPORT int32_t AARU_CALL aaruf_clear_media_part_number(void *context)
4513{
4514 TRACE("Entering aaruf_clear_media_part_number(%p)", context);
4515
4516 // Check context is correct AaruFormat context
4517 if(context == NULL)
4518 {
4519 FATAL("Invalid context");
4520
4521 TRACE("Exiting aaruf_clear_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
4522 return AARUF_ERROR_NOT_AARUFORMAT;
4523 }
4524
4525 aaruformat_context *ctx = context;
4526
4527 // Not a libaaruformat context
4528 if(ctx->magic != AARU_MAGIC)
4529 {
4530 FATAL("Invalid context");
4531
4532 TRACE("Exiting aaruf_clear_media_part_number() = AARUF_ERROR_NOT_AARUFORMAT");
4533 return AARUF_ERROR_NOT_AARUFORMAT;
4534 }
4535
4536 // Check we are writing
4537 if(!ctx->is_writing)
4538 {
4539 FATAL("Trying to write a read-only image");
4540
4541 TRACE("Exiting aaruf_clear_media_part_number() = AARUF_READ_ONLY");
4542 return AARUF_READ_ONLY;
4543 }
4544
4545 if(ctx->metadata_block_header.identifier != MetadataBlock)
4546 {
4547 TRACE("Exiting aaruf_clear_media_part_number() = AARUF_STATUS_OK");
4548 return AARUF_STATUS_OK;
4549 }
4550
4551 if(ctx->media_part_number != NULL) free(ctx->media_part_number);
4552
4553 ctx->media_part_number = NULL;
4554 ctx->metadata_block_header.mediaPartNumberLength = 0;
4555
4556 // Check if all metadata is clear
4557 if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
4558 ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
4559 ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
4560 ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaSerialNumberLength == 0 &&
4561 ctx->metadata_block_header.mediaBarcodeLength == 0 && ctx->metadata_block_header.driveModelLength == 0 &&
4562 ctx->metadata_block_header.driveManufacturerLength == 0 &&
4563 ctx->metadata_block_header.driveSerialNumberLength == 0 &&
4564 ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
4565 ctx->metadata_block_header.identifier = 0;
4566
4567 TRACE("Exiting aaruf_clear_media_part_number() = AARUF_STATUS_OK");
4568 return AARUF_STATUS_OK;
4569}
4570
4598 AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_manufacturer(void *context)
4599{
4600 TRACE("Entering aaruf_clear_drive_manufacturer(%p)", context);
4601
4602 // Check context is correct AaruFormat context
4603 if(context == NULL)
4604 {
4605 FATAL("Invalid context");
4606
4607 TRACE("Exiting aaruf_clear_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
4608 return AARUF_ERROR_NOT_AARUFORMAT;
4609 }
4610
4611 aaruformat_context *ctx = context;
4612
4613 // Not a libaaruformat context
4614 if(ctx->magic != AARU_MAGIC)
4615 {
4616 FATAL("Invalid context");
4617
4618 TRACE("Exiting aaruf_clear_drive_manufacturer() = AARUF_ERROR_NOT_AARUFORMAT");
4619 return AARUF_ERROR_NOT_AARUFORMAT;
4620 }
4621
4622 // Check we are writing
4623 if(!ctx->is_writing)
4624 {
4625 FATAL("Trying to write a read-only image");
4626
4627 TRACE("Exiting aaruf_clear_drive_manufacturer() = AARUF_READ_ONLY");
4628 return AARUF_READ_ONLY;
4629 }
4630
4631 if(ctx->metadata_block_header.identifier != MetadataBlock)
4632 {
4633 TRACE("Exiting aaruf_clear_drive_manufacturer() = AARUF_STATUS_OK");
4634 return AARUF_STATUS_OK;
4635 }
4636
4637 if(ctx->drive_manufacturer != NULL) free(ctx->drive_manufacturer);
4638
4639 ctx->drive_manufacturer = NULL;
4640 ctx->metadata_block_header.driveManufacturerLength = 0;
4641
4642 // Check if all metadata is clear
4643 if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
4644 ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
4645 ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
4646 ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaSerialNumberLength == 0 &&
4647 ctx->metadata_block_header.mediaBarcodeLength == 0 && ctx->metadata_block_header.mediaPartNumberLength == 0 &&
4648 ctx->metadata_block_header.driveModelLength == 0 && ctx->metadata_block_header.driveSerialNumberLength == 0 &&
4649 ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
4650 ctx->metadata_block_header.identifier = 0;
4651
4652 TRACE("Exiting aaruf_clear_drive_manufacturer() = AARUF_STATUS_OK");
4653 return AARUF_STATUS_OK;
4654}
4655
4684 AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_model(void *context)
4685{
4686 TRACE("Entering aaruf_clear_drive_model(%p)", context);
4687
4688 // Check context is correct AaruFormat context
4689 if(context == NULL)
4690 {
4691 FATAL("Invalid context");
4692
4693 TRACE("Exiting aaruf_clear_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
4694 return AARUF_ERROR_NOT_AARUFORMAT;
4695 }
4696
4697 aaruformat_context *ctx = context;
4698
4699 // Not a libaaruformat context
4700 if(ctx->magic != AARU_MAGIC)
4701 {
4702 FATAL("Invalid context");
4703
4704 TRACE("Exiting aaruf_clear_drive_model() = AARUF_ERROR_NOT_AARUFORMAT");
4705 return AARUF_ERROR_NOT_AARUFORMAT;
4706 }
4707
4708 // Check we are writing
4709 if(!ctx->is_writing)
4710 {
4711 FATAL("Trying to write a read-only image");
4712
4713 TRACE("Exiting aaruf_clear_drive_model() = AARUF_READ_ONLY");
4714 return AARUF_READ_ONLY;
4715 }
4716
4717 if(ctx->metadata_block_header.identifier != MetadataBlock)
4718 {
4719 TRACE("Exiting aaruf_clear_drive_model() = AARUF_STATUS_OK");
4720 return AARUF_STATUS_OK;
4721 }
4722
4723 if(ctx->drive_model != NULL) free(ctx->drive_model);
4724
4725 ctx->drive_model = NULL;
4726 ctx->metadata_block_header.driveModelLength = 0;
4727
4728 // Check if all metadata is clear
4729 if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
4730 ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
4731 ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
4732 ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaSerialNumberLength == 0 &&
4733 ctx->metadata_block_header.mediaBarcodeLength == 0 && ctx->metadata_block_header.mediaPartNumberLength == 0 &&
4734 ctx->metadata_block_header.driveManufacturerLength == 0 &&
4735 ctx->metadata_block_header.driveSerialNumberLength == 0 &&
4736 ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
4737 ctx->metadata_block_header.identifier = 0;
4738
4739 TRACE("Exiting aaruf_clear_drive_model() = AARUF_STATUS_OK");
4740 return AARUF_STATUS_OK;
4741}
4742
4773 AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_serial_number(void *context)
4774{
4775 TRACE("Entering aaruf_clear_drive_serial_number(%p)", context);
4776
4777 // Check context is correct AaruFormat context
4778 if(context == NULL)
4779 {
4780 FATAL("Invalid context");
4781
4782 TRACE("Exiting aaruf_clear_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
4783 return AARUF_ERROR_NOT_AARUFORMAT;
4784 }
4785
4786 aaruformat_context *ctx = context;
4787
4788 // Not a libaaruformat context
4789 if(ctx->magic != AARU_MAGIC)
4790 {
4791 FATAL("Invalid context");
4792
4793 TRACE("Exiting aaruf_clear_drive_serial_number() = AARUF_ERROR_NOT_AARUFORMAT");
4794 return AARUF_ERROR_NOT_AARUFORMAT;
4795 }
4796
4797 // Check we are writing
4798 if(!ctx->is_writing)
4799 {
4800 FATAL("Trying to write a read-only image");
4801
4802 TRACE("Exiting aaruf_clear_drive_serial_number() = AARUF_READ_ONLY");
4803 return AARUF_READ_ONLY;
4804 }
4805
4806 if(ctx->metadata_block_header.identifier != MetadataBlock)
4807 {
4808 TRACE("Exiting aaruf_clear_drive_serial_number() = AARUF_STATUS_OK");
4809 return AARUF_STATUS_OK;
4810 }
4811
4812 if(ctx->drive_serial_number != NULL) free(ctx->drive_serial_number);
4813
4814 ctx->drive_serial_number = NULL;
4815 ctx->metadata_block_header.driveSerialNumberLength = 0;
4816
4817 // Check if all metadata is clear
4818 if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
4819 ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
4820 ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
4821 ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaSerialNumberLength == 0 &&
4822 ctx->metadata_block_header.mediaBarcodeLength == 0 && ctx->metadata_block_header.mediaPartNumberLength == 0 &&
4823 ctx->metadata_block_header.driveModelLength == 0 && ctx->metadata_block_header.driveManufacturerLength == 0 &&
4824 ctx->metadata_block_header.driveFirmwareRevisionLength == 0)
4825 ctx->metadata_block_header.identifier = 0;
4826
4827 TRACE("Exiting aaruf_clear_drive_serial_number() = AARUF_STATUS_OK");
4828 return AARUF_STATUS_OK;
4829}
4830
4861 AARU_EXPORT int32_t AARU_CALL aaruf_clear_drive_firmware_revision(void *context)
4862{
4863 TRACE("Entering aaruf_clear_drive_firmware_revision(%p)", context);
4864
4865 // Check context is correct AaruFormat context
4866 if(context == NULL)
4867 {
4868 FATAL("Invalid context");
4869
4870 TRACE("Exiting aaruf_clear_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
4871 return AARUF_ERROR_NOT_AARUFORMAT;
4872 }
4873
4874 aaruformat_context *ctx = context;
4875
4876 // Not a libaaruformat context
4877 if(ctx->magic != AARU_MAGIC)
4878 {
4879 FATAL("Invalid context");
4880
4881 TRACE("Exiting aaruf_clear_drive_firmware_revision() = AARUF_ERROR_NOT_AARUFORMAT");
4882 return AARUF_ERROR_NOT_AARUFORMAT;
4883 }
4884
4885 // Check we are writing
4886 if(!ctx->is_writing)
4887 {
4888 FATAL("Trying to write a read-only image");
4889
4890 TRACE("Exiting aaruf_clear_drive_firmware_revision() = AARUF_READ_ONLY");
4891 return AARUF_READ_ONLY;
4892 }
4893
4894 if(ctx->metadata_block_header.identifier != MetadataBlock)
4895 {
4896 TRACE("Exiting aaruf_clear_drive_firmware_revision() = AARUF_STATUS_OK");
4897 return AARUF_STATUS_OK;
4898 }
4899
4900 if(ctx->drive_firmware_revision != NULL) free(ctx->drive_firmware_revision);
4901
4902 ctx->drive_firmware_revision = NULL;
4903 ctx->metadata_block_header.driveFirmwareRevisionLength = 0;
4904
4905 // Check if all metadata is clear
4906 if(ctx->metadata_block_header.mediaSequence == 0 && ctx->metadata_block_header.lastMediaSequence == 0 &&
4907 ctx->metadata_block_header.creatorLength == 0 && ctx->metadata_block_header.commentsLength == 0 &&
4908 ctx->metadata_block_header.mediaTitleLength == 0 && ctx->metadata_block_header.mediaManufacturerLength == 0 &&
4909 ctx->metadata_block_header.mediaModelLength == 0 && ctx->metadata_block_header.mediaSerialNumberLength == 0 &&
4910 ctx->metadata_block_header.mediaBarcodeLength == 0 && ctx->metadata_block_header.mediaPartNumberLength == 0 &&
4911 ctx->metadata_block_header.driveModelLength == 0 && ctx->metadata_block_header.driveManufacturerLength == 0 &&
4912 ctx->metadata_block_header.driveSerialNumberLength == 0)
4913 ctx->metadata_block_header.identifier = 0;
4914
4915 TRACE("Exiting aaruf_clear_drive_firmware_revision() = AARUF_STATUS_OK");
4916 return AARUF_STATUS_OK;
4917}
aaruformat.h
AARU_MAGIC
#define AARU_MAGIC
Magic identifier for AaruFormat container (ASCII "AARUFRMT").
Definition consts.h:64
AARU_CALL
#define AARU_CALL
Definition decls.h:45
AARU_EXPORT
#define AARU_EXPORT
Definition decls.h:54
GeometryBlock
@ GeometryBlock
Block containing logical geometry.
Definition enums.h:148
AaruMetadataJsonBlock
@ AaruMetadataJsonBlock
Block containing JSON version of Aaru Metadata.
Definition enums.h:159
CicmBlock
@ CicmBlock
Block containing CICM XML metadata.
Definition enums.h:151
MetadataBlock
@ MetadataBlock
Block containing metadata.
Definition enums.h:149
AARUF_STATUS_OK
#define AARUF_STATUS_OK
Sector present and read without uncorrectable errors.
Definition errors.h:75
AARUF_READ_ONLY
#define AARUF_READ_ONLY
Operation requires write mode but context is read-only.
Definition errors.h:61
AARUF_ERROR_NOT_ENOUGH_MEMORY
#define AARUF_ERROR_NOT_ENOUGH_MEMORY
Memory allocation failure (critical).
Definition errors.h:48
AARUF_ERROR_CANNOT_READ_BLOCK
#define AARUF_ERROR_CANNOT_READ_BLOCK
Generic block read failure (seek/read error).
Definition errors.h:46
AARUF_ERROR_INCORRECT_DATA_SIZE
#define AARUF_ERROR_INCORRECT_DATA_SIZE
Data size does not match expected size.
Definition errors.h:65
AARUF_ERROR_METADATA_NOT_PRESENT
#define AARUF_ERROR_METADATA_NOT_PRESENT
Requested metadata not present in image.
Definition errors.h:69
AARUF_ERROR_NOT_AARUFORMAT
#define AARUF_ERROR_NOT_AARUFORMAT
Input file/stream failed magic or structural validation.
Definition errors.h:40
AARUF_ERROR_BUFFER_TOO_SMALL
#define AARUF_ERROR_BUFFER_TOO_SMALL
Caller-supplied buffer insufficient for data.
Definition errors.h:49
log.h
FATAL
#define FATAL(fmt,...)
Definition log.h:40
TRACE
#define TRACE(fmt,...)
Definition log.h:25
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_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_set_media_barcode
int32_t aaruf_set_media_barcode(void *context, const uint8_t *data, const int32_t length)
Sets the media barcode information for the image.
Definition metadata.c:1178
aaruf_set_media_model
int32_t aaruf_set_media_model(void *context, const uint8_t *data, const int32_t length)
Sets the media model or product designation for the image.
Definition metadata.c:941
aaruf_set_media_sequence
int32_t aaruf_set_media_sequence(void *context, const int32_t sequence, const int32_t last_sequence)
Sets the media sequence information for multi-volume media sets.
Definition metadata.c:364
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_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_drive_manufacturer
int32_t aaruf_set_drive_manufacturer(void *context, const uint8_t *data, const int32_t length)
Sets the drive manufacturer information for the image.
Definition metadata.c:1414
aaruf_set_drive_model
int32_t aaruf_set_drive_model(void *context, const uint8_t *data, const int32_t length)
Sets the drive model information for the image.
Definition metadata.c:1536
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_set_media_title
int32_t aaruf_set_media_title(void *context, const uint8_t *data, const 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_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_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_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_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_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_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_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_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_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_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_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_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_clear_creator
int32_t aaruf_clear_creator(void *context)
Clears the creator (person/operator) information from the image metadata.
Definition metadata.c:3874
aaruf_set_media_part_number
int32_t aaruf_set_media_part_number(void *context, const uint8_t *data, const int32_t length)
Sets the media part number or model designation for the image.
Definition metadata.c:1299
aaruf_set_media_serial_number
int32_t aaruf_set_media_serial_number(void *context, const uint8_t *data, const int32_t length)
Sets the media serial number for the image.
Definition metadata.c:1056
aaruf_set_geometry
int32_t aaruf_set_geometry(void *context, const uint32_t cylinders, const uint32_t heads, const uint32_t sectors_per_track)
Sets the logical CHS geometry for the AaruFormat image.
Definition metadata.c:230
aaruf_set_comments
int32_t aaruf_set_comments(void *context, const uint8_t *data, const int32_t length)
Sets user comments or notes for the image.
Definition metadata.c:609
aaruf_set_drive_firmware_revision
int32_t aaruf_set_drive_firmware_revision(void *context, const uint8_t *data, const int32_t length)
Sets the drive firmware revision for the image.
Definition metadata.c:1795
aaruf_set_media_manufacturer
int32_t aaruf_set_media_manufacturer(void *context, const uint8_t *data, const int32_t length)
Sets the media manufacturer information for the image.
Definition metadata.c:834
aaruf_set_drive_serial_number
int32_t aaruf_set_drive_serial_number(void *context, const uint8_t *data, const int32_t length)
Sets the drive serial number for the image.
Definition metadata.c:1660
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_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_creator
int32_t aaruf_set_creator(void *context, const uint8_t *data, const int32_t length)
Sets the creator (person/operator) information for the image.
Definition metadata.c:495
AaruMetadataJsonBlockHeader::identifier
uint32_t identifier
Block identifier, must be BlockType::AaruMetadataJsonBlock.
Definition metadata.h:121
AaruMetadataJsonBlockHeader::length
uint32_t length
Length in bytes of the Aaru metadata JSON payload that follows.
Definition metadata.h:122
CicmMetadataBlock::length
uint32_t length
Length in bytes of the CICM metadata payload that follows.
Definition metadata.h:110
CicmMetadataBlock::identifier
uint32_t identifier
Block identifier, must be BlockType::CicmBlock.
Definition metadata.h:109
DdtHeader2::overflow
uint16_t overflow
Trailing dumped sectors beyond user area (overflow range), still mapped with entries.
Definition ddt.h:151
DdtHeader2::blocks
uint64_t blocks
Total internal span (negative + usable + overflow) in logical sectors.
Definition ddt.h:150
DdtHeader2::negative
uint16_t negative
Leading negative LBA count; added to external L to build internal index.
Definition ddt.h:149
GeometryBlockHeader::identifier
uint32_t identifier
Block identifier, must be BlockType::GeometryBlock.
Definition data.h:92
GeometryBlockHeader::cylinders
uint32_t cylinders
Number of cylinders.
Definition data.h:93
GeometryBlockHeader::heads
uint32_t heads
Number of heads (tracks per cylinder).
Definition data.h:94
GeometryBlockHeader::sectorsPerTrack
uint32_t sectorsPerTrack
Number of sectors per track.
Definition data.h:95
ImageInfo
High-level summary of an opened Aaru image containing metadata and media characteristics.
Definition aaru.h:870
MetadataBlockHeader::commentsLength
uint32_t commentsLength
Length in bytes (including null) of comments string.
Definition metadata.h:78
MetadataBlockHeader::mediaSequence
int32_t mediaSequence
Sequence number within a multi-disc / multi-volume set (0-based or 1-based as producer defines).
Definition metadata.h:72
MetadataBlockHeader::identifier
uint32_t identifier
Block identifier, must be BlockType::MetadataBlock.
Definition metadata.h:70
MetadataBlockHeader::driveModelLength
uint32_t driveModelLength
Length in bytes (including null) of drive model string.
Definition metadata.h:94
MetadataBlockHeader::driveManufacturerLength
uint32_t driveManufacturerLength
Length in bytes (including null) of drive manufacturer string.
Definition metadata.h:92
MetadataBlockHeader::mediaTitleLength
uint32_t mediaTitleLength
Length in bytes (including null) of media title string.
Definition metadata.h:80
MetadataBlockHeader::driveSerialNumberLength
uint32_t driveSerialNumberLength
Length in bytes (including null) of drive serial number string.
Definition metadata.h:96
MetadataBlockHeader::mediaManufacturerLength
uint32_t mediaManufacturerLength
Length in bytes (including null) of media manufacturer string.
Definition metadata.h:82
MetadataBlockHeader::mediaModelLength
uint32_t mediaModelLength
Length in bytes (including null) of media model string.
Definition metadata.h:84
MetadataBlockHeader::lastMediaSequence
int32_t lastMediaSequence
Total number of media in the set; 0 or 1 if single item.
Definition metadata.h:74
MetadataBlockHeader::mediaSerialNumberLength
uint32_t mediaSerialNumberLength
Length in bytes (including null) of media serial number string.
Definition metadata.h:86
MetadataBlockHeader::mediaPartNumberLength
uint32_t mediaPartNumberLength
Length in bytes (including null) of media part number string.
Definition metadata.h:90
MetadataBlockHeader::mediaBarcodeLength
uint32_t mediaBarcodeLength
Length in bytes (including null) of media barcode string.
Definition metadata.h:88
MetadataBlockHeader::creatorLength
uint32_t creatorLength
Length in bytes (including null) of creator string (0 if absent).
Definition metadata.h:76
MetadataBlockHeader::driveFirmwareRevisionLength
uint32_t driveFirmwareRevisionLength
Length in bytes (including null) of drive firmware revision string.
Definition metadata.h:98
aaruformat_context
Master context representing an open or in‑creation Aaru image.
Definition context.h:172
aaruformat_context::media_barcode
uint8_t * media_barcode
Barcode of the media represented by the image.
Definition context.h:222
aaruformat_context::user_data_ddt_header
DdtHeader2 user_data_ddt_header
Active user data DDT v2 header (primary table meta).
Definition context.h:189
aaruformat_context::creator
uint8_t * creator
Who (person) created the image?
Definition context.h:216
aaruformat_context::cicm_block
uint8_t * cicm_block
CICM XML payload.
Definition context.h:214
aaruformat_context::cylinders
uint32_t cylinders
Cylinders of the media represented by the image.
Definition context.h:234
aaruformat_context::drive_firmware_revision
uint8_t * drive_firmware_revision
Firmware revision of the drive used to read the media represented by the image.
Definition context.h:228
aaruformat_context::media_serial_number
uint8_t * media_serial_number
Serial number of the media represented by the image.
Definition context.h:221
aaruformat_context::metadata_block_header
MetadataBlockHeader metadata_block_header
Metadata block header.
Definition context.h:230
aaruformat_context::media_model
uint8_t * media_model
Model of the media represented by the image.
Definition context.h:220
aaruformat_context::drive_serial_number
uint8_t * drive_serial_number
Serial number of the drive used to read the media represented by the image.
Definition context.h:226
aaruformat_context::drive_manufacturer
uint8_t * drive_manufacturer
Manufacturer of the drive used to read the media represented by the image.
Definition context.h:224
aaruformat_context::is_writing
bool is_writing
True if context opened/created for writing.
Definition context.h:292
aaruformat_context::cicm_block_header
CicmMetadataBlock cicm_block_header
CICM metadata header (if present).
Definition context.h:231
aaruformat_context::drive_model
uint8_t * drive_model
Model of the drive used to read the media represented by the image.
Definition context.h:225
aaruformat_context::magic
uint64_t magic
File magic (AARU_MAGIC) post-open.
Definition context.h:174
aaruformat_context::geometry_block
GeometryBlockHeader geometry_block
Logical geometry block (if present).
Definition context.h:229
aaruformat_context::json_block
uint8_t * json_block
JSON metadata block payload (UTF-8).
Definition context.h:215
aaruformat_context::media_part_number
uint8_t * media_part_number
Part number of the media represented by the image.
Definition context.h:223
aaruformat_context::json_block_header
AaruMetadataJsonBlockHeader json_block_header
JSON metadata block header (if present).
Definition context.h:233
aaruformat_context::sectors_per_track
uint32_t sectors_per_track
Sectors per track of the media represented by the image (for variable image, the smallest)
Definition context.h:236
aaruformat_context::comments
uint8_t * comments
Image comments.
Definition context.h:218
aaruformat_context::heads
uint32_t heads
Heads of the media represented by the image.
Definition context.h:235
aaruformat_context::image_info
ImageInfo image_info
Exposed high-level image info summary.
Definition context.h:260
aaruformat_context::media_title
uint8_t * media_title
Title of the media represented by the image.
Definition context.h:217
aaruformat_context::media_manufacturer
uint8_t * media_manufacturer
Manufacturer of the media represented by the image.
Definition context.h:219