outputtree(np, marker, originalgroup, th, depth + 1);
}
-static int trusts_cmdtrustlist(void *source, int cargc, char **cargv) {
- nick *sender = source;
- trustgroup *tg;
+static void displaygroup(nick *sender, trustgroup *tg) {
trusthost *th, **p2;
- time_t t;
unsigned int marker;
array parents;
int i;
-
- if(cargc < 1)
- return CMD_USAGE;
-
- tg = tg_strtotg(cargv[0]);
- if(!tg) {
- controlreply(sender, "Couldn't find a trustgroup with that id.");
- return CMD_ERROR;
- }
-
- t = time(NULL);
+ time_t t = time(NULL);
/* abusing the ternary operator a bit :( */
controlreply(sender, "Name: : %s", tg->name->content);
array_free(&parents);
controlreply(sender, "End of list.");
+}
+
+static int trusts_cmdtrustlist(void *source, int cargc, char **cargv) {
+ nick *sender = source;
+ trustgroup *tg = NULL;
+ int found = 0, remaining = 50;
+ char *name;
+
+ if(cargc < 1)
+ return CMD_USAGE;
+
+ name = cargv[0];
+
+ tg = tg_strtotg(name);
+
+ if(tg) {
+ displaygroup(sender, tg);
+ return CMD_OK;
+ }
+
+ for(tg=tglist;tg;tg=tg->next) {
+ if(match(name, tg->name->content))
+ continue;
+
+ displaygroup(sender, tg);
+ 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;
}
return CMD_ERROR;
}
- for(i=0,tg=tglist;i<totalcount&&th;tg=tg->next,i++)
+ for(i=0,tg=tglist;i<totalcount&&tg;tg=tg->next,i++)
atg[i] = tg;
qsort(atg, totalcount, sizeof(trustgroup *), comparetgs);