diff options
Diffstat (limited to 'src/operator-append.cc')
-rw-r--r-- | src/operator-append.cc | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/operator-append.cc b/src/operator-append.cc index f4eaaa9..cf40fdf 100644 --- a/src/operator-append.cc +++ b/src/operator-append.cc @@ -1,9 +1,10 @@ -/** -------------------------------------------------------------------- +/** * @file operator-append.cc * @brief Implementation of the APPEND command. * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #include "depot.h" #include "iodevice.h" #include "iofactory.h" @@ -18,37 +19,32 @@ #include <fcntl.h> -using namespace ::std; using namespace Binc; +using std::string; -//---------------------------------------------------------------------- AppendOperator::AppendOperator(void) {} -//---------------------------------------------------------------------- AppendOperator::~AppendOperator(void) {} -//---------------------------------------------------------------------- const string AppendOperator::getName(void) const { return "APPEND"; } -//---------------------------------------------------------------------- int AppendOperator::getState(void) const { return Session::AUTHENTICATED | Session::SELECTED; } -//------------------------------------------------------------------------ Operator::ProcessResult AppendOperator::process(Depot &depot, Request &command) { Session &session = Session::getInstance(); const string &srcmailbox = command.getMailbox(); const string &canonmailbox = toCanonMailbox(srcmailbox); - Mailbox *mailbox = 0; + Mailbox *mailbox = nullptr; - if ((mailbox = depot.get(canonmailbox)) == 0) { + if ((mailbox = depot.get(canonmailbox)) == nullptr) { session.setResponseCode("TRYCREATE"); session.setLastError("invalid destination mailbox " + toImapString(srcmailbox)); return NO; @@ -56,7 +52,7 @@ Operator::ProcessResult AppendOperator::process(Depot &depot, Request &command) // mask all passed flags together unsigned int newflags = (unsigned int)Message::F_NONE; - vector<string>::const_iterator f_i = command.flags.begin(); + std::vector<string>::const_iterator f_i = command.flags.begin(); while (f_i != command.flags.end()) { if (*f_i == "\\Deleted") newflags |= Message::F_DELETED; if (*f_i == "\\Answered") newflags |= Message::F_ANSWERED; @@ -150,7 +146,7 @@ Operator::ProcessResult AppendOperator::process(Depot &depot, Request &command) return BAD; } - nr += (char)c; + nr += c; } int nchars = atoi(nr.c_str()); @@ -173,8 +169,8 @@ Operator::ProcessResult AppendOperator::process(Depot &depot, Request &command) return BAD; } - time_t newtime = (command.getDate() != "") ? mktime(&mytm) : time(0); - if (newtime == -1) newtime = time(0); + time_t newtime = (command.getDate() != "") ? mktime(&mytm) : time(nullptr); + if (newtime == -1) newtime = time(nullptr); Message *dest = mailbox->createMessage(depot.mailboxToFilename(canonmailbox), newtime); if (!dest) { session.setLastError(mailbox->getLastError()); @@ -182,7 +178,7 @@ Operator::ProcessResult AppendOperator::process(Depot &depot, Request &command) } if (!literalPlus) { - bincClient << "+ go ahead with " << nchars << " characters" << endl; + bincClient << "+ go ahead with " << nchars << " characters" << std::endl; bincClient.flush(); } @@ -248,7 +244,6 @@ Operator::ProcessResult AppendOperator::process(Depot &depot, Request &command) return OK; } -//---------------------------------------------------------------------- Operator::ParseResult AppendOperator::parse(Request &c_in) const { Session &session = Session::getInstance(); @@ -275,7 +270,7 @@ Operator::ParseResult AppendOperator::parse(Request &c_in) const } if ((res = expectThisString("(")) == ACCEPT) { - if ((res = expectFlag(c_in.getFlags())) == ACCEPT) + if ((res = expectFlag(c_in.getFlags())) == ACCEPT) { while (1) { if ((res = expectSPACE()) != ACCEPT) break; if ((res = expectFlag(c_in.getFlags())) != ACCEPT) { @@ -283,6 +278,7 @@ Operator::ParseResult AppendOperator::parse(Request &c_in) const return res; } } + } if ((res = expectThisString(")")) != ACCEPT) { session.setLastError("expected a ')'"); @@ -296,11 +292,12 @@ Operator::ParseResult AppendOperator::parse(Request &c_in) const } string date; - if ((res = expectDateTime(date)) == ACCEPT) + if ((res = expectDateTime(date)) == ACCEPT) { if ((res = expectSPACE()) != ACCEPT) { session.setLastError("expected a SPACE after date_time"); return res; } + } c_in.setDate(date); c_in.setName("APPEND"); |