mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Compare commits
18 Commits
v1.0.0-alp
...
v1.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
4639e0b71c
|
|||
|
76a013cd04
|
|||
|
a26ba9522e
|
|||
|
45f2494923
|
|||
|
963174ce20
|
|||
|
c5e3878174
|
|||
|
afa1c94aac
|
|||
|
12418518c2
|
|||
|
5bf7981133
|
|||
|
dc221d91ee
|
|||
|
d0859665d9
|
|||
|
0d4d01fa8f
|
|||
|
bd8c00e758
|
|||
|
e28b1209c8
|
|||
|
0e51337e30
|
|||
|
56bb631872
|
|||
|
58788beed1
|
|||
|
176cab648b
|
@@ -544,6 +544,7 @@ For the most accurate and up-to-date list, refer to the `libaaruformat` source.
|
||||
|ISO_14517|802|5.25", M.O., 1273011 sectors, 1024 bytes/sector, ISO 14517, 2.6Gb/cart
|
||||
|ISO_14517_512|803|5.25", M.O., 2244958 sectors, 512 bytes/sector, ISO 14517, 2.3Gb/cart
|
||||
|ISO_15041_512|804|3.5", M.O., 1041500 sectors, 512 bytes/sector, ISO 15041, 540Mb/cart
|
||||
|HSM650|805|3,5", M.O., ??????? sectors, proprietary, 650Mb/cart, Sony HyperStorage
|
||||
|MetaFloppy_Mod_I|820|5.25", SS, DD, 35 tracks, 16 spt, 256 bytes/sector, MFM, 48 tpi, ???rpm
|
||||
|AtariLynxCard|821|
|
||||
|AtariJaguarCartridge|822|
|
||||
|
||||
@@ -770,8 +770,60 @@ typedef enum
|
||||
// VideoNow, types 740 to 749
|
||||
VideoNow = 740, ///< Hasbro VideoNow 85 mm proprietary video disc
|
||||
VideoNowColor = 741, ///< Hasbro VideoNow Color disc
|
||||
VideoNowXp = 742 ///< Hasbro VideoNow XP higher capacity disc
|
||||
//
|
||||
VideoNowXp = 742, ///< Hasbro VideoNow XP higher capacity disc
|
||||
// VideoNow, types 740 to 749
|
||||
|
||||
// Iomega, types 750 to 759
|
||||
Bernoulli10 = 750, ///< 8"x11" Bernoulli Box disk with 10Mb capacity
|
||||
///< 8"x11" Bernoulli Box disk with 20Mb capacity
|
||||
Bernoulli20 = 751,
|
||||
///< 5⅓" Bernoulli Box II disk with 20Mb capacity
|
||||
BernoulliBox2_20 = 752,
|
||||
// Iomega, types 750 to 759
|
||||
|
||||
// Kodak, types 760 to 769
|
||||
KodakVerbatim3 = 760, ///< Kodak/Verbatim (3Mb)
|
||||
KodakVerbatim6 = 761, ///< Kodak/Verbatim (6Mb)
|
||||
KodakVerbatim12 = 762, ///< Kodak/Verbatim (12Mb)
|
||||
// Kodak, types 760 to 769
|
||||
|
||||
// Sony and Panasonic Blu-ray derived, types 770 to 799
|
||||
ProfessionalDisc = 770, ///< Professional Disc for video, single layer, rewritable, 23Gb
|
||||
ProfessionalDiscDual = 771, ///< Professional Disc for video, dual layer, rewritable, 50Gb
|
||||
ProfessionalDiscTriple = 772, ///< Professional Disc for video, triple layer, rewritable, 100Gb
|
||||
ProfessionalDiscQuad = 773, ///< Professional Disc for video, quad layer, write once, 128Gb
|
||||
PDD = 774, ///< Professional Disc for DATA, single layer, rewritable, 23Gb
|
||||
PDD_WORM = 775, ///< Professional Disc for DATA, single layer, write once, 23Gb
|
||||
ArchivalDisc = 776, ///< Archival Disc, 1st gen., 300Gb
|
||||
ArchivalDisc2 = 777, ///< Archival Disc, 2nd gen., 500Gb
|
||||
ArchivalDisc3 = 778, ///< Archival Disc, 3rd gen., 1Tb
|
||||
ODC300R = 779, ///< Optical Disc archive, 1st gen., write once, 300Gb
|
||||
ODC300RE = 780, ///< Optical Disc archive, 1st gen., rewritable, 300Gb
|
||||
ODC600R = 781, ///< Optical Disc archive, 2nd gen., write once, 600Gb
|
||||
ODC600RE = 782, ///< Optical Disc archive, 2nd gen., rewritable, 600Gb
|
||||
ODC1200RE = 783, ///< Optical Disc archive, 3rd gen., rewritable, 1200Gb
|
||||
ODC1500R = 784, ///< Optical Disc archive, 3rd gen., write once, 1500Gb
|
||||
ODC3300R = 785, ///< Optical Disc archive, 4th gen., write once, 3300Gb
|
||||
ODC5500R = 786, ///< Optical Disc archive, 5th gen., write once, 5500Gb
|
||||
// Sony and Panasonic Blu-ray derived, types 770 to 799
|
||||
|
||||
// Magneto-optical, types 800 to 819
|
||||
ECMA_322_1k = 800, ///< 5,25", M.O., 4383356 sectors, 1024 bytes/sector, ECMA-322, ISO 22092, 9.1Gb/cart
|
||||
ECMA_322_512 = 801, ///< 5,25", M.O., ??????? sectors, 512 bytes/sector, ECMA-322, ISO 22092, 9.1Gb/cart
|
||||
ISO_14517 = 802, ///< 5,25", M.O., 1273011 sectors, 1024 bytes/sector, ISO 14517, 2.6Gb/cart
|
||||
ISO_14517_512 = 803, ///< 5,25", M.O., 2244958 sectors, 512 bytes/sector, ISO 14517, 2.3Gb/cart
|
||||
ISO_15041_512 = 804, ///< 3,5", M.O., 1041500 sectors, 512 bytes/sector, ISO 15041, 540Mb/cart
|
||||
HSM650 = 805, ///< 3,5", M.O., ??????? sectors, proprietary, 650Mb/cart, Sony HyperStorage
|
||||
// Magneto-optical, types 800 to 819
|
||||
|
||||
// More floppy formats, types 820 to deprecated
|
||||
MetaFloppy_Mod_I = 820, ///< 5.25", SS, DD, 35 tracks, 16 spt, 256 bytes/sector, MFM, 48 tpi, ???rpm
|
||||
HF12 = 823, ///< HyperFlex (12Mb), 5.25", DS, 301 tracks, 78 spt, 256 bytes/sector, MFM, 333 tpi, 600rpm
|
||||
HF24 = 824, ///< HyperFlex (24Mb), 5.25", DS, 506 tracks, 78 spt, 256 bytes/sector, MFM, 666 tpi, 720rpm
|
||||
// More floppy formats, types 820 to deprecated
|
||||
|
||||
AtariLynxCard = 821, ///< Atari Lynx card
|
||||
AtariJaguarCartridge = 822 ///< Atari Jaguar cartridge
|
||||
} MediaType;
|
||||
|
||||
/** @} */ /* end of MediaTypes group */
|
||||
@@ -1008,7 +1060,7 @@ typedef enum
|
||||
MiniDiscUTOC = 71, ///< User TOC, contains fragments, track names, and can be from 1 to 3 sectors of 2336 bytes
|
||||
MiniDiscDTOC = 72, ///< Not entirely clear kind of TOC that only appears on MD-DATA discs
|
||||
DVD_DiscKey_Decrypted = 73, ///< Decrypted DVD disc key,
|
||||
MaxMediaTag = DVD_DiscKey_Decrypted
|
||||
MaxMediaTag = DVD_DiscKey_Decrypted
|
||||
} MediaTagType;
|
||||
|
||||
/** @} */ /* end of MediaTags group */
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>libaaruformat</id>
|
||||
<version>1.0.0-alpha.11</version>
|
||||
<version>1.0.0-alpha.17</version>
|
||||
<description>Library for management of AaruFormat images.</description>
|
||||
<authors>claunia</authors>
|
||||
<projectUrl>https://github.com/aaru-dps/libaaruformat</projectUrl>
|
||||
|
||||
@@ -81,7 +81,7 @@ void process_metadata_block(aaruformat_context *ctx, const IndexEntry *entry)
|
||||
|
||||
ctx->image_info.ImageSize += ctx->metadata_block_header.blockSize;
|
||||
|
||||
ctx->metadata_block = (uint8_t *)malloc(ctx->metadata_block_header.blockSize);
|
||||
ctx->metadata_block = (uint8_t *)malloc(ctx->metadata_block_header.blockSize + sizeof(MetadataBlockHeader));
|
||||
|
||||
if(ctx->metadata_block == NULL)
|
||||
{
|
||||
@@ -92,15 +92,20 @@ void process_metadata_block(aaruformat_context *ctx, const IndexEntry *entry)
|
||||
return;
|
||||
}
|
||||
|
||||
TRACE("Reading metadata block of size %u at position %" PRIu64, ctx->metadata_block_header.blockSize,
|
||||
entry->offset + sizeof(MetadataBlockHeader));
|
||||
read_bytes = fread(ctx->metadata_block, 1, ctx->metadata_block_header.blockSize, ctx->imageStream);
|
||||
TRACE("Reading metadata block of size %u at position %" PRIu64,
|
||||
ctx->metadata_block_header.blockSize + sizeof(MetadataBlockHeader), entry->offset);
|
||||
|
||||
if(read_bytes != ctx->metadata_block_header.blockSize)
|
||||
fseek(ctx->imageStream, entry->offset, SEEK_SET);
|
||||
read_bytes = fread(ctx->metadata_block, 1, ctx->metadata_block_header.blockSize + sizeof(MetadataBlockHeader),
|
||||
ctx->imageStream);
|
||||
|
||||
if(read_bytes != ctx->metadata_block_header.blockSize + sizeof(MetadataBlockHeader))
|
||||
{
|
||||
memset(&ctx->metadata_block_header, 0, sizeof(MetadataBlockHeader));
|
||||
free(ctx->metadata_block);
|
||||
FATAL("Could not read metadata block, continuing...");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(ctx->metadata_block_header.mediaSequence > 0 && ctx->metadata_block_header.lastMediaSequence > 0)
|
||||
|
||||
42
src/close.c
42
src/close.c
@@ -939,6 +939,7 @@ static void write_mode2_subheaders_block(aaruformat_context *ctx)
|
||||
else
|
||||
subheaders_block.cmpCrc64 = aaruf_crc64_data(buffer, subheaders_block.cmpLength);
|
||||
|
||||
const size_t length_to_write = subheaders_block.cmpLength;
|
||||
if(subheaders_block.compression == Lzma) subheaders_block.cmpLength += LZMA_PROPERTIES_LENGTH;
|
||||
|
||||
// Write header
|
||||
@@ -947,7 +948,7 @@ static void write_mode2_subheaders_block(aaruformat_context *ctx)
|
||||
if(subheaders_block.compression == Lzma) fwrite(lzma_properties, LZMA_PROPERTIES_LENGTH, 1, ctx->imageStream);
|
||||
|
||||
// Write data
|
||||
size_t written_bytes = fwrite(buffer, subheaders_block.cmpLength, 1, ctx->imageStream);
|
||||
const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->imageStream);
|
||||
if(written_bytes == 1)
|
||||
{
|
||||
TRACE("Successfully wrote MODE 2 subheaders block (%" PRIu64 " bytes)", subheaders_block.cmpLength);
|
||||
@@ -1052,6 +1053,7 @@ static void write_sector_prefix(aaruformat_context *ctx)
|
||||
else
|
||||
prefix_block.cmpCrc64 = aaruf_crc64_data(buffer, prefix_block.cmpLength);
|
||||
|
||||
const size_t length_to_write = prefix_block.cmpLength;
|
||||
if(prefix_block.compression == Lzma) prefix_block.cmpLength += LZMA_PROPERTIES_LENGTH;
|
||||
|
||||
// Write header
|
||||
@@ -1060,7 +1062,7 @@ static void write_sector_prefix(aaruformat_context *ctx)
|
||||
if(prefix_block.compression == Lzma) fwrite(lzma_properties, LZMA_PROPERTIES_LENGTH, 1, ctx->imageStream);
|
||||
|
||||
// Write data
|
||||
const size_t written_bytes = fwrite(buffer, prefix_block.cmpLength, 1, ctx->imageStream);
|
||||
const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->imageStream);
|
||||
if(written_bytes == 1)
|
||||
{
|
||||
TRACE("Successfully wrote CD sector prefix block (%" PRIu64 " bytes)", prefix_block.cmpLength);
|
||||
@@ -1174,6 +1176,7 @@ static void write_sector_suffix(aaruformat_context *ctx)
|
||||
else
|
||||
suffix_block.cmpCrc64 = aaruf_crc64_data(buffer, suffix_block.cmpLength);
|
||||
|
||||
const size_t length_to_write = suffix_block.cmpLength;
|
||||
if(suffix_block.compression == Lzma) suffix_block.cmpLength += LZMA_PROPERTIES_LENGTH;
|
||||
|
||||
// Write header
|
||||
@@ -1182,7 +1185,7 @@ static void write_sector_suffix(aaruformat_context *ctx)
|
||||
if(suffix_block.compression == Lzma) fwrite(lzma_properties, LZMA_PROPERTIES_LENGTH, 1, ctx->imageStream);
|
||||
|
||||
// Write data
|
||||
const size_t written_bytes = fwrite(buffer, suffix_block.cmpLength, 1, ctx->imageStream);
|
||||
const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->imageStream);
|
||||
if(written_bytes == 1)
|
||||
{
|
||||
TRACE("Successfully wrote CD sector suffix block (%" PRIu64 " bytes)", suffix_block.cmpLength);
|
||||
@@ -1302,6 +1305,7 @@ static void write_sector_prefix_ddt(aaruformat_context *ctx)
|
||||
else
|
||||
ddt_header2.cmpCrc64 = aaruf_crc64_data(buffer, (uint32_t)ddt_header2.cmpLength);
|
||||
|
||||
const size_t length_to_write = ddt_header2.cmpLength;
|
||||
if(ddt_header2.compression == Lzma) ddt_header2.cmpLength += LZMA_PROPERTIES_LENGTH;
|
||||
|
||||
// Write header
|
||||
@@ -1310,7 +1314,7 @@ static void write_sector_prefix_ddt(aaruformat_context *ctx)
|
||||
if(ddt_header2.compression == Lzma) fwrite(lzma_properties, LZMA_PROPERTIES_LENGTH, 1, ctx->imageStream);
|
||||
|
||||
// Write data
|
||||
const size_t written_bytes = fwrite(buffer, ddt_header2.cmpLength, 1, ctx->imageStream);
|
||||
const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->imageStream);
|
||||
if(written_bytes == 1)
|
||||
{
|
||||
TRACE("Successfully wrote sector prefix DDT v2 (%" PRIu64 " bytes)", ddt_header2.cmpLength);
|
||||
@@ -1446,6 +1450,7 @@ static void write_sector_suffix_ddt(aaruformat_context *ctx)
|
||||
else
|
||||
ddt_header2.cmpCrc64 = aaruf_crc64_data(buffer, (uint32_t)ddt_header2.cmpLength);
|
||||
|
||||
const size_t length_to_write = ddt_header2.cmpLength;
|
||||
if(ddt_header2.compression == Lzma) ddt_header2.cmpLength += LZMA_PROPERTIES_LENGTH;
|
||||
|
||||
// Write header
|
||||
@@ -1454,7 +1459,7 @@ static void write_sector_suffix_ddt(aaruformat_context *ctx)
|
||||
if(ddt_header2.compression == Lzma) fwrite(lzma_properties, LZMA_PROPERTIES_LENGTH, 1, ctx->imageStream);
|
||||
|
||||
// Write data
|
||||
const size_t written_bytes = fwrite(buffer, ddt_header2.cmpLength, 1, ctx->imageStream);
|
||||
const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->imageStream);
|
||||
if(written_bytes == 1)
|
||||
{
|
||||
TRACE("Successfully wrote sector suffix DDT v2 (%" PRIu64 " bytes)", ddt_header2.cmpLength);
|
||||
@@ -1553,14 +1558,13 @@ static void write_sector_subchannel(const aaruformat_context *ctx)
|
||||
bool owns_buffer = false;
|
||||
uint8_t lzma_properties[LZMA_PROPERTIES_LENGTH] = {0};
|
||||
|
||||
subchannel_block.cmpLength = subchannel_block.length;
|
||||
|
||||
if(ctx->image_info.MetadataMediaType == OpticalDisc)
|
||||
{
|
||||
subchannel_block.type = CdSectorSubchannel;
|
||||
subchannel_block.length = (uint32_t)(ctx->user_data_ddt_header.negative + ctx->image_info.Sectors +
|
||||
ctx->user_data_ddt_header.overflow) *
|
||||
96;
|
||||
subchannel_block.cmpLength = subchannel_block.length;
|
||||
|
||||
if(ctx->compression_enabled)
|
||||
{
|
||||
@@ -1627,6 +1631,7 @@ static void write_sector_subchannel(const aaruformat_context *ctx)
|
||||
TRACE("Incorrect media type, not writing sector subchannel block");
|
||||
return; // Incorrect media type
|
||||
}
|
||||
subchannel_block.cmpLength = subchannel_block.length;
|
||||
subchannel_block.compression = Lzma;
|
||||
|
||||
uint8_t *dst_buffer = malloc(subchannel_block.length);
|
||||
@@ -1669,6 +1674,7 @@ static void write_sector_subchannel(const aaruformat_context *ctx)
|
||||
else
|
||||
subchannel_block.cmpCrc64 = aaruf_crc64_data(buffer, subchannel_block.cmpLength);
|
||||
|
||||
const size_t length_to_write = subchannel_block.cmpLength;
|
||||
if(subchannel_block.compression != None) subchannel_block.cmpLength += LZMA_PROPERTIES_LENGTH;
|
||||
|
||||
// Write header
|
||||
@@ -1677,7 +1683,7 @@ static void write_sector_subchannel(const aaruformat_context *ctx)
|
||||
if(subchannel_block.compression != None) fwrite(lzma_properties, LZMA_PROPERTIES_LENGTH, 1, ctx->imageStream);
|
||||
|
||||
// Write data
|
||||
const size_t written_bytes = fwrite(buffer, subchannel_block.cmpLength, 1, ctx->imageStream);
|
||||
const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->imageStream);
|
||||
if(written_bytes == 1)
|
||||
{
|
||||
TRACE("Successfully wrote sector subchannel block (%" PRIu64 " bytes)", subchannel_block.cmpLength);
|
||||
@@ -1899,6 +1905,7 @@ void write_dvd_long_sector_blocks(aaruformat_context *ctx)
|
||||
else
|
||||
id_block.cmpCrc64 = aaruf_crc64_data(buffer, id_block.cmpLength);
|
||||
|
||||
size_t length_to_write = id_block.cmpLength;
|
||||
if(id_block.compression == Lzma) id_block.cmpLength += LZMA_PROPERTIES_LENGTH;
|
||||
|
||||
// Write header
|
||||
@@ -1907,7 +1914,7 @@ void write_dvd_long_sector_blocks(aaruformat_context *ctx)
|
||||
if(id_block.compression == Lzma) fwrite(lzma_properties, LZMA_PROPERTIES_LENGTH, 1, ctx->imageStream);
|
||||
|
||||
// Write data
|
||||
const size_t written_bytes = fwrite(buffer, id_block.cmpLength, 1, ctx->imageStream);
|
||||
const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->imageStream);
|
||||
if(written_bytes == 1)
|
||||
{
|
||||
TRACE("Successfully wrote DVD sector ID block (%" PRIu64 " bytes)", id_block.cmpLength);
|
||||
@@ -1981,6 +1988,7 @@ void write_dvd_long_sector_blocks(aaruformat_context *ctx)
|
||||
else
|
||||
ied_block.cmpCrc64 = aaruf_crc64_data(buffer, ied_block.cmpLength);
|
||||
|
||||
length_to_write = ied_block.cmpLength;
|
||||
if(ied_block.compression == Lzma) ied_block.cmpLength += LZMA_PROPERTIES_LENGTH;
|
||||
|
||||
// Write header
|
||||
@@ -1989,7 +1997,7 @@ void write_dvd_long_sector_blocks(aaruformat_context *ctx)
|
||||
if(ied_block.compression == Lzma) fwrite(lzma_properties, LZMA_PROPERTIES_LENGTH, 1, ctx->imageStream);
|
||||
|
||||
// Write data
|
||||
const size_t written_bytes = fwrite(buffer, ied_block.cmpLength, 1, ctx->imageStream);
|
||||
const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->imageStream);
|
||||
if(written_bytes == 1)
|
||||
{
|
||||
TRACE("Successfully wrote DVD sector IED block (%" PRIu64 " bytes)", ied_block.cmpLength);
|
||||
@@ -2063,6 +2071,7 @@ void write_dvd_long_sector_blocks(aaruformat_context *ctx)
|
||||
else
|
||||
cpr_mai_block.cmpCrc64 = aaruf_crc64_data(buffer, cpr_mai_block.cmpLength);
|
||||
|
||||
length_to_write = cpr_mai_block.cmpLength;
|
||||
if(cpr_mai_block.compression == Lzma) cpr_mai_block.cmpLength += LZMA_PROPERTIES_LENGTH;
|
||||
|
||||
// Write header
|
||||
@@ -2071,7 +2080,7 @@ void write_dvd_long_sector_blocks(aaruformat_context *ctx)
|
||||
if(cpr_mai_block.compression == Lzma) fwrite(lzma_properties, LZMA_PROPERTIES_LENGTH, 1, ctx->imageStream);
|
||||
|
||||
// Write data
|
||||
const size_t written_bytes = fwrite(buffer, cpr_mai_block.cmpLength, 1, ctx->imageStream);
|
||||
const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->imageStream);
|
||||
if(written_bytes == 1)
|
||||
{
|
||||
TRACE("Successfully wrote DVD sector CPR/MAI block (%" PRIu64 " bytes)", cpr_mai_block.cmpLength);
|
||||
@@ -2145,6 +2154,7 @@ void write_dvd_long_sector_blocks(aaruformat_context *ctx)
|
||||
else
|
||||
edc_block.cmpCrc64 = aaruf_crc64_data(buffer, edc_block.cmpLength);
|
||||
|
||||
length_to_write = edc_block.cmpLength;
|
||||
if(edc_block.compression == Lzma) edc_block.cmpLength += LZMA_PROPERTIES_LENGTH;
|
||||
|
||||
// Write header
|
||||
@@ -2153,7 +2163,7 @@ void write_dvd_long_sector_blocks(aaruformat_context *ctx)
|
||||
if(edc_block.compression == Lzma) fwrite(lzma_properties, LZMA_PROPERTIES_LENGTH, 1, ctx->imageStream);
|
||||
|
||||
// Write data
|
||||
const size_t written_bytes = fwrite(buffer, edc_block.cmpLength, 1, ctx->imageStream);
|
||||
const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->imageStream);
|
||||
if(written_bytes == 1)
|
||||
{
|
||||
TRACE("Successfully wrote DVD sector EDC block (%" PRIu64 " bytes)", edc_block.cmpLength);
|
||||
@@ -2333,6 +2343,7 @@ static void write_dvd_title_key_decrypted_block(const aaruformat_context *ctx)
|
||||
else
|
||||
decrypted_title_key_block.cmpCrc64 = aaruf_crc64_data(buffer, decrypted_title_key_block.cmpLength);
|
||||
|
||||
const size_t length_to_write = decrypted_title_key_block.cmpLength;
|
||||
if(decrypted_title_key_block.compression == Lzma) decrypted_title_key_block.cmpLength += LZMA_PROPERTIES_LENGTH;
|
||||
|
||||
// Write header
|
||||
@@ -2342,7 +2353,7 @@ static void write_dvd_title_key_decrypted_block(const aaruformat_context *ctx)
|
||||
fwrite(lzma_properties, LZMA_PROPERTIES_LENGTH, 1, ctx->imageStream);
|
||||
|
||||
// Write data
|
||||
const size_t written_bytes = fwrite(buffer, decrypted_title_key_block.cmpLength, 1, ctx->imageStream);
|
||||
const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->imageStream);
|
||||
if(written_bytes == 1)
|
||||
{
|
||||
TRACE("Successfully wrote DVD decrypted title key block (%" PRIu64 " bytes)",
|
||||
@@ -2502,6 +2513,7 @@ static void write_media_tags(const aaruformat_context *ctx)
|
||||
else
|
||||
tag_block.cmpCrc64 = aaruf_crc64_data(buffer, tag_block.cmpLength);
|
||||
|
||||
const size_t length_to_write = tag_block.cmpLength;
|
||||
if(tag_block.compression == Lzma) tag_block.cmpLength += LZMA_PROPERTIES_LENGTH;
|
||||
|
||||
// Write header
|
||||
@@ -2510,7 +2522,7 @@ static void write_media_tags(const aaruformat_context *ctx)
|
||||
if(tag_block.compression == Lzma)
|
||||
fwrite(lzma_properties, LZMA_PROPERTIES_LENGTH, 1, ctx->imageStream); // Write data
|
||||
|
||||
const size_t written_bytes = fwrite(buffer, tag_block.cmpLength, 1, ctx->imageStream);
|
||||
const size_t written_bytes = fwrite(buffer, length_to_write, 1, ctx->imageStream);
|
||||
if(written_bytes == 1)
|
||||
{
|
||||
TRACE("Successfully wrote media tag block type %d (%" PRIu64 " bytes)", tag_block.type,
|
||||
@@ -3304,6 +3316,8 @@ static void write_metadata_block(aaruformat_context *ctx)
|
||||
block_position = aligned_position;
|
||||
}
|
||||
|
||||
memcpy(buffer, &ctx->metadata_block_header, sizeof(MetadataBlockHeader));
|
||||
|
||||
TRACE("Writing metadata block at position %ld", block_position);
|
||||
|
||||
if(fwrite(buffer, ctx->metadata_block_header.blockSize, 1, ctx->imageStream) == 1)
|
||||
|
||||
@@ -217,26 +217,26 @@ int32_t process_ddt_v1(aaruformat_context *ctx, IndexEntry *entry, bool *found_u
|
||||
break;
|
||||
// TODO: Check CRC
|
||||
case None:
|
||||
#ifdef __linux__
|
||||
TRACE("Memory mapping deduplication table at position %" PRIu64, entry->offset + sizeof(ddt_header));
|
||||
ctx->mapped_memory_ddt_size = sizeof(uint64_t) * ddt_header.entries;
|
||||
ctx->user_data_ddt = mmap(NULL, ctx->mapped_memory_ddt_size, PROT_READ, MAP_SHARED,
|
||||
fileno(ctx->imageStream), entry->offset + sizeof(ddt_header));
|
||||
|
||||
if(ctx->user_data_ddt == MAP_FAILED)
|
||||
ctx->user_data_ddt = (uint64_t *)malloc(ddt_header.length);
|
||||
if(ctx->user_data_ddt == NULL)
|
||||
{
|
||||
*found_user_data_ddt = false;
|
||||
FATAL("Could not read map deduplication table.");
|
||||
TRACE("Cannot allocate memory for DDT, continuing...");
|
||||
break;
|
||||
}
|
||||
|
||||
ctx->in_memory_ddt = false;
|
||||
read_bytes = fread(ctx->user_data_ddt, 1, ddt_header.entries * sizeof(uint64_t), ctx->imageStream);
|
||||
|
||||
if(read_bytes != ddt_header.entries * sizeof(uint64_t))
|
||||
{
|
||||
free(ctx->user_data_ddt);
|
||||
TRACE("Could not read deduplication table, continuing...");
|
||||
break;
|
||||
}
|
||||
|
||||
ctx->in_memory_ddt = true;
|
||||
*found_user_data_ddt = true;
|
||||
|
||||
break;
|
||||
#else // TODO: Implement
|
||||
TRACE("Uncompressed DDT not yet implemented...");
|
||||
*found_user_data_ddt = false;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
TRACE("Found unknown compression type %d, continuing...", ddt_header.compression);
|
||||
*found_user_data_ddt = false;
|
||||
|
||||
@@ -297,7 +297,7 @@ AARU_EXPORT int32_t AARU_CALL aaruf_read_sector(void *context, const uint64_t se
|
||||
return AARUF_ERROR_NOT_AARUFORMAT;
|
||||
}
|
||||
|
||||
if(negative && sector_address > ctx->user_data_ddt_header.negative - 1)
|
||||
if(negative && sector_address > ctx->user_data_ddt_header.negative)
|
||||
{
|
||||
FATAL("Sector address out of bounds");
|
||||
|
||||
@@ -868,7 +868,7 @@ AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_long(void *context, const uint64
|
||||
return AARUF_ERROR_NOT_AARUFORMAT;
|
||||
}
|
||||
|
||||
if(negative && sector_address > ctx->user_data_ddt_header.negative - 1)
|
||||
if(negative && sector_address > ctx->user_data_ddt_header.negative)
|
||||
{
|
||||
FATAL("Sector address out of bounds");
|
||||
|
||||
@@ -1509,7 +1509,7 @@ AARU_EXPORT int32_t AARU_CALL aaruf_read_sector_tag(const void *context, const u
|
||||
return AARUF_ERROR_NOT_AARUFORMAT;
|
||||
}
|
||||
|
||||
if(negative && sector_address > ctx->user_data_ddt_header.negative - 1)
|
||||
if(negative && sector_address > ctx->user_data_ddt_header.negative)
|
||||
{
|
||||
FATAL("Sector address out of bounds");
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ AARU_EXPORT int32_t AARU_CALL aaruf_write_sector(void *context, uint64_t sector_
|
||||
return AARUF_READ_ONLY;
|
||||
}
|
||||
|
||||
if(negative && sector_address > ctx->user_data_ddt_header.negative - 1)
|
||||
if(negative && sector_address > ctx->user_data_ddt_header.negative)
|
||||
{
|
||||
FATAL("Sector address out of bounds");
|
||||
|
||||
@@ -569,7 +569,7 @@ AARU_EXPORT int32_t AARU_CALL aaruf_write_sector_long(void *context, uint64_t se
|
||||
return AARUF_READ_ONLY;
|
||||
}
|
||||
|
||||
if(negative && sector_address > ctx->user_data_ddt_header.negative - 1)
|
||||
if(negative && sector_address > ctx->user_data_ddt_header.negative)
|
||||
{
|
||||
FATAL("Sector address out of bounds");
|
||||
|
||||
@@ -2101,7 +2101,7 @@ AARU_EXPORT int32_t AARU_CALL aaruf_write_sector_tag(void *context, const uint64
|
||||
return AARUF_READ_ONLY;
|
||||
}
|
||||
|
||||
if(negative && sector_address > ctx->user_data_ddt_header.negative - 1)
|
||||
if(negative && sector_address > ctx->user_data_ddt_header.negative)
|
||||
{
|
||||
FATAL("Sector address out of bounds");
|
||||
|
||||
|
||||
@@ -576,7 +576,18 @@ enum MediaType : u32
|
||||
ODC1200RE = 783,
|
||||
ODC1500R = 784,
|
||||
ODC3300R = 785,
|
||||
ODC5500R = 786
|
||||
ODC5500R = 786,
|
||||
|
||||
ECMA_322_1k = 800,
|
||||
ECMA_322_512 = 801,
|
||||
ISO_14517 = 802,
|
||||
ISO_14517_512 = 803,
|
||||
ISO_15041_512 = 804,
|
||||
HSM650 = 805,
|
||||
|
||||
MetaFloppy_Mod_I = 820,
|
||||
HF12 = 823,
|
||||
HF24 = 824,
|
||||
};
|
||||
|
||||
enum CompressionType : u16
|
||||
|
||||
@@ -739,7 +739,6 @@ TEST_F(CreateImageFixture, create_audio_image)
|
||||
EXPECT_EQ(close_result, AARUF_STATUS_OK) << "Failed to close image";
|
||||
}
|
||||
|
||||
|
||||
TEST_F(CreateImageFixture, create_image_negative_sectors)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -855,3 +854,329 @@ TEST_F(CreateImageFixture, create_image_negative_sectors)
|
||||
close_result = aaruf_close(context);
|
||||
EXPECT_EQ(close_result, AARUF_STATUS_OK) << "Failed to close image";
|
||||
}
|
||||
|
||||
TEST_F(CreateImageFixture, create_subchannel_uncompressed_image)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
char filename[PATH_MAX];
|
||||
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/audio.bin", path);
|
||||
|
||||
// Open audio file
|
||||
FILE *f = fopen(filename, "rb");
|
||||
ASSERT_NE(f, nullptr) << "Failed to open audio.bin data file";
|
||||
|
||||
// Get file size
|
||||
fseek(f, 0, SEEK_END);
|
||||
const long audio_size = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
// Read entire audio file into buffer
|
||||
uint8_t *buffer = static_cast<uint8_t *>(malloc(audio_size));
|
||||
ASSERT_NE(buffer, nullptr) << "Failed to allocate memory for audio data";
|
||||
|
||||
size_t bytes_read = fread(buffer, 1, audio_size, f);
|
||||
fclose(f);
|
||||
ASSERT_EQ(bytes_read, static_cast<size_t>(audio_size)) << "Failed to read complete audio data";
|
||||
|
||||
// Calculate total size: three times the audio.bin size
|
||||
const size_t total_size = audio_size * 3;
|
||||
|
||||
// Create image with default options (NULL for options means defaults)
|
||||
void *context = aaruf_create("test_audio.aif", 11, 2352, total_size / 2352, 0, 0, "compress=false",
|
||||
reinterpret_cast<const uint8_t *>("gtest"), 10, 0, 0, false);
|
||||
|
||||
// Verify that the file was successfully opened
|
||||
ASSERT_NE(context, nullptr) << "Failed to create test_audio.aif";
|
||||
|
||||
// Set up a single audio track spanning the entire media
|
||||
TrackEntry track;
|
||||
memset(&track, 0, sizeof(TrackEntry));
|
||||
track.sequence = 1; // Track 1
|
||||
track.type = Audio; // Audio track type (0)
|
||||
track.start = 0; // Start at sector 0
|
||||
track.end = (audio_size * 3 / 2352) - 1; // End at last sector (inclusive)
|
||||
track.pregap = 0; // No pregap
|
||||
track.session = 1; // Session 1
|
||||
memset(track.isrc, 0, 13); // No ISRC
|
||||
track.flags = 0; // No special flags
|
||||
|
||||
int32_t track_result = aaruf_set_tracks(context, &track, 1);
|
||||
ASSERT_EQ(track_result, AARUF_STATUS_OK) << "Failed to set tracks";
|
||||
|
||||
crc64_ctx *ctx = aaruf_crc64_init();
|
||||
uint64_t generated_crc = 0;
|
||||
|
||||
// Write audio data three times using write_sector_long
|
||||
size_t total_sectors = total_size / 2352;
|
||||
|
||||
for(size_t sector = 0; sector < total_sectors; ++sector)
|
||||
{
|
||||
// Calculate offset in the original audio buffer (wrap around after each iteration)
|
||||
const size_t buffer_offset = (sector * 2352) % audio_size;
|
||||
const int32_t write_result =
|
||||
aaruf_write_sector_long(context, sector, false, buffer + buffer_offset, SectorStatusDumped, 2352);
|
||||
ASSERT_EQ(write_result, AARUF_STATUS_OK) << "Failed to write sector " << sector;
|
||||
|
||||
aaruf_crc64_update(ctx, buffer + buffer_offset, 2352);
|
||||
}
|
||||
|
||||
aaruf_crc64_final(ctx, &generated_crc);
|
||||
aaruf_crc64_free(ctx);
|
||||
|
||||
// Write subchannel data for each sector and calculate CRC64
|
||||
crc64_ctx *subchannel_ctx = aaruf_crc64_init();
|
||||
uint64_t generated_subchannel_crc = 0;
|
||||
uint8_t subchannel_data[96];
|
||||
|
||||
for(size_t sector = 0; sector < total_sectors; ++sector)
|
||||
{
|
||||
// Generate subchannel pattern based on sector number (96 bytes per sector)
|
||||
for(size_t i = 0; i < 96; ++i) { subchannel_data[i] = static_cast<uint8_t>((sector * 96 + i) & 0xFF); }
|
||||
|
||||
const int32_t subchannel_result =
|
||||
aaruf_write_sector_tag(context, sector, false, subchannel_data, 96, CdSectorSubchannelAaru);
|
||||
ASSERT_EQ(subchannel_result, AARUF_STATUS_OK) << "Failed to write subchannel for sector " << sector;
|
||||
|
||||
// Update CRC64 with the subchannel data we just wrote
|
||||
aaruf_crc64_update(subchannel_ctx, subchannel_data, 96);
|
||||
}
|
||||
|
||||
aaruf_crc64_final(subchannel_ctx, &generated_subchannel_crc);
|
||||
aaruf_crc64_free(subchannel_ctx);
|
||||
|
||||
// Close the image
|
||||
int32_t close_result = aaruf_close(context);
|
||||
ASSERT_EQ(close_result, AARUF_STATUS_OK) << "Failed to close image";
|
||||
free(buffer);
|
||||
|
||||
// Reopen the image
|
||||
context = aaruf_open("test_audio.aif", false, NULL);
|
||||
ASSERT_NE(context, nullptr) << "Failed to open test_audio.aif";
|
||||
|
||||
// Get image info to verify it's a valid image
|
||||
ImageInfo image_info;
|
||||
const int32_t result = aaruf_get_image_info(context, &image_info);
|
||||
|
||||
ASSERT_EQ(result, AARUF_STATUS_OK) << "Failed to get image info";
|
||||
|
||||
// Basic sanity checks on the image info
|
||||
ASSERT_EQ(image_info.HasPartitions, true) << "Image should not have partitions";
|
||||
ASSERT_EQ(image_info.HasSessions, true) << "Image should not have sessions";
|
||||
ASSERT_EQ(image_info.Sectors, total_sectors) << "Unexpected number of sectors";
|
||||
ASSERT_EQ(image_info.SectorSize, 2352) << "Unexpected sector size";
|
||||
ASSERT_STREQ(image_info.Version, "2.0") << "Unexpected image version";
|
||||
ASSERT_STREQ(image_info.Application, "gtest") << "Unexpected application name";
|
||||
ASSERT_STREQ(image_info.ApplicationVersion, "0.0") << "Unexpected application version";
|
||||
ASSERT_EQ(image_info.MediaType, 11) << "Unexpected media type";
|
||||
ASSERT_EQ(image_info.MetadataMediaType, 0) << "Unexpected metadata media type";
|
||||
|
||||
ctx = aaruf_crc64_init();
|
||||
uint64_t crc = 0;
|
||||
|
||||
for(size_t i = 0; i < total_sectors; i++)
|
||||
{
|
||||
uint8_t sector_buffer[2352];
|
||||
uint32_t length = sizeof(sector_buffer);
|
||||
uint8_t sector_status = 0;
|
||||
|
||||
const int32_t read_result = aaruf_read_sector_long(context, i, false, sector_buffer, &length, §or_status);
|
||||
EXPECT_EQ(read_result, AARUF_STATUS_OK) << "Failed to read sector " << i;
|
||||
EXPECT_EQ(length, 2352U) << "Unexpected length for sector " << i;
|
||||
aaruf_crc64_update(ctx, sector_buffer, 2352);
|
||||
}
|
||||
|
||||
aaruf_crc64_final(ctx, &crc);
|
||||
aaruf_crc64_free(ctx);
|
||||
|
||||
ASSERT_EQ(crc, generated_crc) << "Unexpected CRC64 for image data";
|
||||
|
||||
// Read back and verify subchannel data
|
||||
crc64_ctx *subchannel_read_ctx = aaruf_crc64_init();
|
||||
uint64_t read_subchannel_crc = 0;
|
||||
|
||||
for(size_t i = 0; i < total_sectors; i++)
|
||||
{
|
||||
uint8_t subchannel_buffer[96];
|
||||
uint32_t subchannel_length = sizeof(subchannel_buffer);
|
||||
|
||||
const int32_t subchannel_read_result =
|
||||
aaruf_read_sector_tag(context, i, false, subchannel_buffer, &subchannel_length, CdSectorSubchannelAaru);
|
||||
EXPECT_EQ(subchannel_read_result, AARUF_STATUS_OK) << "Failed to read subchannel for sector " << i;
|
||||
EXPECT_EQ(subchannel_length, 96U) << "Unexpected subchannel length for sector " << i;
|
||||
aaruf_crc64_update(subchannel_read_ctx, subchannel_buffer, 96);
|
||||
}
|
||||
|
||||
aaruf_crc64_final(subchannel_read_ctx, &read_subchannel_crc);
|
||||
aaruf_crc64_free(subchannel_read_ctx);
|
||||
|
||||
ASSERT_EQ(read_subchannel_crc, generated_subchannel_crc) << "Unexpected CRC64 for subchannel data";
|
||||
|
||||
// Close the image
|
||||
close_result = aaruf_close(context);
|
||||
EXPECT_EQ(close_result, AARUF_STATUS_OK) << "Failed to close image";
|
||||
}
|
||||
|
||||
TEST_F(CreateImageFixture, create_subchannel_compressed_image)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
char filename[PATH_MAX];
|
||||
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/audio.bin", path);
|
||||
|
||||
// Open audio file
|
||||
FILE *f = fopen(filename, "rb");
|
||||
ASSERT_NE(f, nullptr) << "Failed to open audio.bin data file";
|
||||
|
||||
// Get file size
|
||||
fseek(f, 0, SEEK_END);
|
||||
const long audio_size = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
// Read entire audio file into buffer
|
||||
uint8_t *buffer = static_cast<uint8_t *>(malloc(audio_size));
|
||||
ASSERT_NE(buffer, nullptr) << "Failed to allocate memory for audio data";
|
||||
|
||||
size_t bytes_read = fread(buffer, 1, audio_size, f);
|
||||
fclose(f);
|
||||
ASSERT_EQ(bytes_read, static_cast<size_t>(audio_size)) << "Failed to read complete audio data";
|
||||
|
||||
// Calculate total size: three times the audio.bin size
|
||||
const size_t total_size = audio_size * 3;
|
||||
|
||||
// Create image with default options (NULL for options means defaults)
|
||||
void *context = aaruf_create("test_audio.aif", 11, 2352, total_size / 2352, 0, 0, "compress=true",
|
||||
reinterpret_cast<const uint8_t *>("gtest"), 10, 0, 0, false);
|
||||
|
||||
// Verify that the file was successfully opened
|
||||
ASSERT_NE(context, nullptr) << "Failed to create test_audio.aif";
|
||||
|
||||
// Set up a single audio track spanning the entire media
|
||||
TrackEntry track;
|
||||
memset(&track, 0, sizeof(TrackEntry));
|
||||
track.sequence = 1; // Track 1
|
||||
track.type = Audio; // Audio track type (0)
|
||||
track.start = 0; // Start at sector 0
|
||||
track.end = (audio_size * 3 / 2352) - 1; // End at last sector (inclusive)
|
||||
track.pregap = 0; // No pregap
|
||||
track.session = 1; // Session 1
|
||||
memset(track.isrc, 0, 13); // No ISRC
|
||||
track.flags = 0; // No special flags
|
||||
|
||||
int32_t track_result = aaruf_set_tracks(context, &track, 1);
|
||||
ASSERT_EQ(track_result, AARUF_STATUS_OK) << "Failed to set tracks";
|
||||
|
||||
crc64_ctx *ctx = aaruf_crc64_init();
|
||||
uint64_t generated_crc = 0;
|
||||
|
||||
// Write audio data three times using write_sector_long
|
||||
size_t total_sectors = total_size / 2352;
|
||||
|
||||
for(size_t sector = 0; sector < total_sectors; ++sector)
|
||||
{
|
||||
// Calculate offset in the original audio buffer (wrap around after each iteration)
|
||||
const size_t buffer_offset = (sector * 2352) % audio_size;
|
||||
const int32_t write_result =
|
||||
aaruf_write_sector_long(context, sector, false, buffer + buffer_offset, SectorStatusDumped, 2352);
|
||||
ASSERT_EQ(write_result, AARUF_STATUS_OK) << "Failed to write sector " << sector;
|
||||
|
||||
aaruf_crc64_update(ctx, buffer + buffer_offset, 2352);
|
||||
}
|
||||
|
||||
aaruf_crc64_final(ctx, &generated_crc);
|
||||
aaruf_crc64_free(ctx);
|
||||
|
||||
// Write subchannel data for each sector and calculate CRC64
|
||||
crc64_ctx *subchannel_ctx = aaruf_crc64_init();
|
||||
uint64_t generated_subchannel_crc = 0;
|
||||
uint8_t subchannel_data[96];
|
||||
|
||||
for(size_t sector = 0; sector < total_sectors; ++sector)
|
||||
{
|
||||
// Generate subchannel pattern based on sector number (96 bytes per sector)
|
||||
for(size_t i = 0; i < 96; ++i) { subchannel_data[i] = static_cast<uint8_t>((sector * 96 + i) & 0xFF); }
|
||||
|
||||
const int32_t subchannel_result =
|
||||
aaruf_write_sector_tag(context, sector, false, subchannel_data, 96, CdSectorSubchannelAaru);
|
||||
ASSERT_EQ(subchannel_result, AARUF_STATUS_OK) << "Failed to write subchannel for sector " << sector;
|
||||
|
||||
// Update CRC64 with the subchannel data we just wrote
|
||||
aaruf_crc64_update(subchannel_ctx, subchannel_data, 96);
|
||||
}
|
||||
|
||||
aaruf_crc64_final(subchannel_ctx, &generated_subchannel_crc);
|
||||
aaruf_crc64_free(subchannel_ctx);
|
||||
|
||||
// Close the image
|
||||
int32_t close_result = aaruf_close(context);
|
||||
ASSERT_EQ(close_result, AARUF_STATUS_OK) << "Failed to close image";
|
||||
free(buffer);
|
||||
|
||||
// Reopen the image
|
||||
context = aaruf_open("test_audio.aif", false, NULL);
|
||||
ASSERT_NE(context, nullptr) << "Failed to open test_audio.aif";
|
||||
|
||||
// Get image info to verify it's a valid image
|
||||
ImageInfo image_info;
|
||||
const int32_t result = aaruf_get_image_info(context, &image_info);
|
||||
|
||||
ASSERT_EQ(result, AARUF_STATUS_OK) << "Failed to get image info";
|
||||
|
||||
// Basic sanity checks on the image info
|
||||
ASSERT_EQ(image_info.HasPartitions, true) << "Image should not have partitions";
|
||||
ASSERT_EQ(image_info.HasSessions, true) << "Image should not have sessions";
|
||||
ASSERT_EQ(image_info.Sectors, total_sectors) << "Unexpected number of sectors";
|
||||
ASSERT_EQ(image_info.SectorSize, 2352) << "Unexpected sector size";
|
||||
ASSERT_STREQ(image_info.Version, "2.0") << "Unexpected image version";
|
||||
ASSERT_STREQ(image_info.Application, "gtest") << "Unexpected application name";
|
||||
ASSERT_STREQ(image_info.ApplicationVersion, "0.0") << "Unexpected application version";
|
||||
ASSERT_EQ(image_info.MediaType, 11) << "Unexpected media type";
|
||||
ASSERT_EQ(image_info.MetadataMediaType, 0) << "Unexpected metadata media type";
|
||||
|
||||
ctx = aaruf_crc64_init();
|
||||
uint64_t crc = 0;
|
||||
|
||||
for(size_t i = 0; i < total_sectors; i++)
|
||||
{
|
||||
uint8_t sector_buffer[2352];
|
||||
uint32_t length = sizeof(sector_buffer);
|
||||
uint8_t sector_status = 0;
|
||||
|
||||
const int32_t read_result = aaruf_read_sector_long(context, i, false, sector_buffer, &length, §or_status);
|
||||
EXPECT_EQ(read_result, AARUF_STATUS_OK) << "Failed to read sector " << i;
|
||||
EXPECT_EQ(length, 2352U) << "Unexpected length for sector " << i;
|
||||
aaruf_crc64_update(ctx, sector_buffer, 2352);
|
||||
}
|
||||
|
||||
aaruf_crc64_final(ctx, &crc);
|
||||
aaruf_crc64_free(ctx);
|
||||
|
||||
ASSERT_EQ(crc, generated_crc) << "Unexpected CRC64 for image data";
|
||||
|
||||
// Read back and verify subchannel data
|
||||
crc64_ctx *subchannel_read_ctx = aaruf_crc64_init();
|
||||
uint64_t read_subchannel_crc = 0;
|
||||
|
||||
for(size_t i = 0; i < total_sectors; i++)
|
||||
{
|
||||
uint8_t subchannel_buffer[96];
|
||||
uint32_t subchannel_length = sizeof(subchannel_buffer);
|
||||
|
||||
const int32_t subchannel_read_result =
|
||||
aaruf_read_sector_tag(context, i, false, subchannel_buffer, &subchannel_length, CdSectorSubchannelAaru);
|
||||
EXPECT_EQ(subchannel_read_result, AARUF_STATUS_OK) << "Failed to read subchannel for sector " << i;
|
||||
EXPECT_EQ(subchannel_length, 96U) << "Unexpected subchannel length for sector " << i;
|
||||
aaruf_crc64_update(subchannel_read_ctx, subchannel_buffer, 96);
|
||||
}
|
||||
|
||||
aaruf_crc64_final(subchannel_read_ctx, &read_subchannel_crc);
|
||||
aaruf_crc64_free(subchannel_read_ctx);
|
||||
|
||||
ASSERT_EQ(read_subchannel_crc, generated_subchannel_crc) << "Unexpected CRC64 for subchannel data";
|
||||
|
||||
// Close the image
|
||||
close_result = aaruf_close(context);
|
||||
EXPECT_EQ(close_result, AARUF_STATUS_OK) << "Failed to close image";
|
||||
}
|
||||
@@ -24,14 +24,14 @@
|
||||
char *byte_array_to_hex_string(const unsigned char *array, int array_size)
|
||||
{
|
||||
char *hex_string = NULL;
|
||||
int j = 0;
|
||||
int j = 0;
|
||||
|
||||
hex_string = malloc(array_size * 2 + 1);
|
||||
|
||||
if(hex_string == NULL) return NULL;
|
||||
|
||||
j = 0;
|
||||
for (int i = 0; i < array_size; i++)
|
||||
for(int i = 0; i < array_size; i++)
|
||||
{
|
||||
hex_string[j] = (array[i] >> 4) + '0';
|
||||
if(hex_string[j] > '9') hex_string[j] += 0x7;
|
||||
@@ -1109,6 +1109,84 @@ const char *media_type_to_string(MediaType type)
|
||||
case VideoNowXp:
|
||||
return "VideoNow XP";
|
||||
|
||||
// Iomega, types 750 to 759
|
||||
case Bernoulli10:
|
||||
return "Bernoulli Box (10Mb)";
|
||||
case Bernoulli20:
|
||||
return "Bernoulli Box (20Mb)";
|
||||
case BernoulliBox2_20:
|
||||
return "Bernoulli Box II (20Mb)";
|
||||
|
||||
// Kodak, types 760 to 769
|
||||
case KodakVerbatim3:
|
||||
return "Kodak/Verbatim (3Mb)";
|
||||
case KodakVerbatim6:
|
||||
return "Kodak/Verbatim (6Mb)";
|
||||
case KodakVerbatim12:
|
||||
return "Kodak/Verbatim (12Mb)";
|
||||
|
||||
// Sony and Panasonic Blu-ray derived, types 770 to 799
|
||||
case ProfessionalDisc:
|
||||
return "Professional Disc for video";
|
||||
case ProfessionalDiscDual:
|
||||
return "Professional Disc for video";
|
||||
case ProfessionalDiscTriple:
|
||||
return "Professional Disc for video";
|
||||
case ProfessionalDiscQuad:
|
||||
return "Professional Disc for video";
|
||||
case PDD:
|
||||
return "Professional Disc for DATA";
|
||||
case PDD_WORM:
|
||||
return "Professional Disc for DATA";
|
||||
case ArchivalDisc:
|
||||
return "Archival Disc";
|
||||
case ArchivalDisc2:
|
||||
return "Archival Disc";
|
||||
case ArchivalDisc3:
|
||||
return "Archival Disc";
|
||||
case ODC300R:
|
||||
return "Optical Disc archive";
|
||||
case ODC300RE:
|
||||
return "Optical Disc archive";
|
||||
case ODC600R:
|
||||
return "Optical Disc archive";
|
||||
case ODC600RE:
|
||||
return "Optical Disc archive";
|
||||
case ODC1200RE:
|
||||
return "Optical Disc archive";
|
||||
case ODC1500R:
|
||||
return "Optical Disc archive";
|
||||
case ODC3300R:
|
||||
return "Optical Disc archive";
|
||||
case ODC5500R:
|
||||
return "Optical Disc archive";
|
||||
|
||||
// Magneto-optical, types 800 to 819
|
||||
case ECMA_322_1k:
|
||||
return "5,25\", M.O., 4383356 sectors, 1024 bytes/sector, ECMA-322, ISO 22092, 9.1Gb/cart";
|
||||
case ECMA_322_512:
|
||||
return "5,25\", M.O., ??????? sectors, 512 bytes/sector, ECMA-322, ISO 22092, 9.1Gb/cart";
|
||||
case ISO_14517:
|
||||
return "5,25\", M.O., 1273011 sectors, 1024 bytes/sector, ISO 14517, 2.6Gb/cart";
|
||||
case ISO_14517_512:
|
||||
return "5,25\", M.O., 2244958 sectors, 512 bytes/sector, ISO 14517, 2.3Gb/cart";
|
||||
case ISO_15041_512:
|
||||
return "3,5\", M.O., 1041500 sectors, 512 bytes/sector, ISO 15041, 540Mb/cart";
|
||||
case HSM650:
|
||||
return "Sony HyperStorage";
|
||||
|
||||
// More floppy formats, types 820 to deprecated
|
||||
case MetaFloppy_Mod_I:
|
||||
return "5.25\", SS, DD, 35 tracks, 16 spt, 256 bytes/sector, MFM, 48 tpi, ???rpm";
|
||||
case HF12:
|
||||
return "HyperFlex (12Mb)";
|
||||
case HF24:
|
||||
return "HyperFlex (24Mb)";
|
||||
|
||||
case AtariLynxCard:
|
||||
return "Atari Lynx card";
|
||||
case AtariJaguarCartridge:
|
||||
return "Atari Jaguar cartridge";
|
||||
default:
|
||||
return "Unknown Media Type";
|
||||
}
|
||||
|
||||
395
tool/info.c
395
tool/info.c
@@ -48,7 +48,10 @@ static const char *format_filetime(uint64_t filetime)
|
||||
snprintf(buf, sizeof(buf), "%04d-%02d-%02d %02d:%02d:%02d", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute,
|
||||
st.wSecond);
|
||||
}
|
||||
else { snprintf(buf, sizeof(buf), "%llu", filetime); }
|
||||
else
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%llu", filetime);
|
||||
}
|
||||
return buf;
|
||||
#else
|
||||
time_t t;
|
||||
@@ -132,285 +135,272 @@ int info(const char *path)
|
||||
int32_t sequence = 0;
|
||||
int32_t lastSequence = 0;
|
||||
|
||||
printf("Metadata block:\n");
|
||||
if(aaruf_get_media_sequence(ctx, &sequence, &lastSequence) == AARUF_STATUS_OK && sequence > 0)
|
||||
{
|
||||
printf("Metadata block:\n");
|
||||
printf("\tMedia is no. %d in a set of %d media\n", sequence, lastSequence);
|
||||
|
||||
int32_t length = 0;
|
||||
if(aaruf_get_creator(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
}
|
||||
int32_t length = 0;
|
||||
if(aaruf_get_creator(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
if(aaruf_get_creator(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
{
|
||||
if(aaruf_get_creator(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length,
|
||||
&u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tCreator: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tCreator: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
length = 0;
|
||||
if(aaruf_get_comments(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
length = 0;
|
||||
if(aaruf_get_comments(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
if(aaruf_get_comments(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
{
|
||||
if(aaruf_get_comments(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length,
|
||||
&u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tComments: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tComments: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
length = 0;
|
||||
if(aaruf_get_media_title(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
length = 0;
|
||||
if(aaruf_get_media_title(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
if(aaruf_get_media_title(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
{
|
||||
if(aaruf_get_media_title(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length,
|
||||
&u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tMedia title: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tMedia title: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
length = 0;
|
||||
if(aaruf_get_media_manufacturer(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
length = 0;
|
||||
if(aaruf_get_media_manufacturer(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
if(aaruf_get_media_manufacturer(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
{
|
||||
if(aaruf_get_media_manufacturer(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length,
|
||||
&u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tMedia manufacturer: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tMedia manufacturer: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
length = 0;
|
||||
if(aaruf_get_media_model(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
length = 0;
|
||||
if(aaruf_get_media_model(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
if(aaruf_get_media_model(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
{
|
||||
if(aaruf_get_media_model(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length,
|
||||
&u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tMedia model: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tMedia model: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
length = 0;
|
||||
if(aaruf_get_media_serial_number(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
length = 0;
|
||||
if(aaruf_get_media_serial_number(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
if(aaruf_get_media_serial_number(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
{
|
||||
if(aaruf_get_media_serial_number(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length,
|
||||
&u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tMedia serial number: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tMedia serial number: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
length = 0;
|
||||
if(aaruf_get_media_barcode(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
length = 0;
|
||||
if(aaruf_get_media_barcode(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
if(aaruf_get_media_barcode(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
{
|
||||
if(aaruf_get_media_barcode(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length,
|
||||
&u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tMedia barcode: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tMedia barcode: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
length = 0;
|
||||
if(aaruf_get_media_part_number(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
length = 0;
|
||||
if(aaruf_get_media_part_number(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
if(aaruf_get_media_part_number(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
{
|
||||
if(aaruf_get_media_part_number(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length,
|
||||
&u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tMedia part number: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tMedia part number: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
length = 0;
|
||||
if(aaruf_get_drive_manufacturer(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
length = 0;
|
||||
if(aaruf_get_drive_manufacturer(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
if(aaruf_get_drive_manufacturer(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
{
|
||||
if(aaruf_get_drive_manufacturer(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length,
|
||||
&u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tDrive manufacturer: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tDrive manufacturer: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
length = 0;
|
||||
if(aaruf_get_drive_model(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
length = 0;
|
||||
if(aaruf_get_drive_model(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
if(aaruf_get_drive_model(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
{
|
||||
if(aaruf_get_drive_model(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length,
|
||||
&u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tDrive model: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tDrive model: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
length = 0;
|
||||
if(aaruf_get_drive_serial_number(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
length = 0;
|
||||
if(aaruf_get_drive_serial_number(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
if(aaruf_get_drive_serial_number(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
{
|
||||
if(aaruf_get_drive_serial_number(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length,
|
||||
&u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tDrive serial number: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tDrive serial number: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
length = 0;
|
||||
if(aaruf_get_drive_firmware_revision(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
length = 0;
|
||||
if(aaruf_get_drive_firmware_revision(ctx, NULL, &length) == AARUF_ERROR_BUFFER_TOO_SMALL && length > 0)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
{
|
||||
uint8_t *utf16Buffer = malloc(length);
|
||||
if(utf16Buffer != NULL)
|
||||
if(aaruf_get_drive_firmware_revision(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
{
|
||||
if(aaruf_get_drive_firmware_revision(ctx, utf16Buffer, &length) == AARUF_STATUS_OK)
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
strBuffer = malloc(length + 1);
|
||||
if(strBuffer != NULL)
|
||||
{
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length,
|
||||
&u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tDrive firmware revision: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
memset(strBuffer, 0, length + 1);
|
||||
u_error_code = U_ZERO_ERROR;
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, length, (const char *)utf16Buffer, length, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tDrive firmware revision: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
free(utf16Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -576,16 +566,7 @@ int info(const char *path)
|
||||
printf("\tImage contains %llu sectors\n", ctx->image_info.Sectors);
|
||||
printf("\tBiggest sector is %d bytes\n", ctx->image_info.SectorSize);
|
||||
printf("\tImage version: %s\n", ctx->image_info.Version);
|
||||
|
||||
if(ctx->image_info.Application != NULL)
|
||||
{
|
||||
strBuffer = malloc(65);
|
||||
memset(strBuffer, 0, 65);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, 64, (const char *)ctx->image_info.Application, 64, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tApplication: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
}
|
||||
|
||||
if(ctx->image_info.Application != NULL) printf("\tApplication: %s\n", ctx->image_info.Application);
|
||||
if(ctx->image_info.ApplicationVersion != NULL)
|
||||
printf("\tApplication version: %s\n", ctx->image_info.ApplicationVersion);
|
||||
printf("\tCreation time: %s\n", format_filetime(ctx->image_info.CreationTime));
|
||||
@@ -620,9 +601,7 @@ int info(const char *path)
|
||||
{
|
||||
printf("Media tags:\n");
|
||||
HASH_ITER(hh, ctx->mediaTags, mediaTag, tmpMediaTag)
|
||||
{
|
||||
printf("\tType %d is %d bytes long.\n", mediaTag->type, mediaTag->length);
|
||||
}
|
||||
{ printf("\tType %d is %d bytes long.\n", mediaTag->type, mediaTag->length); }
|
||||
}
|
||||
|
||||
aaruf_close(ctx);
|
||||
|
||||
Reference in New Issue
Block a user