skalibs
Software
www.skarnet.org
The stddjb library interface
libstddjb is the base, and the most important part, of skalibs.
It is a general-purpose C library wrapping some
system calls, hiding some Unix portability problems, providing some
basic low-level buffering functions and string handling, and generally
offering a nice API to Unix programming - in many ways nicer and safer
than the "standard" Unix APIs like stdio.h.
It is mostly based on some excellent code written and placed into the
public domain by D. J. Bernstein.
Every executable from skarnet.org uses libstddjb. This
library is where secure, safe and small software starts.
Compiling
- Add /package/prog/skalibs/include, or wherever you installed
your header files, to your header directory list
- Use #include "stddjb.h"
Linking
- For static linking:
add /package/prog/skalibs/library, or wherever you installed
your .a files, to your library directory list.
- For dynamic linking:
add /package/prog/skalibs/library.so, or wherever you installed
your .so files, to your library directory list - and make sure to properly
edit your ld.so.conf file and to run ldconfig if needed.
- Link with -lstddjb
Programming
The stddjb.h header is actually a concatenation of other headers;
every family of structures and functions has its own header, for clarity.
- alloc.h: basic heap memory allocation primitives
- allreadwrite.h: safe
wrappers around I/O functions, extra I/O functions
- bitarray.h: how to handle large arrays of bits
- bufalloc.h: bufferized output (with dynamically allocated buffers)
- buffer.h: bufferized I/O (with statically allocated buffers)
- bytestr.h: basic operations on strings and byte arrays
- cdb.h: how to read
cdb files
- cdb_make.h: how to write
cdb files
- djbtime.h: conversions between date and time formats
- djbunix.h: management of basic Unix concepts
- envalloc.h: management of dynamically allocated argv and envp
- env.h: management of argv and envp
- fmtscan.h: formatters (printers) and scanners (parsers) for basic C types
- genalloc.h: generic advanced management of dynamically allocated structures
- genwrite.h: interface to generic writes either to strallocs or to buffers
- getpeereid.h: the getpeereid() system call
- iobuffer.h: optimized data transfer from a fd to another
- ip46.h: IPv4/IPv6 abstraction layer
- lolstdio.h:
printf-like
functions writing into buffers or bufallocs
- mininetstring.h: a protocol to transmit variable-length messages (limited to 64kB)
- netstring.h: a protocol to transmit variable-length messages (limited to 2^32 bytes)
- segfault.h: voluntary error generation
- selfpipe.h: automated selfpipe trick (i.e.
how to safely handle signals in event loops)
- sgetopt.h: getopt()-style command-line options management
- sig.h: safe signal management
- skamisc.h: general string quoting and parsing; miscellaneous, unclassifiable functions
- siovec.h:
iovec-like
structure for scatter/gather IO operations
- socket.h: INET domain sockets
- stralloc.h: advanced management of dynamically allocated strings
- strerr.h: basic error messages
- strerr2.h: advanced error messages
- tai.h: time, timers and system clock
- webipc.h: UNIX domain sockets
The following headers are automatically generated at compile-time, when the
headers subsystem is made. The stddjb.h file also includes
them, and the code they are associated with is part of the stddjb library.
Additionally, stddjb.h also includes the following headers, which
are not associated with any code and are mostly self-explanatory:
- gccattributes.h: wrappers around a few GCC-specific optimizations
- diuint.h: for associative arrays of unsigned integers
- diuint32.h: for associative arrays of 32-bit unsigned integers
- environ.h: declaration of the environ variable
- nsig.h: the number of system signals, for systems that do not define it
- nonposix.h: feature test macros for non-POSIX-compliant systems