]> jfr.im git - irc/quakenet/newserv.git/blobdiff - trusts/formats.c
fixes for clang
[irc/quakenet/newserv.git] / trusts / formats.c
index aa427760a3e8bd14bb5b727e2fd136af09be8026..5ca5a152d34b59b4d69eb22a1a007e78645955bc 100644 (file)
@@ -89,9 +89,9 @@ char *dumptg(trustgroup *tg, int oformat) {
   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;
@@ -132,6 +132,9 @@ int parsetg(char *buf, trustgroup *tg, int oformat) {
     return 0;
   *line++ = '\0';
 
+  if(oformat && (id[0] == '#'))
+    id++;
+
   tg->id = strtoul(id, NULL, 10);
   if(!tg->id)
     return 0;
@@ -156,7 +159,7 @@ int parsetg(char *buf, trustgroup *tg, int oformat) {
 
   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, ',');
@@ -170,7 +173,7 @@ int parsetg(char *buf, trustgroup *tg, int oformat) {
   *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) {
@@ -199,6 +202,9 @@ int parseth(char *line, trusthost *th, unsigned int *tgid, int oformat) {
     return 0;
   *line++ = '\0';
 
+  if(oformat && (id[0] == '#'))
+    id++;
+
   *tgid = strtoul(id, NULL, 10);
   if(!*tgid)
     return 0;
@@ -230,7 +236,7 @@ char *rtrim(char *buf) {
   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;