]> jfr.im git - irc/quakenet/newserv.git/blobdiff - trusts/trusts_commands.c
Merge throttle.
[irc/quakenet/newserv.git] / trusts / trusts_commands.c
index c3c8056aebb07cfd5ffd9df704169c55f9085786..9fd092d3ad2a57fa41ee092f7e4c1d7c4cfc80be 100644 (file)
@@ -18,7 +18,7 @@ static void deregistercommands(int, void *);
 
 extern void printnick_channels(searchCtx *, nick *, nick *);
 
-void calculatespaces(int spaces, int width, char *str, char **_prebuf, char **_postbuf) {
+void calculatespaces(int spaces, int width, const char *str, char **_prebuf, char **_postbuf) {
   static char prebuf[512], postbuf[512];
   int spacelen;
 
@@ -85,12 +85,13 @@ static void marktree(array *parents, unsigned int marker, trusthost *th, int sho
 }
 
 static void outputtree(nick *np, unsigned int marker, trustgroup *originalgroup, trusthost *th, int depth, int showchildren) {
-  char *cidrstr, *prespacebuf, *postspacebuf, parentbuf[512];
+  const char *cidrstr;
+  char *prespacebuf, *postspacebuf, parentbuf[512];
 
   if(th->marker != marker)
     return;
 
-  cidrstr = trusts_cidr2str(&th->ip, th->bits);
+  cidrstr = CIDRtostr(th->ip, th->bits);
   calculatespaces(depth + 2, 30 + 1, cidrstr, &prespacebuf, &postspacebuf);
 
   if(th->group == originalgroup) {
@@ -146,6 +147,13 @@ static char *formatflags(int flags) {
     strncat(buf, "reliable username", 512);
   }
 
+  if(flags & TRUST_UNTHROTTLE) {
+    if(buf[0])
+      strncat(buf, ", ", 512);
+
+    strncat(buf, "unthrottled", 512);
+  }
+
   buf[512-1] = '\0';
 
   return buf;
@@ -264,76 +272,6 @@ static int trusts_cmdtrustlist(void *source, int cargc, char **cargv) {
   return CMD_OK;
 }
 
-static int comparetgs(const void *_a, const void *_b) {
-  const trustgroup *a = _a;
-  const trustgroup *b = _b;
-
-  if(a->id > b->id)
-    return 1;
-  if(a->id < b-> id)
-    return -1;
-  return 0;
-}
-
-static int trusts_cmdtrustdump(void *source, int argc, char **argv) {
-  trusthost *th;
-  trustgroup *tg, **atg;
-  unsigned int wanted, max, maxid, totalcount, i, groupcount, linecount;
-  nick *np = source;
-
-  if((argc < 2) || (argv[0][0] != '#'))
-    return CMD_USAGE;
-
-  wanted = atoi(&argv[0][1]);
-  max = atoi(argv[1]);
-
-  for(maxid=totalcount=0,tg=tglist;tg;tg=tg->next) {
-    if(totalcount == 0 || tg->id > maxid)
-      maxid = tg->id;
-
-    totalcount++;
-  }
-
-  if(maxid > totalcount) {
-    controlreply(np, "Start ID cannot exceed current maximum group ID (#%u)", maxid);
-    return CMD_OK;
-  }
-
-  atg = nsmalloc(POOL_TRUSTS, sizeof(trusthost *) * totalcount);
-  if(!atg) {
-    controlreply(np, "Memory error.");
-    return CMD_ERROR;
-  }
-
-  for(i=0,tg=tglist;i<totalcount&&tg;tg=tg->next,i++)
-    atg[i] = tg;
-
-  qsort(atg, totalcount, sizeof(trustgroup *), comparetgs);
-
-  for(i=0;i<totalcount;i++)
-    if(atg[i]->id >= wanted)
-      break;
-
-  for(groupcount=linecount=0;i<totalcount;i++) {
-    linecount++;
-    groupcount++;
-
-    controlreply(np, "G,%s", dumptg(atg[i], 1));
-
-    for(th=atg[i]->hosts;th;th=th->next) {
-      linecount++;
-      controlreply(np, "H,%s", dumpth(th, 1));
-    }
-
-    if(--max == 0)
-      break;
-  }
-  nsfree(POOL_TRUSTS, atg);
-
-  controlreply(np, "End of list, %u groups and %u lines returned.", groupcount, linecount);
-  return CMD_OK;
-}
-
 static int trusts_cmdtrustglinesuggest(void *source, int cargc, char **cargv) {
   nick *sender = source;
   char mask[512];
@@ -384,7 +322,7 @@ static int trusts_cmdtrustspew(void *source, int cargc, char **cargv) {
     return CMD_USAGE;
 
   tree = NSASTNode(tgroup_parse, NSASTLiteral(cargv[0]));
-  return ast_nicksearch(&tree, controlreply, sender, NULL, printnick_channels, NULL, NULL, 2000);
+  return ast_nicksearch(&tree, controlreply, sender, NULL, printnick_channels, NULL, NULL, 2000, NULL);
 }
 
 static int commandsregistered;
@@ -395,7 +333,6 @@ static void registercommands(int hooknum, void *arg) {
   commandsregistered = 1;
 
   registercontrolhelpcmd("trustlist", NO_OPER, 2, trusts_cmdtrustlist, "Usage: trustlist [-v] <#id|name|IP>\nShows trust data for the specified trust group.");
-  registercontrolhelpcmd("trustdump", NO_OPER, 2, trusts_cmdtrustdump, "Usage: trustdump <#id> <number>");
   registercontrolhelpcmd("trustglinesuggest", NO_OPER, 1, trusts_cmdtrustglinesuggest, "Usage: trustglinesuggest <user@host>\nSuggests glines for the specified hostmask.");
   registercontrolhelpcmd("trustspew", NO_OPER, 1, trusts_cmdtrustspew, "Usage: trustspew <#id|name>\nShows currently connected users for the specified trust group.");
 }
@@ -406,7 +343,6 @@ static void deregistercommands(int hooknum, void *arg) {
   commandsregistered = 0;
 
   deregistercontrolcmd("trustlist", trusts_cmdtrustlist);
-  deregistercontrolcmd("trustdump", trusts_cmdtrustdump);
   deregistercontrolcmd("trustglinesuggest", trusts_cmdtrustglinesuggest);
   deregistercontrolcmd("trustspew", trusts_cmdtrustspew);
 }