1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 Dave Chapman
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
29 #include "metadata_common.h"
30 #include "metadata_parsers.h"
34 /* Read the items in a Vorbis comment packet. Returns true the items were
35 * fully read, false otherwise.
37 bool read_vorbis_tags(int fd
, struct mp3entry
*id3
,
40 char *buf
= id3
->id3v2buf
;
41 int32_t comment_count
;
43 int buf_remaining
= sizeof(id3
->id3v2buf
) + sizeof(id3
->id3v1buf
);
46 if (ecread(fd
, &len
, 1, "l", IS_BIG_ENDIAN
) < (long) sizeof(len
))
51 if ((lseek(fd
, len
, SEEK_CUR
) < 0)
52 || (ecread(fd
, &comment_count
, 1, "l", IS_BIG_ENDIAN
)
53 < (long) sizeof(comment_count
)))
58 tag_remaining
-= len
+ sizeof(len
) + sizeof(comment_count
);
60 if (tag_remaining
<= 0)
65 for (i
= 0; i
< comment_count
; i
++)
67 char name
[TAG_NAME_LENGTH
];
68 char value
[TAG_VALUE_LENGTH
];
71 if (tag_remaining
< 4)
76 if (ecread(fd
, &len
, 1, "l", IS_BIG_ENDIAN
) < (long) sizeof(len
))
83 /* Quit if we've passed the end of the page */
84 if (tag_remaining
< len
)
90 read_len
= read_string(fd
, name
, sizeof(name
), '=', len
);
99 if (read_string(fd
, value
, sizeof(value
), -1, len
) < 0)
104 len
= parse_tag(name
, value
, id3
, buf
, buf_remaining
,
107 buf_remaining
-= len
;
110 /* Skip to the end of the block */
113 if (lseek(fd
, tag_remaining
, SEEK_CUR
) < 0)