X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=audiod_command.c;h=4706131d6c1ff745b1ff6f94a8086fff3af564f7;hp=fe30b2476e6dd99738325df1fccb4c34d646d3b4;hb=3f9051d22fcf6e968259946eaf521ac3daac470e;hpb=9c0ba673964679ea7544f1de066bd3c58e176861 diff --git a/audiod_command.c b/audiod_command.c index fe30b247..4706131d 100644 --- a/audiod_command.c +++ b/audiod_command.c @@ -166,7 +166,7 @@ int com_kill(int fd, int argc, char **argv) return ret; } -int com_stat(int fd, __a_unused int argc, __a_unused char **argv) +int com_stat(int fd, int argc, char **argv) { int i, ret; char *buf = NULL; @@ -183,52 +183,19 @@ int com_stat(int fd, __a_unused int argc, __a_unused 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) { - ret = client_write(fd, ts); - if (ret < 0) - goto out; - free(ts); - } - } - 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); - if (ret < 0) - goto out; - free(tmp); - } - if (mask & (one << SI_AUDIOD_STATUS)) { - char *s = audiod_status_string(); - ret = client_write(fd, s); - if (ret < 0) - goto out; - free(s); - } - if (mask & (one << SI_DECODER_FLAGS)) { - char *df = decoder_flags(); - ret = client_write(fd, df); - if (ret < 0) - goto out; - free(df); - } 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; } ret = client_write(fd, buf); -out: if (ret > 0) ret = stat_client_add(fd, mask); free(buf); @@ -439,14 +406,14 @@ void audiod_status_dump(void) free(new); } - new = uptime_str(); + tmp = uptime_str(); + new = make_message("%s: %s\n", status_item_list[SI_AUDIOD_UPTIME], + tmp); + free(tmp); old = stat_item_values[SI_AUDIOD_UPTIME]; if (!old || strcmp(old, new)) { free(old); - tmp = make_message("%s: %s\n", - status_item_list[SI_AUDIOD_UPTIME], new); - stat_client_write(tmp, SI_AUDIOD_UPTIME); - free(tmp); + stat_client_write(new, SI_AUDIOD_UPTIME); stat_item_values[SI_AUDIOD_UPTIME] = new; } else free(new);