summaryrefslogtreecommitdiff
path: root/source/kit/input_stream.h
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2023-12-29 06:21:33 +0100
committerMitya Selivanov <automainint@guattari.tech>2023-12-29 06:21:33 +0100
commit2d6c8fec45b23a8a28668ecf3ef281139ab778a7 (patch)
tree75d2a8538992129a83c0c2b83688289443d697e5 /source/kit/input_stream.h
parent820b171245f2f14766f3accdb0246a4e2c0d596a (diff)
downloadsaw-2d6c8fec45b23a8a28668ecf3ef281139ab778a7.zip
refactor dependencies; include dependencies source code
Diffstat (limited to 'source/kit/input_stream.h')
-rw-r--r--source/kit/input_stream.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/source/kit/input_stream.h b/source/kit/input_stream.h
new file mode 100644
index 0000000..c60c9e3
--- /dev/null
+++ b/source/kit/input_stream.h
@@ -0,0 +1,50 @@
+#ifndef KIT_INPUT_STREAM_H
+#define KIT_INPUT_STREAM_H
+
+#include "allocator.h"
+#include "string_ref.h"
+
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef i64 (*kit_is_read_fn)(void *state, kit_str_t destination);
+
+typedef struct {
+ void *state;
+ kit_is_read_fn read;
+} kit_is_handle_t;
+
+kit_is_handle_t kit_is_wrap_string(kit_str_t string,
+ kit_allocator_t *alloc);
+
+kit_is_handle_t kit_is_wrap_file(FILE *f, kit_allocator_t *alloc);
+
+void kit_is_destroy(kit_is_handle_t in);
+
+#define KIT_IS_WRAP_STRING(string) kit_is_wrap_string((string), NULL)
+
+#define KIT_IS_WRAP_FILE(f) kit_is_wrap_file((f), NULL)
+
+#define KIT_IS_READ(in, destination) \
+ (in).read((in).state, (destination))
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef KIT_DISABLE_SHORT_NAMES
+# define is_read_fn kit_is_read_fn
+# define is_handle_t kit_is_handle_t
+# define is_wrap_string kit_is_wrap_string
+# define is_wrap_file kit_is_wrap_file
+# define is_destroy kit_is_destroy
+
+# define IS_WRAP_STRING KIT_IS_WRAP_STRING
+# define IS_WRAP_FILE KIT_IS_WRAP_FILE
+# define IS_READ KIT_IS_READ
+#endif
+
+#endif