]> jfr.im git - irc/quakenet/newserv.git/blame - helpmod2/hstat.h
Large reorganisation of all Makefiles, including new configure script.
[irc/quakenet/newserv.git] / helpmod2 / hstat.h
CommitLineData
c86edd1d
Q
1#ifndef HSTAT_H
2#define HSTAT_H
3
4#include "hdef.h"
5
6extern int hstat_cycle;
7extern time_t hstat_last_cycle;
8
e908ecfa 9/* forward declarations */
e908ecfa 10struct hchannel_struct;
11struct huser_struct;
12
13#define HSTAT_ACTIVITY_TRESHOLD (3 * HDEF_m)
c86edd1d
Q
14
15#define HSTAT_ACCOUNT_SUM(sum, op1, op2)\
16{\
17 (sum).time_spent = (op1).time_spent + (op2).time_spent;\
18 (sum).prime_time_spent = (op1).prime_time_spent + (op2).prime_time_spent;\
19 (sum).lines = (op1).lines + (op2).lines;\
20 (sum).words = (op1).words + (op2).words;\
21}
22
23#define HSTAT_ACCOUNT_ZERO(target)\
24{\
25 (target).time_spent = 0;\
26 (target).prime_time_spent = 0;\
27 (target).lines = 0;\
28 (target).words = 0;\
29}
30
31#define HSTAT_CHANNEL_SUM(sum, op1, op2)\
32{\
3a839281 33 (sum).active_time = (op1).active_time + (op2).active_time;\
34 (sum).staff_active_time = (op1).staff_active_time + (op2).staff_active_time;\
c86edd1d
Q
35 (sum).time_spent = (op1).time_spent + (op2).time_spent;\
36 (sum).prime_time_spent = (op1).prime_time_spent + (op2).prime_time_spent;\
37 (sum).lines = (op1).lines + (op2).lines;\
38 (sum).words = (op1).words + (op2).words;\
39 (sum).joins = (op1).joins + (op2).joins;\
40 (sum).queue_use = (op1).queue_use + (op2).queue_use;\
41}
42
43#define HSTAT_CHANNEL_ZERO(target)\
44{\
3a839281 45 (target).active_time = 0;\
46 (target).staff_active_time = 0;\
c86edd1d
Q
47 (target).time_spent = 0;\
48 (target).prime_time_spent = 0;\
49 (target).lines = 0;\
50 (target).words = 0;\
51 (target).joins = 0;\
52 (target).queue_use = 0;\
53}
54
55typedef enum
56{
57 HSTAT_ACCOUNT_SHORT,
58 HSTAT_ACCOUNT_LONG,
59 HSTAT_CHANNEL_SHORT,
60 HSTAT_CHANNEL_LONG
61} hstat_type;
62
63typedef struct hstat_account_entry_struct
64{
65 int time_spent;
66 int prime_time_spent;
67 int lines;
68 int words;
69} hstat_account_entry;
70
71typedef struct hstat_account_entry_sum_struct
72{
73 int time_spent;
74 int prime_time_spent;
75 int lines;
76 int words;
e908ecfa 77 struct haccount_struct *owner; /* haccount* */
c86edd1d
Q
78} hstat_account_entry_sum;
79
80typedef struct hstat_channel_entry_struct
81{
3a839281 82 int active_time;
83 int staff_active_time;
84
c86edd1d
Q
85 int time_spent;
86 int prime_time_spent;
87
88 int joins;
89 int queue_use;
90
91 int lines;
92 int words;
93} hstat_channel_entry;
94
95typedef struct hstat_channel_struct
96{
97 hstat_channel_entry week[7]; /* 7 days */
98 hstat_channel_entry longterm[10]; /* 10 weeks */
99
100} hstat_channel;
101
102typedef struct hstats_account_struct
103{
104 struct hchannel_struct *hchan;
105
106 hstat_account_entry week[7]; /* 7 days */
107 hstat_account_entry longterm[10]; /* 10 weeks */
108
109 struct hstats_account_struct *next;
110} hstat_account;
111
112typedef struct hstat_accounts_array_struct
113{
114 hstat_account_entry_sum *array;
115 int arrlen;
116} hstat_accounts_array;
117
052247fa
CP
118typedef enum
119{
120 HSTAT_ACCOUNT_ARRAY_TOP10,
121 HSTAT_ACCOUNT_ARRAY_WEEKSTATS
122} hstat_account_array_type;
123
c86edd1d 124/* free() this.entries, arguments: channel, level to list */
052247fa 125hstat_accounts_array create_hstat_account_array(struct hchannel_struct*, hlevel, hstat_account_array_type);
c86edd1d
Q
126
127hstat_channel *get_hstat_channel(void);
128hstat_account *get_hstat_account(void);
129
130const char *hstat_header(hstat_type);
131
132const char *hstat_channel_print(hstat_channel_entry*, int);
133
134const char *hstat_account_print(hstat_account_entry*, int);
135
3a839281 136void hstat_calculate_account(struct hchannel_struct*, struct huser_struct*, const char *);
137void hstat_calculate_channel(struct hchannel_struct*, struct huser_struct*, const char *);
c86edd1d 138
e908ecfa 139void hstat_add_join(struct hchannel_struct*);
140void hstat_del_channel(struct hchannel_struct*);
c86edd1d 141
e908ecfa 142void hstat_add_queue(struct hchannel_struct*, int);
c86edd1d
Q
143
144int is_prime_time(void); /* tells if now is the "main" time in #feds */
145
146int hstat_week(void);
147int hstat_day(void);
148
149hstat_account_entry_sum hstat_account_last_week(hstat_account*);
150hstat_account_entry_sum hstat_account_last_month(hstat_account*);
151hstat_channel_entry hstat_channel_last_week(hstat_channel*);
152hstat_channel_entry hstat_channel_last_month(hstat_channel*);
153
154int hstat_account_count(hstat_account*);
155
156/* handles the cycle and today -> week -> longterm changes */
157void hstat_scheduler(void);
158int hstat_get_schedule_time(void);
159
160#endif