audiod: Clean up status output.
authorAndre Noll <maan@systemlinux.org>
Sat, 18 Jul 2009 13:19:24 +0000 (15:19 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 18 Jul 2009 13:19:24 +0000 (15:19 +0200)
It's a mess. Fortunately, this is much cleaner in 0.4.x..

audiod_command.c

index 48c276e..710f4b6 100644 (file)
@@ -183,48 +183,15 @@ int com_stat(int fd, int argc, char **argv)
        } else
                mask--; /* set all bits */
        PARA_INFO_LOG("mask: 0x%llx\n", (long long unsigned)mask);
-       if (mask & (one << SI_PLAY_TIME)) {
-               int slot_num = get_play_time_slot_num();
-               char *ts = get_time_string(slot_num);
-               if (ts) {
-                       PARA_ERROR_LOG("play time: %s\n", ts);
-                       ret = client_write(fd, ts);
-                       free(ts);
-                       if (ret < 0)
-                               goto out;
-               }
-       }
-       if (mask & (one << SI_AUDIOD_UPTIME)) {
-               char *tmp, *us = uptime_str();
-               tmp = make_message("%s: %s\n",
-                       status_item_list[SI_AUDIOD_UPTIME], us);
-               free(us);
-               ret = client_write(fd, tmp);
-               free(tmp);
-               if (ret < 0)
-                       goto out;
-       }
-       if (mask & (one << SI_AUDIOD_STATUS)) {
-               char *s = audiod_status_string();
-               ret = client_write(fd, s);
-               free(s);
-               if (ret < 0)
-                       goto out;
-       }
-       if (mask & (one << SI_DECODER_FLAGS)) {
-               char *df = decoder_flags();
-               ret = client_write(fd, df);
-               free(df);
-               if (ret < 0)
-                       goto out;
-       }
        FOR_EACH_STATUS_ITEM(i) {
                char *tmp, *v;
                if (!((one << i) & mask))
                        continue;
                v = stat_item_values[i];
-               tmp = make_message("%s%s%s", buf? buf: "",
-                       v? v : "", v? "\n" : "");
+               if (!v)
+                       continue;
+               tmp = make_message("%s%s%s", buf? buf: "", v,
+                       strrchr(v, '\n')? "" : "\n");
                free(buf);
                buf = tmp;
        }