Archived
1
0

clang format

This commit is contained in:
Jeff Becker 2018-05-06 08:10:20 -04:00
parent c503cddd85
commit 242e996ded
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
9 changed files with 144 additions and 163 deletions

View File

@ -7,9 +7,7 @@ using namespace mstch;
std::function<std::string(const std::string &)> mstch::config::escape; std::function<std::string(const std::string &)> mstch::config::escape;
std::string mstch::render( std::string mstch::render(const std::string &tmplt, const node &root,
const std::string& tmplt,
const node& root,
const std::map<std::string, std::string> &partials) const std::map<std::string, std::string> &partials)
{ {
std::map<std::string, template_type> partial_templates; std::map<std::string, template_type> partial_templates;

View File

@ -7,7 +7,10 @@ namespace nntpchan
{ {
void SHA512(const uint8_t *d, const std::size_t l, SHA512Digest &h) { crypto_hash(h.data(), d, l); } void SHA512(const uint8_t *d, const std::size_t l, SHA512Digest &h) { crypto_hash(h.data(), d, l); }
void Blake2B(const uint8_t *d, std::size_t l, Blake2BDigest & h) { crypto_generichash(h.data(), h.size(), d, l, nullptr, 0); } void Blake2B(const uint8_t *d, std::size_t l, Blake2BDigest &h)
{
crypto_generichash(h.data(), h.size(), d, l, nullptr, 0);
}
std::string Blake2B_base32(const std::string &str) std::string Blake2B_base32(const std::string &str)
{ {
@ -16,7 +19,6 @@ void SHA512(const uint8_t *d, const std::size_t l, SHA512Digest &h) { crypto_has
return B32Encode(d.data(), d.size()); return B32Encode(d.data(), d.size());
} }
Crypto::Crypto() { assert(sodium_init() == 0); } Crypto::Crypto() { assert(sodium_init() == 0); }
Crypto::~Crypto() {} Crypto::~Crypto() {}

View File

@ -65,9 +65,5 @@ namespace nntpchan
} }
} }
ev::Loop *NewMainLoop() { return new LoopImpl; }
ev::Loop * NewMainLoop()
{
return new LoopImpl;
}
} }

View File

@ -23,6 +23,5 @@ void LineReader::Data(const char *data, ssize_t l)
m_line.clear(); m_line.clear();
} }
bool LineReader::ShouldClose() { return m_close; } bool LineReader::ShouldClose() { return m_close; }
} }

View File

@ -10,8 +10,8 @@
namespace nntpchan namespace nntpchan
{ {
NNTPServerHandler::NNTPServerHandler(fs::path storage) NNTPServerHandler::NNTPServerHandler(fs::path storage)
: LineReader(1024), m_article(nullptr), m_auth(nullptr), m_store(storage), : LineReader(1024), m_article(nullptr), m_auth(nullptr), m_store(storage), m_authed(false),
m_authed(false), m_state(eStateReadCommand) m_state(eStateReadCommand)
{ {
} }

View File

@ -43,7 +43,6 @@ std::string NNTPServer::InstanceName() const { return m_servername; }
void NNTPServer::OnAcceptError(int status) { std::cerr << "nntpserver::accept() " << strerror(status) << std::endl; } void NNTPServer::OnAcceptError(int status) { std::cerr << "nntpserver::accept() " << strerror(status) << std::endl; }
void NNTPServerConn::Greet() void NNTPServerConn::Greet()
{ {
IConnHandler *handler = GetHandler(); IConnHandler *handler = GetHandler();

View File

@ -7,9 +7,7 @@
namespace nntpchan namespace nntpchan
{ {
Server::Server(ev::Loop * loop) : ev::io(-1), m_Loop(loop) Server::Server(ev::Loop *loop) : ev::io(-1), m_Loop(loop) {}
{
}
void Server::close() void Server::close()
{ {
@ -51,7 +49,8 @@ void Server::OnAccept(int f)
int Server::accept() int Server::accept()
{ {
int res = ::accept(fd, nullptr, nullptr); int res = ::accept(fd, nullptr, nullptr);
if(res == -1) return res; if (res == -1)
return res;
OnAccept(res); OnAccept(res);
return res; return res;
} }
@ -80,9 +79,7 @@ std::string IConnHandler::GetNextLine()
return line; return line;
} }
IServerConn::IServerConn(int fd, Server *parent, IConnHandler *h) : ev::io(fd), m_parent(parent), m_handler(h) IServerConn::IServerConn(int fd, Server *parent, IConnHandler *h) : ev::io(fd), m_parent(parent), m_handler(h) {}
{
}
IServerConn::~IServerConn() { delete m_handler; } IServerConn::~IServerConn() { delete m_handler; }
@ -96,10 +93,7 @@ int IServerConn::read(char * buf, size_t sz)
return readsz; return readsz;
} }
bool IServerConn::keepalive() bool IServerConn::keepalive() { return !m_handler->ShouldClose(); }
{
return !m_handler->ShouldClose();
}
int IServerConn::write(size_t avail) int IServerConn::write(size_t avail)
{ {
@ -150,8 +144,7 @@ int IServerConn::write(size_t avail)
m_writeLeftover = line; m_writeLeftover = line;
return -1; return -1;
} }
} } while (avail > 0);
while(avail > 0);
return written; return written;
} }

View File

@ -23,14 +23,12 @@ void ArticleStorage::SetPath(const fs::path &fpath)
errno = 0; errno = 0;
} }
bool ArticleStorage::init_skiplist(const std::string &subdir) const bool ArticleStorage::init_skiplist(const std::string &subdir) const
{ {
fs::path skiplist = skiplist_root(subdir); fs::path skiplist = skiplist_root(subdir);
const auto subdirs = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', const auto subdirs = {
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '2', '3', '4', '5', '6', '7',
'y', 'z', '2', '3', '4', '5', '6', '7',
}; };
for (const auto &s : subdirs) for (const auto &s : subdirs)
fs::create_directories(skiplist / std::string(&s, 1)); fs::create_directories(skiplist / std::string(&s, 1));
@ -85,11 +83,7 @@ void ArticleStorage::EnsureSymlinks(const std::string &msgid) const
skiplist_dir(posts_skiplist_dir, msgidhash); skiplist_dir(posts_skiplist_dir, msgidhash);
} }
fs::path ArticleStorage::skiplist_root(const std::string &name) const { return basedir / name; }
fs::path ArticleStorage::skiplist_root(const std::string & name ) const
{
return basedir / name;
}
fs::path ArticleStorage::skiplist_dir(const fs::path &root, const std::string &name) const fs::path ArticleStorage::skiplist_dir(const fs::path &root, const std::string &name) const
{ {
return root / name.substr(0, 1); return root / name.substr(0, 1);