From: Sebastian Harl Date: Sun, 22 Feb 2015 15:47:01 +0000 (+0100) Subject: sysdb: Print the server version after (re)connecting. X-Git-Tag: sysdb-0.8.0~169 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=23844d9c7d88bc4d73b00dd2ed147f2707533216;p=sysdb.git sysdb: Print the server version after (re)connecting. --- diff --git a/src/tools/sysdb/command.c b/src/tools/sysdb/command.c index 440ba41..c7ca310 100644 --- a/src/tools/sysdb/command.c +++ b/src/tools/sysdb/command.c @@ -215,5 +215,25 @@ sdb_command_exec(sdb_input_t *input) return data; } /* sdb_command_exec */ +void +sdb_command_print_server_version(sdb_input_t *input) +{ + sdb_strbuf_t *buf = sdb_strbuf_create(32); + uint32_t code = 0, version = 0; + const char *extra; + + if ((sdb_client_rpc(input->client, SDB_CONNECTION_SERVER_VERSION, + 0, NULL, &code, buf) < 0) || (code != SDB_CONNECTION_OK)) + return; + if (sdb_strbuf_len(buf) < sizeof(version)) + return; + + sdb_proto_unmarshal_int32(SDB_STRBUF_STR(buf), &version); + extra = sdb_strbuf_string(buf) + sizeof(version); + sdb_log(SDB_LOG_INFO, "SysDB server %d.%d.%d%s", + SDB_VERSION_DECODE((int)version), extra); + sdb_strbuf_destroy(buf); +} /* sdb_command_print_server_version */ + /* vim: set tw=78 sw=4 ts=4 noexpandtab : */ diff --git a/src/tools/sysdb/command.h b/src/tools/sysdb/command.h index bd98338..04ad5e1 100644 --- a/src/tools/sysdb/command.h +++ b/src/tools/sysdb/command.h @@ -58,6 +58,13 @@ sdb_command_print_reply(sdb_client_t *client); char * sdb_command_exec(sdb_input_t *input); +/* + * sdb_command_print_server_version: + * Query and print the server version. + */ +void +sdb_command_print_server_version(sdb_input_t *input); + #endif /* SYSDB_COMMAND_H */ /* vim: set tw=78 sw=4 ts=4 noexpandtab : */ diff --git a/src/tools/sysdb/input.c b/src/tools/sysdb/input.c index 0b0dbf7..f0f86ea 100644 --- a/src/tools/sysdb/input.c +++ b/src/tools/sysdb/input.c @@ -329,6 +329,7 @@ sdb_input_reconnect(void) return -1; } sdb_log(SDB_LOG_INFO, "Successfully reconnected to SysDBd"); + sdb_command_print_server_version(sysdb_input); return 0; } /* sdb_input_reconnect */ diff --git a/src/tools/sysdb/main.c b/src/tools/sysdb/main.c index 792faf9..e4922e9 100644 --- a/src/tools/sysdb/main.c +++ b/src/tools/sysdb/main.c @@ -330,8 +330,10 @@ main(int argc, char **argv) } sdb_log(SDB_LOG_INFO, "SysDB client "SDB_CLIENT_VERSION_STRING - SDB_CLIENT_VERSION_EXTRA" (libsysdbclient %s%s)\n", + SDB_CLIENT_VERSION_EXTRA" (libsysdbclient %s%s)", sdb_client_version_string(), sdb_client_version_extra()); + sdb_command_print_server_version(&input); + printf("\n"); using_history();