Lely core libraries 2.3.4
frbuf.h
Go to the documentation of this file.
1
27#ifndef LELY_UTIL_FRBUF_H_
28#define LELY_UTIL_FRBUF_H_
29
30#include <lely/libc/sys/types.h>
31#include <lely/util/util.h>
32
33#include <stddef.h>
34#include <stdint.h>
35
36struct __frbuf;
37#ifndef __cplusplus
39typedef struct __frbuf frbuf_t;
40#endif
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
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);
50
61frbuf_t *frbuf_create(const char *filename);
62
69void frbuf_destroy(frbuf_t *buf);
70
75intmax_t frbuf_get_size(frbuf_t *buf);
76
86intmax_t frbuf_get_pos(frbuf_t *buf);
87
98intmax_t frbuf_set_pos(frbuf_t *buf, intmax_t pos);
99
113ssize_t frbuf_read(frbuf_t *buf, void *ptr, size_t size);
114
130ssize_t frbuf_pread(frbuf_t *buf, void *ptr, size_t size, intmax_t pos);
131
150const void *frbuf_map(frbuf_t *buf, intmax_t pos, size_t *psize);
151
160int frbuf_unmap(frbuf_t *buf);
161
162#ifdef __cplusplus
163}
164#endif
165
166#endif // !LELY_UTIL_FRBUF_H_
int frbuf_unmap(frbuf_t *buf)
Unmaps the current memory map of a read file buffer, if it exists.
Definition: frbuf.c:513
intmax_t frbuf_get_size(frbuf_t *buf)
Returns the size (in bytes) of the a read file buffer, or -1 on error.
Definition: frbuf.c:172
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.
Definition: frbuf.c:394
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.
Definition: frbuf.c:241
void frbuf_destroy(frbuf_t *buf)
Destroys a read file buffer.
Definition: frbuf.c:163
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...
Definition: frbuf.c:217
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.
Definition: frbuf.c:306
frbuf_t * frbuf_create(const char *filename)
Creates a new read file buffer.
Definition: frbuf.c:138
ssize_t frbuf_read(frbuf_t *buf, void *ptr, size_t size)
Reads bytes from the current position in a read file buffer.
Definition: frbuf.c:275
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.
Definition: frbuf.c:52
This header file is part of the C11 and POSIX compatibility library; it includes <sys/types....