The last obvious bug in the IMAP tokenizer is fixed. I'm going to spend the next few minutes fooling with gperf, which produces perfect hash tables from a fixed set of strings. If gperf doesn't suck, it will allow fast identification of IMAP commands.

Update: Fortunately, gperf does not suck. It takes a while to get the options right, but gperf certainly is easy enough to use. The hash table now works fine, as do enough I/O primitives to get started on serious work. I've got a working command loop with a few commands and pretty robust error-handling. The only problem so far is that t_fseek hangs if the user disconnects from the server improperly. I don't know if this involves the t_io patches or my code, but it will have to wait until tomorrow.