]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - command.c
build: Fix --with-opus-libs.
[paraslash.git] / command.c
index aaaaaecf02084c188482214bebd3df433c54e72b..41a58eac0517e15e44c964250578173708289e60 100644 (file)
--- a/command.c
+++ b/command.c
@@ -8,7 +8,6 @@
 
 #include <regex.h>
 #include <signal.h>
-#include <sys/time.h>
 #include <sys/types.h>
 #include <osl.h>
 
@@ -124,7 +123,7 @@ static unsigned get_status(struct misc_meta_data *nmmd, int parser_friendly,
                localtime_r(&nmmd->mtime, &mtime_tm);
                strftime(mtime, 29, "%b %d %Y", &mtime_tm);
        }
-       gettimeofday(&current_time, NULL);
+       clock_get_realtime(&current_time);
        /*
         * The calls to WRITE_STATUS_ITEM() below never fail because
         * b->max_size is zero (unlimited), see para_printf(). However, clang
@@ -396,7 +395,8 @@ static int com_si(struct command_context *cc)
                free(info);
        }
        ut = get_server_uptime_str(now);
-       ret = xasprintf(&msg, "version: " GIT_VERSION "\n"
+       ret = xasprintf(&msg,
+               "version: %s\n"
                "up: %s\nplayed: %u\n"
                "server_pid: %d\n"
                "afs_pid: %d\n"
@@ -404,6 +404,7 @@ static int com_si(struct command_context *cc)
                "current loglevel: %s\n"
                "supported audio formats: %s\n"
                "%s",
+               version_git(),
                ut, mmd->num_played,
                (int)getppid(),
                (int)mmd->afs_pid,
@@ -432,11 +433,9 @@ static int com_version(struct command_context *cc)
 
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
-       msg = VERSION_TEXT("server") "built: " BUILD_DATE "\n" UNAME_RS
-               ", " CC_VERSION "\n";
-       len = strlen(msg);
+       len = xasprintf(&msg, "%s", version_text("server"));
        if (cc->use_sideband)
-               return send_sb(&cc->scc, msg, len, SBD_OUTPUT, true);
+               return send_sb(&cc->scc, msg, len, SBD_OUTPUT, false);
        return sc_send_bin_buffer(&cc->scc, msg, len);
 }
 
@@ -475,11 +474,8 @@ static int com_version(struct command_context *cc)
  */
 static unsigned empty_status_items(int parser_friendly, char **result)
 {
-       static char *esi;
-       static unsigned len;
-
-       if (esi)
-               goto out;
+       char *esi;
+       unsigned len;
 
        if (parser_friendly)
                len = xasprintf(&esi,
@@ -499,7 +495,6 @@ static unsigned empty_status_items(int parser_friendly, char **result)
                        EMPTY_STATUS_ITEMS
                        #undef ITEM
                );
-out:
        *result = esi;
        return len;
 }
@@ -510,7 +505,7 @@ static int com_stat(struct command_context *cc)
 {
        int i, ret;
        struct misc_meta_data tmp, *nmmd = &tmp;
-       char *s, *esi = NULL;
+       char *s;
        int32_t num = 0;
        int parser_friendly = 0;
 
@@ -550,12 +545,15 @@ static int com_stat(struct command_context *cc)
                if (ret < 0)
                        goto out;
                if (nmmd->vss_status_flags & VSS_NEXT) {
+                       char *esi;
                        ret = empty_status_items(parser_friendly, &esi);
                        if (cc->use_sideband)
                                ret = send_sb(&cc->scc, esi, ret, SBD_OUTPUT,
-                                       true);
-                       else
+                                       false);
+                       else {
                                ret = sc_send_bin_buffer(&cc->scc, esi, ret);
+                               free(esi);
+                       }
                        if (ret < 0)
                                goto out;
                } else
@@ -569,7 +567,6 @@ static int com_stat(struct command_context *cc)
                        goto out;
        }
 out:
-       free(esi);
        return ret;
 }