buffer - Man Page

generic read/write buffering

Syntax

#include <buffer.h>

 buffer* buffer_0;   /* like stdio's stdin */
 buffer* buffer_1;   /* like stdio's stdout */
 buffer* buffer_2;   /* like stdio's stderr */

Description

buffer.h provides a generic buffer interface that can be used for read and write buffering.  Buffers must be initialized with buffer_init.

A buffer can only be used for reading or writing at the same time, not both.

Unlike stdio, these write buffers are not flushed automatically at program termination; you must manually call buffer_flush, buffer_putsflush, buffer_putflush or buffer_putnlflush.

Example

See buffer_init(3) for example read buffer code.  Here is typical code for printing an error message on stderr:

 #include <buffer.h>

 buffer_puts(buffer_2,"error: got only ");
 buffer_putulong(buffer_2,got);
 buffer_puts(buffer_2," bytes, but expected at least ");
 buffer_putulong(buffer_2,expected);
 buffer_putsflush(buffer_2," bytes!");

See Also

buffer_init(3), buffer_put(3), buffer_get(3), buffer_flush(3)

Referenced By

buffer_feed(3), buffer_fromarray(3), buffer_frombuf(3), buffer_fromsa(3), buffer_get(3), buffer_getc(3), buffer_getline(3), buffer_getline_sa(3), buffer_getn(3), buffer_getnewline_sa(3), buffer_get_new_token_sa(3), buffer_get_new_token_sa_pred(3), buffer_get_token(3), buffer_get_token_pred(3), buffer_get_token_sa(3), buffer_get_token_sa_pred(3), buffer_init(3), buffer_init_free(3), buffer_mmapread(3), buffer_peek(3), buffer_put(3), buffer_put8long(3), buffer_putalign(3), buffer_puterror(3), buffer_puterror2(3), buffer_putflush(3), buffer_putlong(3), buffer_putlonglong(3), buffer_putm(3), buffer_putnlflush(3), buffer_puts(3), buffer_putsa(3), buffer_putsaflush(3), buffer_putsalign(3), buffer_putsflush(3), buffer_putspace(3), buffer_putulong(3), buffer_putulonglong(3), buffer_putxlong(3), buffer_seek(3), buffer_tosa(3).