diff --git a/src/stats.c b/src/stats.c index a614da1..0b60071 100644 --- a/src/stats.c +++ b/src/stats.c @@ -58,27 +58,9 @@ void init_stats (void) /* * Display the statics of the tinyproxy server. */ -int showstats (struct conn_s *connptr) +int +showstats (struct conn_s *connptr) { - static const char *msg = - "\n" - "\n" - "\n" - "
\n"
- "Number of open connections: %lu
\n"
- "Number of requests: %lu
\n"
- "Number of bad connections: %lu
\n"
- "Number of denied connections: %lu
\n"
- "Number of refused connections due to high load: %lu\n"
- "
Generated by %s version %s.
\n" "\n" - "\n"; - char *message_buffer; char opens[16], reqs[16], badconns[16], denied[16], refused[16]; FILE *statfile; @@ -94,14 +76,33 @@ int showstats (struct conn_s *connptr) if (!message_buffer) return -1; - snprintf (message_buffer, MAXBUFFSIZE, msg, - PACKAGE, VERSION, PACKAGE, VERSION, - stats->num_open, - stats->num_reqs, - stats->num_badcons, stats->num_denied, - stats->num_refused, PACKAGE, VERSION); + snprintf + (message_buffer, MAXBUFFSIZE, + "\n" + "\n" + "\n" + "\n"
+ "Number of open connections: %lu
\n"
+ "Number of requests: %lu
\n"
+ "Number of bad connections: %lu
\n"
+ "Number of denied connections: %lu
\n"
+ "Number of refused connections due to high load: %lu\n"
+ "
Generated by %s version %s.
\n" "\n" + "\n", + PACKAGE, VERSION, PACKAGE, VERSION, + stats->num_open, + stats->num_reqs, + stats->num_badcons, stats->num_denied, + stats->num_refused, PACKAGE, VERSION); - if (send_http_message (connptr, 200, "OK", message_buffer) < 0) { + if (send_http_message (connptr, 200, "OK", + message_buffer) < 0) { safefree (message_buffer); return -1; }