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