Implement sector tag types.

This commit is contained in:
2019-03-31 14:56:03 +01:00
parent c4e64ee541
commit c03ac0504a
4 changed files with 47 additions and 31 deletions

View File

@@ -1070,7 +1070,7 @@ typedef struct ImageInfo
/** Firmware revision of the drive used to read the media represented by the image */
uint8_t *DriveFirmwareRevision;
/** Type of the media represented by the image to use in XML sidecars */
int32_t XmlMediaType;
uint8_t XmlMediaType;
// CHS geometry...
/** Cylinders of the media represented by the image */
uint32_t Cylinders;
@@ -1080,6 +1080,28 @@ typedef struct ImageInfo
uint32_t SectorsPerTrack;
} ImageInfo;
/**
/// Metadata present for each sector (aka, "tag").
/// */
typedef enum
{
AppleSectorTag = 0,/** Apple's GCR sector tags, 12 bytes */
CdSectorSync = 1, /** Sync frame from CD sector, 12 bytes */
CdSectorHeader = 2, /** CD sector header, 4 bytes */
CdSectorSubHeader = 3, /** CD mode 2 sector subheader */
CdSectorEdc = 4, /** CD sector EDC, 4 bytes */
CdSectorEccP = 5, /** CD sector ECC P, 172 bytes */
CdSectorEccQ = 6, /** CD sector ECC Q, 104 bytes */
CdSectorEcc = 7, /** CD sector ECC (P and Q), 276 bytes */
CdSectorSubchannelDic = 8, /** CD sector subchannel, 96 bytes */
CdTrackIsrc = 9, /** CD track ISRC, string, 12 bytes */
CdTrackText = 10,/** CD track text, string, 13 bytes */
CdTrackFlags = 11, /** CD track flags, 1 byte */
DvdCmi = 12, /** DVD sector copyright information */
FloppyAddressMark = 13,/** Floppy address mark (contents depend on underlying floppy format) */
MaxSectorTag = FloppyAddressMark
} SectorTagType;
#endif //LIBDICFORMAT_DIC_H

View File

@@ -70,6 +70,7 @@ typedef struct dicformatContext
CdEccContext *eccCdContext;
uint8_t numberOfDataTracks;
TrackEntry *dataTracks;
bool *readableSectorTags;
} dicformatContext;
typedef struct dataLinkedList

View File

@@ -111,6 +111,8 @@ int close(void *context)
}
}
free(ctx->readableSectorTags);
free(context);
return 0;

View File

@@ -100,6 +100,18 @@ void *open(const char *filepath)
ctx->header.imageMajorVersion,
ctx->header.imageMinorVersion);
ctx->readableSectorTags = (bool *)malloc(sizeof(bool) * MaxSectorTag);
if(ctx->readableSectorTags == NULL)
{
free(ctx);
errno = DICF_ERROR_NOT_ENOUGH_MEMORY;
return NULL;
}
memset(ctx->readableSectorTags, 0, sizeof(bool) * MaxSectorTag);
ctx->imageInfo.Application = ctx->header.application;
ctx->imageInfo.ApplicationVersion = (uint8_t *)malloc(32);
if(ctx->imageInfo.ApplicationVersion != NULL)
@@ -298,13 +310,8 @@ void *open(const char *filepath)
else
ctx->sectorPrefix = data;
// TODO: ReadableSectorTags
/*
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync))
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync);
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorHeader))
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorHeader);
*/
ctx->readableSectorTags[CdSectorSync] = true;
ctx->readableSectorTags[CdSectorHeader] = true;
break;
case CdSectorSuffix:
@@ -314,35 +321,19 @@ void *open(const char *filepath)
else
ctx->sectorSuffix = data;
// TODO: ReadableSectorTags
/*
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubHeader))
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubHeader);
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEcc))
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEcc);
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccP))
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccP);
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEccQ))
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ);
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorEdc))
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc);
*/
ctx->readableSectorTags[CdSectorSubHeader] = true;
ctx->readableSectorTags[CdSectorEcc] = true;
ctx->readableSectorTags[CdSectorEccP] = true;
ctx->readableSectorTags[CdSectorEccQ] = true;
ctx->readableSectorTags[CdSectorEdc] = true;
break;
case CdSectorSubchannel:ctx->sectorSubchannel = data;
// TODO: ReadableSectorTags
/*
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel))
imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel);
*/
ctx->readableSectorTags[CdSectorSubchannel] = true;
break;
case AppleProfileTag:
case AppleSonyTag:
case PriamDataTowerTag:ctx->sectorSubchannel = data;
// TODO: ReadableSectorTags
/*
if(!imageInfo.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag))
imageInfo.ReadableSectorTags.Add(SectorTagType.AppleSectorTag);
*/
ctx->readableSectorTags[AppleSectorTag] = true;
break;
case CompactDiscMode2Subheader:ctx->mode2Subheaders = data;
break;