/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Some of the source code in this file came from fs/cifs/cifs_unicode.c * and then via server/unicode.c * cifs_unicode: Unicode kernel case support * * Function: * Convert a unicode character to upper or lower case using * compressed tables. * * Copyright (c) International Business Machines Corp., 2000,2009 * * * Notes: * These APIs are based on the C library functions. The semantics * should match the C functions but with expanded size operands. * * The upper/lower functions are based on a table created by mkupr. * This is a compressed table of upper and lower case conversion. * */ #ifndef _NLS_UCS2_UTILS_H #define _NLS_UCS2_UTILS_H #include <asm/byteorder.h> #include <linux/types.h> #include <linux/nls.h> #include <linux/unicode.h> #include "nls_ucs2_data.h" /* * Windows maps these to the user defined 16 bit Unicode range since they are * reserved symbols (along with \ and /), otherwise illegal to store * in filenames in NTFS */ #define UNI_ASTERISK … #define UNI_QUESTION … #define UNI_COLON … #define UNI_GRTRTHAN … #define UNI_LESSTHAN … #define UNI_PIPE … #define UNI_SLASH … /* * UniStrcat: Concatenate the second string to the first * * Returns: * Address of the first string */ static inline wchar_t *UniStrcat(wchar_t *ucs1, const wchar_t *ucs2) { … } /* * UniStrchr: Find a character in a string * * Returns: * Address of first occurrence of character in string * or NULL if the character is not in the string */ static inline wchar_t *UniStrchr(const wchar_t *ucs, wchar_t uc) { … } /* * UniStrcmp: Compare two strings * * Returns: * < 0: First string is less than second * = 0: Strings are equal * > 0: First string is greater than second */ static inline int UniStrcmp(const wchar_t *ucs1, const wchar_t *ucs2) { … } /* * UniStrcpy: Copy a string */ static inline wchar_t *UniStrcpy(wchar_t *ucs1, const wchar_t *ucs2) { … } /* * UniStrlen: Return the length of a string (in 16 bit Unicode chars not bytes) */ static inline size_t UniStrlen(const wchar_t *ucs1) { … } /* * UniStrnlen: Return the length (in 16 bit Unicode chars not bytes) of a * string (length limited) */ static inline size_t UniStrnlen(const wchar_t *ucs1, int maxlen) { … } /* * UniStrncat: Concatenate length limited string */ static inline wchar_t *UniStrncat(wchar_t *ucs1, const wchar_t *ucs2, size_t n) { … } /* * UniStrncmp: Compare length limited string */ static inline int UniStrncmp(const wchar_t *ucs1, const wchar_t *ucs2, size_t n) { … } /* * UniStrncmp_le: Compare length limited string - native to little-endian */ static inline int UniStrncmp_le(const wchar_t *ucs1, const wchar_t *ucs2, size_t n) { … } /* * UniStrncpy: Copy length limited string with pad */ static inline wchar_t *UniStrncpy(wchar_t *ucs1, const wchar_t *ucs2, size_t n) { … } /* * UniStrncpy_le: Copy length limited string with pad to little-endian */ static inline wchar_t *UniStrncpy_le(wchar_t *ucs1, const wchar_t *ucs2, size_t n) { … } /* * UniStrstr: Find a string in a string * * Returns: * Address of first match found * NULL if no matching string is found */ static inline wchar_t *UniStrstr(const wchar_t *ucs1, const wchar_t *ucs2) { … } #ifndef UNIUPR_NOUPPER /* * UniToupper: Convert a unicode character to upper case */ static inline wchar_t UniToupper(register wchar_t uc) { … } /* * UniStrupr: Upper case a unicode string */ static inline __le16 *UniStrupr(register __le16 *upin) { … } #endif /* UNIUPR_NOUPPER */ #endif /* _NLS_UCS2_UTILS_H */