LS_FLAG_ADMISSIBLE_ONLY = 2,
/** -r */
LS_FLAG_REVERSE = 4,
+ /** -d */
+ LS_FLAG_UNIXDATE = 8,
};
/**
goto out;
}
get_attribute_bitmap(&afsi->attributes, att_buf);
- ret = get_local_time(&afsi->last_played, last_played_time,
- sizeof(last_played_time), current_time, opts->mode);
- if (ret < 0)
- goto out;
+ if (opts->flags & LS_FLAG_UNIXDATE)
+ sprintf(last_played_time, "%llu",
+ (long long unsigned)afsi->last_played);
+ else {
+ ret = get_local_time(&afsi->last_played, last_played_time,
+ sizeof(last_played_time), current_time, opts->mode);
+ if (ret < 0)
+ goto out;
+ }
get_duration_buf(afhi->seconds_total, duration_buf, opts);
if (have_score) {
if (opts->mode == LS_MODE_LONG)
);
}
+static void fixup_taginfo(char *begin, char *end)
+{
+ char *p = begin;
+
+ for (;;) {
+ p = strchr(p, '\n');
+ if (!p)
+ break;
+ if (p >= end - 1)
+ break;
+ *p = ' ';
+ p++;
+ }
+}
+
+/* crap, remove this ASAP. */
+static int fixup_info_string(char *info_string)
+{
+ char *t1, *t2, *end;
+
+ if (strncmp(info_string, "audio_file_info:", 16))
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
+ t1 = strstr(info_string, "\ntaginfo1:");
+ if (!t1)
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
+ t2 = strstr(info_string, "\ntaginfo2: ");
+ if (!t2)
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
+
+ end = t2 + strlen(t2);
+ fixup_taginfo(info_string + 16, t1);
+ fixup_taginfo(t1 + 10, t2);
+ fixup_taginfo(t2 + 10, end);
+
+ if (t1 - info_string < 80 && t2 - t1 < 80 && end - t2 < 80)
+ return 0;
+ if (t1 - info_string >= 80) {
+ memmove(info_string + 80, t1, end - t1);
+ t1 = info_string + 80;
+ t2 -= t1 - info_string - 80;
+ end -= t1 - info_string - 80;
+ }
+ if (t2 - t1 >= 80) {
+ memmove(t1 + 80, t2, end - t2);
+ end -= t2 - t1 - 80;
+ t2 = t1 + 80;
+ }
+ if (end - t2 >= 80) {
+ t2[78] = '\n';
+ t2[79] = '\0';
+ }
+ return 1;
+}
+
static int make_status_items(struct audio_file_data *afd,
struct afs_info *afsi, char *path, long score,
HASH_TYPE *hash)
{
struct ls_data d = {
- .afhi = afd->afhi, /* struct copy */
+ .afhi = afd->afhi,
.afsi = *afsi,
.path = path,
.score = score,
time_t current_time;
int ret;
+ ret = fixup_info_string(afd->afhi.info_string);
+ if (ret < 0) {
+ PARA_WARNING_LOG("ignoring invalid tag info\n");
+ afd->afhi.info_string[0] = '\0';
+ } else if (ret)
+ PARA_NOTICE_LOG("truncated overlong tag info\n");
time(¤t_time);
ret = print_list_item(&d, &opts, &pb, current_time); /* frees info string */
afd->afhi.info_string = NULL;
flags |= LS_FLAG_REVERSE;
continue;
}
+ if (!strcmp(arg, "-d")) {
+ flags |= LS_FLAG_UNIXDATE;
+ continue;
+ }
if (!strncmp(arg, "-s", 2)) {
if (!*(arg + 2) || *(arg + 3))
return -E_AFT_SYNTAX;
void aft_init(struct afs_table *t)
{
- t->name = audio_file_table_desc.name;
t->open = aft_open;
t->close = aft_close;
t->create = aft_create;