]>
Commit | Line | Data |
---|---|---|
1 | #ifndef HSTAT_H | |
2 | #define HSTAT_H | |
3 | ||
4 | #include "hdef.h" | |
5 | ||
6 | extern int hstat_cycle; | |
7 | extern time_t hstat_last_cycle; | |
8 | ||
9 | /* forward declarations */ | |
10 | struct hchannel_struct; | |
11 | struct huser_struct; | |
12 | ||
13 | #define HSTAT_ACTIVITY_TRESHOLD (3 * HDEF_m) | |
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 | {\ | |
33 | (sum).active_time = (op1).active_time + (op2).active_time;\ | |
34 | (sum).staff_active_time = (op1).staff_active_time + (op2).staff_active_time;\ | |
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 | {\ | |
45 | (target).active_time = 0;\ | |
46 | (target).staff_active_time = 0;\ | |
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 | ||
55 | typedef enum | |
56 | { | |
57 | HSTAT_ACCOUNT_SHORT, | |
58 | HSTAT_ACCOUNT_LONG, | |
59 | HSTAT_CHANNEL_SHORT, | |
60 | HSTAT_CHANNEL_LONG | |
61 | } hstat_type; | |
62 | ||
63 | typedef 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 | ||
71 | typedef struct hstat_account_entry_sum_struct | |
72 | { | |
73 | int time_spent; | |
74 | int prime_time_spent; | |
75 | int lines; | |
76 | int words; | |
77 | struct haccount_struct *owner; /* haccount* */ | |
78 | } hstat_account_entry_sum; | |
79 | ||
80 | typedef struct hstat_channel_entry_struct | |
81 | { | |
82 | int active_time; | |
83 | int staff_active_time; | |
84 | ||
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 | ||
95 | typedef 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 | ||
102 | typedef 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 | ||
112 | typedef struct hstat_accounts_array_struct | |
113 | { | |
114 | hstat_account_entry_sum *array; | |
115 | int arrlen; | |
116 | } hstat_accounts_array; | |
117 | ||
118 | typedef enum | |
119 | { | |
120 | HSTAT_ACCOUNT_ARRAY_TOP10, | |
121 | HSTAT_ACCOUNT_ARRAY_WEEKSTATS | |
122 | } hstat_account_array_type; | |
123 | ||
124 | /* free() this.entries, arguments: channel, level to list */ | |
125 | hstat_accounts_array create_hstat_account_array(struct hchannel_struct*, hlevel, hstat_account_array_type); | |
126 | ||
127 | hstat_channel *get_hstat_channel(void); | |
128 | hstat_account *get_hstat_account(void); | |
129 | ||
130 | const char *hstat_header(hstat_type); | |
131 | ||
132 | const char *hstat_channel_print(hstat_channel_entry*, int); | |
133 | ||
134 | const char *hstat_account_print(hstat_account_entry*, int); | |
135 | ||
136 | void hstat_calculate_account(struct hchannel_struct*, struct huser_struct*, const char *); | |
137 | void hstat_calculate_channel(struct hchannel_struct*, struct huser_struct*, const char *); | |
138 | ||
139 | void hstat_add_join(struct hchannel_struct*); | |
140 | void hstat_del_channel(struct hchannel_struct*); | |
141 | ||
142 | void hstat_add_queue(struct hchannel_struct*, int); | |
143 | ||
144 | int is_prime_time(void); /* tells if now is the "main" time in #feds */ | |
145 | ||
146 | int hstat_week(void); | |
147 | int hstat_day(void); | |
148 | ||
149 | hstat_account_entry_sum hstat_account_last_week(hstat_account*); | |
150 | hstat_account_entry_sum hstat_account_last_month(hstat_account*); | |
151 | hstat_channel_entry hstat_channel_last_week(hstat_channel*); | |
152 | hstat_channel_entry hstat_channel_last_month(hstat_channel*); | |
153 | ||
154 | int hstat_account_count(hstat_account*); | |
155 | ||
156 | /* handles the cycle and today -> week -> longterm changes */ | |
157 | void hstat_scheduler(void); | |
158 | int hstat_get_schedule_time(void); | |
159 | ||
160 | #endif |