162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * cifs_unicode: Unicode kernel case support 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Function: 662306a36Sopenharmony_ci * Convert a unicode character to upper or lower case using 762306a36Sopenharmony_ci * compressed tables. 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * Copyright (c) International Business Machines Corp., 2000,2009 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * Notes: 1262306a36Sopenharmony_ci * These APIs are based on the C library functions. The semantics 1362306a36Sopenharmony_ci * should match the C functions but with expanded size operands. 1462306a36Sopenharmony_ci * 1562306a36Sopenharmony_ci * The upper/lower functions are based on a table created by mkupr. 1662306a36Sopenharmony_ci * This is a compressed table of upper and lower case conversion. 1762306a36Sopenharmony_ci */ 1862306a36Sopenharmony_ci#ifndef _CIFS_UNICODE_H 1962306a36Sopenharmony_ci#define _CIFS_UNICODE_H 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#include <asm/byteorder.h> 2262306a36Sopenharmony_ci#include <linux/types.h> 2362306a36Sopenharmony_ci#include <linux/nls.h> 2462306a36Sopenharmony_ci#include "../../nls/nls_ucs2_utils.h" 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* 2762306a36Sopenharmony_ci * Macs use an older "SFM" mapping of the symbols above. Fortunately it does 2862306a36Sopenharmony_ci * not conflict (although almost does) with the mapping above. 2962306a36Sopenharmony_ci */ 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci#define SFM_DOUBLEQUOTE ((__u16) 0xF020) 3262306a36Sopenharmony_ci#define SFM_ASTERISK ((__u16) 0xF021) 3362306a36Sopenharmony_ci#define SFM_QUESTION ((__u16) 0xF025) 3462306a36Sopenharmony_ci#define SFM_COLON ((__u16) 0xF022) 3562306a36Sopenharmony_ci#define SFM_GRTRTHAN ((__u16) 0xF024) 3662306a36Sopenharmony_ci#define SFM_LESSTHAN ((__u16) 0xF023) 3762306a36Sopenharmony_ci#define SFM_PIPE ((__u16) 0xF027) 3862306a36Sopenharmony_ci#define SFM_SLASH ((__u16) 0xF026) 3962306a36Sopenharmony_ci#define SFM_SPACE ((__u16) 0xF028) 4062306a36Sopenharmony_ci#define SFM_PERIOD ((__u16) 0xF029) 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci/* 4362306a36Sopenharmony_ci * Mapping mechanism to use when one of the seven reserved characters is 4462306a36Sopenharmony_ci * encountered. We can only map using one of the mechanisms at a time 4562306a36Sopenharmony_ci * since otherwise readdir could return directory entries which we would 4662306a36Sopenharmony_ci * not be able to open 4762306a36Sopenharmony_ci * 4862306a36Sopenharmony_ci * NO_MAP_UNI_RSVD = do not perform any remapping of the character 4962306a36Sopenharmony_ci * SFM_MAP_UNI_RSVD = map reserved characters using SFM scheme (MAC compatible) 5062306a36Sopenharmony_ci * SFU_MAP_UNI_RSVD = map reserved characters ala SFU ("mapchars" option) 5162306a36Sopenharmony_ci * 5262306a36Sopenharmony_ci */ 5362306a36Sopenharmony_ci#define NO_MAP_UNI_RSVD 0 5462306a36Sopenharmony_ci#define SFM_MAP_UNI_RSVD 1 5562306a36Sopenharmony_ci#define SFU_MAP_UNI_RSVD 2 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci#ifdef __KERNEL__ 5862306a36Sopenharmony_ciint cifs_from_utf16(char *to, const __le16 *from, int tolen, int fromlen, 5962306a36Sopenharmony_ci const struct nls_table *cp, int map_type); 6062306a36Sopenharmony_ciint cifs_utf16_bytes(const __le16 *from, int maxbytes, 6162306a36Sopenharmony_ci const struct nls_table *codepage); 6262306a36Sopenharmony_ciint cifs_strtoUTF16(__le16 *, const char *, int, const struct nls_table *); 6362306a36Sopenharmony_cichar *cifs_strndup_from_utf16(const char *src, const int maxlen, 6462306a36Sopenharmony_ci const bool is_unicode, 6562306a36Sopenharmony_ci const struct nls_table *codepage); 6662306a36Sopenharmony_ciextern int cifsConvertToUTF16(__le16 *target, const char *source, int maxlen, 6762306a36Sopenharmony_ci const struct nls_table *cp, int mapChars); 6862306a36Sopenharmony_ciextern int cifs_remap(struct cifs_sb_info *cifs_sb); 6962306a36Sopenharmony_ciextern __le16 *cifs_strndup_to_utf16(const char *src, const int maxlen, 7062306a36Sopenharmony_ci int *utf16_len, const struct nls_table *cp, 7162306a36Sopenharmony_ci int remap); 7262306a36Sopenharmony_ci#endif 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ciwchar_t cifs_toupper(wchar_t in); 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci#endif /* _CIFS_UNICODE_H */ 77