summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDukePyrolator <DukePyrolator@anope.org>2011-03-13 03:42:30 -0400
committerAdam <Adam@anope.org>2011-03-13 03:42:30 -0400
commit3fbf39b25d3ab95cab83baf198a24a7d6ad3689b (patch)
tree0b785f887b531ace1649ed019836b04954f3b460 /src
parent15a833283b0ec501f8c986b269b8360c6aa923f9 (diff)
Added some useful Anope::Version functions to prevent some files from unnecessarily rebuilding on every make
Diffstat (limited to 'src')
-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
8 files changed, 54 insertions, 47 deletions
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)