diff options
| author | Christoph Hellwig <hch@lst.de> | 2004-09-07 17:50:42 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-09-07 17:50:42 -0700 |
| commit | 5be94d3e80331a65338b81d575f4ab5615cc3ded (patch) | |
| tree | ff0c67c5adb534c7deb03a28d23d570eb9529b5c /include | |
| parent | 94486dbdabdd094868c8746a66501bfd3fb05ff0 (diff) | |
[PATCH] centralize some nls helpers
This patch adds common nls_tolower, nls_toupper and nls_strnicmp helpers to
nls.h and uses them in various filesystems instead of local duplicates.
The situation for ncpfs isn't as nice as it allows to compile without nls
support even if the kernel has CONFIG_NLS set, so we need wrappers there.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/nls.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/nls.h b/include/linux/nls.h index 1c657d4f0cf3..816c04ad7381 100644 --- a/include/linux/nls.h +++ b/include/linux/nls.h @@ -33,6 +33,31 @@ 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 */ |
