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