summaryrefslogtreecommitdiff
path: root/src/imapparser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/imapparser.cc')
-rw-r--r--src/imapparser.cc77
1 files changed, 13 insertions, 64 deletions
diff --git a/src/imapparser.cc b/src/imapparser.cc
index fc2e071..d5e5f55 100644
--- a/src/imapparser.cc
+++ b/src/imapparser.cc
@@ -1,9 +1,10 @@
-/** --------------------------------------------------------------------
+/**
* @file imapparser.cc
* @brief Implementation of the common items for parsing IMAP input
* @author Andreas Aardal Hanssen
* @date 2002-2005
- * ----------------------------------------------------------------- **/
+ */
+
#include "imapparser.h"
#include "convert.h"
@@ -16,218 +17,181 @@
#include <stdio.h>
-using namespace ::std;
using namespace Binc;
+using std::string;
-//------------------------------------------------------------------------
-Request::Request(void) : extra(0), flags(), statuses(), bset(), searchkey(), fatt()
-{
- uidmode = false;
-}
+Request::Request(void) : uidmode(false), extra(nullptr), flags(), statuses(), bset(), searchkey(), fatt()
+{}
Request::~Request(void)
{
- if (extra != 0) delete extra;
+ if (extra != nullptr) delete extra;
}
-//------------------------------------------------------------------------
void Request::setUidMode(void)
{
uidmode = true;
}
-//------------------------------------------------------------------------
bool Request::getUidMode(void) const
{
return uidmode;
}
-//------------------------------------------------------------------------
void Request::setTag(string &t_in)
{
tag = t_in;
}
-//------------------------------------------------------------------------
const string &Request::getTag(void) const
{
return tag;
}
-//------------------------------------------------------------------------
void Request::setMode(const string &m_in)
{
mode = m_in;
}
-//------------------------------------------------------------------------
const string &Request::getMode(void) const
{
return mode;
}
-//------------------------------------------------------------------------
void Request::setName(const string &s_in)
{
name = s_in;
}
-//------------------------------------------------------------------------
const string &Request::getName(void) const
{
return name;
}
-//------------------------------------------------------------------------
void Request::setAuthType(const string &s_in)
{
authtype = s_in;
}
-//------------------------------------------------------------------------
const string &Request::getAuthType(void) const
{
return authtype;
}
-//------------------------------------------------------------------------
void Request::setLiteral(const string &s_in)
{
literal = s_in;
}
-//------------------------------------------------------------------------
const string &Request::getLiteral(void) const
{
return literal;
}
-//------------------------------------------------------------------------
void Request::setDate(const string &s_in)
{
date = s_in;
}
-//------------------------------------------------------------------------
const string &Request::getDate(void) const
{
return date;
}
-//------------------------------------------------------------------------
void Request::setCharSet(const string &s_in)
{
charset = s_in;
uppercase(charset);
}
-//------------------------------------------------------------------------
const string &Request::getCharSet(void) const
{
return charset;
}
-//------------------------------------------------------------------------
void Request::setUserID(const string &s_in)
{
userid = s_in;
}
-//------------------------------------------------------------------------
const string &Request::getUserID(void) const
{
return userid;
}
-//------------------------------------------------------------------------
void Request::setPassword(const string &s_in)
{
password = s_in;
}
-//------------------------------------------------------------------------
const string &Request::getPassword(void) const
{
return password;
}
-//------------------------------------------------------------------------
void Request::setMailbox(const string &s_in)
{
mailbox = s_in;
}
-//------------------------------------------------------------------------
const string &Request::getMailbox(void) const
{
return mailbox;
}
-//------------------------------------------------------------------------
void Request::setListMailbox(const string &s_in)
{
listmailbox = s_in;
}
-//------------------------------------------------------------------------
const string &Request::getListMailbox(void) const
{
return listmailbox;
}
-//------------------------------------------------------------------------
void Request::setContextInfo(const string &s_in)
{
contextInfo = s_in;
}
-//------------------------------------------------------------------------
const string &Request::getContextInfo(void) const
{
return contextInfo;
}
-//------------------------------------------------------------------------
void Request::setNewMailbox(const string &s_in)
{
newmailbox = s_in;
}
-//------------------------------------------------------------------------
const string &Request::getNewMailbox(void) const
{
return newmailbox;
}
-//------------------------------------------------------------------------
SequenceSet &Request::getSet(void)
{
return bset;
}
-//------------------------------------------------------------------------
-vector<string> &Request::getStatuses(void)
+std::vector<string> &Request::getStatuses(void)
{
return statuses;
}
-//------------------------------------------------------------------------
-vector<string> &Request::getFlags(void)
+std::vector<string> &Request::getFlags(void)
{
return flags;
}
-//------------------------------------------------------------------------
SequenceSet::SequenceSet(void) : limited(true), nullSet(false) {}
-//------------------------------------------------------------------------
SequenceSet::SequenceSet(const SequenceSet &copy)
: limited(copy.limited)
, nullSet(copy.nullSet)
, internal(copy.internal)
{}
-//------------------------------------------------------------------------
SequenceSet &SequenceSet::operator=(const SequenceSet &copy)
{
limited = copy.limited;
@@ -237,10 +201,8 @@ SequenceSet &SequenceSet::operator=(const SequenceSet &copy)
return *this;
}
-//------------------------------------------------------------------------
SequenceSet::~SequenceSet(void) {}
-//------------------------------------------------------------------------
SequenceSet &SequenceSet::null(void)
{
static SequenceSet nil;
@@ -248,13 +210,11 @@ SequenceSet &SequenceSet::null(void)
return nil;
}
-//------------------------------------------------------------------------
bool SequenceSet::isNull(void) const
{
return nullSet;
}
-//------------------------------------------------------------------------
SequenceSet &SequenceSet::all(void)
{
static bool initialized = false;
@@ -268,7 +228,6 @@ SequenceSet &SequenceSet::all(void)
return all;
}
-//------------------------------------------------------------------------
SequenceSet::Range::Range(unsigned int a, unsigned int b)
{
if (a > b) {
@@ -280,40 +239,33 @@ SequenceSet::Range::Range(unsigned int a, unsigned int b)
}
}
-//------------------------------------------------------------------------
void SequenceSet::addRange(unsigned int a, unsigned int b)
{
if (a == (unsigned int)-1 || b == (unsigned int)-1) limited = false;
internal.push_back(Range(a, b));
}
-//------------------------------------------------------------------------
void SequenceSet::addNumber(unsigned int a)
{
if (a == (unsigned int)-1) limited = false;
internal.push_back(Range(a, a));
}
-//------------------------------------------------------------------------
bool SequenceSet::isInSet(unsigned int n) const
{
unsigned int maxvalue = 0;
- for (vector<Range>::const_iterator i = internal.begin(); i != internal.end(); ++i) {
- const Range &r = *i;
+ for (const auto &r : internal) {
if (r.from > maxvalue)
maxvalue = r.from;
else if (r.to > maxvalue)
maxvalue = r.to;
- if (n >= (*i).from && n <= (*i).to) {
- return true;
- }
+ if (n >= r.from && n <= r.to) return true;
}
return (n > maxvalue && !limited);
}
-//------------------------------------------------------------------------
BincImapParserFetchAtt::BincImapParserFetchAtt(const std::string &typeName) : type(typeName)
{
offsetstart = 0;
@@ -321,7 +273,6 @@ BincImapParserFetchAtt::BincImapParserFetchAtt(const std::string &typeName) : ty
hassection = false;
}
-//------------------------------------------------------------------------
string BincImapParserFetchAtt::toString(void)
{
string tmp;
@@ -340,8 +291,8 @@ string BincImapParserFetchAtt::toString(void)
if (headerlist.size() > 0) {
tmp += " (";
- for (vector<string>::iterator i = headerlist.begin(); i != headerlist.end(); ++i) {
- if (i != headerlist.begin()) tmp += " ";
+ for (auto i = headerlist.cbegin(); i != headerlist.cend(); ++i) {
+ if (i != headerlist.cbegin()) tmp += " ";
tmp += Binc::toImapString(*i);
}
tmp += ")";
@@ -359,14 +310,12 @@ string BincImapParserFetchAtt::toString(void)
return tmp;
}
-//------------------------------------------------------------------------
BincImapParserSearchKey::BincImapParserSearchKey(void)
{
type = 0;
number = 0;
}
-//------------------------------------------------------------------------
const SequenceSet &BincImapParserSearchKey::getSet(void) const
{
return bset;