1 | /* Copyright (C) 1998-2023 Free Software Foundation, Inc. |
2 | This file is part of the GNU C Library. |
3 | |
4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published |
6 | by the Free Software Foundation; version 2 of the License, or |
7 | (at your option) any later version. |
8 | |
9 | This program is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | GNU General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU General Public License |
15 | along with this program; if not, see <https://www.gnu.org/licenses/>. */ |
16 | |
17 | #ifndef _REPERTOIREMAP_H |
18 | #define _REPERTOIREMAP_H 1 |
19 | |
20 | #include <obstack.h> |
21 | #include <stdint.h> |
22 | |
23 | #include "charmap.h" |
24 | #include "simple-hash.h" |
25 | |
26 | struct repertoire_t |
27 | { |
28 | const char *name; |
29 | struct obstack mem_pool; |
30 | hash_table char_table; |
31 | hash_table reverse_table; |
32 | hash_table seq_table; |
33 | }; |
34 | |
35 | |
36 | /* We need one value to mark the error case. Let's use 0xffffffff. |
37 | I.e., it is placed in the last page of ISO 10646. For now only the |
38 | first is used and we have plenty of room. */ |
39 | #define ILLEGAL_CHAR_VALUE ((uint32_t) 0xffffffffu) |
40 | |
41 | /* Another value is needed to signal that a value is not yet determined. */ |
42 | #define UNINITIALIZED_CHAR_VALUE ((uint32_t) 0xfffffffeu) |
43 | |
44 | |
45 | /* Prototypes for repertoire map handling functions. */ |
46 | extern struct repertoire_t *repertoire_read (const char *filename); |
47 | |
48 | /* Report missing repertoire map. */ |
49 | extern void repertoire_complain (const char *name); |
50 | |
51 | /* Return UCS4 value of character with given NAME. */ |
52 | extern uint32_t repertoire_find_value (const struct repertoire_t *repertoire, |
53 | const char *name, size_t len); |
54 | |
55 | /* Return symbol for given UCS4 value. */ |
56 | extern const char *repertoire_find_symbol (const struct repertoire_t *repertoire, |
57 | uint32_t ucs); |
58 | |
59 | /* Query the has table to memoize mapping from UCS4 to byte sequences. */ |
60 | extern struct charseq *repertoire_find_seq (const struct repertoire_t *rep, |
61 | uint32_t ucs); |
62 | |
63 | #endif /* repertoiremap.h */ |
64 | |