a1a189e1a79707e5617dd7059202784a6927fabf
[Faustine.git] / interpretor / libsndfile-1.0.25 / src / id3.c
1 /*
2 ** Copyright (C) 2010-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
3 **
4 ** This program is free software; you can redistribute it and/or modify
5 ** it under the terms of the GNU Lesser General Public License as published by
6 ** the Free Software Foundation; either version 2.1 of the License, or
7 ** (at your option) any later version.
8 **
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ** GNU Lesser General Public License for more details.
13 **
14 ** You should have received a copy of the GNU Lesser General Public License
15 ** along with this program; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #include "sfconfig.h"
20
21 #include <stdio.h>
22 #include <fcntl.h>
23 #include <string.h>
24 #include <ctype.h>
25
26 #include "sndfile.h"
27 #include "sfendian.h"
28 #include "common.h"
29
30 int
31 id3_skip (SF_PRIVATE * psf)
32 { unsigned char buf [10] ;
33
34 memset (buf, 0, sizeof (buf)) ;
35 psf_binheader_readf (psf, "pb", 0, buf, 10) ;
36
37 if (buf [0] == 'I' && buf [1] == 'D' && buf [2] == '3')
38 { int offset = buf [6] & 0x7f ;
39 offset = (offset << 7) | (buf [7] & 0x7f) ;
40 offset = (offset << 7) | (buf [8] & 0x7f) ;
41 offset = (offset << 7) | (buf [9] & 0x7f) ;
42
43 psf_binheader_readf (psf, "j", make_size_t (offset)) ;
44
45 psf_log_printf (psf, "ID3 length : %d\n--------------------\n", offset) ;
46
47 psf->fileoffset = 10 + offset ;
48 return 1 ;
49 } ;
50
51 return 0 ;
52 } /* id3_skip */