skalibs: the lolstdio library interface
Keywords: skalibs c unix stdio lol printf fprintf library libstddjb

libstddjb
libskarnet
skalibs
Software
skarnet.org

# The `lolstdio` library interface

The following functions are declared in the `skalibs/lolstdio.h` header, and implemented in the `libskarnet.a` or `libskarnet.so` library.

## General information

`lolstdio` is a set of convenience functions providing printf-style formatting but interacting with buffers or bufallocs instead of stdio FILEs.

Like any printf-style functions, the lolstdio functions are rather complex and inefficient, and not recommended for general use; they are provided as a quick and dirty way to debug or test things. Programmers are advised to use type-specific formatting functions instead in production-quality code.

Be aware that functions writing into buffers interact badly with non-blocking fds (and asynchronism in general) - just as you cannot use FILEs with non-blocking output. Functions writing into bufallocs, however, are fine, because bufallocs are much more suited to asynchronous writing than fixed-size buffers or FILEs are.

The current lolstdio implementation relies on the libc's vsnprintf function.

## Functions

`int vbprintf (buffer *b, char const *format, va_list args)`
Like vfprintf except that the result is written to the buffer b.

`int bprintf (buffer *b, char const *format, ...)`
Like fprintf except that the result is written to the buffer b.

`int lolprintf (char const *format, ...)`
Like printf except that the result is written to the buffer `buffer_1`.

`int vbaprintf (bufalloc *ba, char const *format, va_list args)`
Like vfprintf except that the result is written to the bufalloc ba.

`int baprintf (bufalloc *ba, char const *format, ...)`
Like fprintf except that the result is written to the bufalloc ba.