1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _LINUX_UNICODE_H 3 #define _LINUX_UNICODE_H 4 5 #include <linux/init.h> 6 #include <linux/dcache.h> 7 8 #define UNICODE_MAJ_SHIFT 16 9 #define UNICODE_MIN_SHIFT 8 10 11 #define UNICODE_AGE(MAJ, MIN, REV) \ 12 (((unsigned int)(MAJ) << UNICODE_MAJ_SHIFT) | \ 13 ((unsigned int)(MIN) << UNICODE_MIN_SHIFT) | \ 14 ((unsigned int)(REV))) 15 16 static inline u8 unicode_major(unsigned int age) 17 { 18 return (age >> UNICODE_MAJ_SHIFT) & 0xff; 19 } 20 21 static inline u8 unicode_minor(unsigned int age) 22 { 23 return (age >> UNICODE_MIN_SHIFT) & 0xff; 24 } 25 26 static inline u8 unicode_rev(unsigned int age) 27 { 28 return age & 0xff; 29 } 30 31 struct unicode_map { 32 unsigned int version; 33 }; 34 35 int utf8_validate(const struct unicode_map *um, const struct qstr *str); 36 37 int utf8_strncmp(const struct unicode_map *um, 38 const struct qstr *s1, const struct qstr *s2); 39 40 int utf8_strncasecmp(const struct unicode_map *um, 41 const struct qstr *s1, const struct qstr *s2); 42 int utf8_strncasecmp_folded(const struct unicode_map *um, 43 const struct qstr *cf, 44 const struct qstr *s1); 45 46 int utf8_normalize(const struct unicode_map *um, const struct qstr *str, 47 unsigned char *dest, size_t dlen); 48 49 int utf8_casefold(const struct unicode_map *um, const struct qstr *str, 50 unsigned char *dest, size_t dlen); 51 52 int utf8_casefold_hash(const struct unicode_map *um, const void *salt, 53 struct qstr *str); 54 55 struct unicode_map *utf8_load(unsigned int version); 56 void utf8_unload(struct unicode_map *um); 57 58 #endif /* _LINUX_UNICODE_H */ 59