diff options
author | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-10-07 23:30:49 +0200 |
---|---|---|
committer | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-10-08 11:35:51 +0200 |
commit | 40ee1fcfb77731f3cd7385882f41630af6aedb33 (patch) | |
tree | 6b13dd75ca9cfbac7daef4f0d5dc2e342ee9ef7d | |
parent | 1978c49bea5b439d993067c055cec47e70db8fd6 (diff) |
reduce line limit to 95
38 files changed, 253 insertions, 116 deletions
diff --git a/.clang-format b/.clang-format index 3e1f716..e6ef560 100644 --- a/.clang-format +++ b/.clang-format @@ -78,7 +78,7 @@ BreakBeforeTernaryOperators: true BreakConstructorInitializers: BeforeComma BreakInheritanceList: BeforeColon BreakStringLiterals: true -ColumnLimit: 105 +ColumnLimit: 95 CommentPragmas: '^ IWYU pragma:' CompactNamespaces: false ConstructorInitializerIndentWidth: 2 @@ -153,7 +153,7 @@ ObjCBreakBeforeNestedBlockParam: true ObjCSpaceAfterProperty: false ObjCSpaceBeforeProtocolList: true PackConstructorInitializers: CurrentLine -PenaltyBreakAssignment: 2 +PenaltyBreakAssignment: 480 PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 diff --git a/src/argparser.cc b/src/argparser.cc index d8e45ae..2d49c5f 100644 --- a/src/argparser.cc +++ b/src/argparser.cc @@ -224,7 +224,10 @@ void CommandLineArgs::addRequired(const string &arg, const string &desc, bool bo registerArg(arg, desc, boolean, false); } -void CommandLineArgs::registerArg(const string &arg, const string &desc, bool boolean, bool optional) +void CommandLineArgs::registerArg(const string &arg, + const string &desc, + bool boolean, + bool optional) { string name = arg; diff --git a/src/authenticate.cc b/src/authenticate.cc index 63a8b3a..7a69388 100644 --- a/src/authenticate.cc +++ b/src/authenticate.cc @@ -49,8 +49,8 @@ int Binc::authenticate(Depot &depot, // check if checkpassword is present if (access(session.unparsedArgs[0], X_OK) != 0) { // x is enough - bincError << "unable to start authenticator " << session.unparsedArgs[0] << ": " << strerror(errno) - << endl; + bincError << "unable to start authenticator " << session.unparsedArgs[0] << ": " + << strerror(errno) << endl; return 1; } @@ -101,7 +101,8 @@ int Binc::authenticate(Depot &depot, int result; int childspid = fork(); if (childspid == -1) { - bincLog << "bincimap-up: pid " << pid << " failed to start main server: " << strerror(errno) << endl; + bincLog << "bincimap-up: pid " << pid + << " failed to start main server: " << strerror(errno) << endl; return 1; } @@ -133,8 +134,9 @@ int Binc::authenticate(Depot &depot, if (session.unparsedArgs[0] != nullptr) { execvp(session.unparsedArgs[0], &session.unparsedArgs[0]); - bincDebug << "bincimap-up: pid " << pid << " authenticate(), [auth module] invocation of " - << session.unparsedArgs[0] << " failed: " << strerror(errno) << endl; + bincDebug << "bincimap-up: pid " << pid + << " authenticate(), [auth module] invocation of " << session.unparsedArgs[0] + << " failed: " << strerror(errno) << endl; bincDebug.flush(); exit(111); } @@ -152,7 +154,8 @@ int Binc::authenticate(Depot &depot, close(authintercom[0]); // create the string of data to be passed to the checkpassword stub - int dataSize = username.length() + password.length() + challenge.length() + timestamp.length(); + int dataSize = username.length() + password.length() + challenge.length() + + timestamp.length(); dataSize += 4; char *checkpasswordData = new char[dataSize]; char *cpTmp = checkpasswordData; @@ -225,8 +228,8 @@ int Binc::authenticate(Depot &depot, } if (n == 0) { - bincLog << "bincimap-up: pid " << pid << " server timed out after " << IDLE_TIMEOUT << " seconds" - << endl; + bincLog << "bincimap-up: pid " << pid << " server timed out after " << IDLE_TIMEOUT + << " seconds" << endl; timedout = true; break; } @@ -256,8 +259,8 @@ int Binc::authenticate(Depot &depot, if (w > 0) Session::getInstance().addReadBytes(w); if (w < 0) { - bincDebug << "bincimap-up: pid " << pid << " error writing to server: " << strerror(errno) - << endl; + bincDebug << "bincimap-up: pid " << pid + << " error writing to server: " << strerror(errno) << endl; eof = true; } } while (bincClient.canRead()); @@ -271,8 +274,8 @@ int Binc::authenticate(Depot &depot, eof = true; break; } else if (ret == -1) { - bincDebug << "bincimap-up: pid " << pid << " error reading from server: " << strerror(errno) - << endl; + bincDebug << "bincimap-up: pid " << pid + << " error reading from server: " << strerror(errno) << endl; eof = true; break; } else { @@ -290,8 +293,8 @@ int Binc::authenticate(Depot &depot, // catch the dead baby if (waitpid(childspid, &result, 0) != childspid) { - bincLog << "bincimap-up: pid " << pid << " <" << username - << "> authentication failed: " << (authenticated ? "server " : session.unparsedArgs[0]) + bincLog << "bincimap-up: pid " << pid << " <" << username << "> authentication failed: " + << (authenticated ? "server " : session.unparsedArgs[0]) << " waitpid returned unexpected value" << endl; string tmp = strerror(errno); @@ -304,9 +307,9 @@ int Binc::authenticate(Depot &depot, if (disconnected) return 0; if (WIFSIGNALED(result)) { - bincLog << "bincimap-up: pid " << pid << " <" << username - << "> authentication failed: " << (authenticated ? "server" : session.unparsedArgs[0]) - << " died by signal " << WTERMSIG(result) << endl; + bincLog << "bincimap-up: pid " << pid << " <" << username << "> authentication failed: " + << (authenticated ? "server" : session.unparsedArgs[0]) << " died by signal " + << WTERMSIG(result) << endl; sleep(AUTH_PENALTY); session.setState(Session::LOGOUT); return -1; diff --git a/src/depot.cc b/src/depot.cc index 86ac5f4..629bda9 100644 --- a/src/depot.cc +++ b/src/depot.cc @@ -226,8 +226,8 @@ bool Depot::renameMailbox(const string &s_in, const string &t_in) const } if (rename(sourcename.c_str(), destname.c_str()) != 0) { - bincWarning << "error renaming " << sourcename << " to " << destname << ": " << strerror(errno) - << endl; + bincWarning << "error renaming " << sourcename << " to " << destname << ": " + << strerror(errno) << endl; } else { nrenamed++; } @@ -241,7 +241,8 @@ bool Depot::renameMailbox(const string &s_in, const string &t_in) const } if (nrenamed == 0) { - setLastError("An error occurred when renaming " + toImapString(s_in) + " to " + toImapString(t_in) + setLastError("An error occurred when renaming " + toImapString(s_in) + " to " + + toImapString(t_in) + ". Try creating a new mailbox," " then copy over all messages." " Finally, delete the original mailbox"); @@ -370,7 +371,8 @@ bool Depot::saveSubscribes(void) const } if (rename(ftemplate.c_str(), ".subscribed") != 0) { - bincWarning << "failed to rename " << ftemplate << " to .subscribed: " << strerror(errno) << endl; + bincWarning << "failed to rename " << ftemplate << " to .subscribed: " << strerror(errno) + << endl; return false; } diff --git a/src/imapparser.cc b/src/imapparser.cc index d5e5f55..6610c3e 100644 --- a/src/imapparser.cc +++ b/src/imapparser.cc @@ -20,7 +20,14 @@ using namespace Binc; using std::string; -Request::Request(void) : uidmode(false), extra(nullptr), flags(), statuses(), bset(), searchkey(), fatt() +Request::Request(void) + : uidmode(false) + , extra(nullptr) + , flags() + , statuses() + , bset() + , searchkey() + , fatt() {} Request::~Request(void) diff --git a/src/imapserver.cc b/src/imapserver.cc index b19bc90..4003b93 100644 --- a/src/imapserver.cc +++ b/src/imapserver.cc @@ -154,7 +154,8 @@ int IMAPServer::run(void) } else if (serverStatus == OK && session.getState() != Session::LOGOUT) { bincClient << clientRequest.getTag() << " OK"; if (clientRequest.getUidMode()) bincClient << " UID"; - bincClient << " " << session.getResponseCode() << clientRequest.getName() << " completed"; + bincClient << " " << session.getResponseCode() << clientRequest.getName() + << " completed"; if (clientRequest.getContextInfo() != "") bincClient << " (" << clientRequest.getContextInfo() << ")"; @@ -192,8 +193,8 @@ int IMAPServer::run(void) if (serverStatus == Timeout) { bincClient << "* BYE Timeout after " << session.timeout() << " seconds of inactivity\n"; bincClient.flush(); - bincLog << "bincimapd: pid " << pid << " Timed out: <" << userID << "> after " << IDLE_TIMEOUT - << "s"; + bincLog << "bincimapd: pid " << pid << " Timed out: <" << userID << "> after " + << IDLE_TIMEOUT << "s"; } else if (serverStatus == ClientDisconnected) { bincLog << "bincimapd: pid " << pid << "Disconnected: <" << userID << ">\n"; } else { diff --git a/src/include/argparser.h b/src/include/argparser.h index 0e9b060..c3caf10 100644 --- a/src/include/argparser.h +++ b/src/include/argparser.h @@ -50,7 +50,10 @@ namespace Binc { const std::vector<std::string> &getUnqualifiedArgs(void) const; private: - void registerArg(const std::string &arg, const std::string &desc, bool boolean, bool optional); + void registerArg(const std::string &arg, + const std::string &desc, + bool boolean, + bool optional); std::string errString; std::map<std::string, ArgOpts> reg; diff --git a/src/include/convert.h b/src/include/convert.h index 2342a70..cfd4747 100644 --- a/src/include/convert.h +++ b/src/include/convert.h @@ -179,7 +179,9 @@ namespace Binc { if (token != "") dest.push_back(token); } - inline void splitAddr(const std::string &s_in, std::vector<std::string> &dest, bool skipempty = true) + inline void splitAddr(const std::string &s_in, + std::vector<std::string> &dest, + bool skipempty = true) { static const std::string delim = ","; std::string token; @@ -217,8 +219,8 @@ namespace Binc { { std::string regex = "^"; for (const char i : s_in) { - if (i == '.' || i == '[' || i == ']' || i == '{' || i == '}' || i == '(' || i == ')' || i == '^' - || i == '$' || i == '?' || i == '+' || i == '\\') + if (i == '.' || i == '[' || i == ']' || i == '{' || i == '}' || i == '(' || i == ')' + || i == '^' || i == '$' || i == '?' || i == '+' || i == '\\') { regex += "\\"; regex += i; diff --git a/src/include/mailbox.h b/src/include/mailbox.h index d8c9592..6d07282 100644 --- a/src/include/mailbox.h +++ b/src/include/mailbox.h @@ -90,7 +90,10 @@ namespace Binc { virtual unsigned int getUidNext(void) const = 0; virtual unsigned int getUidValidity(void) const = 0; - virtual bool getUpdates(bool scan, unsigned int type, PendingUpdates &updates, bool forceScan) = 0; + virtual bool getUpdates(bool scan, + unsigned int type, + PendingUpdates &updates, + bool forceScan) = 0; virtual void updateFlags(void) = 0; virtual void expungeMailbox(void) = 0; diff --git a/src/include/mime.h b/src/include/mime.h index a8050af..ecf02a9 100644 --- a/src/include/mime.h +++ b/src/include/mime.h @@ -116,7 +116,10 @@ namespace Binc { return bodystartoffsetcrlf; } - void printBody(int fd, Binc::IODevice &output, unsigned int startoffset, unsigned int length) const; + void printBody(int fd, + Binc::IODevice &output, + unsigned int startoffset, + unsigned int length) const; void printHeader(int fd, Binc::IODevice &output, std::vector<std::string> headers, @@ -124,7 +127,10 @@ namespace Binc { unsigned int startoffset, unsigned int length, std::string &storage) const; - void printDoc(int fd, Binc::IODevice &output, unsigned int startoffset, unsigned int length) const; + void printDoc(int fd, + Binc::IODevice &output, + unsigned int startoffset, + unsigned int length) const; virtual void clear(void) const; const MimePart *getPart(const std::string &findpart, diff --git a/src/include/operators.h b/src/include/operators.h index 66c7e2b..f6bb987 100644 --- a/src/include/operators.h +++ b/src/include/operators.h @@ -198,7 +198,12 @@ namespace Binc { class ListOperator : public Operator { protected: - enum MailboxFlags { DIR_SELECT = 0x01, DIR_MARKED = 0x02, DIR_NOINFERIORS = 0x04, DIR_LEAF = 0x08 }; + enum MailboxFlags { + DIR_SELECT = 0x01, + DIR_MARKED = 0x02, + DIR_NOINFERIORS = 0x04, + DIR_LEAF = 0x08 + }; std::map<std::string, unsigned int> cache; time_t cacheTimeout; @@ -351,7 +356,9 @@ namespace Binc { S_AND }; - static bool convertDate(const std::string &date, time_t &t, const std::string &delim = "-"); + static bool convertDate(const std::string &date, + time_t &t, + const std::string &delim = "-"); static bool convertDateHeader(const std::string &d_in, time_t &t); void order(void); diff --git a/src/include/session.h b/src/include/session.h index a329183..b02abaa 100644 --- a/src/include/session.h +++ b/src/include/session.h @@ -34,7 +34,12 @@ namespace Binc { bool mailboxchanges; - enum State { NONAUTHENTICATED = 0x01, AUTHENTICATED = 0x02, SELECTED = 0x04, LOGOUT = 0x00 }; + enum State { + NONAUTHENTICATED = 0x01, + AUTHENTICATED = 0x02, + SELECTED = 0x04, + LOGOUT = 0x00 + }; CommandLineArgs args; diff --git a/src/iodevice.cc b/src/iodevice.cc index 851bfb1..894e3e2 100644 --- a/src/iodevice.cc +++ b/src/iodevice.cc @@ -242,8 +242,8 @@ unsigned int IODevice::getWriteCount(void) const void IODevice::enableProtocolDumping(void) { BincStream ss; - ss << "/tmp/bincimap-dump-" << static_cast<int>(time(nullptr)) << "-" << Session::getInstance().getIP() - << "-XXXXXX"; + ss << "/tmp/bincimap-dump-" << static_cast<int>(time(nullptr)) << "-" + << Session::getInstance().getIP() << "-XXXXXX"; std::string safename = ss.str(); dumpfd = mkstemp(safename.data()); if (dumpfd == -1) dumpfd = 0; diff --git a/src/iofactory.cc b/src/iofactory.cc index e58efdb..dfb0870 100644 --- a/src/iofactory.cc +++ b/src/iofactory.cc @@ -38,7 +38,8 @@ IODevice &IOFactory::getClient(void) IOFactory &ioFactory = IOFactory::getInstance(); - if (ioFactory.devices.find("client") != ioFactory.devices.end()) return *ioFactory.devices["client"]; + if (ioFactory.devices.find("client") != ioFactory.devices.end()) + return *ioFactory.devices["client"]; return nulDevice; } @@ -49,6 +50,7 @@ IODevice &IOFactory::getLogger(void) IOFactory &ioFactory = IOFactory::getInstance(); - if (ioFactory.devices.find("log") != ioFactory.devices.end()) return *ioFactory.devices["log"]; + if (ioFactory.devices.find("log") != ioFactory.devices.end()) + return *ioFactory.devices["log"]; return nulDevice; } diff --git a/src/maildir-create.cc b/src/maildir-create.cc index 89d9f40..97b8f71 100644 --- a/src/maildir-create.cc +++ b/src/maildir-create.cc @@ -17,7 +17,11 @@ using namespace Binc; using std::string; -bool Binc::Maildir::createMailbox(const string &s_in, mode_t mode, uid_t owner, gid_t group, bool root) +bool Binc::Maildir::createMailbox(const string &s_in, + mode_t mode, + uid_t owner, + gid_t group, + bool root) { if (s_in != "." && mkdir(s_in.c_str(), mode) == -1) { setLastError("unable to create " + s_in + ": " + string(strerror(errno))); diff --git a/src/maildir-delete.cc b/src/maildir-delete.cc index 356128b..e0e2d30 100644 --- a/src/maildir-delete.cc +++ b/src/maildir-delete.cc @@ -71,7 +71,8 @@ bool Binc::Maildir::deleteMailbox(const string &s_in) } if (rmdir(s_in.c_str()) != 0) { - setLastError("error deleting Maildir: " + string(strerror(errno)) + " - status is undefined"); + setLastError("error deleting Maildir: " + string(strerror(errno)) + + " - status is undefined"); return false; } diff --git a/src/maildir-readcache.cc b/src/maildir-readcache.cc index 5864ff6..de51988 100644 --- a/src/maildir-readcache.cc +++ b/src/maildir-readcache.cc @@ -48,7 +48,8 @@ Maildir::ReadCacheResult Maildir::readCache(void) unsigned int readUidValidity; unsigned int readUidNext; - if (sscanf(inputBuffer, "%s %u %u", cacheFileVersionBuffer, &readUidValidity, &readUidNext) != 3 + if (sscanf(inputBuffer, "%s %u %u", cacheFileVersionBuffer, &readUidValidity, &readUidNext) + != 3 || strcmp(cacheFileVersionBuffer, BINC_CACHE) != 0) { // bump cache @@ -71,7 +72,9 @@ Maildir::ReadCacheResult Maildir::readCache(void) while (fgets(inputBuffer, sizeof(inputBuffer), fp)) { inputBuffer[sizeof(inputBuffer) - 1] = '\0'; - if (sscanf(inputBuffer, "%u %u %u %s", &readUID, &readInternalDate, &readSize, readUnique) != 4) { + if (sscanf(inputBuffer, "%u %u %u %s", &readUID, &readInternalDate, &readSize, readUnique) + != 4) + { // error in input fclose(fp); uidvalidity = time(nullptr); diff --git a/src/maildir-scan.cc b/src/maildir-scan.cc index 65548f7..09f334d 100644 --- a/src/maildir-scan.cc +++ b/src/maildir-scan.cc @@ -27,7 +27,8 @@ Lock::Lock(const string &path) int lockfd = -1; while ((lockfd = ::open(lock.c_str(), O_CREAT | O_WRONLY | O_EXCL, 0666)) == -1) { if (errno != EEXIST) { - bincWarning << "unable to lock mailbox: " << lock << ", " << string(strerror(errno)) << endl; + bincWarning << "unable to lock mailbox: " << lock << ", " << string(strerror(errno)) + << endl; return; } @@ -38,8 +39,8 @@ Lock::Lock(const string &path) if (unlink(lock.c_str()) == 0) { continue; } else { - bincWarning << "failed to force mailbox lock: " << lock << ", " << string(strerror(errno)) - << endl; + bincWarning << "failed to force mailbox lock: " << lock << ", " + << string(strerror(errno)) << endl; } } } else if (errno != ENOENT) { @@ -179,7 +180,8 @@ Maildir::ScanResult Maildir::scan(bool forceScan) // start with a dot. Do not try to extract information from unique // names." - The Maildir spec from cr.yp.to string filename = pdirent->d_name; - if (filename[0] == '.' || filename.find(':') != string::npos || filename.find('/') != string::npos) + if (filename[0] == '.' || filename.find(':') != string::npos + || filename.find('/') != string::npos) continue; string fullfilename = newpath + filename; @@ -223,7 +225,9 @@ Maildir::ScanResult Maildir::scan(bool forceScan) bool ours = false; for (const auto &newIt : newMessages) { - if ((filename == newIt.getUnique()) && (newIt.getInternalFlags() & MaildirMessage::Committed)) { + if ((filename == newIt.getUnique()) + && (newIt.getInternalFlags() & MaildirMessage::Committed)) + { ours = true; break; } @@ -240,8 +244,8 @@ Maildir::ScanResult Maildir::scan(bool forceScan) // move files from new/ to cur/ string newName = curpath + pdirent->d_name; if (rename((newpath + pdirent->d_name).c_str(), (newName + ":2,").c_str()) != 0) { - bincWarning << "error moving messages from new to cur: skipping " << newpath << pdirent->d_name - << ": " << strerror(errno) << endl; + bincWarning << "error moving messages from new to cur: skipping " << newpath + << pdirent->d_name << ": " << strerror(errno) << endl; continue; } } diff --git a/src/maildir-updateflags.cc b/src/maildir-updateflags.cc index ba18f82..40c91e2 100644 --- a/src/maildir-updateflags.cc +++ b/src/maildir-updateflags.cc @@ -90,8 +90,8 @@ void Binc::Maildir::updateFlags(void) continue; } - bincError << "failed to rename " << srcname << " to " << destname << ": " << strerror(errno) - << std::endl; + bincError << "failed to rename " << srcname << " to " << destname << ": " + << strerror(errno) << std::endl; } else { index.insert(uniquename, 0, uniquename + ":2," + flags); } diff --git a/src/maildir-writecache.cc b/src/maildir-writecache.cc index ceb2f81..63d7541 100644 --- a/src/maildir-writecache.cc +++ b/src/maildir-writecache.cc @@ -48,8 +48,8 @@ bool Binc::Maildir::writeCache(void) message.getSize(), message.getUnique().c_str()); std::vector<std::string> cflags = message.getCustomFlags(); - for (std::vector<std::string>::const_iterator it = cflags.begin(); it != cflags.end(); ++it) - fprintf(fp, " %s", (*it).c_str()); + for (const auto &it : cflags) + fprintf(fp, " %s", it.c_str()); fprintf(fp, "\n"); } @@ -64,7 +64,8 @@ bool Binc::Maildir::writeCache(void) } int dfd = open(path.c_str(), O_RDONLY); - if (dfd == -1 || (fsync(fd) && (errno != EROFS || errno != EINVAL)) || close(dfd)) return false; + if (dfd == -1 || (fsync(fd) && (errno != EROFS || errno != EINVAL)) || close(dfd)) + return false; return true; } diff --git a/src/maildir.cc b/src/maildir.cc index dc7e45a..4452010 100644 --- a/src/maildir.cc +++ b/src/maildir.cc @@ -146,7 +146,10 @@ Mailbox::iterator Maildir::begin(const SequenceSet &bset, unsigned int mod) cons Mailbox::iterator Maildir::end(void) const { - endIterator = iterator(const_cast<Maildir *>(this), messages.end(), endIterator.bset, endIterator.mod); + endIterator = iterator(const_cast<Maildir *>(this), + messages.end(), + endIterator.bset, + endIterator.mod); return Mailbox::iterator(endIterator); } @@ -181,7 +184,10 @@ void Maildir::setPath(const string &path_in) path = path_in; } -bool Maildir::getUpdates(bool doscan, unsigned int type, PendingUpdates &updates, bool forceScan) +bool Maildir::getUpdates(bool doscan, + unsigned int type, + PendingUpdates &updates, + bool forceScan) { if (doscan && scan(forceScan) != Success) return false; @@ -312,7 +318,12 @@ bool Maildir::getStatus(const string &path, Status &s) const char cacheFileVersionBuffer[512]; - if (sscanf(inputBuffer, "%s %u %u", cacheFileVersionBuffer, &readUidValidity, &readUidNext) != 3 + if (sscanf(inputBuffer, + "%s %u %u", + cacheFileVersionBuffer, + &readUidValidity, + &readUidNext) + != 3 || strcmp(cacheFileVersionBuffer, BINC_CACHE) != 0) { fclose(fp); @@ -328,7 +339,13 @@ bool Maildir::getStatus(const string &path, Status &s) const char readUnique[512]; while (fgets(inputBuffer, sizeof(inputBuffer), fp)) { inputBuffer[sizeof(inputBuffer) - 1] = '\0'; - if (sscanf(inputBuffer, "%u %u %u %s", &readUID, &readInternalDate, &readSize, readUnique) != 4) + if (sscanf(inputBuffer, + "%u %u %u %s", + &readUID, + &readInternalDate, + &readSize, + readUnique) + != 4) { fclose(fp); readUidValidity = 0; @@ -355,7 +372,8 @@ bool Maildir::getStatus(const string &path, Status &s) const struct dirent *direntp; while ((direntp = readdir(dirp)) != nullptr) { const string filename = direntp->d_name; - if (filename[0] == '.' || filename.find(':') != string::npos || filename.find('/') != string::npos) + if (filename[0] == '.' || filename.find(':') != string::npos + || filename.find('/') != string::npos) continue; ++recent; @@ -549,12 +567,12 @@ bool Maildir::commitNewMessages(const string &mbox) // FIXME: The message was probably moves away from new/ by // another IMAP session. bincWarning << "error rollbacking after failed commit to " << toImapString(mbox) - << ", failed to unlink " << toImapString(second) << ": " << strerror(errno) - << endl; + << ", failed to unlink " << toImapString(second) << ": " + << strerror(errno) << endl; } else { bincWarning << "error rollbacking after failed commit to " << toImapString(mbox) - << ", failed to unlink " << toImapString(second) << ": " << strerror(errno) - << endl; + << ", failed to unlink " << toImapString(second) << ": " + << strerror(errno) << endl; newMessages.clear(); return false; } diff --git a/src/maildirmessage.cc b/src/maildirmessage.cc index 56a75c4..a2ebb57 100644 --- a/src/maildirmessage.cc +++ b/src/maildirmessage.cc @@ -443,7 +443,8 @@ bool MaildirMessage::operator<(const MaildirMessage &a) const void MaildirMessage::close(void) { if (fd != -1) { - if ((internalFlags & WasWrittenTo) && fsync(fd) != 0 && errno != EINVAL && errno != EROFS) { + if ((internalFlags & WasWrittenTo) && fsync(fd) != 0 && errno != EINVAL && errno != EROFS) + { // FIXME: report this error } @@ -758,7 +759,9 @@ unsigned int MaildirMessage::getHeaderSize(const std::string §ion, return 0; } - const MimePart *part = doc->getPart(section, "", mime ? MimePart::FetchMime : MimePart::FetchHeader); + const MimePart *part = doc->getPart(section, + "", + mime ? MimePart::FetchMime : MimePart::FetchHeader); if (!part) { storage = ""; return 0; @@ -811,7 +814,9 @@ unsigned int MaildirMessage::getBodySize(const std::string §ion, return s < length ? s : length; } -bool MaildirMessage::printDoc(unsigned int startOffset, unsigned int length, bool onlyText) const +bool MaildirMessage::printDoc(unsigned int startOffset, + unsigned int length, + bool onlyText) const { if (!parseFull()) return false; @@ -967,7 +972,7 @@ MaildirMessageCache::ParseStatus MaildirMessageCache::getStatus(const MaildirMes void MaildirMessageCache::clear(void) { for (std::deque<const MaildirMessage *>::iterator i = parsed.begin(); i != parsed.end(); ++i) - parsed.clear(); + parsed.clear(); } void MaildirMessageCache::removeStatus(const MaildirMessage *m) @@ -976,7 +981,8 @@ void MaildirMessageCache::removeStatus(const MaildirMessage *m) statuses.erase(statuses.find(m)); - for (std::deque<const MaildirMessage *>::iterator i = parsed.begin(); i != parsed.end(); ++i) { + for (std::deque<const MaildirMessage *>::iterator i = parsed.begin(); i != parsed.end(); ++i) + { if (*i == m) { const_cast<MaildirMessage *>(*i)->close(); parsed.erase(i); diff --git a/src/mime-parsefull.cc b/src/mime-parsefull.cc index 5d5d836..faf02f0 100644 --- a/src/mime-parsefull.cc +++ b/src/mime-parsefull.cc @@ -586,7 +586,13 @@ int Binc::MimePart::parseFull(const string &toboundary, int &boundarysize) const &bodylength, &members); } else { - parseSinglePart(toboundary, &boundarysize, &nbodylines, &nlines, &eof, &foundendofpart, &bodylength); + parseSinglePart(toboundary, + &boundarysize, + &nbodylines, + &nlines, + &eof, + &foundendofpart, + &bodylength); } return (eof || foundendofpart) ? 1 : 0; diff --git a/src/multilogdevice.cc b/src/multilogdevice.cc index cf7c412..ea567ff 100644 --- a/src/multilogdevice.cc +++ b/src/multilogdevice.cc @@ -37,7 +37,11 @@ bool MultilogDevice::waitForWrite(void) const tv.tv_sec = getTimeout(); tv.tv_usec = 0; - int result = select(fileno(stderr) + 1, nullptr, &writeMask, nullptr, tv.tv_sec ? &tv : nullptr); + int result = select(fileno(stderr) + 1, + nullptr, + &writeMask, + nullptr, + tv.tv_sec ? &tv : nullptr); return result > 0; } @@ -50,7 +54,9 @@ bool MultilogDevice::waitForRead(void) const IODevice::WriteResult MultilogDevice::write(void) { for (;;) { - ssize_t wrote = ::write(fileno(stderr), outputBuffer.str().c_str(), outputBuffer.getSize()); + ssize_t wrote = ::write(fileno(stderr), + outputBuffer.str().c_str(), + outputBuffer.getSize()); if (wrote == -1) { if (errno == EINTR) diff --git a/src/operator-append.cc b/src/operator-append.cc index cf40fdf..27cbfba 100644 --- a/src/operator-append.cc +++ b/src/operator-append.cc @@ -229,7 +229,8 @@ Operator::ProcessResult AppendOperator::process(Depot &depot, Request &command) dest->setInternalDate(mktime(&mytm)); if (!mailbox->commitNewMessages(depot.mailboxToFilename(canonmailbox))) { - session.setLastError("failed to commit after successful APPEND: " + mailbox->getLastError()); + session.setLastError("failed to commit after successful APPEND: " + + mailbox->getLastError()); return NO; } diff --git a/src/operator-authenticate.cc b/src/operator-authenticate.cc index 2cb9ced..9add74c 100644 --- a/src/operator-authenticate.cc +++ b/src/operator-authenticate.cc @@ -135,7 +135,9 @@ Operator::ProcessResult AuthenticateOperator::Plain(string &username, string &pa return OK; } -Operator::ProcessResult AuthenticateOperator::Cram(string &username, string &password, string &challenge) +Operator::ProcessResult AuthenticateOperator::Cram(string &username, + string &password, + string &challenge) { Session &session = Session::getInstance(); diff --git a/src/operator-copy.cc b/src/operator-copy.cc index 77e1b9d..6f91349 100644 --- a/src/operator-copy.cc +++ b/src/operator-copy.cc @@ -58,12 +58,15 @@ Operator::ProcessResult CopyOperator::process(Depot &depot, Request &command) for (; success && i != srcMailbox->end(); ++i) { Message &source = *i; - if (srcMailbox->fastCopy(source, *destMailbox, depot.mailboxToFilename(toCanonMailbox(dmailbox)))) + if (srcMailbox->fastCopy(source, + *destMailbox, + depot.mailboxToFilename(toCanonMailbox(dmailbox)))) continue; // Have the destination mailbox create a message for us. - Message *dest = destMailbox->createMessage(depot.mailboxToFilename(toCanonMailbox(dmailbox)), - source.getInternalDate()); + Message *dest = destMailbox->createMessage( + depot.mailboxToFilename(toCanonMailbox(dmailbox)), + source.getInternalDate()); if (!dest) { session.setLastError(destMailbox->getLastError()); success = false; @@ -83,11 +86,13 @@ Operator::ProcessResult CopyOperator::process(Depot &depot, Request &command) if (readSize == 0) { break; } else if (readSize == -1) { - bincWarning << "when reading from message " << i.getSqnr() << "/" << source.getUID() << " in \"" - << srcMailbox->getName() << "\": " << source.getLastError() << std::endl; + bincWarning << "when reading from message " << i.getSqnr() << "/" << source.getUID() + << " in \"" << srcMailbox->getName() << "\": " << source.getLastError() + << std::endl; success = false; } else if (!dest->appendChunk(chunk)) { - bincWarning << "when writing to \"" << dmailbox << "\": " << dest->getLastError() << std::endl; + bincWarning << "when writing to \"" << dmailbox << "\": " << dest->getLastError() + << std::endl; success = false; } } while (success); @@ -96,13 +101,15 @@ Operator::ProcessResult CopyOperator::process(Depot &depot, Request &command) } if (!success && !destMailbox->rollBackNewMessages()) { - session.setLastError("Failed to rollback after unsuccessful copy: " + destMailbox->getLastError()); + session.setLastError("Failed to rollback after unsuccessful copy: " + + destMailbox->getLastError()); return NO; } if (success) { if (!destMailbox->commitNewMessages(depot.mailboxToFilename(toCanonMailbox(dmailbox)))) { - session.setLastError("Failed to commit after successful copy: " + destMailbox->getLastError()); + session.setLastError("Failed to commit after successful copy: " + + destMailbox->getLastError()); return NO; } } diff --git a/src/operator-fetch.cc b/src/operator-fetch.cc index 4fcdf1a..d0e2e6a 100644 --- a/src/operator-fetch.cc +++ b/src/operator-fetch.cc @@ -257,7 +257,9 @@ Operator::ProcessResult FetchOperator::process(Depot &depot, Request &request) } else { unsigned int size; if ((fatt.sectiontext == "" || fatt.sectiontext == "TEXT") && fatt.section == "") - size = message.getDocSize(fatt.offsetstart, fatt.offsetlength, fatt.sectiontext == "TEXT"); + size = message.getDocSize(fatt.offsetstart, + fatt.offsetlength, + fatt.sectiontext == "TEXT"); else size = message.getBodySize(fatt.section, fatt.offsetstart, fatt.offsetlength); @@ -271,7 +273,8 @@ Operator::ProcessResult FetchOperator::process(Depot &depot, Request &request) // set the \Seen flag if .PEEK is not used. if (!peek) { - if ((message.getStdFlags() & Message::F_SEEN) == 0) message.setStdFlag(Message::F_SEEN); + if ((message.getStdFlags() & Message::F_SEEN) == 0) + message.setStdFlag(Message::F_SEEN); } } else if (fatt.type == "RFC822") { bincClient << prefix; @@ -283,7 +286,8 @@ Operator::ProcessResult FetchOperator::process(Depot &depot, Request &request) message.printDoc(fatt.offsetstart, fatt.offsetlength); // set the \Seen flag - if ((message.getStdFlags() & Message::F_SEEN) == 0) message.setStdFlag(Message::F_SEEN); + if ((message.getStdFlags() & Message::F_SEEN) == 0) + message.setStdFlag(Message::F_SEEN); } else if (fatt.type == "RFC822.HEADER") { bincClient << prefix; @@ -291,7 +295,11 @@ Operator::ProcessResult FetchOperator::process(Depot &depot, Request &request) bincClient << fatt.toString(); vector<string> v; string dummy; - unsigned int size = message.getHeaderSize("", v, true, fatt.offsetstart, fatt.offsetlength); + unsigned int size = message.getHeaderSize("", + v, + true, + fatt.offsetstart, + fatt.offsetlength); bincClient << " {" << size << "}\r\n"; message.printHeader("", v, true, fatt.offsetstart, fatt.offsetlength); } else if (fatt.type == "RFC822.TEXT") { @@ -319,7 +327,8 @@ Operator::ProcessResult FetchOperator::process(Depot &depot, Request &request) message.printBody(fatt.section, fatt.offsetstart, fatt.offsetlength); // set the \Seen flag - if ((message.getStdFlags() & Message::F_SEEN) == 0) message.setStdFlag(Message::F_SEEN); + if ((message.getStdFlags() & Message::F_SEEN) == 0) + message.setStdFlag(Message::F_SEEN); } else { // Unrecognized fetch_att, this is stopped by the parser diff --git a/src/operator-idle.cc b/src/operator-idle.cc index ff95dbf..a278139 100644 --- a/src/operator-idle.cc +++ b/src/operator-idle.cc @@ -115,7 +115,8 @@ Operator::ProcessResult IdleOperator::process(Depot &depot, Request &command) Session &session = Session::getInstance(); #ifdef HAVE_FNOTIFY if (waitForNotification) { - bincClient << "* BYE Timeout after " << session.timeout() << " seconds of inactivity." << endl; + bincClient << "* BYE Timeout after " << session.timeout() << " seconds of inactivity." + << endl; session.setState(Session::LOGOUT); close(newfd); close(curfd); @@ -124,7 +125,8 @@ Operator::ProcessResult IdleOperator::process(Depot &depot, Request &command) #endif if (time(nullptr) > startTime + IDLE_TIMEOUT) { - bincClient << "* BYE Timeout after " << IDLE_TIMEOUT << " seconds of inactivity." << endl; + bincClient << "* BYE Timeout after " << IDLE_TIMEOUT << " seconds of inactivity." + << endl; session.setState(Session::LOGOUT); return NOTHING; } @@ -167,8 +169,8 @@ Operator::ProcessResult IdleOperator::process(Depot &depot, Request &command) // scan for changes in the mailbox and report to the client. if (!pendingUpdates(mailbox, - PendingUpdates::EXPUNGE | PendingUpdates::EXISTS | PendingUpdates::RECENT - | PendingUpdates::FLAGS, + PendingUpdates::EXPUNGE | PendingUpdates::EXISTS + | PendingUpdates::RECENT | PendingUpdates::FLAGS, true)) { Session &session = Session::getInstance(); diff --git a/src/operator-list.cc b/src/operator-list.cc index b304e08..7e65a11 100644 --- a/src/operator-list.cc +++ b/src/operator-list.cc @@ -64,7 +64,8 @@ Operator::ProcessResult ListOperator::process(Depot &depot, Request &command) string regex = toRegex(wildcard, depot.getDelimiter()); string wildcardLower = regex; lowercase(wildcardLower); - if (wildcardLower.substr(0, 6) == "^inbox") regex = "^[iI][nN][bB][oO][xX]" + regex.substr(6); + if (wildcardLower.substr(0, 6) == "^inbox") + regex = "^[iI][nN][bB][oO][xX]" + regex.substr(6); // remove leading or trailing delimiter in reference string ref = command.getMailbox(); @@ -81,7 +82,9 @@ Operator::ProcessResult ListOperator::process(Depot &depot, Request &command) // a map from mailbox name to flags std::map<string, unsigned int> mailboxes; - if (cacheTimeout == 0 || cacheTimeout < time(nullptr) - LIST_CACHE_TIMEOUT || session.mailboxchanges) { + if (cacheTimeout == 0 || cacheTimeout < time(nullptr) - LIST_CACHE_TIMEOUT + || session.mailboxchanges) + { session.mailboxchanges = false; // read through all entries in depository. @@ -155,7 +158,9 @@ Operator::ProcessResult ListOperator::process(Depot &depot, Request &command) // finally, print all mailbox entries with flags. for (auto i = mailboxes.begin(); i != mailboxes.end(); ++i) { - if (ref == "" || (ref.length() <= i->first.length() && ref == i->first.substr(0, ref.length()))) { + if (ref == "" + || (ref.length() <= i->first.length() && ref == i->first.substr(0, ref.length()))) + { if (regexMatch(i->first.substr(ref.length()), regex) == 0) { bincClient << "* LIST ("; string sep = ""; @@ -185,7 +190,8 @@ Operator::ProcessResult ListOperator::process(Depot &depot, Request &command) if (flags & DIR_NOINFERIORS) bincClient << sep << "\\Noinferiors"; - bincClient << ") \"" << depot.getDelimiter() << "\" " << toImapString(i->first) << std::endl; + bincClient << ") \"" << depot.getDelimiter() << "\" " << toImapString(i->first) + << std::endl; } } } diff --git a/src/operator-login.cc b/src/operator-login.cc index cacafbb..bc9efcb 100644 --- a/src/operator-login.cc +++ b/src/operator-login.cc @@ -65,7 +65,8 @@ Operator::ProcessResult LoginOperator::process(Depot &depot, Request &command) "your system administrator."); return NO; case 3: - bincClient << "* BYE Timeout after " << IDLE_TIMEOUT << " seconds of inactivity." << std::endl; + bincClient << "* BYE Timeout after " << IDLE_TIMEOUT << " seconds of inactivity." + << std::endl; break; case -1: bincClient << "* BYE The server died unexpectedly. Please contact " diff --git a/src/operator-lsub.cc b/src/operator-lsub.cc index 35c4d7d..7648586 100644 --- a/src/operator-lsub.cc +++ b/src/operator-lsub.cc @@ -57,7 +57,8 @@ Operator::ProcessResult LsubOperator::process(Depot &depot, Request &command) string regex = toRegex(wildcard, depot.getDelimiter()); string wildcardLower = regex; lowercase(wildcardLower); - if (wildcardLower.substr(0, 6) == "^inbox") regex = "^[iI][nN][bB][oO][xX]" + regex.substr(6); + if (wildcardLower.substr(0, 6) == "^inbox") + regex = "^[iI][nN][bB][oO][xX]" + regex.substr(6); // remove leading or trailing delimiter in reference string ref = command.getMailbox(); diff --git a/src/operator-search.cc b/src/operator-search.cc index aca9f1f..30b6ea2 100644 --- a/src/operator-search.cc +++ b/src/operator-search.cc @@ -27,7 +27,9 @@ using std::endl; using std::string; using std::vector; -bool SearchOperator::SearchNode::convertDate(const string &date, time_t &t, const string &delim) +bool SearchOperator::SearchNode::convertDate(const string &date, + time_t &t, + const string &delim) { vector<string> parts; split(date, delim, parts); diff --git a/src/operator-select.cc b/src/operator-select.cc index 1b0f5a4..d0a48bf 100644 --- a/src/operator-select.cc +++ b/src/operator-select.cc @@ -66,7 +66,8 @@ Operator::ProcessResult SelectOperator::process(Depot &depot, Request &command) // find first unseen int unseen = -1; - Mailbox::iterator i = mailbox->begin(SequenceSet::all(), Mailbox::SKIP_EXPUNGED | Mailbox::SQNR_MODE); + Mailbox::iterator i = mailbox->begin(SequenceSet::all(), + Mailbox::SKIP_EXPUNGED | Mailbox::SQNR_MODE); for (; i != mailbox->end(); ++i) { Message &message = *i; @@ -83,7 +84,8 @@ Operator::ProcessResult SelectOperator::process(Depot &depot, Request &command) // unseen if (unseen != -1) { bincClient << "*" - << " OK [UNSEEN " << unseen << "] Message " << unseen << " is first unseen" << endl; + << " OK [UNSEEN " << unseen << "] Message " << unseen << " is first unseen" + << endl; } // uidvalidity diff --git a/src/pendingupdates.cc b/src/pendingupdates.cc index bf4e0f2..402a75b 100644 --- a/src/pendingupdates.cc +++ b/src/pendingupdates.cc @@ -80,7 +80,8 @@ bool PendingUpdates::newRecent(void) const PendingUpdates::expunged_const_iterator::expunged_const_iterator(void) {} -PendingUpdates::expunged_const_iterator::expunged_const_iterator(vector<unsigned int>::iterator i) +PendingUpdates::expunged_const_iterator::expunged_const_iterator( + vector<unsigned int>::iterator i) : internal(i) {} @@ -221,8 +222,8 @@ bool Binc::pendingUpdates(Mailbox *mailbox, } vector<string> customFlags = i.getCustomFlags(); - for (vector<string>::const_iterator it = customFlags.begin(); it != customFlags.end(); ++it) { - if (flagv.size() > 0 || it != customFlags.begin()) bincClient << " "; + for (auto it = customFlags.cbegin(); it != customFlags.cend(); ++it) { + if (flagv.size() > 0 || it != customFlags.cbegin()) bincClient << " "; bincClient << *it; } diff --git a/src/recursivedescent.cc b/src/recursivedescent.cc index e490865..de7aa39 100644 --- a/src/recursivedescent.cc +++ b/src/recursivedescent.cc @@ -346,7 +346,8 @@ Operator::ParseResult Binc::expectListMailbox(string &s_in) if ((res = expectString(s_in)) == Operator::ACCEPT) return Operator::ACCEPT; int c; - if ((res = expectAtomChar(c)) == Operator::ACCEPT || (res = expectListWildcards(c)) == Operator::ACCEPT + if ((res = expectAtomChar(c)) == Operator::ACCEPT + || (res = expectListWildcards(c)) == Operator::ACCEPT || (res = expectThisString("]")) == Operator::ACCEPT) { do { diff --git a/src/session-initialize-bincimapd.cc b/src/session-initialize-bincimapd.cc index a574363..871510b 100644 --- a/src/session-initialize-bincimapd.cc +++ b/src/session-initialize-bincimapd.cc @@ -38,8 +38,8 @@ bool Session::initialize(int argc, char *argv[]) { IOFactory &ioFactory = IOFactory::getInstance(); - IODevice *stdioDevice = - new StdIODevice(IODevice::IsEnabled | IODevice::HasInputLimit | IODevice::HasTimeout); + IODevice *stdioDevice = new StdIODevice(IODevice::IsEnabled | IODevice::HasInputLimit + | IODevice::HasTimeout); stdioDevice->setFlags(IODevice::HasOutputLimit); stdioDevice->setMaxOutputBufferSize(TRANSFER_BUFFER_SIZE); ioFactory.addDevice(stdioDevice); @@ -174,14 +174,16 @@ bool Session::initialize(int argc, char *argv[]) // automatically create depot directory if it's not there already string path; - if (session.args.getUnqualifiedArgs().size() > 0) path = session.args.getUnqualifiedArgs()[0]; + if (session.args.getUnqualifiedArgs().size() > 0) + path = session.args.getUnqualifiedArgs()[0]; if (path == "") { path = "."; } else if (chdir(path.c_str()) != 0) { mkdir(path.c_str(), 0777); if (chdir(path.c_str()) != 0) { - bincLog << "bincimapd: pid" << pid << " Error entering depot " + toImapString(path) + ": " - << strerror(errno) << endl; + bincLog << "bincimapd: pid" << pid + << " Error entering depot " + toImapString(path) + ": " << strerror(errno) + << endl; return false; } } @@ -200,8 +202,9 @@ bool Session::initialize(int argc, char *argv[]) const string details = logindetails; string::size_type det = details.find('+'); if (det == string::npos) { - bincLog << "bincimapd: pid " << pid << " Invalid content of BINCIMAP_LOGIN - did you invoke " - << argv[0] << " correctly?" << endl; + bincLog << "bincimapd: pid " << pid + << " Invalid content of BINCIMAP_LOGIN - did you invoke " << argv[0] + << " correctly?" << endl; return false; } diff --git a/src/stdiodevice.cc b/src/stdiodevice.cc index b078c7a..411bdc5 100644 --- a/src/stdiodevice.cc +++ b/src/stdiodevice.cc @@ -44,7 +44,11 @@ bool StdIODevice::waitForWrite(void) const tv.tv_sec = timeout; tv.tv_usec = 0; - int result = select(fileno(stdout) + 1, nullptr, &writeMask, nullptr, timeout ? &tv : nullptr); + int result = select(fileno(stdout) + 1, + nullptr, + &writeMask, + nullptr, + timeout ? &tv : nullptr); if (result == 0) error = Timeout; return result > 0; } @@ -67,7 +71,9 @@ bool StdIODevice::waitForRead(void) const IODevice::WriteResult StdIODevice::write(void) { for (;;) { - ssize_t wrote = ::write(fileno(stdout), outputBuffer.str().c_str(), outputBuffer.getSize()); + ssize_t wrote = ::write(fileno(stdout), + outputBuffer.str().c_str(), + outputBuffer.getSize()); if (wrote == -1) { if (errno == EINTR) |