From: Andre Noll Date: Sat, 1 Mar 2014 17:56:31 +0000 (+0100) Subject: audiod: Implement version command. X-Git-Tag: v0.5.3~18^2 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=cddb6a7b9491b32b0c1108e934a6ee7f032302bc;p=paraslash.git audiod: Implement version command. 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. --- diff --git a/audioc.c b/audioc.c index 5f6b5ae1..fe7165ed 100644 --- 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) { diff --git a/audiod.cmd b/audiod.cmd index db384226..18c802de 100644 --- a/audiod.cmd +++ b/audiod.cmd @@ -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. diff --git a/audiod_command.c b/audiod_command.c index 4485d9e9..56d922e6 100644 --- a/audiod_command.c +++ b/audiod_command.c @@ -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;