summaryrefslogtreecommitdiff
path: root/src/runtime/c/gu/in.c
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2013-09-05 11:20:39 +0000
committerkr.angelov <kr.angelov@gmail.com>2013-09-05 11:20:39 +0000
commit7c0bad50921365746ea362710015853a4879c0a7 (patch)
treeead13c32a5b2d8ed2968bcdc5b58e5e7eed79720 /src/runtime/c/gu/in.c
parent504341dfbafdcd858704350162bb7e233cf6daf2 (diff)
remove the read and write modules from libgu. this simplifies the i/o layer
Diffstat (limited to 'src/runtime/c/gu/in.c')
-rw-r--r--src/runtime/c/gu/in.c57
1 files changed, 7 insertions, 50 deletions
diff --git a/src/runtime/c/gu/in.c b/src/runtime/c/gu/in.c
index 726eab266..31a72bf96 100644
--- a/src/runtime/c/gu/in.c
+++ b/src/runtime/c/gu/in.c
@@ -255,66 +255,23 @@ gu_in_fini(GuFinalizer* fin)
gu_pool_free(pool);
}
-GuIn
-gu_init_in(GuInStream* stream)
-{
- return (GuIn) {
- .buf_end = NULL,
- .buf_curr = 0,
- .buf_size = 0,
- .stream = stream,
- .fini.fn = gu_in_fini
- };
-}
-
GuIn*
gu_new_in(GuInStream* stream, GuPool* pool)
{
+ gu_require(stream != NULL);
+
GuIn* in = gu_new(GuIn, pool);
- *in = gu_init_in(stream);
+ in->buf_end = NULL;
+ in->buf_curr = 0;
+ in->buf_size = 0;
+ in->stream = stream;
+ in->fini.fn = gu_in_fini;
return in;
}
typedef struct GuProxyInStream GuProxyInStream;
-struct GuProxyInStream {
- GuInStream stream;
- GuIn* real_in;
-};
-
-static const uint8_t*
-gu_proxy_in_begin_buffer(GuInStream* self, size_t* sz_out, GuExn* err)
-{
- GuProxyInStream* pis = gu_container(self, GuProxyInStream, stream);
- return gu_in_begin_span(pis->real_in, sz_out, err);
-}
-
-static void
-gu_proxy_in_end_buffer(GuInStream* self, size_t sz, GuExn* err)
-{
- GuProxyInStream* pis = gu_container(self, GuProxyInStream, stream);
- gu_in_end_span(pis->real_in, sz);
-}
-
-static size_t
-gu_proxy_in_input(GuInStream* self, uint8_t* dst, size_t sz, GuExn* err)
-{
- GuProxyInStream* pis = gu_container(self, GuProxyInStream, stream);
- return gu_in_some(pis->real_in, dst, sz, err);
-}
-
-GuInStream*
-gu_in_proxy_stream(GuIn* in, GuPool* pool)
-{
- GuProxyInStream* ins = gu_new(GuProxyInStream, pool);
- ins->stream.begin_buffer = gu_proxy_in_begin_buffer;
- ins->stream.end_buffer = gu_proxy_in_end_buffer;
- ins->stream.input = gu_proxy_in_input;
- ins->real_in = in;
- return &ins->stream;
-}
-
enum {
GU_BUFFERED_IN_BUF_SIZE = 4096
};