1buffer_mmapread(3)         Library Functions Manual         buffer_mmapread(3)
2
3
4

NAME

6       buffer_mmapread - create read-only memory-mapped file buffer
7

SYNTAX

9       #include <buffer.h>
10
11       int buffer_mmapread(buffer &b,const char* filename);
12

DESCRIPTION

14       buffer_mmapread opens filename for reading and fills b so that the con‐
15       tents of the file can be read from it.  Using mmap  is  more  efficient
16       than  reading  through a real buffer, but you have to call buffer_close
17       to unmap the memory in the end.
18

EXAMPLE

20         #include <buffer.h>
21         #include <open.h>
22
23         buffer input;
24         char x;
25
26         buffer_mmapread(&input,"/etc/passwd");
27         while (buffer_get(&input,&x,1)==1) {
28           buffer_put(buffer_1,&x,1);
29           if (x=='\n') break;
30         }
31         buffer_flush(buffer_1);
32         buffer_close(&input);
33
34

RETURN VALUE

36       buffer_mmapread returns 0 if everything was fine, -1 on error  (setting
37       errno).
38
39

SEE ALSO

41       buffer_flush(3), buffer(3)
42
43
44
45                                                            buffer_mmapread(3)
Impressum