cifs_unicode.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #include <asm/byteorder.h>
  21. #include <linux/types.h>
  22. #include <linux/nls.h>
  23. #include "../../nls/nls_ucs2_utils.h"
  24. /*
  25. * Macs use an older "SFM" mapping of the symbols above. Fortunately it does
  26. * not conflict (although almost does) with the mapping above.
  27. */
  28. #define SFM_DOUBLEQUOTE ((__u16) 0xF020)
  29. #define SFM_ASTERISK ((__u16) 0xF021)
  30. #define SFM_QUESTION ((__u16) 0xF025)
  31. #define SFM_COLON ((__u16) 0xF022)
  32. #define SFM_GRTRTHAN ((__u16) 0xF024)
  33. #define SFM_LESSTHAN ((__u16) 0xF023)
  34. #define SFM_PIPE ((__u16) 0xF027)
  35. #define SFM_SLASH ((__u16) 0xF026)
  36. #define SFM_SPACE ((__u16) 0xF028)
  37. #define SFM_PERIOD ((__u16) 0xF029)
  38. /*
  39. * Mapping mechanism to use when one of the seven reserved characters is
  40. * encountered. We can only map using one of the mechanisms at a time
  41. * since otherwise readdir could return directory entries which we would
  42. * not be able to open
  43. *
  44. * NO_MAP_UNI_RSVD = do not perform any remapping of the character
  45. * SFM_MAP_UNI_RSVD = map reserved characters using SFM scheme (MAC compatible)
  46. * SFU_MAP_UNI_RSVD = map reserved characters ala SFU ("mapchars" option)
  47. *
  48. */
  49. #define NO_MAP_UNI_RSVD 0
  50. #define SFM_MAP_UNI_RSVD 1
  51. #define SFU_MAP_UNI_RSVD 2
  52. #ifdef __KERNEL__
  53. int cifs_from_utf16(char *to, const __le16 *from, int tolen, int fromlen,
  54. const struct nls_table *cp, int map_type);
  55. int cifs_utf16_bytes(const __le16 *from, int maxbytes,
  56. const struct nls_table *codepage);
  57. int cifs_strtoUTF16(__le16 *, const char *, int, const struct nls_table *);
  58. char *cifs_strndup_from_utf16(const char *src, const int maxlen,
  59. const bool is_unicode,
  60. const struct nls_table *codepage);
  61. extern int cifsConvertToUTF16(__le16 *target, const char *source, int maxlen,
  62. const struct nls_table *cp, int mapChars);
  63. extern int cifs_remap(struct cifs_sb_info *cifs_sb);
  64. extern __le16 *cifs_strndup_to_utf16(const char *src, const int maxlen,
  65. int *utf16_len, const struct nls_table *cp,
  66. int remap);
  67. #endif
  68. wchar_t cifs_toupper(wchar_t in);
  69. #endif /* _CIFS_UNICODE_H */