1
0
mirror of https://github.com/anope/anope.git synced 2026-06-12 19:14:47 +02:00

Merge tag '2.0.8' into 2.1.

This commit is contained in:
Sadie Powell
2020-10-07 14:42:33 +01:00
12 changed files with 139 additions and 130 deletions
+4
View File
@@ -7,6 +7,7 @@ jobs:
runs-on: ubuntu-20.04
env:
CXX: ${{ matrix.compiler }}
CXXFLAGS: -std=${{ matrix.standard }}
steps:
- uses: actions/checkout@v2
- name: Install dependencies
@@ -45,3 +46,6 @@ jobs:
compiler:
- clang++
- g++
standard:
- c++98
- c++17
+1 -1
View File
@@ -262,7 +262,7 @@ module
* being recognized, unless they manually add an address to the access list of their account.
* This directive is optional.
*/
addaccessonreg = yes
addaccessonreg = no
}
command { service = "NickServ"; name = "ACCESS"; command = "nickserv/access"; }
+1 -1
View File
@@ -533,7 +533,7 @@ command { service = "OperServ"; name = "RELOAD"; command = "operserv/reload"; pe
*
* This module enables session limiting. Session limiting prevents users from connecting more than a certain
* number of times from the same IP at the same time - thus preventing most types of cloning.
* Once a host reaches it's session limit, all clients attempting to connect from that host will
* Once a host reaches its session limit, all clients attempting to connect from that host will
* be killed. Exceptions to the default session limit can be defined via the exception list.
*
* Used to manage the session limit exception list, and view currently active sessions.
+12 -1
View File
@@ -1,5 +1,16 @@
Anope Version 2.0.8-git
Anope Version 2.0.8
-------------------
Add +K channel mode for ircd-hybrid
Add immutable identifiers to user accounts
Fix build on systems that use musl libc
Fix help of global/global not showing the correct origin nick
Fix not removing vhosts when an nick is dropped
Fix parsing channel metadata on InspIRCd 3+
Fix parsing kicks on InspIRCd 3+
Fix parsing topic changes on InspIRCd 3+
Fix topiclock on InspIRCd
Modernize the ircd-hybrid protocol module
Anope Version 2.0.7
-------------------
+2 -1
View File
@@ -1,5 +1,6 @@
Anope Version 2.0.8-git
Anope Version 2.0.8
-------------------
Fix ns_register:unconfirmedexpire not being used
Anope Version 2.0.7
-------------------
+1 -1
View File
@@ -168,7 +168,7 @@ Table of Contents
* Bahamut 1.4.27 or later (including 1.8)
* Charybdis 3.4 or later
* Hybrid 8.2 or later
* ircd-hybrid 8.2.23 or later
* InspIRCd 3 or later
* ngIRCd 19.2 or later
* Plexus 3 or later
+3
View File
@@ -16,6 +16,9 @@ class GlobalService : public Service
{
}
/** Retrieves the bot which sends global messages unless otherwise specified. */
virtual Reference<BotInfo> GetDefaultSender() = 0;
/** Send out a global message to all users
* @param sender Our client which should send the global
* @param source The sender of the global
+7 -1
View File
@@ -37,10 +37,16 @@ class CommandGLGlobal : public Command
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
{
Reference<BotInfo> sender;
if (GService)
sender = GService->GetDefaultSender();
if (!sender)
sender = source.service;
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Allows Administrators to send messages to all users on the\n"
"network. The message will be sent from the nick \002%s\002."), source.service->nick.c_str());
"network. The message will be sent from the nick \002%s\002."), sender->nick.c_str());
return true;
}
};
+65 -100
View File
@@ -1,7 +1,7 @@
/* ircd-hybrid-8 protocol module
/* ircd-hybrid protocol module. Minimum supported version of ircd-hybrid is 8.2.23.
*
* (C) 2003-2020 Anope Team <team@anope.org>
* (C) 2012-2018 ircd-hybrid development team
* (C) 2012-2020 ircd-hybrid development team
*
* Please read COPYING and README for further details.
*
@@ -12,23 +12,10 @@
#include "module.h"
static Anope::string UplinkSID;
static bool UseSVSAccount = false; // Temporary backwards compatibility hack until old proto is deprecated
class HybridProto : public IRCDProto
{
BotInfo *FindIntroduced()
{
BotInfo *bi = Config->GetClient("OperServ");
if (bi && bi->introduced)
return bi;
for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
if (it->second->introduced)
return it->second;
return NULL;
}
void SendSVSKillInternal(const MessageSource &source, User *u, const Anope::string &buf) anope_override
{
IRCDProto::SendSVSKillInternal(source, u, buf);
@@ -36,7 +23,7 @@ class HybridProto : public IRCDProto
}
public:
HybridProto(Module *creator) : IRCDProto(creator, "ircd-hybrid 8.2.x")
HybridProto(Module *creator) : IRCDProto(creator, "ircd-hybrid 8.2.23+")
{
DefaultPseudoclientModes = "+oi";
CanSVSNick = true;
@@ -69,22 +56,22 @@ class HybridProto : public IRCDProto
void SendSQLine(User *, const XLine *x) anope_override
{
UplinkSocket::Message(FindIntroduced()) << "RESV * " << (x->expires ? x->expires - Anope::CurTime : 0) << " " << x->mask << " :" << x->reason;
UplinkSocket::Message(Me) << "RESV * " << (x->expires ? x->expires - Anope::CurTime : 0) << " " << x->mask << " :" << x->reason;
}
void SendSGLineDel(const XLine *x) anope_override
{
UplinkSocket::Message(Config->GetClient("OperServ")) << "UNXLINE * " << x->mask;
UplinkSocket::Message(Me) << "UNXLINE * " << x->mask;
}
void SendSGLine(User *, const XLine *x) anope_override
{
UplinkSocket::Message(Config->GetClient("OperServ")) << "XLINE * " << x->mask << " " << (x->expires ? x->expires - Anope::CurTime : 0) << " :" << x->GetReason();
UplinkSocket::Message(Me) << "XLINE * " << x->mask << " " << (x->expires ? x->expires - Anope::CurTime : 0) << " :" << x->GetReason();
}
void SendSZLineDel(const XLine *x) anope_override
{
UplinkSocket::Message(Config->GetClient("OperServ")) << "UNDLINE * " << x->GetHost();
UplinkSocket::Message(Me) << "UNDLINE * " << x->GetHost();
}
void SendSZLine(User *, const XLine *x) anope_override
@@ -95,7 +82,7 @@ class HybridProto : public IRCDProto
if (timeleft > 172800 || !x->expires)
timeleft = 172800;
UplinkSocket::Message(Config->GetClient("OperServ")) << "DLINE * " << timeleft << " " << x->GetHost() << " :" << x->GetReason();
UplinkSocket::Message(Me) << "DLINE * " << timeleft << " " << x->GetHost() << " :" << x->GetReason();
}
void SendAkillDel(const XLine *x) anope_override
@@ -103,12 +90,12 @@ class HybridProto : public IRCDProto
if (x->IsRegex() || x->HasNickOrReal())
return;
UplinkSocket::Message(Config->GetClient("OperServ")) << "UNKLINE * " << x->GetUser() << " " << x->GetHost();
UplinkSocket::Message(Me) << "UNKLINE * " << x->GetUser() << " " << x->GetHost();
}
void SendSQLineDel(const XLine *x) anope_override
{
UplinkSocket::Message(Config->GetClient("OperServ")) << "UNRESV * " << x->mask;
UplinkSocket::Message(Me) << "UNRESV * " << x->mask;
}
void SendJoin(User *u, Channel *c, const ChannelStatus *status) anope_override
@@ -117,8 +104,8 @@ class HybridProto : public IRCDProto
* Note that we must send our modes with the SJOIN and can not add them to the
* mode stacker because ircd-hybrid does not allow *any* client to op itself
*/
UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " +" << c->GetModes(true, true) << " :"
<< (status != NULL ? status->BuildModePrefixList() : "") << u->GetUID();
UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name << " +" << c->GetModes(true, true) << " :"
<< (status != NULL ? status->BuildModePrefixList() : "") << u->GetUID();
/* And update our internal status for this user since this is not going through our mode handling system */
if (status)
@@ -168,49 +155,43 @@ class HybridProto : public IRCDProto
if (timeleft > 172800 || !x->expires)
timeleft = 172800;
UplinkSocket::Message(Config->GetClient("OperServ")) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->GetReason();
UplinkSocket::Message(Me) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->GetReason();
}
void SendServer(const Server *server) anope_override
{
if (server == Me)
UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() + 1 << " :" << server->GetDescription();
UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() + 1 << " " << server->GetSID() << " +" << " :" << server->GetDescription();
else
UplinkSocket::Message(Me) << "SID " << server->GetName() << " " << server->GetHops() + 1 << " " << server->GetSID() << " :" << server->GetDescription();
UplinkSocket::Message(Me) << "SID " << server->GetName() << " " << server->GetHops() + 1 << " " << server->GetSID() << " +" << " :" << server->GetDescription();
}
void SendConnect() anope_override
{
UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink].password << " TS 6 :" << Me->GetSID();
UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink].password;
/*
* As of March 23, 2018, ircd-hybrid-8 does support the following capabilities
* As of October 02, 2020, ircd-hybrid-8 does support the following capabilities
* which are required to work with IRC-services:
*
* QS - Can handle quit storm removal
* TBURST - Supports topic burst
* ENCAP - Supports ENCAP
* SVS - Supports services
* EOB - Supports End Of Burst message
* RHOST - Supports UID message with realhost information
*/
UplinkSocket::Message() << "CAPAB :QS ENCAP TBURST SVS EOB RHOST";
UplinkSocket::Message() << "CAPAB :ENCAP TBURST EOB RHOST";
SendServer(Me);
UplinkSocket::Message() << "SVINFO 6 6 0 :" << Anope::CurTime;
UplinkSocket::Message(Me) << "SVINFO 6 6 0 :" << Anope::CurTime;
}
void SendClientIntroduction(User *u) anope_override
{
Anope::string modes = "+" + u->GetModes();
if (Servers::Capab.count("RHOST"))
UplinkSocket::Message(Me) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " "
<< u->host << " " << u->host << " 0.0.0.0 " << u->GetUID() << " * :" << u->realname;
else
UplinkSocket::Message(Me) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " "
<< u->host << " 0.0.0.0 " << u->GetUID() << " * :" << u->realname;
UplinkSocket::Message(Me) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " "
<< u->host << " " << u->host << " 0.0.0.0 " << u->GetUID() << " * :" << u->realname;
}
void SendEOB() anope_override
@@ -225,12 +206,18 @@ class HybridProto : public IRCDProto
void SendLogin(User *u, NickAlias *na) anope_override
{
IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %s", na->nc->display.c_str());
if (UseSVSAccount == false)
IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %s", na->nc->display.c_str());
else
UplinkSocket::Message(Me) << "SVSACCOUNT " << u->GetUID() << " " << u->timestamp << " " << na->nc->display;
}
void SendLogout(User *u) anope_override
{
IRCD->SendMode(Config->GetClient("NickServ"), u, "+d *");
if (UseSVSAccount == false)
IRCD->SendMode(Config->GetClient("NickServ"), u, "+d *");
else
UplinkSocket::Message(Me) << "SVSACCOUNT " << u->GetUID() << " " << u->timestamp << " *";
}
void SendChannel(Channel *c) anope_override
@@ -240,7 +227,7 @@ class HybridProto : public IRCDProto
if (modes.empty())
modes = "+";
UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :";
UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :";
}
void SendTopic(const MessageSource &source, Channel *c) anope_override
@@ -250,10 +237,7 @@ class HybridProto : public IRCDProto
void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) anope_override
{
if (Servers::Capab.count("RHOST"))
UplinkSocket::Message(Me) << "SVSNICK " << u->GetUID() << " " << u->timestamp << " " << newnick << " " << when;
else
UplinkSocket::Message(Me) << "SVSNICK " << u->GetUID() << " " << newnick << " " << when;
UplinkSocket::Message(Me) << "SVSNICK " << u->GetUID() << " " << u->timestamp << " " << newnick << " " << when;
}
void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &) anope_override
@@ -281,23 +265,14 @@ class HybridProto : public IRCDProto
this->SendSQLineDel(&x);
}
void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) anope_override
{
if (Servers::Capab.count("RHOST"))
UplinkSocket::Message(Me) << "SVSHOST " << u->GetUID() << " " << u->timestamp << " " << host;
else
/* Note: the +x doesn't set any mode on the ircd-hybrid side */
UplinkSocket::Message(Me) << "SVSMODE " << u->GetUID() << " " << u->timestamp << " " << "+x " << host;
UplinkSocket::Message(Me) << "SVSHOST " << u->GetUID() << " " << u->timestamp << " " << host;
}
void SendVhostDel(User *u) anope_override
{
if (Servers::Capab.count("RHOST"))
UplinkSocket::Message(Me) << "SVSHOST " << u->GetUID() << " " << u->timestamp << " " << u->host;
else
/* Note: the +x doesn't set any mode on the ircd-hybrid side */
UplinkSocket::Message(Me) << "SVSMODE " << u->GetUID() << " " << u->timestamp << " " << "+x " << u->host;
UplinkSocket::Message(Me) << "SVSHOST " << u->GetUID() << " " << u->timestamp << " " << u->host;
}
bool IsIdentValid(const Anope::string &ident) anope_override
@@ -348,7 +323,7 @@ struct IRCDMessageBMask : IRCDMessage
struct IRCDMessageEOB : IRCDMessage
{
IRCDMessageEOB(Module *craetor) : IRCDMessage(craetor, "EOB", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
IRCDMessageEOB(Module *creator) : IRCDMessage(creator, "EOB", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) anope_override
{
@@ -386,19 +361,20 @@ struct IRCDMessageNick : IRCDMessage
struct IRCDMessagePass : IRCDMessage
{
IRCDMessagePass(Module *creator) : IRCDMessage(creator, "PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
IRCDMessagePass(Module *creator) : IRCDMessage(creator, "PASS", 1) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
/* 0 1 2 3 */
/* PASS password TS 6 0MC */
/* 0 */
/* PASS password */
void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) anope_override
{
UplinkSID = params[3];
if (params.size() == 4)
UplinkSID = params[3];
}
};
struct IRCDMessagePong : IRCDMessage
{
IRCDMessagePong(Module *creator) : IRCDMessage(creator, "PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
IRCDMessagePong(Module *creator) : IRCDMessage(creator, "PONG", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) anope_override
{
@@ -408,17 +384,23 @@ struct IRCDMessagePong : IRCDMessage
struct IRCDMessageServer : IRCDMessage
{
IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
/* 0 1 2 */
/* SERVER hades.arpa 1 :ircd-hybrid test server */
/* 0 1 2 3 4 */
/* SERVER hades.arpa 1 4XY + :ircd-hybrid test server */
void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) anope_override
{
/* Servers other than our immediate uplink are introduced via SID */
if (params[1] != "1")
return;
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID);
if (params.size() == 5)
{
UplinkSID = params[2];
UseSVSAccount = true;
}
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params.back(), UplinkSID);
IRCD->SendPing(Me->GetName(), params[0]);
}
@@ -426,14 +408,14 @@ struct IRCDMessageServer : IRCDMessage
struct IRCDMessageSID : IRCDMessage
{
IRCDMessageSID(Module *creator) : IRCDMessage(creator, "SID", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
IRCDMessageSID(Module *creator) : IRCDMessage(creator, "SID", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
/* 0 1 2 3 */
/* :0MC SID hades.arpa 2 4XY :ircd-hybrid test server */
/* 0 1 2 3 4 */
/* :0MC SID hades.arpa 2 4XY + :ircd-hybrid test server */
void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) anope_override
{
unsigned int hops = params[1].is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0;
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[3], params[2]);
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params.back(), params[2]);
IRCD->SendPing(Me->GetName(), params[0]);
}
@@ -464,7 +446,7 @@ struct IRCDMessageSJoin : IRCDMessage
Message::Join::SJoinUser sju;
/* Get prefixes from the nick */
for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));)
for (char ch; (ch = ModeManager::GetStatusChar(buf[0])); )
{
buf.erase(buf.begin());
sju.first.AddMode(ch);
@@ -493,7 +475,6 @@ struct IRCDMessageSVSMode : IRCDMessage
* parv[0] = nickname
* parv[1] = TS
* parv[2] = mode
* parv[3] = optional argument (services id)
*/
void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) anope_override
{
@@ -552,37 +533,21 @@ struct IRCDMessageTMode : IRCDMessage
struct IRCDMessageUID : IRCDMessage
{
IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 10) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 10) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
void Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags) anope_override
{
NickAlias *na = NULL;
if (params.size() == 11)
{
/* CAPAB RHOST */
/* 0 1 2 3 4 5 6 7 8 9 10 */
/* :0MC UID Steve 1 1350157102 +oi ~steve virtual.host real.host 10.0.0.1 0MCAAAAAB Steve :Mining all the time */
if (params[9] != "*")
na = NickAlias::Find(params[9]);
/* 0 1 2 3 4 5 6 7 8 9 10 */
/* :0MC UID Steve 1 1350157102 +oi ~steve virtual.host real.host 10.0.0.1 0MCAAAAAB Steve :Mining all the time */
if (params[9] != "*")
na = NickAlias::Find(params[9]);
/* Source is always the server */
User::OnIntroduce(params[0], params[4], params[6], params[5], params[7], source.GetServer(), params[10],
params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0,
params[3], params[8], na ? *na->nc : NULL);
}
else
{
/* 0 1 2 3 4 5 6 7 8 9 */
/* :0MC UID Steve 1 1350157102 +oi ~steve resolved.host 10.0.0.1 0MCAAAAAB Steve :Mining all the time */
if (params[8] != "*")
na = NickAlias::Find(params[8]);
/* Source is always the server */
User::OnIntroduce(params[0], params[4], params[5], "", params[6], source.GetServer(), params[9],
params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0,
params[3], params[7], na ? *na->nc : NULL);
}
/* Source is always the server */
User::OnIntroduce(params[0], params[4], params[6], params[5], params[7], source.GetServer(), params[10],
params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0,
params[3], params[8], na ? *na->nc : NULL);
}
};
+5
View File
@@ -29,6 +29,11 @@ class GlobalCore : public Module, public GlobalService
{
}
Reference<BotInfo> GetDefaultSender() anope_override
{
return Global;
}
void SendGlobal(BotInfo *sender, const Anope::string &source, const Anope::string &message) anope_override
{
if (Me->GetLinks().empty())
+1 -1
View File
@@ -63,7 +63,7 @@ int ci::ci_char_traits::compare(const char *str1, const char *str2, size_t n)
{
for (unsigned i = 0; i < n; ++i)
{
register unsigned char c1 = case_map_upper[static_cast<unsigned char>(*str1)],
unsigned char c1 = case_map_upper[static_cast<unsigned char>(*str1)],
c2 = case_map_upper[static_cast<unsigned char>(*str2)];
if (c1 > c2)
+37 -23
View File
@@ -38,33 +38,47 @@
#include "services.h"
#include "anope.h"
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define _le64toh(x) ((uint64_t)(x))
#elif defined(_WIN32)
/* Windows is always little endian, unless you're on xbox360
http://msdn.microsoft.com/en-us/library/b0084kay(v=vs.80).aspx */
# define _le64toh(x) ((uint64_t)(x))
#elif defined(__APPLE__)
// WARNING: This ifdef maze could be a lot simpler but unfortunately
// that will cause find_includes to be unable to parse it.
#ifdef __APPLE__
# include <libkern/OSByteOrder.h>
# define _le64toh(x) OSSwapLittleToHostInt64(x)
#else
/* See: http://sourceforge.net/p/predef/wiki/Endianness/ */
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# include <sys/endian.h>
# else
# include <endian.h>
# endif
# if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && \
__BYTE_ORDER == __LITTLE_ENDIAN
# define _le64toh(x) ((uint64_t)(x))
# else
# define _le64toh(x) le64toh(x)
# endif
#endif
#ifdef __FreeBSD__
# include <sys/endian.h>
# define _le64toh(x) le64toh(x)
#endif
#ifdef __linux__
# include <endian.h>
#endif
#ifdef __NetBSD__
# include <sys/endian.h>
# define _le64toh(x) le64toh(x)
#endif
#ifdef __OpenBSD__
# include <sys/endian.h>
# define _le64toh(x) le64toh(x)
#endif
// Windows is always little endian.
#ifdef _WIN32
# define _le64toh(x) ((uint64_t)(x))
#endif
// Attempt to work on unenumerated platforms.
#if defined(le64toh) && !defined(_le64toh)
# define _le64toh le64toh
#endif
// We can't do anything about this.
#ifndef _le64toh
# error Please define _le64toh for your platform!
#endif
#define ROTATE(x, b) (uint64_t)( ((x) << (b)) | ( (x) >> (64 - (b))) )