]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/ctables.h
(Bigger than it looks, i did this with perl inplace edit) -- commands now take an...
[user/henk/code/inspircd.git] / include / ctables.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16  
17 #ifndef __CTABLES_H__
18 #define __CTABLES_H__
19
20
21 #include "inspircd_config.h"
22 #include "hash_map.h"
23 #include "base.h"
24
25 class userrec;
26 class InspIRCd;
27
28 /*typedef void (handlerfunc) (char**, int, userrec*);*/
29
30 /** A structure that defines a command
31  */
32 class command_t : public Extensible
33 {
34  protected:
35         InspIRCd* ServerInstance;
36  public:
37         /** Command name
38         */
39          std::string command;
40         /** User flags needed to execute the command or 0
41          */
42         char flags_needed;
43         /** Minimum number of parameters command takes
44         */
45         int min_params;
46         /** used by /stats m
47          */
48         long use_count;
49         /** used by /stats m
50          */
51         long total_bytes;
52         /** used for resource tracking between modules
53          */
54         std::string source;
55         /** True if the command is disabled to non-opers
56          */
57         bool disabled;
58         /** Syntax string for the command, displayed if non-empty string.
59          * This takes place of the text in the 'not enough parameters' numeric.
60          */
61         std::string syntax;
62
63         command_t(InspIRCd* Instance, const std::string &cmd, char flags, int minpara) : ServerInstance(Instance), command(cmd), flags_needed(flags), min_params(minpara), disabled(false)
64         {
65                 use_count = total_bytes = 0;
66                 source = "<core>";
67                 syntax = "";
68         }
69
70         virtual void Handle(const char** parameters, int pcnt, userrec* user) = 0;
71
72         void Disable(bool setting)
73         {
74                 disabled = setting;
75         }
76
77         bool IsDisabled()
78         {
79                 return disabled;
80         }
81
82         virtual ~command_t() {}
83 };
84
85 typedef nspace::hash_map<std::string,command_t*> command_table;
86
87 #endif