2019-04-26 01:51:22 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _LINUX_UNICODE_H
|
|
|
|
#define _LINUX_UNICODE_H
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/dcache.h>
|
|
|
|
|
2021-09-15 15:00:04 +08:00
|
|
|
struct utf8data;
|
2021-09-15 15:00:05 +08:00
|
|
|
struct utf8data_table;
|
2021-09-15 15:00:04 +08:00
|
|
|
|
2021-09-15 15:00:00 +08:00
|
|
|
#define UNICODE_MAJ_SHIFT 16
|
|
|
|
#define UNICODE_MIN_SHIFT 8
|
|
|
|
|
|
|
|
#define UNICODE_AGE(MAJ, MIN, REV) \
|
|
|
|
(((unsigned int)(MAJ) << UNICODE_MAJ_SHIFT) | \
|
|
|
|
((unsigned int)(MIN) << UNICODE_MIN_SHIFT) | \
|
|
|
|
((unsigned int)(REV)))
|
|
|
|
|
|
|
|
static inline u8 unicode_major(unsigned int age)
|
|
|
|
{
|
|
|
|
return (age >> UNICODE_MAJ_SHIFT) & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u8 unicode_minor(unsigned int age)
|
|
|
|
{
|
|
|
|
return (age >> UNICODE_MIN_SHIFT) & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u8 unicode_rev(unsigned int age)
|
|
|
|
{
|
|
|
|
return age & 0xff;
|
|
|
|
}
|
|
|
|
|
2021-09-15 15:00:04 +08:00
|
|
|
/*
|
|
|
|
* Two normalization forms are supported:
|
|
|
|
* 1) NFDI
|
|
|
|
* - Apply unicode normalization form NFD.
|
|
|
|
* - Remove any Default_Ignorable_Code_Point.
|
|
|
|
* 2) NFDICF
|
|
|
|
* - Apply unicode normalization form NFD.
|
|
|
|
* - Remove any Default_Ignorable_Code_Point.
|
|
|
|
* - Apply a full casefold (C + F).
|
|
|
|
*/
|
|
|
|
enum utf8_normalization {
|
|
|
|
UTF8_NFDI = 0,
|
|
|
|
UTF8_NFDICF,
|
|
|
|
UTF8_NMAX,
|
|
|
|
};
|
|
|
|
|
2019-04-26 01:51:22 +08:00
|
|
|
struct unicode_map {
|
2021-09-15 14:59:59 +08:00
|
|
|
unsigned int version;
|
2021-09-15 15:00:04 +08:00
|
|
|
const struct utf8data *ntab[UTF8_NMAX];
|
2021-09-15 15:00:05 +08:00
|
|
|
const struct utf8data_table *tables;
|
2019-04-26 01:51:22 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
int utf8_validate(const struct unicode_map *um, const struct qstr *str);
|
|
|
|
|
|
|
|
int utf8_strncmp(const struct unicode_map *um,
|
|
|
|
const struct qstr *s1, const struct qstr *s2);
|
|
|
|
|
|
|
|
int utf8_strncasecmp(const struct unicode_map *um,
|
|
|
|
const struct qstr *s1, const struct qstr *s2);
|
2019-06-20 11:45:09 +08:00
|
|
|
int utf8_strncasecmp_folded(const struct unicode_map *um,
|
|
|
|
const struct qstr *cf,
|
|
|
|
const struct qstr *s1);
|
2019-04-26 01:51:22 +08:00
|
|
|
|
|
|
|
int utf8_normalize(const struct unicode_map *um, const struct qstr *str,
|
|
|
|
unsigned char *dest, size_t dlen);
|
|
|
|
|
|
|
|
int utf8_casefold(const struct unicode_map *um, const struct qstr *str,
|
|
|
|
unsigned char *dest, size_t dlen);
|
|
|
|
|
2020-07-08 17:12:34 +08:00
|
|
|
int utf8_casefold_hash(const struct unicode_map *um, const void *salt,
|
|
|
|
struct qstr *str);
|
|
|
|
|
2021-09-15 15:00:00 +08:00
|
|
|
struct unicode_map *utf8_load(unsigned int version);
|
2019-04-26 01:51:22 +08:00
|
|
|
void utf8_unload(struct unicode_map *um);
|
|
|
|
|
|
|
|
#endif /* _LINUX_UNICODE_H */
|