/src/vlc/modules/meta_engine/ID3Text.h
Line | Count | Source (jump to first uncovered line) |
1 | | /***************************************************************************** |
2 | | * ID3Text.h : ID3v2 Text Helper |
3 | | ***************************************************************************** |
4 | | * Copyright (C) 2016 VLC authors and VideoLAN |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or modify it |
7 | | * under the terms of the GNU Lesser General Public License as published by |
8 | | * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU Lesser General Public License |
17 | | * along with this program; if not, write to the Free Software Foundation, |
18 | | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
19 | | *****************************************************************************/ |
20 | | #ifndef ID3TEXT_H |
21 | | #define ID3TEXT_H |
22 | | |
23 | | #include <vlc_charset.h> |
24 | | |
25 | | static const char * ID3TextConv( const uint8_t *p_buf, size_t i_buf, |
26 | | uint8_t i_charset, char **ppsz_allocated ) |
27 | 0 | { |
28 | 0 | char *p_alloc = NULL; |
29 | 0 | const char *psz = p_alloc; |
30 | 0 | if( i_buf > 0 && i_charset < 0x04 ) |
31 | 0 | { |
32 | 0 | switch( i_charset ) |
33 | 0 | { |
34 | 0 | case 0x00: |
35 | 0 | psz = p_alloc = FromCharset( "ISO_8859-1", p_buf, i_buf ); |
36 | 0 | break; |
37 | 0 | case 0x01: |
38 | 0 | psz = p_alloc = FromCharset( "UTF-16LE", p_buf, i_buf ); |
39 | 0 | break; |
40 | 0 | case 0x02: |
41 | 0 | psz = p_alloc = FromCharset( "UTF-16BE", p_buf, i_buf ); |
42 | 0 | break; |
43 | 0 | default: |
44 | 0 | case 0x03: |
45 | 0 | if( p_buf[ i_buf - 1 ] != 0x00 ) |
46 | 0 | { |
47 | 0 | psz = p_alloc = (char *) malloc( i_buf + 1 ); |
48 | 0 | if( p_alloc ) |
49 | 0 | { |
50 | 0 | memcpy( p_alloc, p_buf, i_buf ); |
51 | 0 | p_alloc[i_buf] = '\0'; |
52 | 0 | } |
53 | 0 | } |
54 | 0 | else |
55 | 0 | { |
56 | 0 | psz = (const char *) p_buf; |
57 | 0 | } |
58 | 0 | break; |
59 | 0 | } |
60 | 0 | } |
61 | 0 | *ppsz_allocated = p_alloc; |
62 | 0 | return psz; |
63 | 0 | } Unexecuted instantiation: es.c:ID3TextConv Unexecuted instantiation: meta.c:ID3TextConv |
64 | | |
65 | | static inline const char * ID3TextConvert( const uint8_t *p_buf, size_t i_buf, |
66 | | char **ppsz_allocated ) |
67 | 0 | { |
68 | 0 | if( i_buf == 0 ) |
69 | 0 | { |
70 | 0 | *ppsz_allocated = NULL; |
71 | 0 | return NULL; |
72 | 0 | } |
73 | 0 | return ID3TextConv( &p_buf[1], i_buf - 1, p_buf[0], ppsz_allocated ); |
74 | 0 | } Unexecuted instantiation: es.c:ID3TextConvert Unexecuted instantiation: meta.c:ID3TextConvert |
75 | | |
76 | | #endif |