|
|
@@ -206,28 +206,38 @@ bool u_match_mask(maskrec *rec, char *mask)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+static int count_mask(maskrec *rec)
|
|
|
+{
|
|
|
+ int ret = 0;
|
|
|
+
|
|
|
+ for (; rec; rec = rec->next)
|
|
|
+ ret++;
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
int u_delmask(char type, struct chanset_t *c, char *who, int doit)
|
|
|
{
|
|
|
- int j, i = 0, *n_mask = NULL;
|
|
|
+ int j, i = 0, n_mask = 0;
|
|
|
char temp[256] = "";
|
|
|
maskrec **u = NULL, *t;
|
|
|
|
|
|
if (type == 'b') {
|
|
|
u = c ? &c->bans : &global_bans;
|
|
|
- n_mask = &n_bans;
|
|
|
+ n_mask = count_mask(global_bans);
|
|
|
} else if (type == 'e') {
|
|
|
u = c ? &c->exempts : &global_exempts;
|
|
|
- n_mask = &n_exempts;
|
|
|
+ n_mask = count_mask(global_exempts);
|
|
|
} else if (type == 'I') {
|
|
|
u = c ? &c->invites : &global_invites;
|
|
|
- n_mask = &n_invites;
|
|
|
+ n_mask = count_mask(global_invites);
|
|
|
}
|
|
|
|
|
|
if (!strchr(who, '!') && str_isdigit(who)) {
|
|
|
j = atoi(who);
|
|
|
j--; /* our list starts at 0 */
|
|
|
if (c)
|
|
|
- j -= *n_mask; /* subtract out the globals as the number given is globals+j */
|
|
|
+ j -= n_mask; /* subtract out the globals as the number given is globals+j */
|
|
|
for (; (*u) && j; u = &((*u)->next), j--);
|
|
|
if (*u) {
|
|
|
strlcpy(temp, (*u)->mask, sizeof temp);
|
|
|
@@ -268,8 +278,6 @@ int u_delmask(char type, struct chanset_t *c, char *who, int doit)
|
|
|
t = *u;
|
|
|
*u = (*u)->next;
|
|
|
free(t);
|
|
|
- if (!c)
|
|
|
- (*n_mask)--;
|
|
|
}
|
|
|
return i;
|
|
|
}
|
|
|
@@ -280,18 +288,13 @@ bool u_addmask(char type, struct chanset_t *chan, char *who, char *from, char *n
|
|
|
{
|
|
|
char host[1024] = "", s[1024] = "";
|
|
|
maskrec *p = NULL, *l = NULL, **u = NULL;
|
|
|
- int *n_mask = NULL;
|
|
|
|
|
|
- if (type == 'b') {
|
|
|
+ if (type == 'b')
|
|
|
u = chan ? &chan->bans : &global_bans;
|
|
|
- n_mask = &n_bans;
|
|
|
- } else if (type == 'e') {
|
|
|
+ else if (type == 'e')
|
|
|
u = chan ? &chan->exempts : &global_exempts;
|
|
|
- n_mask = &n_exempts;
|
|
|
- } else if (type == 'I') {
|
|
|
+ else if (type == 'I')
|
|
|
u = chan ? &chan->invites : &global_invites;
|
|
|
- n_mask = &n_invites;
|
|
|
- }
|
|
|
|
|
|
strcpy(host, who);
|
|
|
/* Choke check: fix broken bans (must have '!' and '@') */
|
|
|
@@ -344,8 +347,6 @@ bool u_addmask(char type, struct chanset_t *chan, char *who, char *from, char *n
|
|
|
free( p->user );
|
|
|
free( p->desc );
|
|
|
}
|
|
|
- if (!chan)
|
|
|
- (*n_mask)++;
|
|
|
|
|
|
p->expire = expire_time;
|
|
|
p->added = now;
|