Lely core libraries  2.2.5
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 
36 struct __frbuf;
37 #ifndef __cplusplus
38 typedef struct __frbuf frbuf_t;
40 #endif
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 void *__frbuf_alloc(void);
47 void __frbuf_free(void *ptr);
48 struct __frbuf *__frbuf_init(struct __frbuf *buf, const char *filename);
49 void __frbuf_fini(struct __frbuf *buf);
50 
61 frbuf_t *frbuf_create(const char *filename);
62 
69 void frbuf_destroy(frbuf_t *buf);
70 
75 intmax_t frbuf_get_size(frbuf_t *buf);
76 
86 intmax_t frbuf_get_pos(frbuf_t *buf);
87 
98 intmax_t frbuf_set_pos(frbuf_t *buf, intmax_t pos);
99 
113 ssize_t frbuf_read(frbuf_t *buf, void *ptr, size_t size);
114 
130 ssize_t frbuf_pread(frbuf_t *buf, void *ptr, size_t size, intmax_t pos);
131 
150 const void *frbuf_map(frbuf_t *buf, intmax_t pos, size_t *psize);
151 
160 int frbuf_unmap(frbuf_t *buf);
161 
162 #ifdef __cplusplus
163 }
164 #endif
165 
166 #endif // !LELY_UTIL_FRBUF_H_
This header file is part of the C11 and POSIX compatibility library; it includes <sys/types.h>, if it exists, and defines any missing functionality.
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:236
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:301
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:212
frbuf_t * frbuf_create(const char *filename)
Creates a new read file buffer.
Definition: frbuf.c:133
int frbuf_unmap(frbuf_t *buf)
Unmaps the current memory map of a read file buffer, if it exists.
Definition: frbuf.c:507
An read file buffer struct.
Definition: frbuf.c:49
This header file is part of the C11 and POSIX compatibility library; it includes <stddef.h> and defines any missing functionality.
void frbuf_destroy(frbuf_t *buf)
Destroys a read file buffer.
Definition: frbuf.c:158
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:270
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:167
This header file is part of the C11 and POSIX compatibility library; it includes <stdint.h> and defines any missing functionality.
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:389
This is the public header file of the utilities library.