05fbeb03 |
1 | .\" -*-nroff-*- |
2 | .TH mLib 3 "7 July 1999" mLib |
3 | .SH NAME |
4 | mLib \- library of miscellaneous utilities |
5 | .\" @mLib |
6 | .SH DESCRIPTION |
7 | The |
8 | .B mLib |
484eed5d |
9 | library is a mixed bag of things which the author finds useful in large |
05fbeb03 |
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 |
13 | hardship. |
14 | .PP |
15 | At the most granular level, |
16 | .B mLib |
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 |
21 | module |
22 | .I foo |
23 | would be put in |
24 | .BR <mLib/ \c |
25 | .IR foo \c |
484eed5d |
26 | .BR .h> . |
05fbeb03 |
27 | .PP |
28 | This description is a bit abstract, and |
29 | .BR mLib , |
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. |
32 | .PP |
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 |
484eed5d |
37 | .BR exc (3) |
05fbeb03 |
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" |
41 | The |
484eed5d |
42 | .BR alloc (3) |
05fbeb03 |
43 | module provides simple veneers onto traditional memory allocation |
44 | functions like |
45 | .BR malloc (3) |
46 | and |
47 | .BR strdup (3) |
48 | (although |
49 | .B mLib |
50 | doesn't actually depend on |
51 | .B strdup |
52 | being defined in the library) which raise exceptions when there's not |
53 | enough memory left. |
54 | .PP |
55 | The |
484eed5d |
56 | .BR sub (3) |
05fbeb03 |
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. |
62 | .PP |
63 | The |
64 | .B track |
65 | module (not yet documented) is a simple memory allocation tracker. It |
66 | can be handy when trying to fix memory leaks. |
67 | .SS "String handling" |
68 | The |
484eed5d |
69 | .BR str (3) |
05fbeb03 |
70 | module provides some trivial string-manipulation functions which tend to |
71 | be useful quite often. |
72 | .PP |
73 | The |
484eed5d |
74 | .BR dstr (3) |
05fbeb03 |
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. |
79 | .PP |
80 | The |
484eed5d |
81 | .BR dspool (3) |
05fbeb03 |
82 | module implements a `pool' of dynamic strings which saves lots of |
83 | allocation and deallocation when a piece of code has high string |
84 | turnover. |
85 | .SS "Program identification and error reporting" |
86 | The |
484eed5d |
87 | .BR quis (3) |
05fbeb03 |
88 | module remembers the name of the program and supplies it when asked. |
89 | It's used in error messages and similar things. |
90 | .PP |
91 | The |
484eed5d |
92 | .BR report (3) |
05fbeb03 |
93 | module emits standard Unixy error messages. It provides functions |
94 | .B moan |
95 | and |
96 | .B die |
97 | which the author uses rather a lot. |
98 | .PP |
99 | The |
53e76188 |
100 | .BR trace (3) |
101 | module provides an interface for emitting tracing information with |
102 | configurable verbosity levels. It needs improving to be able to cope |
103 | with outputting to the system log. |
05fbeb03 |
104 | .SS "Other data types" |
105 | The |
7eb5aec5 |
106 | .BR hash (3) |
107 | module provides the basics for an extending hashtable implementation. |
108 | Many different hashtable-based data structures can be constructed with |
109 | little effort. |
110 | .PP |
111 | The |
484eed5d |
112 | .BR sym (3) |
7eb5aec5 |
113 | module implements a rather good general-purpose extending hash table. |
114 | Keys and values can be arbitrary data. It is implemented using |
115 | .BR hash (3). |
05fbeb03 |
116 | .PP |
117 | The |
53e76188 |
118 | .BR darray (3) |
119 | module implements dynamically resizing arrays which support Perl-like |
120 | stack operations efficiently. |
05fbeb03 |
121 | .SS "Miscellaneous utilities" |
122 | The |
484eed5d |
123 | .BR crc32 (3) |
05fbeb03 |
124 | module calculates CRC values for strings. It's used by the symbol table |
125 | manager as a hash function. |
126 | .PP |
127 | The |
484eed5d |
128 | .BR lock (3) |
05fbeb03 |
129 | module does POSIX |
130 | .BR fcntl (2)-style |
131 | locking with a timeout. |
132 | .PP |
133 | The |
484eed5d |
134 | .BR env (3) |
3fecac47 |
135 | module manipulates environment variables stored in a hashtable, and |
136 | converts between the hashtable and the standard array representation of |
137 | a process environment. |
138 | .PP |
139 | The |
484eed5d |
140 | .BR fdflags (3) |
3fecac47 |
141 | module manipulates file descriptor flags in a fairly painless way. |
142 | .PP |
143 | The |
484eed5d |
144 | .BR lbuf (3) |
05fbeb03 |
145 | module implements a `line buffer', which is an object that emits |
146 | completed lines of text from an incoming asynchronous data stream. It's |
147 | remarkably handy in programs that want to read lines from pipes and |
148 | sockets can't block while waiting for a line-end to arrive. |
149 | .PP |
150 | The |
484eed5d |
151 | .BR tv (3) |
05fbeb03 |
152 | module provides some macros and functions for playing with |
484eed5d |
153 | .BR "struct timeval" . |
05fbeb03 |
154 | .PP |
155 | The |
484eed5d |
156 | .BR bits (3) |
05fbeb03 |
157 | module defines some types and macros for playing with words as chunks of |
158 | bits. There are portable rotate and shift macros (harder than you'd |
159 | think), and macros to do loading and storing in known-endian formats. |
160 | values. |
161 | .PP |
162 | The |
484eed5d |
163 | .BR mdwopt (3) |
05fbeb03 |
164 | module implements a fairly serious options parser compatible with the |
165 | GNU options parser. |
166 | .PP |
167 | The |
484eed5d |
168 | .BR testrig (3) |
05fbeb03 |
169 | module provides a generic structure for reading test vectors from files |
170 | and running them through functions. I mainly use it for testing |
171 | cryptographic transformations of various kinds. |
172 | .SS "Encoding and decoding" |
173 | The |
484eed5d |
174 | .BR base64 (3) |
05fbeb03 |
175 | module does base64 encoding and decoding, as defined in RFC2045. Base64 |
176 | encodes arbitrary binary data in a reliable way which is resistant to |
177 | character-set transformations and other mail transport bogosity. |
178 | .PP |
179 | The |
484eed5d |
180 | .BR url (3) |
05fbeb03 |
181 | module does urlencoding and decoding, as defined in RFC1866. |
182 | Urlencoding encodes arbitrary (but mostly text-like) name/value pairs as |
183 | a text string containing no whitespace. |
184 | .SS "Multiplexed I/O" |
185 | The |
484eed5d |
186 | .BR sel (3) |
05fbeb03 |
187 | module provides a basis for doing nonblocking I/O in Unix systems. It |
188 | provides types and functions for receiving events when files are ready |
189 | for reading or writing, and when timers expire. |
190 | .PP |
191 | The |
484eed5d |
192 | .BR conn (3) |
05fbeb03 |
193 | module implements nonblocking network connections in a way which fits in |
194 | with the |
195 | .B sel |
196 | system. It makes nonblocking connects pretty much trivial. |
197 | .PP |
198 | The |
484eed5d |
199 | .BR selbuf (3) |
05fbeb03 |
200 | module attaches to the |
201 | .B sel |
202 | system and sends an event when lines of text arrive on a file. It's |
203 | useful when reading text from a network connection. |
484eed5d |
204 | .PP |
205 | The |
206 | .BR sig (3) |
207 | module introduces signal handling into the multiplexed I/O world. |
208 | Signals are queued until dispatched through the normal |
209 | .B sel |
210 | mechanism. |
83856dde |
211 | .PP |
212 | The |
213 | .BR ident (3) |
214 | module provides a nonblocking ident (RFC931) client. |
215 | .PP |
216 | The |
217 | .BR bres (3) |
218 | module does background hostname and address resolution. |
05fbeb03 |
219 | .SH "SEE ALSO" |
220 | .BR alloc (3), |
221 | .BR base64 (3), |
222 | .BR bits (3), |
83856dde |
223 | .BR bres (3), |
05fbeb03 |
224 | .BR conn (3), |
225 | .BR crc32 (3), |
53e76188 |
226 | .BR darray (3), |
05fbeb03 |
227 | .BR dspool (3), |
228 | .BR dstr (3), |
3fecac47 |
229 | .BR env (3), |
05fbeb03 |
230 | .BR exc (3), |
3fecac47 |
231 | .BR fdflags (3), |
7eb5aec5 |
232 | .BR hash (3), |
83856dde |
233 | .BR ident (3), |
05fbeb03 |
234 | .BR lbuf (3), |
235 | .BR lock (3), |
236 | .BR mdwopt (3), |
237 | .BR quis (3), |
238 | .BR report (3), |
239 | .BR sel (3), |
240 | .BR selbuf (3), |
484eed5d |
241 | .BR sig (3), |
05fbeb03 |
242 | .BR str (3), |
243 | .BR sub (3), |
244 | .BR sym (3), |
53e76188 |
245 | .BR trace (3), |
05fbeb03 |
246 | .BR tv (3), |
247 | .BR url (3). |
248 | .SH AUTHOR |
249 | Mark Wooding, <mdw@nsict.org> |