12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #ifndef MODULESPEC_SOURCE
- #define MODULESPEC_SOURCE
- #include "../tools/error.h"
- #include "../tools/files.h"
- #include "../plc/plc.h"
- signed ModuleSpec (struct _file_ * file, struct vs_module_spec * spec)
- {
- off_t length;
- if ((length = lseek (file->file, 0, SEEK_END)) == -1)
- {
- error (1, errno, FILE_CANTSIZE, file->name);
- }
- #if 1
- if (length % sizeof (uint32_t))
- {
- error (1, ENOTSUP, "%s not multiple of " SIZE_T_SPEC " bytes", file->name, sizeof (uint32_t));
- }
- #endif
- if (lseek (file->file, 0, SEEK_SET))
- {
- error (1, errno, FILE_CANTHOME, file->name);
- }
- spec->MODULE_LENGTH = length;
- spec->MODULE_CHKSUM = fdchecksum32 (file->file, length, 0);
- if (lseek (file->file, 0, SEEK_SET))
- {
- error (1, errno, FILE_CANTHOME, file->name);
- }
- return (0);
- }
- #endif
|