added GPL header to all files and added INSTALL AUTHORS COPYING files.
[NeonServV5.git] / src / modcmd.h
1 /* modcmd.h - NeonServ v5.0
2  * Copyright (C) 2011  Philipp Kreil (pk910)
3  * 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License 
15  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
16  */
17 #ifndef _modcmd_h
18 #define _modcmd_h
19 #include "main.h"
20
21 #define CMDFLAG_REQUIRE_CHAN            0x0001
22 #define CMDFLAG_REQUIRE_AUTH            0x0002
23 #define CMDFLAG_REQUIRE_GOD             0x0004
24 #define CMDFLAG_CHECK_AUTH              0x0008
25 #define CMDFLAG_REGISTERED_CHAN         0x0010
26 #define CMDFLAG_OVERRIDE_GLOBAL_ACCESS  0x0020
27 #define CMDFLAG_OVERRIDE_CHANNEL_ACCESS 0x0040
28 #define CMDFLAG_CHAN_PARAM              0x0080
29 #define CMDFLAG_LOG                     0x0100
30 #define CMDFLAG_OPLOG                   0x0200
31
32 struct ClientSocket;
33 struct UserNode;
34 struct ChanNode;
35 struct Event;
36
37 #define CMD_BIND(NAME) void NAME(UNUSED_ARG(struct ClientSocket *client), UNUSED_ARG(struct UserNode *user), UNUSED_ARG(struct ChanNode *chan), UNUSED_ARG(char **argv), UNUSED_ARG(char argc), UNUSED_ARG(struct Event *event))
38 typedef void cmd_bind_t(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, char **argv, char argc, struct Event *event);
39 typedef void trigger_callback_t(struct ChanNode *chan, char *trigger);
40
41 struct cmd_function {
42     char *name;
43     int botid;
44     cmd_bind_t *func;
45     unsigned int flags;
46     int paramcount;
47     int global_access;
48     char *channel_access;
49     
50     struct cmd_function *next;
51 };
52
53 struct cmd_binding {
54     char *cmd;
55     int botid;
56     struct cmd_function *func;
57     unsigned int flags;
58     char *parameters;
59     int global_access;
60     char *channel_access;
61     
62     struct cmd_binding *next;
63 };
64
65 struct trigger_cache {
66     int botid;
67     char *trigger;
68     
69     struct trigger_cache *next;
70 };
71
72 void init_modcmd();
73 void free_modcmd();
74 struct ClientSocket* get_prefered_bot(int botid);
75 int register_command(int botid, char *name, cmd_bind_t *func, int paramcount, char *channel_access, int global_access, unsigned int flags);
76 int set_trigger_callback(int botid, trigger_callback_t *func);
77 int changeChannelTrigger(int botid, struct ChanNode *chan, char *new_trigger);
78 int bind_cmd_to_function(int botid, char *cmd, struct cmd_function *func);
79 int bind_cmd_to_command(int botid, char *cmd, char *func);
80 int unbind_cmd(int botid, char *cmd);
81 struct cmd_function *find_cmd_function(int botid, char *name);
82 struct ClientSocket *getTextBot();
83 void bind_set_parameters(int botid, char *cmd, char *parameters);
84 void bind_set_global_access(int botid, char *cmd, int gaccess);
85 void bind_set_channel_access(int botid, char *cmd, char *chanaccess);
86 struct cmd_binding *find_cmd_binding(int botid, char *cmd);
87
88 #endif