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__
|
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
#include "inspircd_config.h"
|
2005-12-28 21:21:54 +00:00
|
|
|
|
|
|
|
#ifdef GCC3
|
|
|
|
#include <ext/hash_map>
|
|
|
|
#else
|
|
|
|
#include <hash_map>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef GCC3
|
|
|
|
#define nspace __gnu_cxx
|
|
|
|
#else
|
|
|
|
#define nspace std
|
|
|
|
#endif
|
2005-12-16 12:00:52 +00:00
|
|
|
|
|
|
|
class userrec;
|
|
|
|
|
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
|
|
|
|
*/
|
2005-12-16 12:00:52 +00:00
|
|
|
class command_t
|
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-03-12 16:56:02 +00:00
|
|
|
command_t(const std::string &cmd, char flags, int minpara) : command(cmd), flags_needed(flags), min_params(minpara)
|
2005-12-16 18:10:38 +00:00
|
|
|
{
|
|
|
|
use_count = total_bytes = 0;
|
|
|
|
source = "<core>";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Handle(char** parameters, int pcnt, userrec* user) = 0;
|
|
|
|
|
|
|
|
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
|
|
|
|
|