taskfs fix up, minor refactoring
[lunaix-os.git] / lunaix-os / includes / lunaix / fs / twimap.h
index 7adbc535e0212464bba188a487be43bf2de4ab85..465c99fc021a69424fdb8ca9d11fe6d1edead20b 100644 (file)
@@ -3,22 +3,42 @@
 
 #include <lunaix/types.h>
 
-#define twimap_index(twimap, type) ((type)((twimap)->index))
-#define twimap_data(twimap, type) ((type)((twimap)->data))
+#define twimap_index(twimap, type) ((type)__ptr((twimap)->index))
+#define twimap_data(twimap, type) ((type)__ptr((twimap)->data))
 
 extern struct v_file_ops twimap_file_ops;
 
+struct twimap;
+struct twimap_ops
+{
+    void (*read)(struct twimap* mapping);
+    int (*go_next)(struct twimap* mapping);
+    void (*reset)(struct twimap* mapping);
+};
+
 struct twimap
 {
     void* index;
     void* buffer;
     void* data;
     size_t size_acc;
-    void (*read)(struct twimap* mapping);
-    int (*go_next)(struct twimap* mapping);
-    void (*reset)(struct twimap* mapping);
+
+    union {
+        struct {
+            void (*read)(struct twimap* mapping);
+            int (*go_next)(struct twimap* mapping);
+            void (*reset)(struct twimap* mapping);
+        };
+        struct twimap_ops ops;
+    };
 };
 
+void
+__twimap_default_reset(struct twimap* map);
+
+int
+__twimap_default_gonext(struct twimap* map);
+
 int
 twimap_read(struct twimap* map, void* buffer, size_t len, size_t fpos);