]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
audiod: Implement version command.
authorAndre Noll <maan@systemlinux.org>
Sat, 1 Mar 2014 17:56:31 +0000 (18:56 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 30 Mar 2014 16:48:08 +0000 (18:48 +0200)
It's sometimes useful to tell the git version of a running instance of
para_audiod. This commit adds the "version" subcommand to para_audiod
which prints this information. A completer for the "-v" option of
the new command is provided as well.

Since the infrastructure is already in place, all of this is rather
simple.

audioc.c
audiod.cmd
audiod_command.c

index 5f6b5ae1195645e3a8b4c2b458559625a036701c..fe7165edd966d1afeaf46c15c252fa70c229e2c6 100644 (file)
--- a/audioc.c
+++ b/audioc.c
@@ -97,6 +97,15 @@ static void help_completer(struct i9e_completion_info *ci,
        result->matches = i9e_complete_commands(ci->word, audiod_completers);
 }
 
+static void version_completer(struct i9e_completion_info *ci,
+               struct i9e_completion_result *cr)
+{
+       char *opts[] = {"-v", NULL};
+
+       if (ci->word_num <= 2 && ci->word && ci->word[0] == '-')
+               i9e_complete_option(opts, ci, cr);
+}
+
 static void stat_completer(struct i9e_completion_info *ci,
                struct i9e_completion_result *cr)
 {
index db3842267f5d3c5b8e72b3c2ea6def502e81a0bb..18c802de8857788449cb6dfbfa53823c7ef0da0e 100644 (file)
@@ -72,3 +72,8 @@ N: term
 D: terminate audiod
 U: term
 H: Stop all decoders, shut down connection to para_server and exit.
+---
+N: version
+D: print the version of para_audiod
+U: version [-v]
+H: If the -v option is given, a more detailed version text is printed.
index 4485d9e9df28ca0fb2d1689046c1e53cffc9f5a5..56d922e6681e66d0d9c4f65df86569806a38ca80 100644 (file)
@@ -29,6 +29,7 @@
 #include "string.h"
 #include "write.h"
 #include "fd.h"
+#include "version.h"
 #include "audiod_command_list.h"
 
 extern struct sched sched;
@@ -419,6 +420,22 @@ static int com_cycle(int fd, int argc, char **argv)
        return 1;
 }
 
+static int com_version(int fd, int argc, char **argv)
+{
+       int ret;
+       char *msg;
+
+       if (argc > 1 && strcmp(argv[1], "-v") == 0)
+               msg = make_message("%s", version_text("audiod"));
+       else
+               msg = make_message("%s\n", version_single_line("audiod"));
+       ret = client_write(fd, msg);
+       free(msg);
+       if (ret >= 0)
+               close(fd);
+       return ret;
+}
+
 static int check_perms(uid_t uid)
 {
        int i;