summaryrefslogtreecommitdiffstats
path: root/libhb/lang.c
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2016-01-27 10:46:01 -0700
committerJohn Stebbins <[email protected]>2016-01-27 10:46:01 -0700
commit091e559752a8c452fb81be2356143d909030ae74 (patch)
treeed3adf39f84ebbd5cd9cba7e5654aa17a482ac5f /libhb/lang.c
parent4b408bced10509e378ee91aa526e126b264cfccf (diff)
LinGui: use language table provided by libhb
LinGui had a duplicate of this table, so it did not automatically get the updates to native language names that was recently added.
Diffstat (limited to 'libhb/lang.c')
-rw-r--r--libhb/lang.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/libhb/lang.c b/libhb/lang.c
index d41985f9e..a8ed2e8c8 100644
--- a/libhb/lang.c
+++ b/libhb/lang.c
@@ -202,29 +202,44 @@ static const iso639_lang_t languages[] =
static const int lang_count = sizeof(languages) / sizeof(languages[0]);
-const iso639_lang_t * lang_lookup( const char * str )
+const int lang_lookup_index( const char * str )
{
+ int ii = 0;
iso639_lang_t * lang;
// We use "Any" as a synonym for undefined
if (!strcasecmp("any", str))
{
- return &languages[0];
+ return 0;
}
- for (lang = (iso639_lang_t*) languages; lang->eng_name; lang++)
+ for (ii = 0; lang->eng_name; ii++)
{
+ lang = &languages[ii];
if ((lang->iso639_1 != NULL && !strcasecmp(lang->iso639_1, str)) ||
(lang->iso639_2 != NULL && !strcasecmp(lang->iso639_2, str)) ||
(lang->iso639_2b != NULL && !strcasecmp(lang->iso639_2b, str)) ||
(lang->eng_name != NULL && !strcasecmp(lang->eng_name, str)) ||
(lang->native_name != NULL && !strcasecmp(lang->native_name, str)))
{
- return lang;
+ return ii;
}
}
- return NULL;
+ return -1;
+}
+
+const iso639_lang_t * lang_lookup( const char * str )
+{
+ return lang_for_index(lang_lookup_index(str));
+}
+
+iso639_lang_t * lang_for_index( int index )
+{
+ if (index < 0 || index >= lang_count)
+ return NULL;
+
+ return &languages[index];
}
iso639_lang_t * lang_for_code( int code )