chiark / gitweb /
Add locale.h header, needed by freelocale()
[elogind.git] / src / basic / locale-util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5   This file is part of systemd.
6
7   Copyright 2014 Lennart Poettering
8
9   systemd is free software; you can redistribute it and/or modify it
10   under the terms of the GNU Lesser General Public License as published by
11   the Free Software Foundation; either version 2.1 of the License, or
12   (at your option) any later version.
13
14   systemd is distributed in the hope that it will be useful, but
15   WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   Lesser General Public License for more details.
18
19   You should have received a copy of the GNU Lesser General Public License
20   along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 #include <libintl.h>
24 #include <stdbool.h>
25 #include <locale.h>
26
27 #include "macro.h"
28
29 typedef enum LocaleVariable {
30         /* We don't list LC_ALL here on purpose. People should be
31          * using LANG instead. */
32
33         VARIABLE_LANG,
34         VARIABLE_LANGUAGE,
35         VARIABLE_LC_CTYPE,
36         VARIABLE_LC_NUMERIC,
37         VARIABLE_LC_TIME,
38         VARIABLE_LC_COLLATE,
39         VARIABLE_LC_MONETARY,
40         VARIABLE_LC_MESSAGES,
41         VARIABLE_LC_PAPER,
42         VARIABLE_LC_NAME,
43         VARIABLE_LC_ADDRESS,
44         VARIABLE_LC_TELEPHONE,
45         VARIABLE_LC_MEASUREMENT,
46         VARIABLE_LC_IDENTIFICATION,
47         _VARIABLE_LC_MAX,
48         _VARIABLE_LC_INVALID = -1
49 } LocaleVariable;
50
51 int get_locales(char ***l);
52 bool locale_is_valid(const char *name);
53
54 #define _(String) gettext(String)
55 #define N_(String) String
56 void init_gettext(void);
57
58 bool is_locale_utf8(void);
59
60 typedef enum {
61         TREE_VERTICAL,
62         TREE_BRANCH,
63         TREE_RIGHT,
64         TREE_SPACE,
65         TRIANGULAR_BULLET,
66         BLACK_CIRCLE,
67         ARROW,
68         MDASH,
69         _SPECIAL_GLYPH_MAX
70 } SpecialGlyph;
71
72 const char *special_glyph(SpecialGlyph code) _const_;
73
74 const char* locale_variable_to_string(LocaleVariable i) _const_;
75 LocaleVariable locale_variable_from_string(const char *s) _pure_;
76
77 int get_keymaps(char ***l);
78 bool keymap_is_valid(const char *name);
79
80 static inline void freelocalep(locale_t *p) {
81         if (*p == (locale_t) 0)
82                 return;
83
84         freelocale(*p);
85 }