1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2/* 3 * cifs_unicode: Unicode kernel case support 4 * 5 * Function: 6 * Convert a unicode character to upper or lower case using 7 * compressed tables. 8 * 9 * Copyright (c) International Business Machines Corp., 2000,2009 10 * 11 * Notes: 12 * These APIs are based on the C library functions. The semantics 13 * should match the C functions but with expanded size operands. 14 * 15 * The upper/lower functions are based on a table created by mkupr. 16 * This is a compressed table of upper and lower case conversion. 17 */ 18#ifndef _CIFS_UNICODE_H 19#define _CIFS_UNICODE_H 20 21#include <asm/byteorder.h> 22#include <linux/types.h> 23#include <linux/nls.h> 24#include "../../nls/nls_ucs2_utils.h" 25 26/* 27 * Macs use an older "SFM" mapping of the symbols above. Fortunately it does 28 * not conflict (although almost does) with the mapping above. 29 */ 30 31#define SFM_DOUBLEQUOTE ((__u16) 0xF020) 32#define SFM_ASTERISK ((__u16) 0xF021) 33#define SFM_QUESTION ((__u16) 0xF025) 34#define SFM_COLON ((__u16) 0xF022) 35#define SFM_GRTRTHAN ((__u16) 0xF024) 36#define SFM_LESSTHAN ((__u16) 0xF023) 37#define SFM_PIPE ((__u16) 0xF027) 38#define SFM_SLASH ((__u16) 0xF026) 39#define SFM_SPACE ((__u16) 0xF028) 40#define SFM_PERIOD ((__u16) 0xF029) 41 42/* 43 * Mapping mechanism to use when one of the seven reserved characters is 44 * encountered. We can only map using one of the mechanisms at a time 45 * since otherwise readdir could return directory entries which we would 46 * not be able to open 47 * 48 * NO_MAP_UNI_RSVD = do not perform any remapping of the character 49 * SFM_MAP_UNI_RSVD = map reserved characters using SFM scheme (MAC compatible) 50 * SFU_MAP_UNI_RSVD = map reserved characters ala SFU ("mapchars" option) 51 * 52 */ 53#define NO_MAP_UNI_RSVD 0 54#define SFM_MAP_UNI_RSVD 1 55#define SFU_MAP_UNI_RSVD 2 56 57#ifdef __KERNEL__ 58int cifs_from_utf16(char *to, const __le16 *from, int tolen, int fromlen, 59 const struct nls_table *cp, int map_type); 60int cifs_utf16_bytes(const __le16 *from, int maxbytes, 61 const struct nls_table *codepage); 62int cifs_strtoUTF16(__le16 *, const char *, int, const struct nls_table *); 63char *cifs_strndup_from_utf16(const char *src, const int maxlen, 64 const bool is_unicode, 65 const struct nls_table *codepage); 66extern int cifsConvertToUTF16(__le16 *target, const char *source, int maxlen, 67 const struct nls_table *cp, int mapChars); 68extern int cifs_remap(struct cifs_sb_info *cifs_sb); 69extern __le16 *cifs_strndup_to_utf16(const char *src, const int maxlen, 70 int *utf16_len, const struct nls_table *cp, 71 int remap); 72#endif 73 74wchar_t cifs_toupper(wchar_t in); 75 76#endif /* _CIFS_UNICODE_H */ 77