Code

sysdb: Print the server version after (re)connecting.
authorSebastian Harl <sh@tokkee.org>
Sun, 22 Feb 2015 15:47:01 +0000 (16:47 +0100)
committerSebastian Harl <sh@tokkee.org>
Sun, 22 Feb 2015 18:03:35 +0000 (19:03 +0100)
src/tools/sysdb/command.c
src/tools/sysdb/command.h
src/tools/sysdb/input.c
src/tools/sysdb/main.c

index 440ba41e3b13832574ff0ca42472315023cd7f07..c7ca310a086230268272b46dcb7c268733b106b8 100644 (file)
@@ -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 : */
 
index bd9833828167de802c063c28e0878efdf06e3bf1..04ad5e156a7cd87992a9c8691adc2414eb4fe013 100644 (file)
@@ -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 : */
index 0b0dbf719c20fee8acbd29218530d4d51838430c..f0f86ea2a9bff1e264013bf39c3ab31758919c63 100644 (file)
@@ -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 */
 
index 792faf9d93a7ff62d407b23320729e35c83cd6d7..e4922e9b939587c914fd7d28ef172ce0fa4a59fb 100644 (file)
@@ -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();