1 /* tr46map.c - header file for IDNA2008 TR46
2    Copyright (C) 2016-2021 Tim Ruehsen
3 
4    Libidn2 is free software: you can redistribute it and/or modify it
5    under the terms of either:
6 
7      * the GNU Lesser General Public License as published by the Free
8        Software Foundation; either version 3 of the License, or (at
9        your option) any later version.
10 
11    or
12 
13      * the GNU General Public License as published by the Free
14        Software Foundation; either version 2 of the License, or (at
15        your option) any later version.
16 
17    or both in parallel, as here.
18 
19    This program is distributed in the hope that it will be useful,
20    but WITHOUT ANY WARRANTY; without even the implied warranty of
21    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22    GNU General Public License for more details.
23 
24    You should have received copies of the GNU General Public License and
25    the GNU Lesser General Public License along with this program.  If
26    not, see <http://www.gnu.org/licenses/>.
27 */
28 
29 #ifndef LIBIDN2_TR46MAP_H
30 #define LIBIDN2_TR46MAP_H
31 
32 #include <stdint.h>
33 #include "idn2.h"
34 
35 #define TR46_FLG_VALID                   1
36 #define TR46_FLG_MAPPED                  2
37 #define TR46_FLG_IGNORED                 4
38 #define TR46_FLG_DEVIATION               8
39 #define TR46_FLG_DISALLOWED             16
40 #define TR46_FLG_DISALLOWED_STD3_MAPPED 32
41 #define TR46_FLG_DISALLOWED_STD3_VALID  64
42 
43 typedef struct
44 {
45   uint32_t cp1;
46   uint16_t range;
47   unsigned nmappings:5,		/* 0-18, # of uint32_t at <offset> */
48     offset:14,			/* 0-16383, byte offset into mapdata */
49     flag_index:3;		/* 0-7, index into flags */
50 } IDNAMap;
51 
52 typedef struct
53 {
54   uint32_t cp1, cp2;
55   char check;			/* 0=NO 2=MAYBE (YES if codepoint has no table entry) */
56 } NFCQCMap;
57 
58 int get_idna_map (uint32_t c, IDNAMap * map);
59 int get_map_data (uint32_t * dst, const IDNAMap * map);
60 int G_GNUC_IDN2_ATTRIBUTE_PURE map_is (const IDNAMap * map, unsigned flags);
61 
62 G_GNUC_IDN2_ATTRIBUTE_PURE NFCQCMap *get_nfcqc_map (uint32_t c);
63 
64 #endif /* LIBIDN2_TR46MAP_H */
65