2 * nls.h - Header for encoding support functions
4 * Copyright (C) 2017 Collabora Ltd.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or (at
10 * your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 #define ARRAY_SIZE(array) \
33 (sizeof(array) / sizeof(array[0]))
36 int (*normalize)(const struct nls_table *charset,
37 const unsigned char *str, size_t len,
38 unsigned char *dest, size_t dlen);
40 int (*casefold)(const struct nls_table *charset,
41 const unsigned char *str, size_t len,
42 unsigned char *dest, size_t dlen);
47 const struct nls_ops *ops;
50 extern const struct nls_table nls_ascii;
54 const struct nls_table *tbl;
56 { EXT4_ENC_ASCII, &nls_ascii },
59 static const struct nls_table *nls_load_table(int encoding)
63 for (i = 0; i < ARRAY_SIZE(nls_map); i++) {
64 if (encoding == nls_map[i].encoding_magic)
65 return nls_map[i].tbl;