DOKK / manpages / debian 11 / libsoldout-dev / soldout_buffer.3.en
SOLDOUT_BUFFER(3) Library Functions Manual SOLDOUT_BUFFER(3)

soldout_buffer, bufcasecmp, bufcmp, bufcmps, bufdup, bufgrow, bufnew, bufnullterm, bufprintf, bufput, bufputs, bufputc, bufrelease, bufreset, bufset, bufslurp, buftoi, vbufprintfbuffer handling functions for soldout

#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;

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.

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.

create a global buffer name from a string literal string.
create a volatile buffer name on the stack from a string strname.
optimized () of a string literal.

()
compare two buffers ignoring case.
()
compare two buffers.
()
compare a buffer to a string.
()
duplicate a buffer src.
()
increase the allocated size to the given value.
()
create a new buffer.
()
terminate the string array by NUL (making a C-string).
()
print formatted output to a buffer buf.
()
append raw data to a buffer buf.
bufputs()
append a NUL-terminated string str to a buffer buf.
()
append a single char c to a buffer buf.
()
decrease the reference count and free the buffer buf if needed.
()
free internal data of the buffer buf.
()
safely assign a buffer to another.
()
remove a given number of bytes from the head of the array.
()
convert the numbers at the beginning of the buffer buf into an int.
()
stdarg(3) variant of formatted printing into a buffer buf.

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.

soldout(3), stdarg(3)

The soldout library was written by Natasha "Kerensikova" Porte <natacha@instinctive.eu>. Manual page was originally written by Massimo Manghi <mxmanghi@apache.org>, and rewritten to mdoc format by Svyatoslav Mishyn <juef@openmailbox.org>.

April 13, 2016 Debian