Merge branch 'refs/heads/t/kill_usleep'
[paraslash.git] / audiod_command.c
index 1ffab87c0fbd5269d6da52b05428dc44132dd922..df8f3936faf89a2c5b5550901d2e6e9bcf12ebdb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2013 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2014 Andre Noll <maan@tuebingen.mpg.de>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -29,7 +29,8 @@
 #include "string.h"
 #include "write.h"
 #include "fd.h"
-#include "audiod_command_list.h"
+#include "version.h"
+#include "audiod.command_list.h"
 
 extern struct sched sched;
 extern char *stat_item_values[NUM_STAT_ITEMS];
@@ -375,10 +376,10 @@ static int com_grab(int fd, int argc, char **argv)
        return grab_client_new(fd, argc, argv, &sched);
 }
 
-__noreturn static int com_term(int fd, __a_unused int argc, __a_unused char **argv)
+static int com_term(int fd, __a_unused int argc, __a_unused char **argv)
 {
        close(fd);
-       clean_exit(EXIT_SUCCESS, "terminating on user request");
+       return -E_AUDIOD_TERM;
 }
 
 static int com_on(int fd, __a_unused int argc, __a_unused char **argv)
@@ -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;
@@ -510,7 +527,7 @@ void audiod_status_dump(bool force)
                        free(new);
        }
 
-       new = get_server_uptime_str(now);
+       new = daemon_get_uptime_str(now);
        old = stat_item_values[SI_AUDIOD_UPTIME];
        if (force || !old || strcmp(old, new)) {
                free(old);