From: Andre Noll Date: Sun, 23 Jul 2017 13:23:03 +0000 (+0200) Subject: Merge branch 'refs/heads/t/hash-sort-for-ls' X-Git-Tag: v0.6.1~50 X-Git-Url: http://git.tuebingen.mpg.de/?a=commitdiff_plain;h=10a62b85c43319d9cdefd7d04823aaed47b3817e;hp=-c;p=paraslash.git Merge branch 'refs/heads/t/hash-sort-for-ls' A single commit which allows to pass -s=h to the ls command for sorting the output by hash value. Cooking for six weeks. * refs/heads/t/hash-sort-for-ls: server: Introduce hash sort for ls command. --- 10a62b85c43319d9cdefd7d04823aaed47b3817e diff --combined NEWS.md index 5398d3a5,60b94238..894922f8 --- a/NEWS.md +++ b/NEWS.md @@@ -1,16 -1,6 +1,18 @@@ NEWS ==== - ------------------------------------------------ - 0.6.1 (to be announced) "hyperbolic correlation" - ------------------------------------------------ ++--------------------- ++current master branch ++--------------------- + ++- New sort order for the ls command: -s=h sorts the ls output by hash ++ value of the audio file. +- The contents of overview.pdf have been integrated into the user + manual. +- The doxygen source browser has been disabled temporarily. The + API reference is still online, though. +- Overhaul of the source code documentation. + ------------------------------- 0.6.0 (2017-04-28) "fuzzy flux" ------------------------------- diff --combined aft.c index c2642ed3,a548afbc..63a40d79 --- a/aft.c +++ b/aft.c @@@ -138,7 -138,7 +138,7 @@@ struct ls_options /** * Describes the layout of the mmapped-afs info struct. * - * \sa struct afs_info. + * \sa struct \ref afs_info. */ enum afsi_offsets { /** Where .last_played is stored. */ @@@ -167,7 -167,7 +167,7 @@@ * \param afsi Pointer to the audio file info to be converted. * \param obj Result pointer. * - * \sa load_afsi(). + * \sa \ref load_afsi(). */ static void save_afsi(struct afs_info *afsi, struct osl_object *obj) { @@@ -192,7 -192,7 +192,7 @@@ * * \return Standard. * - * \sa save_afsi(). + * \sa \ref save_afsi(). */ static int load_afsi(struct afs_info *afsi, struct osl_object *obj) { @@@ -365,10 -365,7 +365,10 @@@ static void save_afhi(struct afh_info * write_u32(buf + CHUNK_TV_TV_SEC_OFFSET, afhi->chunk_tv.tv_sec); write_u32(buf + CHUNK_TV_TV_USEC_OFFSET, afhi->chunk_tv.tv_usec); p = buf + AFHI_INFO_STRING_OFFSET; - /* The sprintf's below are OK as our caller made sure that buf is large enough */ + /* + * The below sprintf(3) calls are OK because our caller already made + * sure that buf is large enough. + */ p += sprintf(p, "%s", afhi->techinfo) + 1; p += sprintf(p, "%s", afhi->tags.artist) + 1; p += sprintf(p, "%s", afhi->tags.title) + 1; @@@ -377,7 -374,6 +377,7 @@@ sprintf(p, "%s", afhi->tags.comment); } +/* does not load the chunk table */ static void load_afhi(const char *buf, struct afh_info *afhi) { afhi->seconds_total = read_u32(buf + AFHI_SECONDS_TOTAL_OFFSET); @@@ -532,7 -528,7 +532,7 @@@ static int get_afsi_of_path(const char * \param row Pointer to a row in the audio file table. * \param path Result pointer. * - * The result is a pointer to mmapped data. The caller must not attempt + * The result is a pointer to memory-mapped data. The caller must not attempt * to free it. * * \return Standard. @@@ -556,7 -552,7 +556,7 @@@ int get_audio_file_path_of_row(const st * * \return The return value of the underlying call to osl_get_object(). * - * \sa get_hash_of_row(). + * \sa \ref get_hash_of_row(). */ static int get_hash_object_of_aft_row(const struct osl_row *row, struct osl_object *obj) @@@ -594,9 -590,7 +594,9 @@@ static int get_hash_of_row(const struc * * \return The return value of the underlying call to osl_get_object(). * - * \sa get_chunk_table_of_row(). + * After the call the members of the afhi structure point to mapped memory + * which is owned by the osl table, Hence the caller must not attempt to free + * this memory by calling \ref clear_afhi(). */ int get_afhi_of_row(const struct osl_row *row, struct afh_info *afhi) { @@@ -700,7 -694,7 +700,7 @@@ static int get_local_time(uint64_t *sec /* * If the given time is more than six month away from the current time, * we print only the year. The additional space character in the format - * string below makes the formated date align nicely with dates that + * string below makes the formatted date align nicely with dates that * contain the time (those written by the above strftime() statement). */ if (!strftime(buf, size, "%b %e %Y", tm)) @@@ -1110,6 -1104,12 +1110,12 @@@ out 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; @@@ -1227,6 -1227,8 +1233,8 @@@ static int sort_matching_paths(struct l 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; } @@@ -1375,7 -1377,6 +1383,6 @@@ out 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); @@@ -1441,6 -1442,8 +1448,8 @@@ 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; @@@ -1913,7 -1916,11 +1922,7 @@@ out } EXPORT_SERVER_CMD_HANDLER(add); -/** - * Flags used by the touch command. - * - * \sa com_touch(). - */ +/** Flags used by the touch command. */ enum touch_flags { /** Whether the \p FNM_PATHNAME flag should be passed to fnmatch(). */ TOUCH_FLAG_FNM_PATHNAME = 1, @@@ -2399,6 -2406,8 +2408,6 @@@ static int check_audio_file(struct osl_ * \param aca Only ->pbout is used for diagnostics. * * \return Standard. Inconsistencies are reported but not regarded as an error. - * - * \sa com_check(). */ int aft_check_callback(struct afs_callback_arg *aca) { @@@ -2467,7 -2476,7 +2476,7 @@@ int aft_check_attributes(uint64_t att_m * * \param flags Usual flags that are passed to osl_close_table(). * - * \sa osl_close_table(). + * \sa \ref osl_close_table(). */ static void aft_close(void) { @@@ -2482,7 -2491,7 +2491,7 @@@ * * \return Standard. * - * \sa osl_open_table(). + * \sa \ref osl_open_table(). */ static int aft_open(const char *dir) {