From 1df928b3ab324b955a24a9d537b3d05b4700ec2f Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 2 Jan 2013 12:07:50 +0100 Subject: [PATCH] Extend info command with hostname and YAZ SHA1 Indent results for both command stat and info. --- src/http_command.c | 43 ++++++++++++++++++++++++++++--------------- test/test_http_2.res | 23 ++++++++++++----------- test/test_icu_2.res | 23 ++++++++++++----------- 3 files changed, 52 insertions(+), 37 deletions(-) diff --git a/src/http_command.c b/src/http_command.c index 65be27c..d1af016 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1355,17 +1355,17 @@ static void cmd_stat(struct http_channel *c) } response_open_no_status(c, "stat"); - wrbuf_printf(c->wrbuf, "%d\n", clients); - wrbuf_printf(c->wrbuf, "" ODR_INT_PRINTF "\n", stat.num_hits); - wrbuf_printf(c->wrbuf, "%d\n", stat.num_records); - wrbuf_printf(c->wrbuf, "%d\n", stat.num_clients); - wrbuf_printf(c->wrbuf, "%d\n", stat.num_no_connection); - wrbuf_printf(c->wrbuf, "%d\n", stat.num_connecting); - wrbuf_printf(c->wrbuf, "%d\n", stat.num_working); - wrbuf_printf(c->wrbuf, "%d\n", stat.num_idle); - wrbuf_printf(c->wrbuf, "%d\n", stat.num_failed); - wrbuf_printf(c->wrbuf, "%d\n", stat.num_error); - wrbuf_printf(c->wrbuf, "%.2f\n", progress); + wrbuf_printf(c->wrbuf, "\n %d\n", clients); + wrbuf_printf(c->wrbuf, " " ODR_INT_PRINTF "\n", stat.num_hits); + wrbuf_printf(c->wrbuf, " %d\n", stat.num_records); + wrbuf_printf(c->wrbuf, " %d\n", stat.num_clients); + wrbuf_printf(c->wrbuf, " %d\n", stat.num_no_connection); + wrbuf_printf(c->wrbuf, " %d\n", stat.num_connecting); + wrbuf_printf(c->wrbuf, " %d\n", stat.num_working); + wrbuf_printf(c->wrbuf, " %d\n", stat.num_idle); + wrbuf_printf(c->wrbuf, " %d\n", stat.num_failed); + wrbuf_printf(c->wrbuf, " %d\n", stat.num_error); + wrbuf_printf(c->wrbuf, " %.2f\n", progress); response_close(c, "stat"); release_session(c, s); } @@ -1373,26 +1373,39 @@ static void cmd_stat(struct http_channel *c) static void cmd_info(struct http_channel *c) { char yaz_version_str[20]; + char yaz_sha1_str[42]; response_open_no_status(c, "info"); - wrbuf_puts(c->wrbuf, " \n"); + wrbuf_puts(c->wrbuf, "\n \n"); wrbuf_puts(c->wrbuf, " wrbuf, " sha1=\"%s\"", PAZPAR2_VERSION_SHA1); #endif wrbuf_puts(c->wrbuf, ">"); wrbuf_xmlputs(c->wrbuf, VERSION); - wrbuf_puts(c->wrbuf, ""); + wrbuf_puts(c->wrbuf, "\n"); - yaz_version(yaz_version_str, 0); + yaz_version(yaz_version_str, yaz_sha1_str); wrbuf_puts(c->wrbuf, " wrbuf, YAZ_VERSION); + wrbuf_puts(c->wrbuf, "\" sha1=\""); + wrbuf_xmlputs(c->wrbuf, yaz_sha1_str); wrbuf_puts(c->wrbuf, "\">"); wrbuf_xmlputs(c->wrbuf, yaz_version_str); wrbuf_puts(c->wrbuf, "\n"); wrbuf_puts(c->wrbuf, " \n"); - +#if HAVE_UNISTD_H + { + char hostname_str[64]; + if (gethostname(hostname_str, sizeof(hostname_str)) == 0) + { + wrbuf_puts(c->wrbuf, " "); + wrbuf_xmlputs(c->wrbuf, hostname_str); + wrbuf_puts(c->wrbuf, "\n"); + } + } +#endif info_services(c->server, c->wrbuf); response_close(c, "info"); diff --git a/test/test_http_2.res b/test/test_http_2.res index 1692dca..95185a4 100644 --- a/test/test_http_2.res +++ b/test/test_http_2.res @@ -1,13 +1,14 @@ -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0.00 + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0.00 \ No newline at end of file diff --git a/test/test_icu_2.res b/test/test_icu_2.res index 1692dca..95185a4 100644 --- a/test/test_icu_2.res +++ b/test/test_icu_2.res @@ -1,13 +1,14 @@ -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0.00 + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0.00 \ No newline at end of file -- 1.7.10.4