summaryrefslogtreecommitdiff
path: root/fs/hfsplus/unicode.h
blob: 31cc7691c9162389489d09bdd361cad3a70d6f1c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Unicode related declarations
 */

#ifndef _LINUX_HFSPLUS_UNICODE_H
#define _LINUX_HFSPLUS_UNICODE_H

/*
 * struct hfsplus_ccc_range - one run of consecutive BMP code points that
 *                            share the same Unicode canonical combining class
 * @first: the first UTF-16 code point in the run
 * @last: the last code point in the run (inclusive)
 * @combining_class: canonical combining class (ccc) shared by @first..@last
 */
struct hfsplus_ccc_range {
	u16 first;
	u16 last;
	u8 combining_class;
};

/*
 * struct hfsplus_legacy_decomp - corrected canonical decomposition
 * @uc: the code point (a UTF-16 code unit) to look up
 * @len: number of valid code units in @repl
 * @repl: corrected decomposition sequence (base letter + combining marks)
 */
struct hfsplus_legacy_decomp {
	u16 uc;
	u8 len;
#define HFSPLUS_LEGACY_DECOMP_MAX_LEN	(3)
	u16 repl[HFSPLUS_LEGACY_DECOMP_MAX_LEN];
};

/*
 * struct hfsplus_legacy_seq_fixup - corrected replacement for a short
 *                                   sequence of already-decomposed code units
 * @match_len: number of valid code units in @match
 * @match: decomposed sequence to look for in the buffer
 * @repl_len: number of valid code units in @repl
 * @repl: corrected sequence to substitute in place of @match
 */
struct hfsplus_legacy_seq_fixup {
	u8 match_len;
#define HFSPLUS_LEGACY_SEQ_MAX_MATCH	(3)
	u16 match[HFSPLUS_LEGACY_SEQ_MAX_MATCH];
	u8 repl_len;
#define HFSPLUS_LEGACY_SEQ_MAX_REPL	(2)
	u16 repl[HFSPLUS_LEGACY_SEQ_MAX_REPL];
};

extern u16 hfsplus_case_fold_table[];
extern u16 hfsplus_decompose_table[];
extern u16 hfsplus_compose_table[];
extern struct hfsplus_ccc_range hfsplus_ccc_table[];
extern struct hfsplus_legacy_decomp hfsplus_legacy_decomp_table[];
extern struct hfsplus_legacy_seq_fixup hfsplus_legacy_seq_fixups[];

u8 hfsplus_combining_class(u16 c);
const u16 *hfsplus_legacy_decompose(u16 uc, int *size);
void hfsplus_fixup_legacy_sequences(u16 *buf, int *len);

#endif /* _LINUX_HFSPLUS_UNICODE_H */