- printf ("CRC32 from offset %08X to %08X of environment = %08X\n",
- (unsigned int) (dataptr - envptr),
- (unsigned int) (dataptr - envptr) + datasize,
- crc);
+ if (!strncmp(argv[1], "--binary", 8)) {
+ int le = (argc > 2 ? !strcmp(argv[2], "le") : 1);
+ size_t i, start, end, step;
+ if (le) {
+ start = 0;
+ end = ENV_HEADER_SIZE;
+ step = 1;
+ } else {
+ start = ENV_HEADER_SIZE - 1;
+ end = -1;
+ step = -1;
+ }
+ for (i = start; i != end; i += step)
+ printf("%c", (crc & (0xFF << (i * 8))) >> (i * 8));
+ if (fwrite(dataptr, 1, datasize, stdout) != datasize)
+ fprintf(stderr, "fwrite() failed: %s\n", strerror(errno));
+ } else {
+ printf("CRC32 from offset %08X to %08X of environment = %08X\n",
+ (unsigned int) (dataptr - envptr),
+ (unsigned int) (dataptr - envptr) + datasize,
+ crc);
+ }