static char buf[512];
if(oformat) {
- snprintf(buf, sizeof(buf), "#%u,%s,%u,%u,%d,%u,%u,%jd,%jd,%jd,%s,%s,%s", tg->id, tg->name->content, tg->count, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, (intmax_t)tg->expires, (intmax_t)tg->lastseen, (intmax_t)tg->lastmaxuserreset, tg->createdby->content, tg->contact->content, tg->comment->content);
+ snprintf(buf, sizeof(buf), "#%u,%s,%u,%u,%d,%u,%u,%jd,%jd,%jd,%s,%s,%s", tg->id, tg->name->content, tg->count, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, (intmax_t)tg->expires, (intmax_t)tg->lastseen, (intmax_t)tg->lastmaxusereset, tg->createdby->content, tg->contact->content, tg->comment->content);
} else {
- snprintf(buf, sizeof(buf), "%u,%s,%u,%d,%u,%u,%jd,%jd,%jd,%s,%s,%s", tg->id, tg->name->content, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, (intmax_t)tg->expires, (intmax_t)tg->lastseen, (intmax_t)tg->lastmaxuserreset, tg->createdby->content, tg->contact->content, tg->comment->content);
+ snprintf(buf, sizeof(buf), "%u,%s,%u,%d,%u,%u,%jd,%jd,%jd,%s,%s,%s", tg->id, tg->name->content, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, (intmax_t)tg->expires, (intmax_t)tg->lastseen, (intmax_t)tg->lastmaxusereset, tg->createdby->content, tg->contact->content, tg->comment->content);
}
return buf;
return 0;
*line++ = '\0';
+ if(oformat && (id[0] == '#'))
+ id++;
+
tg->id = strtoul(id, NULL, 10);
if(!tg->id)
return 0;
tg->expires = (time_t)expires;
tg->lastseen = (time_t)lastseen;
- tg->lastmaxuserreset = (time_t)lastmaxusereset;
+ tg->lastmaxusereset = (time_t)lastmaxusereset;
createdby = &line[pos];
contact = strchr(createdby, ',');
*comment++ = '\0';
tg->name = getsstring(name, TRUSTNAMELEN);
- tg->createdby = getsstring(createdby, NICKLEN);
+ tg->createdby = getsstring(createdby, CREATEDBYLEN);
tg->comment = getsstring(comment, COMMENTLEN);
tg->contact = getsstring(contact, CONTACTLEN);
if(!tg->name || !tg->createdby || !tg->comment || !tg->contact) {
return 0;
*line++ = '\0';
+ if(oformat && (id[0] == '#'))
+ id++;
+
*tgid = strtoul(id, NULL, 10);
if(!*tgid)
return 0;
size_t len = strlcpy(obuf, buf, sizeof(obuf));
if((len < sizeof(obuf)) && (len > 0)) {
- size_t i;
+ int i;
for(i=len-1;i>=0;i--) {
if(obuf[i] != ' ')
break;