clang format
This commit is contained in:
parent
c503cddd85
commit
242e996ded
@ -7,9 +7,7 @@ using namespace mstch;
|
||||
|
||||
std::function<std::string(const std::string &)> mstch::config::escape;
|
||||
|
||||
std::string mstch::render(
|
||||
const std::string& tmplt,
|
||||
const node& root,
|
||||
std::string mstch::render(const std::string &tmplt, const node &root,
|
||||
const std::map<std::string, std::string> &partials)
|
||||
{
|
||||
std::map<std::string, template_type> partial_templates;
|
||||
|
@ -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 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)
|
||||
{
|
||||
@ -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());
|
||||
}
|
||||
|
||||
|
||||
Crypto::Crypto() { assert(sodium_init() == 0); }
|
||||
|
||||
Crypto::~Crypto() {}
|
||||
|
@ -65,9 +65,5 @@ namespace nntpchan
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ev::Loop * NewMainLoop()
|
||||
{
|
||||
return new LoopImpl;
|
||||
}
|
||||
ev::Loop *NewMainLoop() { return new LoopImpl; }
|
||||
}
|
@ -23,6 +23,5 @@ void LineReader::Data(const char *data, ssize_t l)
|
||||
m_line.clear();
|
||||
}
|
||||
|
||||
|
||||
bool LineReader::ShouldClose() { return m_close; }
|
||||
}
|
||||
|
@ -10,8 +10,8 @@
|
||||
namespace nntpchan
|
||||
{
|
||||
NNTPServerHandler::NNTPServerHandler(fs::path storage)
|
||||
: LineReader(1024), m_article(nullptr), m_auth(nullptr), m_store(storage),
|
||||
m_authed(false), m_state(eStateReadCommand)
|
||||
: LineReader(1024), m_article(nullptr), m_auth(nullptr), m_store(storage), m_authed(false),
|
||||
m_state(eStateReadCommand)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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 NNTPServerConn::Greet()
|
||||
{
|
||||
IConnHandler *handler = GetHandler();
|
||||
|
@ -7,9 +7,7 @@
|
||||
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()
|
||||
{
|
||||
@ -51,7 +49,8 @@ void Server::OnAccept(int f)
|
||||
int Server::accept()
|
||||
{
|
||||
int res = ::accept(fd, nullptr, nullptr);
|
||||
if(res == -1) return res;
|
||||
if (res == -1)
|
||||
return res;
|
||||
OnAccept(res);
|
||||
return res;
|
||||
}
|
||||
@ -80,9 +79,7 @@ std::string IConnHandler::GetNextLine()
|
||||
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; }
|
||||
|
||||
@ -96,10 +93,7 @@ int IServerConn::read(char * buf, size_t sz)
|
||||
return readsz;
|
||||
}
|
||||
|
||||
bool IServerConn::keepalive()
|
||||
{
|
||||
return !m_handler->ShouldClose();
|
||||
}
|
||||
bool IServerConn::keepalive() { return !m_handler->ShouldClose(); }
|
||||
|
||||
int IServerConn::write(size_t avail)
|
||||
{
|
||||
@ -150,8 +144,7 @@ int IServerConn::write(size_t avail)
|
||||
m_writeLeftover = line;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
while(avail > 0);
|
||||
} while (avail > 0);
|
||||
return written;
|
||||
}
|
||||
|
||||
|
@ -23,14 +23,12 @@ void ArticleStorage::SetPath(const fs::path &fpath)
|
||||
errno = 0;
|
||||
}
|
||||
|
||||
|
||||
bool ArticleStorage::init_skiplist(const std::string &subdir) const
|
||||
{
|
||||
fs::path skiplist = skiplist_root(subdir);
|
||||
const auto subdirs = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
|
||||
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
|
||||
'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
|
||||
'y', 'z', '2', '3', '4', '5', '6', '7',
|
||||
const auto subdirs = {
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
|
||||
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '2', '3', '4', '5', '6', '7',
|
||||
};
|
||||
for (const auto &s : subdirs)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
{
|
||||
return root / name.substr(0, 1);
|
||||
|
Reference in New Issue
Block a user