]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/command_parse.h
Remove unneeded headers from spanningtree. This was done to the rest of the source...
[user/henk/code/inspircd.git] / include / command_parse.h
index d7c0c4ac15c59ff35abf5ed01798f8b82cb7853c..2c883be203b696458ea4c6366af404c907161355 100644 (file)
@@ -2,12 +2,9 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- *                       E-mail:
- *                <brain@chatspike.net>
- *                <Craig@chatspike.net>
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
  *
- * Written by Craig Edwards, Craig McLure, and others.
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
  *
 #include "ctables.h"
 #include "typedefs.h"
 
+/** Required forward declaration
+ */
 class InspIRCd;
 
+/** A list of dll/so files containing the command handlers for the core
+ */
 typedef std::map<std::string, void*> SharedObjectList;
 
 /** This class handles command management and parsing.
@@ -31,7 +32,7 @@ typedef std::map<std::string, void*> SharedObjectList;
  * call command handlers by name, and chop up comma seperated
  * parameters into multiple calls.
  */
-class CommandParser : public classbase
+class CoreExport CommandParser : public classbase
 {
  private:
        /** The creator of this class
@@ -55,10 +56,6 @@ class CommandParser : public classbase
         */
        void ProcessCommand(userrec *user, std::string &cmd);
 
-       /** Insert the default RFC1459 commands into the command hash.
-        */
-       void SetupCommandTable();
-
        /** Finds the init_command symbol in a .so file
         * @param v A function pointer to be initialized
         * @param h A valid shared object handle
@@ -72,8 +69,15 @@ class CommandParser : public classbase
 
        /** Load a command from a shared object on disk.
         * @param name The shared object to load (without path)
+        * @return NULL on success, pointer to dlerrr() error message on failure
         */
-       void LoadCommand(const char* name);
+       const char* LoadCommand(const char* name);
+
+       /** Removes a command if the sources match. Used as a helper for
+        *  safe hash_map delete while iter in RemoveCommands(const char* source).
+        */
+       void RemoveCommand(nspace::hash_map<std::string,command_t*>::iterator safei, const char* source);
+
 
  public:
        /** Command list, a hash_map of command names to command_t*
@@ -88,7 +92,7 @@ class CommandParser : public classbase
         * @return True if the command was reloaded, false if it could not be found
         * or another error occured
         */
-       bool ReloadCommand(const char* cmd);
+       bool ReloadCommand(const char* cmd, userrec* user);
 
        /** Default constructor.
         * @param Instance The creator of this class
@@ -108,6 +112,10 @@ class CommandParser : public classbase
         */
        CmdResult CallHandler(const std::string &commandname,const char** parameters, int pcnt, userrec *user);
 
+       /** Get the handler function for a command.
+        * @param commandname The command required. Always use uppercase for this parameter.
+        * @return a pointer to the command handler, or NULL
+        */
        command_t* GetHandler(const std::string &commandname);
 
        /** This function returns true if a command is valid with the given number of parameters and user.
@@ -186,6 +194,21 @@ class CommandParser : public classbase
         * @return True if the command was added
         */
        bool CreateCommand(command_t *f, void* so_handle = NULL);
+
+       /** Insert the default RFC1459 commands into the command hash.
+        * Ignore any already loaded commands.
+        * @param user User to spool errors to, or if NULL, when an error occurs spool the errors to
+        * stdout then exit with EXIT_STATUS_HANDLER.
+        */
+       void SetupCommandTable(userrec* user);
+
+       /** Translate nicknames in a string into UIDs, based on the TranslationType given.
+        * @param to The translation type to use for the process.
+        * @param source The input string
+        * @param dest The output string, it is safe to pass source and dest as the same variable only for translation type TR_TEXT.
+        * @return returns the number of substitutions made. Will always be 0 or 1 for TR_TEXT and 0..n for other types.
+        */
+       int TranslateUIDs(TranslateType to, const std::string &source, std::string &dest);
 };
 
 /** Command handler class for the RELOAD command.
@@ -202,6 +225,32 @@ class cmd_reload : public command_t
        CmdResult Handle(const char** parameters, int pcnt, userrec *user);
 };
 
-
+/** A lookup table of values for multiplier characters used by
+ * InspIRCd::Duration(). In this lookup table, the indexes for
+ * the ascii values 'm' and 'M' have the value '60', the indexes
+ * for the ascii values 'D' and 'd' have a value of '86400', etc.
+ */
+const int duration_multi[] =
+{
+       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+       1, 1, 1, 1, 1, 1, 1, 1, 86400, 1, 1, 1, 3600,
+       1, 1, 1, 1, 60, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+       604800, 1, 31536000, 1, 1, 1, 1, 1, 1, 1, 1,
+       1, 1, 86400, 1, 1, 1, 3600, 1, 1, 1, 1, 60,
+       1, 1, 1, 1, 1, 1, 1, 1, 1, 604800, 1, 31536000,
+       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+};
 
 #endif
+