return ret;
}
+static int ls_hash_compare(const void *a, const void *b)
+{
+ struct ls_data *d1 = *(struct ls_data **)a, *d2 = *(struct ls_data **)b;
+ return memcmp(d1->hash, d2->hash, HASH_SIZE);
+}
+
static int ls_audio_format_compare(const void *a, const void *b)
{
struct ls_data *d1 = *(struct ls_data **)a, *d2 = *(struct ls_data **)b;
compar = ls_duration_compare; break;
case LS_SORT_BY_AUDIO_FORMAT:
compar = ls_audio_format_compare; break;
+ case LS_SORT_BY_HASH:
+ compar = ls_hash_compare; break;
default:
return -E_BAD_SORT;
}
return ret;
}
-/* TODO: flags -h (sort by hash) */
static int com_ls(struct command_context *cc, struct lls_parse_result *lpr)
{
const struct lls_command *cmd = SERVER_CMD_CMD_PTR(LS);
opts->sorting = LS_SORT_BY_DURATION;
else if (!strcmp(val, "a") || !strcmp(val, "audio-format"))
opts->sorting = LS_SORT_BY_AUDIO_FORMAT;
+ else if (!strcmp(val, "h") || !strcmp(val, "hash"))
+ opts->sorting = LS_SORT_BY_HASH;
else {
ret = -E_AFT_SYNTAX;
goto out;