summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2022-07-22 11:09:15 +0200
committerBastien Nocera <hadess@hadess.net>2022-07-22 11:16:50 +0200
commitdd34d89b668254aa8b05192d396ab9f3069a0c28 (patch)
tree4fe978d9f30e1b490360d918dbf98717ae8780ff
parente4488b3ead25ea413a915085e911df5918233daa (diff)
downloadaccountsservice-dd34d89b668254aa8b05192d396ab9f3069a0c28.tar.gz
util: Add locale verification function
Same as the XPG locale verification, but also considers empty strings as valid locale, as this means "use the system value" in AccountsService.
-rw-r--r--src/util.c8
-rw-r--r--src/util.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 3b7a2da..54cdd6d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -389,3 +389,11 @@ verify_xpg_locale (const char *locale)
{
return (explode_locale (locale, NULL, NULL, NULL, NULL) & COMPONENT_LANGUAGE);
}
+
+gboolean
+verify_locale (const char *locale)
+{
+ if (locale && *locale == '\0')
+ return TRUE;
+ return verify_xpg_locale (locale);
+}
diff --git a/src/util.h b/src/util.h
index c51887e..a42d0ed 100644
--- a/src/util.h
+++ b/src/util.h
@@ -44,6 +44,7 @@ gint get_user_groups (const gchar *username,
gid_t **groups);
gboolean verify_xpg_locale (const char *locale);
+gboolean verify_locale (const char *locale);
G_END_DECLS