]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/locale-util.h
Merge pull request #28301 from berrange/cvm-lockdown
[thirdparty/systemd.git] / src / basic / locale-util.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <libintl.h>
5 #include <locale.h>
6 #include <stdbool.h>
7
8 #include "macro.h"
9
10 typedef enum LocaleVariable {
11 /* We don't list LC_ALL here on purpose. People should be
12 * using LANG instead. */
13
14 VARIABLE_LANG,
15 VARIABLE_LANGUAGE,
16 VARIABLE_LC_CTYPE,
17 VARIABLE_LC_NUMERIC,
18 VARIABLE_LC_TIME,
19 VARIABLE_LC_COLLATE,
20 VARIABLE_LC_MONETARY,
21 VARIABLE_LC_MESSAGES,
22 VARIABLE_LC_PAPER,
23 VARIABLE_LC_NAME,
24 VARIABLE_LC_ADDRESS,
25 VARIABLE_LC_TELEPHONE,
26 VARIABLE_LC_MEASUREMENT,
27 VARIABLE_LC_IDENTIFICATION,
28 _VARIABLE_LC_MAX,
29 _VARIABLE_LC_INVALID = -EINVAL,
30 } LocaleVariable;
31
32 int get_locales(char ***l);
33 bool locale_is_valid(const char *name);
34 int locale_is_installed(const char *name);
35
36 #define _(String) gettext(String)
37 #define N_(String) String
38 void init_gettext(void);
39
40 bool is_locale_utf8(void);
41
42 const char* locale_variable_to_string(LocaleVariable i) _const_;
43 LocaleVariable locale_variable_from_string(const char *s) _pure_;
44
45 static inline void freelocalep(locale_t *p) {
46 if (*p == (locale_t) 0)
47 return;
48
49 freelocale(*p);
50 }
51
52 void locale_variables_free(char* l[_VARIABLE_LC_MAX]);
53 static inline void locale_variables_freep(char*(*l)[_VARIABLE_LC_MAX]) {
54 locale_variables_free(*l);
55 }
56 void locale_variables_simplify(char *l[_VARIABLE_LC_MAX]);