NAME
soldout_buffer, bufcasecmp, bufcmp, bufcmps, bufdup, bufgrow, bufnew, bufnullterm, bufprintf, bufput, bufputs, bufputc, bufrelease, bufreset, bufset, bufslurp, buftoi, vbufprintf – buffer handling functions for soldout
SYNOPSIS
#include <buffer.h>
#define CONST_BUF(name, string)
#define VOLATILE_BUF(name, strname)
#define BUFPUTSL(output, literal)
int
bufcasecmp(const struct buf *a, const struct buf *b);
int
bufcmp(const struct buf *a, const struct buf *b);
int
bufcmps(const struct buf *a, const char *b);
struct buf *
bufdup(const struct buf *src, size_t dupunit);
int
bufgrow(struct buf *buf, size_t sz);
struct buf *
bufnew(size_t unit);
void
bufnullterm(struct buf *buf);
void
bufprintf(struct buf *buf, const char *fmt, ...);
void
bufput(struct buf *buf, const void *data, size_t len);
void
bufputs(struct buf *buf, const char *str);
void
bufputc(struct buf *buf, char c);
void
bufrelease(struct buf *buf);
void
bufreset(struct buf *buf);
void
bufset(struct buf **dest, struct buf *src);
void
bufslurp(struct buf *buf, size_t len);
int
buftoi(struct buf *buf, size_t offset_i, size_t *offset_o);
void
vbufprintf(struct buf *buf, const char *fmt, va_list ap);
extern long buffer_stat_nb; 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
- struct buf
-
character array buffer. Consists of the following fields:
- char * data
-
actual character data.
- size_t size
-
size of the string.
- size_t asize
-
allocated size (0 = volatile buffer).
- size_t unit
-
reallocation unit size (0 = read-only buffer).
- 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 bufputs() of a string literal.
Functions
- bufcasecmp()
-
compare two buffers ignoring case.
- bufcmp()
-
compare two buffers.
- bufcmps()
-
compare a buffer to a string.
- bufdup()
-
duplicate a buffer src.
- bufgrow()
-
increase the allocated size to the given value.
- bufnew()
-
create a new buffer.
- bufnullterm()
-
terminate the string array by NUL (making a C-string).
- bufprintf()
-
print formatted output to a buffer buf.
- bufput()
-
append raw data to a buffer buf.
- bufputs()
-
append a NUL-terminated string str to a buffer buf.
- bufputc()
-
append a single char c to a buffer buf.
- bufrelease()
-
decrease the reference count and free the buffer buf if needed.
- bufreset()
-
free internal data of the buffer buf.
- bufset()
-
safely assign a buffer to another.
- bufslurp()
-
remove a given number of bytes from the head of the array.
- buftoi()
-
convert the numbers at the beginning of the buffer buf into an int.
- vbufprintf()
-
stdarg(3) variant of formatted printing into a buffer buf.
RETURN VALUES
The bufcasecmp(), bufcmp() and 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 bufdup() and bufnew() functions return a struct buf * on success; on error they return NULL.
The bufgrow() function returns on success 1; on error - 0.
The bufnullterm(), bufprintf(), bufput(), bufputs(), bufputc(), bufrelease(), bufreset(), bufset(), bufslurp() and vbufprintf() functions do not return a value.
The buftoi() function return the converted value.
SEE ALSO
AUTHORS
The soldout library was written by Natasha "Kerensikova" Porte ⟨[email protected]⟩. Manual page was originally written by Massimo Manghi ⟨[email protected]⟩, and rewritten to mdoc format by Svyatoslav Mishyn ⟨[email protected]⟩.