5 #include <ctu_io_api.h>
CT_NODISCARD STA_WRITES(size) void *dst
os_protect_t
file mapping memory protection
os_access_t
file access mode
#define CT_ALLOC(...)
mark a function as allocating memory
#define STA_RELEASE
annotate a pointer as invalid after the function returns
#define CT_NODISCARD
mark a function as returning a value that must be used
#define STA_PRINTF(a, b)
mark a function as a printf style function
#define IN_NOTNULL
annotate a parameter as not being null
#define STA_FORMAT_STRING
mark a function parameter as a printf format string
#define STA_READS(size)
annotate a parameter as reading expr elements
#define RET_INSPECT
annotate the return value as needing to be inspected this is the same as CT_NODISCARD but implies tha...
#define IN_STRING
annotate a parameter as being a null terminated string
CT_NODISCARD CT_IO_API io_t * io_view_init(STA_WRITES(IO_VIEW_SIZE) void *buffer, const char *name, const void *data, size_t size)
create an io object from a memory buffer initializes an io object using a preallocated buffer.
CT_IO_API os_error_t io_free(STA_RELEASE io_t *io)
destroy an IO object and free its memory
CT_IO_API size_t io_write(io_t *io, STA_READS(size) const void *src, size_t size)
write to an io object
CT_NODISCARD CT_IO_API io_t * io_string_init(STA_WRITES(IO_VIEW_SIZE) void *buffer, const char *name, const char *string)
create an io object from a memory buffer initializes an io object using a preallocated buffer.
CT_NODISCARD CT_IO_API io_t * io_file(const char *path, os_access_t mode, arena_t *arena)
create an IO object from a file
CT_NODISCARD CT_IO_API io_t * io_blob_init(STA_WRITES(IO_BUFFER_SIZE) void *buffer, const char *name, size_t size, os_access_t flags, arena_t *arena)
create an io object from a memory buffer initializes an io object using a preallocated buffer.
CT_NODISCARD CT_IO_API os_error_t io_error(const io_t *io)
get the last error from the io object
CT_NODISCARD CT_IO_API size_t io_seek(io_t *io, size_t offset)
seek to an absolute offset in a file
CT_IO_API size_t io_vprintf(io_t *io, const char *fmt, va_list args)
vprintf to an io object
CT_NODISCARD CT_IO_API io_t * io_view(const char *name, const void *data, size_t size, arena_t *arena)
create a readonly IO object for a given view of memory
CT_NODISCARD CT_IO_API io_t * io_blob(const char *name, size_t size, os_access_t flags, arena_t *arena)
create an IO object in memory of a given size size specifies the initial internal buffer size,...
CT_NODISCARD CT_IO_API io_t * io_file_init(STA_WRITES(IO_FILE_SIZE) void *buffer, const char *path, os_access_t mode)
create an io object from a file initializes an io object using a preallocated buffer.
CT_NODISCARD CT_IO_API io_t * io_string(const char *name, const char *string, arena_t *arena)
create an IO view of a string create a readonly IO view of a string
CT_IO_API os_error_t io_close(INOUT_NOTNULL io_t *io)
destroy an IO object
CT_NODISCARD CT_IO_API io_t * io_memory(const char *name, const void *data, size_t size, os_access_t flags, arena_t *arena)
create an IO object from an initial view of memory
CT_NODISCARD CT_IO_API size_t io_size(io_t *io)
get the total size of an io objects contents
CT_IO_API size_t io_printf(io_t *io, STA_FORMAT_STRING const char *fmt,...)
printf to an io object
CT_NODISCARD CT_IO_API const char * io_name(const io_t *io)
get the name of an io object
CT_IO_API size_t io_read(io_t *io, STA_WRITES(size) void *dst, size_t size)
read from an io object
CT_NODISCARD CT_IO_API void * io_map(io_t *io, os_protect_t protect)
map an io object into memory maps an io objects entire contents into memory.
CT_NODISCARD CT_IO_API io_t * io_memory_init(STA_WRITES(IO_BUFFER_SIZE) void *buffer, const char *name, const void *data, size_t size, os_access_t flags, arena_t *arena)
create an io object from a memory buffer initializes an io object using a preallocated buffer.
CT_NODISCARD STA_FORMAT_STRING const char * fmt
char data[]
user data region
arena_t * arena
the arena this object was allocated from
const char * name
the name of this object
os_access_t flags
the access flags for this object