]> jfr.im git - irc/quakenet/newserv.git/blob - authdump/authdump.c
CHANSERV: better batcher error handling for expired accounts/accounts with no email.
[irc/quakenet/newserv.git] / authdump / authdump.c
1 #include <stdio.h>
2
3 #include "../core/schedule.h"
4 #include "../authext/authext.h"
5 #include "../nick/nick.h"
6 #include "../lib/version.h"
7
8 MODULE_VERSION("");
9
10 static void *authdumpsched;
11
12 static void doauthdump(void *arg) {
13 authname *a;
14 nick *np;
15 int i;
16 FILE *fp = fopen("authdump/authdump.txt.1", "w");
17
18 if(!fp)
19 return;
20
21 for(i=0;i<AUTHNAMEHASHSIZE;i++) {
22 for(a=authnametable[i];a;a=a->next) {
23 np = a->nicks;
24 if(!np)
25 continue;
26
27 /* grossly inefficient */
28 fprintf(fp, "%s %lu", np->authname, np->auth->userid);
29 for(;np;np=np->nextbyauthname)
30 fprintf(fp, " %s", np->nick);
31
32 fprintf(fp, "\n");
33 }
34 }
35
36 fclose(fp);
37
38 rename("authdump/authdump.txt.1", "authdump/authdump.txt");
39 }
40
41 void _init() {
42 authdumpsched = (void *)schedulerecurring(time(NULL), 0, 300, &doauthdump, NULL);
43 }
44
45 void _fini() {
46 deleteschedule(authdumpsched, &doauthdump, NULL);
47 }