]> jfr.im git - irc/quakenet/newserv.git/blame - 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
CommitLineData
48a00760
CP
1#include <stdio.h>
2
3#include "../core/schedule.h"
4#include "../channel/channel.h"
87698d77
CP
5#include "../lib/version.h"
6
7MODULE_VERSION("$Id")
48a00760
CP
8
9void *dumpsched;
10
11void dodump(void *arg) {
12 chanindex *c;
13 int i;
14
98bf5864 15 FILE *fp = fopen("chandump/chandump.txt.1", "w");
48a00760
CP
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
98bf5864 26 rename("chandump/chandump.txt.1", "chandump/chandump.txt");
48a00760
CP
27}
28
29void _init() {
30 dumpsched = (void *)schedulerecurring(time(NULL), 0, 300, &dodump, NULL);
31}
32
33void _fini() {
34 deleteschedule(dumpsched, &dodump, NULL);
35}