Rename library.

This commit is contained in:
2020-03-01 19:51:13 +00:00
parent a976bdaa5d
commit 1b2a7cf35e
14 changed files with 110 additions and 108 deletions

View File

@@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
project(libdicformat C) project(libaaruformat C)
set(CMAKE_C_STANDARD 90) set(CMAKE_C_STANDARD 90)
add_compile_definitions(__STDC_FORMAT_MACROS=1) add_compile_definitions(__STDC_FORMAT_MACROS=1)
add_library(dicformat SHARED include/aaruformat/consts.h include/aaruformat/enums.h include/dic.h include/dicformat.h add_library(aaruformat SHARED include/aaruformat/consts.h include/aaruformat/enums.h include/dic.h include/aaruformat.h
include/aaruformat/decls.h include/aaruformat/structs.h src/identify.c src/open.c include/aaruformat/context.h include/aaruformat/decls.h include/aaruformat/structs.h src/identify.c src/open.c include/aaruformat/context.h
src/close.c include/aaruformat/errors.h src/read.c src/crc64.c src/cst.c src/ecc_cd.c src/helpers.c) src/close.c include/aaruformat/errors.h src/read.c src/crc64.c src/cst.c src/ecc_cd.c src/helpers.c)

View File

@@ -5,7 +5,7 @@
// Filename : consts.h // Filename : consts.h
// Author(s) : Natalia Portillo <claunia@claunia.com> // Author(s) : Natalia Portillo <claunia@claunia.com>
// //
// Component : libdicformat. // Component : libaaruformat.
// //
// --[ Description ] ---------------------------------------------------------- // --[ Description ] ----------------------------------------------------------
// //

View File

@@ -5,11 +5,11 @@
// Filename : context.h // Filename : context.h
// Author(s) : Natalia Portillo <claunia@claunia.com> // Author(s) : Natalia Portillo <claunia@claunia.com>
// //
// Component : libdicformat. // Component : libaaruformat.
// //
// --[ Description ] ---------------------------------------------------------- // --[ Description ] ----------------------------------------------------------
// //
// Describes context to be passed between libdicformat functions. // Describes context to be passed between libaaruformat functions.
// //
// --[ License ] -------------------------------------------------------------- // --[ License ] --------------------------------------------------------------
// //
@@ -38,7 +38,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
typedef struct dicformatContext typedef struct aaruformatContext
{ {
uint64_t magic; uint64_t magic;
uint8_t libraryMajorVersion; uint8_t libraryMajorVersion;
@@ -73,7 +73,7 @@ typedef struct dicformatContext
uint8_t numberOfDataTracks; uint8_t numberOfDataTracks;
TrackEntry* dataTracks; TrackEntry* dataTracks;
bool* readableSectorTags; bool* readableSectorTags;
} dicformatContext; } aaruformatContext;
typedef struct dataLinkedList typedef struct dataLinkedList
{ {

View File

@@ -5,7 +5,7 @@
// Filename : decls.h // Filename : decls.h
// Author(s) : Natalia Portillo <claunia@claunia.com> // Author(s) : Natalia Portillo <claunia@claunia.com>
// //
// Component : libdicformat. // Component : libaaruformat.
// //
// --[ Description ] ---------------------------------------------------------- // --[ Description ] ----------------------------------------------------------
// //

View File

@@ -5,7 +5,7 @@
// Filename : dic.h // Filename : dic.h
// Author(s) : Natalia Portillo <claunia@claunia.com> // Author(s) : Natalia Portillo <claunia@claunia.com>
// //
// Component : libdicformat. // Component : libaaruformat.
// //
// --[ Description ] ---------------------------------------------------------- // --[ Description ] ----------------------------------------------------------
// //

View File

@@ -5,7 +5,7 @@
// Filename : aaruformat.h // Filename : aaruformat.h
// Author(s) : Natalia Portillo <claunia@claunia.com> // Author(s) : Natalia Portillo <claunia@claunia.com>
// //
// Component : libdicformat. // Component : libaaruformat.
// //
// --[ Description ] ---------------------------------------------------------- // --[ Description ] ----------------------------------------------------------
// //
@@ -36,11 +36,11 @@
#define LIBDICFORMAT_MAJOR_VERSION 1 #define LIBDICFORMAT_MAJOR_VERSION 1
#define LIBDICFORMAT_MINOR_VERSION 0 #define LIBDICFORMAT_MINOR_VERSION 0
#include "dicformat/consts.h" #include "aaruformat/consts.h"
#include "dicformat/context.h" #include "aaruformat/context.h"
#include "dicformat/decls.h" #include "aaruformat/decls.h"
#include "dicformat/enums.h" #include "aaruformat/enums.h"
#include "dicformat/errors.h" #include "aaruformat/errors.h"
#include "dicformat/structs.h" #include "aaruformat/structs.h"
#endif // LIBDICFORMAT_DICFORMAT_H #endif // LIBDICFORMAT_DICFORMAT_H

View File

@@ -5,7 +5,7 @@
// Filename : close.c // Filename : close.c
// Author(s) : Natalia Portillo <claunia@claunia.com> // Author(s) : Natalia Portillo <claunia@claunia.com>
// //
// Component : libdicformat. // Component : libaaruformat.
// //
// --[ Description ] ---------------------------------------------------------- // --[ Description ] ----------------------------------------------------------
// //
@@ -30,7 +30,7 @@
// Copyright © 2011-2020 Natalia Portillo // Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
#include <dicformat.h> #include <aaruformat.h>
#include <errno.h> #include <errno.h>
#include <malloc.h> #include <malloc.h>
#include <stdio.h> #include <stdio.h>
@@ -46,9 +46,9 @@ int close(void* context)
return -1; return -1;
} }
dicformatContext* ctx = context; aaruformatContext* ctx = context;
// Not a libdicformat context // Not a libaaruformat context
if(ctx->magic != DIC_MAGIC) if(ctx->magic != DIC_MAGIC)
{ {
errno = EINVAL; errno = EINVAL;

View File

@@ -30,7 +30,7 @@
// Copyright © 2011-2020 Natalia Portillo // Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
#include <dicformat.h> #include <aaruformat.h>
#include <malloc.h> #include <malloc.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>

View File

@@ -30,7 +30,7 @@
// Copyright © 2011-2020 Natalia Portillo // Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
#include <dicformat.h> #include <aaruformat.h>
#include <malloc.h> #include <malloc.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>

View File

@@ -31,7 +31,7 @@
// ECC algorithm from ECM(c) 2002-2011 Neill Corlett // ECC algorithm from ECM(c) 2002-2011 Neill Corlett
// ****************************************************************************/ // ****************************************************************************/
#include <dicformat.h> #include <aaruformat.h>
#include <malloc.h> #include <malloc.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>

View File

@@ -30,8 +30,8 @@
// Copyright © 2011-2020 Natalia Portillo // Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
#include <aaruformat.h>
#include <dic.h> #include <dic.h>
#include <dicformat.h>
// Converts between image data type and dic media tag type // Converts between image data type and dic media tag type
int32_t GetMediaTagTypeForDataType(int32_t type) int32_t GetMediaTagTypeForDataType(int32_t type)

View File

@@ -30,7 +30,7 @@
// Copyright © 2011-2020 Natalia Portillo // Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
#include <dicformat.h> #include <aaruformat.h>
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>

View File

@@ -5,7 +5,7 @@
// Filename : open.c // Filename : open.c
// Author(s) : Natalia Portillo <claunia@claunia.com> // Author(s) : Natalia Portillo <claunia@claunia.com>
// //
// Component : libdicformat. // Component : libaaruformat.
// //
// --[ Description ] ---------------------------------------------------------- // --[ Description ] ----------------------------------------------------------
// //
@@ -30,7 +30,7 @@
// Copyright © 2011-2020 Natalia Portillo // Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
#include <dicformat.h> #include <aaruformat.h>
#include <errno.h> #include <errno.h>
#include <inttypes.h> #include <inttypes.h>
#include <malloc.h> #include <malloc.h>
@@ -40,21 +40,21 @@
void* open(const char* filepath) void* open(const char* filepath)
{ {
dicformatContext* ctx; aaruformatContext* ctx;
int errorNo; int errorNo;
size_t readBytes; size_t readBytes;
long pos; long pos;
IndexHeader idxHeader; IndexHeader idxHeader;
IndexEntry* idxEntries; IndexEntry* idxEntries;
uint8_t* data; uint8_t* data;
uint32_t* cdDdt; uint32_t* cdDdt;
uint64_t crc64; uint64_t crc64;
uint8_t temp8u; uint8_t temp8u;
int i; int i;
uint16_t e; uint16_t e;
ctx = (dicformatContext*)malloc(sizeof(dicformatContext)); ctx = (aaruformatContext*)malloc(sizeof(aaruformatContext));
memset(ctx, 0, sizeof(dicformatContext)); memset(ctx, 0, sizeof(aaruformatContext));
if(ctx == NULL) return NULL; if(ctx == NULL) return NULL;
@@ -97,7 +97,7 @@ void* open(const char* filepath)
} }
fprintf(stderr, fprintf(stderr,
"libdicformat: Opening image version %d.%d", "libaaruformat: Opening image version %d.%d",
ctx->header.imageMajorVersion, ctx->header.imageMajorVersion,
ctx->header.imageMinorVersion); ctx->header.imageMinorVersion);
@@ -161,7 +161,7 @@ void* open(const char* filepath)
} }
fprintf( fprintf(
stderr, "libdicformat: Index at %" PRIu64 " contains %d entries", ctx->header.indexOffset, idxHeader.entries); stderr, "libaaruformat: Index at %" PRIu64 " contains %d entries", ctx->header.indexOffset, idxHeader.entries);
idxEntries = (IndexEntry*)malloc(sizeof(IndexEntry) * idxHeader.entries); idxEntries = (IndexEntry*)malloc(sizeof(IndexEntry) * idxHeader.entries);
@@ -189,7 +189,7 @@ void* open(const char* filepath)
for(i = 0; i < idxHeader.entries; i++) for(i = 0; i < idxHeader.entries; i++)
{ {
fprintf(stderr, fprintf(stderr,
"libdicformat: Block type %4.4s with data type %4.4s is indexed to be at %" PRIu64 "", "libaaruformat: Block type %4.4s with data type %4.4s is indexed to be at %" PRIu64 "",
(char*)&idxEntries[i].blockType, (char*)&idxEntries[i].blockType,
(char*)&idxEntries[i].dataType, (char*)&idxEntries[i].dataType,
idxEntries[i].offset); idxEntries[i].offset);
@@ -204,7 +204,7 @@ void* open(const char* filepath)
if(pos < 0 || ftell(ctx->imageStream) != idxEntries[i].offset) if(pos < 0 || ftell(ctx->imageStream) != idxEntries[i].offset)
{ {
fprintf(stderr, fprintf(stderr,
"libdicformat: Could not seek to %" PRIu64 " as indicated by index entry %d, continuing...", "libaaruformat: Could not seek to %" PRIu64 " as indicated by index entry %d, continuing...",
idxEntries[i].offset, idxEntries[i].offset,
i); i);
@@ -224,7 +224,7 @@ void* open(const char* filepath)
if(readBytes != sizeof(BlockHeader)) if(readBytes != sizeof(BlockHeader))
{ {
fprintf(stderr, "libdicformat: Could not read block header at %" PRIu64 "", idxEntries[i].offset); fprintf(stderr, "libaaruformat: Could not read block header at %" PRIu64 "", idxEntries[i].offset);
break; break;
} }
@@ -243,7 +243,7 @@ void* open(const char* filepath)
if(blockHeader.identifier != idxEntries[i].blockType) if(blockHeader.identifier != idxEntries[i].blockType)
{ {
fprintf(stderr, fprintf(stderr,
"libdicformat: Incorrect identifier for data block at position %" PRIu64 "", "libaaruformat: Incorrect identifier for data block at position %" PRIu64 "",
idxEntries[i].offset); idxEntries[i].offset);
break; break;
} }
@@ -251,7 +251,7 @@ void* open(const char* filepath)
if(blockHeader.type != idxEntries[i].dataType) if(blockHeader.type != idxEntries[i].dataType)
{ {
fprintf(stderr, fprintf(stderr,
"libdicformat: Expected block with data type %4.4s at position %" PRIu64 "libaaruformat: Expected block with data type %4.4s at position %" PRIu64
" but found data type %4.4s", " but found data type %4.4s",
(char*)&idxEntries[i].blockType, (char*)&idxEntries[i].blockType,
idxEntries[i].offset, idxEntries[i].offset,
@@ -260,7 +260,7 @@ void* open(const char* filepath)
} }
fprintf(stderr, fprintf(stderr,
"libdicformat: Found data block with type %4.4s at position %" PRIu64 "", "libaaruformat: Found data block with type %4.4s at position %" PRIu64 "",
(char*)&idxEntries[i].blockType, (char*)&idxEntries[i].blockType,
idxEntries[i].offset); idxEntries[i].offset);
@@ -285,7 +285,7 @@ void* open(const char* filepath)
else else
{ {
fprintf(stderr, fprintf(stderr,
"libdicformat: Found unknown compression type %d, continuing...", "libaaruformat: Found unknown compression type %d, continuing...",
blockHeader.compression); blockHeader.compression);
break; break;
} }
@@ -294,7 +294,7 @@ void* open(const char* filepath)
if(crc64 != blockHeader.crc64) if(crc64 != blockHeader.crc64)
{ {
fprintf(stderr, fprintf(stderr,
"libdicformat: Incorrect CRC found: 0x%" PRIx64 " found, expected 0x%" PRIx64 "libaaruformat: Incorrect CRC found: 0x%" PRIx64 " found, expected 0x%" PRIx64
", continuing...", ", continuing...",
crc64, crc64,
blockHeader.crc64); blockHeader.crc64);
@@ -349,7 +349,7 @@ void* open(const char* filepath)
if(mediaTag->type == blockHeader.type) if(mediaTag->type == blockHeader.type)
{ {
fprintf(stderr, fprintf(stderr,
"libdicformat: Media tag type %d duplicated, removing previous entry...", "libaaruformat: Media tag type %d duplicated, removing previous entry...",
blockHeader.type); blockHeader.type);
free(mediaTag->data); free(mediaTag->data);
mediaTag->data = data; mediaTag->data = data;
@@ -368,7 +368,7 @@ void* open(const char* filepath)
if(mediaTag == NULL) if(mediaTag == NULL)
{ {
fprintf(stderr, "libdicformat: Cannot allocate memory for media tag list entry."); fprintf(stderr, "libaaruformat: Cannot allocate memory for media tag list entry.");
break; break;
} }
memset(mediaTag, 0, sizeof(dataLinkedList)); memset(mediaTag, 0, sizeof(dataLinkedList));
@@ -395,7 +395,7 @@ void* open(const char* filepath)
if(readBytes != sizeof(DdtHeader)) if(readBytes != sizeof(DdtHeader))
{ {
fprintf(stderr, "libdicformat: Could not read block header at %" PRIu64 "", idxEntries[i].offset); fprintf(stderr, "libaaruformat: Could not read block header at %" PRIu64 "", idxEntries[i].offset);
break; break;
} }
@@ -424,7 +424,7 @@ void* open(const char* filepath)
if(ctx->userDataDdt == MAP_FAILED) if(ctx->userDataDdt == MAP_FAILED)
{ {
foundUserDataDdt = false; foundUserDataDdt = false;
fprintf(stderr, "libdicformat: Could not read map deduplication table."); fprintf(stderr, "libaaruformat: Could not read map deduplication table.");
break; break;
} }
@@ -432,7 +432,7 @@ void* open(const char* filepath)
break; break;
default: default:
fprintf(stderr, fprintf(stderr,
"libdicformat: Found unknown compression type %d, continuing...", "libaaruformat: Found unknown compression type %d, continuing...",
blockHeader.compression); blockHeader.compression);
foundUserDataDdt = false; foundUserDataDdt = false;
break; break;
@@ -448,7 +448,7 @@ void* open(const char* filepath)
if(mediaTag == NULL) if(mediaTag == NULL)
{ {
fprintf(stderr, "libdicformat: Cannot allocate memory for deduplication table."); fprintf(stderr, "libaaruformat: Cannot allocate memory for deduplication table.");
break; break;
} }
@@ -457,7 +457,7 @@ void* open(const char* filepath)
if(readBytes != ddtHeader.entries * sizeof(uint32_t)) if(readBytes != ddtHeader.entries * sizeof(uint32_t))
{ {
free(data); free(data);
fprintf(stderr, "libdicformat: Could not read deduplication table, continuing..."); fprintf(stderr, "libaaruformat: Could not read deduplication table, continuing...");
break; break;
} }
@@ -471,7 +471,7 @@ void* open(const char* filepath)
break; break;
default: default:
fprintf(stderr, fprintf(stderr,
"libdicformat: Found unknown compression type %d, continuing...", "libaaruformat: Found unknown compression type %d, continuing...",
blockHeader.compression); blockHeader.compression);
break; break;
} }
@@ -484,14 +484,14 @@ void* open(const char* filepath)
if(readBytes != sizeof(GeometryBlockHeader)) if(readBytes != sizeof(GeometryBlockHeader))
{ {
memset(&ctx->geometryBlock, 0, sizeof(GeometryBlockHeader)); memset(&ctx->geometryBlock, 0, sizeof(GeometryBlockHeader));
fprintf(stderr, "libdicformat: Could not read geometry block, continuing..."); fprintf(stderr, "libaaruformat: Could not read geometry block, continuing...");
break; break;
} }
if(ctx->geometryBlock.identifier == GeometryBlock) if(ctx->geometryBlock.identifier == GeometryBlock)
{ {
fprintf(stderr, fprintf(stderr,
"libdicformat: Geometry set to %d cylinders %d heads %d sectors per track", "libaaruformat: Geometry set to %d cylinders %d heads %d sectors per track",
ctx->geometryBlock.cylinders, ctx->geometryBlock.cylinders,
ctx->geometryBlock.heads, ctx->geometryBlock.heads,
ctx->geometryBlock.sectorsPerTrack); ctx->geometryBlock.sectorsPerTrack);
@@ -511,7 +511,7 @@ void* open(const char* filepath)
if(readBytes != sizeof(MetadataBlockHeader)) if(readBytes != sizeof(MetadataBlockHeader))
{ {
memset(&ctx->metadataBlockHeader, 0, sizeof(MetadataBlockHeader)); memset(&ctx->metadataBlockHeader, 0, sizeof(MetadataBlockHeader));
fprintf(stderr, "libdicformat: Could not read metadata block header, continuing..."); fprintf(stderr, "libaaruformat: Could not read metadata block header, continuing...");
break; break;
} }
@@ -519,7 +519,7 @@ void* open(const char* filepath)
{ {
memset(&ctx->metadataBlockHeader, 0, sizeof(MetadataBlockHeader)); memset(&ctx->metadataBlockHeader, 0, sizeof(MetadataBlockHeader));
fprintf(stderr, fprintf(stderr,
"libdicformat: Incorrect identifier for data block at position %" PRIu64 "", "libaaruformat: Incorrect identifier for data block at position %" PRIu64 "",
idxEntries[i].offset); idxEntries[i].offset);
break; break;
} }
@@ -531,7 +531,7 @@ void* open(const char* filepath)
if(ctx->metadataBlock == NULL) if(ctx->metadataBlock == NULL)
{ {
memset(&ctx->metadataBlockHeader, 0, sizeof(MetadataBlockHeader)); memset(&ctx->metadataBlockHeader, 0, sizeof(MetadataBlockHeader));
fprintf(stderr, "libdicformat: Could not allocate memory for metadata block, continuing..."); fprintf(stderr, "libaaruformat: Could not allocate memory for metadata block, continuing...");
break; break;
} }
@@ -541,7 +541,7 @@ void* open(const char* filepath)
{ {
memset(&ctx->metadataBlockHeader, 0, sizeof(MetadataBlockHeader)); memset(&ctx->metadataBlockHeader, 0, sizeof(MetadataBlockHeader));
free(ctx->metadataBlock); free(ctx->metadataBlock);
fprintf(stderr, "libdicformat: Could not read metadata block, continuing..."); fprintf(stderr, "libaaruformat: Could not read metadata block, continuing...");
} }
if(ctx->metadataBlockHeader.mediaSequence > 0 && ctx->metadataBlockHeader.lastMediaSequence > 0) if(ctx->metadataBlockHeader.mediaSequence > 0 && ctx->metadataBlockHeader.lastMediaSequence > 0)
@@ -549,7 +549,7 @@ void* open(const char* filepath)
ctx->imageInfo.MediaSequence = ctx->metadataBlockHeader.mediaSequence; ctx->imageInfo.MediaSequence = ctx->metadataBlockHeader.mediaSequence;
ctx->imageInfo.LastMediaSequence = ctx->metadataBlockHeader.lastMediaSequence; ctx->imageInfo.LastMediaSequence = ctx->metadataBlockHeader.lastMediaSequence;
fprintf(stderr, fprintf(stderr,
"libdicformat: Setting media sequence as %d of %d", "libaaruformat: Setting media sequence as %d of %d",
ctx->imageInfo.MediaSequence, ctx->imageInfo.MediaSequence,
ctx->imageInfo.LastMediaSequence); ctx->imageInfo.LastMediaSequence);
} }
@@ -727,7 +727,7 @@ void* open(const char* filepath)
if(readBytes != sizeof(TracksHeader)) if(readBytes != sizeof(TracksHeader))
{ {
memset(&ctx->tracksHeader, 0, sizeof(TracksHeader)); memset(&ctx->tracksHeader, 0, sizeof(TracksHeader));
fprintf(stderr, "libdicformat: Could not read tracks header, continuing..."); fprintf(stderr, "libaaruformat: Could not read tracks header, continuing...");
break; break;
} }
@@ -735,7 +735,7 @@ void* open(const char* filepath)
{ {
memset(&ctx->tracksHeader, 0, sizeof(TracksHeader)); memset(&ctx->tracksHeader, 0, sizeof(TracksHeader));
fprintf(stderr, fprintf(stderr,
"libdicformat: Incorrect identifier for data block at position %" PRIu64 "", "libaaruformat: Incorrect identifier for data block at position %" PRIu64 "",
idxEntries[i].offset); idxEntries[i].offset);
} }
@@ -746,7 +746,7 @@ void* open(const char* filepath)
if(ctx->trackEntries == NULL) if(ctx->trackEntries == NULL)
{ {
memset(&ctx->tracksHeader, 0, sizeof(TracksHeader)); memset(&ctx->tracksHeader, 0, sizeof(TracksHeader));
fprintf(stderr, "libdicformat: Could not allocate memory for metadata block, continuing..."); fprintf(stderr, "libaaruformat: Could not allocate memory for metadata block, continuing...");
break; break;
} }
@@ -756,7 +756,7 @@ void* open(const char* filepath)
{ {
memset(&ctx->tracksHeader, 0, sizeof(TracksHeader)); memset(&ctx->tracksHeader, 0, sizeof(TracksHeader));
free(ctx->trackEntries); free(ctx->trackEntries);
fprintf(stderr, "libdicformat: Could not read metadata block, continuing..."); fprintf(stderr, "libaaruformat: Could not read metadata block, continuing...");
} }
crc64 = crc64 =
@@ -764,7 +764,7 @@ void* open(const char* filepath)
if(crc64 != ctx->tracksHeader.crc64) if(crc64 != ctx->tracksHeader.crc64)
{ {
fprintf(stderr, fprintf(stderr,
"libdicformat: Incorrect CRC found: 0x%" PRIx64 " found, expected 0x%" PRIx64 "libaaruformat: Incorrect CRC found: 0x%" PRIx64 " found, expected 0x%" PRIx64
", continuing...", ", continuing...",
crc64, crc64,
ctx->tracksHeader.crc64); ctx->tracksHeader.crc64);
@@ -772,7 +772,7 @@ void* open(const char* filepath)
} }
fprintf(stderr, fprintf(stderr,
"libdicformat: Found %d tracks at position %" PRIu64 ".", "libaaruformat: Found %d tracks at position %" PRIu64 ".",
ctx->tracksHeader.entries, ctx->tracksHeader.entries,
idxEntries[i].offset); idxEntries[i].offset);
@@ -813,7 +813,7 @@ void* open(const char* filepath)
if(readBytes != sizeof(CicmMetadataBlock)) if(readBytes != sizeof(CicmMetadataBlock))
{ {
memset(&ctx->cicmBlockHeader, 0, sizeof(CicmMetadataBlock)); memset(&ctx->cicmBlockHeader, 0, sizeof(CicmMetadataBlock));
fprintf(stderr, "libdicformat: Could not read CICM XML metadata header, continuing..."); fprintf(stderr, "libaaruformat: Could not read CICM XML metadata header, continuing...");
break; break;
} }
@@ -821,7 +821,7 @@ void* open(const char* filepath)
{ {
memset(&ctx->cicmBlockHeader, 0, sizeof(CicmMetadataBlock)); memset(&ctx->cicmBlockHeader, 0, sizeof(CicmMetadataBlock));
fprintf(stderr, fprintf(stderr,
"libdicformat: Incorrect identifier for data block at position %" PRIu64 "", "libaaruformat: Incorrect identifier for data block at position %" PRIu64 "",
idxEntries[i].offset); idxEntries[i].offset);
} }
@@ -833,7 +833,7 @@ void* open(const char* filepath)
{ {
memset(&ctx->cicmBlockHeader, 0, sizeof(CicmMetadataBlock)); memset(&ctx->cicmBlockHeader, 0, sizeof(CicmMetadataBlock));
fprintf(stderr, fprintf(stderr,
"libdicformat: Could not allocate memory for CICM XML metadata block, continuing..."); "libaaruformat: Could not allocate memory for CICM XML metadata block, continuing...");
break; break;
} }
@@ -843,10 +843,10 @@ void* open(const char* filepath)
{ {
memset(&ctx->cicmBlockHeader, 0, sizeof(CicmMetadataBlock)); memset(&ctx->cicmBlockHeader, 0, sizeof(CicmMetadataBlock));
free(ctx->cicmBlock); free(ctx->cicmBlock);
fprintf(stderr, "libdicformat: Could not read CICM XML metadata block, continuing..."); fprintf(stderr, "libaaruformat: Could not read CICM XML metadata block, continuing...");
} }
fprintf(stderr, "libdicformat: Found CICM XML metadata block %" PRIu64 ".", idxEntries[i].offset); fprintf(stderr, "libaaruformat: Found CICM XML metadata block %" PRIu64 ".", idxEntries[i].offset);
break; break;
// Dump hardware block // Dump hardware block
case DumpHardwareBlock: case DumpHardwareBlock:
@@ -855,7 +855,7 @@ void* open(const char* filepath)
if(readBytes != sizeof(DumpHardwareHeader)) if(readBytes != sizeof(DumpHardwareHeader))
{ {
memset(&ctx->dumpHardwareHeader, 0, sizeof(DumpHardwareHeader)); memset(&ctx->dumpHardwareHeader, 0, sizeof(DumpHardwareHeader));
fprintf(stderr, "libdicformat: Could not read dump hardware block header, continuing..."); fprintf(stderr, "libaaruformat: Could not read dump hardware block header, continuing...");
break; break;
} }
@@ -863,7 +863,7 @@ void* open(const char* filepath)
{ {
memset(&ctx->dumpHardwareHeader, 0, sizeof(DumpHardwareHeader)); memset(&ctx->dumpHardwareHeader, 0, sizeof(DumpHardwareHeader));
fprintf(stderr, fprintf(stderr,
"libdicformat: Incorrect identifier for data block at position %" PRIu64 "", "libaaruformat: Incorrect identifier for data block at position %" PRIu64 "",
idxEntries[i].offset); idxEntries[i].offset);
} }
@@ -879,7 +879,7 @@ void* open(const char* filepath)
{ {
free(data); free(data);
fprintf(stderr, fprintf(stderr,
"libdicformat: Incorrect CRC found: 0x%" PRIx64 " found, expected 0x%" PRIx64 "libaaruformat: Incorrect CRC found: 0x%" PRIx64 " found, expected 0x%" PRIx64
", continuing...", ", continuing...",
crc64, crc64,
ctx->dumpHardwareHeader.crc64); ctx->dumpHardwareHeader.crc64);
@@ -897,7 +897,7 @@ void* open(const char* filepath)
if(ctx->dumpHardwareEntriesWithData == NULL) if(ctx->dumpHardwareEntriesWithData == NULL)
{ {
memset(&ctx->dumpHardwareHeader, 0, sizeof(DumpHardwareHeader)); memset(&ctx->dumpHardwareHeader, 0, sizeof(DumpHardwareHeader));
fprintf(stderr, "libdicformat: Could not allocate memory for dump hardware block, continuing..."); fprintf(stderr, "libaaruformat: Could not allocate memory for dump hardware block, continuing...");
break; break;
} }
@@ -913,7 +913,7 @@ void* open(const char* filepath)
if(readBytes != sizeof(DumpHardwareEntry)) if(readBytes != sizeof(DumpHardwareEntry))
{ {
ctx->dumpHardwareHeader.entries = e + (uint16_t)1; ctx->dumpHardwareHeader.entries = e + (uint16_t)1;
fprintf(stderr, "libdicformat: Could not read dump hardware block entry, continuing..."); fprintf(stderr, "libaaruformat: Could not read dump hardware block entry, continuing...");
break; break;
} }
@@ -934,7 +934,7 @@ void* open(const char* filepath)
free(ctx->dumpHardwareEntriesWithData[e].manufacturer); free(ctx->dumpHardwareEntriesWithData[e].manufacturer);
ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength = 0; ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength = 0;
fprintf(stderr, fprintf(stderr,
"libdicformat: Could not read dump hardware block entry manufacturer, " "libaaruformat: Could not read dump hardware block entry manufacturer, "
"continuing..."); "continuing...");
} }
} }
@@ -957,7 +957,7 @@ void* open(const char* filepath)
free(ctx->dumpHardwareEntriesWithData[e].model); free(ctx->dumpHardwareEntriesWithData[e].model);
ctx->dumpHardwareEntriesWithData[e].entry.modelLength = 0; ctx->dumpHardwareEntriesWithData[e].entry.modelLength = 0;
fprintf(stderr, fprintf(stderr,
"libdicformat: Could not read dump hardware block entry model, continuing..."); "libaaruformat: Could not read dump hardware block entry model, continuing...");
} }
} }
} }
@@ -980,7 +980,7 @@ void* open(const char* filepath)
ctx->dumpHardwareEntriesWithData[e].entry.revisionLength = 0; ctx->dumpHardwareEntriesWithData[e].entry.revisionLength = 0;
fprintf( fprintf(
stderr, stderr,
"libdicformat: Could not read dump hardware block entry revision, continuing..."); "libaaruformat: Could not read dump hardware block entry revision, continuing...");
} }
} }
} }
@@ -1003,7 +1003,7 @@ void* open(const char* filepath)
ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength = 0; ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength = 0;
fprintf( fprintf(
stderr, stderr,
"libdicformat: Could not read dump hardware block entry firmware, continuing..."); "libaaruformat: Could not read dump hardware block entry firmware, continuing...");
} }
} }
} }
@@ -1024,8 +1024,9 @@ void* open(const char* filepath)
{ {
free(ctx->dumpHardwareEntriesWithData[e].serial); free(ctx->dumpHardwareEntriesWithData[e].serial);
ctx->dumpHardwareEntriesWithData[e].entry.serialLength = 0; ctx->dumpHardwareEntriesWithData[e].entry.serialLength = 0;
fprintf(stderr, fprintf(
"libdicformat: Could not read dump hardware block entry serial, continuing..."); stderr,
"libaaruformat: Could not read dump hardware block entry serial, continuing...");
} }
} }
} }
@@ -1047,7 +1048,7 @@ void* open(const char* filepath)
free(ctx->dumpHardwareEntriesWithData[e].softwareName); free(ctx->dumpHardwareEntriesWithData[e].softwareName);
ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength = 0; ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength = 0;
fprintf(stderr, fprintf(stderr,
"libdicformat: Could not read dump hardware block entry software name, " "libaaruformat: Could not read dump hardware block entry software name, "
"continuing..."); "continuing...");
} }
} }
@@ -1070,7 +1071,7 @@ void* open(const char* filepath)
free(ctx->dumpHardwareEntriesWithData[e].softwareVersion); free(ctx->dumpHardwareEntriesWithData[e].softwareVersion);
ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength = 0; ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength = 0;
fprintf(stderr, fprintf(stderr,
"libdicformat: Could not read dump hardware block entry software version, " "libaaruformat: Could not read dump hardware block entry software version, "
"continuing..."); "continuing...");
} }
} }
@@ -1093,7 +1094,7 @@ void* open(const char* filepath)
free(ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem); free(ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem);
ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength = 0; ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength = 0;
fprintf(stderr, fprintf(stderr,
"libdicformat: Could not read dump hardware block entry manufacturer, " "libaaruformat: Could not read dump hardware block entry manufacturer, "
"continuing..."); "continuing...");
} }
} }
@@ -1106,7 +1107,7 @@ void* open(const char* filepath)
{ {
fprintf( fprintf(
stderr, stderr,
"libdicformat: Could not allocate memory for dump hardware block extents, continuing..."); "libaaruformat: Could not allocate memory for dump hardware block extents, continuing...");
continue; continue;
} }
@@ -1118,7 +1119,7 @@ void* open(const char* filepath)
if(readBytes != sizeof(DumpExtent) * ctx->dumpHardwareEntriesWithData->entry.extents) if(readBytes != sizeof(DumpExtent) * ctx->dumpHardwareEntriesWithData->entry.extents)
{ {
free(ctx->dumpHardwareEntriesWithData[e].extents); free(ctx->dumpHardwareEntriesWithData[e].extents);
fprintf(stderr, "libdicformat: Could not read dump hardware block extents, continuing..."); fprintf(stderr, "libaaruformat: Could not read dump hardware block extents, continuing...");
continue; continue;
} }
@@ -1128,7 +1129,8 @@ void* open(const char* filepath)
break; break;
default: default:
fprintf(stderr, fprintf(stderr,
"libdicformat: Unhandled block type %4.4s with data type %4.4s is indexed to be at %" PRIu64 "", "libaaruformat: Unhandled block type %4.4s with data type %4.4s is indexed to be at %" PRIu64
"",
(char*)&idxEntries[i].blockType, (char*)&idxEntries[i].blockType,
(char*)&idxEntries[i].dataType, (char*)&idxEntries[i].dataType,
idxEntries[i].offset); idxEntries[i].offset);
@@ -1140,7 +1142,7 @@ void* open(const char* filepath)
if(!foundUserDataDdt) if(!foundUserDataDdt)
{ {
fprintf(stderr, "libdicformat: Could not find user data deduplication table, aborting..."); fprintf(stderr, "libaaruformat: Could not find user data deduplication table, aborting...");
close(ctx); close(ctx);
return NULL; return NULL;
} }

View File

@@ -5,7 +5,7 @@
// Filename : open.c // Filename : open.c
// Author(s) : Natalia Portillo <claunia@claunia.com> // Author(s) : Natalia Portillo <claunia@claunia.com>
// //
// Component : libdicformat. // Component : libaaruformat.
// //
// --[ Description ] ---------------------------------------------------------- // --[ Description ] ----------------------------------------------------------
// //
@@ -30,20 +30,20 @@
// Copyright © 2011-2020 Natalia Portillo // Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
#include <dicformat.h> #include <aaruformat.h>
#include <malloc.h> #include <malloc.h>
#include <string.h> #include <string.h>
int32_t read_media_tag(void* context, uint8_t* data, int32_t tag, uint32_t* length) int32_t read_media_tag(void* context, uint8_t* data, int32_t tag, uint32_t* length)
{ {
dicformatContext* ctx; aaruformatContext* ctx;
dataLinkedList* item; dataLinkedList* item;
if(context == NULL) return DICF_ERROR_NOT_DICFORMAT; if(context == NULL) return DICF_ERROR_NOT_DICFORMAT;
ctx = context; ctx = context;
// Not a libdicformat context // Not a libaaruformat context
if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT; if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT;
item = ctx->mediaTagsHead; item = ctx->mediaTagsHead;
@@ -71,8 +71,8 @@ int32_t read_media_tag(void* context, uint8_t* data, int32_t tag, uint32_t* leng
int32_t read_sector(void* context, uint64_t sectorAddress, uint8_t* data, uint32_t* length) int32_t read_sector(void* context, uint64_t sectorAddress, uint8_t* data, uint32_t* length)
{ {
dicformatContext* ctx; aaruformatContext* ctx;
uint64_t ddtEntry; uint64_t ddtEntry;
uint32_t offsetMask; uint32_t offsetMask;
uint64_t offset; uint64_t offset;
uint64_t blockOffset; uint64_t blockOffset;
@@ -84,7 +84,7 @@ int32_t read_sector(void* context, uint64_t sectorAddress, uint8_t* data, uint32
ctx = context; ctx = context;
// Not a libdicformat context // Not a libaaruformat context
if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT; if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT;
if(sectorAddress > ctx->imageInfo.Sectors - 1) return DICF_ERROR_SECTOR_OUT_OF_BOUNDS; if(sectorAddress > ctx->imageInfo.Sectors - 1) return DICF_ERROR_SECTOR_OUT_OF_BOUNDS;
@@ -150,14 +150,14 @@ int32_t read_sector(void* context, uint64_t sectorAddress, uint8_t* data, uint32
int32_t read_track_sector(void* context, uint8_t* data, uint64_t sectorAddress, uint32_t* length, uint8_t track) int32_t read_track_sector(void* context, uint8_t* data, uint64_t sectorAddress, uint32_t* length, uint8_t track)
{ {
dicformatContext* ctx; aaruformatContext* ctx;
int i; int i;
if(context == NULL) return DICF_ERROR_NOT_DICFORMAT; if(context == NULL) return DICF_ERROR_NOT_DICFORMAT;
ctx = context; ctx = context;
// Not a libdicformat context // Not a libaaruformat context
if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT; if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT;
if(ctx->imageInfo.XmlMediaType != OpticalDisc) return DICF_ERROR_INCORRECT_MEDIA_TYPE; if(ctx->imageInfo.XmlMediaType != OpticalDisc) return DICF_ERROR_INCORRECT_MEDIA_TYPE;
@@ -173,8 +173,8 @@ int32_t read_track_sector(void* context, uint8_t* data, uint64_t sectorAddress,
int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, uint32_t* length) int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, uint32_t* length)
{ {
dicformatContext* ctx; aaruformatContext* ctx;
uint32_t bareLength; uint32_t bareLength;
uint32_t tagLength; uint32_t tagLength;
uint8_t* bareData; uint8_t* bareData;
int32_t res; int32_t res;
@@ -186,7 +186,7 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
ctx = context; ctx = context;
// Not a libdicformat context // Not a libaaruformat context
if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT; if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT;
switch(ctx->imageInfo.XmlMediaType) switch(ctx->imageInfo.XmlMediaType)