mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Fix pointer formatting.
This commit is contained in:
@@ -86,7 +86,7 @@ PenaltyBreakFirstLessLess: 120
|
|||||||
PenaltyBreakString: 1000
|
PenaltyBreakString: 1000
|
||||||
PenaltyExcessCharacter: 1000000
|
PenaltyExcessCharacter: 1000000
|
||||||
PenaltyReturnTypeOnItsOwnLine: 60
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
PointerAlignment: Right
|
PointerAlignment: Left
|
||||||
ReflowComments: true
|
ReflowComments: true
|
||||||
SortIncludes: true
|
SortIncludes: true
|
||||||
SortUsingDeclarations: true
|
SortUsingDeclarations: true
|
||||||
|
|||||||
@@ -1032,31 +1032,31 @@ typedef struct ImageInfo
|
|||||||
/** Sector tags contained by the image */
|
/** Sector tags contained by the image */
|
||||||
// List<SectorTagType> ReadableSectorTags;
|
// List<SectorTagType> ReadableSectorTags;
|
||||||
/** Image version */
|
/** Image version */
|
||||||
uint8_t *Version;
|
uint8_t* Version;
|
||||||
/** Application that created the image */
|
/** Application that created the image */
|
||||||
uint8_t *Application;
|
uint8_t* Application;
|
||||||
/** Version of the application that created the image */
|
/** Version of the application that created the image */
|
||||||
uint8_t *ApplicationVersion;
|
uint8_t* ApplicationVersion;
|
||||||
/** Who (person) created the image? */
|
/** Who (person) created the image? */
|
||||||
uint8_t *Creator;
|
uint8_t* Creator;
|
||||||
/** Image creation time */
|
/** Image creation time */
|
||||||
int64_t CreationTime;
|
int64_t CreationTime;
|
||||||
/** Image last modification time */
|
/** Image last modification time */
|
||||||
int64_t LastModificationTime;
|
int64_t LastModificationTime;
|
||||||
/** Title of the media represented by the image */
|
/** Title of the media represented by the image */
|
||||||
uint8_t *MediaTitle;
|
uint8_t* MediaTitle;
|
||||||
/** Image comments */
|
/** Image comments */
|
||||||
uint8_t *Comments;
|
uint8_t* Comments;
|
||||||
/** Manufacturer of the media represented by the image */
|
/** Manufacturer of the media represented by the image */
|
||||||
uint8_t *MediaManufacturer;
|
uint8_t* MediaManufacturer;
|
||||||
/** Model of the media represented by the image */
|
/** Model of the media represented by the image */
|
||||||
uint8_t *MediaModel;
|
uint8_t* MediaModel;
|
||||||
/** Serial number of the media represented by the image */
|
/** Serial number of the media represented by the image */
|
||||||
uint8_t *MediaSerialNumber;
|
uint8_t* MediaSerialNumber;
|
||||||
/** Barcode of the media represented by the image */
|
/** Barcode of the media represented by the image */
|
||||||
uint8_t *MediaBarcode;
|
uint8_t* MediaBarcode;
|
||||||
/** Part number of the media represented by the image */
|
/** Part number of the media represented by the image */
|
||||||
uint8_t *MediaPartNumber;
|
uint8_t* MediaPartNumber;
|
||||||
/** Media type represented by the image */
|
/** Media type represented by the image */
|
||||||
uint32_t MediaType;
|
uint32_t MediaType;
|
||||||
/** Number in sequence for the media represented by the image */
|
/** Number in sequence for the media represented by the image */
|
||||||
@@ -1064,13 +1064,13 @@ typedef struct ImageInfo
|
|||||||
/** Last media of the sequence the media represented by the image corresponds to */
|
/** Last media of the sequence the media represented by the image corresponds to */
|
||||||
int32_t LastMediaSequence;
|
int32_t LastMediaSequence;
|
||||||
/** Manufacturer of the drive used to read the media represented by the image */
|
/** Manufacturer of the drive used to read the media represented by the image */
|
||||||
uint8_t *DriveManufacturer;
|
uint8_t* DriveManufacturer;
|
||||||
/** Model of the drive used to read the media represented by the image */
|
/** Model of the drive used to read the media represented by the image */
|
||||||
uint8_t *DriveModel;
|
uint8_t* DriveModel;
|
||||||
/** Serial number of the drive used to read the media represented by the image */
|
/** Serial number of the drive used to read the media represented by the image */
|
||||||
uint8_t *DriveSerialNumber;
|
uint8_t* DriveSerialNumber;
|
||||||
/** Firmware revision of the drive used to read the media represented by the image */
|
/** Firmware revision of the drive used to read the media represented by the image */
|
||||||
uint8_t *DriveFirmwareRevision;
|
uint8_t* DriveFirmwareRevision;
|
||||||
/** Type of the media represented by the image to use in XML sidecars */
|
/** Type of the media represented by the image to use in XML sidecars */
|
||||||
uint8_t XmlMediaType;
|
uint8_t XmlMediaType;
|
||||||
// CHS geometry...
|
// CHS geometry...
|
||||||
|
|||||||
@@ -43,43 +43,43 @@ typedef struct dicformatContext
|
|||||||
uint64_t magic;
|
uint64_t magic;
|
||||||
uint8_t libraryMajorVersion;
|
uint8_t libraryMajorVersion;
|
||||||
uint8_t libraryMinorVersion;
|
uint8_t libraryMinorVersion;
|
||||||
FILE * imageStream;
|
FILE* imageStream;
|
||||||
DicHeader header;
|
DicHeader header;
|
||||||
struct dataLinkedList * mediaTagsHead;
|
struct dataLinkedList* mediaTagsHead;
|
||||||
struct dataLinkedList * mediaTagsTail;
|
struct dataLinkedList* mediaTagsTail;
|
||||||
uint8_t * sectorPrefix;
|
uint8_t* sectorPrefix;
|
||||||
uint8_t * sectorPrefixCorrected;
|
uint8_t* sectorPrefixCorrected;
|
||||||
uint8_t * sectorSuffix;
|
uint8_t* sectorSuffix;
|
||||||
uint8_t * sectorSuffixCorrected;
|
uint8_t* sectorSuffixCorrected;
|
||||||
uint8_t * sectorSubchannel;
|
uint8_t* sectorSubchannel;
|
||||||
uint8_t * mode2Subheaders;
|
uint8_t* mode2Subheaders;
|
||||||
uint8_t shift;
|
uint8_t shift;
|
||||||
bool inMemoryDdt;
|
bool inMemoryDdt;
|
||||||
uint64_t * userDataDdt;
|
uint64_t* userDataDdt;
|
||||||
size_t mappedMemoryDdtSize;
|
size_t mappedMemoryDdtSize;
|
||||||
uint32_t * sectorPrefixDdt;
|
uint32_t* sectorPrefixDdt;
|
||||||
uint32_t * sectorSuffixDdt;
|
uint32_t* sectorSuffixDdt;
|
||||||
GeometryBlockHeader geometryBlock;
|
GeometryBlockHeader geometryBlock;
|
||||||
MetadataBlockHeader metadataBlockHeader;
|
MetadataBlockHeader metadataBlockHeader;
|
||||||
uint8_t * metadataBlock;
|
uint8_t* metadataBlock;
|
||||||
TracksHeader tracksHeader;
|
TracksHeader tracksHeader;
|
||||||
TrackEntry * trackEntries;
|
TrackEntry* trackEntries;
|
||||||
CicmMetadataBlock cicmBlockHeader;
|
CicmMetadataBlock cicmBlockHeader;
|
||||||
uint8_t * cicmBlock;
|
uint8_t* cicmBlock;
|
||||||
DumpHardwareHeader dumpHardwareHeader;
|
DumpHardwareHeader dumpHardwareHeader;
|
||||||
struct DumpHardwareEntriesWithData *dumpHardwareEntriesWithData;
|
struct DumpHardwareEntriesWithData* dumpHardwareEntriesWithData;
|
||||||
struct ImageInfo imageInfo;
|
struct ImageInfo imageInfo;
|
||||||
CdEccContext * eccCdContext;
|
CdEccContext* eccCdContext;
|
||||||
uint8_t numberOfDataTracks;
|
uint8_t numberOfDataTracks;
|
||||||
TrackEntry * dataTracks;
|
TrackEntry* dataTracks;
|
||||||
bool * readableSectorTags;
|
bool* readableSectorTags;
|
||||||
} dicformatContext;
|
} dicformatContext;
|
||||||
|
|
||||||
typedef struct dataLinkedList
|
typedef struct dataLinkedList
|
||||||
{
|
{
|
||||||
struct dataLinkedList *previous;
|
struct dataLinkedList* previous;
|
||||||
struct dataLinkedList *next;
|
struct dataLinkedList* next;
|
||||||
uint8_t * data;
|
uint8_t* data;
|
||||||
int32_t type;
|
int32_t type;
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
} dataLinkedList;
|
} dataLinkedList;
|
||||||
@@ -87,15 +87,15 @@ typedef struct dataLinkedList
|
|||||||
typedef struct DumpHardwareEntriesWithData
|
typedef struct DumpHardwareEntriesWithData
|
||||||
{
|
{
|
||||||
DumpHardwareEntry entry;
|
DumpHardwareEntry entry;
|
||||||
struct DumpExtent *extents;
|
struct DumpExtent* extents;
|
||||||
uint8_t * manufacturer;
|
uint8_t* manufacturer;
|
||||||
uint8_t * model;
|
uint8_t* model;
|
||||||
uint8_t * revision;
|
uint8_t* revision;
|
||||||
uint8_t * firmware;
|
uint8_t* firmware;
|
||||||
uint8_t * serial;
|
uint8_t* serial;
|
||||||
uint8_t * softwareName;
|
uint8_t* softwareName;
|
||||||
uint8_t * softwareVersion;
|
uint8_t* softwareVersion;
|
||||||
uint8_t * softwareOperatingSystem;
|
uint8_t* softwareOperatingSystem;
|
||||||
} DumpHardwareEntriesWithData;
|
} DumpHardwareEntriesWithData;
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
|||||||
@@ -37,81 +37,81 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int identify(const char *filename);
|
int identify(const char* filename);
|
||||||
|
|
||||||
int identifyStream(FILE *imageStream);
|
int identifyStream(FILE* imageStream);
|
||||||
|
|
||||||
void *open(const char *filepath);
|
void* open(const char* filepath);
|
||||||
|
|
||||||
int close(void *context);
|
int close(void* context);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
void *crc64_init(uint64_t polynomial, uint64_t seed);
|
void* crc64_init(uint64_t polynomial, uint64_t seed);
|
||||||
|
|
||||||
void *crc64_init_ecma(void);
|
void* crc64_init_ecma(void);
|
||||||
|
|
||||||
void crc64_update(void *context, const uint8_t *data, size_t len);
|
void crc64_update(void* context, const uint8_t* data, size_t len);
|
||||||
|
|
||||||
uint64_t crc64_final(void *context);
|
uint64_t crc64_final(void* context);
|
||||||
|
|
||||||
uint64_t crc64_data(const uint8_t *data, size_t len, uint64_t polynomial, uint64_t seed);
|
uint64_t crc64_data(const uint8_t* data, size_t len, uint64_t polynomial, uint64_t seed);
|
||||||
|
|
||||||
uint64_t crc64_data_ecma(const uint8_t *data, size_t len);
|
uint64_t crc64_data_ecma(const uint8_t* data, size_t len);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
int32_t cst_transform(const uint8_t *interleaved, uint8_t *sequential, size_t length);
|
int32_t cst_transform(const uint8_t* interleaved, uint8_t* sequential, size_t length);
|
||||||
|
|
||||||
int32_t cst_untransform(const uint8_t *sequential, uint8_t *interleaved, size_t length);
|
int32_t cst_untransform(const uint8_t* sequential, uint8_t* interleaved, size_t length);
|
||||||
|
|
||||||
void *ecc_cd_init();
|
void* ecc_cd_init();
|
||||||
|
|
||||||
bool ecc_cd_is_suffix_correct(void *context, const uint8_t *sector);
|
bool ecc_cd_is_suffix_correct(void* context, const uint8_t* sector);
|
||||||
|
|
||||||
bool ecc_cd_is_suffix_correct_mode2(void *context, const uint8_t *sector);
|
bool ecc_cd_is_suffix_correct_mode2(void* context, const uint8_t* sector);
|
||||||
|
|
||||||
bool ecc_cd_check(void * context,
|
bool ecc_cd_check(void* context,
|
||||||
const uint8_t *address,
|
const uint8_t* address,
|
||||||
const uint8_t *data,
|
const uint8_t* data,
|
||||||
uint32_t majorCount,
|
uint32_t majorCount,
|
||||||
uint32_t minorCount,
|
uint32_t minorCount,
|
||||||
uint32_t majorMult,
|
uint32_t majorMult,
|
||||||
uint32_t minorInc,
|
uint32_t minorInc,
|
||||||
const uint8_t *ecc,
|
const uint8_t* ecc,
|
||||||
int32_t addressOffset,
|
int32_t addressOffset,
|
||||||
int32_t dataOffset,
|
int32_t dataOffset,
|
||||||
int32_t eccOffset);
|
int32_t eccOffset);
|
||||||
|
|
||||||
void ecc_cd_write(void * context,
|
void ecc_cd_write(void* context,
|
||||||
const uint8_t *address,
|
const uint8_t* address,
|
||||||
const uint8_t *data,
|
const uint8_t* data,
|
||||||
uint32_t majorCount,
|
uint32_t majorCount,
|
||||||
uint32_t minorCount,
|
uint32_t minorCount,
|
||||||
uint32_t majorMult,
|
uint32_t majorMult,
|
||||||
uint32_t minorInc,
|
uint32_t minorInc,
|
||||||
uint8_t * ecc,
|
uint8_t* ecc,
|
||||||
int32_t addressOffset,
|
int32_t addressOffset,
|
||||||
int32_t dataOffset,
|
int32_t dataOffset,
|
||||||
int32_t eccOffset);
|
int32_t eccOffset);
|
||||||
|
|
||||||
void ecc_cd_write_sector(void * context,
|
void ecc_cd_write_sector(void* context,
|
||||||
const uint8_t *address,
|
const uint8_t* address,
|
||||||
const uint8_t *data,
|
const uint8_t* data,
|
||||||
uint8_t * ecc,
|
uint8_t* ecc,
|
||||||
int32_t addressOffset,
|
int32_t addressOffset,
|
||||||
int32_t dataOffset,
|
int32_t dataOffset,
|
||||||
int32_t eccOffset);
|
int32_t eccOffset);
|
||||||
|
|
||||||
void cd_lba_to_msf(int64_t pos, uint8_t *minute, uint8_t *second, uint8_t *frame);
|
void cd_lba_to_msf(int64_t pos, uint8_t* minute, uint8_t* second, uint8_t* frame);
|
||||||
|
|
||||||
void ecc_cd_reconstruct_prefix(uint8_t *sector, uint8_t type, int64_t lba);
|
void ecc_cd_reconstruct_prefix(uint8_t* sector, uint8_t type, int64_t lba);
|
||||||
|
|
||||||
void ecc_cd_reconstruct(void *context, uint8_t *sector, uint8_t type);
|
void ecc_cd_reconstruct(void* context, uint8_t* sector, uint8_t type);
|
||||||
|
|
||||||
uint32_t edc_cd_compute(void *context, uint32_t edc, const uint8_t *src, int size, int pos);
|
uint32_t edc_cd_compute(void* context, uint32_t edc, const uint8_t* src, int size, int pos);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
int32_t GetMediaTagTypeForDataType(int32_t type);
|
int32_t GetMediaTagTypeForDataType(int32_t type);
|
||||||
|
|
||||||
|
|||||||
@@ -314,9 +314,9 @@ typedef struct Crc64Context
|
|||||||
typedef struct CdEccContext
|
typedef struct CdEccContext
|
||||||
{
|
{
|
||||||
bool initedEdc;
|
bool initedEdc;
|
||||||
uint8_t * eccBTable;
|
uint8_t* eccBTable;
|
||||||
uint8_t * eccFTable;
|
uint8_t* eccFTable;
|
||||||
uint32_t *edcTable;
|
uint32_t* edcTable;
|
||||||
} CdEccContext;
|
} CdEccContext;
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
int close(void *context)
|
int close(void* context)
|
||||||
{
|
{
|
||||||
if(context == NULL)
|
if(context == NULL)
|
||||||
{
|
{
|
||||||
@@ -44,7 +44,7 @@ int close(void *context)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dicformatContext *ctx = context;
|
dicformatContext* ctx = context;
|
||||||
|
|
||||||
// Not a libdicformat context
|
// Not a libdicformat context
|
||||||
if(ctx->magic != DIC_MAGIC)
|
if(ctx->magic != DIC_MAGIC)
|
||||||
@@ -65,7 +65,7 @@ int close(void *context)
|
|||||||
|
|
||||||
if(ctx->mediaTagsTail != NULL)
|
if(ctx->mediaTagsTail != NULL)
|
||||||
{
|
{
|
||||||
dataLinkedList *mediaTag = ctx->mediaTagsTail;
|
dataLinkedList* mediaTag = ctx->mediaTagsTail;
|
||||||
|
|
||||||
while(mediaTag->previous != NULL)
|
while(mediaTag->previous != NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
18
src/crc64.c
18
src/crc64.c
@@ -35,9 +35,9 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
void *crc64_init(uint64_t polynomial, uint64_t seed)
|
void* crc64_init(uint64_t polynomial, uint64_t seed)
|
||||||
{
|
{
|
||||||
Crc64Context *ctx;
|
Crc64Context* ctx;
|
||||||
|
|
||||||
ctx = malloc(sizeof(Crc64Context));
|
ctx = malloc(sizeof(Crc64Context));
|
||||||
|
|
||||||
@@ -63,23 +63,23 @@ void *crc64_init(uint64_t polynomial, uint64_t seed)
|
|||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *crc64_init_ecma(void) { return crc64_init(CRC64_ECMA_POLY, CRC64_ECMA_SEED); }
|
void* crc64_init_ecma(void) { return crc64_init(CRC64_ECMA_POLY, CRC64_ECMA_SEED); }
|
||||||
|
|
||||||
void crc64_update(void *context, const uint8_t *data, size_t len)
|
void crc64_update(void* context, const uint8_t* data, size_t len)
|
||||||
{
|
{
|
||||||
Crc64Context *ctx = context;
|
Crc64Context* ctx = context;
|
||||||
|
|
||||||
for(size_t i = 0; i < len; i++) ctx->hashInt = (ctx->hashInt >> 8) ^ ctx->table[data[i] ^ (ctx->hashInt & 0xFF)];
|
for(size_t i = 0; i < len; i++) ctx->hashInt = (ctx->hashInt >> 8) ^ ctx->table[data[i] ^ (ctx->hashInt & 0xFF)];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t crc64_final(void *context)
|
uint64_t crc64_final(void* context)
|
||||||
{
|
{
|
||||||
Crc64Context *ctx = context;
|
Crc64Context* ctx = context;
|
||||||
|
|
||||||
return ctx->hashInt ^ ctx->finalSeed;
|
return ctx->hashInt ^ ctx->finalSeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t crc64_data(const uint8_t *data, size_t len, uint64_t polynomial, uint64_t seed)
|
uint64_t crc64_data(const uint8_t* data, size_t len, uint64_t polynomial, uint64_t seed)
|
||||||
{
|
{
|
||||||
uint64_t table[256];
|
uint64_t table[256];
|
||||||
uint64_t hashInt = seed;
|
uint64_t hashInt = seed;
|
||||||
@@ -101,7 +101,7 @@ uint64_t crc64_data(const uint8_t *data, size_t len, uint64_t polynomial, uint64
|
|||||||
return hashInt ^ seed;
|
return hashInt ^ seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t crc64_data_ecma(const uint8_t *data, size_t len)
|
uint64_t crc64_data_ecma(const uint8_t* data, size_t len)
|
||||||
{
|
{
|
||||||
return crc64_data(data, len, CRC64_ECMA_POLY, CRC64_ECMA_SEED);
|
return crc64_data(data, len, CRC64_ECMA_POLY, CRC64_ECMA_SEED);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int32_t cst_transform(const uint8_t *interleaved, uint8_t *sequential, size_t length)
|
int32_t cst_transform(const uint8_t* interleaved, uint8_t* sequential, size_t length)
|
||||||
{
|
{
|
||||||
uint8_t *p, *q, *r, *s, *t, *u, *v, *w;
|
uint8_t *p, *q, *r, *s, *t, *u, *v, *w;
|
||||||
size_t qStart;
|
size_t qStart;
|
||||||
@@ -168,7 +168,7 @@ int32_t cst_transform(const uint8_t *interleaved, uint8_t *sequential, size_t le
|
|||||||
return DICF_STATUS_OK;
|
return DICF_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cst_untransform(const uint8_t *sequential, uint8_t *interleaved, size_t length)
|
int32_t cst_untransform(const uint8_t* sequential, uint8_t* interleaved, size_t length)
|
||||||
{
|
{
|
||||||
uint8_t *p, *q, *r, *s, *t, *u, *v, *w;
|
uint8_t *p, *q, *r, *s, *t, *u, *v, *w;
|
||||||
size_t qStart;
|
size_t qStart;
|
||||||
|
|||||||
74
src/ecc_cd.c
74
src/ecc_cd.c
@@ -37,16 +37,16 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
void *ecc_cd_init()
|
void* ecc_cd_init()
|
||||||
{
|
{
|
||||||
CdEccContext *context;
|
CdEccContext* context;
|
||||||
uint32_t edc, i, j;
|
uint32_t edc, i, j;
|
||||||
|
|
||||||
context = (CdEccContext *)malloc(sizeof(CdEccContext));
|
context = (CdEccContext*)malloc(sizeof(CdEccContext));
|
||||||
|
|
||||||
if(context == NULL) return NULL;
|
if(context == NULL) return NULL;
|
||||||
|
|
||||||
context->eccFTable = (uint8_t *)malloc(sizeof(uint8_t) * 256);
|
context->eccFTable = (uint8_t*)malloc(sizeof(uint8_t) * 256);
|
||||||
|
|
||||||
if(context->eccFTable == NULL)
|
if(context->eccFTable == NULL)
|
||||||
{
|
{
|
||||||
@@ -54,7 +54,7 @@ void *ecc_cd_init()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
context->eccBTable = (uint8_t *)malloc(sizeof(uint8_t) * 256);
|
context->eccBTable = (uint8_t*)malloc(sizeof(uint8_t) * 256);
|
||||||
|
|
||||||
if(context->eccBTable == NULL)
|
if(context->eccBTable == NULL)
|
||||||
{
|
{
|
||||||
@@ -62,7 +62,7 @@ void *ecc_cd_init()
|
|||||||
free(context);
|
free(context);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
context->edcTable = (uint32_t *)malloc(sizeof(uint32_t) * 256);
|
context->edcTable = (uint32_t*)malloc(sizeof(uint32_t) * 256);
|
||||||
|
|
||||||
if(context->edcTable == NULL)
|
if(context->edcTable == NULL)
|
||||||
{
|
{
|
||||||
@@ -87,15 +87,15 @@ void *ecc_cd_init()
|
|||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ecc_cd_is_suffix_correct(void *context, const uint8_t *sector)
|
bool ecc_cd_is_suffix_correct(void* context, const uint8_t* sector)
|
||||||
{
|
{
|
||||||
CdEccContext *ctx;
|
CdEccContext* ctx;
|
||||||
uint32_t storedEdc, edc, calculatedEdc;
|
uint32_t storedEdc, edc, calculatedEdc;
|
||||||
int size, pos;
|
int size, pos;
|
||||||
|
|
||||||
if(context == NULL || sector == NULL) return false;
|
if(context == NULL || sector == NULL) return false;
|
||||||
|
|
||||||
ctx = (CdEccContext *)context;
|
ctx = (CdEccContext*)context;
|
||||||
|
|
||||||
if(!ctx->initedEdc) return false;
|
if(!ctx->initedEdc) return false;
|
||||||
|
|
||||||
@@ -121,16 +121,16 @@ bool ecc_cd_is_suffix_correct(void *context, const uint8_t *sector)
|
|||||||
return calculatedEdc == storedEdc;
|
return calculatedEdc == storedEdc;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ecc_cd_is_suffix_correct_mode2(void *context, const uint8_t *sector)
|
bool ecc_cd_is_suffix_correct_mode2(void* context, const uint8_t* sector)
|
||||||
{
|
{
|
||||||
CdEccContext *ctx;
|
CdEccContext* ctx;
|
||||||
uint32_t storedEdc, edc, calculatedEdc;
|
uint32_t storedEdc, edc, calculatedEdc;
|
||||||
int size, pos;
|
int size, pos;
|
||||||
uint8_t zeroaddress[4];
|
uint8_t zeroaddress[4];
|
||||||
|
|
||||||
if(context == NULL || sector == NULL) return false;
|
if(context == NULL || sector == NULL) return false;
|
||||||
|
|
||||||
ctx = (CdEccContext *)context;
|
ctx = (CdEccContext*)context;
|
||||||
|
|
||||||
if(!ctx->initedEdc) return false;
|
if(!ctx->initedEdc) return false;
|
||||||
|
|
||||||
@@ -152,25 +152,25 @@ bool ecc_cd_is_suffix_correct_mode2(void *context, const uint8_t *sector)
|
|||||||
return calculatedEdc == storedEdc;
|
return calculatedEdc == storedEdc;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ecc_cd_check(void * context,
|
bool ecc_cd_check(void* context,
|
||||||
const uint8_t *address,
|
const uint8_t* address,
|
||||||
const uint8_t *data,
|
const uint8_t* data,
|
||||||
uint32_t majorCount,
|
uint32_t majorCount,
|
||||||
uint32_t minorCount,
|
uint32_t minorCount,
|
||||||
uint32_t majorMult,
|
uint32_t majorMult,
|
||||||
uint32_t minorInc,
|
uint32_t minorInc,
|
||||||
const uint8_t *ecc,
|
const uint8_t* ecc,
|
||||||
int32_t addressOffset,
|
int32_t addressOffset,
|
||||||
int32_t dataOffset,
|
int32_t dataOffset,
|
||||||
int32_t eccOffset)
|
int32_t eccOffset)
|
||||||
{
|
{
|
||||||
CdEccContext *ctx;
|
CdEccContext* ctx;
|
||||||
uint32_t size, major, idx, minor;
|
uint32_t size, major, idx, minor;
|
||||||
uint8_t eccA, eccB, temp;
|
uint8_t eccA, eccB, temp;
|
||||||
|
|
||||||
if(context == NULL || address == NULL || data == NULL || ecc == NULL) return false;
|
if(context == NULL || address == NULL || data == NULL || ecc == NULL) return false;
|
||||||
|
|
||||||
ctx = (CdEccContext *)context;
|
ctx = (CdEccContext*)context;
|
||||||
|
|
||||||
if(!ctx->initedEdc) return false;
|
if(!ctx->initedEdc) return false;
|
||||||
|
|
||||||
@@ -197,25 +197,25 @@ bool ecc_cd_check(void * context,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ecc_cd_write(void * context,
|
void ecc_cd_write(void* context,
|
||||||
const uint8_t *address,
|
const uint8_t* address,
|
||||||
const uint8_t *data,
|
const uint8_t* data,
|
||||||
uint32_t majorCount,
|
uint32_t majorCount,
|
||||||
uint32_t minorCount,
|
uint32_t minorCount,
|
||||||
uint32_t majorMult,
|
uint32_t majorMult,
|
||||||
uint32_t minorInc,
|
uint32_t minorInc,
|
||||||
uint8_t * ecc,
|
uint8_t* ecc,
|
||||||
int32_t addressOffset,
|
int32_t addressOffset,
|
||||||
int32_t dataOffset,
|
int32_t dataOffset,
|
||||||
int32_t eccOffset)
|
int32_t eccOffset)
|
||||||
{
|
{
|
||||||
CdEccContext *ctx;
|
CdEccContext* ctx;
|
||||||
uint32_t size, major, idx, minor;
|
uint32_t size, major, idx, minor;
|
||||||
uint8_t eccA, eccB, temp;
|
uint8_t eccA, eccB, temp;
|
||||||
|
|
||||||
if(context == NULL || address == NULL || data == NULL || ecc == NULL) return;
|
if(context == NULL || address == NULL || data == NULL || ecc == NULL) return;
|
||||||
|
|
||||||
ctx = (CdEccContext *)context;
|
ctx = (CdEccContext*)context;
|
||||||
|
|
||||||
if(!ctx->initedEdc) return;
|
if(!ctx->initedEdc) return;
|
||||||
|
|
||||||
@@ -242,10 +242,10 @@ void ecc_cd_write(void * context,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ecc_cd_write_sector(void * context,
|
void ecc_cd_write_sector(void* context,
|
||||||
const uint8_t *address,
|
const uint8_t* address,
|
||||||
const uint8_t *data,
|
const uint8_t* data,
|
||||||
uint8_t * ecc,
|
uint8_t* ecc,
|
||||||
int32_t addressOffset,
|
int32_t addressOffset,
|
||||||
int32_t dataOffset,
|
int32_t dataOffset,
|
||||||
int32_t eccOffset)
|
int32_t eccOffset)
|
||||||
@@ -254,14 +254,14 @@ void ecc_cd_write_sector(void * context,
|
|||||||
ecc_cd_write(context, address, data, 52, 43, 86, 88, ecc, addressOffset, dataOffset, eccOffset + 0xAC); // Q
|
ecc_cd_write(context, address, data, 52, 43, 86, 88, ecc, addressOffset, dataOffset, eccOffset + 0xAC); // Q
|
||||||
}
|
}
|
||||||
|
|
||||||
void cd_lba_to_msf(int64_t pos, uint8_t *minute, uint8_t *second, uint8_t *frame)
|
void cd_lba_to_msf(int64_t pos, uint8_t* minute, uint8_t* second, uint8_t* frame)
|
||||||
{
|
{
|
||||||
*minute = (uint8_t)((pos + 150) / 75 / 60);
|
*minute = (uint8_t)((pos + 150) / 75 / 60);
|
||||||
*second = (uint8_t)((pos + 150) / 75 % 60);
|
*second = (uint8_t)((pos + 150) / 75 % 60);
|
||||||
*frame = (uint8_t)((pos + 150) % 75);
|
*frame = (uint8_t)((pos + 150) % 75);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ecc_cd_reconstruct_prefix(uint8_t *sector, // must point to a full 2352-byte sector
|
void ecc_cd_reconstruct_prefix(uint8_t* sector, // must point to a full 2352-byte sector
|
||||||
uint8_t type,
|
uint8_t type,
|
||||||
int64_t lba)
|
int64_t lba)
|
||||||
{
|
{
|
||||||
@@ -318,18 +318,18 @@ void ecc_cd_reconstruct_prefix(uint8_t *sector, // must point to a full 2352-byt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ecc_cd_reconstruct(void * context,
|
void ecc_cd_reconstruct(void* context,
|
||||||
uint8_t *sector, // must point to a full 2352-byte sector
|
uint8_t* sector, // must point to a full 2352-byte sector
|
||||||
uint8_t type)
|
uint8_t type)
|
||||||
{
|
{
|
||||||
uint32_t computedEdc;
|
uint32_t computedEdc;
|
||||||
uint8_t zeroaddress[4];
|
uint8_t zeroaddress[4];
|
||||||
|
|
||||||
CdEccContext *ctx;
|
CdEccContext* ctx;
|
||||||
|
|
||||||
if(context == NULL || sector == NULL) return;
|
if(context == NULL || sector == NULL) return;
|
||||||
|
|
||||||
ctx = (CdEccContext *)context;
|
ctx = (CdEccContext*)context;
|
||||||
|
|
||||||
if(!ctx->initedEdc) return;
|
if(!ctx->initedEdc) return;
|
||||||
|
|
||||||
@@ -383,13 +383,13 @@ void ecc_cd_reconstruct(void * context,
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t edc_cd_compute(void *context, uint32_t edc, const uint8_t *src, int size, int pos)
|
uint32_t edc_cd_compute(void* context, uint32_t edc, const uint8_t* src, int size, int pos)
|
||||||
{
|
{
|
||||||
CdEccContext *ctx;
|
CdEccContext* ctx;
|
||||||
|
|
||||||
if(context == NULL || src == NULL) return 0;
|
if(context == NULL || src == NULL) return 0;
|
||||||
|
|
||||||
ctx = (CdEccContext *)context;
|
ctx = (CdEccContext*)context;
|
||||||
|
|
||||||
if(!ctx->initedEdc) return 0;
|
if(!ctx->initedEdc) return 0;
|
||||||
|
|
||||||
|
|||||||
@@ -41,9 +41,9 @@
|
|||||||
* @return If positive, confidence value, with 100 being maximum confidentiality, and 0 not recognizing the file.
|
* @return If positive, confidence value, with 100 being maximum confidentiality, and 0 not recognizing the file.
|
||||||
* If negative, error value
|
* If negative, error value
|
||||||
*/
|
*/
|
||||||
int identify(const char *filename)
|
int identify(const char* filename)
|
||||||
{
|
{
|
||||||
FILE *stream;
|
FILE* stream;
|
||||||
|
|
||||||
stream = fopen(filename, "rb");
|
stream = fopen(filename, "rb");
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ int identify(const char *filename)
|
|||||||
* @return If positive, confidence value, with 100 being maximum confidentiality, and 0 not recognizing the file.
|
* @return If positive, confidence value, with 100 being maximum confidentiality, and 0 not recognizing the file.
|
||||||
* If negative, error value
|
* If negative, error value
|
||||||
*/
|
*/
|
||||||
int identifyStream(FILE *imageStream)
|
int identifyStream(FILE* imageStream)
|
||||||
{
|
{
|
||||||
fseek(imageStream, 0, SEEK_SET);
|
fseek(imageStream, 0, SEEK_SET);
|
||||||
|
|
||||||
|
|||||||
104
src/open.c
104
src/open.c
@@ -38,20 +38,20 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
void *open(const char *filepath)
|
void* open(const char* filepath)
|
||||||
{
|
{
|
||||||
dicformatContext *ctx;
|
dicformatContext* 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;
|
||||||
|
|
||||||
ctx = (dicformatContext *)malloc(sizeof(dicformatContext));
|
ctx = (dicformatContext*)malloc(sizeof(dicformatContext));
|
||||||
memset(ctx, 0, sizeof(dicformatContext));
|
memset(ctx, 0, sizeof(dicformatContext));
|
||||||
|
|
||||||
if(ctx == NULL) return NULL;
|
if(ctx == NULL) return NULL;
|
||||||
@@ -99,7 +99,7 @@ void *open(const char *filepath)
|
|||||||
ctx->header.imageMajorVersion,
|
ctx->header.imageMajorVersion,
|
||||||
ctx->header.imageMinorVersion);
|
ctx->header.imageMinorVersion);
|
||||||
|
|
||||||
ctx->readableSectorTags = (bool *)malloc(sizeof(bool) * MaxSectorTag);
|
ctx->readableSectorTags = (bool*)malloc(sizeof(bool) * MaxSectorTag);
|
||||||
|
|
||||||
if(ctx->readableSectorTags == NULL)
|
if(ctx->readableSectorTags == NULL)
|
||||||
{
|
{
|
||||||
@@ -112,20 +112,20 @@ void *open(const char *filepath)
|
|||||||
memset(ctx->readableSectorTags, 0, sizeof(bool) * MaxSectorTag);
|
memset(ctx->readableSectorTags, 0, sizeof(bool) * MaxSectorTag);
|
||||||
|
|
||||||
ctx->imageInfo.Application = ctx->header.application;
|
ctx->imageInfo.Application = ctx->header.application;
|
||||||
ctx->imageInfo.ApplicationVersion = (uint8_t *)malloc(32);
|
ctx->imageInfo.ApplicationVersion = (uint8_t*)malloc(32);
|
||||||
if(ctx->imageInfo.ApplicationVersion != NULL)
|
if(ctx->imageInfo.ApplicationVersion != NULL)
|
||||||
{
|
{
|
||||||
memset(ctx->imageInfo.ApplicationVersion, 0, 32);
|
memset(ctx->imageInfo.ApplicationVersion, 0, 32);
|
||||||
sprintf((char *)ctx->imageInfo.ApplicationVersion,
|
sprintf((char*)ctx->imageInfo.ApplicationVersion,
|
||||||
"%d.%d",
|
"%d.%d",
|
||||||
ctx->header.applicationMajorVersion,
|
ctx->header.applicationMajorVersion,
|
||||||
ctx->header.applicationMinorVersion);
|
ctx->header.applicationMinorVersion);
|
||||||
}
|
}
|
||||||
ctx->imageInfo.Version = (uint8_t *)malloc(32);
|
ctx->imageInfo.Version = (uint8_t*)malloc(32);
|
||||||
if(ctx->imageInfo.Version != NULL)
|
if(ctx->imageInfo.Version != NULL)
|
||||||
{
|
{
|
||||||
memset(ctx->imageInfo.Version, 0, 32);
|
memset(ctx->imageInfo.Version, 0, 32);
|
||||||
sprintf((char *)ctx->imageInfo.Version, "%d.%d", ctx->header.imageMajorVersion, ctx->header.imageMinorVersion);
|
sprintf((char*)ctx->imageInfo.Version, "%d.%d", ctx->header.imageMajorVersion, ctx->header.imageMinorVersion);
|
||||||
}
|
}
|
||||||
ctx->imageInfo.MediaType = ctx->header.mediaType;
|
ctx->imageInfo.MediaType = ctx->header.mediaType;
|
||||||
|
|
||||||
@@ -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, "libdicformat: 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);
|
||||||
|
|
||||||
if(idxEntries == NULL)
|
if(idxEntries == NULL)
|
||||||
{
|
{
|
||||||
@@ -188,8 +188,8 @@ void *open(const char *filepath)
|
|||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"libdicformat: Block type %4.4s with data type %4.4s is indexed to be at %" PRIu64 "",
|
"libdicformat: 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,20 +251,20 @@ void *open(const char *filepath)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"libdicformat: Expected block with data type %4.4s at position %" PRIu64
|
"libdicformat: 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,
|
||||||
(char *)&blockHeader.type);
|
(char*)&blockHeader.type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"libdicformat: Found data block with type %4.4s at position %" PRIu64 "",
|
"libdicformat: Found data block with type %4.4s at position %" PRIu64 "",
|
||||||
(char *)&idxEntries[i].blockType,
|
(char*)&idxEntries[i].blockType,
|
||||||
idxEntries[i].offset);
|
idxEntries[i].offset);
|
||||||
|
|
||||||
if(blockHeader.compression == None)
|
if(blockHeader.compression == None)
|
||||||
{
|
{
|
||||||
data = (uint8_t *)malloc(blockHeader.length);
|
data = (uint8_t*)malloc(blockHeader.length);
|
||||||
if(data == NULL)
|
if(data == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Cannot allocate memory for block, continuing...");
|
fprintf(stderr, "Cannot allocate memory for block, continuing...");
|
||||||
@@ -299,7 +299,7 @@ void *open(const char *filepath)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataLinkedList *mediaTag = NULL;
|
dataLinkedList* mediaTag = NULL;
|
||||||
|
|
||||||
// Check if it's not a media tag, but a sector tag, and fill the appropriate table then
|
// Check if it's not a media tag, but a sector tag, and fill the appropriate table then
|
||||||
switch(idxEntries[i].dataType)
|
switch(idxEntries[i].dataType)
|
||||||
@@ -362,7 +362,7 @@ void *open(const char *filepath)
|
|||||||
// or the list was empty
|
// or the list was empty
|
||||||
if(mediaTag != NULL) break;
|
if(mediaTag != NULL) break;
|
||||||
|
|
||||||
mediaTag = (dataLinkedList *)malloc(sizeof(dataLinkedList));
|
mediaTag = (dataLinkedList*)malloc(sizeof(dataLinkedList));
|
||||||
|
|
||||||
if(mediaTag == NULL)
|
if(mediaTag == NULL)
|
||||||
{
|
{
|
||||||
@@ -442,7 +442,7 @@ void *open(const char *filepath)
|
|||||||
switch(ddtHeader.compression)
|
switch(ddtHeader.compression)
|
||||||
{
|
{
|
||||||
case None:
|
case None:
|
||||||
cdDdt = (uint32_t *)malloc(ddtHeader.entries * sizeof(uint32_t));
|
cdDdt = (uint32_t*)malloc(ddtHeader.entries * sizeof(uint32_t));
|
||||||
|
|
||||||
if(mediaTag == NULL)
|
if(mediaTag == NULL)
|
||||||
{
|
{
|
||||||
@@ -524,7 +524,7 @@ void *open(const char *filepath)
|
|||||||
|
|
||||||
ctx->imageInfo.ImageSize += ctx->metadataBlockHeader.blockSize;
|
ctx->imageInfo.ImageSize += ctx->metadataBlockHeader.blockSize;
|
||||||
|
|
||||||
ctx->metadataBlock = (uint8_t *)malloc(ctx->metadataBlockHeader.blockSize);
|
ctx->metadataBlock = (uint8_t*)malloc(ctx->metadataBlockHeader.blockSize);
|
||||||
|
|
||||||
if(ctx->metadataBlock == NULL)
|
if(ctx->metadataBlock == NULL)
|
||||||
{
|
{
|
||||||
@@ -556,7 +556,7 @@ void *open(const char *filepath)
|
|||||||
ctx->metadataBlockHeader.creatorOffset + ctx->metadataBlockHeader.creatorLength <=
|
ctx->metadataBlockHeader.creatorOffset + ctx->metadataBlockHeader.creatorLength <=
|
||||||
ctx->metadataBlockHeader.blockSize)
|
ctx->metadataBlockHeader.blockSize)
|
||||||
{
|
{
|
||||||
ctx->imageInfo.Creator = (uint8_t *)malloc(ctx->metadataBlockHeader.creatorLength);
|
ctx->imageInfo.Creator = (uint8_t*)malloc(ctx->metadataBlockHeader.creatorLength);
|
||||||
if(ctx->imageInfo.Creator != NULL)
|
if(ctx->imageInfo.Creator != NULL)
|
||||||
{
|
{
|
||||||
memcpy(ctx->imageInfo.Creator,
|
memcpy(ctx->imageInfo.Creator,
|
||||||
@@ -569,7 +569,7 @@ void *open(const char *filepath)
|
|||||||
ctx->metadataBlockHeader.commentsOffset + ctx->metadataBlockHeader.commentsLength <=
|
ctx->metadataBlockHeader.commentsOffset + ctx->metadataBlockHeader.commentsLength <=
|
||||||
ctx->metadataBlockHeader.blockSize)
|
ctx->metadataBlockHeader.blockSize)
|
||||||
{
|
{
|
||||||
ctx->imageInfo.Comments = (uint8_t *)malloc(ctx->metadataBlockHeader.commentsLength);
|
ctx->imageInfo.Comments = (uint8_t*)malloc(ctx->metadataBlockHeader.commentsLength);
|
||||||
if(ctx->imageInfo.Comments != NULL)
|
if(ctx->imageInfo.Comments != NULL)
|
||||||
{
|
{
|
||||||
memcpy(ctx->imageInfo.Comments,
|
memcpy(ctx->imageInfo.Comments,
|
||||||
@@ -582,7 +582,7 @@ void *open(const char *filepath)
|
|||||||
ctx->metadataBlockHeader.mediaTitleOffset + ctx->metadataBlockHeader.mediaTitleLength <=
|
ctx->metadataBlockHeader.mediaTitleOffset + ctx->metadataBlockHeader.mediaTitleLength <=
|
||||||
ctx->metadataBlockHeader.blockSize)
|
ctx->metadataBlockHeader.blockSize)
|
||||||
{
|
{
|
||||||
ctx->imageInfo.MediaTitle = (uint8_t *)malloc(ctx->metadataBlockHeader.mediaTitleLength);
|
ctx->imageInfo.MediaTitle = (uint8_t*)malloc(ctx->metadataBlockHeader.mediaTitleLength);
|
||||||
if(ctx->imageInfo.MediaTitle != NULL)
|
if(ctx->imageInfo.MediaTitle != NULL)
|
||||||
{
|
{
|
||||||
memcpy(ctx->imageInfo.MediaTitle,
|
memcpy(ctx->imageInfo.MediaTitle,
|
||||||
@@ -597,7 +597,7 @@ void *open(const char *filepath)
|
|||||||
ctx->metadataBlockHeader.blockSize)
|
ctx->metadataBlockHeader.blockSize)
|
||||||
{
|
{
|
||||||
ctx->imageInfo.MediaManufacturer =
|
ctx->imageInfo.MediaManufacturer =
|
||||||
(uint8_t *)malloc(ctx->metadataBlockHeader.mediaManufacturerLength);
|
(uint8_t*)malloc(ctx->metadataBlockHeader.mediaManufacturerLength);
|
||||||
if(ctx->imageInfo.MediaManufacturer != NULL)
|
if(ctx->imageInfo.MediaManufacturer != NULL)
|
||||||
{
|
{
|
||||||
memcpy(ctx->imageInfo.MediaManufacturer,
|
memcpy(ctx->imageInfo.MediaManufacturer,
|
||||||
@@ -610,7 +610,7 @@ void *open(const char *filepath)
|
|||||||
ctx->metadataBlockHeader.mediaModelOffset + ctx->metadataBlockHeader.mediaModelLength <=
|
ctx->metadataBlockHeader.mediaModelOffset + ctx->metadataBlockHeader.mediaModelLength <=
|
||||||
ctx->metadataBlockHeader.blockSize)
|
ctx->metadataBlockHeader.blockSize)
|
||||||
{
|
{
|
||||||
ctx->imageInfo.MediaModel = (uint8_t *)malloc(ctx->metadataBlockHeader.mediaModelOffset);
|
ctx->imageInfo.MediaModel = (uint8_t*)malloc(ctx->metadataBlockHeader.mediaModelOffset);
|
||||||
if(ctx->imageInfo.MediaModel != NULL)
|
if(ctx->imageInfo.MediaModel != NULL)
|
||||||
{
|
{
|
||||||
memcpy(ctx->imageInfo.MediaModel,
|
memcpy(ctx->imageInfo.MediaModel,
|
||||||
@@ -625,7 +625,7 @@ void *open(const char *filepath)
|
|||||||
ctx->metadataBlockHeader.blockSize)
|
ctx->metadataBlockHeader.blockSize)
|
||||||
{
|
{
|
||||||
ctx->imageInfo.MediaSerialNumber =
|
ctx->imageInfo.MediaSerialNumber =
|
||||||
(uint8_t *)malloc(ctx->metadataBlockHeader.mediaSerialNumberLength);
|
(uint8_t*)malloc(ctx->metadataBlockHeader.mediaSerialNumberLength);
|
||||||
if(ctx->imageInfo.MediaSerialNumber != NULL)
|
if(ctx->imageInfo.MediaSerialNumber != NULL)
|
||||||
{
|
{
|
||||||
memcpy(ctx->imageInfo.MediaSerialNumber,
|
memcpy(ctx->imageInfo.MediaSerialNumber,
|
||||||
@@ -638,7 +638,7 @@ void *open(const char *filepath)
|
|||||||
ctx->metadataBlockHeader.mediaBarcodeOffset + ctx->metadataBlockHeader.mediaBarcodeLength <=
|
ctx->metadataBlockHeader.mediaBarcodeOffset + ctx->metadataBlockHeader.mediaBarcodeLength <=
|
||||||
ctx->metadataBlockHeader.blockSize)
|
ctx->metadataBlockHeader.blockSize)
|
||||||
{
|
{
|
||||||
ctx->imageInfo.MediaBarcode = (uint8_t *)malloc(ctx->metadataBlockHeader.mediaBarcodeLength);
|
ctx->imageInfo.MediaBarcode = (uint8_t*)malloc(ctx->metadataBlockHeader.mediaBarcodeLength);
|
||||||
if(ctx->imageInfo.MediaBarcode != NULL)
|
if(ctx->imageInfo.MediaBarcode != NULL)
|
||||||
{
|
{
|
||||||
memcpy(ctx->imageInfo.MediaBarcode,
|
memcpy(ctx->imageInfo.MediaBarcode,
|
||||||
@@ -651,7 +651,7 @@ void *open(const char *filepath)
|
|||||||
ctx->metadataBlockHeader.mediaPartNumberOffset + ctx->metadataBlockHeader.mediaPartNumberLength <=
|
ctx->metadataBlockHeader.mediaPartNumberOffset + ctx->metadataBlockHeader.mediaPartNumberLength <=
|
||||||
ctx->metadataBlockHeader.blockSize)
|
ctx->metadataBlockHeader.blockSize)
|
||||||
{
|
{
|
||||||
ctx->imageInfo.MediaPartNumber = (uint8_t *)malloc(ctx->metadataBlockHeader.mediaPartNumberLength);
|
ctx->imageInfo.MediaPartNumber = (uint8_t*)malloc(ctx->metadataBlockHeader.mediaPartNumberLength);
|
||||||
if(ctx->imageInfo.MediaPartNumber != NULL)
|
if(ctx->imageInfo.MediaPartNumber != NULL)
|
||||||
{
|
{
|
||||||
memcpy(ctx->imageInfo.MediaPartNumber,
|
memcpy(ctx->imageInfo.MediaPartNumber,
|
||||||
@@ -666,7 +666,7 @@ void *open(const char *filepath)
|
|||||||
ctx->metadataBlockHeader.blockSize)
|
ctx->metadataBlockHeader.blockSize)
|
||||||
{
|
{
|
||||||
ctx->imageInfo.DriveManufacturer =
|
ctx->imageInfo.DriveManufacturer =
|
||||||
(uint8_t *)malloc(ctx->metadataBlockHeader.driveManufacturerLength);
|
(uint8_t*)malloc(ctx->metadataBlockHeader.driveManufacturerLength);
|
||||||
if(ctx->imageInfo.DriveManufacturer != NULL)
|
if(ctx->imageInfo.DriveManufacturer != NULL)
|
||||||
{
|
{
|
||||||
memcpy(ctx->imageInfo.DriveManufacturer,
|
memcpy(ctx->imageInfo.DriveManufacturer,
|
||||||
@@ -679,7 +679,7 @@ void *open(const char *filepath)
|
|||||||
ctx->metadataBlockHeader.driveModelOffset + ctx->metadataBlockHeader.driveModelLength <=
|
ctx->metadataBlockHeader.driveModelOffset + ctx->metadataBlockHeader.driveModelLength <=
|
||||||
ctx->metadataBlockHeader.blockSize)
|
ctx->metadataBlockHeader.blockSize)
|
||||||
{
|
{
|
||||||
ctx->imageInfo.DriveModel = (uint8_t *)malloc(ctx->metadataBlockHeader.driveModelLength);
|
ctx->imageInfo.DriveModel = (uint8_t*)malloc(ctx->metadataBlockHeader.driveModelLength);
|
||||||
if(ctx->imageInfo.DriveModel != NULL)
|
if(ctx->imageInfo.DriveModel != NULL)
|
||||||
{
|
{
|
||||||
memcpy(ctx->imageInfo.DriveModel,
|
memcpy(ctx->imageInfo.DriveModel,
|
||||||
@@ -694,7 +694,7 @@ void *open(const char *filepath)
|
|||||||
ctx->metadataBlockHeader.blockSize)
|
ctx->metadataBlockHeader.blockSize)
|
||||||
{
|
{
|
||||||
ctx->imageInfo.DriveSerialNumber =
|
ctx->imageInfo.DriveSerialNumber =
|
||||||
(uint8_t *)malloc(ctx->metadataBlockHeader.driveSerialNumberLength);
|
(uint8_t*)malloc(ctx->metadataBlockHeader.driveSerialNumberLength);
|
||||||
if(ctx->imageInfo.DriveSerialNumber != NULL)
|
if(ctx->imageInfo.DriveSerialNumber != NULL)
|
||||||
{
|
{
|
||||||
memcpy(ctx->imageInfo.DriveSerialNumber,
|
memcpy(ctx->imageInfo.DriveSerialNumber,
|
||||||
@@ -709,7 +709,7 @@ void *open(const char *filepath)
|
|||||||
ctx->metadataBlockHeader.blockSize)
|
ctx->metadataBlockHeader.blockSize)
|
||||||
{
|
{
|
||||||
ctx->imageInfo.DriveFirmwareRevision =
|
ctx->imageInfo.DriveFirmwareRevision =
|
||||||
(uint8_t *)malloc(ctx->metadataBlockHeader.driveFirmwareRevisionLength);
|
(uint8_t*)malloc(ctx->metadataBlockHeader.driveFirmwareRevisionLength);
|
||||||
if(ctx->imageInfo.DriveFirmwareRevision != NULL)
|
if(ctx->imageInfo.DriveFirmwareRevision != NULL)
|
||||||
{
|
{
|
||||||
memcpy(ctx->imageInfo.DriveFirmwareRevision,
|
memcpy(ctx->imageInfo.DriveFirmwareRevision,
|
||||||
@@ -739,7 +739,7 @@ void *open(const char *filepath)
|
|||||||
|
|
||||||
ctx->imageInfo.ImageSize += sizeof(TrackEntry) * ctx->tracksHeader.entries;
|
ctx->imageInfo.ImageSize += sizeof(TrackEntry) * ctx->tracksHeader.entries;
|
||||||
|
|
||||||
ctx->trackEntries = (TrackEntry *)malloc(sizeof(TrackEntry) * ctx->tracksHeader.entries);
|
ctx->trackEntries = (TrackEntry*)malloc(sizeof(TrackEntry) * ctx->tracksHeader.entries);
|
||||||
|
|
||||||
if(ctx->trackEntries == NULL)
|
if(ctx->trackEntries == NULL)
|
||||||
{
|
{
|
||||||
@@ -758,7 +758,7 @@ void *open(const char *filepath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
crc64 =
|
crc64 =
|
||||||
crc64_data_ecma((const uint8_t *)ctx->trackEntries, ctx->tracksHeader.entries * sizeof(TrackEntry));
|
crc64_data_ecma((const uint8_t*)ctx->trackEntries, ctx->tracksHeader.entries * sizeof(TrackEntry));
|
||||||
if(crc64 != ctx->tracksHeader.crc64)
|
if(crc64 != ctx->tracksHeader.crc64)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@@ -788,7 +788,7 @@ void *open(const char *filepath)
|
|||||||
|
|
||||||
if(temp8u > 0)
|
if(temp8u > 0)
|
||||||
{
|
{
|
||||||
ctx->dataTracks = (TrackEntry *)malloc(sizeof(TrackEntry) * temp8u);
|
ctx->dataTracks = (TrackEntry*)malloc(sizeof(TrackEntry) * temp8u);
|
||||||
|
|
||||||
if(ctx->dataTracks == NULL) break;
|
if(ctx->dataTracks == NULL) break;
|
||||||
|
|
||||||
@@ -825,7 +825,7 @@ void *open(const char *filepath)
|
|||||||
|
|
||||||
ctx->imageInfo.ImageSize += ctx->cicmBlockHeader.length;
|
ctx->imageInfo.ImageSize += ctx->cicmBlockHeader.length;
|
||||||
|
|
||||||
ctx->cicmBlock = (uint8_t *)malloc(ctx->cicmBlockHeader.length);
|
ctx->cicmBlock = (uint8_t*)malloc(ctx->cicmBlockHeader.length);
|
||||||
|
|
||||||
if(ctx->cicmBlock == NULL)
|
if(ctx->cicmBlock == NULL)
|
||||||
{
|
{
|
||||||
@@ -865,7 +865,7 @@ void *open(const char *filepath)
|
|||||||
idxEntries[i].offset);
|
idxEntries[i].offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
data = (uint8_t *)malloc(ctx->dumpHardwareHeader.length);
|
data = (uint8_t*)malloc(ctx->dumpHardwareHeader.length);
|
||||||
if(data != NULL)
|
if(data != NULL)
|
||||||
{
|
{
|
||||||
readBytes = fread(data, ctx->dumpHardwareHeader.length, 1, ctx->imageStream);
|
readBytes = fread(data, ctx->dumpHardwareHeader.length, 1, ctx->imageStream);
|
||||||
@@ -889,7 +889,7 @@ void *open(const char *filepath)
|
|||||||
fseek(ctx->imageStream, -readBytes, SEEK_CUR);
|
fseek(ctx->imageStream, -readBytes, SEEK_CUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->dumpHardwareEntriesWithData = (DumpHardwareEntriesWithData *)malloc(
|
ctx->dumpHardwareEntriesWithData = (DumpHardwareEntriesWithData*)malloc(
|
||||||
sizeof(DumpHardwareEntriesWithData) * ctx->dumpHardwareHeader.entries);
|
sizeof(DumpHardwareEntriesWithData) * ctx->dumpHardwareHeader.entries);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData == NULL)
|
if(ctx->dumpHardwareEntriesWithData == NULL)
|
||||||
@@ -918,7 +918,7 @@ void *open(const char *filepath)
|
|||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].manufacturer =
|
ctx->dumpHardwareEntriesWithData[e].manufacturer =
|
||||||
(uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength);
|
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.manufacturerLength);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].manufacturer != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].manufacturer != NULL)
|
||||||
{
|
{
|
||||||
@@ -941,7 +941,7 @@ void *open(const char *filepath)
|
|||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.modelLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.modelLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].model =
|
ctx->dumpHardwareEntriesWithData[e].model =
|
||||||
(uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.modelLength);
|
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.modelLength);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].model != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].model != NULL)
|
||||||
{
|
{
|
||||||
@@ -963,7 +963,7 @@ void *open(const char *filepath)
|
|||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.revisionLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.revisionLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].revision =
|
ctx->dumpHardwareEntriesWithData[e].revision =
|
||||||
(uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.revisionLength);
|
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.revisionLength);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].revision != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].revision != NULL)
|
||||||
{
|
{
|
||||||
@@ -986,7 +986,7 @@ void *open(const char *filepath)
|
|||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].firmware =
|
ctx->dumpHardwareEntriesWithData[e].firmware =
|
||||||
(uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength);
|
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.firmwareLength);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].firmware != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].firmware != NULL)
|
||||||
{
|
{
|
||||||
@@ -1009,7 +1009,7 @@ void *open(const char *filepath)
|
|||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.serialLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.serialLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].serial =
|
ctx->dumpHardwareEntriesWithData[e].serial =
|
||||||
(uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.serialLength);
|
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.serialLength);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].serial != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].serial != NULL)
|
||||||
{
|
{
|
||||||
@@ -1031,7 +1031,7 @@ void *open(const char *filepath)
|
|||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].softwareName =
|
ctx->dumpHardwareEntriesWithData[e].softwareName =
|
||||||
(uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength);
|
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareNameLength);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].softwareName != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].softwareName != NULL)
|
||||||
{
|
{
|
||||||
@@ -1054,7 +1054,7 @@ void *open(const char *filepath)
|
|||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].softwareVersion =
|
ctx->dumpHardwareEntriesWithData[e].softwareVersion =
|
||||||
(uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength);
|
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareVersionLength);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].softwareVersion != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].softwareVersion != NULL)
|
||||||
{
|
{
|
||||||
@@ -1077,7 +1077,7 @@ void *open(const char *filepath)
|
|||||||
if(ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength > 0)
|
if(ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength > 0)
|
||||||
{
|
{
|
||||||
ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem =
|
ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem =
|
||||||
(uint8_t *)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength);
|
(uint8_t*)malloc(ctx->dumpHardwareEntriesWithData[e].entry.softwareOperatingSystemLength);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem != NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].softwareOperatingSystem != NULL)
|
||||||
{
|
{
|
||||||
@@ -1098,7 +1098,7 @@ void *open(const char *filepath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx->dumpHardwareEntriesWithData[e].extents =
|
ctx->dumpHardwareEntriesWithData[e].extents =
|
||||||
(DumpExtent *)malloc(sizeof(DumpExtent) * ctx->dumpHardwareEntriesWithData->entry.extents);
|
(DumpExtent*)malloc(sizeof(DumpExtent) * ctx->dumpHardwareEntriesWithData->entry.extents);
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData[e].extents == NULL)
|
if(ctx->dumpHardwareEntriesWithData[e].extents == NULL)
|
||||||
{
|
{
|
||||||
@@ -1127,8 +1127,8 @@ void *open(const char *filepath)
|
|||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"libdicformat: Unhandled block type %4.4s with data type %4.4s is indexed to be at %" PRIu64 "",
|
"libdicformat: 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);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1166,7 +1166,7 @@ void *open(const char *filepath)
|
|||||||
// TODO: Cache tracks and sessions?
|
// TODO: Cache tracks and sessions?
|
||||||
|
|
||||||
// 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 = DIC_MAGIC;
|
||||||
ctx->libraryMajorVersion = LIBDICFORMAT_MAJOR_VERSION;
|
ctx->libraryMajorVersion = LIBDICFORMAT_MAJOR_VERSION;
|
||||||
|
|||||||
26
src/read.c
26
src/read.c
@@ -34,10 +34,10 @@
|
|||||||
#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;
|
dicformatContext* ctx;
|
||||||
dataLinkedList * item;
|
dataLinkedList* item;
|
||||||
|
|
||||||
if(context == NULL) return DICF_ERROR_NOT_DICFORMAT;
|
if(context == NULL) return DICF_ERROR_NOT_DICFORMAT;
|
||||||
|
|
||||||
@@ -69,15 +69,15 @@ int32_t read_media_tag(void *context, uint8_t *data, int32_t tag, uint32_t *leng
|
|||||||
return DICF_ERROR_MEDIA_TAG_NOT_PRESENT;
|
return DICF_ERROR_MEDIA_TAG_NOT_PRESENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
dicformatContext* 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;
|
||||||
BlockHeader blockHeader;
|
BlockHeader blockHeader;
|
||||||
uint8_t * block;
|
uint8_t* block;
|
||||||
size_t readBytes;
|
size_t readBytes;
|
||||||
|
|
||||||
if(context == NULL) return DICF_ERROR_NOT_DICFORMAT;
|
if(context == NULL) return DICF_ERROR_NOT_DICFORMAT;
|
||||||
@@ -121,7 +121,7 @@ int32_t read_sector(void *context, uint64_t sectorAddress, uint8_t *data, uint32
|
|||||||
switch(blockHeader.compression)
|
switch(blockHeader.compression)
|
||||||
{
|
{
|
||||||
case None:
|
case None:
|
||||||
block = (uint8_t *)malloc(blockHeader.length);
|
block = (uint8_t*)malloc(blockHeader.length);
|
||||||
if(block == NULL) return DICF_ERROR_NOT_ENOUGH_MEMORY;
|
if(block == NULL) return DICF_ERROR_NOT_ENOUGH_MEMORY;
|
||||||
|
|
||||||
readBytes = fread(block, blockHeader.length, 1, ctx->imageStream);
|
readBytes = fread(block, blockHeader.length, 1, ctx->imageStream);
|
||||||
@@ -148,9 +148,9 @@ int32_t read_sector(void *context, uint64_t sectorAddress, uint8_t *data, uint32
|
|||||||
return DICF_STATUS_OK;
|
return DICF_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
dicformatContext* ctx;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(context == NULL) return DICF_ERROR_NOT_DICFORMAT;
|
if(context == NULL) return DICF_ERROR_NOT_DICFORMAT;
|
||||||
@@ -171,12 +171,12 @@ int32_t read_track_sector(void *context, uint8_t *data, uint64_t sectorAddress,
|
|||||||
return DICF_ERROR_TRACK_NOT_FOUND;
|
return DICF_ERROR_TRACK_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
dicformatContext* 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;
|
||||||
TrackEntry trk;
|
TrackEntry trk;
|
||||||
int i;
|
int i;
|
||||||
@@ -204,7 +204,7 @@ int32_t read_sector_long(void *context, uint8_t *data, uint64_t sectorAddress, u
|
|||||||
bareLength = 0;
|
bareLength = 0;
|
||||||
read_sector(context, sectorAddress, NULL, &bareLength);
|
read_sector(context, sectorAddress, NULL, &bareLength);
|
||||||
|
|
||||||
bareData = (uint8_t *)malloc(bareLength);
|
bareData = (uint8_t*)malloc(bareLength);
|
||||||
|
|
||||||
if(bareData == NULL) return DICF_ERROR_NOT_ENOUGH_MEMORY;
|
if(bareData == NULL) return DICF_ERROR_NOT_ENOUGH_MEMORY;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user