add a few buffer_init*_forread variants to pretend we have type safety make sure buffer_init_staticcontents handles flushing attempts
33 lines
757 B
Groff
33 lines
757 B
Groff
.TH buffer_init_read 3
|
|
.SH NAME
|
|
buffer_init_read \- initialize buffer structure
|
|
.SH SYNTAX
|
|
.B #include <libowfat/buffer.h>
|
|
|
|
void \fBbuffer_init_read\fR(buffer &\fIb\fR,
|
|
int \fIfd\fR, char* \fIy\fR, size_t \fIylen\fR);
|
|
|
|
.SH DESCRIPTION
|
|
buffer_init_read is equivalent to calling buffer_init_forread with read(2) as op.
|
|
|
|
.SH EXAMPLE
|
|
#include <libowfat/buffer.h>
|
|
#include <libowfat/open.h>
|
|
|
|
char buf[4096];
|
|
int fd=open_read("/etc/services");
|
|
buffer input;
|
|
|
|
if (fd>=0) {
|
|
char x;
|
|
buffer_init_read(&input,fd,buf,sizeof buf);
|
|
while (buffer_get(&input,&x,1)==1) {
|
|
buffer_put(buffer_1,&x,1);
|
|
if (x=='\\n') break;
|
|
}
|
|
buffer_flush(buffer_1);
|
|
}
|
|
|
|
.SH "SEE ALSO"
|
|
buffer_init(3), buffer(3), buffer_init_write(3)
|