chiark / gitweb /
New refresh_min option to bound below the web interface refresh
[disorder] / lib / trackname.h
CommitLineData
460b9539 1/*
2 * This file is part of DisOrder
5aff007d 3 * Copyright (C) 2005-2008 Richard Kettlewell
460b9539 4 *
e7eb3a27 5 * This program is free software: you can redistribute it and/or modify
460b9539 6 * it under the terms of the GNU General Public License as published by
e7eb3a27 7 * the Free Software Foundation, either version 3 of the License, or
460b9539 8 * (at your option) any later version.
e7eb3a27
RK
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
460b9539 15 * You should have received a copy of the GNU General Public License
e7eb3a27 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
460b9539 17 */
132a5a4a
RK
18/** @file lib/trackname.h
19 * @brief Track name calculation
20 */
460b9539 21#ifndef TRACKNAME_H
22#define TRACKNAME_H
23
d1694464 24const struct collection *find_track_collection(const char *track);
25/* find the collection for @track@ */
26
460b9539 27const char *find_track_root(const char *track);
28/* find the collection root for @track@ */
29
30const char *track_rootless(const char *track);
31/* return the rootless part of @track@ (typically starting /) */
32
33const char *trackname_part(const char *track,
34 const char *context,
35 const char *part);
36/* compute PART (artist/album/title) for TRACK in CONTEXT (display/sort) */
37
38const char *trackname_transform(const char *type,
39 const char *subject,
40 const char *context);
41/* convert SUBJECT (usually 'track' or 'dir' according to TYPE) for CONTEXT
42 * (display/sort) */
43
44int compare_tracks(const char *sa, const char *sb,
45 const char *da, const char *db,
46 const char *ta, const char *tb);
47/* Compare tracks A and B, with sort/display/track names S?, D? and T? */
48
49int compare_path_raw(const unsigned char *ap, size_t an,
50 const unsigned char *bp, size_t bn);
51/* Comparison function for path names that groups all entries in a directory
52 * together */
53
d53ef367
RK
54/** @brief Compare two paths
55 * @param ap First path
56 * @param bp Second path
57 * @return -ve, 0 or +ve for ap <, = or > bp
58 *
59 * Sorts files within a directory together.
60 * A wrapper around compare_path_raw().
61 */
460b9539 62static inline int compare_path(const char *ap, const char *bp) {
63 return compare_path_raw((const unsigned char *)ap, strlen(ap),
64 (const unsigned char *)bp, strlen(bp));
65}
66
2fadbbc6
RK
67/** @brief Entry in a list of tracks or directories */
68struct tracksort_data {
69 /** @brief Track name */
70 const char *track;
71 /** @brief Sort key */
72 const char *sort;
73 /** @brief Display key */
74 const char *display;
2fadbbc6
RK
75};
76
77struct tracksort_data *tracksort_init(int nvec,
78 char **vec,
79 const char *type);
80
460b9539 81#endif /* TRACKNAME_H */
82
83/*
84Local Variables:
85c-basic-offset:2
86comment-column:40
87fill-column:79
88End:
89*/