Add new magic number.

This commit is contained in:
2020-03-01 19:58:09 +00:00
parent d892f90a59
commit 629401939d
5 changed files with 12 additions and 9 deletions

View File

@@ -35,8 +35,10 @@
#ifndef LIBAARUFORMAT_CONSTS_H
#define LIBAARUFORMAT_CONSTS_H
/** Magic identidier = "DICMFMT". */
/** Magic identidier = "DICMFRMT". */
#define DIC_MAGIC 0x544D52464D434944
/** Magic identidier = "AARUFRMT". */
#define AARU_MAGIC 0x544D524655524141
/** 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 AARUF_VERSION 1

View File

@@ -49,7 +49,7 @@ int close(void* context)
aaruformatContext* ctx = context;
// Not a libaaruformat context
if(ctx->magic != DIC_MAGIC)
if(ctx->magic != AARU_MAGIC)
{
errno = EINVAL;
return -1;

View File

@@ -73,7 +73,8 @@ int identifyStream(FILE* imageStream)
if(ret < sizeof(AaruHeader)) return 0;
if(header.identifier == DIC_MAGIC && header.imageMajorVersion <= AARUF_VERSION) return 100;
if((header.identifier == DIC_MAGIC || header.identifier == AARU_MAGIC) && header.imageMajorVersion <= AARUF_VERSION)
return 100;
return 0;
}

View File

@@ -80,7 +80,7 @@ void* open(const char* filepath)
return NULL;
}
if(ctx->header.identifier != DIC_MAGIC)
if(ctx->header.identifier != DIC_MAGIC && ctx->header.identifier != AARU_MAGIC)
{
free(ctx);
errno = AARUF_ERROR_NOT_AARUFORMAT;
@@ -1172,7 +1172,7 @@ void* open(const char* filepath)
// Initialize ECC for Compact Disc
ctx->eccCdContext = (CdEccContext*)ecc_cd_init();
ctx->magic = DIC_MAGIC;
ctx->magic = AARU_MAGIC;
ctx->libraryMajorVersion = LIBAARUFORMAT_MAJOR_VERSION;
ctx->libraryMinorVersion = LIBAARUFORMAT_MINOR_VERSION;

View File

@@ -44,7 +44,7 @@ int32_t read_media_tag(void* context, uint8_t* data, int32_t tag, uint32_t* leng
ctx = context;
// Not a libaaruformat context
if(ctx->magic != DIC_MAGIC) return AARUF_ERROR_NOT_AARUFORMAT;
if(ctx->magic != AARU_MAGIC) return AARUF_ERROR_NOT_AARUFORMAT;
item = ctx->mediaTagsHead;
@@ -85,7 +85,7 @@ int32_t read_sector(void* context, uint64_t sectorAddress, uint8_t* data, uint32
ctx = context;
// Not a libaaruformat context
if(ctx->magic != DIC_MAGIC) return AARUF_ERROR_NOT_AARUFORMAT;
if(ctx->magic != AARU_MAGIC) return AARUF_ERROR_NOT_AARUFORMAT;
if(sectorAddress > ctx->imageInfo.Sectors - 1) return AARUF_ERROR_SECTOR_OUT_OF_BOUNDS;
@@ -158,7 +158,7 @@ int32_t read_track_sector(void* context, uint8_t* data, uint64_t sectorAddress,
ctx = context;
// Not a libaaruformat context
if(ctx->magic != DIC_MAGIC) return AARUF_ERROR_NOT_AARUFORMAT;
if(ctx->magic != AARU_MAGIC) return AARUF_ERROR_NOT_AARUFORMAT;
if(ctx->imageInfo.XmlMediaType != OpticalDisc) return AARUF_ERROR_INCORRECT_MEDIA_TYPE;
@@ -187,7 +187,7 @@ int32_t read_sector_long(void* context, uint8_t* data, uint64_t sectorAddress, u
ctx = context;
// Not a libaaruformat context
if(ctx->magic != DIC_MAGIC) return AARUF_ERROR_NOT_AARUFORMAT;
if(ctx->magic != AARU_MAGIC) return AARUF_ERROR_NOT_AARUFORMAT;
switch(ctx->imageInfo.XmlMediaType)
{