]> jfr.im git - irc/quakenet/newserv.git/blobdiff - glines/glines_store.c
CHANSERV: better batcher error handling for expired accounts/accounts with no email.
[irc/quakenet/newserv.git] / glines / glines_store.c
index 46c16d8195376edd134b51b5364b27aaecba4686..a52f51bc4151f7129ec0437773b3ac0fde66b9a5 100644 (file)
@@ -1,8 +1,11 @@
 #include <stdio.h>
+#include "../lib/version.h"
 #include "../core/schedule.h"
 #include "../control/control.h"
 #include "glines.h"
 
+MODULE_VERSION("");
+
 static int glstore_savefile(const char *file) {
   FILE *fp;
   gline *gl;
@@ -19,7 +22,7 @@ static int glstore_savefile(const char *file) {
     fprintf(fp, "%s %jd,%jd,%jd,%d,%s,%s\n",
       glinetostring(gl), (intmax_t)gl->expire, (intmax_t)gl->lastmod, (intmax_t)gl->lifetime,
       (gl->flags & GLINE_ACTIVE) ? 1 : 0,
-      gl->creator->content, gl->reason->content);
+      gl->creator->content, gl->reason ? gl->reason->content : "");
     count++;
   }
 
@@ -60,7 +63,7 @@ static int glstore_loadfile(const char *file) {
 
     gl->creator = getsstring(creator, 512);
 
-    gl->flags = active ? GLINE_ACTIVE : 0;
+    gl->flags |= active ? GLINE_ACTIVE : 0;
 
     gl->reason = getsstring(reason, 512);
     gl->expire = expire;
@@ -71,6 +74,8 @@ static int glstore_loadfile(const char *file) {
     glinelist = gl;
   }
 
+  fclose(fp);
+
   return count;
 }
 
@@ -105,58 +110,6 @@ int glstore_load(void) {
   return glstore_loadfile(path);
 }
 
-static int glines_cmdcleanupglines(void *source, int cargc, char **cargv) {
-  nick *sender = source;
-  gline **pnext, *gl;
-  int count;
-  time_t now;
-  
-  count = 0;
-  time(&now);
-  
-  for (pnext = &glinelist; *pnext;) {
-    gl = *pnext;
-    
-    /* Remove inactivate glines that have been last changed more than a week ago */
-    if (!(gl->flags & GLINE_ACTIVE) && gl->lastmod < now - 7 * 24 * 60 * 60) {
-      gline_destroy(gl, 0, 1);
-      count++;
-    } else {
-      pnext = &((*pnext)->next);
-    }
-    
-    if (!*pnext)
-      break;
-  }
-  
-  controlwall(NO_OPER, NL_GLINES, "%s CLEANUPGLINES'd %d G-Lines.",
-    controlid(sender), count);
-  
-  controlreply(sender, "Done.");
-  
-  return CMD_OK;
-}
-
-static int glines_cmdsyncglines(void *source, int cargc, char **cargv) {
-  nick *sender = source;
-  gline *gl;
-  int count;
-
-  count = 0;
-
-  for (gl = glinelist; gl; gl = gl->next) {
-    gline_propagate(gl);
-    count++;
-  }
-  
-  controlwall(NO_OPER, NL_GLINES, "%s SYNCGLINE'd %d G-Lines.",
-    controlid(sender), count);
-
-  controlreply(sender, "Done.");
-
-  return CMD_OK;
-}
-
 static int glines_cmdsaveglines(void *source, int cargc, char **cargv) {
   nick *sender = source;
   int count;
@@ -190,8 +143,6 @@ static void glines_sched_save(void *arg) {
 }
 
 void _init() {
-  registercontrolhelpcmd("cleanupglines", NO_OPER, 0, glines_cmdcleanupglines, "Usage: cleanupglines\nDestroys all deactivated G-Lines.");
-  registercontrolhelpcmd("syncglines", NO_DEVELOPER, 0, glines_cmdsyncglines, "Usage: syncglines\nSends all G-Lines to all other servers.");
   registercontrolhelpcmd("loadglines", NO_DEVELOPER, 0, glines_cmdloadglines, "Usage: loadglines\nForce load of glines.");
   registercontrolhelpcmd("saveglines", NO_DEVELOPER, 0, glines_cmdsaveglines, "Usage: saveglines\nForce save of glines.");
 
@@ -201,8 +152,6 @@ void _init() {
 }
 
 void _fini() {
-  deregistercontrolcmd("cleanupglines", glines_cmdcleanupglines);
-  deregistercontrolcmd("syncglines", glines_cmdsyncglines);
   deregistercontrolcmd("loadglines", glines_cmdloadglines);
   deregistercontrolcmd("saveglines", glines_cmdsaveglines);