Lines Matching +full:no +full:- +full:memory +full:- +full:wc

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * unistr.c - NTFS Unicode string handling. Part of the Linux-NTFS project.
5 * Copyright (c) 2001-2006 Anton Altaparmakov
41 * ntfs_are_names_equal - compare two Unicode names for equality
66 * ntfs_collate_names - collate two Unicode names
76 * -1 if the first name collates before the second one,
106 return -1; in ntfs_collate_names()
111 return -1; in ntfs_collate_names()
122 * ntfs_ucsncmp - compare two little endian Unicode strings
129 * conversion is performed on non-little endian machines.
144 return -1; in ntfs_ucsncmp()
154 * ntfs_ucsncasecmp - compare two little endian Unicode strings, ignoring case
163 * le16_to_cpu() conversion is performed on non-little endian machines.
183 return -1; in ntfs_ucsncasecmp()
206 ntfs_upcase_name((ntfschar*)&file_name_attr->file_name, in ntfs_file_upcase_value()
207 file_name_attr->file_name_length, upcase, upcase_len); in ntfs_file_upcase_value()
215 return ntfs_collate_names((ntfschar*)&file_name_attr1->file_name, in ntfs_file_compare_values()
216 file_name_attr1->file_name_length, in ntfs_file_compare_values()
217 (ntfschar*)&file_name_attr2->file_name, in ntfs_file_compare_values()
218 file_name_attr2->file_name_length, in ntfs_file_compare_values()
223 * ntfs_nlstoucs - convert NLS string to little endian Unicode string
230 * map dictates, into a little endian, 2-byte Unicode string.
248 struct nls_table *nls = vol->nls_map; in ntfs_nlstoucs()
250 wchar_t wc; in ntfs_nlstoucs() local
258 wc_len = nls->char2uni(ins + i, ins_len - i, in ntfs_nlstoucs()
259 &wc); in ntfs_nlstoucs()
262 if (likely(wc)) { in ntfs_nlstoucs()
263 ucs[o++] = cpu_to_le16(wc); in ntfs_nlstoucs()
265 } /* else if (!wc) */ in ntfs_nlstoucs()
275 ntfs_error(vol->sb, "Failed to allocate buffer for converted " in ntfs_nlstoucs()
277 return -ENOMEM; in ntfs_nlstoucs()
279 ntfs_error(vol->sb, "Received NULL pointer."); in ntfs_nlstoucs()
280 return -EINVAL; in ntfs_nlstoucs()
284 ntfs_error(vol->sb, "Name using character set %s contains " in ntfs_nlstoucs()
286 "Unicode.", nls->charset); in ntfs_nlstoucs()
287 i = -EILSEQ; in ntfs_nlstoucs()
289 ntfs_error(vol->sb, "Name is too long (maximum length for a " in ntfs_nlstoucs()
292 i = -ENAMETOOLONG; in ntfs_nlstoucs()
298 * ntfs_ucstonls - convert little endian Unicode string to NLS string
305 * Convert the input little endian, 2-byte Unicode string @ins, of length
325 struct nls_table *nls = vol->nls_map; in ntfs_ucstonls()
327 int i, o, ns_len, wc; in ntfs_ucstonls() local
334 wc = -ENAMETOOLONG; in ntfs_ucstonls()
344 retry: wc = nls->uni2char(le16_to_cpu(ins[i]), ns + o, in ntfs_ucstonls()
345 ns_len - o); in ntfs_ucstonls()
346 if (wc > 0) { in ntfs_ucstonls()
347 o += wc; in ntfs_ucstonls()
349 } else if (!wc) in ntfs_ucstonls()
351 else if (wc == -ENAMETOOLONG && ns != *outs) { in ntfs_ucstonls()
358 ns_len = ((ns_len + 64) & ~63) - 1; in ntfs_ucstonls()
362 } /* No memory so goto conversion_error; */ in ntfs_ucstonls()
363 } /* wc < 0, real error. */ in ntfs_ucstonls()
370 ntfs_error(vol->sb, "Received NULL pointer."); in ntfs_ucstonls()
371 return -EINVAL; in ntfs_ucstonls()
373 ntfs_error(vol->sb, "Unicode name contains characters that cannot be " in ntfs_ucstonls()
375 "try to use the mount option nls=utf8.", nls->charset); in ntfs_ucstonls()
378 if (wc != -ENAMETOOLONG) in ntfs_ucstonls()
379 wc = -EILSEQ; in ntfs_ucstonls()
380 return wc; in ntfs_ucstonls()
382 ntfs_error(vol->sb, "Failed to allocate name!"); in ntfs_ucstonls()
383 return -ENOMEM; in ntfs_ucstonls()