mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Add new magic number.
This commit is contained in:
@@ -35,8 +35,10 @@
|
|||||||
#ifndef LIBAARUFORMAT_CONSTS_H
|
#ifndef LIBAARUFORMAT_CONSTS_H
|
||||||
#define LIBAARUFORMAT_CONSTS_H
|
#define LIBAARUFORMAT_CONSTS_H
|
||||||
|
|
||||||
/** Magic identidier = "DICMFMT". */
|
/** Magic identidier = "DICMFRMT". */
|
||||||
#define DIC_MAGIC 0x544D52464D434944
|
#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
|
/** 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. */
|
* implementations from reading it correctly, if at all. */
|
||||||
#define AARUF_VERSION 1
|
#define AARUF_VERSION 1
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ int close(void* context)
|
|||||||
aaruformatContext* ctx = context;
|
aaruformatContext* ctx = context;
|
||||||
|
|
||||||
// Not a libaaruformat context
|
// Not a libaaruformat context
|
||||||
if(ctx->magic != DIC_MAGIC)
|
if(ctx->magic != AARU_MAGIC)
|
||||||
{
|
{
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ int identifyStream(FILE* imageStream)
|
|||||||
|
|
||||||
if(ret < sizeof(AaruHeader)) return 0;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ void* open(const char* filepath)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ctx->header.identifier != DIC_MAGIC)
|
if(ctx->header.identifier != DIC_MAGIC && ctx->header.identifier != AARU_MAGIC)
|
||||||
{
|
{
|
||||||
free(ctx);
|
free(ctx);
|
||||||
errno = AARUF_ERROR_NOT_AARUFORMAT;
|
errno = AARUF_ERROR_NOT_AARUFORMAT;
|
||||||
@@ -1172,7 +1172,7 @@ void* open(const char* filepath)
|
|||||||
// Initialize ECC for Compact Disc
|
// Initialize ECC for Compact Disc
|
||||||
ctx->eccCdContext = (CdEccContext*)ecc_cd_init();
|
ctx->eccCdContext = (CdEccContext*)ecc_cd_init();
|
||||||
|
|
||||||
ctx->magic = DIC_MAGIC;
|
ctx->magic = AARU_MAGIC;
|
||||||
ctx->libraryMajorVersion = LIBAARUFORMAT_MAJOR_VERSION;
|
ctx->libraryMajorVersion = LIBAARUFORMAT_MAJOR_VERSION;
|
||||||
ctx->libraryMinorVersion = LIBAARUFORMAT_MINOR_VERSION;
|
ctx->libraryMinorVersion = LIBAARUFORMAT_MINOR_VERSION;
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ int32_t read_media_tag(void* context, uint8_t* data, int32_t tag, uint32_t* leng
|
|||||||
ctx = context;
|
ctx = context;
|
||||||
|
|
||||||
// Not a libaaruformat 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;
|
item = ctx->mediaTagsHead;
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ int32_t read_sector(void* context, uint64_t sectorAddress, uint8_t* data, uint32
|
|||||||
ctx = context;
|
ctx = context;
|
||||||
|
|
||||||
// Not a libaaruformat 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;
|
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;
|
ctx = context;
|
||||||
|
|
||||||
// Not a libaaruformat 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;
|
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;
|
ctx = context;
|
||||||
|
|
||||||
// Not a libaaruformat 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)
|
switch(ctx->imageInfo.XmlMediaType)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user