/*
*
* (C) 2003-2025 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
#include "module.h"
#include "modules/botserv/badwords.h"
#include "modules/botserv/kick.h"
#include "modules/chanserv/entrymsg.h"
#include "modules/chanserv/mode.h"
#include "modules/hostserv/request.h"
#include "modules/info.h"
#include "modules/nickserv/cert.h"
#include "modules/operserv/forbid.h"
#include "modules/operserv/news.h"
#include "modules/operserv/oper.h"
#include "modules/operserv/session.h"
#include "modules/set_misc.h"
#include "modules/suspend.h"
// Handles reading from an Atheme database row.
class AthemeRow final
{
private:
// The number of failed reads.
unsigned error = 0;
// The underlying token stream.
spacesepstream stream;
public:
AthemeRow(const Anope::string &str)
: stream(str)
{
}
operator bool() const
{
return !error;
}
// Retrieves the next parameter.
Anope::string Get()
{
Anope::string token;
if (!stream.GetToken(token))
error++;
return token;
}
// Retrieves the next parameter as a number.
template<typename Numeric>
std::enable_if_t<std::is_arithmetic_v<Numeric>, Numeric> GetNum()
{
return Anope::Convert<Numeric>(Get(), 0);
}
// Retrieves the entire row.
Anope::string GetRow()
{
return stream.GetString();
}
// Retrieves the remaining data in the row.
Anope::string GetRemaining()
{
auto remaining = stream.GetRemaining();
if (remaining.empty())
error++;
return remaining;
}
bool LogError(Module *mod)
{
Log(mod) << "Malformed database line (expected " << error << " fields): " << GetRow();
return false;
}
};
struct ModeData final
{
char le