mlmmj-archive-mid
==================

A Message-ID to archive URL resolver for mlmmj mailing lists.

Given a Message-ID, mlmmj-archive-mid looks it up in mlmmj archive SQLite
databases and returns the corresponding archive URL.

It operates in two modes:

 - CGI mode: when invoked without arguments, it parses the HTTP request via
   kcgi and responds with an HTTP 303 redirect to the archive page.
 - CLI mode: when invoked with -d and -m arguments, it prints the resolved
   archive URL to stdout.

Requirements
------------

 - sqlite3
 - kcgi (https://kristaps.bsd.lv/kcgi/)

Building
--------

    make

Environment Variables
---------------------

 MLMMJ_ARCHIVES_DIRECTORY
    Path to the directory containing mailing list archives. Each subdirectory
    should contain a .db SQLite database with a "mails" table. Required in
    CGI mode.

 MLMMJ_ARCHIVES_PREFIX
    URL prefix prepended to generated archive paths. Defaults to empty.

CLI Usage
---------

    mlmmj-archive-mid -d <archivedir> -m <msgid> [-r]

    -d <archivedir>   Path to the archive directory.
    -m <msgid>        The Message-ID to look up.
    -r                Return the raw text URL instead of HTML.

CGI Usage
---------

The CGI exposes two endpoints:

    /mid/<Message-ID>      Redirects to the HTML archive page.
    /midraw/<Message-ID>   Redirects to the raw text version.

License
-------

BSD 2-Clause. See the source file for details.
