#include <stdio.h>
#include <ctype.h>
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#include "hexfile.h"
Go to the source code of this file.
Functions | |
int | read_hex_file (FILE *fp, int crc, unsigned char *buf, unsigned buf_size, unsigned *low_addr, unsigned *high_addr) |
int read_hex_file | ( | FILE * | fp, |
int | crc, | ||
unsigned char * | buf, | ||
unsigned | buf_size, | ||
unsigned * | low_addr, | ||
unsigned * | high_addr | ||
) |
Definition at line 74 of file hexfile.c.
{ int res, lcount, err; char line[1000]; lcount = 0; err = 0; while (!feof(fp) && !ferror(fp)) { fgets(line, 1000, fp); lcount++; if ((res = read_hex_line(line, buf, buf_size, low_addr, high_addr)) != NO_ERR) { switch(res) { case ERR_CRC: if (crc == 1) { fprintf(stderr, "ERROR: Checksum error on line %d\n", lcount); err = res;; } break; case ERR_ADDR: fprintf(stderr, "ERROR: Hex file contents does not fit into flash\n"); return res; case ERR_FMT: fprintf(stderr, "ERROR: Invalid Intel hex format on line %d\n", lcount); return res; } } } return err; }