-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstats.h
46 lines (39 loc) · 1.4 KB
/
stats.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#if !defined(MEMBOX_STATS_)
#define MEMBOX_STATS_
#include <stdio.h>
#include <time.h>
struct statistics {
unsigned long nusers; // n. di utenti registrati
unsigned long nonline; // n. di utenti connessi
unsigned long ndelivered; // n. di messaggi testuali consegnati
unsigned long nnotdelivered; // n. di messaggi testuali non ancora consegnati
unsigned long nfiledelivered; // n. di file consegnati
unsigned long nfilenotdelivered; // n. di file non ancora consegnati
unsigned long nerrors; // n. di messaggi di errore
unsigned long incoda;
};
/* aggiungere qui altre funzioni di utilita' per le statistiche */
/**
* @function printStats
* @brief Stampa le statistiche nel file passato come argomento
*
* @param fout descrittore del file aperto in append.
*
* @return 0 in caso di successo, -1 in caso di fallimento
*/
static inline int printStats(FILE *fout) {
extern struct statistics chattyStats;
if (fprintf(fout, "%ld - %ld %ld %ld %ld %ld %ld %ld\n",
(unsigned long)time(NULL),
chattyStats.nusers,
chattyStats.nonline,
chattyStats.ndelivered,
chattyStats.nnotdelivered,
chattyStats.nfiledelivered,
chattyStats.nfilenotdelivered,
chattyStats.nerrors
) < 0) return -1;
fflush(fout);
return 0;
}
#endif /* MEMBOX_STATS_ */