tried to reorder the program structure and build process
[NeonServV5.git] / src / modcmd.h
1 #ifndef _modcmd_h
2 #define _modcmd_h
3 #include "main.h"
4
5 #define CMDFLAG_REQUIRE_CHAN            0x0001
6 #define CMDFLAG_REQUIRE_AUTH            0x0002
7 #define CMDFLAG_REQUIRE_GOD             0x0004
8 #define CMDFLAG_CHECK_AUTH              0x0008
9 #define CMDFLAG_REGISTERED_CHAN         0x0010
10 #define CMDFLAG_OVERRIDE_GLOBAL_ACCESS  0x0020
11 #define CMDFLAG_OVERRIDE_CHANNEL_ACCESS 0x0040
12 #define CMDFLAG_CHAN_PARAM              0x0080
13 #define CMDFLAG_LOG                     0x0100
14 #define CMDFLAG_OPLOG                   0x0200
15
16 struct ClientSocket;
17 struct UserNode;
18 struct ChanNode;
19 struct Event;
20
21 #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))
22 typedef void cmd_bind_t(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, char **argv, char argc, struct Event *event);
23 typedef void trigger_callback_t(struct ChanNode *chan, char *trigger);
24
25 struct cmd_function {
26     char *name;
27     int botid;
28     cmd_bind_t *func;
29     unsigned int flags;
30     int paramcount;
31     int global_access;
32     char *channel_access;
33     
34     struct cmd_function *next;
35 };
36
37 struct cmd_binding {
38     char *cmd;
39     int botid;
40     struct cmd_function *func;
41     unsigned int flags;
42     char *parameters;
43     int global_access;
44     char *channel_access;
45     
46     struct cmd_binding *next;
47 };
48
49 struct trigger_cache {
50     int botid;
51     char *trigger;
52     
53     struct trigger_cache *next;
54 };
55
56 void init_modcmd();
57 void free_modcmd();
58 struct ClientSocket* get_prefered_bot(int botid);
59 int register_command(int botid, char *name, cmd_bind_t *func, int paramcount, char *channel_access, int global_access, unsigned int flags);
60 int set_trigger_callback(int botid, trigger_callback_t *func);
61 int changeChannelTrigger(int botid, struct ChanNode *chan, char *new_trigger);
62 int bind_cmd_to_function(int botid, char *cmd, struct cmd_function *func);
63 int bind_cmd_to_command(int botid, char *cmd, char *func);
64 int unbind_cmd(int botid, char *cmd);
65 struct cmd_function *find_cmd_function(int botid, char *name);
66 struct ClientSocket *getTextBot();
67 void bind_set_parameters(int botid, char *cmd, char *parameters);
68 void bind_set_global_access(int botid, char *cmd, int gaccess);
69 void bind_set_channel_access(int botid, char *cmd, char *chanaccess);
70 struct cmd_binding *find_cmd_binding(int botid, char *cmd);
71
72 #endif