]> jfr.im git - irc/quakenet/newserv.git/commitdiff
maxperuser -> maxperident, NICKLEN -> CREATEDBYLEN, lastmaxuserreset -> lastmaxusereset.
authorChris Porter <redacted>
Mon, 13 Oct 2008 04:48:48 +0000 (05:48 +0100)
committerChris Porter <redacted>
Mon, 13 Oct 2008 04:48:48 +0000 (05:48 +0100)
trusts/data.c
trusts/formats.c
trusts/trusts.h
trusts/trusts_commands.c
trusts/trusts_db.c
trusts/trusts_management.c

index 5c30046b262616114047a62a5cb4da4f7ac7d26c..5aeae8116aa76eee0bf9940bf994c02dce0335ef 100644 (file)
@@ -121,7 +121,7 @@ trustgroup *tg_add(trustgroup *itg) {
   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) {
@@ -436,7 +436,7 @@ int tg_modify(trustgroup *oldtg, trustgroup *newtg) {
   /* 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) {
@@ -454,7 +454,7 @@ int tg_modify(trustgroup *oldtg, trustgroup *newtg) {
   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));
 
index d35570448cd9cd8c9b58b1aa23b7f0c40e726e53..47f1d053d8c45278404dc5f077d1a9986af41d7d 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;
@@ -159,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, ',');
@@ -173,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) {
index de5523d5ea5b6097971b55b7480e9db62c84edc5..d9685046f44d3dfe4274cecc5f12cbe0172cbbef 100644 (file)
@@ -13,6 +13,8 @@
 #define COMMENTLEN 300
 #define TRUSTNAMELEN 100
 #define TRUSTHOSTLEN 100
+#define CREATEDBYLEN NICKLEN + 1
+
 #define MAXTGEXTS 5
 
 #define MAXTRUSTEDFOR 50000
@@ -39,7 +41,6 @@ typedef struct trusthost {
 
   unsigned int count;
 
-
   struct trusthost *parent, *children;
   unsigned int marker;
 
@@ -57,7 +58,7 @@ typedef struct trustgroup {
   unsigned int maxusage;
   time_t expires;
   time_t lastseen;
-  time_t lastmaxuserreset;
+  time_t lastmaxusereset;
   sstring *createdby, *contact, *comment;
 
   trusthost *hosts;
index 0a2f4e0bcbd0d417dd750a83b2b35c1fef27c278..2aee70c73ecb701b1d142f53e7a1618ad2e1758f 100644 (file)
@@ -130,7 +130,7 @@ static int trusts_cmdtrustlist(void *source, int cargc, char **cargv) {
   controlreply(sender, "ID:              : %u", tg->id);
   controlreply(sender, "Last used        : %s", (tg->count>0)?"(now)":((tg->lastseen>0)?trusts_timetostr(tg->lastseen):"(never)"));
   controlreply(sender, "Max usage        : %d", tg->maxusage);
-  controlreply(sender, "Last max reset   : %s", tg->lastmaxuserreset?trusts_timetostr(tg->lastmaxuserreset):"(never)");
+  controlreply(sender, "Last max reset   : %s", tg->lastmaxusereset?trusts_timetostr(tg->lastmaxusereset):"(never)");
 
   controlreply(sender, "Host                 Current    Max        Last seen            Group ID   Group name");
 
index a24958ea21fa3994b0a1995e98d87e862599336e..2ed5dc38abb44867fc56a4a50ab8ee8f10079b0e 100644 (file)
@@ -30,8 +30,8 @@ void createtrusttables(int mode) {
   }
 
   trustsdb->createtable(trustsdb, NULL, NULL,
-    "CREATE TABLE ? (id INT PRIMARY KEY, name VARCHAR(?), trustedfor INT, mode INT, maxperident INT, maxusage INT, expires INT, lastseen INT, lastmaxuserreset INT, createdby VARCHAR(?), contact VARCHAR(?), comment VARCHAR(?))",
-    "Tdddd", groups, TRUSTNAMELEN, NICKLEN, CONTACTLEN, COMMENTLEN
+    "CREATE TABLE ? (id INT PRIMARY KEY, name VARCHAR(?), trustedfor INT, mode INT, maxperident INT, maxusage INT, expires INT, lastseen INT, lastmaxusereset INT, createdby VARCHAR(?), contact VARCHAR(?), comment VARCHAR(?))",
+    "Tdddd", groups, TRUSTNAMELEN, CREATEDBYLEN, CONTACTLEN, COMMENTLEN
   );
 
   /* I'd like multiple keys here but that's not gonna happen on a cross-database platform :( */
@@ -155,8 +155,8 @@ static void loadgroups_data(const DBAPIResult *result, void *tag) {
     tg.maxusage = strtoul(result->get(result, 5), NULL, 10);
     tg.expires = (time_t)strtoul(result->get(result, 6), NULL, 10);
     tg.lastseen = (time_t)strtoul(result->get(result, 7), NULL, 10);
-    tg.lastmaxuserreset = (time_t)strtoul(result->get(result, 8), NULL, 10);
-    tg.createdby = getsstring(rtrim(result->get(result, 9)), NICKLEN);
+    tg.lastmaxusereset = (time_t)strtoul(result->get(result, 8), NULL, 10);
+    tg.createdby = getsstring(rtrim(result->get(result, 9)), CREATEDBYLEN);
     tg.contact = getsstring(rtrim(result->get(result, 10)), CONTACTLEN);
     tg.comment = getsstring(rtrim(result->get(result, 11)), COMMENTLEN);
 
@@ -289,7 +289,7 @@ trustgroup *tg_new(trustgroup *itg) {
   itg->id = tgmaxid + 1;
   itg->maxusage = 0;
   itg->lastseen = 0;
-  itg->lastmaxuserreset = 0;
+  itg->lastmaxusereset = 0;
 
   tg = tg_copy(itg);
   if(!tg)
@@ -309,15 +309,15 @@ void trustsdb_insertth(char *table, trusthost *th, unsigned int groupid) {
 
 void trustsdb_inserttg(char *table, trustgroup *tg) {
   trustsdb->squery(trustsdb,
-    "INSERT INTO ? (id, name, trustedfor, mode, maxperident, maxusage, expires, lastseen, lastmaxuserreset, createdby, contact, comment) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
-    "Tusuuuutttsss", table, tg->id, tg->name->content, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, tg->expires, tg->lastseen, tg->lastmaxuserreset, tg->createdby->content, tg->contact->content, tg->comment->content
+    "INSERT INTO ? (id, name, trustedfor, mode, maxperident, maxusage, expires, lastseen, lastmaxusereset, createdby, contact, comment) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+    "Tusuuuutttsss", table, tg->id, tg->name->content, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, tg->expires, tg->lastseen, tg->lastmaxusereset, tg->createdby->content, tg->contact->content, tg->comment->content
   );
 }
 
 void tg_update(trustgroup *tg) {
   trustsdb->squery(trustsdb,
-    "UPDATE ? SET name = ?, trustedfor = ?, maxperident = ?, maxusage = ?, expires = ?, lastseen = ?, lastmaxuserreset = ?, createdby = ?, contact = ?, comment = ? WHERE id = ?",
-    "Tsuuuutttsssu", "groups", tg->name->content, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, tg->expires, tg->lastseen, tg->lastmaxuserreset, tg->createdby->content, tg->contact->content, tg->comment->content, tg->id
+    "UPDATE ? SET name = ?, trustedfor = ?, maxperident = ?, maxusage = ?, expires = ?, lastseen = ?, lastmaxusereset = ?, createdby = ?, contact = ?, comment = ? WHERE id = ?",
+    "Tsuuuutttsssu", "groups", tg->name->content, tg->trustedfor, tg->mode, tg->maxperident, tg->maxusage, tg->expires, tg->lastseen, tg->lastmaxusereset, tg->createdby->content, tg->contact->content, tg->comment->content, tg->id
   );
 }
 
index e3a40a80ba831e3112d89c23e3c7246750b346f3..c2f8e9a204847956fdf7109b27ef0532d670fc09 100644 (file)
@@ -150,7 +150,7 @@ static int trusts_cmdtrustgroupadd(void *source, int cargc, char **cargv) {
   itg.mode = enforceident;
   itg.maxperident = maxperident;
   itg.expires = howlong + time(NULL);
-  itg.createdby = getsstring(createdby, NICKLEN);
+  itg.createdby = getsstring(createdby, CREATEDBYLEN);
   itg.contact = getsstring(contact, CONTACTLEN);
   itg.comment = getsstring(comment, COMMENTLEN);
   itg.name = getsstring(name, TRUSTNAMELEN);
@@ -283,13 +283,13 @@ static int modifytrustedfor(trustgroup *tg, char *num) {
   return 1;
 }
 
-static int modifymaxperuser(trustgroup *tg, char *num) {
-  unsigned int maxperuser = strtoul(num, NULL, 10);
+static int modifymaxperident(trustgroup *tg, char *num) {
+  unsigned int maxperident = strtoul(num, NULL, 10);
 
-  if(maxperuser > MAXPERIDENT)
+  if(maxperident > MAXPERIDENT)
     return 0;
 
-  tg->maxperident = maxperuser;
+  tg->maxperident = maxperident;
 
   return 1;
 }
@@ -323,7 +323,7 @@ static int trusts_cmdtrustgroupmodify(void *source, int cargc, char **cargv) {
   trustgroup *tg;
   nick *sender = source;
   char *what, *to, validfields[512];
-  struct trustmodification *mods = (struct trustmodification []){ MS(expires), MS(enforceident), MS(maxperuser), MS(contact), MS(comment), MS(trustedfor) };
+  struct trustmodification *mods = (struct trustmodification []){ MS(expires), MS(enforceident), MS(maxperident), MS(contact), MS(comment), MS(trustedfor) };
   int modcount = sizeof(mods) / sizeof(struct trustmodification);
   int i;
   StringBuf b;