]> jfr.im git - irc/quakenet/newserv.git/blame_incremental - chandump/chandump.c
CHANSERV: better batcher error handling for expired accounts/accounts with no email.
[irc/quakenet/newserv.git] / chandump / chandump.c
... / ...
CommitLineData
1#include <stdio.h>
2#include <string.h>
3
4#include "../core/schedule.h"
5#include "../channel/channel.h"
6#include "../lib/version.h"
7
8MODULE_VERSION("");
9
10void *dumpsched;
11
12void dodump(void *arg) {
13 chanindex *c;
14 int i;
15 nick *n;
16 char buf[512];
17
18 FILE *fp = fopen("chandump/chandump.txt.1", "w");
19 if(!fp)
20 return;
21
22 fprintf(fp, "M T %lld\n", (unsigned long long)time(NULL));
23
24 for(i=0;i<CHANNELHASHSIZE;i++)
25 for(c=chantable[i];c;c=c->next)
26 if(c->channel && !IsSecret(c->channel))
27 fprintf(fp, "C %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:"");
28
29 for(i=0;i<NICKHASHSIZE;i++)
30 for(n=nicktable[i];n;n=n->next)
31 fprintf(fp, "N %s %s %s %s %s\n", n->nick, n->ident, strchr(visibleuserhost(n, buf), '@') + 1, (IsAccount(n) && n->authname) ? n->authname : "0", n->realname->name->content);
32
33 fclose(fp);
34
35 rename("chandump/chandump.txt.1", "chandump/chandump.txt");
36}
37
38void _init() {
39 dumpsched = (void *)schedulerecurring(time(NULL), 0, 60, &dodump, NULL);
40}
41
42void _fini() {
43 deleteschedule(dumpsched, &dodump, NULL);
44}