Lines Matching +full:end +full:- +full:of +full:- +full:conversion

1 // SPDX-License-Identifier: GPL-2.0-or-later
19 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SFM_CHR) in cifs_remap()
21 else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR) in cifs_remap()
29 /* Convert character using the SFU - "Services for Unix" remapping range */
63 /* Convert character using the SFM - "Services for Mac" remapping range */
68 *target = src_char - 0xF000; in convert_sfm_char()
107 * cifs_mapchar - convert a host-endian char to proper char in codepage
108 * @target - where converted character should be copied
109 * @src_char - 2 byte host-endian source character
110 * @cp - codepage to which character should be converted
111 * @map_type - How should the 7 NTFS/SMB reserved characters be mapped to UCS2?
113 * This function handles the conversion of a single character. It is the
114 * responsibility of the caller to ensure that the target buffer is large
115 * enough to hold the result of the conversion (at least NLS_MAX_CHARSET_SIZE).
132 /* if character not one of seven in special remap set */ in cifs_mapchar()
133 len = cp->uni2char(src_char, target, NLS_MAX_CHARSET_SIZE); in cifs_mapchar()
141 if (strcmp(cp->charset, "utf8")) in cifs_mapchar()
155 * cifs_from_utf16 - convert utf16le string to local charset
156 * @to - destination buffer
157 * @from - source buffer
158 * @tolen - destination buffer size (in bytes)
159 * @fromlen - source buffer size (in bytes)
160 * @codepage - codepage to which characters should be converted
161 * @mapchar - should characters be remapped according to the mapchars option?
163 * Convert a little-endian utf16le string (as sent by the server) to a string
165 * that the code doesn't walk off of the end of the buffer (which is always
166 * a danger if the alignment of the source buffer is off). The destination
168 * buffer. Returns the length of the destination string in bytes (including
171 * Note that some windows versions actually send multiword UTF-16 characters
172 * instead of straight UTF16-2. The linux nls routines however aren't able to
173 * deal with those characters properly. In the event that we get some of
185 __u16 ftmp[3]; /* ftmp[3] = 3array x 2bytes = 6bytes UTF-16 */ in cifs_from_utf16()
188 * because the chars can be of varying widths, we need to take care in cifs_from_utf16()
190 * end of it. Until we get to this offset, we don't need to check in cifs_from_utf16()
193 safelen = tolen - (NLS_MAX_CHARSET_SIZE + nullsize); in cifs_from_utf16()
210 * conversion bleed into the null terminator in cifs_from_utf16()
214 if ((outlen + charlen) > (tolen - nullsize)) in cifs_from_utf16()
222 /* charlen (=bytes of UTF-8 for 1 character) in cifs_from_utf16()
223 * 4bytes UTF-8(surrogate pair) is charlen=4 in cifs_from_utf16()
224 * (4bytes UTF-16 code) in cifs_from_utf16()
225 * 7-8bytes UTF-8(IVS) is charlen=3+4 or 4+4 in cifs_from_utf16()
226 * (2 UTF-8 pairs divided to 2 UTF-16 pairs) */ in cifs_from_utf16()
230 /* 5-6bytes UTF-8 */ in cifs_from_utf16()
234 /* properly null-terminate string */ in cifs_from_utf16()
256 if (!strcmp(codepage->charset, "utf8")) { in cifs_strtoUTF16()
258 * convert utf8 -> utf16, we assume we have enough space in cifs_strtoUTF16()
259 * as caller should have assumed conversion does not overflow in cifs_strtoUTF16()
276 for (i = 0; len && *from; i++, from += charlen, len -= charlen) { in cifs_strtoUTF16()
277 charlen = codepage->char2uni(from, len, &wchar_to); in cifs_strtoUTF16()
279 cifs_dbg(VFS, "strtoUTF16: char2uni of 0x%x returned %d\n", in cifs_strtoUTF16()
294 * cifs_utf16_bytes - how long will a string be after conversion?
295 * @utf16 - pointer to input string
296 * @maxbytes - don't go past this many bytes of input string
297 * @codepage - destination codepage
299 * Walk a utf16le string and return the number of bytes that the string will
334 * cifs_strndup_from_utf16 - copy a string from wire format to the local
336 * @src - source string
337 * @maxlen - don't walk past this many bytes in the source string
338 * @is_unicode - is this a unicode string?
339 * @codepage - destination codepage
448 * page. Conversion may involve remapping up the six characters that are
449 * only legal in POSIX-like OS (if they are present in the string). Path
461 wchar_t *wchar_to; /* UTF-16 */ in cifsConvertToUTF16()
474 /* check if end of string */ in cifsConvertToUTF16()
485 * Remap spaces and periods found at the end of every in cifsConvertToUTF16()
486 * component of the path. The special cases of '.' and in cifsConvertToUTF16()
487 * '..' are need to be handled because of symlinks. in cifsConvertToUTF16()
488 * They are treated as non-end-of-string to avoid in cifsConvertToUTF16()
491 if ((i == 0 || source[i-1] == '\\') && in cifsConvertToUTF16()
493 (i == srclen-1 || source[i+1] == '\\')) in cifsConvertToUTF16()
496 (i == 1 || source[i-2] == '\\') && in cifsConvertToUTF16()
497 source[i-1] == '.' && in cifsConvertToUTF16()
499 (i == srclen-1 || source[i+1] == '\\')) in cifsConvertToUTF16()
501 else if ((i == srclen - 1) || (source[i+1] == '\\')) in cifsConvertToUTF16()
515 charlen = cp->char2uni(source + i, srclen - i, &tmp); in cifsConvertToUTF16()
526 if (strcmp(cp->charset, "utf8") || !wchar_to) in cifsConvertToUTF16()
543 /* 1-3bytes UTF-8 to 2bytes UTF-16 */ in cifsConvertToUTF16()
546 /* 4bytes UTF-8(surrogate pair) to 4bytes UTF-16 in cifsConvertToUTF16()
547 * 7-8bytes UTF-8(IVS) divided to 2 UTF-16 in cifsConvertToUTF16()
554 /* 5-6bytes UTF-8 to 6bytes UTF-16 */ in cifsConvertToUTF16()
586 * cifs_local_to_utf16_bytes - how long will a string be after conversion?
587 * @from - pointer to input string
588 * @maxbytes - don't go past this many bytes of input string
589 * @codepage - source codepage
591 * Walk a string and return the number of bytes that the string will
604 for (i = 0; len && *from; i++, from += charlen, len -= charlen) { in cifs_local_to_utf16_bytes()
605 charlen = codepage->char2uni(from, len, &wchar_to); in cifs_local_to_utf16_bytes()
606 /* Failed conversion defaults to a question mark */ in cifs_local_to_utf16_bytes()
614 * cifs_strndup_to_utf16 - copy a string to wire format from the local codepage
615 * @src - source string
616 * @maxlen - don't walk past this many bytes in the source string
617 * @utf16_len - the length of the allocated string in bytes (including null)
618 * @cp - source codepage
619 * @remap - map special chars