aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/nls.h
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2009-04-30 06:45:08 -0400
committerSteve French <sfrench@us.ibm.com>2009-04-30 11:32:11 -0400
commitd37dc42ab6f040b8f0f2962ab219c5b2accf748d (patch)
tree5030ecff53843afe1f362cdca3d0794cda17fac1 /include/linux/nls.h
parentcbb7fe129bb2b836083ebcc256c43faff4b48cc2 (diff)
nls: add a nls_nullsize inline
It's possible for character sets to require a multi-byte null string terminator. Add a helper function that determines the size of the null terminator at runtime. Signed-off-by: Jeff Layton <jlayton@redhat.com> Acked-by: Suresh Jayaraman <sjayaraman@suse.de> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'include/linux/nls.h')
-rw-r--r--include/linux/nls.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/nls.h b/include/linux/nls.h
index 6a882208301a..52b1a76c1b43 100644
--- a/include/linux/nls.h
+++ b/include/linux/nls.h
@@ -58,6 +58,25 @@ static inline int nls_strnicmp(struct nls_table *t, const unsigned char *s1,
58 return 0; 58 return 0;
59} 59}
60 60
61/*
62 * nls_nullsize - return length of null character for codepage
63 * @codepage - codepage for which to return length of NULL terminator
64 *
65 * Since we can't guarantee that the null terminator will be a particular
66 * length, we have to check against the codepage. If there's a problem
67 * determining it, assume a single-byte NULL terminator.
68 */
69static inline int
70nls_nullsize(const struct nls_table *codepage)
71{
72 int charlen;
73 char tmp[NLS_MAX_CHARSET_SIZE];
74
75 charlen = codepage->uni2char(0, tmp, NLS_MAX_CHARSET_SIZE);
76
77 return charlen > 0 ? charlen : 1;
78}
79
61#define MODULE_ALIAS_NLS(name) MODULE_ALIAS("nls_" __stringify(name)) 80#define MODULE_ALIAS_NLS(name) MODULE_ALIAS("nls_" __stringify(name))
62 81
63#endif /* _LINUX_NLS_H */ 82#endif /* _LINUX_NLS_H */