1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 Dave Chapman
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
27 #include "metadata_common.h"
28 #include "metadata_parsers.h"
32 /* Read the items in a Vorbis comment packet. Returns true the items were
33 * fully read, false otherwise.
35 bool read_vorbis_tags(int fd
, struct mp3entry
*id3
,
38 char *buf
= id3
->id3v2buf
;
39 int32_t comment_count
;
41 int buf_remaining
= sizeof(id3
->id3v2buf
) + sizeof(id3
->id3v1buf
);
44 if (ecread(fd
, &len
, 1, "l", IS_BIG_ENDIAN
) < (long) sizeof(len
))
49 if ((lseek(fd
, len
, SEEK_CUR
) < 0)
50 || (ecread(fd
, &comment_count
, 1, "l", IS_BIG_ENDIAN
)
51 < (long) sizeof(comment_count
)))
56 tag_remaining
-= len
+ sizeof(len
) + sizeof(comment_count
);
58 if (tag_remaining
<= 0)
63 for (i
= 0; i
< comment_count
; i
++)
65 char name
[TAG_NAME_LENGTH
];
66 char value
[TAG_VALUE_LENGTH
];
69 if (tag_remaining
< 4)
74 if (ecread(fd
, &len
, 1, "l", IS_BIG_ENDIAN
) < (long) sizeof(len
))
81 /* Quit if we've passed the end of the page */
82 if (tag_remaining
< len
)
88 read_len
= read_string(fd
, name
, sizeof(name
), '=', len
);
97 if (read_string(fd
, value
, sizeof(value
), -1, len
) < 0)
102 len
= parse_tag(name
, value
, id3
, buf
, buf_remaining
,
105 buf_remaining
-= len
;
108 /* Skip to the end of the block */
111 if (lseek(fd
, tag_remaining
, SEEK_CUR
) < 0)