123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #include <stdlib.h>
- #include "../plc/plc.h"
- #include "../pib/pib.h"
- uint32_t piboffset (struct _file_ * file)
- {
- struct pib_header pib_header;
- uint32_t offset = 0;
- if (lseek (file->file, 0, SEEK_SET))
- {
- error (1, errno, FILE_CANTHOME, file->name);
- }
- if (read (file->file, &pib_header, sizeof (pib_header)) < sizeof (pib_header))
- {
- error (1, errno, FILE_CANTREAD, file->name);
- }
- if (lseek (file->file, 0, SEEK_SET))
- {
- error (1, errno, FILE_CANTHOME, file->name);
- }
- if (BE16TOH (*(uint16_t *)(&pib_header)) < 0x0305)
- {
- offset = LEGACY_PIBOFFSET;
- }
- else if (BE16TOH (*(uint16_t *)(&pib_header)) < 0x0500)
- {
- offset = INT6x00_PIBOFFSET;
- }
- else
- {
- offset = AR7x00_PIBOFFSET;
- }
- return (offset);
- }
|