#ifndef __MODULES_H
#define __MODULES_H
-/** log levels
- */
-enum DebugLevels { DEBUG, VERBOSE, DEFAULT, SPARSE, NONE };
-
/** Used with OnAccessCheck() method of modules
*/
enum AccessControlType {
typedef std::deque<std::string> file_cache;
typedef file_cache string_list;
-/** Holds a list of users in a channel
- */
-typedef std::deque<userrec*> chanuserlist;
-
-
/** Holds a list of 'published features' for modules.
*/
typedef std::map<std::string,Module*> featurelist;
* loaded modules in a readable simple way, e.g.:
* 'FOREACH_MOD(I_OnXonnwxr,OnConnect(user));'
*/
-#define FOREACH_MOD(y,x) if (Config->global_implementation[y] > 0) { \
+#define FOREACH_MOD(y,x) if (ServerInstance->Config->global_implementation[y] > 0) { \
for (int _i = 0; _i <= MODCOUNT; _i++) { \
- if (Config->implement_lists[_i][y]) \
+ if (ServerInstance->Config->implement_lists[_i][y]) \
try \
{ \
modules[_i]->x ; \
} \
}
+#define FOREACH_MOD_I(z,y,x) if (z->Config->global_implementation[y] > 0) { \
+ for (int _i = 0; _i <= MODCOUNT; _i++) { \
+ if (z->Config->implement_lists[_i][y]) \
+ try \
+ { \
+ modules[_i]->x ; \
+ } \
+ catch (ModuleException& modexcept) \
+ { \
+ log(DEBUG,"Module exception caught: %s",modexcept.GetReason()); \
+ } \
+ } \
+}
/**
* This define is similar to the one above but returns a result in MOD_RESULT.
* 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 (Config->global_implementation[y] > 0) { \
+#define FOREACH_RESULT(y,x) { if (ServerInstance->Config->global_implementation[y] > 0) { \
MOD_RESULT = 0; \
for (int _i = 0; _i <= MODCOUNT; _i++) { \
- if (Config->implement_lists[_i][y]) {\
+ if (ServerInstance->Config->implement_lists[_i][y]) { \
try \
{ \
int res = modules[_i]->x ; \
} \
}
+#define FOREACH_RESULT_I(z,y,x) { if (z->Config->global_implementation[y] > 0) { \
+ MOD_RESULT = 0; \
+ for (int _i = 0; _i <= MODCOUNT; _i++) { \
+ if (z->Config->implement_lists[_i][y]) { \
+ try \
+ { \
+ int res = modules[_i]->x ; \
+ if (res != 0) { \
+ MOD_RESULT = res; \
+ break; \
+ } \
+ } \
+ catch (ModuleException& modexcept) \
+ { \
+ log(DEBUG,"Module exception cought: %s",modexcept.GetReason()); \
+ } \
+ } \
+ } \
+ } \
+}
+
#define FD_MAGIC_NUMBER -42
// useful macros
*/
virtual bool IsNick(const std::string &nick);
- /** Returns a count of the number of users on a channel.
- * This will NEVER be 0, as if the chanrec exists, it will have at least one user in the channel.
- */
- virtual int CountUsers(chanrec* c);
-
/** Adds an InspTimer which will trigger at a future time
*/
virtual void AddTimer(InspTimer* T);
*/
virtual void SendMode(const char **parameters, int pcnt, userrec *user);
-
- /** Sends to all users matching a mode mask
- * You must specify one or more usermodes as the first parameter. These can be RFC specified modes such as +i,
- * or module provided modes, including ones provided by your own module.
- * In the second parameter you must place a flag value which indicates wether the modes you have given will be
- * logically ANDed or OR'ed. You may use one of either WM_AND or WM_OR.
- * for example, if you were to use:
- *
- * Serv->SendToModeMask("xi", WM_OR, "m00");
- *
- * Then the text 'm00' will be sent to all users with EITHER mode x or i. Conversely if you used WM_AND, the
- * user must have both modes set to receive the message.
- */
- virtual void SendToModeMask(const std::string &modes, int flags, const std::string &text);
-
+
/** Matches text against a glob pattern.
* Uses the ircd's internal matching function to match string against a globbing pattern, e.g. *!*@*.com
* Returns true if the literal successfully matches the pattern, false if otherwise.
*/
virtual bool IsValidModuleCommand(const std::string &commandname, int pcnt, userrec* user);
- /** Change displayed hostname of a user.
- * You should always call this method to change a user's host rather than writing directly to the
- * dhost member of userrec, as any change applied via this method will be propogated to any
- * linked servers.
- */
- virtual void ChangeHost(userrec* user, const std::string &host);
-
- /** Change GECOS (fullname) of a user.
- * You should always call this method to change a user's GECOS rather than writing directly to the
- * fullname member of userrec, as any change applied via this method will be propogated to any
- * linked servers.
- */
- virtual void ChangeGECOS(userrec* user, const std::string &gecos);
-
/** Returns true if the servername you give is ulined.
* ULined servers have extra privilages. They are allowed to change nicknames on remote servers,
* change modes of clients which are on remote servers and set modes of channels where there are
*/
virtual bool IsUlined(const std::string &server);
- /** Fetches the userlist of a channel. This function must be here and not a member of userrec or
- * chanrec due to include constraints.
- */
- virtual chanuserlist GetUsers(chanrec* chan);
-
- /** Remove a user's connection to the irc server, but leave their client in existence in the
- * user hash. When you call this function, the user's file descriptor will be replaced with the
- * value of FD_MAGIC_NUMBER and their old file descriptor will be closed. This idle client will
- * remain until it is restored with a valid file descriptor, or is removed from IRC by an operator
- * After this call, the pointer to user will be invalid.
- */
- virtual bool UserToPseudo(userrec* user, const std::string &message);
-
- /** This user takes one user, and switches their file descriptor with another user, so that one user
- * "becomes" the other. The user in 'alive' is booted off the server with the given message. The user
- * referred to by 'zombie' should have previously been locked with Server::UserToPseudo, otherwise
- * stale sockets and file descriptor leaks can occur. After this call, the pointer to alive will be
- * invalid, and the pointer to zombie will be equivalent in effect to the old pointer to alive.
- */
- virtual bool PseudoToUser(userrec* alive, userrec* zombie, const std::string &message);
-
/** Adds a G-line
* The G-line is propogated to all of the servers in the mesh and enforced as soon as it is added.
* The duration must be in seconds, however you can use the Server::CalcDuration method to convert