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 
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_
frbuf_pread
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_read
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
types.h
frbuf_create
frbuf_t * frbuf_create(const char *filename)
Creates a new read file buffer.
Definition: frbuf.c:138
util.h
frbuf_map
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
frbuf_unmap
int frbuf_unmap(frbuf_t *buf)
Unmaps the current memory map of a read file buffer, if it exists.
Definition: frbuf.c:513
frbuf_destroy
void frbuf_destroy(frbuf_t *buf)
Destroys a read file buffer.
Definition: frbuf.c:163
frbuf_get_size
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
frbuf_set_pos
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
__frbuf
An read file buffer struct.
Definition: frbuf.c:52
stdint.h
frbuf_get_pos
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
stddef.h