27#ifndef LELY_UTIL_FRBUF_H_
28#define LELY_UTIL_FRBUF_H_
46void *__frbuf_alloc(
void);
47void __frbuf_free(
void *ptr);
48struct __frbuf *__frbuf_init(
struct __frbuf *buf,
const char *filename);
49void __frbuf_fini(
struct __frbuf *buf);
int frbuf_unmap(frbuf_t *buf)
Unmaps the current memory map of a read file buffer, if it exists.
intmax_t frbuf_get_size(frbuf_t *buf)
Returns the size (in bytes) of the a read file buffer, or -1 on error.
const void * frbuf_map(frbuf_t *buf, intmax_t pos, size_t *psize)
Maps (part of) the contents of a read file buffer to memory.
intmax_t frbuf_set_pos(frbuf_t *buf, intmax_t pos)
Sets the current offset (in bytes) of a read file buffer with respect to the beginning of the file.
void frbuf_destroy(frbuf_t *buf)
Destroys a read file buffer.
intmax_t frbuf_get_pos(frbuf_t *buf)
Returns the current offset (in bytes) of a read file buffer with respect to the beginning of the file...
ssize_t frbuf_pread(frbuf_t *buf, void *ptr, size_t size, intmax_t pos)
Reads bytes from the specified position in a read file buffer.
frbuf_t * frbuf_create(const char *filename)
Creates a new read file buffer.
ssize_t frbuf_read(frbuf_t *buf, void *ptr, size_t size)
Reads bytes from the current position in a read file buffer.
This is the public header file of the utilities library.
This header file is part of the C11 and POSIX compatibility library; it includes <stddef....
This header file is part of the C11 and POSIX compatibility library; it includes <stdint....
An read file buffer struct.
This header file is part of the C11 and POSIX compatibility library; it includes <sys/types....
ptrdiff_t ssize_t
Used for a count of bytes or an error indication.