"Fossies" - the Fresh Open Source Software Archive 
Member "postal-0.76/results.cpp" (1 Jan 2012, 1198 Bytes) of package /linux/privat/postal-0.76.tgz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "results.cpp" see the
Fossies "Dox" file reference documentation.
1 #include <stdio.h>
2 #include "postal.h"
3 #include "results.h"
4
5 results::results()
6 : m_connections(0)
7 #ifdef USE_SSL
8 , m_ssl_connections(0)
9 #endif
10 , m_mut(true)
11 , m_msgs(0)
12 , m_bytes(0)
13 , m_errors(0)
14 {
15 }
16
17 results::~results()
18 {
19 m_print();
20 }
21
22 void results::error()
23 {
24 Lock l(m_mut);
25 m_errors++;
26 }
27
28 void results::dataBytes(int bytes)
29 {
30 Lock l(m_mut);
31 m_bytes += bytes;
32 }
33
34 void results::message()
35 {
36 Lock l(m_mut);
37 m_msgs++;
38 }
39
40 void results::connection()
41 {
42 Lock l(m_mut);
43 m_connections++;
44 }
45
46 #ifdef USE_SSL
47 void results::connect_ssl()
48 {
49 Lock l(m_mut);
50 m_ssl_connections++;
51 }
52 #endif
53
54 void results::print()
55 {
56 Lock l(m_mut);
57 m_print();
58 }
59
60 void results::childPrint()
61 {
62 }
63
64 void results::m_print()
65 {
66 time_t now = time(NULL);
67 tm *t = localtime(&now);
68 printf("%02d:%02d,%u,%u,%u", t->tm_hour, t->tm_min, m_msgs
69 , (unsigned int)m_bytes / 1024, m_errors);
70 #ifdef USE_SSL
71 printf(",%d,%d", m_connections, m_ssl_connections);
72 m_ssl_connections = 0;
73 #else
74 printf(",%d", m_connections);
75 #endif
76 childPrint();
77 printf("\n");
78 fflush(NULL);
79 m_msgs = 0;
80 m_connections = 0;
81 m_bytes = m_bytes % 1024;
82 m_errors = 0;
83 }