2 .TH mLib 3 "7 July 1999" mLib
4 mLib \- library of miscellaneous utilities
9 library is a mixed bag of things which the author finds useful in large
10 numbers of programs. As a result, its structure is somewhat arbitrary,
11 and it's accreted extra bits over time rather than actually being
12 designed as a whole. In the author's opinion this isn't too much of a
15 At the most granular level,
17 is split into `modules', each of which has its own header file and
18 manual page. Sometimes there are identifiable `chunks' of several
19 modules which fit together as a whole. Modules and chunks fit into
20 `layers', each depending on the ones below it. The header file for
28 This description is a bit abstract, and
30 as a result of its history, doesn't fit it as well as I might like.
31 Even so, it's not too bad a model really.
33 The rest of this section describes the various chunks and layers.
34 .SS "Exception handling"
35 Right at the bottom, there's a fairly primitive exception handling
36 system. It's provided by the
38 module, and stands alone. It's used mainly by the memory allocation
39 modules to raise exceptions when there's no more memory to be had.
40 .SS "Memory allocation"
43 module provides simple veneers onto traditional memory allocation
50 doesn't actually depend on
52 being defined in the library) which raise exceptions when there's not
57 module handles efficient allocation of small blocks. It allocates
58 memory in relatively big chunks and divides the chunks up into small
59 blocks before returning them. It keeps lists of differently-sized
60 blocks so allocation and freeing is fast. The downside is that your
61 code must know how big a block is when it's being freed.
65 module (not yet documented) is a simple memory allocation tracker. It
66 can be handy when trying to fix memory leaks.
70 module provides some trivial string-manipulation functions which tend to
71 be useful quite often.
75 module implements a dynamic string data type. It works quite quickly
76 and well, and is handy in security-sensitive programs, to prevent
77 buffer-overflows. Dynamic strings are used occasionally through the
78 rest of the library, mainly as output arguments.
82 module implements a `pool' of dynamic strings which saves lots of
83 allocation and deallocation when a piece of code has high string
85 .SS "Program identification and error reporting"
88 module remembers the name of the program and supplies it when asked.
89 It's used in error messages and similar things.
93 module emits standard Unixy error messages. It provides functions
97 which the author uses rather a lot.
101 module (not yet documented)
102 provides an interface for emitting tracing information with configurable
103 verbosity levels. It needs improving to be able to cope with outputting
105 .SS "Other data types"
108 module provides the basics for an extending hashtable implementation.
109 Many different hashtable-based data structures can be constructed with
114 module implements a rather good general-purpose extending hash table.
115 Keys and values can be arbitrary data. It is implemented using
120 module (not yet documented) implements unbounded sparse arrays. It
122 .SS "Miscellaneous utilities"
125 module calculates CRC values for strings. It's used by the symbol table
126 manager as a hash function.
132 locking with a timeout.
136 module manipulates environment variables stored in a hashtable, and
137 converts between the hashtable and the standard array representation of
138 a process environment.
142 module manipulates file descriptor flags in a fairly painless way.
146 module implements a `line buffer', which is an object that emits
147 completed lines of text from an incoming asynchronous data stream. It's
148 remarkably handy in programs that want to read lines from pipes and
149 sockets can't block while waiting for a line-end to arrive.
153 module provides some macros and functions for playing with
154 .BR "struct timeval" .
158 module defines some types and macros for playing with words as chunks of
159 bits. There are portable rotate and shift macros (harder than you'd
160 think), and macros to do loading and storing in known-endian formats.
165 module implements a fairly serious options parser compatible with the
170 module provides a generic structure for reading test vectors from files
171 and running them through functions. I mainly use it for testing
172 cryptographic transformations of various kinds.
173 .SS "Encoding and decoding"
176 module does base64 encoding and decoding, as defined in RFC2045. Base64
177 encodes arbitrary binary data in a reliable way which is resistant to
178 character-set transformations and other mail transport bogosity.
182 module does urlencoding and decoding, as defined in RFC1866.
183 Urlencoding encodes arbitrary (but mostly text-like) name/value pairs as
184 a text string containing no whitespace.
185 .SS "Multiplexed I/O"
188 module provides a basis for doing nonblocking I/O in Unix systems. It
189 provides types and functions for receiving events when files are ready
190 for reading or writing, and when timers expire.
194 module implements nonblocking network connections in a way which fits in
197 system. It makes nonblocking connects pretty much trivial.
201 module attaches to the
203 system and sends an event when lines of text arrive on a file. It's
204 useful when reading text from a network connection.
208 module introduces signal handling into the multiplexed I/O world.
209 Signals are queued until dispatched through the normal
215 module provides a nonblocking ident (RFC931) client.
219 module does background hostname and address resolution.
248 Mark Wooding, <mdw@nsict.org>