#ifndef __MODULES_H
#define __MODULES_H
-#include "globals.h"
#include "dynamic.h"
#include "base.h"
#include "ctables.h"
#define FD_MAGIC_NUMBER -42
/* Useful macros */
-#ifdef WINDOWS
+
/** Is a local user */
#define IS_LOCAL(x) ((x->GetFd() > -1))
-#else
-/** Is a local user */
-#define IS_LOCAL(x) ((x->GetFd() > -1) && (x->GetFd() <= MAX_DESCRIPTORS))
-#endif
/** Is a remote user */
#define IS_REMOTE(x) (x->GetFd() < 0)
/** Is a module created user */
#define IS_MODULE_CREATED(x) (x->GetFd() == FD_MAGIC_NUMBER)
/** Is an oper */
-#define IS_OPER(x) (*x->oper)
+#define IS_OPER(x) (!x->oper.empty())
/** Is away */
-#define IS_AWAY(x) (*x->awaymsg)
+#define IS_AWAY(x) (!x->awaymsg.empty())
/** Holds a module's Version information.
* The four members (set by the constructor only) indicate details as to the version number
class CoreExport Version : public classbase
{
public:
- /** Version numbers, build number, flags and API version
- */
- const int Major, Minor, Revision, Build, Flags, API;
+ /** Version information.
+ */
+ std::string version;
+
+ /** Flags and API version
+ */
+ const int Flags, API;
- /** Initialize version class
- */
- Version(int major, int minor, int revision, int build, int flags, int api_ver);
+ /** Initialize version class
+ */
+ Version(const std::string &sversion, int flags, int api_ver);
};
/** The ModuleMessage class is the base class of Request and Event
enum Implementation
{
I_BEGIN,
- I_OnUserConnect, I_OnUserQuit, I_OnUserDisconnect, I_OnUserJoin, I_OnUserPart, I_OnRehash, I_OnServerRaw,
+ I_OnUserConnect, I_OnUserQuit, I_OnUserDisconnect, I_OnUserJoin, I_OnUserPart, I_OnRehash, I_OnServerRaw, I_OnSendSnotice,
I_OnUserPreJoin, I_OnUserPreKick, I_OnUserKick, I_OnOper, I_OnInfo, I_OnWhois, I_OnUserPreInvite,
I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserPreNick, I_OnUserMessage, I_OnUserNotice, I_OnMode,
I_OnGetServerDescription, I_OnSyncUser, I_OnSyncChannel, I_OnSyncChannelMetaData, I_OnSyncUserMetaData,
I_OnDecodeMetaData, I_ProtoSendMode, I_ProtoSendMetaData, I_OnWallops, I_OnChangeHost, I_OnChangeName, I_OnAddLine,
I_OnDelLine, I_OnExpireLine, I_OnCleanup, I_OnUserPostNick, I_OnAccessCheck, I_On005Numeric, I_OnKill, I_OnRemoteKill, I_OnLoadModule, I_OnUnloadModule,
I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite, I_OnRawMode,
- I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnStats, I_OnChangeLocalUserHost, I_OnChangeLocalUserGecos, I_OnLocalTopicChange,
- I_OnPostLocalTopicChange, I_OnEvent, I_OnRequest, I_OnGlobalOper, I_OnPostConnect, I_OnAddBan, I_OnDelBan,
+ I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnCheckExtBan, I_OnCheckStringExtBan, I_OnStats, I_OnChangeLocalUserHost, I_OnChangeLocalUserGecos,
+ I_OnLocalTopicChange, I_OnPostLocalTopicChange, I_OnEvent, I_OnRequest, I_OnGlobalOper, I_OnPostConnect, I_OnAddBan, I_OnDelBan,
I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketWrite, I_OnRawSocketRead, I_OnChangeLocalUserGECOS, I_OnUserRegister,
I_OnChannelPreDelete, I_OnChannelDelete, I_OnPostOper, I_OnSyncOtherMetaData, I_OnSetAway, I_OnUserList,
I_OnPostCommand, I_OnPostJoin, I_OnWhoisLine, I_OnBuildExemptList, I_OnRawSocketConnect, I_OnGarbageCollect, I_OnBufferFlushed,
- I_OnText, I_OnReadConfig, I_OnDownloadFile, I_OnPassCompare, I_OnRunTestSuite, I_OnNamesListItem, I_OnNumeric, I_OnHookUserIO,
+ I_OnText, I_OnPassCompare, I_OnRunTestSuite, I_OnNamesListItem, I_OnNumeric, I_OnHookUserIO,
I_END
};
{
}
- virtual void OnReadConfig(ServerConfig* config, ConfigReader* coreconf);
-
- virtual int OnDownloadFile(const std::string &filename, std::istream* &filedata);
-
/** Returns the version number of a Module.
* The method should return a Version object with its version information assigned via
* Version::Version
* and the details of the channel they have left is available in the variable Channel *channel
* @param user The user who is parting
* @param channel The channel being parted
- * @param partmessage The part message, or an empty string
+ * @param partmessage The part message, or an empty string (may be modified)
* @param silent Change this to true if you want to conceal the PART command from the other users
* of the channel (useful for modules such as auditorium)
*/
- virtual void OnUserPart(User* user, Channel* channel, const std::string &partmessage, bool &silent);
+ virtual void OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent);
/** Called on rehash.
* This method is called prior to a /REHASH or when a SIGHUP is received from the operating
*/
virtual void OnServerRaw(std::string &raw, bool inbound, User* user);
+ /** Called whenever a snotice is about to be sent to a snomask.
+ * snomask and type may both be modified; the message may not.
+ * @param snomask The snomask the message is going to (e.g. 'A')
+ * @param type The textual description the snomask will go to (e.g. 'OPER')
+ * @param message The text message to be sent via snotice
+ * @return 1 to block the snotice from being sent entirely, 0 else.
+ */
+ virtual int OnSendSnotice(char &snomask, std::string &type, const std::string &message);
+
/** Called whenever a user is about to join a channel, before any processing is done.
* Returning a value of 1 from this function stops the process immediately, causing no
* output to be sent to the user by the core. If you do this you must produce your own numerics,
* @param cname The channel name being joined. For new channels this is valid where chan is not.
* @param privs A string containing the users privilages when joining the channel. For new channels this will contain "@".
* You may alter this string to alter the user's modes on the channel.
+ * @param keygiven The key given to join the channel, or an empty string if none was provided
* @return 1 To prevent the join, 0 to allow it.
*/
- virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs);
+ virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven);
/** Called whenever a user is about to be kicked.
* Returning a value of 1 from this function stops the process immediately, causing no
* @param dest The user being invited
* @param channel The channel the user is being invited to
* @param timeout The time the invite will expire (0 == never)
- * @return 1 to deny the invite, 0 to allow
+ * @return 1 to deny the invite, 0 to check whether or not the user has permission to invite, -1 to explicitly allow the invite
*/
virtual int OnUserPreInvite(User* source,User* dest,Channel* channel, time_t timeout);
* @param pcnt The nuimber of parameters passed to the command
* @param user the user issuing the command
* @param validated True if the command has passed all checks, e.g. it is recognised, has enough parameters, the user has permission to execute it, etc.
+ * You should only change the parameter list and command string if validated == false (e.g. before the command lookup occurs).
* @param original_line The entire original line as passed to the parser from the user
* @return 1 to block the command, 0 to allow
*/
- virtual int OnPreCommand(const std::string &command, const char* const* parameters, int pcnt, User *user, bool validated, const std::string &original_line);
+ virtual int OnPreCommand(std::string &command, std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line);
/** Called after any command has been executed.
* This event occurs for all registered commands, wether they are registered in the core,
* @param result The return code given by the command handler, one of CMD_SUCCESS or CMD_FAILURE
* @param original_line The entire original line as passed to the parser from the user
*/
- virtual void OnPostCommand(const std::string &command, const char* const* parameters, int pcnt, User *user, CmdResult result, const std::string &original_line);
+ virtual void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line);
/** Called to check if a user who is connecting can now be allowed to register
* If any modules return false for this function, the user is held in the waiting
* return 1 to explicitly allow the join to go ahead or 0 to ignore the event.
* @param user The user joining the channel
* @param chan The channel being joined
- * @return 1 to explicitly allow the join, 0 to proceed as normal
+ * @return 1 to explicitly allow the join, 0 to proceed as normal. Return -1 to explicitly deny the
+ * join to the channel.
*/
virtual int OnCheckBan(User* user, Channel* chan);
+ /* Called whenever checking whether or not a user is matched by an applicable extended bantype.
+ * NOTE: may also trigger extra OnCheckStringExtBan events!
+ * @param u The user to check
+ * @param c The channel the user is on
+ * @param type The type of extended ban to check for.
+ */
+ virtual int OnCheckExtBan(User *u, Channel *c, char type);
+
+ /** Called whenever checking whether or not a string is extbanned. NOTE: one OnCheckExtBan will also trigger a number of
+ * OnCheckStringExtBan events for seperate host/IP comnbinations.
+ */
+ virtual int OnCheckStringExtBan(const std::string &s, Channel *c, char type);
+
/** Called on all /STATS commands
* This method is triggered for all /STATS use, including stats symbols handled by the core.
* @param symbol the symbol provided to /STATS
virtual int OnChangeLocalUserGECOS(User* user, const std::string &newhost);
/** Called whenever a topic is changed by a local user.
- * Return 1 to deny the topic change, or 0 to allow it.
+ * Return 1 to deny the topic change, 0 to check details on the change, -1 to let it through with no checks
* @param user The user changing the topic
* @param chan The channels who's topic is being changed
* @param topic The actual topic text
* and functions needed to make a module loadable by the OS.
* It defines the class factory and external init_module function.
*/
+#ifdef WINDOWS
+
#define MODULE_INIT(y) \
extern "C" DllExport Module * init_module(InspIRCd* Me) \
{ \
return new y(Me); \
+ } \
+ BOOLEAN WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) \
+ { \
+ switch ( nReason ) \
+ { \
+ case DLL_PROCESS_ATTACH: \
+ case DLL_PROCESS_DETACH: \
+ break; \
+ } \
+ return TRUE; \
}
+#else
+
+#define MODULE_INIT(y) \
+ extern "C" DllExport Module * init_module(InspIRCd* Me) \
+ { \
+ return new y(Me); \
+ }
+#endif
+
#endif