summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/anope.h8
-rw-r--r--include/modules.h14
-rw-r--r--modules/protocol/inspircd-ts6.h2
-rw-r--r--modules/protocol/inspircd11.cpp2
-rw-r--r--modules/protocol/inspircd20.cpp2
-rw-r--r--modules/protocol/ngircd.cpp3
-rw-r--r--src/init.cpp6
-rw-r--r--src/main.cpp15
-rw-r--r--src/messages.cpp2
-rw-r--r--src/misc.cpp29
-rw-r--r--src/module.cpp8
-rw-r--r--src/modulemanager.cpp19
-rw-r--r--src/modules.cpp20
-rw-r--r--src/protocol.cpp2
14 files changed, 71 insertions, 61 deletions
diff --git a/include/anope.h b/include/anope.h
index 8153c976f..1a8612241 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -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)
diff --git a/include/modules.h b/include/modules.h
index 97cb49697..0918a67f8 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -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 */
diff --git a/modules/protocol/inspircd-ts6.h b/modules/protocol/inspircd-ts6.h
index f0fb0addd..ce226407c 100644
--- a/modules/protocol/inspircd-ts6.h
+++ b/modules/protocol/inspircd-ts6.h
@@ -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 */
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index 4030e40c1..ce0611916 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -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 */
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index 40f1a413d..87fe74c69 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -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());
}
};
diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp
index 160f74e9c..94b253a58 100644
--- a/modules/protocol/ngircd.cpp
+++ b/modules/protocol/ngircd.cpp
@@ -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 */
diff --git a/src/init.cpp b/src/init.cpp
index 71ef4b638..05b15aecb 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -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
diff --git a/src/main.cpp b/src/main.cpp
index eea96dee9..c350f4323 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -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;
-}
-
-
+} \ No newline at end of file
diff --git a/src/messages.cpp b/src/messages.cpp
index 8a9f86632..c5ea2f039 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -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;
}
diff --git a/src/misc.cpp b/src/misc.cpp
index 3fce523aa..1e1110fd9 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -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; }
+
diff --git a/src/module.cpp b/src/module.cpp
index 2b7676550..eadfbf4d1 100644
--- a/src/module.cpp
+++ b/src/module.cpp
@@ -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;
}
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index d530b6e46..400b258a5 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -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))
diff --git a/src/modules.cpp b/src/modules.cpp
index 51ae4acb9..cebe58987 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -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 : "");
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 264f0d02a..ddf1557bd 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -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)