zram: use __bio_add_page for adding single page to bio
[linux-block.git] / fs / unicode / utf8n.h
CommitLineData
9f806850 1/* SPDX-License-Identifier: GPL-2.0-only */
44594c2f
OW
2/*
3 * Copyright (c) 2014 SGI.
4 * All rights reserved.
44594c2f
OW
5 */
6
7#ifndef UTF8NORM_H
8#define UTF8NORM_H
9
10#include <linux/types.h>
11#include <linux/export.h>
12#include <linux/string.h>
13#include <linux/module.h>
49bd03cc 14#include <linux/unicode.h>
44594c2f 15
2b3d0478 16int utf8version_is_supported(const struct unicode_map *um, unsigned int version);
44594c2f 17
44594c2f
OW
18/*
19 * Determine the length of the normalized from of the string,
20 * excluding any terminating NULL byte.
21 * Returns 0 if only ignorable code points are present.
22 * Returns -1 if the input is not valid UTF-8.
23 */
6ca99ce7
CH
24ssize_t utf8nlen(const struct unicode_map *um, enum utf8_normalization n,
25 const char *s, size_t len);
44594c2f 26
a8384c68
OW
27/* Needed in struct utf8cursor below. */
28#define UTF8HANGULLEAF (12)
29
44594c2f
OW
30/*
31 * Cursor structure used by the normalizer.
32 */
33struct utf8cursor {
6ca99ce7
CH
34 const struct unicode_map *um;
35 enum utf8_normalization n;
44594c2f
OW
36 const char *s;
37 const char *p;
38 const char *ss;
39 const char *sp;
40 unsigned int len;
41 unsigned int slen;
42 short int ccc;
43 short int nccc;
a8384c68 44 unsigned char hangul[UTF8HANGULLEAF];
44594c2f
OW
45};
46
47/*
48 * Initialize a utf8cursor to normalize a string.
49 * Returns 0 on success.
50 * Returns -1 on failure.
51 */
6ca99ce7
CH
52int utf8ncursor(struct utf8cursor *u8c, const struct unicode_map *um,
53 enum utf8_normalization n, const char *s, size_t len);
44594c2f
OW
54
55/*
56 * Get the next byte in the normalization.
57 * Returns a value > 0 && < 256 on success.
58 * Returns 0 when the end of the normalization is reached.
59 * Returns -1 if the string being normalized is not valid UTF-8.
60 */
61extern int utf8byte(struct utf8cursor *u8c);
62
2b3d0478
CH
63struct utf8data {
64 unsigned int maxage;
65 unsigned int offset;
66};
67
68struct utf8data_table {
69 const unsigned int *utf8agetab;
70 int utf8agetab_size;
71
72 const struct utf8data *utf8nfdicfdata;
73 int utf8nfdicfdata_size;
74
75 const struct utf8data *utf8nfdidata;
76 int utf8nfdidata_size;
77
78 const unsigned char *utf8data;
79};
80
81extern struct utf8data_table utf8_data_table;
82
44594c2f 83#endif /* UTF8NORM_H */