From: batt Date: Sun, 27 Sep 2009 13:21:27 +0000 (+0000) Subject: Add KFile base class constructor. X-Git-Tag: 2.3.0~105 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=97b217a3c33051e68cc0c77374d543e2d5903fcc;p=bertos.git Add KFile base class constructor. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2975 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/kern/kfile.c b/bertos/kern/kfile.c index 81cd9d0a..d98f1548 100644 --- a/bertos/kern/kfile.c +++ b/bertos/kern/kfile.c @@ -255,4 +255,30 @@ void kfile_resync(KFile *fd, mtime_t delay) } } +/** + * Stub function that does nothing. + * This is a generic implementation that only return 0. + */ +static int kfile_generic(UNUSED_ARG(struct KFile *, fd)) +{ + return 0; +}; + + +/** + * Base class KFile constructor. + */ +void kfile_init(struct KFile *fd) +{ + ASSERT(fd); + memset(fd, 0, sizeof(*fd)); + fd->clearerr = (ClearErrFunc_t)kfile_generic; + fd->close = kfile_genericClose; + fd->error = kfile_generic; + fd->flush = kfile_generic; + fd->read = (ReadFunc_t)kfile_generic; + fd->reopen = kfile_genericReopen; + fd->seek = kfile_genericSeek; + fd->write = (WriteFunc_t)kfile_generic; +} diff --git a/bertos/kern/kfile.h b/bertos/kern/kfile.h index 10f98ef1..44c32b06 100644 --- a/bertos/kern/kfile.h +++ b/bertos/kern/kfile.h @@ -221,6 +221,7 @@ int kfile_print(struct KFile *fd, const char *s); int kfile_gets(struct KFile *fd, char *buf, int size); int kfile_gets_echo(struct KFile *fd, char *buf, int size, bool echo); void kfile_resync(KFile *fd, mtime_t delay); +void kfile_init(struct KFile *fd); /** * Interface functions for KFile access. @@ -284,4 +285,5 @@ int kfile_testRun(void); int kfile_testRunGeneric(KFile *fd, uint8_t *test_buf, uint8_t *save_buf, size_t size); int kfile_testTearDown(void); + #endif /* KERN_KFILE_H */