]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/modules.h
Add proper support for "munging" of ipv6 addresses when ::ffff:addr is used (this...
[user/henk/code/inspircd.git] / include / modules.h
index 33416a596ed17a964aa6bbb187af6ee04e735c0c..25fb52077938fa6c0f5714464901e285bc32d008 100644 (file)
@@ -71,6 +71,7 @@ enum TargetTypeFlags {
 #include <typeinfo>
 #include "timer.h"
 #include "mode.h"
+#include "dns.h"
 
 class Server;
 class ServerConfig;
@@ -192,6 +193,11 @@ class Request : public ModuleMessage
        /** This member holds a pointer to arbitary data set by the emitter of the message
         */
        char* data;
+       /** This should be a null-terminated string identifying the type of request,
+        * all modules should define this and use it to determine the nature of the
+        * request before they attempt to cast the Request in any way.
+        */
+       const char* id;
        /** This is a pointer to the sender of the message, which can be used to
         * directly trigger events, or to create a reply.
         */
@@ -201,11 +207,28 @@ class Request : public ModuleMessage
        Module* dest;
  public:
        /** Create a new Request
+        * This is for the 'old' way of casting whatever the data is
+        * to char* and hoping you get the right thing at the other end.
+        * This is slowly being depreciated in favor of the 'new' way.
         */
        Request(char* anydata, Module* src, Module* dst);
+       /** Create a new Request
+        * This is for the 'new' way of defining a subclass
+        * of Request and defining it in a common header,
+        * passing an object of your Request subclass through
+        * as a Request* and using the ID string to determine
+        * what to cast it back to and the other end. This is
+        * much safer as there are no casts not confirmed by
+        * the ID string, and all casts are child->parent and
+        * can be checked at runtime with dynamic_cast<>()
+        */
+       Request(Module* src, Module* dst, const char* idstr);
        /** Fetch the Request data
         */
        char* GetData();
+       /** Fetch the ID string
+        */
+       const char* GetId();
        /** Fetch the request source
         */
        Module* GetSource();
@@ -966,7 +989,7 @@ class Module : public Extensible
         * @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.
         * @return 1 to block the command, 0 to allow
         */
-       virtual int OnPreCommand(const std::string &command, char **parameters, int pcnt, userrec *user, bool validated);
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated);
 
        /** 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
@@ -1048,10 +1071,11 @@ class Module : public Extensible
        /** 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
-        * @user the user issuing the /STATS command
+        * @param user the user issuing the /STATS command
+        * @param results A string_list to append results into
         * @return 1 to block the /STATS from being processed by the core, 0 to allow it
         */
-       virtual int OnStats(char symbol, userrec* user);
+       virtual int OnStats(char symbol, userrec* user, string_list &results);
 
        /** Called whenever a change of a local users displayed host is attempted.
         * Return 1 to deny the host change, or 0 to allow it.
@@ -1431,6 +1455,8 @@ class Server : public Extensible
 
        virtual bool DelModeWatcher(ModeWatcher* mw);
 
+       virtual bool AddResolver(Resolver* r);
+
        /** Adds a command to the command table.
         * This allows modules to add extra commands into the command table. You must place a function within your
         * module which is is of type handlerfunc:
@@ -1471,7 +1497,7 @@ class Server : public Extensible
         * your server in an unstable state!
         */
 
-       virtual void SendMode(char **parameters, int pcnt, userrec *user);
+       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,
@@ -1547,7 +1573,7 @@ class Server : public Extensible
         * used for privilage checks, etc.
         * @return True if the command exists
         */
-       virtual bool CallCommandHandler(const std::string &commandname, char** parameters, int pcnt, userrec* user);
+       virtual bool CallCommandHandler(const std::string &commandname, const char** parameters, int pcnt, userrec* user);
 
        /** This function returns true if the commandname exists, pcnt is equal to or greater than the number
         * of paramters the command requires, the user specified is allowed to execute the command, AND
@@ -1824,57 +1850,62 @@ class FileReader : public classbase
        /** The file contents
         */
        file_cache fc;
+
+       unsigned long contentsize;
+
+       void CalcSize();
+
  public:
-        /** Default constructor.
-         * This method does not load any file into memory, you must use the LoadFile method
-         * after constructing the class this way.
-         */
-        FileReader();
-
-        /** Secondary constructor.
-         * This method initialises the class with a file loaded into it ready for GetLine and
-         * and other methods to be called. If the file could not be loaded, FileReader::FileSize
-         * returns 0.
-         */
-        FileReader(const std::string &filename);
-
-        /** Default destructor.
-         * This deletes the memory allocated to the file.
-         */
-        ~FileReader();
-
-        /** Used to load a file.
-         * This method loads a file into the class ready for GetLine and
-         * and other methods to be called. If the file could not be loaded, FileReader::FileSize
-         * returns 0.
-         */
-        void LoadFile(const std::string &filename);
-
-        /** Returns the whole content of the file as std::string
-         */
-        std::string Contents();
-
-        /** Returns the entire size of the file as std::string
-         */
-        unsigned long ContentSize();
-
-        /** Returns true if the file exists
-         * This function will return false if the file could not be opened.
-         */
-        bool Exists();
-        
-        /** Retrieve one line from the file.
-         * This method retrieves one line from the text file. If an empty non-NULL string is returned,
-         * the index was out of bounds, or the line had no data on it.
-         */
-        std::string GetLine(int x);
-
-        /** Returns the size of the file in lines.
-         * This method returns the number of lines in the read file. If it is 0, no lines have been
-         * read into memory, either because the file is empty or it does not exist, or cannot be
-         * opened due to permission problems.
-         */
-        int FileSize();
+       /** Default constructor.
+        * This method does not load any file into memory, you must use the LoadFile method
+        * after constructing the class this way.
+        */
+       FileReader();
+
+       /** Secondary constructor.
+        * This method initialises the class with a file loaded into it ready for GetLine and
+        * and other methods to be called. If the file could not be loaded, FileReader::FileSize
+        * returns 0.
+        */
+       FileReader(const std::string &filename);
+
+       /** Default destructor.
+        * This deletes the memory allocated to the file.
+        */
+       ~FileReader();
+
+       /** Used to load a file.
+        * This method loads a file into the class ready for GetLine and
+        * and other methods to be called. If the file could not be loaded, FileReader::FileSize
+        * returns 0.
+        */
+       void LoadFile(const std::string &filename);
+
+       /** Returns the whole content of the file as std::string
+        */
+       std::string Contents();
+
+       /** Returns the entire size of the file as std::string
+        */
+       unsigned long ContentSize();
+
+       /** Returns true if the file exists
+        * This function will return false if the file could not be opened.
+        */
+       bool Exists();
+       /** Retrieve one line from the file.
+        * This method retrieves one line from the text file. If an empty non-NULL string is returned,
+        * the index was out of bounds, or the line had no data on it.
+        */
+       std::string GetLine(int x);
+
+       /** Returns the size of the file in lines.
+        * This method returns the number of lines in the read file. If it is 0, no lines have been
+        * read into memory, either because the file is empty or it does not exist, or cannot be
+        * opened due to permission problems.
+        */
+       int FileSize();
 };