@@ -542,7 +542,7 @@ befs_utf2nls(struct super_block *sb, const char *in,
/* convert from Unicode to nls */
if (uni > MAX_WCHAR_T)
goto conv_err;
- unilen = nls->uni2char(uni, &result[o], in_len - o);
+ unilen = nls_uni2char(nls, uni, &result[o], in_len - o);
if (unilen < 0)
goto conv_err;
}
@@ -616,7 +616,7 @@ befs_nls2utf(struct super_block *sb, const char *in,
for (i = o = 0; i < in_len; i += unilen, o += utflen) {
/* convert from nls to unicode */
- unilen = nls->char2uni(&in[i], in_len - i, &uni);
+ unilen = nls_char2uni(nls, &in[i], in_len - i, &uni);
if (unilen < 0)
goto conv_err;
@@ -145,7 +145,7 @@ cifs_mapchar(char *target, const __u16 *from, const struct nls_table *cp,
return len;
/* if character not one of seven in special remap set */
- len = cp->uni2char(src_char, target, NLS_MAX_CHARSET_SIZE);
+ len = nls_uni2char(cp, src_char, target, NLS_MAX_CHARSET_SIZE);
if (len <= 0)
goto surrogate_pair;
@@ -289,7 +289,7 @@ cifs_strtoUTF16(__le16 *to, const char *from, int len,
}
for (i = 0; len && *from; i++, from += charlen, len -= charlen) {
- charlen = codepage->char2uni(from, len, &wchar_to);
+ charlen = nls_char2uni(codepage, from, len, &wchar_to);
if (charlen < 1) {
cifs_dbg(VFS, "strtoUTF16: char2uni of 0x%x returned %d\n",
*from, charlen);
@@ -515,7 +515,8 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
* as they use backslash as separator.
*/
if (dst_char == 0) {
- charlen = cp->char2uni(source + i, srclen - i, &tmp);
+ charlen = nls_char2uni(cp, source + i, srclen - i,
+ &tmp);
dst_char = cpu_to_le16(tmp);
/*
@@ -605,7 +606,7 @@ cifs_local_to_utf16_bytes(const char *from, int len,
wchar_t wchar_to;
for (i = 0; len && *from; i++, from += charlen, len -= charlen) {
- charlen = codepage->char2uni(from, len, &wchar_to);
+ charlen = nls_char2uni(codepage, from, len, &wchar_to);
/* Failed conversion defaults to a question mark */
if (charlen < 1)
charlen = 1;
@@ -910,7 +910,7 @@ static int cifs_ci_hash(const struct dentry *dentry, struct qstr *q)
hash = init_name_hash(dentry);
for (i = 0; i < q->len; i += charlen) {
- charlen = codepage->char2uni(&q->name[i], q->len - i, &c);
+ charlen = nls_char2uni(codepage, &q->name[i], q->len - i, &c);
/* error out if we can't convert the character */
if (unlikely(charlen < 0))
return charlen;
@@ -939,8 +939,9 @@ static int cifs_ci_compare(const struct dentry *dentry,
for (i = 0; i < len; i += l1) {
/* Convert characters in both strings to UTF-16. */
- l1 = codepage->char2uni(&str[i], len - i, &c1);
- l2 = codepage->char2uni(&name->name[i], name->len - i, &c2);
+ l1 = nls_char2uni(codepage, &str[i], len - i, &c1);
+ l2 = nls_char2uni(codepage, &name->name[i], name->len - i,
+ &c2);
/*
* If we can't convert either character, just declare it to
@@ -153,7 +153,7 @@ static int uni16_to_x8(struct super_block *sb, unsigned char *ascii,
while (*ip && ((len - NLS_MAX_CHARSET_SIZE) > 0)) {
ec = *ip++;
- charlen = nls->uni2char(ec, op, NLS_MAX_CHARSET_SIZE);
+ charlen = nls_uni2char(nls, ec, op, NLS_MAX_CHARSET_SIZE);
if (charlen > 0) {
op += charlen;
len -= charlen;
@@ -195,7 +195,7 @@ fat_short2uni(struct nls_table *t, unsigned char *c, int clen, wchar_t *uni)
{
int charlen;
- charlen = t->char2uni(c, clen, uni);
+ charlen = nls_char2uni(t, c, clen, uni);
if (charlen < 0) {
*uni = 0x003f; /* a question mark */
charlen = 1;
@@ -210,7 +210,7 @@ fat_short2lower_uni(struct nls_table *t, unsigned char *c,
int charlen;
wchar_t wc;
- charlen = t->char2uni(c, clen, &wc);
+ charlen = nls_char2uni(t, c, clen, &wc);
if (charlen < 0) {
*uni = 0x003f; /* a question mark */
charlen = 1;
@@ -220,7 +220,7 @@ fat_short2lower_uni(struct nls_table *t, unsigned char *c,
if (!nc)
nc = *c;
- charlen = t->char2uni(&nc, 1, uni);
+ charlen = nls_char2uni(t, &nc, 1, uni);
if (charlen < 0) {
*uni = 0x003f; /* a question mark */
charlen = 1;
@@ -289,7 +289,7 @@ static inline int to_shortname_char(struct nls_table *nls,
return 1;
}
- len = nls->uni2char(*src, buf, buf_size);
+ len = nls_uni2char(nls, *src, buf, buf_size);
if (len <= 0) {
info->valid = 0;
buf[0] = '_';
@@ -544,8 +544,8 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
ip += 5;
i += 5;
} else {
- charlen = nls->char2uni(ip, len - i,
- (wchar_t *)op);
+ charlen = nls_char2uni(nls, ip, len - i,
+ (wchar_t *)op);
if (charlen < 0)
return -EINVAL;
ip += charlen;
@@ -49,7 +49,8 @@ int hfs_mac2asc(struct super_block *sb, char *out, const struct hfs_name *in)
while (srclen > 0) {
if (nls_disk) {
- size = nls_disk->char2uni(src, srclen, &ch);
+ size = nls_char2uni(nls_disk, src, srclen,
+ &ch);
if (size <= 0) {
ch = '?';
size = 1;
@@ -62,7 +63,7 @@ int hfs_mac2asc(struct super_block *sb, char *out, const struct hfs_name *in)
}
if (ch == '/')
ch = ':';
- size = nls_io->uni2char(ch, dst, dstlen);
+ size = nls_uni2char(nls_io, ch, dst, dstlen);
if (size < 0) {
if (size == -ENAMETOOLONG)
goto out;
@@ -110,7 +111,7 @@ void hfs_asc2mac(struct super_block *sb, struct hfs_name *out, const struct qstr
wchar_t ch;
while (srclen > 0) {
- size = nls_io->char2uni(src, srclen, &ch);
+ size = nls_char2uni(nls_io, src, srclen, &ch);
if (size < 0) {
ch = '?';
size = 1;
@@ -120,7 +121,7 @@ void hfs_asc2mac(struct super_block *sb, struct hfs_name *out, const struct qstr
if (ch == ':')
ch = '/';
if (nls_disk) {
- size = nls_disk->uni2char(ch, dst, dstlen);
+ size = nls_uni2char(nls_disk, ch, dst, dstlen);
if (size < 0) {
if (size == -ENAMETOOLONG)
goto out;
@@ -190,7 +190,7 @@ int hfsplus_uni2asc(struct super_block *sb,
c0 = ':';
break;
}
- res = nls->uni2char(c0, op, len);
+ res = nls_uni2char(nls, c0, op, len);
if (res < 0) {
if (res == -ENAMETOOLONG)
goto out;
@@ -233,7 +233,7 @@ int hfsplus_uni2asc(struct super_block *sb,
cc = c0;
}
done:
- res = nls->uni2char(cc, op, len);
+ res = nls_uni2char(nls, cc, op, len);
if (res < 0) {
if (res == -ENAMETOOLONG)
goto out;
@@ -256,7 +256,7 @@ int hfsplus_uni2asc(struct super_block *sb,
static inline int asc2unichar(struct super_block *sb, const char *astr, int len,
wchar_t *uc)
{
- int size = HFSPLUS_SB(sb)->nls->char2uni(astr, len, uc);
+ int size = nls_char2uni(HFSPLUS_SB(sb)->nls, astr, len, uc);
if (size <= 0) {
*uc = '?';
size = 1;
@@ -25,7 +25,8 @@ uni16_to_x8(unsigned char *ascii, __be16 *uni, int len, struct nls_table *nls)
while ((ch = get_unaligned(ip)) && len) {
int llen;
- llen = nls->uni2char(be16_to_cpu(ch), op, NLS_MAX_CHARSET_SIZE);
+ llen = nls_uni2char(nls, be16_to_cpu(ch), op,
+ NLS_MAX_CHARSET_SIZE);
if (llen > 0)
op += llen;
else
@@ -41,9 +41,8 @@ int jfs_strfromUCS_le(char *to, const __le16 * from,
for (i = 0; (i < len) && from[i]; i++) {
int charlen;
charlen =
- codepage->uni2char(le16_to_cpu(from[i]),
- &to[outlen],
- NLS_MAX_CHARSET_SIZE);
+ nls_uni2char(codepage, le16_to_cpu(from[i]),
+ &to[outlen], NLS_MAX_CHARSET_SIZE);
if (charlen > 0)
outlen += charlen;
else
@@ -88,7 +87,7 @@ static int jfs_strtoUCS(wchar_t * to, const unsigned char *from, int len,
if (codepage) {
for (i = 0; len && *from; i++, from += charlen, len -= charlen)
{
- charlen = codepage->char2uni(from, len, &to[i]);
+ charlen = nls_char2uni(codepage, from, len, &to[i]);
if (charlen < 1) {
jfs_err("jfs_strtoUCS: char2uni returned %d.",
charlen);
@@ -413,7 +413,7 @@ static int uni2char(const wchar_t uni,
if (!p_nls)
return -EINVAL;
- if ((n = p_nls->uni2char(uni, out, boundlen)) < 0)
+ if ((n = nls_uni2char(p_nls, uni, out, boundlen)) < 0)
return n;
/* translate SJIS into EUC-JP */
@@ -543,7 +543,7 @@ static int char2uni(const unsigned char *rawstring, int boundlen,
sjis_temp[1] = 0x00;
}
- if ( (n = p_nls->char2uni(sjis_temp, sizeof(sjis_temp), uni)) < 0)
+ if ( (n = nls_char2uni(p_nls, sjis_temp, sizeof(sjis_temp), uni)) < 0)
return n;
return euc_offset;
@@ -28,12 +28,12 @@ static int uni2char(const wchar_t uni,
else if (uni == 0x255d || uni == 0x256c)
return 0;
else
- return p_nls->uni2char(uni, out, boundlen);
+ return nls_uni2char(p_nls, uni, out, boundlen);
return 1;
}
else
/* fast path */
- return p_nls->uni2char(uni, out, boundlen);
+ return nls_uni2char(p_nls, uni, out, boundlen);
}
static int char2uni(const unsigned char *rawstring, int boundlen,
@@ -47,7 +47,7 @@ static int char2uni(const unsigned char *rawstring, int boundlen,
return 1;
}
- n = p_nls->char2uni(rawstring, boundlen, uni);
+ n = nls_char2uni(p_nls, rawstring, boundlen, uni);
return n;
}
@@ -269,8 +269,8 @@ int ntfs_nlstoucs(const ntfs_volume *vol, const char *ins,
ucs = kmem_cache_alloc(ntfs_name_cache, GFP_NOFS);
if (likely(ucs)) {
for (i = o = 0; i < ins_len; i += wc_len) {
- wc_len = nls->char2uni(ins + i, ins_len - i,
- &wc);
+ wc_len = nls_char2uni(nls, ins + i,
+ ins_len - i, &wc);
if (likely(wc_len >= 0 &&
o < NTFS_MAX_NAME_LEN)) {
if (likely(wc)) {
@@ -355,8 +355,8 @@ int ntfs_ucstonls(const ntfs_volume *vol, const ntfschar *ins,
goto mem_err_out;
}
for (i = o = 0; i < ins_len; i++) {
-retry: wc = nls->uni2char(le16_to_cpu(ins[i]), ns + o,
- ns_len - o);
+retry: wc = nls_uni2char(nls, le16_to_cpu(ins[i]),
+ ns + o, ns_len - o);
if (wc > 0) {
o += wc;
continue;
@@ -59,6 +59,19 @@ extern int utf8s_to_utf16s(const u8 *s, int len,
extern int utf16s_to_utf8s(const wchar_t *pwcs, int len,
enum utf16_endian endian, u8 *s, int maxlen);
+static inline int nls_uni2char(const struct nls_table *table, wchar_t uni,
+ unsigned char *out, int boundlen)
+{
+ return table->uni2char(uni, out, boundlen);
+}
+
+static inline int nls_char2uni(const struct nls_table *table,
+ const unsigned char *rawstring,
+ int boundlen, wchar_t *uni)
+{
+ return table->char2uni(rawstring, boundlen, uni);
+}
+
static inline unsigned char nls_tolower(struct nls_table *t, unsigned char c)
{
unsigned char nc = t->charset2lower[c];