summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/bridges/README.md8
-rw-r--r--include/bridges/stdio/stream.c17
-rw-r--r--include/bridges/stdio/stream.h8
3 files changed, 33 insertions, 0 deletions
diff --git a/include/bridges/README.md b/include/bridges/README.md
new file mode 100644
index 0000000..02e477f
--- /dev/null
+++ b/include/bridges/README.md
@@ -0,0 +1,8 @@
+# tinyff platform bridges
+
+This folder contains **bridges** that connect tinyff to platform-specific features, like file I/O.
+These files **do not need to be compiled** if you are running tinyff on a freestand environment.
+
+## Structure
+
+`stdio/`: Bridges which use the stdio library
diff --git a/include/bridges/stdio/stream.c b/include/bridges/stdio/stream.c
new file mode 100644
index 0000000..72cee46
--- /dev/null
+++ b/include/bridges/stdio/stream.c
@@ -0,0 +1,17 @@
+#include "../bridges/stdio/stream.h"
+
+size_t ff_file_read(void *ptr, size_t size, void *user)
+{
+ FILE *f = (FILE *)user;
+ return fread(ptr, size, 1, f);
+}
+
+ff_stream ff_create_file_stream(FILE *f)
+{
+ ff_stream stream;
+ stream.read = ff_file_read;
+ stream.user = (void *)f;
+ return stream;
+}
+
+// Memory stream coming soon \ No newline at end of file
diff --git a/include/bridges/stdio/stream.h b/include/bridges/stdio/stream.h
new file mode 100644
index 0000000..1ae2dbc
--- /dev/null
+++ b/include/bridges/stdio/stream.h
@@ -0,0 +1,8 @@
+#include <stdio.h>
+#include <tinyff/stream.h>
+
+// Default reads for common types (just FILE for now, memory later)
+size_t ff_file_read(void *ptr, size_t size, void *user);
+
+// Stream creation helpers
+ff_stream ff_create_file_stream(FILE *f); \ No newline at end of file