The libdjb project (original) (raw)
(Note: This has not been touched since 2000, use instead)
Recent changes: implement socket_sendfile and socket_getifidx, work around broken BSD includes.
What is it?
This project aims to make the excellent libraries from Dan Bernstein available to a wider public by extracting them from his packages and providing a minimal Makefile for each library.
So far, I extracted the alloc, buffer, byte, dns, tai, timeoutconn and unix libraries (iopause and timeoutconn are not libraries in djb's software but I made them into libraries for easier use), but since they share some include files (I hardlinked them in the respective directories so you can still use each library completely on its own) and the whole package is below 40k when compressed with bzip2, I chose to distribute them in one package.
The package also comes with a few undocumented perl scripts that will hopefully evolve into a system that allows you to incorporate the libraries into your code easily. You can reach me asfelix-djb@fefe.de.
Licensing terms?
The same as the rest of Bernstein's code. See http://cr.yp.to/softwarelaw.html.
Actually, Bernstein explicitly declared parts of his work to be public domain, for example the tai code that is included in libdjb (albeit not documented yet).
What do the libraries do?
- alloc.a contains wrappers around memory allocation, stralloc (dynamic strings)
- buffer.a contains buffered I/O
- byte.a contains formatting, scanning and other string routines
- dns.a contains a full blown DNS resolver
- tai.a contains an abstraction for 64-bit system time
- timeout.a contains versions of several socket routines with user specified timeout
- unix.a contains wrappers for socket functions, mkfifo, opendir, wait and an abstraction around errno.
- sig.a contains wrappers for Unix signal functions.
Did you add anything?
Yes. See <news.html> for a list of recent changes.
- Every directory now also contains a "make clean" target.
- unix also contains IPv6 versions of djb's socket routines, env and iopause.
- dns also contains support for resolving IPv6 addresses.
- byte also contains implementations for scan_0x and fmt_xlong, and support for parsing and formatting IPv6 numbers.
- timeoutconn.o was taken from ucspi-tcp, I added a timeoutconn6.o for IPv6 and called the result timeoutconn.a.
- Converted K&R prototypes to ANSI
- Changed uint32 and uint64 checks to allow cross compiling
- added byte_dup and str_dup functions to create a malloced copy
The IPv6 socket routines in unix.a look and feel like the IPv4 routines except that the IPs are now 16 instead of 4 bytes long. The routines will compile and work even if you don't have IPv6 support in your system, so you can write IPv6 code that is 100% backwards compatible to IPv4 without making your code unreadable with tons of #ifdefs and conversion code all over the place. Or, even easier, use my IPv6 patches to ucspi-tcp and completely get rid of transport protocol dependencies in your code!
Where can I download it?
Just grab <djb-0.5.2.tar.bz2>.
See also
- a GPL reimplementation efford of libdjb.
- my diet libc.
- my IPv6 patches to djbdns
- my IPv6 patches to ucspi-tcp. These two spawned the project
- my ncp rewrite using libdjb. This is my first program using libdjb.
- superscript djblib appears to be a similar project (without IPv6 though)