summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2015-04-02 16:08:26 +0000
committerjstebbins <[email protected]>2015-04-02 16:08:26 +0000
commiteb3f55f728c92887b4a210015533e8e6e9a5357f (patch)
treed6f0e2276e4e1a7370c73cd9583cb7fb5831ea90
parent4e26c6488ca8910d834568d22c89b34c239798c7 (diff)
libhb: add language lookup based on any of iso639_1/2/2b, eng_name, or native
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7038 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--libhb/lang.c19
-rw-r--r--libhb/lang.h5
2 files changed, 23 insertions, 1 deletions
diff --git a/libhb/lang.c b/libhb/lang.c
index a336268a7..f40520a23 100644
--- a/libhb/lang.c
+++ b/libhb/lang.c
@@ -202,6 +202,25 @@ static const iso639_lang_t languages[] =
static const int lang_count = sizeof(languages) / sizeof(languages[0]);
+iso639_lang_t * lang_lookup( const char * str )
+{
+ iso639_lang_t * lang;
+
+ for (lang = (iso639_lang_t*) languages; lang->eng_name; lang++)
+ {
+ 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 NULL;
+}
+
iso639_lang_t * lang_for_code( int code )
{
char code_string[2];
diff --git a/libhb/lang.h b/libhb/lang.h
index 0b353573f..21aab70af 100644
--- a/libhb/lang.h
+++ b/libhb/lang.h
@@ -14,7 +14,7 @@ typedef struct iso639_lang_t
{
char * eng_name; /* Description in English */
char * native_name; /* Description in native language */
- char * iso639_1; /* ISO-639-1 (2 characters) code */
+ char * iso639_1; /* ISO-639-1 (2 characters) code */
char * iso639_2; /* ISO-639-2/t (3 character) code */
char * iso639_2b; /* ISO-639-2/b code (if different from above) */
@@ -23,6 +23,9 @@ typedef struct iso639_lang_t
#ifdef __cplusplus
extern "C" {
#endif
+/* find language, match any of names in lang struct */
+iso639_lang_t * lang_lookup( const char * str );
+
/* find language associated with ISO-639-1 language code */
iso639_lang_t * lang_for_code( int code );