#include #include #include "hexdump.h" static unsigned char chk(unsigned char *buf, int len) { int i; unsigned char r = 0; for (i=0; i bufsize) { fprintf(stderr, "hex file too large\n"); ret = -6; goto err; } if (address + data_count > max_address) { max_address = address + data_count; } memcpy(dstbuf + address, databuf + 4, data_count); break; case 0x01: // EOF eof_seen = 1; break; default: case 0x02: // Extended segment address case 0x03: // Start segment address case 0x04: // Extended linear address case 0x05: // Start linear address fprintf(stderr, "ihex parser: Unimplemented record type 0x%02x\n", databuf[3]); ret = -2; goto err; } } } while (!feof(fptr)); return max_address; err: fclose(fptr); return ret; }