forked from GitHub/gf-core
remove the read and write modules from libgu. this simplifies the i/o layer
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user