1 /* chanserv.h - Channel service bot
2 * Copyright 2000-2004 srvx Development Team
4 * This file is part of srvx.
6 * srvx is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with srvx; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
30 UL_PRESENT = UL_MASTER,
60 #define CHANNEL_NODELETE 0x00000001 /* (1 << 0) */
61 #define CHANNEL_SUSPENDED 0x00000002 /* (1 << 1) */
62 #define CHANNEL_INFO_LINES 0x00000004 /* (1 << 2) - DEPRECATED */
63 #define CHANNEL_VOICE_ALL 0x00000008 /* (1 << 3) - DEPRECATED */
64 /* No longer used. */ /* (1 << 4) */
65 #define CHANNEL_DYNAMIC_LIMIT 0x00000020 /* (1 << 5) */
66 #define CHANNEL_TOPIC_SNARF 0x00000040 /* (1 << 6) - DEPRECATED */
67 #define CHANNEL_PEON_INVITE 0x00000080 /* (1 << 7) - DEPRECATED */
68 #define CHANNEL_OFFCHANNEL 0x00000100 /* (1 << 8) */
69 #define CHANNEL_UNREVIEWED 0x00000200 /* (1 << 9) */
70 #define CHANNEL_ADVTOPIC 0x00000400 /* (1 << 10) */
71 /* Flags with values over 0x20000000 or (1 << 29) will not work
72 * because chanData.flags is a 30-bit field.
75 #define IsProtected(x) ((x)->flags & CHANNEL_NODELETE)
76 #define IsSuspended(x) ((x)->flags & CHANNEL_SUSPENDED)
77 #define IsOffChannel(x) (((x)->flags & CHANNEL_OFFCHANNEL) && (off_channel > 1))
79 #define MAXADVTOPICENTRIES 9
83 struct chanNode *channel;
84 struct mod_chanmode modes;
86 unsigned long registered;
87 unsigned long visited;
88 unsigned long limitAdjusted;
89 unsigned long ownerTransfer;
99 unsigned int vote_start;
102 unsigned int flags : 30;
103 unsigned int may_opchan : 1;
105 unsigned int max_time;
106 unsigned int last_refresh;
107 unsigned short banCount;
108 unsigned short userCount;
109 unsigned short lvlOpts[NUM_LEVEL_OPTIONS];
110 unsigned char chOpts[NUM_CHAR_OPTIONS];
114 struct userData *users;
115 struct banData *bans;
117 struct suspended *suspended;
118 struct giveownership *giveownership;
119 struct chanData *prev;
120 struct chanData *next;
123 #define USER_AUTO_OP 0x00000001
124 #define USER_SUSPENDED 0x00000002
125 #define USER_AUTO_INVITE 0x00000004
126 #define USER_FLAGS_SIZE 7
128 #define IsUserAutoOp(USER) (!((USER)->flags & USER_AUTO_OP))
129 #define IsUserSuspended(USER) ((USER)->flags & USER_SUSPENDED)
130 #define IsUserAutoInvite(USER) ((USER)->flags & USER_AUTO_INVITE)
134 struct handle_info *handle;
135 struct chanData *channel;
139 unsigned short access;
140 unsigned int present : 1;
141 unsigned int flags : USER_FLAGS_SIZE;
143 unsigned short voted;
144 unsigned int votefor;
146 /* linked list of userDatas for a chanData */
147 struct userData *prev;
148 struct userData *next;
149 /* linked list of userDatas for a handle_info */
150 struct userData *u_prev;
151 struct userData *u_next;
156 char mask[NICKLEN + USERLEN + HOSTLEN + 3];
157 char owner[NICKLEN+1];
158 struct chanData *channel;
161 unsigned long triggered;
162 unsigned long expires;
166 struct banData *prev;
167 struct banData *next;
172 struct chanData *cData;
175 unsigned long issued;
176 unsigned long expires;
177 unsigned long revoked;
178 struct suspended *previous;
184 unsigned int option_id;
196 unsigned short target_access;
201 struct giveownership *previous;
204 struct do_not_register
206 char chan_name[CHANNELLEN+1];
207 char setter[NICKSERV_HANDLE_LEN+1];
209 unsigned long expires;
213 #define GetChannelUser(channel, handle) _GetChannelUser(channel, handle, 1, 0)
214 struct userData *_GetChannelUser(struct chanData *channel, struct handle_info *handle, int override, int allow_suspended);
215 struct banData *add_channel_ban(struct chanData *channel, const char *mask, char *owner, unsigned long set, unsigned long triggered, unsigned long expires, char *reason);
216 void init_chanserv(const char *nick);
217 void del_channel_user(struct userData *user, int do_gc);
218 struct channelList *chanserv_support_channels(void);
219 unsigned short user_level_from_name(const char *name, unsigned short clamp_level);
220 struct do_not_register *chanserv_is_dnr(const char *chan_name, struct handle_info *handle);
221 int check_user_level(struct chanNode *channel, struct userNode *user, enum levelOption opt, int allow_override, int exempt_owner);
222 struct mod_chanmode *find_matching_bans(struct banList *bans, struct userNode *actee, const char *mask);
223 void handle_new_channel_created(char *chan, struct userNode *user);