mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Rename macros.
This commit is contained in:
@@ -37,9 +37,9 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||
#ifndef LIBDICFORMAT_DIC_H
|
||||
#define LIBDICFORMAT_DIC_H
|
||||
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||
#ifndef LIBAARUFORMAT_AARU_H
|
||||
#define LIBAARUFORMAT_AARU_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -1184,6 +1184,6 @@ typedef enum
|
||||
CD_LeadIn = 68
|
||||
} MediaTagType;
|
||||
|
||||
#endif // LIBDICFORMAT_DIC_H
|
||||
#endif // LIBAARUFORMAT_AARU_H
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
@@ -30,11 +30,11 @@
|
||||
// Copyright © 2011-2020 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
#ifndef LIBDICFORMAT_DICFORMAT_H
|
||||
#define LIBDICFORMAT_DICFORMAT_H
|
||||
#ifndef LIBAARUFORMAT_AARUFORMAT_H
|
||||
#define LIBAARUFORMAT_AARUFORMAT_H
|
||||
|
||||
#define LIBDICFORMAT_MAJOR_VERSION 1
|
||||
#define LIBDICFORMAT_MINOR_VERSION 0
|
||||
#define LIBAARUFORMAT_MAJOR_VERSION 1
|
||||
#define LIBAARUFORMAT_MINOR_VERSION 0
|
||||
|
||||
#include "aaruformat/consts.h"
|
||||
#include "aaruformat/context.h"
|
||||
@@ -43,4 +43,4 @@
|
||||
#include "aaruformat/errors.h"
|
||||
#include "aaruformat/structs.h"
|
||||
|
||||
#endif // LIBDICFORMAT_DICFORMAT_H
|
||||
#endif // LIBAARUFORMAT_AARUFORMAT_H
|
||||
|
||||
@@ -31,15 +31,15 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
|
||||
#ifndef LIBDICFORMAT_CONSTS_H
|
||||
#define LIBDICFORMAT_CONSTS_H
|
||||
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
|
||||
#ifndef LIBAARUFORMAT_CONSTS_H
|
||||
#define LIBAARUFORMAT_CONSTS_H
|
||||
|
||||
/** Magic identidier = "DICMFMT". */
|
||||
#define DIC_MAGIC 0x544D52464D434944
|
||||
/** Image format version. A change in this number indicates an incompatible change to the format that prevents older
|
||||
* implementations from reading it correctly, if at all. */
|
||||
#define DICF_VERSION 1
|
||||
#define AARUF_VERSION 1
|
||||
/** Maximum read cache size, 256MiB. */
|
||||
#define MAX_CACHE_SIZE 256 * 1024 * 1024
|
||||
/** Size in bytes of LZMA properties. */
|
||||
@@ -60,6 +60,6 @@
|
||||
#define CRC64_ECMA_POLY 0xC96C5795D7870F42
|
||||
#define CRC64_ECMA_SEED 0xFFFFFFFFFFFFFFFF
|
||||
|
||||
#endif // LIBDICFORMAT_CONSTS_H
|
||||
#endif // LIBAARUFORMAT_CONSTS_H
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
@@ -29,8 +29,8 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2020 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
#ifndef LIBDICFORMAT_CONTEXT_H
|
||||
#define LIBDICFORMAT_CONTEXT_H
|
||||
#ifndef LIBAARUFORMAT_CONTEXT_H
|
||||
#define LIBAARUFORMAT_CONTEXT_H
|
||||
|
||||
#include "structs.h"
|
||||
|
||||
@@ -108,4 +108,4 @@ typedef struct DumpExtent
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif // LIBDICFORMAT_CONTEXT_H
|
||||
#endif // LIBAARUFORMAT_CONTEXT_H
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
// Copyright © 2011-2020 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
#ifndef LIBDICFORMAT_DECLS_H
|
||||
#define LIBDICFORMAT_DECLS_H
|
||||
#ifndef LIBAARUFORMAT_DECLS_H
|
||||
#define LIBAARUFORMAT_DECLS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@@ -117,4 +117,4 @@ int32_t GetMediaTagTypeForDataType(int32_t type);
|
||||
|
||||
int32_t GetXmlMediaType(int32_t type);
|
||||
|
||||
#endif // LIBDICFORMAT_DECLS_H
|
||||
#endif // LIBAARUFORMAT_DECLS_H
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||
#ifndef LIBDICFORMAT_ENUMS_H
|
||||
#define LIBDICFORMAT_ENUMS_H
|
||||
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||
#ifndef LIBAARUFORMAT_ENUMS_H
|
||||
#define LIBAARUFORMAT_ENUMS_H
|
||||
|
||||
/** List of known compression types */
|
||||
typedef enum
|
||||
@@ -241,7 +241,7 @@ typedef enum
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DICF_STATUS_INVALID_CONTEXT = -1,
|
||||
AARUF_STATUS_INVALID_CONTEXT = -1,
|
||||
} DicformatStatus;
|
||||
|
||||
/**
|
||||
@@ -265,6 +265,6 @@ typedef enum
|
||||
AudioMedia = 3
|
||||
} XmlMediaType;
|
||||
|
||||
#endif // LIBDICFORMAT_ENUMS_H
|
||||
#endif // LIBAARUFORMAT_ENUMS_H
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
@@ -2,29 +2,29 @@
|
||||
// Created by claunia on 17/03/19.
|
||||
//
|
||||
|
||||
#ifndef LIBDICFORMAT_ERRORS_H
|
||||
#define LIBDICFORMAT_ERRORS_H
|
||||
#ifndef LIBAARUFORMAT_ERRORS_H
|
||||
#define LIBAARUFORMAT_ERRORS_H
|
||||
|
||||
#define DICF_ERROR_NOT_DICFORMAT -1
|
||||
#define DICF_ERROR_FILE_TOO_SMALL -2
|
||||
#define DICF_ERROR_INCOMPATIBLE_VERSION -3
|
||||
#define DICF_ERROR_CANNOT_READ_INDEX -4
|
||||
#define DICF_ERROR_SECTOR_OUT_OF_BOUNDS -5
|
||||
#define DICF_ERROR_CANNOT_READ_HEADER -6
|
||||
#define DICF_ERROR_CANNOT_READ_BLOCK -7
|
||||
#define DICF_ERROR_UNSUPPORTED_COMPRESSION -8
|
||||
#define DICF_ERROR_NOT_ENOUGH_MEMORY -9
|
||||
#define DICF_ERROR_BUFFER_TOO_SMALL -10
|
||||
#define DICF_ERROR_MEDIA_TAG_NOT_PRESENT -11
|
||||
#define DICF_ERROR_INCORRECT_MEDIA_TYPE -12
|
||||
#define DICF_ERROR_TRACK_NOT_FOUND -13
|
||||
#define DICF_ERROR_REACHED_UNREACHABLE_CODE -14
|
||||
#define DICF_ERROR_INVALID_TRACK_FORMAT -15
|
||||
#define DICF_ERROR_SECTOR_TAG_NOT_PRESENT -11
|
||||
#define AARUF_ERROR_NOT_AARUFORMAT -1
|
||||
#define AARUF_ERROR_FILE_TOO_SMALL -2
|
||||
#define AARUF_ERROR_INCOMPATIBLE_VERSION -3
|
||||
#define AARUF_ERROR_CANNOT_READ_INDEX -4
|
||||
#define AARUF_ERROR_SECTOR_OUT_OF_BOUNDS -5
|
||||
#define AARUF_ERROR_CANNOT_READ_HEADER -6
|
||||
#define AARUF_ERROR_CANNOT_READ_BLOCK -7
|
||||
#define AARUF_ERROR_UNSUPPORTED_COMPRESSION -8
|
||||
#define AARUF_ERROR_NOT_ENOUGH_MEMORY -9
|
||||
#define AARUF_ERROR_BUFFER_TOO_SMALL -10
|
||||
#define AARUF_ERROR_MEDIA_TAG_NOT_PRESENT -11
|
||||
#define AARUF_ERROR_INCORRECT_MEDIA_TYPE -12
|
||||
#define AARUF_ERROR_TRACK_NOT_FOUND -13
|
||||
#define AARUF_ERROR_REACHED_UNREACHABLE_CODE -14
|
||||
#define AARUF_ERROR_INVALID_TRACK_FORMAT -15
|
||||
#define AARUF_ERROR_SECTOR_TAG_NOT_PRESENT -11
|
||||
|
||||
#define DICF_STATUS_OK 0
|
||||
#define DICF_STATUS_SECTOR_NOT_DUMPED 1
|
||||
#define DICF_STATUS_SECTOR_WITH_ERRORS 2
|
||||
#define DICF_STATUS_SECTOR_DELETED 3
|
||||
#define AARUF_STATUS_OK 0
|
||||
#define AARUF_STATUS_SECTOR_NOT_DUMPED 1
|
||||
#define AARUF_STATUS_SECTOR_WITH_ERRORS 2
|
||||
#define AARUF_STATUS_SECTOR_DELETED 3
|
||||
|
||||
#endif // LIBDICFORMAT_ERRORS_H
|
||||
#endif // LIBAARUFORMAT_ERRORS_H
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||
#ifndef LIBDICFORMAT_STRUCTS_H
|
||||
#define LIBDICFORMAT_STRUCTS_H
|
||||
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||
#ifndef LIBAARUFORMAT_STRUCTS_H
|
||||
#define LIBAARUFORMAT_STRUCTS_H
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
/**Header, at start of file */
|
||||
typedef struct DicHeader
|
||||
{
|
||||
/**Header identifier, <see cref="DIC_MAGIC" /> */
|
||||
/**Header identifier, <see cref="AARU_MAGIC" /> */
|
||||
uint64_t identifier;
|
||||
/**UTF-16LE name of the application that created the image */
|
||||
uint8_t application[64];
|
||||
@@ -321,6 +321,6 @@ typedef struct CdEccContext
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif // LIBDICFORMAT_STRUCTS_H
|
||||
#endif // LIBAARUFORMAT_STRUCTS_H
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
12
src/cst.c
12
src/cst.c
@@ -47,7 +47,7 @@ int32_t cst_transform(const uint8_t* interleaved, uint8_t* sequential, size_t le
|
||||
size_t wStart;
|
||||
size_t i;
|
||||
|
||||
if(interleaved == NULL || sequential == NULL) return DICF_ERROR_BUFFER_TOO_SMALL;
|
||||
if(interleaved == NULL || sequential == NULL) return AARUF_ERROR_BUFFER_TOO_SMALL;
|
||||
|
||||
p = malloc(length / 8);
|
||||
q = malloc(length / 8);
|
||||
@@ -68,7 +68,7 @@ int32_t cst_transform(const uint8_t* interleaved, uint8_t* sequential, size_t le
|
||||
free(u);
|
||||
free(v);
|
||||
free(w);
|
||||
return DICF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
for(i = 0; i < length; i += 8)
|
||||
@@ -166,7 +166,7 @@ int32_t cst_transform(const uint8_t* interleaved, uint8_t* sequential, size_t le
|
||||
sequential[wStart + i] = w[i];
|
||||
}
|
||||
|
||||
return DICF_STATUS_OK;
|
||||
return AARUF_STATUS_OK;
|
||||
}
|
||||
|
||||
int32_t cst_untransform(const uint8_t* sequential, uint8_t* interleaved, size_t length)
|
||||
@@ -181,7 +181,7 @@ int32_t cst_untransform(const uint8_t* sequential, uint8_t* interleaved, size_t
|
||||
size_t wStart;
|
||||
size_t i;
|
||||
|
||||
if(interleaved == NULL || sequential == NULL) return DICF_ERROR_BUFFER_TOO_SMALL;
|
||||
if(interleaved == NULL || sequential == NULL) return AARUF_ERROR_BUFFER_TOO_SMALL;
|
||||
|
||||
p = malloc(length / 8);
|
||||
q = malloc(length / 8);
|
||||
@@ -202,7 +202,7 @@ int32_t cst_untransform(const uint8_t* sequential, uint8_t* interleaved, size_t
|
||||
free(u);
|
||||
free(v);
|
||||
free(w);
|
||||
return DICF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
return AARUF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
qStart = length * 1;
|
||||
@@ -302,5 +302,5 @@ int32_t cst_untransform(const uint8_t* sequential, uint8_t* interleaved, size_t
|
||||
interleaved[i + 7] += ((w[i / 8] & 0x01) == 0x01 ? 0x01 : 0);
|
||||
}
|
||||
|
||||
return DICF_STATUS_OK;
|
||||
return AARUF_STATUS_OK;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ int32_t GetMediaTagTypeForDataType(int32_t type)
|
||||
}
|
||||
}
|
||||
|
||||
// Get the CICM XML media type from DIC media type
|
||||
// Get the CICM XML media type from AARU media type
|
||||
int32_t GetXmlMediaType(int32_t type)
|
||||
{
|
||||
switch(type)
|
||||
|
||||
@@ -73,7 +73,7 @@ int identifyStream(FILE* imageStream)
|
||||
|
||||
if(ret < sizeof(DicHeader)) return 0;
|
||||
|
||||
if(header.identifier == DIC_MAGIC && header.imageMajorVersion <= DICF_VERSION) return 100;
|
||||
if(header.identifier == DIC_MAGIC && header.imageMajorVersion <= AARUF_VERSION) return 100;
|
||||
|
||||
return 0;
|
||||
}
|
||||
22
src/open.c
22
src/open.c
@@ -75,7 +75,7 @@ void* open(const char* filepath)
|
||||
if(readBytes != sizeof(DicHeader))
|
||||
{
|
||||
free(ctx);
|
||||
errno = DICF_ERROR_FILE_TOO_SMALL;
|
||||
errno = AARUF_ERROR_FILE_TOO_SMALL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -83,15 +83,15 @@ void* open(const char* filepath)
|
||||
if(ctx->header.identifier != DIC_MAGIC)
|
||||
{
|
||||
free(ctx);
|
||||
errno = DICF_ERROR_NOT_DICFORMAT;
|
||||
errno = AARUF_ERROR_NOT_AARUFORMAT;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(ctx->header.imageMajorVersion > DICF_VERSION)
|
||||
if(ctx->header.imageMajorVersion > AARUF_VERSION)
|
||||
{
|
||||
free(ctx);
|
||||
errno = DICF_ERROR_INCOMPATIBLE_VERSION;
|
||||
errno = AARUF_ERROR_INCOMPATIBLE_VERSION;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ void* open(const char* filepath)
|
||||
if(ctx->readableSectorTags == NULL)
|
||||
{
|
||||
free(ctx);
|
||||
errno = DICF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
errno = AARUF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ void* open(const char* filepath)
|
||||
if(pos < 0)
|
||||
{
|
||||
free(ctx);
|
||||
errno = DICF_ERROR_CANNOT_READ_INDEX;
|
||||
errno = AARUF_ERROR_CANNOT_READ_INDEX;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ void* open(const char* filepath)
|
||||
if(pos != ctx->header.indexOffset)
|
||||
{
|
||||
free(ctx);
|
||||
errno = DICF_ERROR_CANNOT_READ_INDEX;
|
||||
errno = AARUF_ERROR_CANNOT_READ_INDEX;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ void* open(const char* filepath)
|
||||
if(readBytes != sizeof(IndexHeader) || idxHeader.identifier != IndexBlock)
|
||||
{
|
||||
free(ctx);
|
||||
errno = DICF_ERROR_CANNOT_READ_INDEX;
|
||||
errno = AARUF_ERROR_CANNOT_READ_INDEX;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ void* open(const char* filepath)
|
||||
{
|
||||
free(idxEntries);
|
||||
free(ctx);
|
||||
errno = DICF_ERROR_CANNOT_READ_INDEX;
|
||||
errno = AARUF_ERROR_CANNOT_READ_INDEX;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -1173,8 +1173,8 @@ void* open(const char* filepath)
|
||||
ctx->eccCdContext = (CdEccContext*)ecc_cd_init();
|
||||
|
||||
ctx->magic = DIC_MAGIC;
|
||||
ctx->libraryMajorVersion = LIBDICFORMAT_MAJOR_VERSION;
|
||||
ctx->libraryMinorVersion = LIBDICFORMAT_MINOR_VERSION;
|
||||
ctx->libraryMajorVersion = LIBAARUFORMAT_MAJOR_VERSION;
|
||||
ctx->libraryMinorVersion = LIBAARUFORMAT_MINOR_VERSION;
|
||||
|
||||
free(idxEntries);
|
||||
return ctx;
|
||||
|
||||
80
src/read.c
80
src/read.c
@@ -39,12 +39,12 @@ int32_t read_media_tag(void* context, uint8_t* data, int32_t tag, uint32_t* leng
|
||||
aaruformatContext* ctx;
|
||||
dataLinkedList* item;
|
||||
|
||||
if(context == NULL) return DICF_ERROR_NOT_DICFORMAT;
|
||||
if(context == NULL) return AARUF_ERROR_NOT_AARUFORMAT;
|
||||
|
||||
ctx = context;
|
||||
|
||||
// Not a libaaruformat context
|
||||
if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT;
|
||||
if(ctx->magic != DIC_MAGIC) return AARUF_ERROR_NOT_AARUFORMAT;
|
||||
|
||||
item = ctx->mediaTagsHead;
|
||||
|
||||
@@ -55,7 +55,7 @@ int32_t read_media_tag(void* context, uint8_t* data, int32_t tag, uint32_t* leng
|
||||
if(data == NULL || *length < item->length)
|
||||
{
|
||||
*length = item->length;
|
||||
return DICF_ERROR_BUFFER_TOO_SMALL;
|
||||
return AARUF_ERROR_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
*length = item->length;
|
||||
@@ -66,7 +66,7 @@ int32_t read_media_tag(void* context, uint8_t* data, int32_t tag, uint32_t* leng
|
||||
}
|
||||
|
||||
*length = 0;
|
||||
return DICF_ERROR_MEDIA_TAG_NOT_PRESENT;
|
||||
return AARUF_ERROR_MEDIA_TAG_NOT_PRESENT;
|
||||
}
|
||||
|
||||
int32_t read_sector(void* context, uint64_t sectorAddress, uint8_t* data, uint32_t* length)
|
||||
@@ -80,14 +80,14 @@ int32_t read_sector(void* context, uint64_t sectorAddress, uint8_t* data, uint32
|
||||
uint8_t* block;
|
||||
size_t readBytes;
|
||||
|
||||
if(context == NULL) return DICF_ERROR_NOT_DICFORMAT;
|
||||
if(context == NULL) return AARUF_ERROR_NOT_AARUFORMAT;
|
||||
|
||||
ctx = context;
|
||||
|
||||
// Not a libaaruformat context
|
||||
if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT;
|
||||
if(ctx->magic != DIC_MAGIC) return AARUF_ERROR_NOT_AARUFORMAT;
|
||||
|
||||
if(sectorAddress > ctx->imageInfo.Sectors - 1) return DICF_ERROR_SECTOR_OUT_OF_BOUNDS;
|
||||
if(sectorAddress > ctx->imageInfo.Sectors - 1) return AARUF_ERROR_SECTOR_OUT_OF_BOUNDS;
|
||||
|
||||
ddtEntry = ctx->userDataDdt[sectorAddress];
|
||||
offsetMask = (uint32_t)((1 << ctx->shift) - 1);
|
||||
@@ -99,7 +99,7 @@ int32_t read_sector(void* context, uint64_t sectorAddress, uint8_t* data, uint32
|
||||
{
|
||||
memset(data, 0, ctx->imageInfo.SectorSize);
|
||||
*length = ctx->imageInfo.SectorSize;
|
||||
return DICF_STATUS_SECTOR_NOT_DUMPED;
|
||||
return AARUF_STATUS_SECTOR_NOT_DUMPED;
|
||||
}
|
||||
|
||||
// Check if block is cached
|
||||
@@ -109,12 +109,12 @@ int32_t read_sector(void* context, uint64_t sectorAddress, uint8_t* data, uint32
|
||||
fseek(ctx->imageStream, blockOffset, SEEK_SET);
|
||||
readBytes = fread(&blockHeader, sizeof(BlockHeader), 1, ctx->imageStream);
|
||||
|
||||
if(readBytes != sizeof(BlockHeader)) return DICF_ERROR_CANNOT_READ_HEADER;
|
||||
if(readBytes != sizeof(BlockHeader)) return AARUF_ERROR_CANNOT_READ_HEADER;
|
||||
|
||||
if(data == NULL || *length < blockHeader.sectorSize)
|
||||
{
|
||||
*length = blockHeader.sectorSize;
|
||||
return DICF_ERROR_BUFFER_TOO_SMALL;
|
||||
return AARUF_ERROR_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
// Decompress block
|
||||
@@ -122,18 +122,18 @@ int32_t read_sector(void* context, uint64_t sectorAddress, uint8_t* data, uint32
|
||||
{
|
||||
case None:
|
||||
block = (uint8_t*)malloc(blockHeader.length);
|
||||
if(block == NULL) return DICF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
if(block == NULL) return AARUF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
|
||||
readBytes = fread(block, blockHeader.length, 1, ctx->imageStream);
|
||||
|
||||
if(readBytes != blockHeader.length)
|
||||
{
|
||||
free(block);
|
||||
return DICF_ERROR_CANNOT_READ_BLOCK;
|
||||
return AARUF_ERROR_CANNOT_READ_BLOCK;
|
||||
}
|
||||
|
||||
break;
|
||||
default: return DICF_ERROR_UNSUPPORTED_COMPRESSION;
|
||||
default: return AARUF_ERROR_UNSUPPORTED_COMPRESSION;
|
||||
}
|
||||
|
||||
// Check if cache needs to be emptied
|
||||
@@ -145,7 +145,7 @@ int32_t read_sector(void* context, uint64_t sectorAddress, uint8_t* data, uint32
|
||||
memcpy(data, block + offset, blockHeader.sectorSize);
|
||||
*length = blockHeader.sectorSize;
|
||||
free(block);
|
||||
return DICF_STATUS_OK;
|
||||
return AARUF_STATUS_OK;
|
||||
}
|
||||
|
||||
int32_t read_track_sector(void* context, uint8_t* data, uint64_t sectorAddress, uint32_t* length, uint8_t track)
|
||||
@@ -153,14 +153,14 @@ int32_t read_track_sector(void* context, uint8_t* data, uint64_t sectorAddress,
|
||||
aaruformatContext* ctx;
|
||||
int i;
|
||||
|
||||
if(context == NULL) return DICF_ERROR_NOT_DICFORMAT;
|
||||
if(context == NULL) return AARUF_ERROR_NOT_AARUFORMAT;
|
||||
|
||||
ctx = context;
|
||||
|
||||
// Not a libaaruformat context
|
||||
if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT;
|
||||
if(ctx->magic != DIC_MAGIC) return AARUF_ERROR_NOT_AARUFORMAT;
|
||||
|
||||
if(ctx->imageInfo.XmlMediaType != OpticalDisc) return DICF_ERROR_INCORRECT_MEDIA_TYPE;
|
||||
if(ctx->imageInfo.XmlMediaType != OpticalDisc) return AARUF_ERROR_INCORRECT_MEDIA_TYPE;
|
||||
|
||||
for(i = 0; i < ctx->numberOfDataTracks; i++)
|
||||
{
|
||||
@@ -168,7 +168,7 @@ int32_t read_track_sector(void* context, uint8_t* data, uint64_t sectorAddress,
|
||||
{ return read_sector(context, ctx->dataTracks[i].start + sectorAddress, data, length); }
|
||||
}
|
||||
|
||||
return DICF_ERROR_TRACK_NOT_FOUND;
|
||||
return AARUF_ERROR_TRACK_NOT_FOUND;
|
||||
}
|
||||
|
||||
int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, uint32_t* length)
|
||||
@@ -182,12 +182,12 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
|
||||
int i;
|
||||
bool trkFound;
|
||||
|
||||
if(context == NULL) return DICF_ERROR_NOT_DICFORMAT;
|
||||
if(context == NULL) return AARUF_ERROR_NOT_AARUFORMAT;
|
||||
|
||||
ctx = context;
|
||||
|
||||
// Not a libaaruformat context
|
||||
if(ctx->magic != DIC_MAGIC) return DICF_ERROR_NOT_DICFORMAT;
|
||||
if(ctx->magic != DIC_MAGIC) return AARUF_ERROR_NOT_AARUFORMAT;
|
||||
|
||||
switch(ctx->imageInfo.XmlMediaType)
|
||||
{
|
||||
@@ -195,7 +195,7 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
|
||||
if(*length < 2352 || data == NULL)
|
||||
{
|
||||
*length = 2352;
|
||||
return DICF_ERROR_BUFFER_TOO_SMALL;
|
||||
return AARUF_ERROR_BUFFER_TOO_SMALL;
|
||||
}
|
||||
if((ctx->sectorSuffix == NULL || ctx->sectorPrefix == NULL) &&
|
||||
(ctx->sectorSuffixCorrected == NULL || ctx->sectorPrefixCorrected == NULL))
|
||||
@@ -206,11 +206,11 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
|
||||
|
||||
bareData = (uint8_t*)malloc(bareLength);
|
||||
|
||||
if(bareData == NULL) return DICF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
if(bareData == NULL) return AARUF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
|
||||
res = read_sector(context, sectorAddress, bareData, &bareLength);
|
||||
|
||||
if(res < DICF_STATUS_OK) return res;
|
||||
if(res < AARUF_STATUS_OK) return res;
|
||||
|
||||
trkFound = false;
|
||||
|
||||
@@ -224,7 +224,7 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
|
||||
}
|
||||
}
|
||||
|
||||
if(!trkFound) return DICF_ERROR_TRACK_NOT_FOUND;
|
||||
if(!trkFound) return AARUF_ERROR_TRACK_NOT_FOUND;
|
||||
|
||||
switch(trk.type)
|
||||
{
|
||||
@@ -240,11 +240,11 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
|
||||
if((ctx->sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == Correct)
|
||||
{
|
||||
ecc_cd_reconstruct_prefix(data, trk.type, sectorAddress);
|
||||
res = DICF_STATUS_OK;
|
||||
res = AARUF_STATUS_OK;
|
||||
}
|
||||
else if((ctx->sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == NotDumped)
|
||||
{
|
||||
res = DICF_STATUS_SECTOR_NOT_DUMPED;
|
||||
res = AARUF_STATUS_SECTOR_NOT_DUMPED;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -255,7 +255,7 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
|
||||
}
|
||||
}
|
||||
else
|
||||
return DICF_ERROR_REACHED_UNREACHABLE_CODE;
|
||||
return AARUF_ERROR_REACHED_UNREACHABLE_CODE;
|
||||
|
||||
if(ctx->sectorSuffix != NULL)
|
||||
memcpy(data + 2064, ctx->sectorSuffix + sectorAddress * 288, 288);
|
||||
@@ -264,11 +264,11 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
|
||||
if((ctx->sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == Correct)
|
||||
{
|
||||
ecc_cd_reconstruct(ctx->eccCdContext, data, trk.type);
|
||||
res = DICF_STATUS_OK;
|
||||
res = AARUF_STATUS_OK;
|
||||
}
|
||||
else if((ctx->sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == NotDumped)
|
||||
{
|
||||
res = DICF_STATUS_SECTOR_NOT_DUMPED;
|
||||
res = AARUF_STATUS_SECTOR_NOT_DUMPED;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -279,7 +279,7 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
|
||||
}
|
||||
}
|
||||
else
|
||||
return DICF_ERROR_REACHED_UNREACHABLE_CODE;
|
||||
return AARUF_ERROR_REACHED_UNREACHABLE_CODE;
|
||||
|
||||
return res;
|
||||
case CdMode2Formless:
|
||||
@@ -292,11 +292,11 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
|
||||
if((ctx->sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == Correct)
|
||||
{
|
||||
ecc_cd_reconstruct_prefix(data, trk.type, sectorAddress);
|
||||
res = DICF_STATUS_OK;
|
||||
res = AARUF_STATUS_OK;
|
||||
}
|
||||
else if((ctx->sectorPrefixDdt[sectorAddress] & CD_XFIX_MASK) == NotDumped)
|
||||
{
|
||||
res = DICF_STATUS_SECTOR_NOT_DUMPED;
|
||||
res = AARUF_STATUS_SECTOR_NOT_DUMPED;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -307,7 +307,7 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
|
||||
}
|
||||
}
|
||||
else
|
||||
return DICF_ERROR_REACHED_UNREACHABLE_CODE;
|
||||
return AARUF_ERROR_REACHED_UNREACHABLE_CODE;
|
||||
|
||||
if(ctx->mode2Subheaders != NULL && ctx->sectorSuffixDdt != NULL)
|
||||
{
|
||||
@@ -327,7 +327,7 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
|
||||
}
|
||||
else if((ctx->sectorSuffixDdt[sectorAddress] & CD_XFIX_MASK) == NotDumped)
|
||||
{
|
||||
res = DICF_STATUS_SECTOR_NOT_DUMPED;
|
||||
res = AARUF_STATUS_SECTOR_NOT_DUMPED;
|
||||
}
|
||||
else
|
||||
// Mode 2 where ECC failed
|
||||
@@ -342,7 +342,7 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
|
||||
memcpy(data + 16, bareData, 2336);
|
||||
|
||||
return res;
|
||||
default: return DICF_ERROR_INVALID_TRACK_FORMAT;
|
||||
default: return AARUF_ERROR_INVALID_TRACK_FORMAT;
|
||||
}
|
||||
case BlockMedia:
|
||||
switch(ctx->imageInfo.MediaType)
|
||||
@@ -363,7 +363,7 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
|
||||
case AppleSonySS:
|
||||
case AppleSonyDS: tagLength = 12; break;
|
||||
case PriamDataTower: tagLength = 24; break;
|
||||
default: return DICF_ERROR_INCORRECT_MEDIA_TYPE;
|
||||
default: return AARUF_ERROR_INCORRECT_MEDIA_TYPE;
|
||||
}
|
||||
|
||||
bareLength = 512;
|
||||
@@ -371,12 +371,12 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
|
||||
if(*length < tagLength + bareLength || data == NULL)
|
||||
{
|
||||
*length = tagLength + bareLength;
|
||||
return DICF_ERROR_BUFFER_TOO_SMALL;
|
||||
return AARUF_ERROR_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
bareData = malloc(bareLength);
|
||||
|
||||
if(bareData == NULL) return DICF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
if(bareData == NULL) return AARUF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
|
||||
res = read_sector(context, sectorAddress, bareData, &bareLength);
|
||||
|
||||
@@ -388,8 +388,8 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
|
||||
free(bareData);
|
||||
|
||||
return res;
|
||||
default: return DICF_ERROR_INCORRECT_MEDIA_TYPE;
|
||||
default: return AARUF_ERROR_INCORRECT_MEDIA_TYPE;
|
||||
}
|
||||
default: return DICF_ERROR_INCORRECT_MEDIA_TYPE;
|
||||
default: return AARUF_ERROR_INCORRECT_MEDIA_TYPE;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user