]> jfr.im git - irc/quakenet/newserv.git/blob - chandump/chandump.c
Added module support - UNTESTED, but I've got to commit before the Id tags update.
[irc/quakenet/newserv.git] / chandump / chandump.c
1 #include <stdio.h>
2
3 #include "../core/schedule.h"
4 #include "../channel/channel.h"
5 #include "../lib/version.h"
6
7 MODULE_VERSION("$Id")
8
9 void *dumpsched;
10
11 void dodump(void *arg) {
12 chanindex *c;
13 int i;
14
15 FILE *fp = fopen("chandump/chandump.txt.1", "w");
16 if(!fp)
17 return;
18
19 for(i=0;i<CHANNELHASHSIZE;i++)
20 for(c=chantable[i];c;c=c->next)
21 if(c->channel && !IsSecret(c->channel))
22 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:"");
23
24 fclose(fp);
25
26 rename("chandump/chandump.txt.1", "chandump/chandump.txt");
27 }
28
29 void _init() {
30 dumpsched = (void *)schedulerecurring(time(NULL), 0, 300, &dodump, NULL);
31 }
32
33 void _fini() {
34 deleteschedule(dumpsched, &dodump, NULL);
35 }