ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/vendor/ircservices-5.1.24/modes.h
Revision: 3389
Committed: Fri Apr 25 14:12:15 2014 UTC (9 years, 11 months ago) by michael
Content type: text/x-chdr
File size: 5511 byte(s)
Log Message:
- Imported ircservices-5.1.24

File Contents

# Content
1 /* Mode flag definitions.
2 *
3 * IRC Services is copyright (c) 1996-2009 Andrew Church.
4 * E-mail: <achurch@achurch.org>
5 * Parts written by Andrew Kempe and others.
6 * This program is free but copyrighted software; see the file GPL.txt for
7 * details.
8 */
9
10 #ifndef MODES_H
11 #define MODES_H
12
13 /*************************************************************************/
14
15 /* Special flag constants. */
16
17 #define MODE_INVALID 0x80000000 /* Used as error flag, or as "this
18 * isn't an on/off mode" flag */
19 #define MODE_ALL (~MODE_INVALID) /* All possible modes */
20
21 /*************************************************************************/
22
23 /* Data for mode characters. If a mode character is given the MODE_INVALID
24 * flag, it indicates that that mode is a valid mode but is assigned no
25 * flag. (For example, channel mode +b uses this.) */
26
27 typedef struct {
28 int32 flag;
29 uint8 plus_params; /* Number of parameters when adding */
30 uint8 minus_params; /* Number of characters when deleting */
31 char prefix; /* Prefix for channel user mode (e.g. +o -> '@') */
32 uint32 info; /* What kind of mode this is (MI_* below) */
33 } ModeData;
34
35 #define MI_MULTIPLE 0x01 /* Can be set multiple times (+b etc) */
36 #define MI_REGISTERED 0x02 /* [UC] Applied to all registered nicks/chans */
37 #define MI_OPERS_ONLY 0x04 /* [ C] Only opers may join */
38 #define MI_REGNICKS_ONLY 0x08 /* [ C] Only registered/ID'd nicks may join */
39
40 /* These bits are available for private use by protocol modules: (see
41 * Unreal module for an example of usage) */
42 #define MI_LOCAL_MASK 0xFF000000
43
44 /*************************************************************************/
45
46 /*
47 * Arrays of mode characters--one entry for each possible character. These
48 * are declared extern to allow modules to add entries; read access should
49 * be done through the functions below.
50 *
51 * The following modes are predefined:
52 * User: o, i, w
53 * Channel: i, k, l, m, n, p, s, t, b
54 * Channel user (modes applied to individual users on a channel): o, v
55 */
56 extern ModeData usermodes[256], chanmodes[256], chanusermodes[256];
57
58 /* The following are initialized by mode_setup(): */
59 extern int32 usermode_reg; /* Usermodes applied to registered nicks */
60 extern int32 chanmode_reg; /* Chanmodes applied to registered chans */
61 extern int32 chanmode_regonly; /* Chanmodes indicating regnick-only channels*/
62 extern int32 chanmode_opersonly;/* Chanmodes indicating oper-only channels */
63 extern char chanmode_multiple[];/* Chanmodes that can be set multiple times */
64
65 /*************************************************************************/
66
67 /* Initialize flag tables and flag sets from mode tables. Must be called
68 * before any other mode_* function. */
69 extern void mode_setup(void);
70
71 /* Return the flag corresponding to the given mode character, or 0 if no
72 * such mode exists. Return MODE_INVALID if the mode exists but has no
73 * assigned flag. See below for the meaning of "which". */
74 extern int32 mode_char_to_flag(char c, int which);
75
76 /* Return the number of parameters the given mode takes, as
77 * (plus_params<<8) | (minus_params). Return -1 if there is no such mode. */
78 extern int mode_char_to_params(char c, int which);
79
80 /* Return the mode character corresponding to the given flag, or 0 if no
81 * such mode exists. */
82 extern char mode_flag_to_char(int32 f, int which);
83
84 /* Return the flag set corresponding to the given string of mode
85 * characters, or (CMODE_INVALID | modechar) if an invalid mode character
86 * is found. */
87 extern int32 mode_string_to_flags(const char *s, int which);
88
89 /* Return the string of mode characters corresponding to the given flag
90 * set. If the flag set has invalid flags in it, they are ignored.
91 * The returned string is stored in a static buffer which will be
92 * overwritten on the next call. */
93 extern char *mode_flags_to_string(int32 flags, int which);
94
95 /* Return the flag corresponding to the given channel user mode prefix, or
96 * 0 if no such mode exists. */
97 extern int32 cumode_prefix_to_flag(char c);
98
99 /*************************************************************************/
100
101 /* Values for "which" parameter to mode_* functions: */
102
103 #define MODE_USER 0 /* UMODE_* (user modes) */
104 #define MODE_CHANNEL 1 /* CMODE_* (binary channel modes) */
105 #define MODE_CHANUSER 2 /* CUMODE_* (channel modes for users) */
106
107 #define MODE_NOERROR 0x8000 /* Ignore bad chars in string_to_flags() */
108
109 /*************************************************************************/
110
111 /* User modes: */
112 #define UMODE_o 0x00000001
113 #define UMODE_i 0x00000002
114 #define UMODE_w 0x00000004
115
116 /* Channel modes: */
117 #define CMODE_i 0x00000001
118 #define CMODE_m 0x00000002
119 #define CMODE_n 0x00000004
120 #define CMODE_p 0x00000008
121 #define CMODE_s 0x00000010
122 #define CMODE_t 0x00000020
123 #define CMODE_k 0x00000040
124 #define CMODE_l 0x00000080
125
126 /* Modes for users on channels: */
127 #define CUMODE_o 0x00000001
128 #define CUMODE_v 0x00000002
129
130 /*************************************************************************/
131 /*************************************************************************/
132
133 #endif /* MODES_H */
134
135 /*
136 * Local variables:
137 * c-file-style: "stroustrup"
138 * c-file-offsets: ((case-label . *) (statement-case-intro . *))
139 * indent-tabs-mode: nil
140 * End:
141 *
142 * vim: expandtab shiftwidth=4:
143 */