memcpy(tg, itg, sizeof(trustgroup));
tg->name = getsstring(tg->name->content, TRUSTNAMELEN);
- tg->createdby = getsstring(tg->createdby->content, NICKLEN);
+ tg->createdby = getsstring(tg->createdby->content, CREATEDBYLEN);
tg->contact = getsstring(tg->contact->content, CONTACTLEN);
tg->comment = getsstring(tg->comment->content, COMMENTLEN);
if(!tg->name || !tg->createdby || !tg->contact || !tg->comment) {
/* 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;
/* unfortunately we can't just memcpy the new one over */
vnewtg.name = getsstring(newtg->name->content, TRUSTNAMELEN);
- vnewtg.createdby = getsstring(newtg->createdby->content, NICKLEN);
+ vnewtg.createdby = getsstring(newtg->createdby->content, CREATEDBYLEN);
vnewtg.contact = getsstring(newtg->contact->content, CONTACTLEN);
vnewtg.comment = getsstring(newtg->comment->content, COMMENTLEN);
- if(!vnewtg.name || !vnewtg.createdby || !vnewtg.contact || vnewtg.comment) {
+ if(!vnewtg.name || !vnewtg.createdby || !vnewtg.contact || !vnewtg.comment) {
freesstring(vnewtg.name);
freesstring(vnewtg.createdby);
freesstring(vnewtg.contact);
vnewtg.maxusage = newtg->maxusage;
vnewtg.expires = newtg->expires;
vnewtg.lastseen = newtg->lastseen;
- vnewtg.lastmaxuserreset = newtg->lastmaxuserreset;
+ vnewtg.lastmaxusereset = newtg->lastmaxusereset;
memcpy(oldtg, &vnewtg, sizeof(trustgroup));