X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fmodules.h;h=6a56384f5ec05ad306b486768b5eec8b5f1fc136;hb=38d5fd9b40e126bfde51022dac8d5a8a1ff787a9;hp=d429288c91979125128adbe73b4eb2309ec9aa18;hpb=43d2d6ec89d35adf021a8bbd52373e3b6e3d3042;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/modules.h b/include/modules.h index d429288c9..6a56384f5 100644 --- a/include/modules.h +++ b/include/modules.h @@ -123,18 +123,16 @@ typedef std::map > interfacelist; * loaded modules in a readable simple way, e.g.: * 'FOREACH_MOD(I_OnConnect,OnConnect(user));' */ -#define FOREACH_MOD(y,x) if (!ServerInstance->Modules->EventHandlers[y].empty()) \ +#define FOREACH_MOD(y,x) \ +for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ++_i) \ { \ - for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ++_i) \ + try \ { \ - try \ - { \ - (*_i)->x ; \ - } \ - catch (CoreException& modexcept) \ - { \ - ServerInstance->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \ - } \ + (*_i)->x ; \ + } \ + catch (CoreException& modexcept) \ + { \ + ServerInstance->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \ } \ } @@ -144,18 +142,16 @@ typedef std::map > interfacelist; * an instance pointer to the macro. e.g.: * 'FOREACH_MOD_I(Instance, OnConnect, OnConnect(user));' */ -#define FOREACH_MOD_I(z,y,x) if (!z->Modules->EventHandlers[y].empty()) \ +#define FOREACH_MOD_I(z,y,x) \ +for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Modules->EventHandlers[y].end(); ++_i) \ { \ - for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Modules->EventHandlers[y].end(); ++_i) \ + try \ { \ - try \ - { \ - (*_i)->x ; \ - } \ - catch (CoreException& modexcept) \ - { \ - z->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \ - } \ + (*_i)->x ; \ + } \ + catch (CoreException& modexcept) \ + { \ + z->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \ } \ } @@ -164,8 +160,8 @@ typedef std::map > interfacelist; * The first module to return a nonzero result is the value to be accepted, * and any modules after are ignored. */ -#define FOREACH_RESULT(y,x) if (!ServerInstance->Modules->EventHandlers[y].empty()) \ -{ \ +#define FOREACH_RESULT(y,x) \ +do { \ MOD_RESULT = 0; \ for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ++_i) \ { \ @@ -182,7 +178,7 @@ typedef std::map > interfacelist; ServerInstance->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \ } \ } \ -} +} while(0); /** @@ -190,8 +186,8 @@ typedef std::map > interfacelist; * The first module to return a nonzero result is the value to be accepted, * and any modules after are ignored. */ -#define FOREACH_RESULT_I(z,y,x) if (!z->Modules->EventHandlers[y].empty()) \ -{ \ +#define FOREACH_RESULT_I(z,y,x) \ +do { \ MOD_RESULT = 0; \ for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Modules->EventHandlers[y].end(); ++_i) \ { \ @@ -208,7 +204,7 @@ typedef std::map > interfacelist; z->Log(DEBUG,"Exception caught: %s",modexcept.GetReason()); \ } \ } \ -} +} while (0); /** Represents a non-local user. * (in fact, any FD less than -1 does) @@ -1521,10 +1517,6 @@ class CoreExport FileReader : public classbase */ typedef DLLFactory ircd_module; -/** A list of loaded module handles (ircd_module) - */ -typedef std::vector ModuleHandleList; - /** A list of modules */ typedef std::vector IntModuleList; @@ -1556,7 +1548,7 @@ class CoreExport ModuleManager : public classbase private: /** Holds a string describing the last module error to occur */ - char MODERR[MAXBUF]; + std::string LastModuleError; /** The feature names published by various modules */ @@ -1566,7 +1558,7 @@ class CoreExport ModuleManager : public classbase */ interfacelist Interfaces; - /** Total number of modules loaded into the ircd, minus one + /** Total number of modules loaded into the ircd */ int ModCount; @@ -1659,7 +1651,7 @@ class CoreExport ModuleManager : public classbase /** Returns text describing the last module error * @return The last error message to occur */ - const char* LastError(); + std::string& LastError(); /** Load a given module file * @param filename The file to load