add a few buffer_init*_forread variants to pretend we have type safety make sure buffer_init_staticcontents handles flushing attempts
33 lines
830 B
Groff
33 lines
830 B
Groff
.TH buffer_init_staticcontents_forread 3
|
|
.SH NAME
|
|
buffer_init_staticcontents_forread \- initialize buffer structure
|
|
.SH SYNTAX
|
|
.B #include <libowfat/buffer.h>
|
|
|
|
void \fBbuffer_init_staticcontents_forread\fR(buffer &\fIb\fR,
|
|
const char* \fIy\fR, size_t \fIylen\fR);
|
|
|
|
.SH DESCRIPTION
|
|
buffer_init_staticcontents_forread sets up a buffer for reading,
|
|
pointing to a pre-filled fixed buffer.
|
|
|
|
This is useful for writing unit tests.
|
|
|
|
.SH EXAMPLE
|
|
#include <libowfat/buffer.h>
|
|
#include <libowfat/open.h>
|
|
|
|
char buf[]="foo\\nbar\\n";
|
|
buffer input;
|
|
|
|
char x;
|
|
buffer_init_staticcontents_forread(&input,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_staticcontents(3)
|