Framework for exporting system header to user space (#59)
[lunaix-os.git] / lunaix-os / includes / lunaix / fs / twimap.h
1 #ifndef __LUNAIX_TWIMAP_H
2 #define __LUNAIX_TWIMAP_H
3
4 #include <lunaix/types.h>
5
6 #define twimap_index(twimap, type) ((type)__ptr((twimap)->index))
7 #define twimap_data(twimap, type) ((type)__ptr((twimap)->data))
8
9 extern struct v_file_ops twimap_file_ops;
10
11 #define __TWIMAP_OPS    \
12         void (*read)(struct twimap* mapping);   \
13         int (*go_next)(struct twimap* mapping); \
14         void (*reset)(struct twimap* mapping);
15
16 struct twimap;
17 struct twimap_ops
18 {
19     __TWIMAP_OPS
20 };
21
22 struct twimap
23 {
24     void* index;
25     void* buffer;
26     void* data;
27     size_t size_acc;
28     union
29     {
30         struct twimap_ops ops;
31         struct { __TWIMAP_OPS };
32     };
33     
34 };
35
36 int
37 twimap_read(struct twimap* map, void* buffer, size_t len, size_t fpos);
38
39 void
40 twimap_printf(struct twimap* mapping, const char* fmt, ...);
41
42 int
43 twimap_memcpy(struct twimap* mapping, const void* src, const size_t len);
44
45 int
46 twimap_memappend(struct twimap* mapping, const void* src, const size_t len);
47
48 struct twimap*
49 twimap_create(void* data);
50
51 #endif /* __LUNAIX_TWIMAP_H */