- Cable driver helper API courtesy of Dick Hollenbeck <dick@softplc.com>
[fw/openocd] / src / helper / fileio.c
index bb10dbd1331f6c9d3b5400d40c50c208fd39f84f..84e1f846e4ba3bdd563de17defa2c103907c4b39 100644 (file)
@@ -2,6 +2,12 @@
  *   Copyright (C) 2007 by Dominic Rath                                    *
  *   Dominic.Rath@gmx.de                                                   *
  *                                                                         *
+ *   Copyright (C) 2007,2008 Ã˜yvind Harboe                                 *
+ *   oyvind.harboe@zylin.com                                               *
+ *                                                                         *
+ *   Copyright (C) 2008 by Spencer Oliver                                  *
+ *   spen@spen-soft.co.uk                                                  *
+ *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
@@ -62,7 +68,7 @@ int fileio_open_local(fileio_t *fileio)
                        strcpy(access, "a+");   
                        break;
                default:
-                       ERROR("BUG: access neither read, write nor readwrite");
+                       LOG_ERROR("BUG: access neither read, write nor readwrite");
                        return ERROR_INVALID_ARGUMENTS;
        }
        
@@ -76,7 +82,7 @@ int fileio_open_local(fileio_t *fileio)
        
        if (!(fileio->file = open_file_from_path (fileio->url, access)))
        {
-               ERROR("couldn't open %s", fileio->url);
+               LOG_ERROR("couldn't open %s", fileio->url);
                return ERROR_FILEIO_OPERATION_FAILED;
        }
        
@@ -127,11 +133,11 @@ int fileio_close_local(fileio_t *fileio)
        {
                if (retval == EBADF)
                {
-                       ERROR("BUG: fileio_local->file not a valid file descriptor");
+                       LOG_ERROR("BUG: fileio_local->file not a valid file descriptor");
                }
                else
                {
-                       ERROR("couldn't close %s: %s", fileio->url, strerror(errno));
+                       LOG_ERROR("couldn't close %s: %s", fileio->url, strerror(errno));
                }
 
                return ERROR_FILEIO_OPERATION_FAILED;
@@ -157,7 +163,7 @@ int fileio_seek(fileio_t *fileio, u32 position)
        int retval;
        if ((retval = fseek(fileio->file, position, SEEK_SET)) != 0)
        {
-               ERROR("couldn't seek file %s: %s", fileio->url, strerror(errno));
+               LOG_ERROR("couldn't seek file %s: %s", fileio->url, strerror(errno));
                return ERROR_FILEIO_OPERATION_FAILED;
        }
        
@@ -189,7 +195,7 @@ int fileio_read_u32(fileio_t *fileio, u32 *data)
        return ERROR_OK;
 }
 
-int fileio_local_fgets(fileio_t *fileio, u32 size, u8 *buffer)
+int fileio_local_fgets(fileio_t *fileio, u32 size, char *buffer)
 {
        if( fgets(buffer, size, fileio->file) == NULL)
                return ERROR_FILEIO_OPERATION_FAILED;
@@ -197,7 +203,7 @@ int fileio_local_fgets(fileio_t *fileio, u32 size, u8 *buffer)
        return ERROR_OK;
 }
 
-int fileio_fgets(fileio_t *fileio, u32 size, u8 *buffer)
+int fileio_fgets(fileio_t *fileio, u32 size, char *buffer)
 {
        return fileio_local_fgets(fileio, size, buffer);
 }