aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/nls.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/nls.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/linux/nls.h')
-rw-r--r--include/linux/nls.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/include/linux/nls.h b/include/linux/nls.h
new file mode 100644
index 000000000000..816c04ad7381
--- /dev/null
+++ b/include/linux/nls.h
@@ -0,0 +1,64 @@
1#ifndef _LINUX_NLS_H
2#define _LINUX_NLS_H
3
4#include <linux/init.h>
5
6/* unicode character */
7typedef __u16 wchar_t;
8
9struct nls_table {
10 char *charset;
11 char *alias;
12 int (*uni2char) (wchar_t uni, unsigned char *out, int boundlen);
13 int (*char2uni) (const unsigned char *rawstring, int boundlen,
14 wchar_t *uni);
15 unsigned char *charset2lower;
16 unsigned char *charset2upper;
17 struct module *owner;
18 struct nls_table *next;
19};
20
21/* this value hold the maximum octet of charset */
22#define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
23
24/* nls.c */
25extern int register_nls(struct nls_table *);
26extern int unregister_nls(struct nls_table *);
27extern struct nls_table *load_nls(char *);
28extern void unload_nls(struct nls_table *);
29extern struct nls_table *load_nls_default(void);
30
31extern int utf8_mbtowc(wchar_t *, const __u8 *, int);
32extern int utf8_mbstowcs(wchar_t *, const __u8 *, int);
33extern int utf8_wctomb(__u8 *, wchar_t, int);
34extern int utf8_wcstombs(__u8 *, const wchar_t *, int);
35
36static inline unsigned char nls_tolower(struct nls_table *t, unsigned char c)
37{
38 unsigned char nc = t->charset2lower[c];
39
40 return nc ? nc : c;
41}
42
43static inline unsigned char nls_toupper(struct nls_table *t, unsigned char c)
44{
45 unsigned char nc = t->charset2upper[c];
46
47 return nc ? nc : c;
48}
49
50static inline int nls_strnicmp(struct nls_table *t, const unsigned char *s1,
51 const unsigned char *s2, int len)
52{
53 while (len--) {
54 if (nls_tolower(t, *s1++) != nls_tolower(t, *s2++))
55 return 1;
56 }
57
58 return 0;
59}
60
61#define MODULE_ALIAS_NLS(name) MODULE_ALIAS("nls_" __stringify(name))
62
63#endif /* _LINUX_NLS_H */
64