* ipv4 servers, so this value will be ten times as
* high on ipv6 servers.
*/
-#define NATIVE_API_VERSION 11008
+#define NATIVE_API_VERSION 11009
#ifdef IPV6
#define API_VERSION (NATIVE_API_VERSION * 10)
#else
{ \
ServerInstance->modules[_i]->x ; \
} \
- catch (ModuleException& modexcept) \
+ catch (CoreException& modexcept) \
{ \
- ServerInstance->Log(DEBUG,"Module exception caught: %s",modexcept.GetReason()); \
+ ServerInstance->Log(DEFAULT,"Exception cought: %s",modexcept.GetReason()); \
} \
} \
}
{ \
z->modules[_i]->x ; \
} \
- catch (ModuleException& modexcept) \
+ catch (CoreException& modexcept) \
{ \
- z->Log(DEBUG,"Module exception caught: %s",modexcept.GetReason()); \
+ z->Log(DEFAULT,"Exception cought: %s",modexcept.GetReason()); \
} \
} \
}
break; \
} \
} \
- catch (ModuleException& modexcept) \
+ catch (CoreException& modexcept) \
{ \
- ServerInstance->Log(DEBUG,"Module exception cought: %s",modexcept.GetReason()); \
+ ServerInstance->Log(DEFAULT,"Exception cought: %s",modexcept.GetReason()); \
} \
} \
} \
break; \
} \
} \
- catch (ModuleException& modexcept) \
+ catch (CoreException& modexcept) \
{ \
- z->Log(DEBUG,"Module exception cought: %s",modexcept.GetReason()); \
+ z->Log(DEBUG,"Exception cought: %s",modexcept.GetReason()); \
} \
} \
} \
* be loaded. If this happens, the error message returned by ModuleException::GetReason will be displayed to the user
* attempting to load the module, or dumped to the console if the ircd is currently loading for the first time.
*/
-class ModuleException : public std::exception
+class CoreException : public std::exception
{
- private:
+ protected:
/** Holds the error message to be displayed
*/
- std::string err;
+ const std::string err;
+ const std::string source;
public:
- /** Default constructor, just uses the error mesage 'Module threw an exception'.
+ /** Default constructor, just uses the error mesage 'Core threw an exception'.
*/
- ModuleException() : err("Module threw an exception") {}
+ CoreException() : err("Core threw an exception"), source("The core") {}
/** This constructor can be used to specify an error message before throwing.
*/
- ModuleException(std::string message) : err(message) {}
+ CoreException(const std::string &message) : err(message), source("The core") {}
+ /** This constructor can be used to specify an error message before throwing,
+ * and to specify the source of the exception.
+ */
+ CoreException(const std::string &message, const std::string &src) : err(message), source(src) {}
/** This destructor solves world hunger, cancels the world debt, and causes the world to end.
* Actually no, it does nothing. Never mind.
* @throws Nothing!
*/
- virtual ~ModuleException() throw() {};
+ virtual ~CoreException() throw() {};
/** Returns the reason for the exception.
* The module should probably put something informative here as the user will see this upon failure.
*/
{
return err.c_str();
}
+
+ virtual const char* GetSource()
+ {
+ return source.c_str();
+ }
+};
+
+class ModuleException : public CoreException
+{
+ public:
+ /** Default constructor, just uses the error mesage 'Module threw an exception'.
+ */
+ ModuleException() : CoreException("Module threw an exception", "A Module") {}
+
+ /** This constructor can be used to specify an error message before throwing.
+ */
+ ModuleException(const std::string &message) : CoreException(message, "A Module") {}
+ /** This destructor solves world hunger, cancels the world debt, and causes the world to end.
+ * Actually no, it does nothing. Never mind.
+ * @throws Nothing!
+ */
+ virtual ~ModuleException() throw() {};
};
/** Priority types which can be returned from Module::Prioritize()
I_OnPostLocalTopicChange, I_OnEvent, I_OnRequest, I_OnOperCompre, I_OnGlobalOper, I_OnPostConnect, I_OnAddBan, I_OnDelBan,
I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketWrite, I_OnRawSocketRead, I_OnChangeLocalUserGECOS, I_OnUserRegister,
I_OnOperCompare, I_OnChannelDelete, I_OnPostOper, I_OnSyncOtherMetaData, I_OnSetAway, I_OnCancelAway, I_OnUserList,
- I_OnPostCommand, I_OnPostJoin, I_OnWhoisLine, I_OnBuildExemptList, I_OnRawSocketConnect };
+ I_OnPostCommand, I_OnPostJoin, I_OnWhoisLine, I_OnBuildExemptList, I_OnRawSocketConnect, I_OnGarbageCollect };
/** Base class for all InspIRCd modules
* This class is the base class for InspIRCd modules. All modules must inherit from this class,
* receive it, or zero to allow the line to be sent.
*/
virtual int OnWhoisLine(userrec* user, userrec* dest, int &numeric, std::string &text);
+
+ /** Called at intervals for modules to garbage-collect any hashes etc.
+ * Certain data types such as hash_map 'leak' buckets, which must be
+ * tidied up and freed by copying into a new item every so often. This
+ * method is called when it is time to do that.
+ */
+ virtual void OnGarbageCollect();
};
* This method destroys the ConfigReader class.
*/
~ConfigReader();
+
+ /** Retrieves a value from the config file.
+ * This method retrieves a value from the config file. Where multiple copies of the tag
+ * exist in the config file, index indicates which of the values to retrieve. If the
+ * tag is not found the default value is returned instead.
+ */
+ std::string ReadValue(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool allow_linefeeds = false);
/** Retrieves a value from the config file.
* This method retrieves a value from the config file. Where multiple copies of the tag
* exist in the config file, index indicates which of the values to retrieve.
*/
- std::string ReadValue(const std::string &tag, const std::string &name, int index);
+ std::string ReadValue(const std::string &tag, const std::string &name, int index, bool allow_linefeeds = false);
/** Retrieves a boolean value from the config file.
* This method retrieves a boolean value from the config file. Where multiple copies of the tag
* exist in the config file, index indicates which of the values to retrieve. The values "1", "yes"