Changeset 803 for trunk/ithildin/modules/ircd/chanmode.h
- Timestamp:
- 05/31/07 15:15:23 (5 years ago)
- File:
-
- 1 copied
-
trunk/ithildin/modules/ircd/chanmode.h (copied) (copied from trunk/ithildin/modules/ircd/channel.h) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ithildin/modules/ircd/chanmode.h
r801 r803 1 1 /* 2 * chan nel.h: channel (mode)structures and prototypes2 * chanmode.h: channel mode structures and prototypes 3 3 * 4 * Copyright 2002 the Ithildin Project.4 * Copyright 2002-2007 the Ithildin Project. 5 5 * See the COPYING file for more information on licensing and use. 6 6 * … … 8 8 */ 9 9 10 #ifndef IRCD_CHAN NEL_H11 #define IRCD_CHAN NEL_H10 #ifndef IRCD_CHANMODE_H 11 #define IRCD_CHANMODE_H 12 12 13 13 /* … … 76 76 int *, void **); 77 77 78 #define CHANMODE_FL_A 0x0179 #define CHANMODE_FL_B 0x0280 #define CHANMODE_FL_C 0x0481 #define CHANMODE_FL_D 0x0882 #define CHANMODE_FL_E 0x1078 #define CHANMODE_FL_A 0x01 79 #define CHANMODE_FL_B 0x02 80 #define CHANMODE_FL_C 0x04 81 #define CHANMODE_FL_D 0x08 82 #define CHANMODE_FL_E 0x10 83 83 #define CHANMODE_FL_PREFIX 0x20 84 84 85 #define CHANMODE_SET 186 #define CHANMODE_UNSET 087 #define CHANMODE_CLEAR -185 #define CHANMODE_SET 1 86 #define CHANMODE_UNSET 0 87 #define CHANMODE_CLEAR -1 88 88 89 89 #define CHANMODE_OK 0 90 #define CHANMODE_FAIL -1 91 #define CHANMODE_NOP -2 92 #define CHANMODE_NONEX -3 93 #define CHANMODE_NOARG -4 94 90 #define CHANMODE_FAIL -1 91 #define CHANMODE_NOP -2 92 #define CHANMODE_NONEX -3 93 #define CHANMODE_NOARG -4 94 95 void chanmode_init(bool); 96 void chanmode_deinit(bool); 95 97 uint64_t chanmode_request(unsigned char, unsigned char *, int, 96 98 chanmode_func, chanmode_query_func, size_t, void *); … … 183 185 }; 184 186 185 LIST_HEAD(chanusers, chanlink); 186 LIST_HEAD(userchans, chanlink); 187 188 /* this structure is used to glue users and channels together. one structure 189 * is allocated per user/chan relationship, and is saved in a linked list on 190 * the user's side, and on the channel's side. */ 191 struct chanlink { 192 client_t *cli; 193 channel_t *chan; 194 short flags; 195 short bans; /* for users only, stores how many bans they have against 196 them */ 197 198 LIST_ENTRY(chanlink) lpcli; 199 LIST_ENTRY(chanlink) lpchan; 187 /* some functions for generic channel mode handling */ 188 CHANMODE_FUNC(chanmode_flag); 189 CHANMODE_QUERY_FUNC(chanmode_flag_query); 190 CHANMODE_FUNC(chanmode_uflag); 191 CHANMODE_QUERY_FUNC(chanmode_uflag_query); 192 193 /* this structure is used to hold bans on a channel. */ 194 #define MAX_BANS_PER_CHANNEL 100 195 #define BAN_MASK_LEN NICKLEN + USERLEN + HOSTLEN + 3 196 LIST_HEAD(channel_ban_list, channel_ban); 197 struct channel_ban { 198 char nick[NICKLEN + 1]; /* the three components of ban, split up for easier 199 processing. */ 200 char user[USERLEN + 1]; 201 char host[HOSTLEN + 1]; 202 char who[BAN_MASK_LEN + 1]; 203 time_t when; /* when the ban was set */ 204 #define CHANNEL_BAN_BAN 0x01 205 unsigned char type; /* reserved for various uses */ 206 207 LIST_ENTRY(channel_ban) lp; 200 208 }; 201 209 202 char **channel_mdext_iter(char **); 203 204 struct channel { 205 char name[CHANLEN + 1]; /* our channel's name. */ 206 time_t created; /* the timestamp as well as creation time */ 207 208 unsigned int onchannel; /* number of people on channel */ 209 int flags; 210 struct chanusers users; /* list of users in channel */ 211 uint64_t modes; /* the flag-modes for the channel. */ 212 char *mdext; /* mdext data */ 213 214 LIST_ENTRY(channel) lp; 215 }; 216 217 /* create a channel. give it a name, initially the channel will be empty, 218 * so you use...*/ 219 channel_t *create_channel(char *); 220 221 /* add_to_channel. adds the given client to the given channel, fixes up all 222 * structures properly. the third argument is set if the caller wishes the 223 * channel_add event to be hooked. this is *almost* always the case. */ 224 void add_to_channel(client_t *, channel_t *, bool); 225 226 /* del_from_channel. removes the user from the given channel, if the 227 * channel becomes empty, it is destroyed with... the third argument is the 228 * same as above. */ 229 void del_from_channel(client_t *, channel_t *, bool); 230 231 /* destroy_channel. destroys a channel and returns all the good stuff to 232 * memory */ 233 void destroy_channel(channel_t *); 234 235 /* find a channel by name */ 236 #define find_channel(name) hash_find(ircd.hashes.channel, name) 237 238 /* finds a channel/user's chanlink entity and returns it (or NULL if it doesn't 239 * exist). Also, onchannel() is a wraparound checker to give a boolean return 240 * based on this info. */ 241 struct chanlink *find_chan_link(client_t *, channel_t *); 242 #define onchannel(cli, chan) \ 243 (find_chan_link(cli, chan) != NULL ? 1 : 0) 244 245 #define check_channame(name) \ 246 (name && (*name == '#') && \ 247 istr_okay(ircd.maps.channel, name)) 248 249 /* this structure is used by channel_check_access to pass to its various hook 250 * functions when checking if a channel can have an action performed on it (or 251 * something.. */ 252 struct channel_check_args { 253 channel_t *chan; /* the channel */ 254 client_t *cli; /* the client */ 255 struct chanlink *clp; /* if they're in the channel, this is the link. */ 256 char *extra; /* extra data */ 257 }; 258 259 /* this function determines whether a client (cli) can perform some action 260 * related to a channel (chan). it can be used in various manners and with 261 * various events. it calls the hooks for the specified event, which should 262 * return one of the five CHANNEL_ statuses above, or an error numeric to send 263 * to the user (which should be of the format '%s :...' unless your function is 264 * going to have some special handling). */ 265 266 /* these three are synonyms for the definitions in event.h */ 267 #define CHANNEL_CHECK_OVERRIDE HOOK_COND_SPASS 268 #define CHANNEL_CHECK_OK HOOK_COND_PASS 269 #define CHANNEL_CHECK_NO HOOK_COND_FAIL 270 int channel_check_access(client_t *, channel_t *, char *, event_t *); 271 272 /* this lets you check to see if a user can enter a channel. */ 273 #define can_can_join_channel(cli, chan, arg) \ 274 channel_check_access(cli, chan, arg, ircd.events.can_join_channel) 275 /* this lets you check to see if a user can see a channel's details. */ 276 #define can_can_see_channel(cli, chan) \ 277 channel_check_access(cli, chan, NULL, ircd.events.can_see_channel) 278 279 /* this is like the above two, except that you also pass the message the user 280 * is attempting to send to the channel. */ 281 #define can_can_send_channel(cli, chan, msg) \ 282 channel_check_access(cli, chan, msg, ircd.events.can_send_channel) 283 284 /* this is like the above three, except for nick changes in the channel. 285 * hopefully this is it. :) */ 286 #define can_can_nick_channel(cli, chan, nick) \ 287 channel_check_access(cli, chan, nick, ircd.events.can_nick_channel); 288 289 /* chancmp, like nickcmp in client.c */ 290 int chancmp(char *, char *, size_t); 210 /* some macros... the link variety are a lot faster if you've already taken 211 * the time to see if they're in the channel (and have saved the chanlink 212 * entry). */ 213 #define CHANOP(cli, chan) chanmode_isprefix(chan, cli, '@') 214 #define CLINKOP(clp) chanlink_ismode(clp, ircd.cmodes.mode_op) 215 #define CHANVOICE(cli, chan) chanmode_isprefix(chan, cli, '+') 216 #define CLINKVOICE(clp) chanlink_ismode(clp, ircd.cmodes.mode_voice) 291 217 292 218 #endif
Note: See TracChangeset
for help on using the changeset viewer.
