2003-01-23 19:45:57 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
2006-01-15 15:59:11 +00:00
|
|
|
* InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
|
2003-01-23 19:45:57 +00:00
|
|
|
* E-mail:
|
|
|
|
* <brain@chatspike.net>
|
|
|
|
* <Craig@chatspike.net>
|
|
|
|
*
|
|
|
|
* Written by Craig Edwards, Craig McLure, and others.
|
|
|
|
* This program is free but copyrighted software; see
|
|
|
|
* the file COPYING for details.
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*/
|
2004-05-16 14:58:40 +00:00
|
|
|
|
2004-04-29 15:35:00 +00:00
|
|
|
#ifndef __CTABLES_H__
|
|
|
|
#define __CTABLES_H__
|
|
|
|
|
2006-07-19 13:50:16 +00:00
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
#include "inspircd_config.h"
|
2006-04-08 17:05:48 +00:00
|
|
|
#include "hash_map.h"
|
2006-07-10 18:25:17 +00:00
|
|
|
#include "base.h"
|
2005-12-16 12:00:52 +00:00
|
|
|
|
|
|
|
class userrec;
|
2006-08-11 00:15:07 +00:00
|
|
|
class InspIRCd;
|
2005-12-16 12:00:52 +00:00
|
|
|
|
2005-12-16 18:10:38 +00:00
|
|
|
/*typedef void (handlerfunc) (char**, int, userrec*);*/
|
2005-12-14 17:44:38 +00:00
|
|
|
|
2003-02-09 12:49:00 +00:00
|
|
|
/** A structure that defines a command
|
|
|
|
*/
|
2006-07-10 18:22:16 +00:00
|
|
|
class command_t : public Extensible
|
2003-01-26 23:53:03 +00:00
|
|
|
{
|
2006-08-11 00:15:07 +00:00
|
|
|
protected:
|
|
|
|
InspIRCd* ServerInstance;
|
2003-01-26 23:53:03 +00:00
|
|
|
public:
|
2004-04-11 13:08:31 +00:00
|
|
|
/** Command name
|
|
|
|
*/
|
2005-12-16 18:10:38 +00:00
|
|
|
std::string command;
|
2003-02-09 12:49:00 +00:00
|
|
|
/** User flags needed to execute the command or 0
|
|
|
|
*/
|
|
|
|
char flags_needed;
|
2004-04-11 13:08:31 +00:00
|
|
|
/** Minimum number of parameters command takes
|
|
|
|
*/
|
2003-02-09 12:49:00 +00:00
|
|
|
int min_params;
|
|
|
|
/** used by /stats m
|
|
|
|
*/
|
|
|
|
long use_count;
|
|
|
|
/** used by /stats m
|
|
|
|
*/
|
|
|
|
long total_bytes;
|
2005-04-07 17:04:04 +00:00
|
|
|
/** used for resource tracking between modules
|
|
|
|
*/
|
2005-12-16 18:10:38 +00:00
|
|
|
std::string source;
|
2006-07-16 13:02:38 +00:00
|
|
|
/** True if the command is disabled to non-opers
|
|
|
|
*/
|
|
|
|
bool disabled;
|
2006-07-28 00:13:41 +00:00
|
|
|
/** Syntax string for the command, displayed if non-empty string.
|
|
|
|
* This takes place of the text in the 'not enough parameters' numeric.
|
|
|
|
*/
|
|
|
|
std::string syntax;
|
2005-12-16 18:10:38 +00:00
|
|
|
|
2006-08-11 00:15:07 +00:00
|
|
|
command_t(InspIRCd* Instance, const std::string &cmd, char flags, int minpara) : ServerInstance(Instance), command(cmd), flags_needed(flags), min_params(minpara), disabled(false)
|
2005-12-16 18:10:38 +00:00
|
|
|
{
|
|
|
|
use_count = total_bytes = 0;
|
|
|
|
source = "<core>";
|
2006-07-28 00:13:41 +00:00
|
|
|
syntax = "";
|
2005-12-16 18:10:38 +00:00
|
|
|
}
|
|
|
|
|
2006-07-16 12:18:29 +00:00
|
|
|
virtual void Handle(const char** parameters, int pcnt, userrec* user) = 0;
|
2005-12-16 18:10:38 +00:00
|
|
|
|
2006-07-16 13:02:38 +00:00
|
|
|
void Disable(bool setting)
|
|
|
|
{
|
|
|
|
disabled = setting;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsDisabled()
|
|
|
|
{
|
|
|
|
return disabled;
|
|
|
|
}
|
|
|
|
|
2005-12-16 18:10:38 +00:00
|
|
|
virtual ~command_t() {}
|
2003-01-23 19:45:57 +00:00
|
|
|
};
|
|
|
|
|
2005-12-28 21:21:54 +00:00
|
|
|
typedef nspace::hash_map<std::string,command_t*> command_table;
|
2005-12-16 12:00:52 +00:00
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
#endif
|