]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/ctables.h
failover connections are now added, thanks for the idea Lauren (happy now? lol) :)
[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         /** True if the command can be issued before registering
59          */
60         bool works_before_reg;
61         /** Syntax string for the command, displayed if non-empty string.
62          * This takes place of the text in the 'not enough parameters' numeric.
63          */
64         std::string syntax;
65
66         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)
67         {
68                 use_count = total_bytes = 0;
69                 source = "<core>";
70                 syntax = "";
71         }
72
73         virtual void Handle(const char** parameters, int pcnt, userrec* user) = 0;
74
75         void Disable(bool setting)
76         {
77                 disabled = setting;
78         }
79
80         bool IsDisabled()
81         {
82                 return disabled;
83         }
84
85         bool WorksBeforeReg()
86         {
87                 return works_before_reg;
88         }
89
90         virtual ~command_t() {}
91 };
92
93 typedef nspace::hash_map<std::string,command_t*> command_table;
94
95 #endif