1 /* mpdscribble (MPD Client)
2 * Copyright (C) 2008-2010 The Music Player Daemon Project
3 * Copyright (C) 2005-2008 Kuno Woudt <kuno@frob.nl>
4 * Project homepage: http://musicpd.org
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #ifndef RECORD_H
22 #define RECORD_H
23
24 #include <stdbool.h>
25 #include <stddef.h>
26
27 struct record {
28 char *artist;
29 char *track;
30 char *album;
31 char *number;
32 char *mbid;
33 char *time;
34 int length;
35 bool love;
36 const char *source;
37 };
38
39 /**
40 * Copies attributes from one record to another. Does not free
41 * existing values in the destination record.
42 */
43 void
44 record_copy(struct record *dest, const struct record *src);
45
46 /**
47 * Duplicates a record object.
48 */
49 struct record *
50 record_dup(const struct record *src);
51
52 /**
53 * Deinitializes a record object, freeing all members.
54 */
55 void
56 record_deinit(struct record *record);
57
58 /**
59 * Frees a record object: free all members with record_deinit(), and
60 * free the record pointer itself.
61 */
62 void
63 record_free(struct record *record);
64
65 void
66 record_clear(struct record *record);
67
68 /**
69 * Does this record object have a defined and usable value?
70 */
71 static inline bool
record_is_defined(const struct record * record)72 record_is_defined(const struct record *record)
73 {
74 return record->artist != NULL && record->track != NULL;
75 }
76
77 #endif /* RECORD_H */
78