Explorar el Código

* Moved u_del* and u_add* to u_delmask and u_addmask

svn: 908
Bryan Drewery hace 22 años
padre
commit
2ac78e2a25

+ 1 - 0
doc/UPDATES

@@ -3,6 +3,7 @@ This is a summary of ChangeLog basically.
 1.1.6
 1.1.6
 
 
 1.Fixed a cosmetic error in cmd_downbots.
 1.Fixed a cosmetic error in cmd_downbots.
+2.Cleaned up and removed more un-needed code.
 
 
 1.1.5
 1.1.5
 
 

+ 3 - 3
src/mod/channels.mod/channels.c

@@ -608,13 +608,13 @@ void remove_channel(struct chanset_t *chan)
    noshare = 1;
    noshare = 1;
    /* Remove channel-bans */
    /* Remove channel-bans */
    while (chan->bans)
    while (chan->bans)
-     u_delban(chan, chan->bans->mask, 1);
+     u_delmask('b', chan, chan->bans->mask, 1);
    /* Remove channel-exempts */
    /* Remove channel-exempts */
    while (chan->exempts)
    while (chan->exempts)
-     u_delexempt(chan, chan->exempts->mask, 1);
+     u_delmask('e', chan, chan->exempts->mask, 1);
    /* Remove channel-invites */
    /* Remove channel-invites */
    while (chan->invites)
    while (chan->invites)
-     u_delinvite(chan, chan->invites->mask, 1);
+     u_delmask('I', chan, chan->invites->mask, 1);
    /* Remove channel specific user flags */
    /* Remove channel specific user flags */
    user_del_chan(chan->dname);
    user_del_chan(chan->dname);
    noshare = 0;
    noshare = 0;

+ 2 - 6
src/mod/channels.mod/channels.h

@@ -72,12 +72,8 @@ int write_chans (FILE *, int);
 int write_invites (FILE *, int);
 int write_invites (FILE *, int);
 int expired_mask(struct chanset_t *, char *);
 int expired_mask(struct chanset_t *, char *);
 void set_handle_laston(char *, struct userrec *, time_t);
 void set_handle_laston(char *, struct userrec *, time_t);
-int u_delexempt(struct chanset_t *, char *, int);
-int u_addexempt(struct chanset_t *, char *, char *, char *,  time_t, int);
-int u_delinvite(struct chanset_t *, char *, int);
-int u_addinvite(struct chanset_t *, char *, char *, char *,  time_t, int);
-int u_delban(struct chanset_t *, char *, int);
-int u_addban(struct chanset_t *, char *, char *, char *, time_t, int);
+int u_delmask(char type, struct chanset_t *c, char *who, int doit);
+int u_addmask(char type, struct chanset_t *, char *, char *, char *, time_t, int);
 int u_sticky_mask(maskrec *, char *);
 int u_sticky_mask(maskrec *, char *);
 int u_setsticky_mask(struct chanset_t *, maskrec *, char *, int, char *);
 int u_setsticky_mask(struct chanset_t *, maskrec *, char *, int, char *);
 int SplitList(char *, const char *, int *, const char ***);
 int SplitList(char *, const char *, int *, const char ***);

+ 18 - 18
src/mod/channels.mod/cmdschan.c

@@ -106,7 +106,7 @@ static void cmd_pls_ban(struct userrec *u, int idx, char *par)
 	s[70] = 0;
 	s[70] = 0;
       }
       }
       if (chan) {
       if (chan) {
-	u_addban(chan, s, dcc[idx].nick, par,
+	u_addmask('b', chan, s, dcc[idx].nick, par,
 		 expire_time ? now + expire_time : 0, 0);
 		 expire_time ? now + expire_time : 0, 0);
 	if (par[0] == '*') {
 	if (par[0] == '*') {
 	  sticky = 1;
 	  sticky = 1;
@@ -127,7 +127,7 @@ static void cmd_pls_ban(struct userrec *u, int idx, char *par)
 #endif /* LEAF */
 #endif /* LEAF */
         
         
       } else {
       } else {
-	u_addban(NULL, s, dcc[idx].nick, par, expire_time ? now + expire_time : 0, 0);
+	u_addmask('b', NULL, s, dcc[idx].nick, par, expire_time ? now + expire_time : 0, 0);
 	if (par[0] == '*') {
 	if (par[0] == '*') {
 	  sticky = 1;
 	  sticky = 1;
 	  par++;
 	  par++;
@@ -242,7 +242,7 @@ static void cmd_pls_exempt(struct userrec *u, int idx, char *par)
       s[70] = 0;
       s[70] = 0;
     }
     }
     if (chan) {
     if (chan) {
-      u_addexempt(chan, s, dcc[idx].nick, par,
+      u_addmask('e', chan, s, dcc[idx].nick, par,
 		  expire_time ? now + expire_time : 0, 0);
 		  expire_time ? now + expire_time : 0, 0);
       if (par[0] == '*') {
       if (par[0] == '*') {
 	par++;
 	par++;
@@ -258,7 +258,7 @@ static void cmd_pls_exempt(struct userrec *u, int idx, char *par)
       add_mode(chan, '+', 'e', s);
       add_mode(chan, '+', 'e', s);
 #endif /* LEAF */
 #endif /* LEAF */
     } else {
     } else {
-      u_addexempt(NULL, s, dcc[idx].nick, par,
+      u_addmask('e', NULL, s, dcc[idx].nick, par,
 		  expire_time ? now + expire_time : 0, 0);
 		  expire_time ? now + expire_time : 0, 0);
       if (par[0] == '*') {
       if (par[0] == '*') {
 	par++;
 	par++;
@@ -375,7 +375,7 @@ static void cmd_pls_invite(struct userrec *u, int idx, char *par)
       s[70] = 0;
       s[70] = 0;
     }
     }
     if (chan) {
     if (chan) {
-      u_addinvite(chan, s, dcc[idx].nick, par,
+      u_addmask('I', chan, s, dcc[idx].nick, par,
 		  expire_time ? now + expire_time : 0, 0);
 		  expire_time ? now + expire_time : 0, 0);
       if (par[0] == '*') {
       if (par[0] == '*') {
 	par++;
 	par++;
@@ -391,7 +391,7 @@ static void cmd_pls_invite(struct userrec *u, int idx, char *par)
       add_mode(chan, '+', 'I', s);
       add_mode(chan, '+', 'I', s);
 #endif /* LEAF */
 #endif /* LEAF */
     } else {
     } else {
-      u_addinvite(NULL, s, dcc[idx].nick, par,
+      u_addmask('I', NULL, s, dcc[idx].nick, par,
 		  expire_time ? now + expire_time : 0, 0);
 		  expire_time ? now + expire_time : 0, 0);
       if (par[0] == '*') {
       if (par[0] == '*') {
 	par++;
 	par++;
@@ -446,7 +446,7 @@ static void cmd_mns_ban(struct userrec *u, int idx, char *par)
   }
   }
   strncpyz(s, ban, sizeof s);
   strncpyz(s, ban, sizeof s);
   if (console) {
   if (console) {
-    i = u_delban(NULL, s, (u->flags & USER_MASTER));
+    i = u_delmask('b', NULL, s, (u->flags & USER_MASTER));
     if (i > 0) {
     if (i > 0) {
       if (lastdeletedmask)
       if (lastdeletedmask)
         mask = lastdeletedmask;
         mask = lastdeletedmask;
@@ -472,10 +472,10 @@ static void cmd_mns_ban(struct userrec *u, int idx, char *par)
     i = atoi(ban);
     i = atoi(ban);
     /* substract the numer of global bans to get the number of the channel ban */
     /* substract the numer of global bans to get the number of the channel ban */
     egg_snprintf(s, sizeof s, "%d", i);
     egg_snprintf(s, sizeof s, "%d", i);
-    j = u_delban(0, s, 0);
+    j = u_delmask('b', 0, s, 0);
     if (j < 0) {
     if (j < 0) {
       egg_snprintf(s, sizeof s, "%d", -j);
       egg_snprintf(s, sizeof s, "%d", -j);
-      j = u_delban(chan, s, 1);
+      j = u_delmask('b', chan, s, 1);
       if (j > 0) {
       if (j > 0) {
         if (lastdeletedmask)
         if (lastdeletedmask)
           mask = lastdeletedmask;
           mask = lastdeletedmask;
@@ -505,7 +505,7 @@ static void cmd_mns_ban(struct userrec *u, int idx, char *par)
       }
       }
     }
     }
   } else {
   } else {
-    j = u_delban(chan, ban, 1);
+    j = u_delmask('b', chan, ban, 1);
     if (j > 0) {
     if (j > 0) {
       putlog(LOG_CMDS, "*", "#%s# (%s) -ban %s", dcc[idx].nick, dcc[idx].u.chat->con_chan, ban);
       putlog(LOG_CMDS, "*", "#%s# (%s) -ban %s", dcc[idx].nick, dcc[idx].u.chat->con_chan, ban);
       dprintf(idx, "Removed %s channel ban: %s\n", chname, ban);
       dprintf(idx, "Removed %s channel ban: %s\n", chname, ban);
@@ -567,7 +567,7 @@ static void cmd_mns_exempt(struct userrec *u, int idx, char *par)
   }
   }
   strncpyz(s, exempt, sizeof s);
   strncpyz(s, exempt, sizeof s);
   if (console) {
   if (console) {
-    i = u_delexempt(NULL, s, (u->flags & USER_MASTER));
+    i = u_delmask('e', NULL, s, (u->flags & USER_MASTER));
     if (i > 0) {
     if (i > 0) {
       if (lastdeletedmask)
       if (lastdeletedmask)
         mask = lastdeletedmask;
         mask = lastdeletedmask;
@@ -593,10 +593,10 @@ static void cmd_mns_exempt(struct userrec *u, int idx, char *par)
     i = atoi(exempt);
     i = atoi(exempt);
     /* substract the numer of global exempts to get the number of the channel exempt */
     /* substract the numer of global exempts to get the number of the channel exempt */
     egg_snprintf(s, sizeof s, "%d", i);
     egg_snprintf(s, sizeof s, "%d", i);
-    j = u_delexempt(0, s, 0);
+    j = u_delmask('e', 0, s, 0);
     if (j < 0) {
     if (j < 0) {
       egg_snprintf(s, sizeof s, "%d", -j);
       egg_snprintf(s, sizeof s, "%d", -j);
-      j = u_delexempt(chan, s, 1);
+      j = u_delmask('e', chan, s, 1);
       if (j > 0) {
       if (j > 0) {
         if (lastdeletedmask)
         if (lastdeletedmask)
           mask = lastdeletedmask;
           mask = lastdeletedmask;
@@ -627,7 +627,7 @@ static void cmd_mns_exempt(struct userrec *u, int idx, char *par)
       }
       }
     }
     }
   } else {
   } else {
-    j = u_delexempt(chan, exempt, 1);
+    j = u_delmask('e', chan, exempt, 1);
     if (j > 0) {
     if (j > 0) {
       putlog(LOG_CMDS, "*", "#%s# (%s) -exempt %s", dcc[idx].nick, dcc[idx].u.chat->con_chan, exempt);
       putlog(LOG_CMDS, "*", "#%s# (%s) -exempt %s", dcc[idx].nick, dcc[idx].u.chat->con_chan, exempt);
       dprintf(idx, "Removed %s channel exempt: %s\n", chname, exempt);
       dprintf(idx, "Removed %s channel exempt: %s\n", chname, exempt);
@@ -689,7 +689,7 @@ static void cmd_mns_invite(struct userrec *u, int idx, char *par)
   }
   }
   strncpyz(s, invite, sizeof s);
   strncpyz(s, invite, sizeof s);
   if (console) {
   if (console) {
-    i = u_delinvite(NULL, s, (u->flags & USER_MASTER));
+    i = u_delmask('I', NULL, s, (u->flags & USER_MASTER));
     if (i > 0) {
     if (i > 0) {
       if (lastdeletedmask)
       if (lastdeletedmask)
         mask = lastdeletedmask;
         mask = lastdeletedmask;
@@ -715,10 +715,10 @@ static void cmd_mns_invite(struct userrec *u, int idx, char *par)
     i = atoi(invite);
     i = atoi(invite);
     /* substract the numer of global invites to get the number of the channel invite */
     /* substract the numer of global invites to get the number of the channel invite */
     egg_snprintf(s, sizeof s, "%d", i);
     egg_snprintf(s, sizeof s, "%d", i);
-    j = u_delinvite(0, s, 0);
+    j = u_delmask('I', 0, s, 0);
     if (j < 0) {
     if (j < 0) {
       egg_snprintf(s, sizeof s, "%d", -j);
       egg_snprintf(s, sizeof s, "%d", -j);
-      j = u_delinvite(chan, s, 1);
+      j = u_delmask('I', chan, s, 1);
       if (j > 0) {
       if (j > 0) {
         if (lastdeletedmask)
         if (lastdeletedmask)
           mask = lastdeletedmask;
           mask = lastdeletedmask;
@@ -749,7 +749,7 @@ static void cmd_mns_invite(struct userrec *u, int idx, char *par)
       }
       }
     }
     }
   } else {
   } else {
-    j = u_delinvite(chan, invite, 1);
+    j = u_delmask('I', chan, invite, 1);
     if (j > 0) {
     if (j > 0) {
       putlog(LOG_CMDS, "*", "#%s# (%s) -invite %s", dcc[idx].nick, dcc[idx].u.chat->con_chan, invite);
       putlog(LOG_CMDS, "*", "#%s# (%s) -invite %s", dcc[idx].nick, dcc[idx].u.chat->con_chan, invite);
       dprintf(idx, "Removed %s channel invite: %s\n", chname, invite);
       dprintf(idx, "Removed %s channel invite: %s\n", chname, invite);

+ 35 - 275
src/mod/channels.mod/userchan.c

@@ -217,12 +217,18 @@ int u_match_mask(maskrec *rec, char *mask)
   return 0;
   return 0;
 }
 }
 
 
-int u_delban(struct chanset_t *c, char *who, int doit)
+int u_delmask(char type, struct chanset_t *c, char *who, int doit)
 {
 {
   int j, i = 0;
   int j, i = 0;
-  maskrec *t = NULL;
-  maskrec **u = (c) ? &c->bans : &global_bans;
   char temp[256] = "";
   char temp[256] = "";
+  maskrec **u = NULL, *t;
+
+  if (type == 'b')
+    u = c ? &c->bans : &global_bans;
+  if (type == 'e')
+    u = c ? &c->exempts : &global_exempts;
+  if (type == 'I')
+    u = c ? &c->invites : &global_invites;
 
 
   if (!strchr(who, '!') && str_isdigit(who)) {
   if (!strchr(who, '!') && str_isdigit(who)) {
     j = atoi(who);
     j = atoi(who);
@@ -251,112 +257,9 @@ int u_delban(struct chanset_t *c, char *who, int doit)
       if (mask) {
       if (mask) {
 	/* Distribute chan bans differently */
 	/* Distribute chan bans differently */
 	if (c)
 	if (c)
-	  shareout(c, "-bc %s %s\n", c->dname, mask);
-	else
-	  shareout(NULL, "-b %s\n", mask);
-	free(mask);
-      }
-    }
-    if (lastdeletedmask)
-      free(lastdeletedmask);
-    lastdeletedmask = strdup((*u)->mask);
-    free((*u)->mask);
-    if ((*u)->desc)
-      free((*u)->desc);
-    if ((*u)->user)
-      free((*u)->user);
-    t = *u;
-    *u = (*u)->next;
-    free(t);
-  }
-  return i;
-}
-
-int u_delexempt (struct chanset_t * c, char * who, int doit)
-{
-  int j, i = 0;
-  maskrec *t = NULL;
-  maskrec **u = c ? &(c->exempts) : &global_exempts;
-
-  if (!strchr(who, '!') && str_isdigit(who)) {
-    j = atoi(who);
-    j--;
-    for (;(*u) && j;u=&((*u)->next),j--);
-    if (*u) {
-      strcpy(who, (*u)->mask);
-      i = 1;
-    } else
-      return -j-1;
-  } else {
-    /* Find matching host, if there is one */
-    for (;*u && !i;u=&((*u)->next))
-      if (!rfc_casecmp((*u)->mask,who)) {
-	i = 1;
-	break;
-      }
-    if (!*u)
-      return 0;
-  }
-  if (i && doit) {
-    if (!noshare) {
-      char *mask = str_escape(who, ':', '\\');
-
-      if (mask) {
-	/* Distribute chan exempts differently */
-	if (c)
-	  shareout(c, "-ec %s %s\n", c->dname, mask);
-	else
-	  shareout(NULL, "-e %s\n", mask);
-	free(mask);
-      }
-    }
-    free((*u)->mask);
-    if ((*u)->desc)
-      free((*u)->desc);
-    if ((*u)->user)
-      free((*u)->user);
-    t = *u;
-    *u = (*u)->next;
-    free(t);
-  }
-  return i;
-}
-
-int u_delinvite(struct chanset_t *c, char *who, int doit)
-{
-  int j, i = 0;
-  maskrec *t = NULL;
-  maskrec **u = c ? &(c->invites) : &global_invites;
-
-  if (!strchr(who, '!') && str_isdigit(who)) {
-    j = atoi(who);
-    j--;
-    for (;(*u) && j;u=&((*u)->next),j--);
-    if (*u) {
-      strcpy(who, (*u)->mask);
-      i = 1;
-    } else
-      return -j-1;
-  } else {
-    /* Find matching host, if there is one */
-    for (;*u && !i; u = &((*u)->next))
-      if (!rfc_casecmp((*u)->mask,who)) {
-	i = 1;
-	break;
-      }
-    if (!*u)
-      return 0;
-  }
-  if (i && doit) {
-    if (!noshare) {
-      char *mask = str_escape(who, ':', '\\');
-
-      if (mask) {
-	/* Distribute chan invites differently */
-	if (c)
-	  shareout(c, "-invc %s %s\n", c->dname, mask);
+	  shareout(c, "-%s %s %s\n", type == 'b' ? "bc" : type == 'e' ? "ec" : "invc", c->dname, mask);
 	else
 	else
-	  shareout(NULL, "-inv %s\n", mask);
+	  shareout(NULL, "-%s %s\n", type == 'b' ? "b" : type == 'e' ? "e" : "inv", mask);
 	free(mask);
 	free(mask);
       }
       }
     }
     }
@@ -372,14 +275,21 @@ int u_delinvite(struct chanset_t *c, char *who, int doit)
   return i;
   return i;
 }
 }
 
 
-/* Note: If first char of note is '*' it's a sticky ban.
+/* Note: If first char of note is '*' it's a sticky mask.
  */
  */
-int u_addban(struct chanset_t *chan, char *ban, char *from, char *note, time_t expire_time, int flags)
+int u_addmask(char type, struct chanset_t *chan, char *who, char *from, char *note, time_t expire_time, int flags)
 {
 {
   char host[1024] = "", s[1024] = "";
   char host[1024] = "", s[1024] = "";
-  maskrec *p = NULL, *l = NULL, **u = chan ? &chan->bans : &global_bans;
+  maskrec *p = NULL, *l = NULL, **u = NULL;
+
+  if (type == 'b')
+    u = chan ? &chan->bans : &global_bans;
+  if (type == 'e')
+    u = chan ? &chan->exempts : &global_exempts;
+  if (type == 'I')
+    u = chan ? &chan->invites : &global_invites;
 
 
-  strcpy(host, ban);
+  strcpy(host, who);
   /* Choke check: fix broken bans (must have '!' and '@') */
   /* Choke check: fix broken bans (must have '!' and '@') */
   if ((strchr(host, '!') == NULL) && (strchr(host, '@') == NULL))
   if ((strchr(host, '!') == NULL) && (strchr(host, '@') == NULL))
     strcat(host, "!*@*");
     strcat(host, "!*@*");
@@ -398,7 +308,7 @@ int u_addban(struct chanset_t *chan, char *ban, char *from, char *note, time_t e
 #else
 #else
     simple_sprintf(s, "%s!%s@%s", origbotname, botuser, conf.bot->host);
     simple_sprintf(s, "%s!%s@%s", origbotname, botuser, conf.bot->host);
 #endif /* LEAF */
 #endif /* LEAF */
-  if (wild_match(host, s)) {
+  if (s[0] && type == 'b' && wild_match(host, s)) {
     putlog(LOG_MISC, "*", IRC_IBANNEDME);
     putlog(LOG_MISC, "*", IRC_IBANNEDME);
     return 0;
     return 0;
   }
   }
@@ -443,11 +353,15 @@ int u_addban(struct chanset_t *chan, char *ban, char *from, char *note, time_t e
 
 
     if (mask) {
     if (mask) {
       if (!chan)
       if (!chan)
-	shareout(NULL, "+b %s %li %s%s %s %s\n", mask, expire_time - now,
+	shareout(NULL, "+%s %s %lu %s%s %s %s\n",
+		 type == 'b' ? "b" : type == 'e' ? "e" : "inv",
+		 mask, expire_time - now,
 		 (flags & MASKREC_STICKY) ? "s" : "",
 		 (flags & MASKREC_STICKY) ? "s" : "",
 		 (flags & MASKREC_PERM) ? "p" : "-", from, note);
 		 (flags & MASKREC_PERM) ? "p" : "-", from, note);
       else
       else
-	shareout(chan, "+bc %s %li %s %s%s %s %s\n", mask, expire_time - now,
+	shareout(chan, "+%s %s %lu %s %s%s %s %s\n",
+		 type == 'b' ? "bc" : type == 'e' ? "ec" : "invc",	
+		 mask, expire_time - now,
 		 chan->dname, (flags & MASKREC_STICKY) ? "s" : "",
 		 chan->dname, (flags & MASKREC_STICKY) ? "s" : "",
 		 (flags & MASKREC_PERM) ? "p" : "-", from, note);
 		 (flags & MASKREC_PERM) ? "p" : "-", from, note);
       free(mask);
       free(mask);
@@ -456,160 +370,6 @@ int u_addban(struct chanset_t *chan, char *ban, char *from, char *note, time_t e
   return 1;
   return 1;
 }
 }
 
 
-/* Note: If first char of note is '*' it's a sticky invite.
- */
-int u_addinvite(struct chanset_t *chan, char *invite, char *from, char *note, time_t expire_time, int flags)
-{
-  char host[1024] = "", s[1024] = "";
-  maskrec *p = NULL, *l, **u = chan ? &chan->invites : &global_invites;
-
-  strcpy(host, invite);
-  /* Choke check: fix broken invites (must have '!' and '@') */
-  if ((strchr(host, '!') == NULL) && (strchr(host, '@') == NULL))
-    strcat(host, "!*@*");
-  else if (strchr(host, '@') == NULL)
-    strcat(host, "@*");
-  else if (strchr(host, '!') == NULL) {
-    char * i = strchr(host, '@');
-    strcpy(s, i);
-    *i = 0;
-    strcat(host, "!*");
-    strcat(host, s);
-  }
-#ifdef LEAF
-    simple_sprintf(s, "%s!%s", botname, botuserhost);
-#else
-    simple_sprintf(s, "%s!%s@%s", origbotname, botuser, conf.bot->host);
-#endif /* LEAF */
-
-  for (l = *u; l; l = l->next)
-    if (!rfc_casecmp(l->mask, host)) {
-      p = l;
-      break;
-    }  
-
-  /* It shouldn't expire and be sticky also */
-  if (note[0] == '*') {
-    flags |= MASKREC_STICKY;
-    note++;
-  }
-  if ((expire_time == 0L) || (flags & MASKREC_PERM)) {
-    flags |= MASKREC_PERM;
-    expire_time = 0L;
-  }
-
-  if (p == NULL) {  
-    p = calloc(1, sizeof(maskrec));
-    p->next = *u;
-    *u = p;
-  }
-  else {
-    free( p->mask );
-    free( p->user );
-    free( p->desc );
-  }
-  p->expire = expire_time;
-  p->added = now;
-  p->lastactive = 0;
-  p->flags = flags;
-  p->mask = strdup(host);
-  p->user = strdup(from);
-  p->desc = strdup(note);
-  if (!noshare) {
-    char *mask = str_escape(host, ':', '\\');
-
-    if (mask) {
-      if (!chan)
-	shareout(NULL, "+inv %s %li %s%s %s %s\n", mask, expire_time - now,
-		 (flags & MASKREC_STICKY) ? "s" : "",
-		 (flags & MASKREC_PERM) ? "p": "-", from, note);
-      else
-	shareout(chan, "+invc %s %li %s %s%s %s %s\n", mask, expire_time - now,
-		 chan->dname, (flags & MASKREC_STICKY) ? "s" : "",
-		 (flags & MASKREC_PERM) ? "p": "-", from, note);
-      free(mask);
-    }
-  }
-  return 1;
-}
-
-/* Note: If first char of note is '*' it's a sticky exempt.
- */
-int u_addexempt(struct chanset_t *chan, char *exempt, char *from, char *note, time_t expire_time, int flags)
-{
-  char host[1024] = "", s[1024] = "";
-  maskrec *p = NULL, *l, **u = chan ? &chan->exempts : &global_exempts;
-
-  strcpy(host, exempt);
-  /* Choke check: fix broken exempts (must have '!' and '@') */
-  if ((strchr(host, '!') == NULL) && (strchr(host, '@') == NULL))
-    strcat(host, "!*@*");
-  else if (strchr(host, '@') == NULL)
-    strcat(host, "@*");
-  else if (strchr(host, '!') == NULL) {
-    char * i = strchr(host, '@');
-    strcpy(s, i);
-    *i = 0;
-    strcat(host, "!*");
-    strcat(host, s);
-  }
-#ifdef LEAF
-    simple_sprintf(s, "%s!%s", botname, botuserhost);
-#else
-    simple_sprintf(s, "%s!%s@%s", origbotname, botuser, conf.bot->host);
-#endif /* LEAF */
-
-  for (l = *u; l; l = l->next)
-    if (!rfc_casecmp(l->mask, host)) {
-      p = l;
-      break;
-    }  
-
-  /* It shouldn't expire and be sticky also */
-  if (note[0] == '*') {
-    flags |= MASKREC_STICKY;
-    note++;
-  }
-  if ((expire_time == 0L) || (flags & MASKREC_PERM)) {
-    flags |= MASKREC_PERM;
-    expire_time = 0L;
-  }
-
-  if (p == NULL) {  
-    p = calloc(1, sizeof(maskrec));
-    p->next = *u;
-    *u = p;
-  }
-  else {
-    free( p->mask );
-    free( p->user );
-    free( p->desc );
-  }
-  p->expire = expire_time;
-  p->added = now;
-  p->lastactive = 0;
-  p->flags = flags;
-  p->mask = strdup(host);
-  p->user = strdup(from);
-  p->desc = strdup(note);
-  if (!noshare) {
-    char *mask = str_escape(host, ':', '\\');
-
-    if (mask) {
-      if (!chan)
-	shareout(NULL, "+e %s %li %s%s %s %s\n", mask, expire_time - now,
-		 (flags & MASKREC_STICKY) ? "s" : "",
-		 (flags & MASKREC_PERM) ? "p": "-", from, note);
-      else
-	shareout(chan, "+ec %s %li %s %s%s %s %s\n", mask, expire_time - now,
-		 chan->dname, (flags & MASKREC_STICKY) ? "s" : "",
-		 (flags & MASKREC_PERM) ? "p": "-", from, note);
-      free(mask);
-    }
-  }
-  return 1;
-}
-
 /* Take host entry from ban list and display it ban-style.
 /* Take host entry from ban list and display it ban-style.
  */
  */
 static void display_ban(int idx, int number, maskrec *ban, struct chanset_t *chan, int show_inact)
 static void display_ban(int idx, int number, maskrec *ban, struct chanset_t *chan, int show_inact)
@@ -1437,7 +1197,7 @@ static void check_expired_bans(void)
 #endif /* LEAF */
 #endif /* LEAF */
 	    b->timer = now;
 	    b->timer = now;
 	  }
 	  }
-      u_delban(NULL, u->mask, 1);
+      u_delmask('b', NULL, u->mask, 1);
     }
     }
   }
   }
   /* Check for specific channel-domain bans expiring */
   /* Check for specific channel-domain bans expiring */
@@ -1454,7 +1214,7 @@ static void check_expired_bans(void)
 #endif /* LEAF */
 #endif /* LEAF */
 	    b->timer = now;
 	    b->timer = now;
 	  }
 	  }
-	u_delban(chan, u->mask, 1);
+	u_delmask('b', chan, u->mask, 1);
       }
       }
     }
     }
   }
   }
@@ -1499,7 +1259,7 @@ static void check_expired_exempts(void)
 	      e->timer = now;
 	      e->timer = now;
 	    }
 	    }
       }
       }
-      u_delexempt(NULL, u->mask,1);
+      u_delmask('e', NULL, u->mask,1);
     }
     }
   }
   }
   /* Check for specific channel-domain exempts expiring */
   /* Check for specific channel-domain exempts expiring */
@@ -1530,7 +1290,7 @@ static void check_expired_exempts(void)
 #endif /* LEAF */
 #endif /* LEAF */
 	      e->timer = now;
 	      e->timer = now;
 	    }
 	    }
-          u_delexempt(chan, u->mask, 1);
+          u_delmask('e', chan, u->mask, 1);
         }
         }
       }
       }
     }
     }
@@ -1561,7 +1321,7 @@ static void check_expired_invites(void)
 #endif /* LEAF */
 #endif /* LEAF */
 	      b->timer = now;
 	      b->timer = now;
 	    }
 	    }
-      u_delinvite(NULL, u->mask,1);
+      u_delmask('I', NULL, u->mask,1);
     }
     }
   }
   }
   /* Check for specific channel-domain invites expiring */
   /* Check for specific channel-domain invites expiring */
@@ -1579,7 +1339,7 @@ static void check_expired_invites(void)
 #endif /* LEAF */
 #endif /* LEAF */
 	      b->timer = now;
 	      b->timer = now;
 	    }
 	    }
-	u_delinvite(chan, u->mask, 1);
+	u_delmask('I', chan, u->mask, 1);
       }
       }
     }
     }
   }
   }

+ 4 - 4
src/mod/irc.mod/chan.c

@@ -467,7 +467,7 @@ static int detect_chan_flood(char *floodnick, char *floodhost, char *from,
       else
       else
 	putlog(LOG_MISC | LOG_JOIN, chan->dname, IRC_FLOODIGNORE4, p);
 	putlog(LOG_MISC | LOG_JOIN, chan->dname, IRC_FLOODIGNORE4, p);
       strcpy(ftype + 4, " flood");
       strcpy(ftype + 4, " flood");
-      u_addban(chan, h, conf.bot->nick, ftype, now + (60 * chan->ban_time), 0);
+      u_addmask('b', chan, h, conf.bot->nick, ftype, now + (60 * chan->ban_time), 0);
       if (!channel_enforcebans(chan) && me_op(chan)) {
       if (!channel_enforcebans(chan) && me_op(chan)) {
 	  char s[UHOSTLEN];
 	  char s[UHOSTLEN];
 	  for (m = chan->channel.member; m && m->nick[0]; m = m->next) {	  
 	  for (m = chan->channel.member; m && m->nick[0]; m = m->next) {	  
@@ -529,7 +529,7 @@ static void doban(struct chanset_t *chan, memberlist *m)
 
 
     check_exemptlist(chan, s);
     check_exemptlist(chan, s);
     s1 = quickban(chan, m->userhost);
     s1 = quickban(chan, m->userhost);
-    u_addban(chan, s1, conf.bot->nick, "joined closed chan", now + (60 * chan->ban_time), 0);
+    u_addmask('b', chan, s1, conf.bot->nick, "joined closed chan", now + (60 * chan->ban_time), 0);
   }
   }
   return;
   return;
 }
 }
@@ -2584,7 +2584,7 @@ static int gotmsg(char *from, char *msg)
 	   u_match_mask(chan->exempts, from)))) {
 	   u_match_mask(chan->exempts, from)))) {
       if (ban_fun) {
       if (ban_fun) {
 	check_exemptlist(chan, from);
 	check_exemptlist(chan, from);
-	u_addban(chan, quickban(chan, uhost), conf.bot->nick,
+	u_addmask('b', chan, quickban(chan, uhost), conf.bot->nick,
                IRC_FUNKICK, now + (60 * chan->ban_time), 0);
                IRC_FUNKICK, now + (60 * chan->ban_time), 0);
       }
       }
       if (kick_fun) {
       if (kick_fun) {
@@ -2759,7 +2759,7 @@ static int gotnotice(char *from, char *msg)
 	   u_match_mask(chan->exempts, from)))) {
 	   u_match_mask(chan->exempts, from)))) {
       if (ban_fun) {
       if (ban_fun) {
 	check_exemptlist(chan, from);
 	check_exemptlist(chan, from);
-	u_addban(chan, quickban(chan, uhost), conf.bot->nick,
+	u_addmask('b', chan, quickban(chan, uhost), conf.bot->nick,
                IRC_FUNKICK, now + (60 * chan->ban_time), 0);
                IRC_FUNKICK, now + (60 * chan->ban_time), 0);
       }
       }
       if (kick_fun) {
       if (kick_fun) {

+ 1 - 1
src/mod/irc.mod/cmdsirc.c

@@ -260,7 +260,7 @@ static void cmd_kickban(struct userrec *u, int idx, char *par)
       par = "requested";
       par = "requested";
     dprintf(DP_MODE, "KICK %s %s :%s%s\n", chan->name, m->nick, bankickprefix, par);
     dprintf(DP_MODE, "KICK %s %s :%s%s\n", chan->name, m->nick, bankickprefix, par);
     m->flags |= SENTKICK;
     m->flags |= SENTKICK;
-    u_addban(chan, s1, dcc[idx].nick, par, now + (60 * chan->ban_time), 0);
+    u_addmask('b', chan, s1, dcc[idx].nick, par, now + (60 * chan->ban_time), 0);
     dprintf(idx, "Kick-banned %s on %s.\n", nick, chan->dname);
     dprintf(idx, "Kick-banned %s on %s.\n", nick, chan->dname);
     next:;
     next:;
     if (!all)
     if (!all)

+ 1 - 1
src/mod/irc.mod/irc.c

@@ -778,7 +778,7 @@ static void punish_badguy(struct chanset_t *chan, char *whobad,
     splitnick(&whobad);
     splitnick(&whobad);
     maskhost(whobad, s1);
     maskhost(whobad, s1);
     simple_sprintf(s, "(%s) %s", ct, reason);
     simple_sprintf(s, "(%s) %s", ct, reason);
-    u_addban(chan, s1, conf.bot->nick, s, now + (60 * chan->ban_time), 0);
+    u_addmask('b', chan, s1, conf.bot->nick, s, now + (60 * chan->ban_time), 0);
     if (!mevictim && me_op(chan)) {
     if (!mevictim && me_op(chan)) {
       add_mode(chan, '+', 'b', s1);
       add_mode(chan, '+', 'b', s1);
       flush_mode(chan, QUICK);
       flush_mode(chan, QUICK);

+ 18 - 18
src/mod/share.mod/share.c

@@ -649,7 +649,7 @@ static void share_mns_ban(int idx, char *par)
     putlog(LOG_CMDS, "@", "%s: cancel ban %s", dcc[idx].nick, par);
     putlog(LOG_CMDS, "@", "%s: cancel ban %s", dcc[idx].nick, par);
     str_unescape(par, '\\');
     str_unescape(par, '\\');
     noshare = 1;
     noshare = 1;
-    if (u_delban(NULL, par, 1) > 0) {
+    if (u_delmask('b', NULL, par, 1) > 0) {
       for (chan = chanset; chan; chan = chan->next)
       for (chan = chanset; chan; chan = chan->next)
 	add_delay(chan, '-', 'b', par);
 	add_delay(chan, '-', 'b', par);
     }
     }
@@ -666,7 +666,7 @@ static void share_mns_exempt(int idx, char *par)
     putlog(LOG_CMDS, "@", "%s: cancel exempt %s", dcc[idx].nick, par);
     putlog(LOG_CMDS, "@", "%s: cancel exempt %s", dcc[idx].nick, par);
     str_unescape(par, '\\');
     str_unescape(par, '\\');
     noshare = 1;
     noshare = 1;
-    if (u_delexempt(NULL, par, 1) > 0) {
+    if (u_delmask('e', NULL, par, 1) > 0) {
       for (chan = chanset; chan; chan = chan->next)
       for (chan = chanset; chan; chan = chan->next)
 	add_delay(chan, '-', 'e', par);
 	add_delay(chan, '-', 'e', par);
     }
     }
@@ -683,7 +683,7 @@ static void share_mns_invite(int idx, char *par)
     putlog(LOG_CMDS, "@", "%s: cancel invite %s", dcc[idx].nick, par);
     putlog(LOG_CMDS, "@", "%s: cancel invite %s", dcc[idx].nick, par);
     str_unescape(par, '\\');
     str_unescape(par, '\\');
     noshare = 1;
     noshare = 1;
-    if (u_delinvite(NULL, par, 1) > 0) {
+    if (u_delmask('I', NULL, par, 1) > 0) {
       for (chan = chanset; chan; chan = chan->next)
       for (chan = chanset; chan; chan = chan->next)
 	add_delay(chan, '-', 'I', par);
 	add_delay(chan, '-', 'I', par);
     }
     }
@@ -709,7 +709,7 @@ static void share_mns_banchan(int idx, char *par)
       putlog(LOG_CMDS, "@", "%s: cancel ban %s on %s", dcc[idx].nick, par, chname);
       putlog(LOG_CMDS, "@", "%s: cancel ban %s on %s", dcc[idx].nick, par, chname);
       str_unescape(par, '\\');
       str_unescape(par, '\\');
       noshare = 1;
       noshare = 1;
-      if (u_delban(chan, par, 1) > 0)
+      if (u_delmask('b', chan, par, 1) > 0)
 	add_delay(chan, '-', 'b', par);
 	add_delay(chan, '-', 'b', par);
       noshare = 0;
       noshare = 0;
     }
     }
@@ -737,7 +737,7 @@ static void share_mns_exemptchan(int idx, char *par)
 	     par, chname);
 	     par, chname);
       str_unescape(par, '\\');
       str_unescape(par, '\\');
       noshare = 1;
       noshare = 1;
-      if (u_delexempt(chan, par, 1) > 0)
+      if (u_delmask('e', chan, par, 1) > 0)
 	add_delay(chan, '-', 'e', par);
 	add_delay(chan, '-', 'e', par);
       noshare = 0;
       noshare = 0;
     }
     }
@@ -765,7 +765,7 @@ static void share_mns_invitechan (int idx, char *par)
 	     par, chname);
 	     par, chname);
       str_unescape(par, '\\');
       str_unescape(par, '\\');
       noshare = 1;
       noshare = 1;
-      if (u_delinvite(chan, par, 1) > 0)
+      if (u_delmask('I', chan, par, 1) > 0)
 	add_delay(chan, '-', 'I', par);
 	add_delay(chan, '-', 'I', par);
       noshare = 0;
       noshare = 0;
     }
     }
@@ -808,7 +808,7 @@ static void share_pls_ban(int idx, char *par)
     expire_time = (time_t) atoi(tm);
     expire_time = (time_t) atoi(tm);
     if (expire_time != 0L)
     if (expire_time != 0L)
       expire_time += now;
       expire_time += now;
-    u_addban(NULL, ban, from, par, expire_time, flags);
+    u_addmask('b', NULL, ban, from, par, expire_time, flags);
     putlog(LOG_CMDS, "@", "%s: global ban %s (%s:%s)", dcc[idx].nick, ban,
     putlog(LOG_CMDS, "@", "%s: global ban %s (%s:%s)", dcc[idx].nick, ban,
 	   from, par);
 	   from, par);
     noshare = 0;
     noshare = 0;
@@ -853,7 +853,7 @@ static void share_pls_banchan(int idx, char *par)
       expire_time = (time_t) atoi(tm);
       expire_time = (time_t) atoi(tm);
       if (expire_time != 0L)
       if (expire_time != 0L)
 	expire_time += now;
 	expire_time += now;
-      u_addban(chan, ban, from, par, expire_time, flags);
+      u_addmask('b', chan, ban, from, par, expire_time, flags);
       noshare = 0;
       noshare = 0;
 #ifdef LEAF
 #ifdef LEAF
       check_this_ban(chan, ban, 0);
       check_this_ban(chan, ban, 0);
@@ -885,7 +885,7 @@ static void share_pls_exempt(int idx, char *par)
     expire_time = (time_t) atoi(tm);
     expire_time = (time_t) atoi(tm);
     if (expire_time != 0L)
     if (expire_time != 0L)
       expire_time += now;
       expire_time += now;
-    u_addexempt(NULL,exempt, from, par, expire_time,flags);
+    u_addmask('e', NULL,exempt, from, par, expire_time,flags);
     putlog(LOG_CMDS, "@", "%s: global exempt %s (%s:%s)", dcc[idx].nick, exempt,
     putlog(LOG_CMDS, "@", "%s: global exempt %s (%s:%s)", dcc[idx].nick, exempt,
 	   from, par);
 	   from, par);
     noshare = 0;
     noshare = 0;
@@ -928,7 +928,7 @@ static void share_pls_exemptchan(int idx, char *par)
       expire_time = (time_t) atoi(tm);
       expire_time = (time_t) atoi(tm);
       if (expire_time != 0L)
       if (expire_time != 0L)
 	expire_time += now;
 	expire_time += now;
-      u_addexempt(chan, exempt, from, par, expire_time,flags);
+      u_addmask('e', chan, exempt, from, par, expire_time,flags);
       noshare = 0;
       noshare = 0;
     }
     }
   }
   }
@@ -957,7 +957,7 @@ static void share_pls_invite(int idx, char *par)
     expire_time = (time_t) atoi(tm);
     expire_time = (time_t) atoi(tm);
     if (expire_time != 0L)
     if (expire_time != 0L)
       expire_time += now;
       expire_time += now;
-    u_addinvite(NULL,invite, from, par, expire_time,flags);
+    u_addmask('I', NULL,invite, from, par, expire_time,flags);
     putlog(LOG_CMDS, "@", "%s: global invite %s (%s:%s)", dcc[idx].nick,
     putlog(LOG_CMDS, "@", "%s: global invite %s (%s:%s)", dcc[idx].nick,
 	   invite, from, par);
 	   invite, from, par);
     noshare = 0;
     noshare = 0;
@@ -1000,7 +1000,7 @@ static void share_pls_invitechan(int idx, char *par)
       expire_time = (time_t) atoi(tm);
       expire_time = (time_t) atoi(tm);
       if (expire_time != 0L)
       if (expire_time != 0L)
 	expire_time += now;
 	expire_time += now;
-      u_addinvite(chan, invite, from, par, expire_time,flags);
+      u_addmask('I', chan, invite, from, par, expire_time,flags);
       noshare = 0;
       noshare = 0;
     }
     }
   }
   }
@@ -1748,23 +1748,23 @@ void finish_share(int idx)
   noshare = 1;
   noshare = 1;
   fr.match = (FR_CHAN | FR_BOT);
   fr.match = (FR_CHAN | FR_BOT);
   while (global_bans)
   while (global_bans)
-    u_delban(NULL, global_bans->mask, 1);
+    u_delmask('b', NULL, global_bans->mask, 1);
   while (global_ign)
   while (global_ign)
     delignore(global_ign->igmask);
     delignore(global_ign->igmask);
   while (global_invites)
   while (global_invites)
-    u_delinvite(NULL, global_invites->mask, 1);
+    u_delmask('I', NULL, global_invites->mask, 1);
   while (global_exempts)
   while (global_exempts)
-    u_delexempt(NULL, global_exempts->mask, 1);
+    u_delmask('e', NULL, global_exempts->mask, 1);
   for (chan = chanset; chan; chan = chan->next)
   for (chan = chanset; chan; chan = chan->next)
     if (channel_shared(chan)) {
     if (channel_shared(chan)) {
       get_user_flagrec(dcc[j].user, &fr, chan->dname);
       get_user_flagrec(dcc[j].user, &fr, chan->dname);
       if (bot_chan(fr) || bot_global(fr)) {
       if (bot_chan(fr) || bot_global(fr)) {
 	while (chan->bans)
 	while (chan->bans)
-	  u_delban(chan, chan->bans->mask, 1);
+	  u_delmask('b', chan, chan->bans->mask, 1);
 	while (chan->exempts)
 	while (chan->exempts)
-	  u_delexempt(chan, chan->exempts->mask, 1);
+	  u_delmask('e', chan, chan->exempts->mask, 1);
 	while (chan->invites)
 	while (chan->invites)
-	  u_delinvite(chan, chan->invites->mask, 1);
+	  u_delmask('I', chan, chan->invites->mask, 1);
       }
       }
     }
     }
   noshare = 0;
   noshare = 0;