]> jfr.im git - irc/quakenet/newserv.git/blob - chanstats/chanstats.h
e642926b3b69a5968cf4104a4bb2f29d1724e43b
[irc/quakenet/newserv.git] / chanstats / chanstats.h
1
2 #ifndef __CHANSTATS_H
3 #define __CHANSTATS_H
4
5 #include <time.h>
6 #include "../lib/sstring.h"
7 #include "../channel/channel.h"
8 #include "../parser/parser.h"
9
10 #define SAVEINTERVAL 3600
11 #define SAMPLEINTERVAL 360
12 #define SAMPLEHISTORY 10
13 #define HISTORYDAYS 14
14
15 /* The main stats structure. Everything except the "lastsamples" array needs to be saved/restored */
16
17 typedef struct chanstats {
18 chanindex *index; /* Channel index pointer */
19 unsigned short lastdays[HISTORYDAYS]; /* Average user counts for the last 14 days, stored as (average users * 10) */
20 unsigned char lastdaysamples[HISTORYDAYS]; /* Number of samples taken on each of the last 14 days */
21 unsigned short lastmax[HISTORYDAYS]; /* Max users seen on each of the last 14 days */
22 unsigned short lastsamples[SAMPLEHISTORY]; /* Number of users for the last 10 samples (i.e. 1 hour) */
23 unsigned char todaysamples; /* Number of samples taken today */
24 unsigned int todayusers; /* Total of all of today's samples */
25 unsigned short todaymax; /* Max users seen today */
26 time_t lastsampled; /* When this channel was last sampled */
27 struct chanstats *nextsorted; /* Next channel in sorted order */
28 } chanstats;
29
30 /* These sample counts need to be saved and restored */
31 extern unsigned int totaltodaysamples;
32 extern unsigned int totallastdaysamples[HISTORYDAYS];
33
34 extern int csext;
35
36 extern int uponehour;
37 extern unsigned int lastdaysamples[HISTORYDAYS];
38 extern unsigned int todaysamples;
39
40 extern time_t chanstats_lastsample;
41
42 /* chanstatshash.c */
43 chanstats *findchanstats(const char *channame);
44 chanstats *findchanstatsifexists(const char *channame);
45
46 /* chanstatsalloc.c */
47 void cstsfreeall();
48 void initchanstatsalloc();
49 chanstats *getchanstats();
50 void freechanstats(chanstats *csp);
51
52 /* chansearch.c */
53 void initchansearch();
54 void finichansearch();
55 void regchansearchfunc(const char *name, int args, CommandHandler handler);
56 void unregchansearchfunc(const char *name, CommandHandler handler);
57 int dochansearch(void *source, int cargc, char **cargv);
58
59 #endif