30 fprintf(stderr,
"ERROR: %s\n", why);
35 main(
int argc,
char *argv[])
44 fail(
"missing EEPROM file name");
46 if (
NULL == (fp =
fopen(argv[1],
"rb"))) {
47 fail(
"can't open EEPROM file");
50 fail(
"can't read EEPROM file");
56 fail(
"bad magic in EEPROM file");
59 fail(
"unsupported EEPROM format revision");
63 index =
sizeof(*header);
67 printf(
"end sentinel at %u\n", index);
70 printf(
"%04x: key %u size %d\n ", index, var->
key, var->
size + 1);
71 index +=
sizeof(*var);
72 for (i = 0; i <= var->
size; i++) {
76 index += var->
size + 1;
77 if (index >=
sizeof(
eeprom)) {
79 fail(
"missing end sentinel");
int printf(const char *fmt,...)
void fail(const char *why)
static const uint16_t k_EEPROM_magic
static const uint8_t k_key_sentinel
static const uint16_t k_EEPROM_revision
FILE * fopen(const char *path, const char *mode)
POSIX Open a file with path name and ascii file mode string.
int main(int argc, char *argv[])
int fprintf(FILE *fp, const char *fmt,...)
fprintf character write function