]> jfr.im git - irc/quakenet/newserv.git/blob - control/control.h
BUILD: add require-all build mode
[irc/quakenet/newserv.git] / control / control.h
1
2 #ifndef __CONTROL_H
3 #define __CONTROL_H
4
5 #include "control_db.h"
6 #include "../lib/flags.h"
7 #include "../parser/parser.h"
8 #include "../nick/nick.h"
9 #include "../channel/channel.h"
10
11 #define registercontrolcmd(a, b, c, d) registercontrolhelpcmd(a, b, c, d, NULL)
12
13 void controlreply(nick *, char *, ...);
14 void controlwall(flag_t, flag_t, char *, ...);
15 int controlpermitted(flag_t, nick *);
16
17 extern nick *mynick;
18
19 extern CommandTree *controlcmds;
20
21 struct specialsched {
22 sstring *modulename;
23 void *schedule;
24 };
25
26 typedef void (*CommandHelp)(nick *, Command *);
27 typedef struct cmdhelp {
28 char *helpstr;
29 CommandHelp helpcmd;
30 } cmdhelp;
31
32 void registercontrolhelpcmd(const char *name, int level, int maxparams, CommandHandler handler, char *help);
33 void registercontrolhelpfunccmd(const char *name, int level, int maxparams, CommandHandler handler, CommandHelp helpcmd);
34 int deregistercontrolcmd(const char *name, CommandHandler handler);
35 void controlmessage(nick *target, char *message, ... ) __attribute__ ((format (printf, 2, 3)));
36 void controlchanmsg(channel *cp, char *message, ...) __attribute__ ((format (printf, 2, 3)));
37 void controlnotice(nick *target, char *message, ...) __attribute__ ((format (printf, 2, 3)));
38 int controlshowcommands(void *sender, int cargc, char **cargv);
39 int controlrmmod(void *sender, int cargc, char **cargv);
40 void controlspecialrmmod(void *arg);
41 void controlspecialreloadmod(void *arg);
42 void controlhelp(nick *np, Command *cmd);
43 void controlnswall(int noticelevel, char *format, ...) __attribute__ ((format (printf, 2, 3)));
44 char *controlid(nick *);
45
46 /* NEVER USE THE FOLLOWING IN COMMANDS, you'll end up missing bits off and users'll end up being able to gline people */
47 #define __NO_ANYONE 0x000
48 #define __NO_AUTHED 0x001 /* must be authed with the network, don't know what use this is really */
49 #define __NO_OPERED 0x002 /* just means that they MUST be /oper'ed, for hello -- part of LEGACY */
50 #define __NO_ACCOUNT 0x004 /* for hello, must have a user account */
51 #define __NO_LEGACY 0x008 /* reserved for old newserv commands, their level is 10 */
52 #define __NO_STAFF 0x010 /* +s */
53 #define __NO_TRUST 0x020 /* +t */
54 #define __NO_OPER 0x040 /* +O */
55 #define __NO_SEC 0x080 /* +w */
56 #define __NO_DEVELOPER 0x100 /* +d */
57 #define __NO_RELAY 0x200 /* +Y */
58
59 /* These are dangerous, they don't include requiring /OPER or STAFF status, be careful */
60 #define NOD_ACCOUNT __NO_ACCOUNT | NO_AUTHED /* must contain authed else account won't be checked */
61 #define NOD_STAFF __NO_STAFF | NOD_ACCOUNT
62 #define NOD_TRUST __NO_TRUST | NOD_ACCOUNT
63 #define NOD_OPER __NO_OPER | NOD_ACCOUNT
64 #define NOD_SEC __NO_SEC | NOD_ACCOUNT
65 #define NOD_DEVELOPER __NO_DEVELOPER | NOD_ACCOUNT
66 #define NOD_RELAY __NO_RELAY | NOD_ACCOUNT
67
68 /* These ones are safe to use */
69 #define NO_ANYONE __NO_ANYONE /* don't have to be authed to Q, or us, or opered or anything */
70 #define NO_AUTHED __NO_AUTHED /* must be authed to Q */
71 #define NO_ACCOUNT NOD_ACCOUNT /* must have an account on the bot */
72 #define NO_OPERED __NO_OPERED /* must be /opered */
73 #define NO_STAFF NOD_STAFF /* must be authed to Q and have staff level on bot */
74 #define NO_OPER NO_OPERED | NOD_OPER /* must be authed to Q, /opered, and have oper level on bot */
75 #define NO_DEVELOPER NO_OPERED | NOD_DEVELOPER /* must be authed to Q, /opered, and have dev level on bot */
76 #define NO_TRUST_STAFF NO_STAFF | NOD_TRUST /* must be authed to Q, and have staff and trust level on bot */
77 #define NO_TRUST_OPER NO_OPER | NOD_TRUST /* must be authed to Q, /opered, and have trust and oper levels on bot */
78 #define NO_SEC_STAFF NO_STAFF | NOD_SEC /* must be authed to Q, and have staff and sec level on bot */
79 #define NO_SEC_OPER NO_OPER | NOD_SEC /* must be authed to Q, /opered, and have sec and oper levels on bot */
80 #define NO_RELAY NO_OPERED | NOD_RELAY /* must be authed to Q, /opered, and have the relay level on bot */
81
82 #define NO_ALL_FLAGS __NO_STAFF | __NO_TRUST | __NO_OPER | __NO_SEC | __NO_DEVELOPER | __NO_RELAY
83 #define NO_OPER_FLAGS __NO_STAFF
84 #define NO_DEV_FLAGS NO_ALL_FLAGS
85
86 #define NL_MANAGEMENT 0x0001 /* hello, password, userflags, noticeflags */
87 #define NL_TRUSTS 0x0002 /* trust stuff... */
88 #define NL_KICKKILLS 0x0004 /* KICK/KILL command */
89 #define NL_MISC 0x0008 /* misc commands (resync, etc) */
90 #define NL_GLINES 0x0010 /* GLINE commands */
91 #define NL_HITS 0x0020 /* Where a gline or kill is set automatically by the bot */
92 #define NL_CLONING 0x0040 /* Clone detection */
93 #define NL_CLEARCHAN 0x0080 /* When someone clearchans */
94 #define NL_FAKEUSERS 0x0100 /* Fakeuser addition */
95 #define NL_BROADCASTS 0x0200 /* Broadcast/mbroadcast/sbroadcast */
96 #define NL_OPERATIONS 0x0400 /* insmod/rmmod/etc */
97 #define NL_OPERING 0x0800 /* when someone opers */
98 #define NL_NOTICES 0x1000 /* turn off to receive privmsgs instead of notices */
99 #define NL_ALL_COMMANDS 0x2000 /* every single command sent */
100 #define NL_GLINES_AUTO 0x4000 /* automated gline messages */
101 #define NL_CLEANUP 0x8000 /* automated cleanup notices */
102
103 extern int noperserv_ext;
104
105 extern const flag no_userflags[];
106 extern const flag no_noticeflags[];
107 extern const flag no_commandflags[];
108
109 #define NO_NICKS_PER_WHOIS_LINE 3
110
111 #define NOGetAuthedUser(user) (no_autheduser *)(user->auth ? user->auth->exts[noperserv_ext] : NULL)
112 #define NOGetAuthLevel(user) user->authlevel
113 #define NOGetNoticeLevel(user) user->noticelevel
114 #define NOMax(a, b) (a>b?a:b)
115 #define NOMin(a, b) (a<b?b:a)
116
117 #endif