+}
+
+static int trusts_cmdtrustlist(void *source, int cargc, char **cargv) {
+ nick *sender = source;
+ trustgroup *tg = NULL;
+ int found = 0, remaining = 50;
+ char *name;
+ trusthost *th;
+ struct irc_in_addr ip;
+ unsigned char bits;
+ int showchildren;
+
+ if(cargc < 1)
+ return CMD_USAGE;
+
+ if(strcmp(cargv[0], "-v") == 0) {
+ if(cargc < 2)
+ return CMD_USAGE;
+
+ showchildren = 1;
+ name = cargv[1];
+ } else {
+ showchildren = 0;
+ name = cargv[0];
+ }
+
+ tg = tg_strtotg(name);
+
+ if(tg) {
+ displaygroup(sender, tg, showchildren);
+ return CMD_OK;
+ }
+
+ if(ipmask_parse(name, &ip, &bits)) {
+ th = th_getbyhost(&ip);
+
+ if(!th) {
+ controlreply(sender, "Specified IP address is not trusted.");
+ return CMD_OK;
+ }
+
+ displaygroup(sender, th->group, showchildren);
+ return CMD_OK;
+ }
+
+ for(tg=tglist;tg;tg=tg->next) {
+ if(match(name, tg->name->content))
+ continue;
+
+ displaygroup(sender, tg, showchildren);
+ if(--remaining == 0) {
+ controlreply(sender, "Maximum number of matches reached.");
+ return CMD_OK;
+ }
+ found = 1;
+ }
+
+ if(!found)
+ controlreply(sender, "No matches found.");
+
+ return CMD_OK;
+}
+
+static int trusts_cmdtrustglinesuggest(void *source, int cargc, char **cargv) {
+ nick *sender = source;
+ char mask[512];
+ char *p, *user, *host;
+ struct irc_in_addr ip;
+ unsigned char bits;
+ int count;
+ glinebuf gbuf;
+ char creator[32];
+
+ if(cargc < 1)
+ return CMD_USAGE;
+
+ strncpy(mask, cargv[0], sizeof(mask));
+
+ p = strchr(mask, '@');
+
+ if(!p)
+ return CMD_USAGE;
+
+ user = mask;
+ host = p + 1;
+ *p = '\0';
+
+ if(!ipmask_parse(host, &ip, &bits)) {
+ controlreply(sender, "Invalid CIDR.");
+ return CMD_ERROR;
+ }
+
+ snprintf(creator, sizeof(creator), "#%s", sender->authname);
+
+ glinebufinit(&gbuf, 0);
+ glinebufaddbyip(&gbuf, user, &ip, 128, 0, creator, "Simulate", getnettime(), getnettime(), getnettime());
+ glinebufcounthits(&gbuf, &count, NULL);
+ glinebufspew(&gbuf, sender);
+ glinebufabort(&gbuf);
+
+ controlreply(sender, "Total hits: %d", count);