1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
/* $Id: mbox.cpp,v 1.9 2004/08/24 16:16:35 terpstra Exp $
*
* mbox.cpp - Handle a mbox/ command
*
* Copyright (C) 2002 - Wesley W. Terpstra
*
* License: GPL
*
* Authors: 'Wesley W. Terpstra' <wesley@terpstra.ca>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define _XOPEN_SOURCE 500
#define _FILE_OFFSET_BITS 64
#include <mimelib/message.h>
#include "commands.h"
#include "Summary.h"
#include "Cache.h"
int handle_mbox(const Config& cfg, ESort::Reader* db, const string& param)
{
Request req = parse_request(param);
if (!MessageId::is_full(req.options.c_str()))
error(_("Bad request"), param,
_("The given parameter was not of the correct format. "
"A mbox request must be formatted like: "
"mbox/YYYYMMDD.HHMMSS.hashcode.txt"));
if (!cfg.raw_email)
error(_("Permission Denied"), param,
_("Access to raw email text has been disabled. "
"Contact the site administrator if this is a problem."));
MessageId id(req.options.c_str());
string ok;
Summary source(id);
if ((ok = source.load(db, cfg)) != "")
error(_("Database mbox source pull failure"), ok,
_("The specified message does not exist."));
DwMessage message;
if ((ok = source.message(cfg.dbdir, message)) != "")
error(_("MBox read failure"), ok,
_("Unable to open message in the mailbox. "
"Perhaps it has been deleted or moved?"));
Cache cache(cfg, "mbox", param, req.ext);
cache.o << message.AsString().c_str();
return 0;
}
|