/* legacy format */
if(name[0] == '#') {
- id = strtoul(&name[1], NULL, 10);
- if(!id)
+ char *endp;
+ id = strtoul(&name[1], &endp, 10);
+ if(!id || *endp)
return NULL;
- for(tg=tglist;tg;tg=tg->next)
- if(tg->id == id)
- return tg;
+ return tg_getbyid(id);
}
for(tg=tglist;tg;tg=tg->next)
- if(!match(name, tg->name->content))
- return tg;
-
- id = strtoul(name, NULL, 10);
- if(!id)
- return NULL;
-
- /* legacy format */
- for(tg=tglist;tg;tg=tg->next)
- if(tg->id == id)
+ if(!strcmp(name, tg->name->content))
return tg;
return NULL;
static int trusts_cmdtrustlist(void *source, int cargc, char **cargv) {
nick *sender = source;
- char *name;
trustgroup *tg = NULL;
- int id, found = 0, remaining = 50;
+ int found = 0, remaining = 50;
+ char *name;
if(cargc < 1)
return CMD_USAGE;
name = cargv[0];
- if(name[0] == '#')
- tg = tg_strtotg(name + 1);
-
- if((id = strtol(name, NULL, 10)))
- tg = tg_getbyid(id);
+ tg = tg_strtotg(name);
if(tg) {
displaygroup(sender, tg);