#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.
* 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
*/
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
/** 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*
* @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
*/
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.
*/
bool RemoveCommands(const char* source);
- void RemoveCommand(nspace::hash_map<std::string,command_t*>::iterator safei, const char* source);
-
/** Add a new command to the commands hash
* @param f The new command_t to add to the list
* @param so_handle The handle to the shared object where the command can be found.
* @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);
};
/** Command handler class for the RELOAD command.
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
+