]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/ctables.h
And now, just to force you to recompile the *whole* ircd.. updated headers on the...
[user/henk/code/inspircd.git] / include / ctables.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13  
14 #ifndef __CTABLES_H__
15 #define __CTABLES_H__
16
17
18 #include "inspircd_config.h"
19 #include "hash_map.h"
20 #include "base.h"
21
22 class userrec;
23 class InspIRCd;
24
25 /** Used to indicate command success codes
26  */
27 enum CmdResult
28 {
29         CMD_FAILURE = 0,        /* Command exists, but failed */
30         CMD_SUCCESS = 1,        /* Command exists, and succeeded */
31         CMD_INVALID = 2,        /* Command doesnt exist at all! */
32         CMD_USER_DELETED = 3,   /* User was deleted! */
33 };
34
35 /** A structure that defines a command
36  */
37 class command_t : public Extensible
38 {
39  protected:
40         InspIRCd* ServerInstance;
41  public:
42         /** Command name
43         */
44          std::string command;
45         /** User flags needed to execute the command or 0
46          */
47         char flags_needed;
48         /** Minimum number of parameters command takes
49         */
50         int min_params;
51         /** used by /stats m
52          */
53         long use_count;
54         /** used by /stats m
55          */
56         long total_bytes;
57         /** used for resource tracking between modules
58          */
59         std::string source;
60         /** True if the command is disabled to non-opers
61          */
62         bool disabled;
63         /** True if the command can be issued before registering
64          */
65         bool works_before_reg;
66         /** Syntax string for the command, displayed if non-empty string.
67          * This takes place of the text in the 'not enough parameters' numeric.
68          */
69         std::string syntax;
70
71         command_t(InspIRCd* Instance, const std::string &cmd, char flags, int minpara, int before_reg = false) : ServerInstance(Instance), command(cmd), flags_needed(flags), min_params(minpara), disabled(false), works_before_reg(before_reg)
72         {
73                 use_count = total_bytes = 0;
74                 source = "<core>";
75                 syntax = "";
76         }
77
78         virtual CmdResult Handle(const char** parameters, int pcnt, userrec* user) = 0;
79
80         virtual CmdResult HandleServer(const char** parameters, int pcnt, const std::string &servername)
81         {
82                 return CMD_INVALID;
83         }
84
85         void Disable(bool setting)
86         {
87                 disabled = setting;
88         }
89
90         bool IsDisabled()
91         {
92                 return disabled;
93         }
94
95         bool WorksBeforeReg()
96         {
97                 return works_before_reg;
98         }
99
100         virtual ~command_t() {}
101 };
102
103 typedef nspace::hash_map<std::string,command_t*> command_table;
104
105 #endif