]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/modules.h
Add a counter for errored files
[user/henk/code/inspircd.git] / include / modules.h
index 598c0b4f6f00aa1e434348fbb557423bd21b7997..a3cac1486b891af17c9e8302334729bfe9500c01 100644 (file)
@@ -123,18 +123,23 @@ typedef std::map<std::string, std::pair<int, modulelist> > interfacelist;
  * loaded modules in a readable simple way, e.g.:
  * 'FOREACH_MOD(I_OnConnect,OnConnect(user));'
  */
-#define FOREACH_MOD(y,x) \
-for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ++_i) \
-{ \
-       try \
+#define FOREACH_MOD(y,x) do { \
+       EventHandlerIter safei; \
+       for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ) \
        { \
-               (*_i)->x ; \
-       } \
-       catch (CoreException& modexcept) \
-       { \
-               ServerInstance->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \
+               safei = _i; \
+               ++safei; \
+               try \
+               { \
+                       (*_i)->x ; \
+               } \
+               catch (CoreException& modexcept) \
+               { \
+                       ServerInstance->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \
+               } \
+               _i = safei; \
        } \
-}
+} while (0);
 
 /**
  * This #define allows us to call a method in all
@@ -142,18 +147,23 @@ for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i
  * an instance pointer to the macro. e.g.:
  * 'FOREACH_MOD_I(Instance, OnConnect, OnConnect(user));'
  */
-#define FOREACH_MOD_I(z,y,x) \
-for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Modules->EventHandlers[y].end(); ++_i) \
-{ \
-       try \
-       { \
-               (*_i)->x ; \
-       } \
-       catch (CoreException& modexcept) \
+#define FOREACH_MOD_I(z,y,x) do { \
+       EventHandlerIter safei; \
+       for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Modules->EventHandlers[y].end(); ) \
        { \
-               z->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \
+               safei = _i; \
+               ++safei; \
+               try \
+               { \
+                       (*_i)->x ; \
+               } \
+               catch (CoreException& modexcept) \
+               { \
+                       z->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \
+               } \
+               _i = safei; \
        } \
-}
+} while (0);
 
 /**
  * This define is similar to the one above but returns a result in MOD_RESULT.
@@ -162,9 +172,12 @@ for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Module
  */
 #define FOREACH_RESULT(y,x) \
 do { \
+       EventHandlerIter safei; \
        MOD_RESULT = 0; \
-       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(); ) \
        { \
+               safei = _i; \
+               ++safei; \
                try \
                { \
                        int res = (*_i)->x ; \
@@ -177,6 +190,7 @@ do { \
                { \
                        ServerInstance->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \
                } \
+               _i = safei; \
        } \
 } while(0);
 
@@ -188,9 +202,12 @@ do { \
  */
 #define FOREACH_RESULT_I(z,y,x) \
 do { \
+       EventHandlerIter safei; \
        MOD_RESULT = 0; \
-       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(); ) \
        { \
+               safei = _i; \
+               ++safei; \
                try \
                { \
                        int res = (*_i)->x ; \
@@ -203,6 +220,7 @@ do { \
                { \
                        z->Log(DEBUG,"Exception caught: %s",modexcept.GetReason()); \
                } \
+               _i = safei; \
        } \
 } while (0);
 
@@ -383,10 +401,12 @@ enum Implementation
        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_OnGarbageCollect, I_OnBufferFlushed,
-       I_OnText,
+       I_OnText, I_OnReadConfig, I_OnDownloadFile,
        I_END
 };
 
+class ConfigReader;
+
 /** Base class for all InspIRCd modules
  *  This class is the base class for InspIRCd modules. All modules must inherit from this class,
  *  its methods will be called when irc server events occur. class inherited from module must be
@@ -416,6 +436,10 @@ class CoreExport Module : public Extensible
        {
        }
 
+       virtual void OnReadConfig(ServerConfig* config, ConfigReader* coreconf);
+
+       virtual int OnDownloadFile(const std::string &filename, std::stringstream &filedata);
+
        /** Returns the version number of a Module.
         * The method should return a Version object with its version information assigned via
         * Version::Version
@@ -458,8 +482,10 @@ class CoreExport Module : public Extensible
         * @param channel The channel being joined
         * @param silent Change this to true if you want to conceal the JOIN command from the other users
         * of the channel (useful for modules such as auditorium)
+        * @param sync This is set to true if the JOIN is the result of a network sync and the remote user is being introduced
+        * to a channel due to the network sync.
         */
-       virtual void OnUserJoin(User* user, Channel* channel, bool &silent);
+       virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent);
 
        /** Called after a user joins a channel
         * Identical to OnUserJoin, but called immediately afterwards, when any linking module has
@@ -1269,7 +1295,9 @@ class CoreExport Module : public Extensible
         * @param userlist The user list for the channel (you may change this pointer.
         * If you want to change the values, take a copy first, and change the copy, then
         * point the pointer at your copy)
-        * @return 1 to prevent the user list being sent to the client, 0 to allow it
+        * @return 1 to prevent the user list being sent to the client, 0 to allow it.
+        * Returning -1 allows the names list, but bypasses any checks which check for
+        * channel membership before sending the names list.
         */
        virtual int OnUserList(User* user, Channel* Ptr, CUList* &userlist);