% Ravel & Unravel -- command-line mime packing and extracting
% Jessica L. Parsons <orc@pell.portland.or.us>
% Tue Jan 15 20:48:28 PST 2008
#Ravel & Unravel

**Ravel** and **unravel** pack and unpack [mime-encoded][mime]
messages.  I wrote these for [Mastodon Linux][mastodon]
because the exiting mime packers and unpackers seemed to be too
complicated for such a simple spec.    A few dozen code revisions
later, I realized my mistake.   But here they are;  I've grown
used to them, and prefer them to the traditional standards.

##Source Code

 * [1.2.5](mimecode-1.2.5.tar.bz2) adds one option to 
    the `unravel` program -- the '-d' (--dryrun) option
    doesn't actually extract files, but tells you what
    files are being extracted (this was implemented once
    before, but the changes got submerged when that
    copy of the mimecode sccs files got out of sync
    with everything else.)    It also fixes one 
    bug with memory allocation;  I keep a stack of
    mime boundaries so I can rewind out from multiply
    nested mime bundles, and I'd _completely_ misdone
    the memory allocation for that stack to the point
    that often it wouldn't actually expand the stack
    but would instead just sort of wander off into
    random memory building a stack.    This was an annoying
    bug, because it would only rarely either make the
    program dump core (on Linux, via the memory management
    code in libc; this would dump so much information that
    it as difficult to track) or drop into an infinite
    loop as things got progressively more corrupt.

    Resorting to [valgrind](http://valgrind.org) pointed
    me to the problem in a hurry (a placeholder malloc(1)
    which SHOULD have been reallocated to fit if the rest
    of the memory management worked) so it's fixed to the
    point where valgrind doesn't complain about that 
    anymore (it still complains about orphaned memory
    segments and I know *exactly* where that's happening;
    that's a bugfix for a different day, though) and maybe?
    unravel won't dump core or go into an infinite loop in
    the middle of `make test`.
    
 * [1.2.4](mimecode-1.2.4.tar.bz2) adds two options to 
    the `unravel` and `uudecode` programs -- the `-q` option
    makes them run as quietly as possible, and the `-t` option
    makes them write extracted files into the specified directory
    instead of where the pathname wants to put them.

 * [1.2](mimecode-1.2.1.tar.gz) -- codenamed '*superfussy*' --
    is a massively cleaned up version that improves on the
    cleanups in version 1.1.1 plus has more and better documentation
    and a few additional features.
    I've added the `-c`
    (extract files to current directory) and `-f` (overwrite
    files) options, documented them, added a
    [README](mimecode-current/README) describing the package,
    and added an
    [INSTALL](mimecode-current/INSTALL) document which, in
    about the tersest way possible, attempts to tell you how
    to install it.

    For completeness, I've complemented `uudecode` with a `uuencode`
    program (providing both *base64* and *uuencode* formats,) based
    on code from [4.4bsd][].

    > To wall off my uuencode/uudecode from any that might already be on
    > the system, I've added the `--enable-uuencode` flag to
    > `configure.sh` so you need to *really* want the uu family
    > before you get it.

 * [1.1.1](mimecode-1.1.1.tar.gz) is a cleanup version of the 1.1;
    I went in and did a generalized cleanup of the manpages, the
    build process, and the install process.  Version 1.1.1 now
    [uuencode][] manpage [a lightly edited version of the BSD
    page], has the other manpages redone from the USG (`.TH/.SH/`&tc)
    to the newer `-mandoc` style that BSD uses, has been lightly edited
    to use my standard method of carrying around a program name
    (global `char* pgm;`, populated by `pgm=basename?basename():strrchr()`)
    and to have the arguments to `->encode()`
    and `->decode()` cast to the `mimeread` and `mimewrite` types,
    and, finally, has a version of [configure.sh][configure]
    that tries to look for the existance of **$prefix**`/share/man`
    so it can put the manpages there instead of **$prefix**`/man`.

    Amazingly, none of this appears to have actually broken the rest
    of the code.

 * [1.1](mimecode-1.1.tar.gz), codenamed *Rip Van Winkle*, was provoked
    by trying -- after a several-year interval --  to run the program 
    on a new machine.   It didn't work, and when I looked at the code
    I realized that there were parts in it that were pretty much
    guaranteed to **NEVER** work.  So I've ripped out the guts of the
    program and restructured it, and now it appears to run on
    [Mastodon][], [MacOS][], and [FreeBSD][].

 * [1.0](mimecode-1.0.tar.gz) was ripped out of the [Mastodon][] toolkit
    and stuffed into its own little tarball.   These compile (for some
    version of "compile") on FreeBSD 4.8 and Mastodon INST0067, unlike
    the old code that wouldn't compile anywhere except in the Mastodon
    build tree.


[mime]: http://www.ietf.org/rfc/rfc2045.txt
[mastodon]: /~mastodon
[4.4bsd]: http://www.tuhs.org/archive_sites.html
[uuencode]: http://www.opengroup.org/onlinepubs/007908799/xcu/uuencode.html
[configure]: /~orc/Code/configure
[macos]: http://www.apple.com/macosx
[freebsd]: http://www.freebsd.org