]> git.sesse.net Git - vlc/blob - src/text/iso_lang.c
Use var_Inherit* instead of var_CreateGet*.
[vlc] / src / text / iso_lang.c
1 /*****************************************************************************
2  * iso_lang.c: function to decode language code (in dvd or a52 for instance).
3  *****************************************************************************
4  * Copyright (C) 1998-2004 the VideoLAN team
5  * $Id$
6  *
7  * Author: Stéphane Borel <stef@via.ecp.fr>
8  *         Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include <stdio.h>
34
35 #include <vlc_common.h>
36
37 #include "vlc_iso_lang.h"
38
39 /*****************************************************************************
40  * Local tables
41  *****************************************************************************/
42 #include "iso-639_def.h"
43
44 static const iso639_lang_t unknown_language =
45     { "Unknown", "Unknown", "??", "???", "???" };
46
47 const iso639_lang_t * GetLang_1( const char * psz_code )
48 {
49     const iso639_lang_t *p_lang;
50
51     for( p_lang = p_languages; p_lang->psz_eng_name; p_lang++ )
52         if( !strncasecmp( p_lang->psz_iso639_1, psz_code, 2 ) )
53             return p_lang;
54
55     return &unknown_language;
56 }
57
58 const iso639_lang_t * GetLang_2T( const char * psz_code )
59 {
60     const iso639_lang_t *p_lang;
61
62     for( p_lang = p_languages; p_lang->psz_eng_name; p_lang++ )
63         if( !strncasecmp( p_lang->psz_iso639_2T, psz_code, 3 ) )
64             return p_lang;
65
66     return &unknown_language;
67 }
68
69 const iso639_lang_t * GetLang_2B( const char * psz_code )
70 {
71     const iso639_lang_t *p_lang;
72
73     for( p_lang = p_languages; p_lang->psz_eng_name; p_lang++ )
74         if( !strncasecmp( p_lang->psz_iso639_2B, psz_code, 3 ) )
75             return p_lang;
76
77     return &unknown_language;
78 }
79