summaryrefslogtreecommitdiff
path: root/kit/input_buffer.h
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2024-07-14 21:12:37 +0200
committerMitya Selivanov <automainint@guattari.tech>2024-07-14 21:12:37 +0200
commit30740ca4131d1f574718262451b4410207dc8d4e (patch)
treefc88b16a216079397ad85b9c6b1a1c1c5712a814 /kit/input_buffer.h
parent5e3c99bb1cf1d03ea006300121265571f5008fd2 (diff)
downloadsaw-30740ca4131d1f574718262451b4410207dc8d4e.zip
Reworking the build system
Diffstat (limited to 'kit/input_buffer.h')
-rw-r--r--kit/input_buffer.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/kit/input_buffer.h b/kit/input_buffer.h
new file mode 100644
index 0000000..2a490c0
--- /dev/null
+++ b/kit/input_buffer.h
@@ -0,0 +1,66 @@
+#ifndef KIT_INPUT_BUFFER_H
+#define KIT_INPUT_BUFFER_H
+
+#include "string_builder.h"
+#include "input_stream.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ kit_is_handle_t upstream;
+ kit_str_builder_t data;
+} kit_input_buffer_t;
+
+typedef struct {
+ s32 status;
+ i64 offset;
+ i64 size;
+ kit_input_buffer_t *buffer;
+} kit_ib_token_t;
+
+typedef b8 (*kit_ib_read_condition_fn)(kit_str_t data, void *context);
+
+kit_input_buffer_t kit_ib_init(kit_is_handle_t upstream,
+ kit_allocator_t *alloc);
+
+void kit_ib_destroy(kit_input_buffer_t *buf);
+
+kit_ib_token_t kit_ib_token(kit_input_buffer_t *buf);
+
+kit_str_t kit_ib_str(kit_ib_token_t tok);
+
+kit_ib_token_t kit_ib_read(kit_ib_token_t tok, i64 size);
+
+kit_ib_token_t kit_ib_any(kit_ib_token_t tok, kit_str_t data);
+
+kit_ib_token_t kit_ib_none(kit_ib_token_t tok, kit_str_t data);
+
+kit_ib_token_t kit_ib_exact(kit_ib_token_t tok, kit_str_t data);
+
+kit_ib_token_t kit_ib_until(kit_ib_token_t tok, kit_str_t data);
+
+kit_ib_token_t kit_ib_while(kit_ib_token_t buf,
+ kit_ib_read_condition_fn condition,
+ void *context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#define input_buffer_t kit_input_buffer_t
+#define ib_token_t kit_ib_token_t
+#define ib_read_condition_fn kit_ib_read_condition_fn
+#define ib_init kit_ib_init
+#define ib_destroy kit_ib_destroy
+#define ib_token kit_ib_token
+#define ib_str kit_ib_str
+#define ib_read kit_ib_read
+#define ib_any kit_ib_any
+#define ib_none kit_ib_none
+#define ib_exact kit_ib_exact
+#define ib_until kit_ib_until
+#define ib_while kit_ib_while
+
+#endif