mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Set to C90 standard.
This commit is contained in:
@@ -38,6 +38,8 @@
|
||||
|
||||
int close(void* context)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(context == NULL)
|
||||
{
|
||||
errno = EINVAL;
|
||||
@@ -92,7 +94,7 @@ int close(void* context)
|
||||
|
||||
if(ctx->dumpHardwareEntriesWithData != NULL)
|
||||
{
|
||||
for(int i = 0; i < ctx->dumpHardwareHeader.entries; i++)
|
||||
for(i = 0; i < ctx->dumpHardwareHeader.entries; i++)
|
||||
{
|
||||
free(ctx->dumpHardwareEntriesWithData[i].extents);
|
||||
free(ctx->dumpHardwareEntriesWithData[i].manufacturer);
|
||||
|
||||
16
src/crc64.c
16
src/crc64.c
@@ -38,6 +38,7 @@
|
||||
void* crc64_init(uint64_t polynomial, uint64_t seed)
|
||||
{
|
||||
Crc64Context* ctx;
|
||||
int i, j;
|
||||
|
||||
ctx = malloc(sizeof(Crc64Context));
|
||||
|
||||
@@ -48,10 +49,10 @@ void* crc64_init(uint64_t polynomial, uint64_t seed)
|
||||
ctx->finalSeed = seed;
|
||||
ctx->hashInt = seed;
|
||||
|
||||
for(int i = 0; i < 256; i++)
|
||||
for(i = 0; i < 256; i++)
|
||||
{
|
||||
uint64_t entry = (uint64_t)i;
|
||||
for(int j = 0; j < 8; j++)
|
||||
for(j = 0; j < 8; j++)
|
||||
if((entry & 1) == 1)
|
||||
entry = (entry >> 1) ^ polynomial;
|
||||
else
|
||||
@@ -68,8 +69,9 @@ 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)
|
||||
{
|
||||
Crc64Context* ctx = context;
|
||||
size_t i;
|
||||
|
||||
for(size_t i = 0; i < len; i++) ctx->hashInt = (ctx->hashInt >> 8) ^ ctx->table[data[i] ^ (ctx->hashInt & 0xFF)];
|
||||
for(i = 0; i < len; i++) ctx->hashInt = (ctx->hashInt >> 8) ^ ctx->table[data[i] ^ (ctx->hashInt & 0xFF)];
|
||||
}
|
||||
|
||||
uint64_t crc64_final(void* context)
|
||||
@@ -83,11 +85,13 @@ uint64_t crc64_data(const uint8_t* data, size_t len, uint64_t polynomial, uint64
|
||||
{
|
||||
uint64_t table[256];
|
||||
uint64_t hashInt = seed;
|
||||
int i, j;
|
||||
size_t s;
|
||||
|
||||
for(int i = 0; i < 256; i++)
|
||||
for(i = 0; i < 256; i++)
|
||||
{
|
||||
uint64_t entry = (uint64_t)i;
|
||||
for(int j = 0; j < 8; j++)
|
||||
for(j = 0; j < 8; j++)
|
||||
if((entry & 1) == 1)
|
||||
entry = (entry >> 1) ^ polynomial;
|
||||
else
|
||||
@@ -96,7 +100,7 @@ uint64_t crc64_data(const uint8_t* data, size_t len, uint64_t polynomial, uint64
|
||||
table[i] = entry;
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < len; i++) hashInt = (hashInt >> 8) ^ table[data[i] ^ (hashInt & 0xFF)];
|
||||
for(s = 0; s < len; s++) hashInt = (hashInt >> 8) ^ table[data[s] ^ (hashInt & 0xFF)];
|
||||
|
||||
return hashInt ^ seed;
|
||||
}
|
||||
|
||||
10
src/cst.c
10
src/cst.c
@@ -45,6 +45,7 @@ int32_t cst_transform(const uint8_t* interleaved, uint8_t* sequential, size_t le
|
||||
size_t uStart;
|
||||
size_t vStart;
|
||||
size_t wStart;
|
||||
size_t i;
|
||||
|
||||
if(interleaved == NULL || sequential == NULL) return DICF_ERROR_BUFFER_TOO_SMALL;
|
||||
|
||||
@@ -70,7 +71,7 @@ int32_t cst_transform(const uint8_t* interleaved, uint8_t* sequential, size_t le
|
||||
return DICF_ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < length; i += 8)
|
||||
for(i = 0; i < length; i += 8)
|
||||
{
|
||||
p[i / 8] = (uint8_t)(interleaved[i] & 0x80);
|
||||
p[i / 8] += (interleaved[i + 1] & 0x80) >> 1;
|
||||
@@ -153,7 +154,7 @@ int32_t cst_transform(const uint8_t* interleaved, uint8_t* sequential, size_t le
|
||||
vStart = length * 6;
|
||||
wStart = length * 7;
|
||||
|
||||
for(size_t i = 0; i < length; i++)
|
||||
for(i = 0; i < length; i++)
|
||||
{
|
||||
sequential[i] = p[i];
|
||||
sequential[qStart + i] = q[i];
|
||||
@@ -178,6 +179,7 @@ int32_t cst_untransform(const uint8_t* sequential, uint8_t* interleaved, size_t
|
||||
size_t uStart;
|
||||
size_t vStart;
|
||||
size_t wStart;
|
||||
size_t i;
|
||||
|
||||
if(interleaved == NULL || sequential == NULL) return DICF_ERROR_BUFFER_TOO_SMALL;
|
||||
|
||||
@@ -211,7 +213,7 @@ int32_t cst_untransform(const uint8_t* sequential, uint8_t* interleaved, size_t
|
||||
vStart = length * 6;
|
||||
wStart = length * 7;
|
||||
|
||||
for(size_t i = 0; i < length; i++)
|
||||
for(i = 0; i < length; i++)
|
||||
{
|
||||
p[i] = sequential[i];
|
||||
q[i] = sequential[qStart + i];
|
||||
@@ -225,7 +227,7 @@ int32_t cst_untransform(const uint8_t* sequential, uint8_t* interleaved, size_t
|
||||
|
||||
memset(interleaved, 0, length);
|
||||
|
||||
for(size_t i = 0; i < length; i += 8)
|
||||
for(i = 0; i < length; i += 8)
|
||||
{
|
||||
interleaved[i] += ((p[i / 8] & 0x80) == 0x80 ? 0x80 : 0);
|
||||
interleaved[i + 1] += ((p[i / 8] & 0x40) == 0x40 ? 0x80 : 0);
|
||||
|
||||
@@ -50,6 +50,8 @@ void* open(const char* filepath)
|
||||
uint32_t* cdDdt;
|
||||
uint64_t crc64;
|
||||
uint8_t temp8u;
|
||||
int i;
|
||||
uint16_t e;
|
||||
|
||||
ctx = (dicformatContext*)malloc(sizeof(dicformatContext));
|
||||
memset(ctx, 0, sizeof(dicformatContext));
|
||||
@@ -184,7 +186,7 @@ void* open(const char* filepath)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(int i = 0; i < idxHeader.entries; i++)
|
||||
for(i = 0; i < idxHeader.entries; i++)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"libdicformat: Block type %4.4s with data type %4.4s is indexed to be at %" PRIu64 "",
|
||||
@@ -195,7 +197,7 @@ void* open(const char* filepath)
|
||||
|
||||
bool foundUserDataDdt = false;
|
||||
ctx->imageInfo.ImageSize = 0;
|
||||
for(int i = 0; i < idxHeader.entries; i++)
|
||||
for(i = 0; i < idxHeader.entries; i++)
|
||||
{
|
||||
pos = fseek(ctx->imageStream, idxEntries[i].offset, SEEK_SET);
|
||||
|
||||
@@ -903,7 +905,7 @@ void* open(const char* filepath)
|
||||
0,
|
||||
sizeof(DumpHardwareEntriesWithData) * ctx->dumpHardwareHeader.entries);
|
||||
|
||||
for(uint16_t e = 0; e < ctx->dumpHardwareHeader.entries; e++)
|
||||
for(e = 0; e < ctx->dumpHardwareHeader.entries; e++)
|
||||
{
|
||||
readBytes = fread(
|
||||
&ctx->dumpHardwareEntriesWithData[e].entry, sizeof(DumpHardwareEntry), 1, ctx->imageStream);
|
||||
|
||||
Reference in New Issue
Block a user