Merge branch 'oprofile-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[pandora-kernel.git] / include / linux / nls.h
index 816c04a..52b1a76 100644 (file)
@@ -7,13 +7,13 @@
 typedef __u16 wchar_t;
 
 struct nls_table {
-       char *charset;
-       char *alias;
+       const char *charset;
+       const 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;
+       const unsigned char *charset2lower;
+       const unsigned char *charset2upper;
        struct module *owner;
        struct nls_table *next;
 };
@@ -58,6 +58,25 @@ static inline int nls_strnicmp(struct nls_table *t, const unsigned char *s1,
        return 0;
 }
 
+/*
+ * nls_nullsize - return length of null character for codepage
+ * @codepage - codepage for which to return length of NULL terminator
+ *
+ * Since we can't guarantee that the null terminator will be a particular
+ * length, we have to check against the codepage. If there's a problem
+ * determining it, assume a single-byte NULL terminator.
+ */
+static inline int
+nls_nullsize(const struct nls_table *codepage)
+{
+       int charlen;
+       char tmp[NLS_MAX_CHARSET_SIZE];
+
+       charlen = codepage->uni2char(0, tmp, NLS_MAX_CHARSET_SIZE);
+
+       return charlen > 0 ? charlen : 1;
+}
+
 #define MODULE_ALIAS_NLS(name) MODULE_ALIAS("nls_" __stringify(name))
 
 #endif /* _LINUX_NLS_H */