From 995326b6000773efd454e308d487dec0b9f564b5 Mon Sep 17 00:00:00 2001 From: ntfreak Date: Mon, 1 Oct 2007 08:31:30 +0000 Subject: - flash autoerase cmd added, default is off - flash banks are calculated and erased prior to write (flash write_image only) - corrected array overrun in armv7m.c - corrected breakpoint memory allocation bug - image read now uses fgets, vastly improves reading of large files - improved hex file reading, support for Linear Address Record added git-svn-id: svn://svn.berlios.de/openocd/trunk@208 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/helper/fileio.c | 23 +++++++++++++++++++++++ src/helper/fileio.h | 1 + 2 files changed, 24 insertions(+) (limited to 'src/helper') diff --git a/src/helper/fileio.c b/src/helper/fileio.c index b0ad446e..3ee0b18b 100644 --- a/src/helper/fileio.c +++ b/src/helper/fileio.c @@ -284,6 +284,29 @@ int fileio_read_u32(fileio_t *fileio, u32 *data) return ERROR_OK; } +int fileio_local_fgets(fileio_t *fileio, u32 size, u8 *buffer) +{ + fileio_local_t *fileio_local = fileio->location_private; + + if( fgets(buffer, size, fileio_local->file) == NULL) + return ERROR_FILEIO_OPERATION_FAILED; + + return ERROR_OK; +} + +int fileio_fgets(fileio_t *fileio, u32 size, u8 *buffer) +{ + switch (fileio->location) + { + case FILEIO_LOCAL: + return fileio_local_fgets(fileio, size, buffer); + break; + default: + ERROR("BUG: should never get here"); + exit(-1); + } +} + int fileio_local_write(fileio_t *fileio, u32 size, u8 *buffer, u32 *size_written) { fileio_local_t *fileio_local = fileio->location_private; diff --git a/src/helper/fileio.h b/src/helper/fileio.h index 5c0a88da..20e5c629 100644 --- a/src/helper/fileio.h +++ b/src/helper/fileio.h @@ -79,6 +79,7 @@ typedef struct fileio_local_s extern int fileio_write(fileio_t *fileio, u32 size, u8 *buffer, u32 *size_written); extern int fileio_read(fileio_t *fileio, u32 size, u8 *buffer, u32 *size_read); +extern int fileio_fgets(fileio_t *fileio, u32 size, u8 *buffer); extern int fileio_seek(fileio_t *fileio, u32 position); extern int fileio_close(fileio_t *fileio); extern int fileio_open(fileio_t *fileio, char *url, enum fileio_access access, enum fileio_type type); -- cgit v1.2.3