From 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sat, 16 Apr 2005 15:20:36 -0700 Subject: Linux-2.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! --- include/linux/nls.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 include/linux/nls.h (limited to 'include/linux/nls.h') diff --git a/include/linux/nls.h b/include/linux/nls.h new file mode 100644 index 00000000000..816c04ad738 --- /dev/null +++ b/include/linux/nls.h @@ -0,0 +1,64 @@ +#ifndef _LINUX_NLS_H +#define _LINUX_NLS_H + +#include + +/* unicode character */ +typedef __u16 wchar_t; + +struct nls_table { + char *charset; + char *alias; + int (*uni2char) (wchar_t uni, unsigned char *out, int boundlen); + int (*char2uni) (const unsigned char *rawstring, int boundlen, + wchar_t *uni); + unsigned char *charset2lower; + unsigned char *charset2upper; + struct module *owner; + struct nls_table *next; +}; + +/* this value hold the maximum octet of charset */ +#define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */ + +/* nls.c */ +extern int register_nls(struct nls_table *); +extern int unregister_nls(struct nls_table *); +extern struct nls_table *load_nls(char *); +extern void unload_nls(struct nls_table *); +extern struct nls_table *load_nls_default(void); + +extern int utf8_mbtowc(wchar_t *, const __u8 *, int); +extern int utf8_mbstowcs(wchar_t *, const __u8 *, int); +extern int utf8_wctomb(__u8 *, wchar_t, int); +extern int utf8_wcstombs(__u8 *, const wchar_t *, int); + +static inline unsigned char nls_tolower(struct nls_table *t, unsigned char c) +{ + unsigned char nc = t->charset2lower[c]; + + return nc ? nc : c; +} + +static inline unsigned char nls_toupper(struct nls_table *t, unsigned char c) +{ + unsigned char nc = t->charset2upper[c]; + + return nc ? nc : c; +} + +static inline int nls_strnicmp(struct nls_table *t, const unsigned char *s1, + const unsigned char *s2, int len) +{ + while (len--) { + if (nls_tolower(t, *s1++) != nls_tolower(t, *s2++)) + return 1; + } + + return 0; +} + +#define MODULE_ALIAS_NLS(name) MODULE_ALIAS("nls_" __stringify(name)) + +#endif /* _LINUX_NLS_H */ + -- cgit v1.2.3