CT_NODISCARD STA_WRITES(size) void *dst
os_protect_t
file mapping memory protection
os_access_t
file access mode
#define CT_PUREFN
mark a function as pure, always returns the same value for the same arguments
#define IN_NOTNULL
annotate a parameter as not being null
#define STA_READS(size)
annotate a parameter as reading expr elements
#define IN_STRING
annotate a parameter as being a null terminated string
size_t(* io_fwrite_t)(io_t *self, const char *fmt, va_list args)
io write format callback seperate from io_write_t to allow for more efficient implementations if this...
size_t(* io_seek_t)(io_t *self, size_t offset)
io seek callback seek from start callback
CT_PUREFN CT_IO_API void * io_data(io_t *io)
get the user data from an io object
size_t(* io_read_t)(io_t *self, void *dst, size_t size)
io object read callback
void *(* io_map_t)(io_t *self, os_protect_t protect)
io map callback map an io objects backing data into memory
CT_IO_API io_t * io_init(STA_WRITES(sizeof(io_t)+cb->size) void *buffer, const io_callbacks_t *cb, os_access_t flags, const char *name, STA_READS(cb->size) const void *data, arena_t *arena)
initialize an IO object for a given interface
size_t(* io_write_t)(io_t *self, const void *src, size_t size)
io write callback
os_error_t(* io_close_t)(io_t *self)
io close callback destroy an io objects backing data and any associated resources
typedefCT_BEGIN_API struct io_t io_t
an io object
CT_IO_API io_t * io_new(const io_callbacks_t *cb, os_access_t flags, const char *name, STA_READS(cb->size) const void *data, arena_t *arena)
create a new IO object for a given interface
size_t(* io_size_t)(io_t *self)
io size callback get the total size of an io objects backing data
CT_NODISCARD STA_FORMAT_STRING const char * fmt
io_seek_t fn_seek
absolute seek callback must always be provided
io_map_t fn_map
file map callback must always be provided
io_close_t fn_close
close callback optional if backing data does not require lifetime management
io_read_t fn_read
read callback may be NULL on non-readable objects
io_size_t fn_get_size
total size callback must always be provided
size_t size
the size of the io objects private data
io_write_t fn_write
write callback may be NULL on non-writable objects
io_fwrite_t fn_fwrite
write format callback may be NULL on non-writable objects
char data[]
user data region
arena_t * arena
the arena this object was allocated from
const char * name
the name of this object
os_error_t error
the last error set on this object
const io_callbacks_t * cb
callback struct
os_access_t flags
the access flags for this object