/************************************************************************* * * HTCd - Copyright (C) 1998-2006 Henrik Rydberg * * 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; either version 2 of the License, or * (at your option) any later version. * * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include static int FromHead(const sref& body) { sref tag,from,rest=body; Split(tag,rest); Split(from,rest); return tag==from_tag&&htcTime(0,rest)>=0; } ///////////////////////////////////////////////////////////////////// const mstring nextmsg_tag="\nFrom "; const mstring sep_tag="--"; Message::Message() { } int Message::Special(sref line) { line=Rest(line); from=from0=First(line); date=Rest(line); idate=htcTime(0,date); return idate>=0; } int Message::Handle(const sref& name, const sref& rawval, const sref& val, const rrpile& opts) { mstring mime; if(Mime::Handle(name,rawval,val,opts)) return 1; else if(eqn(name,from_tag)) { swrite sw(from); decodeHeader(sw,mime,rawval); } else if(eqn(name,subject_tag)) { swrite sw(subject); decodeHeader(sw,mime,rawval); } else if(eqn(name,to_tag)) { swrite sw(to); decodeHeader(sw,mime,rawval); } else if(eqn(name,msgid_tag)) msgid=rawval; else if(eqn(name,received_tag)) received.push_back(rawval); else return 0; return 1; } void Message::putHead(mstream& out) const { if(from0.nempty()) { out<<"From "<