Comply all functions and types to new name.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 4 Aug 2010 14:04:41 +0000 (14:04 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 4 Aug 2010 14:04:41 +0000 (14:04 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4142 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/io/kblock_posix.c
bertos/io/kblock_posix.h

index cd18431d101c6b141804d0651a721d2f05efa7b2..57c2ee8c7838a5218e81ef75c4082239ccf8a285 100644 (file)
  */
 
 
-#include "kblock_file.h"
+#include "kblock_posix.h"
 #include <string.h>
 #include <stdio.h>
 
 
-static int kblockfile_load(KBlock *b, block_idx_t index)
+static int kblockposix_load(KBlock *b, block_idx_t index)
 {
-       KBlockFile *f = KBLOCKFILE_CAST(b);
+       KBlockPosix *f = KBLOCKPOSIX_CAST(b);
        fseek(f->fp, index * b->blk_size, SEEK_SET);
        return (fread(f->b.priv.buf, 1, b->blk_size, f->fp) == b->blk_size) ? 0 : EOF;
 }
 
-static int kblockfile_store(struct KBlock *b, block_idx_t index)
+static int kblockposix_store(struct KBlock *b, block_idx_t index)
 {
-       KBlockFile *f = KBLOCKFILE_CAST(b);
+       KBlockPosix *f = kblockposix_CAST(b);
        fseek(f->fp, index * b->blk_size, SEEK_SET);
        return (fwrite(f->b.priv.buf, 1, b->blk_size, f->fp) == b->blk_size) ? 0 : EOF;
 }
 
-static size_t kblockfile_readBuf(struct KBlock *b, void *buf, size_t offset, size_t size)
+static size_t kblockposix_readBuf(struct KBlock *b, void *buf, size_t offset, size_t size)
 {
-       KBlockFile *f = KBLOCKFILE_CAST(b);
+       KBlockPosix *f = KBLOCKPOSIX_CAST(b);
        memcpy(buf, (uint8_t *)f->b.priv.buf + offset, size);
        return size;
 }
 
-static size_t kblockfile_readDirect(struct KBlock *b, block_idx_t index, void *buf, size_t offset, size_t size)
+static size_t kblockposix_readDirect(struct KBlock *b, block_idx_t index, void *buf, size_t offset, size_t size)
 {
-       KBlockFile *f = KBLOCKFILE_CAST(b);
+       KBlockPosix *f = KBLOCKPOSIX_CAST(b);
        fseek(f->fp, index * b->blk_size + offset, SEEK_SET);
        return fread(buf, 1, size, f->fp);
 }
 
-static size_t kblockfile_writeBuf(struct KBlock *b, const void *buf, size_t offset, size_t size)
+static size_t kblockposix_writeBuf(struct KBlock *b, const void *buf, size_t offset, size_t size)
 {
-       KBlockFile *f = KBLOCKFILE_CAST(b);
+       KBlockPosix *f = KBLOCKPOSIX_CAST(b);
        memcpy((uint8_t *)f->b.priv.buf + offset, buf, size);
        return size;
 }
 
-static size_t kblockfile_writeDirect(struct KBlock *b, block_idx_t index, const void *buf, size_t offset, size_t size)
+static size_t kblockposix_writeDirect(struct KBlock *b, block_idx_t index, const void *buf, size_t offset, size_t size)
 {
-       KBlockFile *f = KBLOCKFILE_CAST(b);
+       KBlockPosix *f = KBLOCKPOSIX_CAST(b);
        ASSERT(buf);
        ASSERT(index < b->blk_cnt);
        fseek(f->fp, index * b->blk_size + offset, SEEK_SET);
        return fwrite(buf, 1, size, f->fp);
 }
 
-static int kblockfile_error(struct KBlock *b)
+static int kblockposix_error(struct KBlock *b)
 {
-       KBlockFile *f = KBLOCKFILE_CAST(b);
+       KBlockPosix *f = KBLOCKPOSIX_CAST(b);
        return ferror(f->fp);
 }
 
 
-static int kblockfile_claererr(struct KBlock *b)
+static int kblockposix_claererr(struct KBlock *b)
 {
-       KBlockFile *f = KBLOCKFILE_CAST(b);
+       KBlockPosix *f = KBLOCKPOSIX_CAST(b);
        clearerr(f->fp);
        return 0;
 }
 
 
-static int kblockfile_close(struct KBlock *b)
+static int kblockposix_close(struct KBlock *b)
 {
-       KBlockFile *f = KBLOCKFILE_CAST(b);
+       KBlockPosix *f = KBLOCKPOSIX_CAST(b);
 
        return fflush(f->fp) | fclose(f->fp);
 }
 
 
-static const KBlockVTable kblockfile_hwbuffered_vt =
+static const KBlockVTable kblockposix_hwbuffered_vt =
 {
-       .readDirect = kblockfile_readDirect,
+       .readDirect = kblockposix_readDirect,
 
-       .readBuf = kblockfile_readBuf,
-       .writeBuf = kblockfile_writeBuf,
-       .load = kblockfile_load,
-       .store = kblockfile_store,
+       .readBuf = kblockposix_readBuf,
+       .writeBuf = kblockposix_writeBuf,
+       .load = kblockposix_load,
+       .store = kblockposix_store,
 
-       .error = kblockfile_error,
-       .clearerr = kblockfile_claererr,
-       .close = kblockfile_close,
+       .error = kblockposix_error,
+       .clearerr = kblockposix_claererr,
+       .close = kblockposix_close,
 };
 
-static const KBlockVTable kblockfile_swbuffered_vt =
+static const KBlockVTable kblockposix_swbuffered_vt =
 {
-       .readDirect = kblockfile_readDirect,
-       .writeDirect =kblockfile_writeDirect,
+       .readDirect = kblockposix_readDirect,
+       .writeDirect =kblockposix_writeDirect,
 
        .readBuf = kblock_swReadBuf,
        .writeBuf = kblock_swWriteBuf,
        .load = kblock_swLoad,
        .store = kblock_swStore,
 
-       .error = kblockfile_error,
-       .clearerr = kblockfile_claererr,
-       .close = kblockfile_close,
+       .error = kblockposix_error,
+       .clearerr = kblockposix_claererr,
+       .close = kblockposix_close,
 };
 
-static const KBlockVTable kblockfile_unbuffered_vt =
+static const KBlockVTable kblockposix_unbuffered_vt =
 {
-       .readDirect = kblockfile_readDirect,
-       .writeDirect =kblockfile_writeDirect,
+       .readDirect = kblockposix_readDirect,
+       .writeDirect =kblockposix_writeDirect,
 
-       .error = kblockfile_error,
-       .clearerr = kblockfile_claererr,
-       .close = kblockfile_close,
+       .error = kblockposix_error,
+       .clearerr = kblockposix_claererr,
+       .close = kblockposix_close,
 };
 
 
 
-void kblockfile_init(KBlockFile *f, FILE *fp, bool hwbuf, void *buf, size_t block_size, block_idx_t block_count)
+void kblockposix_init(KBlockPosix *f, FILE *fp, bool hwbuf, void *buf, size_t block_size, block_idx_t block_count)
 {
        ASSERT(f);
        ASSERT(fp);
@@ -160,7 +160,7 @@ void kblockfile_init(KBlockFile *f, FILE *fp, bool hwbuf, void *buf, size_t bloc
 
        memset(f, 0, sizeof(*f));
 
-       DB(f->b.priv.type = KBT_KBLOCKFILE);
+       DB(f->b.priv.type = KBT_KBLOCKPOSIX);
 
        f->fp = fp;
        f->b.blk_size = block_size;
@@ -172,12 +172,12 @@ void kblockfile_init(KBlockFile *f, FILE *fp, bool hwbuf, void *buf, size_t bloc
                f->b.priv.flags |= KB_BUFFERED;
                f->b.priv.buf = buf;
                if (hwbuf)
-                       f->b.priv.vt = &kblockfile_hwbuffered_vt;
+                       f->b.priv.vt = &kblockposix_hwbuffered_vt;
                else
-                       f->b.priv.vt = &kblockfile_swbuffered_vt;
-               kblockfile_load(&f->b, 0);
+                       f->b.priv.vt = &kblockposix_swbuffered_vt;
+               kblockposix_load(&f->b, 0);
                f->b.priv.curr_blk = 0;
        }
        else
-               f->b.priv.vt = &kblockfile_unbuffered_vt;
+               f->b.priv.vt = &kblockposix_unbuffered_vt;
 }
index 5cbd5434108f41b143c72b01113a4e50fb7da458..eba541abc6bc32671128d3fab79ae7e62080660e 100644 (file)
 
 #include <stdio.h>
 
-typedef struct KBlockFile
+typedef struct KBlockPosix
 {
        KBlock b;
        FILE *fp;
-} KBlockFile;
+} KBlockPosix;
 
-#define KBT_KBLOCKFILE MAKE_ID('K', 'B', 'F', 'L')
+#define KBT_KBLOCKPOSIX MAKE_ID('K', 'B', 'F', 'L')
 
 
-INLINE KBlockFile *KBLOCKFILE_CAST(KBlock *b)
+INLINE KBlockPosix *KBLOCKPOSIX_CAST(KBlock *b)
 {
-       ASSERT(b->priv.type == KBT_KBLOCKFILE);
-       return (KBlockFile *)b;
+       ASSERT(b->priv.type == KBT_KBLOCKPOSIX);
+       return (KBlockPosix *)b;
 }
 
-void kblockfile_init(KBlockFile *f, FILE *fp, bool hwbuf, void *buf, size_t block_size, block_idx_t block_count);
+void kblockposix_init(KBlockPosix *f, FILE *fp, bool hwbuf, void *buf, size_t block_size, block_idx_t block_count);
 
 #endif /* KBLOCK_POSIX_H */