Convert time-related variables to consistently use "unsigned long".
[srvx.git] / src / chanserv.h
1 /* chanserv.h - Channel service bot
2  * Copyright 2000-2004 srvx Development Team
3  *
4  * This file is part of srvx.
5  *
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.
10  *
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.
15  *
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.
19  */
20
21 #ifndef _chanserv_h
22 #define _chanserv_h
23
24 #include "nickserv.h"
25
26 enum UL_ALIASES {
27     UL_PEON = 100,
28     UL_OP = 200,
29     UL_MASTER = 300,
30     UL_PRESENT = UL_MASTER,
31     UL_COOWNER = 400,
32     UL_OWNER = 500,
33     UL_HELPER = 600,
34 };
35
36 enum levelOption {
37     lvlGiveVoice,
38     lvlGiveOps,
39     lvlEnfOps,
40     lvlEnfModes,
41     lvlEnfTopic,
42     lvlPubCmd,
43     lvlSetters,
44     lvlCTCPUsers,
45     lvlUserInfo,
46     lvlInviteMe,
47     lvlTopicSnarf,
48     NUM_LEVEL_OPTIONS
49 };
50
51 enum charOption {
52     chProtect,
53     chToys,
54     chTopicRefresh,
55     chCTCPReaction,
56     NUM_CHAR_OPTIONS
57 };
58
59 #define CHANNEL_NODELETE    0x00000001 /* (1 << 0) */
60 #define CHANNEL_SUSPENDED   0x00000002 /* (1 << 1) */
61 #define CHANNEL_INFO_LINES  0x00000004 /* (1 << 2) - DEPRECATED */
62 #define CHANNEL_VOICE_ALL   0x00000008 /* (1 << 3) - DEPRECATED */
63 /* No longer used. */                      /* (1 << 4) */
64 #define CHANNEL_DYNAMIC_LIMIT   0x00000020 /* (1 << 5) */
65 #define CHANNEL_TOPIC_SNARF     0x00000040 /* (1 << 6) - DEPRECATED */
66 #define CHANNEL_PEON_INVITE     0x00000080 /* (1 << 7) - DEPRECATED */
67 #define CHANNEL_OFFCHANNEL      0x00000100 /* (1 << 8) */
68 #define CHANNEL_UNREVIEWED      0x00000200 /* (1 << 9) */
69 /* Flags with values over 0x20000000 or (1 << 29) will not work
70  * because chanData.flags is a 30-bit field.
71  */
72
73 #define IsProtected(x)  ((x)->flags & CHANNEL_NODELETE)
74 #define IsSuspended(x)  ((x)->flags & CHANNEL_SUSPENDED)
75 #define IsOffChannel(x) (((x)->flags & CHANNEL_OFFCHANNEL) && (off_channel > 1))
76
77 struct chanData
78 {
79     struct chanNode     *channel;
80     struct mod_chanmode modes;
81
82     unsigned long       registered;
83     unsigned long       visited;
84     unsigned long       limitAdjusted;
85     unsigned long       ownerTransfer;
86
87     char    *topic;
88     char    *greeting;
89     char    *user_greeting;
90     char    *registrar;
91     char    *topic_mask;
92
93     unsigned int        flags : 30;
94     unsigned int        may_opchan : 1;
95     unsigned int        max;
96     unsigned int        last_refresh;
97     unsigned short      banCount;
98     unsigned short      userCount;
99     unsigned short      lvlOpts[NUM_LEVEL_OPTIONS];
100     unsigned char       chOpts[NUM_CHAR_OPTIONS];
101
102     struct userData     *users;
103     struct banData      *bans;
104     struct dict         *notes;
105     struct suspended    *suspended;
106     struct chanData     *prev;
107     struct chanData     *next;
108 };
109
110 #define USER_AUTO_OP            0x00000001
111 #define USER_SUSPENDED          0x00000002
112 #define USER_AUTO_INVITE        0x00000004
113 #define USER_FLAGS_SIZE         7
114
115 #define IsUserAutoOp(USER)      (!((USER)->flags & USER_AUTO_OP))
116 #define IsUserSuspended(USER)   ((USER)->flags & USER_SUSPENDED)
117 #define IsUserAutoInvite(USER)  ((USER)->flags & USER_AUTO_INVITE)
118
119 struct userData
120 {
121     struct handle_info  *handle;
122     struct chanData     *channel;
123
124     char                *info;
125     unsigned long       seen;
126     unsigned short      access;
127     unsigned int        present : 1;
128     unsigned int        flags : USER_FLAGS_SIZE;
129
130     /* linked list of userDatas for a chanData */
131     struct userData     *prev;
132     struct userData     *next;
133     /* linked list of userDatas for a handle_info */
134     struct userData     *u_prev;
135     struct userData     *u_next;
136 };
137
138 struct banData
139 {
140     char            mask[NICKLEN + USERLEN + HOSTLEN + 3];
141     char            owner[NICKLEN+1];
142     struct chanData *channel;
143
144     unsigned long   set;
145     unsigned long   triggered;
146     unsigned long   expires;
147
148     char            *reason;
149
150     struct banData  *prev;
151     struct banData  *next;
152 };
153
154 struct suspended
155 {
156     struct chanData     *cData;
157     char                *suspender;
158     char                *reason;
159     unsigned long       issued;
160     unsigned long       expires;
161     unsigned long       revoked;
162     struct suspended    *previous;
163 };
164
165 struct do_not_register
166 {
167     char   chan_name[CHANNELLEN+1];
168     char   setter[NICKSERV_HANDLE_LEN+1];
169     unsigned long set;
170     unsigned long expires;
171     char   reason[1];
172 };
173
174 void init_chanserv(const char *nick);
175 void del_channel_user(struct userData *user, int do_gc);
176 struct channelList *chanserv_support_channels(void);
177 unsigned short user_level_from_name(const char *name, unsigned short clamp_level);
178 struct do_not_register *chanserv_is_dnr(const char *chan_name, struct handle_info *handle);
179 int check_user_level(struct chanNode *channel, struct userNode *user, enum levelOption opt, int allow_override, int exempt_owner);
180
181 #endif