summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspircd.h67
-rw-r--r--include/modules.h59
-rw-r--r--src/modules.cpp22
-rw-r--r--src/modules/extra/m_mysql.cpp2
-rw-r--r--src/modules/extra/m_pgsql.cpp2
-rw-r--r--src/modules/extra/m_sqlauth.cpp4
-rw-r--r--src/modules/extra/m_sqllog.cpp2
-rw-r--r--src/modules/extra/m_sqloper.cpp4
-rw-r--r--src/modules/extra/m_sqlutils.cpp4
-rw-r--r--src/modules/extra/m_testclient.cpp4
-rw-r--r--src/modules/m_hostchange.cpp4
-rw-r--r--src/modules/m_securelist.cpp4
12 files changed, 93 insertions, 85 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 94bba27f6..dadab34fa 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -3,13 +3,13 @@
* +------------------------------------+
*
* InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- * E-mail:
- * <brain@chatspike.net>
- * <Craig@chatspike.net>
+ * E-mail:
+ * <brain@chatspike.net>
+ * <Craig@chatspike.net>
*
* Written by Craig Edwards, Craig McLure, and others.
* This program is free but copyrighted software; see
- * the file COPYING for details.
+ * the file COPYING for details.
*
* ---------------------------------------------------
*/
@@ -150,6 +150,65 @@ class InspIRCd : public classbase
void SendError(const char *s);
+ /** For use with Module::Prioritize().
+ * When the return value of this function is returned from
+ * Module::Prioritize(), this specifies that the module wishes
+ * to be ordered exactly BEFORE 'modulename'. For more information
+ * please see Module::Prioritize().
+ * @param modulename The module your module wants to be before in the call list
+ * @returns a priority ID which the core uses to relocate the module in the list
+ */
+ long PriorityBefore(const std::string &modulename);
+
+ /** For use with Module::Prioritize().
+ * When the return value of this function is returned from
+ * Module::Prioritize(), this specifies that the module wishes
+ * to be ordered exactly AFTER 'modulename'. For more information please
+ * see Module::Prioritize().
+ * @param modulename The module your module wants to be after in the call list
+ * @returns a priority ID which the core uses to relocate the module in the list
+ */
+ long PriorityAfter(const std::string &modulename);
+
+ /** Publish a 'feature'.
+ * There are two ways for a module to find another module it depends on.
+ * Either by name, using InspIRCd::FindModule, or by feature, using this
+ * function. A feature is an arbitary string which identifies something this
+ * module can do. For example, if your module provides SSL support, but other
+ * modules provide SSL support too, all the modules supporting SSL should
+ * publish an identical 'SSL' feature. This way, any module requiring use
+ * of SSL functions can just look up the 'SSL' feature using FindFeature,
+ * then use the module pointer they are given.
+ * @param FeatureName The case sensitive feature name to make available
+ * @param Mod a pointer to your module class
+ * @returns True on success, false if the feature is already published by
+ * another module.
+ */
+ bool PublishFeature(const std::string &FeatureName, Module* Mod);
+
+ /** Unpublish a 'feature'.
+ * When your module exits, it must call this method for every feature it
+ * is providing so that the feature table is cleaned up.
+ * @param FeatureName the feature to remove
+ */
+ bool UnpublishFeature(const std::string &FeatureName);
+
+ /** Find a 'feature'.
+ * There are two ways for a module to find another module it depends on.
+ * Either by name, using InspIRCd::FindModule, or by feature, using the
+ * InspIRCd::PublishFeature method. A feature is an arbitary string which
+ * identifies something this module can do. For example, if your module
+ * provides SSL support, but other modules provide SSL support too, all
+ * the modules supporting SSL should publish an identical 'SSL' feature.
+ * To find a module capable of providing the feature you want, simply
+ * call this method with the feature name you are looking for.
+ * @param FeatureName The feature name you wish to obtain the module for
+ * @returns A pointer to a valid module class on success, NULL on failure.
+ */
+ Module* FindFeature(const std::string &FeatureName);
+
+ const std::string& GetModuleName(Module* m);
+
std::string GetRevision();
std::string GetVersionString();
void WritePID(const std::string &filename);
diff --git a/include/modules.h b/include/modules.h
index 8baf31b4c..1b9d8c25b 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -1250,65 +1250,6 @@ class Module : public Extensible
class Server : public Extensible
{
public:
- /** For use with Module::Prioritize().
- * When the return value of this function is returned from
- * Module::Prioritize(), this specifies that the module wishes
- * to be ordered exactly BEFORE 'modulename'. For more information
- * please see Module::Prioritize().
- * @param modulename The module your module wants to be before in the call list
- * @returns a priority ID which the core uses to relocate the module in the list
- */
- long PriorityBefore(const std::string &modulename);
-
- /** For use with Module::Prioritize().
- * When the return value of this function is returned from
- * Module::Prioritize(), this specifies that the module wishes
- * to be ordered exactly AFTER 'modulename'. For more information please
- * see Module::Prioritize().
- * @param modulename The module your module wants to be after in the call list
- * @returns a priority ID which the core uses to relocate the module in the list
- */
- long PriorityAfter(const std::string &modulename);
-
- /** Publish a 'feature'.
- * There are two ways for a module to find another module it depends on.
- * Either by name, using Server::FindModule, or by feature, using this
- * function. A feature is an arbitary string which identifies something this
- * module can do. For example, if your module provides SSL support, but other
- * modules provide SSL support too, all the modules supporting SSL should
- * publish an identical 'SSL' feature. This way, any module requiring use
- * of SSL functions can just look up the 'SSL' feature using FindFeature,
- * then use the module pointer they are given.
- * @param FeatureName The case sensitive feature name to make available
- * @param Mod a pointer to your module class
- * @returns True on success, false if the feature is already published by
- * another module.
- */
- bool PublishFeature(const std::string &FeatureName, Module* Mod);
-
- /** Unpublish a 'feature'.
- * When your module exits, it must call this method for every feature it
- * is providing so that the feature table is cleaned up.
- * @param FeatureName the feature to remove
- */
- bool UnpublishFeature(const std::string &FeatureName);
-
- /** Find a 'feature'.
- * There are two ways for a module to find another module it depends on.
- * Either by name, using Server::FindModule, or by feature, using the
- * Server::PublishFeature method. A feature is an arbitary string which
- * identifies something this module can do. For example, if your module
- * provides SSL support, but other modules provide SSL support too, all
- * the modules supporting SSL should publish an identical 'SSL' feature.
- * To find a module capable of providing the feature you want, simply
- * call this method with the feature name you are looking for.
- * @param FeatureName The feature name you wish to obtain the module for
- * @returns A pointer to a valid module class on success, NULL on failure.
- */
- Module* FindFeature(const std::string &FeatureName);
-
- const std::string& GetModuleName(Module* m);
-
/** Returns true if a nick is valid.
* Nicks for unregistered connections will return false.
*/
diff --git a/src/modules.cpp b/src/modules.cpp
index ee18cb9a6..78beb5715 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -241,11 +241,11 @@ void Server::RemoveSocket(InspSocket* sock)
}
}
-long Server::PriorityAfter(const std::string &modulename)
+long InspIRCd::PriorityAfter(const std::string &modulename)
{
- for (unsigned int j = 0; j < ServerInstance->Config->module_names.size(); j++)
+ for (unsigned int j = 0; j < this->Config->module_names.size(); j++)
{
- if (ServerInstance->Config->module_names[j] == modulename)
+ if (this->Config->module_names[j] == modulename)
{
return ((j << 8) | PRIORITY_AFTER);
}
@@ -253,11 +253,11 @@ long Server::PriorityAfter(const std::string &modulename)
return PRIORITY_DONTCARE;
}
-long Server::PriorityBefore(const std::string &modulename)
+long InspIRCd::PriorityBefore(const std::string &modulename)
{
- for (unsigned int j = 0; j < ServerInstance->Config->module_names.size(); j++)
+ for (unsigned int j = 0; j < this->Config->module_names.size(); j++)
{
- if (ServerInstance->Config->module_names[j] == modulename)
+ if (this->Config->module_names[j] == modulename)
{
return ((j << 8) | PRIORITY_BEFORE);
}
@@ -265,7 +265,7 @@ long Server::PriorityBefore(const std::string &modulename)
return PRIORITY_DONTCARE;
}
-bool Server::PublishFeature(const std::string &FeatureName, Module* Mod)
+bool InspIRCd::PublishFeature(const std::string &FeatureName, Module* Mod)
{
if (Features.find(FeatureName) == Features.end())
{
@@ -275,7 +275,7 @@ bool Server::PublishFeature(const std::string &FeatureName, Module* Mod)
return false;
}
-bool Server::UnpublishFeature(const std::string &FeatureName)
+bool InspIRCd::UnpublishFeature(const std::string &FeatureName)
{
featurelist::iterator iter = Features.find(FeatureName);
@@ -286,7 +286,7 @@ bool Server::UnpublishFeature(const std::string &FeatureName)
return true;
}
-Module* Server::FindFeature(const std::string &FeatureName)
+Module* InspIRCd::FindFeature(const std::string &FeatureName)
{
featurelist::iterator iter = Features.find(FeatureName);
@@ -296,14 +296,14 @@ Module* Server::FindFeature(const std::string &FeatureName)
return iter->second;
}
-const std::string& Server::GetModuleName(Module* m)
+const std::string& InspIRCd::GetModuleName(Module* m)
{
static std::string nothing = ""; /* Prevent compiler warning */
for (int i = 0; i <= MODCOUNT; i++)
{
if (modules[i] == m)
{
- return ServerInstance->Config->module_names[i];
+ return this->Config->module_names[i];
}
}
return nothing; /* As above */
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp
index a6fa7ab8e..5eaa0e8d3 100644
--- a/src/modules/extra/m_mysql.cpp
+++ b/src/modules/extra/m_mysql.cpp
@@ -808,7 +808,7 @@ class ModuleSQL : public Module
{
throw ModuleException("m_mysql: Failed to create dispatcher thread: " + std::string(strerror(errno)));
}
- if (!Srv->PublishFeature("SQL", this))
+ if (!ServerInstance->PublishFeature("SQL", this))
{
/* Tell worker thread to exit NOW */
giveup = true;
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp
index d488bed8e..988700d41 100644
--- a/src/modules/extra/m_pgsql.cpp
+++ b/src/modules/extra/m_pgsql.cpp
@@ -522,7 +522,7 @@ public:
ModulePgSQL(Server* Me)
: Module::Module(Me), Srv(Me), currid(0)
{
- log(DEBUG, "%s 'SQL' feature", Srv->PublishFeature("SQL", this) ? "Published" : "Couldn't publish");
+ log(DEBUG, "%s 'SQL' feature", ServerInstance->PublishFeature("SQL", this) ? "Published" : "Couldn't publish");
sqlsuccess = new char[strlen(SQLSUCCESS)+1];
diff --git a/src/modules/extra/m_sqlauth.cpp b/src/modules/extra/m_sqlauth.cpp
index bc72e0e0c..960a3c540 100644
--- a/src/modules/extra/m_sqlauth.cpp
+++ b/src/modules/extra/m_sqlauth.cpp
@@ -48,7 +48,7 @@ public:
ModuleSQLAuth(Server* Me)
: Module::Module(Me), Srv(Me)
{
- SQLutils = Srv->FindFeature("SQLutils");
+ SQLutils = ServerInstance->FindFeature("SQLutils");
if(SQLutils)
{
@@ -104,7 +104,7 @@ public:
{
Module* target;
- target = Srv->FindFeature("SQL");
+ target = ServerInstance->FindFeature("SQL");
if(target)
{
diff --git a/src/modules/extra/m_sqllog.cpp b/src/modules/extra/m_sqllog.cpp
index a7d73af18..b2ddf1c5d 100644
--- a/src/modules/extra/m_sqllog.cpp
+++ b/src/modules/extra/m_sqllog.cpp
@@ -279,7 +279,7 @@ class ModuleSQLLog : public Module
Conf = new ConfigReader();
dbid = Conf->ReadValue("sqllog","dbid",0); // database id of a database configured in sql module
DELETE(Conf);
- SQLModule = Srv->FindFeature("SQL");
+ SQLModule = ServerInstance->FindFeature("SQL");
if (!SQLModule)
log(DEFAULT,"WARNING: m_sqllog.so could not initialize because an SQL module is not loaded. Load the module and rehash your server.");
return (SQLModule);
diff --git a/src/modules/extra/m_sqloper.cpp b/src/modules/extra/m_sqloper.cpp
index 17188ed68..7e905d691 100644
--- a/src/modules/extra/m_sqloper.cpp
+++ b/src/modules/extra/m_sqloper.cpp
@@ -44,7 +44,7 @@ public:
ModuleSQLOper(Server* Me)
: Module::Module(Me), Srv(Me)
{
- SQLutils = Srv->FindFeature("SQLutils");
+ SQLutils = ServerInstance->FindFeature("SQLutils");
if (SQLutils)
{
@@ -91,7 +91,7 @@ public:
{
Module* target;
- target = Srv->FindFeature("SQL");
+ target = ServerInstance->FindFeature("SQL");
if (target)
{
diff --git a/src/modules/extra/m_sqlutils.cpp b/src/modules/extra/m_sqlutils.cpp
index bbda7f3ea..f2085cbcd 100644
--- a/src/modules/extra/m_sqlutils.cpp
+++ b/src/modules/extra/m_sqlutils.cpp
@@ -31,6 +31,8 @@
/* $ModDesc: Provides some utilities to SQL client modules, such as mapping queries to users and channels */
+extern InspIRCd* ServerInstance;
+
typedef std::map<unsigned long, userrec*> IdUserMap;
typedef std::map<unsigned long, chanrec*> IdChanMap;
typedef std::list<unsigned long> AssocIdList;
@@ -47,7 +49,7 @@ public:
ModuleSQLutils(Server* Me)
: Module::Module(Me), Srv(Me)
{
- log(DEBUG, "%s 'SQLutils' feature", Srv->PublishFeature("SQLutils", this) ? "Published" : "Couldn't publish");
+ log(DEBUG, "%s 'SQLutils' feature", ServerInstance->PublishFeature("SQLutils", this) ? "Published" : "Couldn't publish");
}
void Implements(char* List)
diff --git a/src/modules/extra/m_testclient.cpp b/src/modules/extra/m_testclient.cpp
index 6aec581ae..a5744f240 100644
--- a/src/modules/extra/m_testclient.cpp
+++ b/src/modules/extra/m_testclient.cpp
@@ -8,6 +8,8 @@
#include "configreader.h"
#include "m_sqlv2.h"
+extern InspIRCd* ServerInstance;
+
class ModuleTestClient : public Module
{
private:
@@ -31,7 +33,7 @@ public:
virtual void OnBackgroundTimer(time_t foo)
{
- Module* target = Srv->FindFeature("SQL");
+ Module* target = ServerInstance->FindFeature("SQL");
if(target)
{
diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp
index 354eea3ed..d4da6d1ff 100644
--- a/src/modules/m_hostchange.cpp
+++ b/src/modules/m_hostchange.cpp
@@ -24,6 +24,8 @@ using namespace std;
/* $ModDesc: Provides masking of user hostnames in a different way to m_cloaking */
+extern InspIRCd* ServerInstance;
+
class Host : public classbase
{
public:
@@ -58,7 +60,7 @@ class ModuleHostChange : public Module
Priority Prioritize()
{
- return (Priority)Srv->PriorityAfter("m_cloaking.so");
+ return (Priority)ServerInstance->PriorityAfter("m_cloaking.so");
}
void Implements(char* List)
diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp
index 232a083be..00e860467 100644
--- a/src/modules/m_securelist.cpp
+++ b/src/modules/m_securelist.cpp
@@ -27,6 +27,8 @@ using namespace std;
extern time_t TIME;
/* $ModDesc: A module overriding /list, and making it safe - stop those sendq problems. */
+
+extern InspIRCd* ServerInstance;
class ModuleSecureList : public Module
{
@@ -82,7 +84,7 @@ class ModuleSecureList : public Module
virtual Priority Prioritize()
{
- return (Priority)Srv->PriorityBefore("m_safelist.so");
+ return (Priority)ServerInstance->PriorityBefore("m_safelist.so");
}
};