18 int32_t (*read)(
void *ctx,
void *buf,
size_t len);
20 int (*seek)(
void *ctx, int64_t offset,
int whence);
21 int64_t (*tell)(
void *ctx);
22 int64_t (*size)(
void *ctx);
23 void (*close)(
void *ctx);
Base definitions shared by every core module: error codes, memory, logging, locks.
int core_stream_read_be24(core_stream_t *s, uint32_t *out)
int core_stream_read_le16(core_stream_t *s, uint16_t *out)
int core_stream_read_le32(core_stream_t *s, uint32_t *out)
core_stream_t * core_stream_create(const core_stream_ops_t *ops, void *ctx)
Wrap custom ops. The stream owns ctx and calls ops->close on core_stream_close.
int core_stream_skip(core_stream_t *s, int64_t bytes)
int core_stream_read_exact(core_stream_t *s, void *buf, size_t len)
Reads exactly len bytes or fails with CORE_EOF / CORE_EIO.
struct core_stream core_stream_t
Definition stream.h:14
int core_stream_read_be64(core_stream_t *s, uint64_t *out)
int core_stream_read_le64(core_stream_t *s, uint64_t *out)
core_stream_t * core_stream_open_memory(const void *data, size_t len, bool take_ownership)
Read-only view of memory. If take_ownership, core_free(data) on close.
int64_t core_stream_tell(core_stream_t *s)
int core_stream_read_u8(core_stream_t *s, uint8_t *out)
Little/big-endian readers. Return CORE_OK or error; value written to *out.
void core_stream_close(core_stream_t *s)
int core_stream_read_be16(core_stream_t *s, uint16_t *out)
int core_stream_seek(core_stream_t *s, int64_t offset, int whence)
core_stream_t * core_stream_open_file(const char *path, size_t buf_size)
Open a file with an internal read buffer of buf_size bytes (0 = default 16 KiB).
int core_stream_read_be32(core_stream_t *s, uint32_t *out)
int32_t core_stream_read(core_stream_t *s, void *buf, size_t len)
int64_t core_stream_size(core_stream_t *s)