bufput(3) buffer handling functions for soldout

Other Alias

soldout_buffer, bufcasecmp, bufcmp, bufcmps, bufdup, bufgrow, bufnew, bufnullterm, bufprintf, bufputs, bufputc, bufrelease, bufreset, bufset, bufslurp, buftoi, vbufprintf

SYNOPSIS

In buffer.h

Fd #define CONST_BUF(name, string) Fd #define VOLATILE_BUF(name, strname) Fd #define BUFPUTSL(output, literal) Ft int Fo bufcasecmp Fa const struct buf *a Fa const struct buf *b Fc Ft int Fo bufcmp Fa const struct buf *a Fa const struct buf *b Fc Ft int Fo bufcmps Fa const struct buf *a Fa const char *b Fc Ft struct buf * Fo bufdup Fa const struct buf *src Fa size_t dupunit Fc Ft int Fo bufgrow Fa struct buf *buf Fa size_t sz Fc Ft struct buf * Fo bufnew Fa size_t unit Fc Ft void Fo bufnullterm Fa struct buf *buf Fc Ft void Fo bufprintf Fa struct buf *buf Fa const char *fmt Fa ... Fc Ft void Fo bufput Fa struct buf *buf Fa const void *data Fa size_t len Fc Ft void Fo bufputs Fa struct buf *buf Fa const char *str Fc Ft void Fo bufputc Fa struct buf *buf Fa char c Fc Ft void Fo bufrelease Fa struct buf *buf Fc Ft void Fo bufreset Fa struct buf *buf Fc Ft void Fo bufset Fa struct buf **dest Fa struct buf *src Fc Ft void Fo bufslurp Fa struct buf *buf Fa size_t len Fc Ft int Fo buftoi Fa struct buf *buf Fa size_t offset_i Fa size_t *offset_o Fc Ft void Fo vbufprintf Fa struct buf *buf Fa const char *fmt Fa va_list ap Fc Vt extern long buffer_stat_nb; Vt extern size_t buffer_stat_alloc_bytes;

DESCRIPTION

Variables

Compile time options. Statistics are kept about memory usage.

buffer_stat_nb
show how many buffers were created.
buffer_stat_alloc_bytes
show how many bytes were allocated.

Types

Vt struct buf
character array buffer. Consists of the following fields:

Vt char * data
actual character data.
Vt size_t size
size of the string.
Vt size_t asize
allocated size (0 = volatile buffer)
Vt size_t unit
reallocation unit size (0 = read-only buffer)
Vt int ref
reference count.

Macros

CONST_BUF
create a global buffer name from a string literal string
VOLATILE_BUF
create a volatile buffer name on the stack from a string strname
BUFPUTSL
optimized Fn bufputs of a string literal.

Functions

Fn bufcasecmp
compare two buffers ignoring case.
Fn bufcmp
compare two buffers.
Fn bufcmps
compare a buffer to a string.
Fn bufdup
duplicate a buffer src
Fn bufgrow
increase the allocated size to the given value.
Fn bufnew
create a new buffer.
Fn bufnullterm
terminate the string array by NUL (making a C-string)
Fn bufprintf
print formatted output to a buffer buf
Fn bufput
append raw data to a buffer buf
Fn bufputs
append a NUL-terminated string str to a buffer buf
Fn bufputc
append a single char c to a buffer buf
Fn bufrelease
decrease the reference count and free the buffer buf if needed.
Fn bufreset
free internal data of the buffer buf
Fn bufset
safely assign a buffer to another.
Fn bufslurp
remove a given number of bytes from the head of the array.
Fn buftoi
convert the numbers at the beginning of the buffer buf into an Vt int .
Fn vbufprintf
stdarg(3) variant of formatted printing into a buffer buf

RETURN VALUES

The Fn bufcasecmp , Fn bufcmp and Fn bufcmps functions return an integer less than, equal to, or greater than zero if a is found, respectively, to be less than, to match, or be greater than b

The Fn bufdup and Fn bufnew functions return a Vt struct buf * on success; on error they return NULL

The Fn bufgrow function returns on success 1; on error - 0.

The Fn bufnullterm , Fn bufprintf , Fn bufput , Fn bufputs , Fn bufputc , Fn bufrelease , Fn bufreset , Fn bufset , Fn bufslurp and Fn vbufprintf functions do not return a value.

The Fn buftoi function return the converted value.

AUTHORS

An -nosplit The soldout library was written by An Natasha Qo Kerensikova Qc Porte Aq Mt [email protected] . Manual page was originally written by An Massimo Manghi Aq Mt [email protected] , and rewritten to mdoc format by An Svyatoslav Mishyn Aq Mt [email protected] .