Add virtual file I/O interface.
[bertos.git] / mware / kfile.h
1 /*!
2  * \file
3  * <!--
4  * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
5  * Copyright 1999, 2000, 2001, 2003 Bernardo Innocenti <bernie@develer.com>
6  * This file is part of DevLib - See devlib/README for information.
7  * -->
8  *
9  * \brief Virtual KFile I/O interface.
10  *
11  * \version $Id$
12  * \author Bernardo Innocenti <bernie@develer.com>
13  */
14
15 /*
16  * $Log$
17  * Revision 1.1  2004/08/04 02:40:25  bernie
18  * Add virtual file I/O interface.
19  *
20  */
21 #ifndef MWARE_KFILE_H
22 #define MWARE_KFILE_H
23
24 #include <compiler.h>
25
26 /* fwd decl */
27 struct _KFile;
28
29 typedef size_t  (*ReadFunc_t)   (struct _KFile *fd, char *buf, size_t size);
30 typedef size_t  (*WriteFunc_t)  (struct _KFile *fd, const char *buf, size_t size);
31 typedef bool    (*SeekFunc_t)   (struct _KFile *fd, int32_t offset);
32 typedef bool    (*OpenFunc_t)   (struct _KFile *fd, const char *name, int mode);
33 typedef bool    (*CloseFunc_t)  (struct _KFile *fd);
34
35
36 /* Context data for callback functions which operate on
37  * pseudo files.
38  */
39 typedef struct _KFile
40 {
41         ReadFunc_t              read;
42         WriteFunc_t             write;
43         SeekFunc_t              seek;
44         OpenFunc_t              open;
45         CloseFunc_t             close;
46
47         /* NOTE: these must _NOT_ be size_t on 16bit CPUs! */
48         uint32_t                SeekPos;
49         uint32_t                Size;
50 } KFile;
51
52 #endif /* MWARE_KFILE_H */