6d2d5d959f3733cb89523aeb70f3151d23f96597
[NeonServV5.git] / ModeNode.h
1 #ifndef _ModeNode_h
2 #define _ModeNode_h
3 #include "main.h"
4
5 struct ChanNode;
6
7 //Types: http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt
8 #define CHANNEL_MODE_TYPE_A        0x01 /* ... special (addresses or users) ... */
9 #define CHANNEL_MODE_TYPE_B        0x02 /* These modes always take a parameter. */
10 #define CHANNEL_MODE_TYPE_C        0x03 /* These modes take a parameter only when set. */
11 #define CHANNEL_MODE_TYPE_D        0x04 /* These modes never take a parameter. */
12 #define CHANNEL_MODE_TYPE          0x07 /* bit mask to get the type */
13
14 #define CHANNEL_MODE_VALUE_STRING  0x10
15 #define CHANNEL_MODE_VALUE_INTEGER 0x20
16 #define CHANNEL_MODE_VALUE         0x30 /* bit mask to get the value */
17
18 #define CHANNEL_MODE_KEY           0x40 /* mode is a key - automatically add the current key as parameter on unset */
19
20 #define CHANNEL_MODE_VALUE_INDEX_SHIFT 8
21 #define CHANNEL_MODE_VALUE_INDEX_MASK  (0xff << CHANNEL_MODE_VALUE_INDEX_SHIFT) /* this "bitrange" is reserved for storing the array indexes of the mode values */
22
23 struct ModeNode {
24     struct ChanNode *chan;
25     unsigned int modes;
26     unsigned int allmodes;
27     char **mode_str_args;
28     int *mode_int_args;
29 };
30
31 extern unsigned int valid_modes[];
32
33 void init_ModeNode();
34 struct ModeNode *createModeNode(struct ChanNode *chan);
35 void freeModeNode(struct ModeNode *modes);
36 int isModeSet(struct ModeNode* modes, char modeChar);
37 int isModeAffected(struct ModeNode* modes, char modeChar);
38 void* getModeValue(struct ModeNode* modes, char modeChar);
39 unsigned int getModeType(struct ModeNode* modes, char modeChar);
40 void parseModes(struct ModeNode* modes, char *modeStr, char **argv, int argc);
41 void parseModeString(struct ModeNode* modes, char *modeStr);
42 int parseMode(struct ModeNode* modes, int add, char mode, char *param);
43 void getModeString(struct ModeNode* modes, char *modesStr);
44 void getFullModeString(struct ModeNode* modes, char *modesStr);
45
46 #endif