mirror of
https://github.com/anope/anope.git
synced 2026-07-06 23:23:13 +02:00
Added some useful Anope::Version functions to prevent some files from unnecessarily rebuilding on every make
This commit is contained in:
+6
-2
@@ -299,8 +299,12 @@ namespace Anope
|
||||
extern CoreExport time_t CurTime;
|
||||
|
||||
extern CoreExport string Version();
|
||||
|
||||
extern CoreExport string Build();
|
||||
extern CoreExport string VersionShort();
|
||||
extern CoreExport string VersionBuildString();
|
||||
extern CoreExport int VersionMajor();
|
||||
extern CoreExport int VersionMinor();
|
||||
extern CoreExport int VersionPatch();
|
||||
extern CoreExport int VersionBuild();
|
||||
|
||||
/** Check whether two strings match.
|
||||
* @param str The string to check against the pattern (e.g. foobar)
|
||||
|
||||
+7
-7
@@ -165,9 +165,9 @@ extern CoreExport std::list<Module *> Modules;
|
||||
class Version
|
||||
{
|
||||
private:
|
||||
unsigned Major;
|
||||
unsigned Minor;
|
||||
unsigned Build;
|
||||
int Major;
|
||||
int Minor;
|
||||
int Build;
|
||||
|
||||
public:
|
||||
/** Constructor
|
||||
@@ -175,7 +175,7 @@ class Version
|
||||
* @param vMinor The minor version numbber
|
||||
* @param vBuild The build version numbber
|
||||
*/
|
||||
Version(unsigned vMajor, unsigned vMinor, unsigned vBuild);
|
||||
Version(int vMajor, int vMinor, int vBuild);
|
||||
|
||||
/** Destructor
|
||||
*/
|
||||
@@ -184,17 +184,17 @@ class Version
|
||||
/** Get the major version of Anope this was built against
|
||||
* @return The major version
|
||||
*/
|
||||
unsigned GetMajor() const;
|
||||
int GetMajor() const;
|
||||
|
||||
/** Get the minor version of Anope this was built against
|
||||
* @return The minor version
|
||||
*/
|
||||
unsigned GetMinor() const;
|
||||
int GetMinor() const;
|
||||
|
||||
/** Get the build version this was built against
|
||||
* @return The build version
|
||||
*/
|
||||
unsigned GetBuild() const;
|
||||
int GetBuild() const;
|
||||
};
|
||||
|
||||
/* Forward declaration of CallBack class for the Module class */
|
||||
|
||||
@@ -169,7 +169,7 @@ class InspIRCdTS6Proto : public IRCDProto
|
||||
{
|
||||
SendServer(Me);
|
||||
send_cmd(Config->Numeric, "BURST");
|
||||
send_cmd(Config->Numeric, "VERSION :Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, Config->EncModuleList.begin()->c_str(), Anope::Build().c_str());
|
||||
send_cmd(Config->Numeric, "VERSION :Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, Config->EncModuleList.begin()->c_str(), Anope::VersionBuildString().c_str());
|
||||
}
|
||||
|
||||
/* SVSHOLD - set */
|
||||
|
||||
@@ -197,7 +197,7 @@ class InspIRCdProto : public IRCDProto
|
||||
inspircd_cmd_pass(uplink_server->password);
|
||||
SendServer(Me);
|
||||
send_cmd("", "BURST");
|
||||
send_cmd(Config->ServerName, "VERSION :Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, Config->EncModuleList.begin()->c_str(), Anope::Build().c_str());
|
||||
send_cmd(Config->ServerName, "VERSION :Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, Config->EncModuleList.begin()->c_str(), Anope::VersionBuildString().c_str());
|
||||
}
|
||||
|
||||
/* CHGIDENT */
|
||||
|
||||
@@ -80,7 +80,7 @@ class InspIRCdProto : public InspIRCdTS6Proto
|
||||
send_cmd("", "CAPAB END");
|
||||
SendServer(Me);
|
||||
send_cmd(Config->Numeric, "BURST");
|
||||
send_cmd(Config->Numeric, "VERSION :Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, Config->EncModuleList.begin()->c_str(), Anope::Build().c_str());
|
||||
send_cmd(Config->Numeric, "VERSION :Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, Config->EncModuleList.begin()->c_str(), Anope::VersionBuildString().c_str());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include "services.h"
|
||||
#include "modules.h"
|
||||
#include "version.h"
|
||||
|
||||
IRCDVar myIrcd[] = {
|
||||
{"ngIRCd", /* ircd name */
|
||||
@@ -81,7 +80,7 @@ class ngIRCdProto : public IRCDProto
|
||||
|
||||
void SendConnect()
|
||||
{
|
||||
send_cmd("", "PASS %s 0210-IRC+ Anope|%d.%d.%d:CLHSo P", uplink_server->password.c_str(), VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
|
||||
send_cmd("", "PASS %s 0210-IRC+ Anope|%s:CLHSo P", uplink_server->password.c_str(), Anope::VersionShort().c_str());
|
||||
/* Make myself known to myself in the serverlist */
|
||||
SendServer(Me);
|
||||
/* finish the enhanced server handshake and register the connection */
|
||||
|
||||
+3
-3
@@ -229,13 +229,13 @@ void Init(int ac, char **av)
|
||||
|
||||
if (GetCommandLineArgument("version", 'v'))
|
||||
{
|
||||
Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- " << Anope::Build();
|
||||
Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- " << Anope::VersionBuildString();
|
||||
throw FatalException();
|
||||
}
|
||||
|
||||
if (GetCommandLineArgument("help", 'h'))
|
||||
{
|
||||
Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- " << Anope::Build();
|
||||
Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- " << Anope::VersionBuildString();
|
||||
Log(LOG_TERMINAL) << "Anope IRC Services (http://www.anope.org)";
|
||||
Log(LOG_TERMINAL) << "Usage ./" << services_bin << " [options] ...";
|
||||
Log(LOG_TERMINAL) << "-c, --config=filename.conf";
|
||||
@@ -313,7 +313,7 @@ void Init(int ac, char **av)
|
||||
|
||||
init_core_messages();
|
||||
|
||||
Log(LOG_TERMINAL) << "Anope " << Anope::Version() << ", " << Anope::Build();
|
||||
Log(LOG_TERMINAL) << "Anope " << Anope::Version() << ", " << Anope::VersionBuildString();
|
||||
#ifdef _WIN32
|
||||
Log(LOG_TERMINAL) << "Using configuration file " << services_dir << "\\" << services_conf.GetName();
|
||||
#else
|
||||
|
||||
+1
-14
@@ -26,7 +26,6 @@
|
||||
#include "services.h"
|
||||
#include "timers.h"
|
||||
#include "modules.h"
|
||||
#include "version.h"
|
||||
|
||||
// getrlimit.
|
||||
#ifndef _WIN32
|
||||
@@ -552,16 +551,4 @@ int main(int ac, char **av, char **envp)
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Anope::string Anope::Version()
|
||||
{
|
||||
return stringify(VERSION_MAJOR) + "." + stringify(VERSION_MINOR) + "." + stringify(VERSION_PATCH) + VERSION_EXTRA + " (" + stringify(VERSION_BUILD) + ")";
|
||||
}
|
||||
|
||||
Anope::string Anope::Build()
|
||||
{
|
||||
return "build #" + stringify(BUILD) + ", compiled " + Anope::compiled;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+1
-1
@@ -86,7 +86,7 @@ bool OnTime(const Anope::string &source, const std::vector<Anope::string> &)
|
||||
bool OnVersion(const Anope::string &source, const std::vector<Anope::string> &)
|
||||
{
|
||||
if (!source.empty())
|
||||
ircdproto->SendNumeric(Config->ServerName, 351, source, "Anope-%s %s :%s -(%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, Config->EncModuleList.begin()->c_str(), Anope::Build().c_str());
|
||||
ircdproto->SendNumeric(Config->ServerName, 351, source, "Anope-%s %s :%s -(%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, Config->EncModuleList.begin()->c_str(), Anope::VersionBuildString().c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+28
-1
@@ -11,6 +11,8 @@
|
||||
*/
|
||||
|
||||
#include "services.h"
|
||||
#include "version.h"
|
||||
#include "modules.h"
|
||||
|
||||
/* Cheaper than isspace() or isblank() */
|
||||
#define issp(c) ((c) == 32)
|
||||
@@ -805,7 +807,7 @@ Anope::string Anope::printf(const Anope::string &fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buf[1024];
|
||||
va_start(args, fmt.c_str());
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt.c_str(), args);
|
||||
va_end(args);
|
||||
return buf;
|
||||
@@ -1150,3 +1152,28 @@ const Anope::string Anope::LastError()
|
||||
#endif
|
||||
}
|
||||
|
||||
Version Module::GetVersion() const
|
||||
{
|
||||
return Version(VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD);
|
||||
}
|
||||
|
||||
Anope::string Anope::Version()
|
||||
{
|
||||
return stringify(VERSION_MAJOR) + "." + stringify(VERSION_MINOR) + "." + stringify(VERSION_PATCH) + VERSION_EXTRA + " (" + stringify(VERSION_BUILD) + ")";
|
||||
}
|
||||
|
||||
Anope::string Anope::VersionShort()
|
||||
{
|
||||
return stringify(VERSION_MAJOR) + "." + stringify(VERSION_MINOR) + "." + stringify(VERSION_PATCH);
|
||||
}
|
||||
|
||||
Anope::string Anope::VersionBuildString()
|
||||
{
|
||||
return "build #" + stringify(BUILD) + ", compiled " + Anope::compiled;
|
||||
}
|
||||
|
||||
int Anope::VersionMajor() { return VERSION_MAJOR; }
|
||||
int Anope::VersionMinor() { return VERSION_MINOR; }
|
||||
int Anope::VersionPatch() { return VERSION_PATCH; }
|
||||
int Anope::VersionBuild() { return VERSION_BUILD; }
|
||||
|
||||
|
||||
+4
-4
@@ -72,7 +72,7 @@ void Module::SetAuthor(const Anope::string &nauthor)
|
||||
this->author = nauthor;
|
||||
}
|
||||
|
||||
Version::Version(unsigned vMajor, unsigned vMinor, unsigned vBuild) : Major(vMajor), Minor(vMinor), Build(vBuild)
|
||||
Version::Version(int vMajor, int vMinor, int vBuild) : Major(vMajor), Minor(vMinor), Build(vBuild)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -80,17 +80,17 @@ Version::~Version()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned Version::GetMajor() const
|
||||
int Version::GetMajor() const
|
||||
{
|
||||
return this->Major;
|
||||
}
|
||||
|
||||
unsigned Version::GetMinor() const
|
||||
int Version::GetMinor() const
|
||||
{
|
||||
return this->Minor;
|
||||
}
|
||||
|
||||
unsigned Version::GetBuild() const
|
||||
int Version::GetBuild() const
|
||||
{
|
||||
return this->Build;
|
||||
}
|
||||
|
||||
+9
-10
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
#include "modules.h"
|
||||
#include "version.h"
|
||||
#include <algorithm> // std::find
|
||||
|
||||
std::map<Anope::string, Service *> ModuleManager::ServiceProviders;
|
||||
@@ -174,23 +173,23 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u)
|
||||
m->handle = handle;
|
||||
|
||||
Version v = m->GetVersion();
|
||||
if (v.GetMajor() < VERSION_MAJOR || (v.GetMajor() == VERSION_MAJOR && v.GetMinor() < VERSION_MINOR))
|
||||
if (v.GetMajor() < Anope::VersionMajor() || (v.GetMajor() == Anope::VersionMajor() && v.GetMinor() < Anope::VersionMinor()))
|
||||
{
|
||||
Log() << "Module " << modname << " is compiled against an older version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << VERSION_MAJOR << "." << VERSION_MINOR;
|
||||
Log() << "Module " << modname << " is compiled against an older version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << Anope::VersionMajor() << "." << Anope::VersionMinor();
|
||||
DeleteModule(m);
|
||||
return MOD_ERR_VERSION;
|
||||
}
|
||||
else if (v.GetMajor() > VERSION_MAJOR || (v.GetMajor() == VERSION_MAJOR && v.GetMinor() > VERSION_MINOR))
|
||||
else if (v.GetMajor() > Anope::VersionMajor() || (v.GetMajor() == Anope::VersionMajor() && v.GetMinor() > Anope::VersionMinor()))
|
||||
{
|
||||
Log() << "Module " << modname << " is compiled against a newer version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << VERSION_MAJOR << "." << VERSION_MINOR;
|
||||
Log() << "Module " << modname << " is compiled against a newer version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << Anope::VersionMajor() << "." << Anope::VersionMinor();
|
||||
DeleteModule(m);
|
||||
return MOD_ERR_VERSION;
|
||||
}
|
||||
else if (v.GetBuild() < VERSION_BUILD)
|
||||
Log() << "Module " << modname << " is compiled against an older revision of Anope " << v.GetBuild() << ", this is " << VERSION_BUILD;
|
||||
else if (v.GetBuild() > VERSION_BUILD)
|
||||
Log() << "Module " << modname << " is compiled against a newer revision of Anope " << v.GetBuild() << ", this is " << VERSION_BUILD;
|
||||
else if (v.GetBuild() == VERSION_BUILD)
|
||||
else if (v.GetBuild() < Anope::VersionBuild())
|
||||
Log() << "Module " << modname << " is compiled against an older revision of Anope " << v.GetBuild() << ", this is " << Anope::VersionBuild();
|
||||
else if (v.GetBuild() > Anope::VersionBuild())
|
||||
Log() << "Module " << modname << " is compiled against a newer revision of Anope " << v.GetBuild() << ", this is " << Anope::VersionBuild();
|
||||
else if (v.GetBuild() == Anope::VersionBuild())
|
||||
Log(LOG_DEBUG) << "Module " << modname << " compiled against current version of Anope " << v.GetBuild();
|
||||
|
||||
if (m->type == PROTOCOL && IsOneOfModuleTypeLoaded(PROTOCOL))
|
||||
|
||||
+7
-13
@@ -10,7 +10,6 @@
|
||||
*/
|
||||
|
||||
#include "modules.h"
|
||||
#include "version.h"
|
||||
|
||||
message_map MessageMap;
|
||||
std::list<Module *> Modules;
|
||||
@@ -196,27 +195,27 @@ int Module::DelCommand(BotInfo *bi, Command *c)
|
||||
bool moduleMinVersion(int major, int minor, int patch, int build)
|
||||
{
|
||||
bool ret = false;
|
||||
if (VERSION_MAJOR > major) /* Def. new */
|
||||
if (Anope::VersionMajor() > major) /* Def. new */
|
||||
ret = true;
|
||||
else if (VERSION_MAJOR == major) /* Might be newer */
|
||||
else if (Anope::VersionMajor() == major) /* Might be newer */
|
||||
{
|
||||
if (minor == -1)
|
||||
return true; /* They dont care about minor */
|
||||
if (VERSION_MINOR > minor) /* Def. newer */
|
||||
if (Anope::VersionMinor() > minor) /* Def. newer */
|
||||
ret = true;
|
||||
else if (VERSION_MINOR == minor) /* Might be newer */
|
||||
else if (Anope::VersionMinor() == minor) /* Might be newer */
|
||||
{
|
||||
if (patch == -1)
|
||||
return true; /* They dont care about patch */
|
||||
if (VERSION_PATCH > patch)
|
||||
if (Anope::VersionPatch() > patch)
|
||||
ret = true;
|
||||
else if (VERSION_PATCH == patch)
|
||||
else if (Anope::VersionPatch() == patch)
|
||||
{
|
||||
#if 0
|
||||
// XXX
|
||||
if (build == -1)
|
||||
return true; /* They dont care about build */
|
||||
if (VERSION_BUILD >= build)
|
||||
if (Anope::VersionBuild >= build)
|
||||
ret = true;
|
||||
#endif
|
||||
}
|
||||
@@ -280,11 +279,6 @@ void ModuleRunTimeDirCleanUp()
|
||||
Log(LOG_DEBUG) << "Module run time directory has been cleaned out";
|
||||
}
|
||||
|
||||
Version Module::GetVersion() const
|
||||
{
|
||||
return Version(VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD);
|
||||
}
|
||||
|
||||
void Module::SendMessage(CommandSource &source, const char *fmt, ...)
|
||||
{
|
||||
Anope::string language = (source.u && source.u->Account() ? source.u->Account()->language : "");
|
||||
|
||||
+1
-1
@@ -430,7 +430,7 @@ bool IRCdMessage::OnPrivmsg(const Anope::string &source, const std::vector<Anope
|
||||
}
|
||||
else if (message.substr(0, 9).equals_ci("\1VERSION\1"))
|
||||
{
|
||||
ircdproto->SendCTCP(bi, u->nick, "VERSION Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, Config->EncModuleList.begin()->c_str(), Anope::Build().c_str());
|
||||
ircdproto->SendCTCP(bi, u->nick, "VERSION Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, Config->EncModuleList.begin()->c_str(), Anope::VersionBuildString().c_str());
|
||||
}
|
||||
}
|
||||
else if (bi == ChanServ)
|
||||
|
||||
Reference in New Issue
Block a user