]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Add chandump
authorChris Porter <redacted>
Sun, 14 May 2006 18:59:00 +0000 (19:59 +0100)
committerChris Porter <redacted>
Sun, 14 May 2006 18:59:00 +0000 (19:59 +0100)
chandump/Makefile [new file with mode: 0644]
chandump/chandump.c [new file with mode: 0644]

diff --git a/chandump/Makefile b/chandump/Makefile
new file mode 100644 (file)
index 0000000..ce8a501
--- /dev/null
@@ -0,0 +1,6 @@
+
+.PHONY: all
+all: chandump.so  
+
+chandump.so: chandump.o
+       ld -shared -Bdynamic -o $@ $^
diff --git a/chandump/chandump.c b/chandump/chandump.c
new file mode 100644 (file)
index 0000000..47e1b06
--- /dev/null
@@ -0,0 +1,32 @@
+#include <stdio.h>
+
+#include "../core/schedule.h"
+#include "../channel/channel.h"
+
+void *dumpsched;
+
+void dodump(void *arg) {
+  chanindex *c;
+  int i;
+
+  FILE *fp = fopen("chandump.txt.1", "w");
+  if(!fp)
+    return;
+
+  for(i=0;i<CHANNELHASHSIZE;i++)
+    for(c=chantable[i];c;c=c->next)
+      if(c->channel && !IsSecret(c->channel))
+        fprintf(fp, "%s %d%s%s\n", c->name->content, c->channel->users->totalusers, (c->channel->topic&&c->channel->topic->content)?" ":"", (c->channel->topic&&c->channel->topic->content)?c->channel->topic->content:"");
+
+  fclose(fp);
+
+  rename("chandump.txt.1", "chandump.txt");
+} 
+
+void _init() {
+  dumpsched = (void *)schedulerecurring(time(NULL), 0, 300, &dodump, NULL);
+}
+
+void _fini() {
+  deleteschedule(dumpsched, &dodump, NULL);
+}