]> jfr.im git - irc/quakenet/newserv.git/blobdiff - glines/glines_util.c
BUILD: add require-all build mode
[irc/quakenet/newserv.git] / glines / glines_util.c
index da34935e28216bbc8b1a93458a930262d0bf7078..a8410b1930b4980c0784f6a8d3509ed9cac847f6 100644 (file)
@@ -7,7 +7,7 @@ int glinebyip(const char *user, struct irc_in_addr *ip, unsigned char bits, int
   int hits;
 
   glinebufinit(&gbuf, 0);
-  glinebufcommentf(&gbuf, "on IP mask %s@%s, set by %s", user, trusts_cidr2str(ip, bits), creator);
+  glinebufcommentf(&gbuf, "on IP mask %s@%s, set by %s", user, CIDRtostr(*ip, bits), creator);
   glinebufaddbyip(&gbuf, user, ip, bits, flags, creator, reason, getnettime() + duration, getnettime(), getnettime() + duration);
 
   glinebufcounthits(&gbuf, &hits, NULL);
@@ -20,22 +20,27 @@ int glinebyip(const char *user, struct irc_in_addr *ip, unsigned char bits, int
   return hits;
 }
 
-int glinebynick(nick *np, int duration, const char *reason, int flags, const char *creator) {
+glineinfo *glinebynickex(nick *np, int duration, const char *reason, int flags, const char *creator) {
+  static glineinfo info;
   glinebuf gbuf;
-  int hits;
 
   glinebufinit(&gbuf, 0);
   glinebufcommentf(&gbuf, "on nick %s!%s@%s, set by %s", np->nick, np->ident, np->host->name->content, creator);
-  glinebufaddbynick(&gbuf, np, flags, creator, reason, getnettime() + duration, getnettime(), getnettime() + duration);
+  info.mask = glinebufaddbynick(&gbuf, np, flags, creator, reason, getnettime() + duration, getnettime(), getnettime() + duration);
 
-  glinebufcounthits(&gbuf, &hits, NULL);
+  glinebufcounthits(&gbuf, &info.hits, NULL);
 
   if (flags & GLINE_SIMULATE)
     glinebufabort(&gbuf);
   else
     glinebufcommit(&gbuf, 1);
 
-  return hits;
+  return &info;
+}
+
+int glinebynick(nick *np, int duration, const char *reason, int flags, const char *creator) {
+  glineinfo *result = glinebynickex(np, duration, reason, flags, creator);
+  return result->hits;
 }
 
 void glineunsetmask(const char *mask) {