6 extern int hstat_cycle
;
7 extern time_t hstat_last_cycle
;
9 #define HSTAT_ACTIVITY_TRESHOLD (3 * 60)
11 #define HSTAT_ACCOUNT_SUM(sum, op1, op2)\
13 (sum).time_spent = (op1).time_spent + (op2).time_spent;\
14 (sum).prime_time_spent = (op1).prime_time_spent + (op2).prime_time_spent;\
15 (sum).lines = (op1).lines + (op2).lines;\
16 (sum).words = (op1).words + (op2).words;\
19 #define HSTAT_ACCOUNT_ZERO(target)\
21 (target).time_spent = 0;\
22 (target).prime_time_spent = 0;\
27 #define HSTAT_CHANNEL_SUM(sum, op1, op2)\
29 (sum).time_spent = (op1).time_spent + (op2).time_spent;\
30 (sum).prime_time_spent = (op1).prime_time_spent + (op2).prime_time_spent;\
31 (sum).lines = (op1).lines + (op2).lines;\
32 (sum).words = (op1).words + (op2).words;\
33 (sum).joins = (op1).joins + (op2).joins;\
34 (sum).queue_use = (op1).queue_use + (op2).queue_use;\
37 #define HSTAT_CHANNEL_ZERO(target)\
39 (target).time_spent = 0;\
40 (target).prime_time_spent = 0;\
44 (target).queue_use = 0;\
55 typedef struct hstat_account_entry_struct
61 } hstat_account_entry
;
63 typedef struct hstat_account_entry_sum_struct
69 void *owner
; /* haccount* */
70 } hstat_account_entry_sum
;
72 typedef struct hstat_channel_entry_struct
82 } hstat_channel_entry
;
84 typedef struct hstat_channel_struct
86 hstat_channel_entry week
[7]; /* 7 days */
87 hstat_channel_entry longterm
[10]; /* 10 weeks */
91 typedef struct hstats_account_struct
93 struct hchannel_struct
*hchan
;
95 hstat_account_entry week
[7]; /* 7 days */
96 hstat_account_entry longterm
[10]; /* 10 weeks */
98 struct hstats_account_struct
*next
;
101 typedef struct hstat_accounts_array_struct
103 hstat_account_entry_sum
*array
;
105 } hstat_accounts_array
;
107 /* free() this.entries, arguments: channel, level to list */
108 hstat_accounts_array
create_hstat_account_array(void*, hlevel
);
110 hstat_channel
*get_hstat_channel(void);
111 hstat_account
*get_hstat_account(void);
113 const char *hstat_header(hstat_type
);
115 const char *hstat_channel_print(hstat_channel_entry
*, int);
117 const char *hstat_account_print(hstat_account_entry
*, int);
119 /* void* = hchannel*, huser* */
120 void hstat_calculate_general(void*, void*, const char *);
122 /* void* = hchannel* */
123 void hstat_add_join(void*);
124 void hstat_del_channel(void*);
126 /* void* = hchannel* */
127 void hstat_add_queue(void*, int);
129 int is_prime_time(void); /* tells if now is the "main" time in #feds */
131 int hstat_week(void);
134 hstat_account_entry_sum
hstat_account_last_week(hstat_account
*);
135 hstat_account_entry_sum
hstat_account_last_month(hstat_account
*);
136 hstat_channel_entry
hstat_channel_last_week(hstat_channel
*);
137 hstat_channel_entry
hstat_channel_last_month(hstat_channel
*);
139 int hstat_account_count(hstat_account
*);
141 /* handles the cycle and today -> week -> longterm changes */
142 void hstat_scheduler(void);
143 int hstat_get_schedule_time(void);