]>
Commit | Line | Data |
---|---|---|
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 | ||
8 | MODULE_VERSION(""); | |
9 | ||
10 | void *dumpsched; | |
11 | ||
12 | void 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 | ||
38 | void _init() { | |
39 | dumpsched = (void *)schedulerecurring(time(NULL), 0, 60, &dodump, NULL); | |
40 | } | |
41 | ||
42 | void _fini() { | |
43 | deleteschedule(dumpsched, &dodump, NULL); | |
44 | } |