diff options
author | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-10-07 22:33:50 +0200 |
---|---|---|
committer | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-10-08 11:35:51 +0200 |
commit | 1978c49bea5b439d993067c055cec47e70db8fd6 (patch) | |
tree | 255caea96a13f95564e6b631be9a4ac55ce33cd9 /src/include | |
parent | 3b1278f5459514a6d6364f068ff97b8a0432057b (diff) |
minor refactoring
Diffstat (limited to 'src/include')
29 files changed, 198 insertions, 274 deletions
diff --git a/src/include/address.h b/src/include/address.h index a8aded9..6d0a6cd 100644 --- a/src/include/address.h +++ b/src/include/address.h @@ -1,26 +1,24 @@ -/** -------------------------------------------------------------------- +/** * @file address.h * @brief Declaration of the Address class. * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #ifndef address_h_included #define address_h_included + #include <string> namespace Binc { - //------------------------------------------------------------------------ - class Address { - public: + struct Address { std::string name; std::string local; std::string host; - //-- std::string toParenList(void) const; - //-- Address(const std::string &name, const std::string &addr); Address(const std::string &wholeaddr); }; diff --git a/src/include/argparser.h b/src/include/argparser.h index ba7838d..0e9b060 100644 --- a/src/include/argparser.h +++ b/src/include/argparser.h @@ -1,30 +1,31 @@ -/** -------------------------------------------------------------------- +/** * @file argparser.h * @brief Declaration of the argument parser class. * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #ifndef ARGPARSER_H_INCLUDED #define ARGPARSER_H_INCLUDED + #include <map> #include <string> #include <vector> namespace Binc { - class ArgOpts { - public: + + struct ArgOpts { std::string c; bool b; bool o; std::string desc; - inline ArgOpts(const std::string &chr, bool boolean, bool optional, const std::string &descr) - { - c = chr; - b = boolean; - o = optional; - desc = descr; - } + ArgOpts(const std::string &chr, bool boolean, bool optional, const std::string &descr) + : c(chr) + , b(boolean) + , o(optional) + , desc(descr) + {} }; class CommandLineArgs { @@ -46,7 +47,7 @@ namespace Binc { void setTail(const std::string &str); - const std::vector<std::string> &getUnqualifiedArgs() const; + const std::vector<std::string> &getUnqualifiedArgs(void) const; private: void registerArg(const std::string &arg, const std::string &desc, bool boolean, bool optional); diff --git a/src/include/authenticate.h b/src/include/authenticate.h index a3d63ce..b3f68e9 100644 --- a/src/include/authenticate.h +++ b/src/include/authenticate.h @@ -1,9 +1,10 @@ -/** -------------------------------------------------------------------- +/** * @file authenticate.h * @brief Declaration of the common authentication mechanism. * @author Andreas Aardal Hanssen, Erwin Hoffmann * @date 2002-2005, 2023 - * ----------------------------------------------------------------- **/ + */ + #ifndef authenticate_h_included #define authenticate_h_included #include "depot.h" diff --git a/src/include/base64.h b/src/include/base64.h index 25b0ff4..da219d2 100644 --- a/src/include/base64.h +++ b/src/include/base64.h @@ -1,18 +1,18 @@ -/** -------------------------------------------------------------------- +/** * @file base64.h * @brief Declaration of base64 Utilities * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #ifndef base64_h_included #define base64_h_included + #include <string> namespace Binc { - std::string base64decode(const std::string &s_in); std::string base64encode(const std::string &s_in); - } #endif diff --git a/src/include/broker.h b/src/include/broker.h index ac78041..eb28bd4 100644 --- a/src/include/broker.h +++ b/src/include/broker.h @@ -1,11 +1,13 @@ -/** -------------------------------------------------------------------- +/** * @file broker.h * @brief Declaration of the Broker class. * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #ifndef broker_h_included #define broker_h_included + #include "depot.h" #include "operators.h" @@ -17,12 +19,10 @@ namespace Binc { class Request; class Broker; - //------------------------------------------------------------------ class BrokerFactory { private: std::map<int, Broker *> brokers; - //-- BrokerFactory(void); mutable std::string lastError; @@ -36,24 +36,20 @@ namespace Binc { inline const std::string &getLastError(void) const; inline void setLastError(const std::string &error) const; - //-- static BrokerFactory &getInstance(void); ~BrokerFactory(void); }; - //------------------------------------------------------------------ inline const std::string &BrokerFactory::getLastError(void) const { return lastError; } - //------------------------------------------------------------------ inline void BrokerFactory::setLastError(const std::string &error) const { lastError = error; } - //------------------------------------------------------------------ class Broker { private: std::map<std::string, Operator *> operators; @@ -64,11 +60,10 @@ namespace Binc { void assign(const std::string &fname, Operator *o, bool deletable = false); Operator::ParseResult parseStub(Request &cmd); - //-- inline Broker(Broker &); inline Broker(const Broker &); Broker(void); - ~Broker(void); + ~Broker(); }; inline Broker::Broker(Broker &) {} diff --git a/src/include/convert.h b/src/include/convert.h index 9e51027..2342a70 100644 --- a/src/include/convert.h +++ b/src/include/convert.h @@ -1,12 +1,13 @@ -/** -------------------------------------------------------------------- +/** * @file convert.h * @brief Declaration of miscellaneous convertion functions. * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ #ifndef convert_h_included #define convert_h_included + #include "address.h" #include "depot.h" @@ -22,7 +23,6 @@ namespace Binc { - //---------------------------------------------------------------------- inline std::string toString(int i_in) { char intbuf[16]; @@ -30,7 +30,6 @@ namespace Binc { return std::string(intbuf); } - //---------------------------------------------------------------------- inline std::string toString(unsigned int i_in) { char intbuf[16]; @@ -38,7 +37,6 @@ namespace Binc { return std::string(intbuf); } - //---------------------------------------------------------------------- inline std::string toString(unsigned long i_in) { char longbuf[40]; @@ -46,25 +44,22 @@ namespace Binc { return std::string(longbuf); } - //---------------------------------------------------------------------- inline std::string toString(const char *i_in) { return std::string(i_in); } - //---------------------------------------------------------------------- inline int atoi(const std::string &s_in) { return ::atoi(s_in.c_str()); } - //---------------------------------------------------------------------- inline std::string toHex(const std::string &s) { const char hexchars[] = "0123456789abcdef"; std::string tmp; - for (std::string::const_iterator i = s.begin(); i != s.end(); ++i) { - unsigned char c = (unsigned char)*i; + for (auto i : s) { + unsigned char c = static_cast<unsigned char>(i); tmp += hexchars[((c & 0xf0) >> 4)]; tmp += hexchars[c & 0x0f]; } @@ -72,22 +67,21 @@ namespace Binc { return tmp; } - //---------------------------------------------------------------------- inline std::string fromHex(const std::string &s) { // const char hexchars[] = "0123456789abcdef"; std::string tmp; - for (std::string::const_iterator i = s.begin(); i != s.end() && i + 1 != s.end(); i += 2) { + for (auto i = s.cbegin(); i != s.cend() && i + 1 != s.cend(); i += 2) { int n; unsigned char c = *i; unsigned char d = *(i + 1); char *t; - if ((t = strchr(hexchars, c)) == 0) return "out of range"; + if ((t = strchr(hexchars, c)) == nullptr) return "out of range"; n = (t - hexchars) << 4; - if ((t = strchr(hexchars, d)) == 0) return "out of range"; + if ((t = strchr(hexchars, d)) == nullptr) return "out of range"; n += (t - hexchars); if (n >= 0 && n <= 255) @@ -99,11 +93,10 @@ namespace Binc { return tmp; } - //---------------------------------------------------------------------- inline std::string toImapString(const std::string &s_in) { - for (std::string::const_iterator i = s_in.begin(); i != s_in.end(); ++i) { - unsigned char c = (unsigned char)*i; + for (const auto i : s_in) { + auto c = static_cast<unsigned char>(i); if (c <= 31 || c >= 127 || c == '\"' || c == '\\') return "{" + toString(s_in.length()) + "}\r\n" + s_in; } @@ -111,21 +104,18 @@ namespace Binc { return "\"" + s_in + "\""; } - //---------------------------------------------------------------------- inline void uppercase(std::string &input) { - for (std::string::iterator i = input.begin(); i != input.end(); ++i) - *i = toupper(*i); + for (auto &i : input) + i = toupper(i); } - //---------------------------------------------------------------------- inline void lowercase(std::string &input) { - for (std::string::iterator i = input.begin(); i != input.end(); ++i) - *i = tolower(*i); + for (char &i : input) + i = tolower(i); } - //---------------------------------------------------------------------- inline void chomp(std::string &s_in, const std::string &chars = " \t\r\n") { int n = s_in.length(); @@ -133,7 +123,6 @@ namespace Binc { s_in.resize(n-- - 1); } - //---------------------------------------------------------------------- inline void trim(std::string &s_in, const std::string &chars = " \t\r\n") { while (s_in != "" && chars.find(s_in[0]) != std::string::npos) @@ -141,14 +130,15 @@ namespace Binc { chomp(s_in, chars); } - //---------------------------------------------------------------------- inline const std::string unfold(const std::string &a, bool removecomment = true) { std::string tmp; + bool incomment = false; bool inquotes = false; - for (std::string::const_iterator i = a.begin(); i != a.end(); ++i) { - unsigned char c = (unsigned char)*i; + + for (const char i : a) { + unsigned char c = (unsigned char)i; if (!inquotes && removecomment) { if (c == '(') { incomment = true; @@ -156,14 +146,14 @@ namespace Binc { } else if (c == ')') { incomment = false; } else if (c != 0x0a && c != 0x0d) { - tmp += *i; + tmp += i; } } else if (c != 0x0a && c != 0x0d) { - tmp += *i; + tmp += i; } if (!incomment) { - if (*i == '\"') inquotes = !inquotes; + if (i == '\"') inquotes = !inquotes; } } @@ -171,46 +161,45 @@ namespace Binc { return tmp; } - //---------------------------------------------------------------------- inline void split(const std::string &s_in, const std::string &delim, std::vector<std::string> &dest, bool skipempty = true) { std::string token; - for (std::string::const_iterator i = s_in.begin(); i != s_in.end(); ++i) { - if (delim.find(*i) != std::string::npos) { + for (const char i : s_in) { + if (delim.find(i) != std::string::npos) { if (!skipempty || token != "") dest.push_back(token); token = ""; - } else - token += *i; + } else { + token += i; + } } if (token != "") dest.push_back(token); } - //---------------------------------------------------------------------- inline void splitAddr(const std::string &s_in, std::vector<std::string> &dest, bool skipempty = true) { static const std::string delim = ","; std::string token; bool inquote = false; - for (std::string::const_iterator i = s_in.begin(); i != s_in.end(); ++i) { - if (inquote && *i == '\"') + for (const char i : s_in) { + if (inquote && i == '\"') inquote = false; - else if (!inquote && *i == '\"') + else if (!inquote && i == '\"') inquote = true; - if (!inquote && delim.find(*i) != std::string::npos) { + if (!inquote && delim.find(i) != std::string::npos) { if (!skipempty || token != "") dest.push_back(token); token = ""; - } else - token += *i; + } else { + token += i; + } } if (token != "") dest.push_back(token); } - //---------------------------------------------------------------------- inline std::string toCanonMailbox(const std::string &s_in) { if (s_in.find("..") != std::string::npos) return ""; @@ -224,27 +213,27 @@ namespace Binc { return s_in; } - //------------------------------------------------------------------------ inline std::string toRegex(const std::string &s_in, char delimiter) { std::string regex = "^"; - for (std::string::const_iterator i = s_in.begin(); i != s_in.end(); ++i) { - if (*i == '.' || *i == '[' || *i == ']' || *i == '{' || *i == '}' || *i == '(' || *i == ')' - || *i == '^' || *i == '$' || *i == '?' || *i == '+' || *i == '\\') + for (const char i : s_in) { + if (i == '.' || i == '[' || i == ']' || i == '{' || i == '}' || i == '(' || i == ')' || i == '^' + || i == '$' || i == '?' || i == '+' || i == '\\') { regex += "\\"; - regex += *i; - } else if (*i == '*') + regex += i; + } else if (i == '*') { regex += ".*?"; - else if (*i == '%') { + } else if (i == '%') { regex += "(\\"; regex += delimiter; regex += "){0,1}"; regex += "[^\\"; regex += delimiter; regex += "]*?"; - } else - regex += *i; + } else { + regex += i; + } } if (regex[regex.length() - 1] == '?') @@ -255,13 +244,11 @@ namespace Binc { return regex; } - //------------------------------------------------------------------------ class BincStream { private: std::string nstr; public: - //-- BincStream &operator<<(std::ostream &(*)(std::ostream &)); BincStream &operator<<(const std::string &t); BincStream &operator<<(unsigned long t); @@ -269,24 +256,18 @@ namespace Binc { BincStream &operator<<(int t); BincStream &operator<<(char t); - //-- std::string popString(unsigned int size); - //-- char popChar(void); void unpopChar(char c); void unpopStr(const std::string &s); - //-- const std::string &str(void) const; - //-- unsigned int getSize(void) const; - //-- void clear(void); - //-- BincStream(void); ~BincStream(void); }; diff --git a/src/include/depot.h b/src/include/depot.h index bd4f743..3e65c8e 100644 --- a/src/include/depot.h +++ b/src/include/depot.h @@ -1,11 +1,13 @@ -/** -------------------------------------------------------------------- +/** * @filec depot.h * @file Declaration of the Depot class (the mail storage) * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #ifndef depot_h_included #define depot_h_included + #include <map> #include <string> #include <vector> @@ -18,7 +20,6 @@ namespace Binc { class Depot; class Status; - //------------------------------------------------------------------ class DepotFactory { private: std::vector<Depot *> depots; @@ -32,26 +33,24 @@ namespace Binc { ~DepotFactory(void); }; - //------------------------------------------------------------------ class Depot { public: - //-- class iterator { public: - std::string operator*(void) const; - void operator++(void); - bool operator!=(iterator) const; - bool operator==(iterator) const; - iterator(void); iterator(const iterator ©); iterator(DIR *, struct dirent *); ~iterator(void); - void deref(void); - iterator &operator=(const iterator ©); + std::string operator*(void) const; + void operator++(void); + bool operator!=(iterator) const; + bool operator==(iterator) const; + + void deref(void); + friend class Depot; private: @@ -77,11 +76,15 @@ namespace Binc { mutable std::map<std::string, Status> mailboxstatuses; public: + Depot(); + Depot(const std::string &name); + virtual ~Depot(void) = default; + virtual iterator begin(const std::string &) const; virtual const iterator &end(void) const; void setDelimiter(char); - const char getDelimiter(void) const; + char getDelimiter(void) const; virtual void assign(Mailbox *); @@ -116,14 +119,8 @@ namespace Binc { virtual bool unsubscribeTo(const std::string mailbox); virtual void loadSubscribes(void); virtual bool saveSubscribes(void) const; - - //-- - Depot(void); - Depot(const std::string &name); - virtual ~Depot(void); }; - //------------------------------------------------------------------ class MaildirPPDepot : public Depot { public: std::string mailboxToFilename(const std::string &m) const; @@ -131,7 +128,6 @@ namespace Binc { const std::string &getPersonalNamespace(void) const; - //-- MaildirPPDepot(); ~MaildirPPDepot(); @@ -139,13 +135,11 @@ namespace Binc { std::string privateNamespace; }; - //------------------------------------------------------------------ class IMAPdirDepot : public Depot { public: std::string mailboxToFilename(const std::string &m) const; std::string filenameToMailbox(const std::string &m) const; - //-- IMAPdirDepot(); ~IMAPdirDepot(); }; diff --git a/src/include/globals.h b/src/include/globals.h index d86ae4d..8d939b6 100644 --- a/src/include/globals.h +++ b/src/include/globals.h @@ -1,9 +1,10 @@ -/** -------------------------------------------------------------------- +/** * @file globals.h * @brief Global constants. * @author Andreas Aardal Hanssen, Erwin Hoffmann * @date 2002-2005, 2023 - * ----------------------------------------------------------------- **/ + */ + #ifndef GLOBAL_H_INCLUDED #define GLOBAL_H_INCLUDED @@ -20,6 +21,6 @@ namespace Binc { static const int TRANSFER_TIMEOUT = 20 * 60; static const int TRANSFER_BUFFER_SIZE = 1024; static const int INPUT_BUFFER_LIMIT = 8192; - }; + #endif diff --git a/src/include/imapparser.h b/src/include/imapparser.h index 5dfffb4..737d7c7 100644 --- a/src/include/imapparser.h +++ b/src/include/imapparser.h @@ -1,19 +1,18 @@ -/** -------------------------------------------------------------------- +/** * @file imapparser.h * @brief Declaration of the common items for parsing IMAP input * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #ifndef imapparser_h_included #define imapparser_h_included -/* stl includes */ #include <map> #include <string> #include <vector> namespace Binc { - //------------------------------------------------------------------------ class SequenceSet { public: void addRange(unsigned int a_in, unsigned int b_in); @@ -52,7 +51,6 @@ namespace Binc { std::vector<Range> internal; }; - //------------------------------------------------------------------------ class BincImapParserFetchAtt { public: std::string type; @@ -68,7 +66,6 @@ namespace Binc { std::string toString(void); }; - //------------------------------------------------------------------------ class BincImapParserSearchKey { public: std::string name; @@ -88,13 +85,11 @@ namespace Binc { BincImapParserSearchKey(void); }; - //------------------------------------------------------------------------ class BincImapParserData { public: virtual ~BincImapParserData(void) {} }; - //------------------------------------------------------------------------ class Request { private: std::string tag; diff --git a/src/include/imapserver.h b/src/include/imapserver.h index d3268ba..2afaadd 100644 --- a/src/include/imapserver.h +++ b/src/include/imapserver.h @@ -1,9 +1,9 @@ -/** -------------------------------------------------------------------- +/** * @file imapserver.h * @brief Declaration of the IMAPServer class. * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ namespace Binc { diff --git a/src/include/iodevice.h b/src/include/iodevice.h index 73dd2ab..1612d3a 100644 --- a/src/include/iodevice.h +++ b/src/include/iodevice.h @@ -1,14 +1,15 @@ -/** -------------------------------------------------------------------- +/** * @file iodevice.h * @brief Declaration of the IODevice class. * @author Andreas Aardal Hanssen * @date 2002, 2003 - * ----------------------------------------------------------------- **/ + */ + #ifndef iodevice_h_included #define iodevice_h_included #include "convert.h" // BincStream -// #include <iostream> + #include <string> #include <unistd.h> // ::write @@ -143,7 +144,7 @@ namespace Binc { For instance, if the output level is set to 0, then "Hello" is written, and the output level is set to 1, followed by writing - "Daisy", the output level limit value will decive wether only + "Daisy", the output level limit value will decide whether only "Hello" is written, or if also "Daisy" is written. A low value of the level gives higher priority, and a high level @@ -233,7 +234,7 @@ namespace Binc { \param dest The incoming byte is stored in this char. */ - bool readChar(char *dest = 0); + bool readChar(char *dest = nullptr); /*! FIXME: add docs @@ -347,7 +348,6 @@ namespace Binc { int dumpfd; }; - //---------------------------------------------------------------------- template<class T> IODevice &IODevice::operator<<(const T &source) { if ((flags & IsEnabled) && outputLevel <= outputLevelLimit) { @@ -359,8 +359,9 @@ namespace Binc { ::write(dumpfd, ss.str().c_str(), ss.getSize()); } - if (flags & HasInputLimit) + if (flags & HasInputLimit) { if (outputBuffer.getSize() > maxOutputBufferSize) flush(); + } } return *this; diff --git a/src/include/iofactory.h b/src/include/iofactory.h index 1a50e4e..70bd8f4 100644 --- a/src/include/iofactory.h +++ b/src/include/iofactory.h @@ -1,11 +1,13 @@ -/** -------------------------------------------------------------------- +/** * @file iofactory.h * @brief Declaration of the IOFactory class. * @author Andreas Aardal Hanssen * @date 2002, 2003 - * ----------------------------------------------------------------- **/ + */ + #ifndef IOFACTORY_H_INCLUDED #define IOFACTORY_H_INCLUDED + #include "iodevice.h" #include <map> diff --git a/src/include/mailbox.h b/src/include/mailbox.h index 870a695..d8c9592 100644 --- a/src/include/mailbox.h +++ b/src/include/mailbox.h @@ -1,9 +1,10 @@ -/** -------------------------------------------------------------------- +/** * @file mailbox.h * @brief Declaration of the Mailbox class (Mailbox is logical container) * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #ifndef mailbox_h_included #define mailbox_h_included @@ -27,10 +28,8 @@ namespace Binc { class PendingUpdates; class File; - //------------------------------------------------------------------------ class Mailbox { public: - //---------------------------------------------------------------------- class BaseIterator { public: BaseIterator(int sqn = 0); @@ -46,7 +45,6 @@ namespace Binc { unsigned int sqnr; }; - //---------------------------------------------------------------------- class iterator { public: iterator(BaseIterator &i); @@ -117,6 +115,8 @@ namespace Binc { Mailbox(void); virtual ~Mailbox(void); + Mailbox &operator=(const Mailbox &m) = delete; + friend class Mailbox::iterator; protected: diff --git a/src/include/maildir.h b/src/include/maildir.h index dda88df..4a4c106 100644 --- a/src/include/maildir.h +++ b/src/include/maildir.h @@ -1,11 +1,13 @@ -/** -------------------------------------------------------------------- +/** * @file maildir.h * @brief Declaration of the Maildir class. * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #ifndef maildir_h_included #define maildir_h_included + #include "mailbox.h" #include "maildirmessage.h" @@ -17,7 +19,6 @@ namespace Binc { static const std::string CACHEFILEVERSION = "1.0.5"; static const std::string UIDVALFILEVERSION = "1.0.5"; - //---------------------------------------------------------------------- class Lock { public: Lock(const std::string &path); @@ -27,14 +28,12 @@ namespace Binc { std::string lock; }; - //------------------------------------------------------------------------ class MaildirIndexItem { public: unsigned int uid; std::string fileName; }; - //------------------------------------------------------------------------ class MaildirIndex { private: std::map<std::string, MaildirIndexItem> idx; @@ -49,7 +48,6 @@ namespace Binc { MaildirIndexItem *find(const std::string &unique); }; - //------------------------------------------------------------------------ class Maildir : public Mailbox { public: typedef std::map<unsigned int, MaildirMessage> MessageMap; @@ -131,7 +129,6 @@ namespace Binc { bool fastCopy(Message &source, Mailbox &desttype, const std::string &destname); - //-- Maildir(void); ~Maildir(void); diff --git a/src/include/maildirmessage.h b/src/include/maildirmessage.h index 6bc2a20..96dcf73 100644 --- a/src/include/maildirmessage.h +++ b/src/include/maildirmessage.h @@ -1,15 +1,18 @@ -/** -------------------------------------------------------------------- +/** * @file maildirmessage.h * @brief Declaration of the MaildirMessage class. * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #ifndef maildirmessage_h_included #define maildirmessage_h_included + #include "address.h" #include "message.h" #include "mime.h" +#include <deque> #include <exception> #include <iostream> #include <map> @@ -278,7 +281,6 @@ namespace Binc { std::vector<std::string> *customFlags; }; - //------------------------------------------------------------------------ class MaildirMessageCache { public: ~MaildirMessageCache(); diff --git a/src/include/message.h b/src/include/message.h index e1bbf2b..130902e 100644 --- a/src/include/message.h +++ b/src/include/message.h @@ -1,11 +1,13 @@ -/** -------------------------------------------------------------------- +/** * @file message.h * @brief Declaration of the Message class. * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #ifndef message_h_included #define message_h_included + #include <string> #include <vector> @@ -18,33 +20,30 @@ namespace Binc { /*! - \class Message - \brief The Message class provides an interface for - IMAP messages. - - Mailbox independent operations and properties are available - through this interface. - - This class is an abstract, and has no implementation. - - \sa MaildirMessage - */ + * \class Message + * \brief The Message class provides an interface for + * IMAP messages. + * + * Mailbox independent operations and properties are available + * through this interface. + * + * This class is an abstract, and has no implementation. + * + * \sa MaildirMessage + */ class Message { public: - /*! - Standard IMAP message flags. - - */ + //! Standard IMAP message flags. enum Flags { - F_NONE = 0x00, /*!< No flag is set */ - F_SEEN = 0x01, /*!< The message has been seen */ - F_ANSWERED = 0x02, /*!< The message has been answered */ - F_DELETED = 0x04, /*!< The message is marked as deleted */ - F_DRAFT = 0x08, /*!< The message is a draft */ - F_RECENT = 0x10, /*!< The message arrived recently */ - F_FLAGGED = 0x20, /*!< The message is flagged / important */ - F_EXPUNGED = 0x40, /*!< The message has been expunged */ - F_PASSED = 0x80 /*!< The message has been bounced */ + F_NONE = 0x00, //!< No flag is set + F_SEEN = 0x01, //!< The message has been seen + F_ANSWERED = 0x02, //!< The message has been answered + F_DELETED = 0x04, //!< The message is marked as deleted + F_DRAFT = 0x08, //!< The message is a draft + F_RECENT = 0x10, //!< The message arrived recently + F_FLAGGED = 0x20, //!< The message is flagged / important + F_EXPUNGED = 0x40, //!< The message has been expunged + F_PASSED = 0x80 //!< The message has been bounced }; virtual void setUID(unsigned int) = 0; @@ -68,7 +67,7 @@ namespace Binc { virtual void setInternalDate(time_t) = 0; virtual time_t getInternalDate(void) const = 0; - // virtual void rewind(void) = 0; + // virtual void rewind(void) = 0; virtual int readChunk(std::string &) = 0; virtual bool appendChunk(const std::string &) = 0; virtual void close(void) = 0; diff --git a/src/include/mime-inputsource.h b/src/include/mime-inputsource.h index 8ff97f4..011c4c3 100644 --- a/src/include/mime-inputsource.h +++ b/src/include/mime-inputsource.h @@ -1,9 +1,10 @@ -/** -------------------------------------------------------------------- +/** * @file mime-inputsource.h * @brief The base class of the MIME input source * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #ifndef mime_inputsource_h_included #define mime_inputsource_h_included diff --git a/src/include/mime-utils.h b/src/include/mime-utils.h index 8a59041..a8f62c7 100644 --- a/src/include/mime-utils.h +++ b/src/include/mime-utils.h @@ -1,9 +1,10 @@ -/** -------------------------------------------------------------------- +/** * @file mime.cc * @brief Implementation of main mime parser components * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #ifndef mime_utils_h_included #define mime_utils_h_included @@ -12,8 +13,6 @@ #include <stdio.h> #include <string.h> -using namespace ::std; - inline bool compareStringToQueue(const char *s_in, char *bqueue, int pos, int size) { for (int i = 0; i < size; ++i) diff --git a/src/include/mime.h b/src/include/mime.h index f35ebb2..a8050af 100644 --- a/src/include/mime.h +++ b/src/include/mime.h @@ -1,11 +1,13 @@ -/** -------------------------------------------------------------------- +/** * @file mime.h * @brief Declaration of main mime parser components * @author Andreas Aardal Hanssen * @date Andreas Aardal Hanssen - * ----------------------------------------------------------------- **/ + */ + #ifndef mime_h_included #define mime_h_included + #include <map> #include <string> #include <vector> @@ -13,7 +15,6 @@ #include <stdio.h> namespace Binc { - //---------------------------------------------------------------------- class HeaderItem { private: mutable std::string key; @@ -30,12 +31,10 @@ namespace Binc { return value; } - //-- HeaderItem(void); HeaderItem(const std::string &key, const std::string &value); }; - //---------------------------------------------------------------------- class Header { private: mutable std::vector<HeaderItem> content; @@ -46,12 +45,10 @@ namespace Binc { void add(const std::string &name, const std::string &content); void clear(void) const; - //-- Header(void); ~Header(void); }; - //---------------------------------------------------------------------- class IODevice; class MimeDocument; @@ -140,7 +137,6 @@ namespace Binc { virtual ~MimePart(void); }; - //---------------------------------------------------------------------- class MimeDocument : public MimePart { private: mutable bool headerIsParsed; @@ -161,7 +157,6 @@ namespace Binc { return allIsParsed; } - //-- MimeDocument(void); ~MimeDocument(void); }; diff --git a/src/include/multilogdevice.h b/src/include/multilogdevice.h index a6f29f2..3ae4655 100644 --- a/src/include/multilogdevice.h +++ b/src/include/multilogdevice.h @@ -1,9 +1,10 @@ -/** -------------------------------------------------------------------- +/** * @file multilogdevice.h * @brief Declaration of the MultilogDevice class. * @author Andreas Aardal Hanssen * @date Andreas Aardal Hanssen - * ----------------------------------------------------------------- **/ + */ + #ifndef multilogdevice_h_included #define multilogdevice_h_included diff --git a/src/include/operators.h b/src/include/operators.h index a4e0f74..66c7e2b 100644 --- a/src/include/operators.h +++ b/src/include/operators.h @@ -1,11 +1,13 @@ -/** -------------------------------------------------------------------- +/** * @file operators.h * @brief Declaration of all operators. * @author Andreas Aardal Hanssen, Erwin Hoffmann * @date 2002-2005, 2023 - * ----------------------------------------------------------------- **/ + */ + #ifndef operators_h_included #define operators_h_included + #include "depot.h" #include "imapparser.h" #include "message.h" @@ -15,7 +17,6 @@ namespace Binc { - //-------------------------------------------------------------------- class Operator { public: enum ProcessResult { OK, BAD, NO, NOTHING, ABORT }; @@ -27,11 +28,9 @@ namespace Binc { virtual int getState(void) const = 0; virtual const std::string getName(void) const = 0; - //-- virtual ~Operator(void){}; }; - //-------------------------------------------------------------------- class AppendOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -43,7 +42,6 @@ namespace Binc { ~AppendOperator(void); }; - //-------------------------------------------------------------------- class AuthenticateOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -60,7 +58,6 @@ namespace Binc { ~AuthenticateOperator(void); }; - //-------------------------------------------------------------------- class CapabilityOperator : public Operator { std::vector<std::string> capabilities; @@ -77,7 +74,6 @@ namespace Binc { ~CapabilityOperator(void); }; - //-------------------------------------------------------------------- class CheckOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -90,7 +86,6 @@ namespace Binc { ~CheckOperator(void); }; - //-------------------------------------------------------------------- class CreateOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -103,7 +98,6 @@ namespace Binc { ~CreateOperator(void); }; - //-------------------------------------------------------------------- class CloseOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -116,7 +110,6 @@ namespace Binc { ~CloseOperator(void); }; - //-------------------------------------------------------------------- class CopyOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -129,7 +122,6 @@ namespace Binc { ~CopyOperator(void); }; - //-------------------------------------------------------------------- class DeleteOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -142,7 +134,6 @@ namespace Binc { ~DeleteOperator(void); }; - //-------------------------------------------------------------------- class ExpungeOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -155,7 +146,6 @@ namespace Binc { ~ExpungeOperator(void); }; - //-------------------------------------------------------------------- class FetchOperator : public Operator { protected: ParseResult expectSectionText(BincImapParserFetchAtt &f_in) const; @@ -175,7 +165,6 @@ namespace Binc { ~FetchOperator(void); }; - //-------------------------------------------------------------------- class IdOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -188,7 +177,6 @@ namespace Binc { ~IdOperator(void); }; - //-------------------------------------------------------------------- class IdleOperator : public Operator { protected: ParseResult expectSectionText(BincImapParserFetchAtt &f_in) const; @@ -208,7 +196,6 @@ namespace Binc { ~IdleOperator(void); }; - //-------------------------------------------------------------------- class ListOperator : public Operator { protected: enum MailboxFlags { DIR_SELECT = 0x01, DIR_MARKED = 0x02, DIR_NOINFERIORS = 0x04, DIR_LEAF = 0x08 }; @@ -227,7 +214,6 @@ namespace Binc { ~ListOperator(void); }; - //-------------------------------------------------------------------- class LoginOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -240,7 +226,6 @@ namespace Binc { ~LoginOperator(void); }; - //-------------------------------------------------------------------- class LogoutOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -253,7 +238,6 @@ namespace Binc { ~LogoutOperator(void); }; - //-------------------------------------------------------------------- class LsubOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -266,7 +250,6 @@ namespace Binc { ~LsubOperator(void); }; - //-------------------------------------------------------------------- class NamespaceOperator : public Operator { public: virtual ProcessResult process(Depot &, Request &); @@ -279,7 +262,6 @@ namespace Binc { ~NamespaceOperator(void); }; - //-------------------------------------------------------------------- class NoopOperator : public Operator { public: virtual ProcessResult process(Depot &, Request &); @@ -292,7 +274,6 @@ namespace Binc { ~NoopOperator(void); }; - //-------------------------------------------------------------------- class NoopPendingOperator : public NoopOperator { public: ProcessResult process(Depot &, Request &); @@ -301,7 +282,6 @@ namespace Binc { ~NoopPendingOperator(void); }; - //-------------------------------------------------------------------- class RenameOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -314,12 +294,10 @@ namespace Binc { ~RenameOperator(void); }; - //-------------------------------------------------------------------- class SearchOperator : public Operator { protected: ParseResult expectSearchKey(BincImapParserSearchKey &s_in) const; - //------------------------------------------------------------------ class SearchNode { std::string date; std::string astring; @@ -390,7 +368,6 @@ namespace Binc { void init(const BincImapParserSearchKey &a); - //- static bool compareNodes(const SearchNode &a, const SearchNode &b) { return a.getWeight() < b.getWeight(); @@ -411,7 +388,6 @@ namespace Binc { ~SearchOperator(void); }; - //-------------------------------------------------------------------- class SelectOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -424,7 +400,6 @@ namespace Binc { ~SelectOperator(void); }; - //-------------------------------------------------------------------- class ExamineOperator : public SelectOperator { public: const std::string getName(void) const; @@ -432,7 +407,6 @@ namespace Binc { ~ExamineOperator(void); }; - //-------------------------------------------------------------------- class StarttlsOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -446,7 +420,6 @@ namespace Binc { ~StarttlsOperator(void); }; - //-------------------------------------------------------------------- class StatusOperator : public Operator { std::map<int, Status> statuses; @@ -461,7 +434,6 @@ namespace Binc { ~StatusOperator(void); }; - //-------------------------------------------------------------------- class StoreOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -474,7 +446,6 @@ namespace Binc { ~StoreOperator(void); }; - //-------------------------------------------------------------------- class SubscribeOperator : public Operator { public: ProcessResult process(Depot &, Request &); @@ -487,7 +458,6 @@ namespace Binc { ~SubscribeOperator(void); }; - //-------------------------------------------------------------------- class UnsubscribeOperator : public Operator { public: ProcessResult process(Depot &, Request &); diff --git a/src/include/pendingupdates.h b/src/include/pendingupdates.h index c1adda0..eddf8f9 100644 --- a/src/include/pendingupdates.h +++ b/src/include/pendingupdates.h @@ -1,24 +1,24 @@ -/** -------------------------------------------------------------------- +/** * @file pendingupdates.h * @brief <---> * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ -#include <map> -#include <vector> + */ #ifndef pendingupdates_h_included #define pendingupdates_h_included +#include <map> +#include <string> +#include <vector> + namespace Binc { class Mailbox; - //------------------------------------------------------------------------ class PendingUpdates { public: enum { EXPUNGE = 0x01, FLAGS = 0x02, EXISTS = 0x04, RECENT = 0x08 }; - //---------------------------------------------------------------------- class expunged_const_iterator { private: std::vector<unsigned int>::iterator internal; @@ -29,16 +29,13 @@ namespace Binc { bool operator!=(expunged_const_iterator) const; bool operator==(expunged_const_iterator) const; - //-- expunged_const_iterator(void); expunged_const_iterator(std::vector<unsigned int>::iterator i); }; - //-- expunged_const_iterator beginExpunged(void); expunged_const_iterator endExpunged(void); - //---------------------------------------------------------------------- class flagupdates_const_iterator { private: std::map<unsigned int, unsigned int>::iterator internal; @@ -54,18 +51,15 @@ namespace Binc { void operator++(void); bool operator!=(flagupdates_const_iterator) const; - //-- flagupdates_const_iterator(void); flagupdates_const_iterator(std::map<unsigned int, unsigned int>::iterator i, std::map<unsigned int, std::vector<std::string>> *, std::map<unsigned int, unsigned int> *); }; - //-- flagupdates_const_iterator beginFlagUpdates(void); flagupdates_const_iterator endFlagUpdates(void); - //-- void addExpunged(unsigned int uid); void addFlagUpdates(unsigned int sqnr, unsigned int uid, @@ -78,7 +72,6 @@ namespace Binc { bool newExists(void) const; bool newRecent(void) const; - //-- PendingUpdates(void); ~PendingUpdates(void); diff --git a/src/include/recursivedescent.h b/src/include/recursivedescent.h index 96c3a7e..26ad794 100644 --- a/src/include/recursivedescent.h +++ b/src/include/recursivedescent.h @@ -1,11 +1,13 @@ -/** -------------------------------------------------------------------- +/** * @file recursivedescent.h * @brief Declaration of a recursive descent IMAP command parser. * @author Andreas Aardal Hanssen * @date Andreas Aardal Hanssen - * ----------------------------------------------------------------- **/ + */ + #ifndef expectcommand_h_inluded #define expectcommand_h_inluded + #include "imapparser.h" #include "operators.h" diff --git a/src/include/regmatch.h b/src/include/regmatch.h index 1471e90..5cc2274 100644 --- a/src/include/regmatch.h +++ b/src/include/regmatch.h @@ -1,16 +1,16 @@ -/** -------------------------------------------------------------------- +/** * @file regex.h * @brief Declaration of miscellaneous regexp functions. * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #ifndef regex_h_included #define regex_h_included #include <string> namespace Binc { - int regexMatch(const std::string &data_in, const std::string &p_in); } diff --git a/src/include/session.h b/src/include/session.h index ee96613..a329183 100644 --- a/src/include/session.h +++ b/src/include/session.h @@ -1,11 +1,13 @@ -/** -------------------------------------------------------------------- +/** * @file session.h * @brief <---> * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #ifndef session_h_included #define session_h_included + #include "argparser.h" #include <map> @@ -18,7 +20,6 @@ namespace Binc { class Depot; - //-------------------------------------------------------------------- class Session { public: std::map<std::string, std::string> attrs; @@ -37,13 +38,13 @@ namespace Binc { CommandLineArgs args; - int timeout() const; + int timeout(void) const; bool hasEnv(const std::string &key) const; std::string getEnv(const std::string &key); void setEnv(const std::string &key, const std::string &value); - const int getState(void) const; + int getState(void) const; void setState(int n); bool parseCommandLine(int argc, char *argv[]); void assignCommandLineArgs(void); @@ -61,7 +62,7 @@ namespace Binc { const std::string &getLastError(void) const; const std::string &getResponseCode(void) const; const std::string &getIP(void) const; - const std::string &getUserID() const; + const std::string &getUserID(void) const; pid_t getPid(void); const std::string &getHostname(void); void setLastError(const std::string &error) const; @@ -72,13 +73,11 @@ namespace Binc { inline Depot *getDepot(void) const; - //-- static Session &getInstance(void); bool initialize(int argc, char *argv[]); private: - //-- int state; std::string userid; std::string ip; diff --git a/src/include/status.h b/src/include/status.h index 9248505..ae944c0 100644 --- a/src/include/status.h +++ b/src/include/status.h @@ -1,28 +1,25 @@ -/** -------------------------------------------------------------------- +/** * @file status.h * @brief Declaration of the Status class. * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #ifndef status_h_included #define status_h_included namespace Binc { - //------------------------------------------------------------------------ class Status { - //-- int recent; int messages; int unseen; int uidvalidity; int uidnext; - //-- int statusid; public: - //-- inline void setMessages(int i) { messages = i; @@ -53,7 +50,6 @@ namespace Binc { uidnext = i; } - //-- inline int getMessages(void) const { return messages; @@ -84,7 +80,6 @@ namespace Binc { return uidnext; } - //-- Status(void); ~Status(void); }; diff --git a/src/include/stdiodevice.h b/src/include/stdiodevice.h index 7b4f465..9dac4fd 100644 --- a/src/include/stdiodevice.h +++ b/src/include/stdiodevice.h @@ -1,9 +1,10 @@ -/** -------------------------------------------------------------------- +/** * @file stdiodevice.h * @brief Declaration of the StdIODevice class. * @author Andreas Aardal Hanssen * @date 2002, 2003 - * ----------------------------------------------------------------- **/ + */ + #ifndef stdiodevice_h_included #define stdiodevice_h_included diff --git a/src/include/syslogdevice.h b/src/include/syslogdevice.h index 68d4112..78389d7 100644 --- a/src/include/syslogdevice.h +++ b/src/include/syslogdevice.h @@ -1,9 +1,10 @@ -/** -------------------------------------------------------------------- +/** * @file Syslogdevice.h * @brief Declaration of the SyslogDevice class. * @author Andreas Aardal Hanssen * @date 2002, 2003 - * ----------------------------------------------------------------- **/ + */ + #ifndef syslogdevice_h_included #define syslogdevice_h_included diff --git a/src/include/tools.h b/src/include/tools.h index 67ed91e..70f5cf4 100644 --- a/src/include/tools.h +++ b/src/include/tools.h @@ -1,9 +1,10 @@ -/** -------------------------------------------------------------------- +/** * @file tools.h * @brief Declaration of miscellaneous tools. * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #include <string> namespace Binc { @@ -16,7 +17,6 @@ namespace Binc { void setenv(const std::string &key, const std::string &value) const; std::string getenv(const std::string &key) const; - //-- static Tools &getInstance(void); }; |