summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
Diffstat (limited to 'libhb')
-rw-r--r--libhb/lang.c17
-rw-r--r--libhb/lang.h8
2 files changed, 25 insertions, 0 deletions
diff --git a/libhb/lang.c b/libhb/lang.c
index 2e0cc3a48..4600f1020 100644
--- a/libhb/lang.c
+++ b/libhb/lang.c
@@ -200,6 +200,8 @@ static const iso639_lang_t languages[] =
{ "Zulu", "", "zu", "zul" },
{ NULL, NULL, NULL } };
+static const int lang_count = sizeof(languages) / sizeof(languages[0]);
+
iso639_lang_t * lang_for_code( int code )
{
char code_string[2];
@@ -269,3 +271,18 @@ iso639_lang_t * lang_for_english( const char * english )
return (iso639_lang_t*) languages;
}
+const iso639_lang_t* lang_get_next(const iso639_lang_t *last)
+{
+ if (last == NULL)
+ {
+ return (const iso639_lang_t*)languages;
+ }
+ if (last < languages || // out of bounds
+ last >= languages + lang_count - 2) // last valid language
+ {
+ return NULL;
+ }
+ return ++last;
+}
+
+
diff --git a/libhb/lang.h b/libhb/lang.h
index 9df8e10f4..cf4ecc321 100644
--- a/libhb/lang.h
+++ b/libhb/lang.h
@@ -33,6 +33,14 @@ iso639_lang_t * lang_for_code2( const char *code2 );
int lang_to_code(const iso639_lang_t *lang);
iso639_lang_t * lang_for_english( const char * english );
+
+/*
+ * Get the next language in the list.
+ * Returns NULL if there are no more languages.
+ * Pass NULL to get the first language in the list.
+ */
+const iso639_lang_t* lang_get_next(const iso639_lang_t *last);
+
#ifdef __cplusplus
}
#endif