1 #ifndef T_TUNE_H
2 #define T_TUNE_H
3 /*
4  * t_tune.h
5  *
6  * A tune represent a music file with tags (or comments) attributes.
7  */
8 #include <stdlib.h>
9 
10 #include "t_config.h"
11 #include "t_toolkit.h"
12 #include "t_backend.h"
13 #include "t_taglist.h"
14 
15 
16 /* abstract music file */
17 struct t_tune;
18 
19 /*
20  * allocate memory for a new t_tune.
21  *
22  * @return
23  *   a pointer to a fresh t_tune on success, NULL on error (malloc(3) failed).
24  */
25 struct t_tune	*t_tune_new(const char *path);
26 
27 /*
28  * get all the tags of a tune.
29  *
30  * @return
31  *   A complete and ordered t_taglist on success, NULL on error. The caller
32  *   should pass the returned t_taglist to t_taglist_delete() after use.
33  */
34 struct t_taglist	*t_tune_tags(struct t_tune *tune);
35 
36 /*
37  * get the tune's path.
38  *
39  * @return
40  *   the path given at tune initialization.
41  */
42 const char	*t_tune_path(struct t_tune *tune);
43 
44 /*
45  * get the tune's backend.
46  *
47  * @return
48  *   the backend used for this tune.
49  */
50 const struct t_backend	*t_tune_backend(struct t_tune *tune);
51 
52 /*
53  * set the tags for a tune.
54  *
55  * @return
56  *   0 on success, -1 on error.
57  */
58 int	t_tune_set_tags(struct t_tune *tune, const struct t_taglist *tlist);
59 
60 /*
61  * Save (write) the file to the storage with its new tags.
62  *
63  * @return
64  *   0 on success, -1 on error.
65  */
66 int	t_tune_save(struct t_tune *tune);
67 
68 /*
69  * clear the t_tune and pass it to free(3). The pointer should not be used
70  * afterward.
71  */
72 void	t_tune_delete(struct t_tune *tune);
73 #endif /* ndef T_TUNE_H */
74