summaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
authorntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2007-10-01 08:31:30 +0000
committerntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2007-10-01 08:31:30 +0000
commit995326b6000773efd454e308d487dec0b9f564b5 (patch)
treeeb60bb8053fdc33aeb6490080a1e4da678dc7014 /src/helper
parented36a8d15dfd04e47d23d5f1e09078f105785fb1 (diff)
downloadopenocd+libswd-995326b6000773efd454e308d487dec0b9f564b5.tar.gz
openocd+libswd-995326b6000773efd454e308d487dec0b9f564b5.tar.bz2
openocd+libswd-995326b6000773efd454e308d487dec0b9f564b5.tar.xz
openocd+libswd-995326b6000773efd454e308d487dec0b9f564b5.zip
- flash autoerase <on|off> 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
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/fileio.c23
-rw-r--r--src/helper/fileio.h1
2 files changed, 24 insertions, 0 deletions
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);