URL
https://opencores.org/ocsvn/or1k_old/or1k_old/trunk
[/] [or1k_old/] [trunk/] [orpmon/] [gencrc.c] - Diff between revs 820 and 822
Go to most recent revision |
Show entire file |
Details |
Blame |
View Log
Rev 820 |
Rev 822 |
Line 45... |
Line 45... |
fo = fopen (argv[2], "rb+");
|
fo = fopen (argv[2], "rb+");
|
if (!fi || !fo) return 1;
|
if (!fi || !fo) return 1;
|
|
|
size = fread (buf, 1, MAX_SIZE, fi);
|
size = fread (buf, 1, MAX_SIZE, fi);
|
fclose (fi);
|
fclose (fi);
|
crc = crc32 (0, buf, size);
|
|
|
if (*((unsigned long *)&buf[0]) != SWAP32(0xcccccccc) || *((unsigned long *)&buf[4]) != SWAP32(0xdddddddd)) {
|
|
fprintf (stderr, "File does not have 0xcccccccc 0xdddddddd at start\n");
|
|
return 2;
|
|
}
|
|
|
|
crc = crc32 (0, buf + 8, size -= 8);
|
tsize = fread (buf, 1, MAX_SIZE, fo);
|
tsize = fread (buf, 1, MAX_SIZE, fo);
|
for (i = 0; i < tsize - 8; i++)
|
for (i = 0; i < tsize - 8; i++)
|
if (*((unsigned long *)&buf[i]) == SWAP32(0xcccccccc) && *((unsigned long *)&buf[i + 4]) == SWAP32(0xdddddddd)) {
|
if (*((unsigned long *)&buf[i]) == SWAP32(0xcccccccc) && *((unsigned long *)&buf[i + 4]) == SWAP32(0xdddddddd)) {
|
*(unsigned long *)&buf[i] = SWAP32(crc);
|
*(unsigned long *)&buf[i] = SWAP32(crc);
|
*(unsigned long *)&buf[i + 4] = SWAP32(size);
|
*(unsigned long *)&buf[i + 4] = SWAP32(size);
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.