]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
b75a7d8f A |
3 | /* |
4 | ******************************************************************************* | |
5 | * | |
73c04bcf | 6 | * Copyright (C) 2003-2006, International Business Machines |
b75a7d8f A |
7 | * Corporation and others. All Rights Reserved. |
8 | * | |
9 | ******************************************************************************* | |
10 | * file name: sprpimpl.h | |
f3c0d7a5 | 11 | * encoding: UTF-8 |
b75a7d8f A |
12 | * tab size: 8 (not used) |
13 | * indentation:4 | |
14 | * | |
15 | * created on: 2003feb1 | |
16 | * created by: Ram Viswanadha | |
17 | */ | |
18 | ||
19 | #ifndef SPRPIMPL_H | |
20 | #define SPRPIMPL_H | |
21 | ||
22 | #include "unicode/utypes.h" | |
374ca955 A |
23 | |
24 | #if !UCONFIG_NO_IDNA | |
25 | ||
b75a7d8f A |
26 | #include "unicode/ustring.h" |
27 | #include "unicode/parseerr.h" | |
374ca955 A |
28 | #include "unicode/usprep.h" |
29 | #include "unicode/udata.h" | |
30 | #include "utrie.h" | |
31 | #include "udataswp.h" | |
73c04bcf | 32 | #include "ubidi_props.h" |
b75a7d8f | 33 | |
374ca955 A |
34 | #define _SPREP_DATA_TYPE "spp" |
35 | ||
36 | enum UStringPrepType{ | |
37 | USPREP_UNASSIGNED = 0x0000 , | |
38 | USPREP_MAP = 0x0001 , | |
39 | USPREP_PROHIBITED = 0x0002 , | |
40 | USPREP_DELETE = 0x0003 , | |
41 | USPREP_TYPE_LIMIT = 0x0004 | |
42 | }; | |
43 | ||
44 | typedef enum UStringPrepType UStringPrepType; | |
45 | ||
46 | #ifdef USPREP_TYPE_NAMES_ARRAY | |
47 | static const char* usprepTypeNames[] ={ | |
48 | "UNASSIGNED" , | |
49 | "MAP" , | |
50 | "PROHIBITED" , | |
51 | "DELETE", | |
52 | "TYPE_LIMIT" | |
53 | }; | |
54 | #endif | |
b75a7d8f A |
55 | |
56 | enum{ | |
374ca955 A |
57 | _SPREP_NORMALIZATION_ON = 0x0001, |
58 | _SPREP_CHECK_BIDI_ON = 0x0002 | |
b75a7d8f | 59 | }; |
374ca955 | 60 | |
b75a7d8f | 61 | enum{ |
374ca955 A |
62 | _SPREP_TYPE_THRESHOLD = 0xFFF0, |
63 | _SPREP_MAX_INDEX_VALUE = 0x3FBF, /*16139*/ | |
64 | _SPREP_MAX_INDEX_TOP_LENGTH = 0x0003 | |
b75a7d8f | 65 | }; |
374ca955 | 66 | |
b75a7d8f A |
67 | /* indexes[] value names */ |
68 | enum { | |
374ca955 A |
69 | _SPREP_INDEX_TRIE_SIZE = 0, /* number of bytes in StringPrep trie */ |
70 | _SPREP_INDEX_MAPPING_DATA_SIZE = 1, /* The array that contains the mapping */ | |
71 | _SPREP_NORM_CORRECTNS_LAST_UNI_VERSION = 2, /* The index of Unicode version of last entry in NormalizationCorrections.txt */ | |
72 | _SPREP_ONE_UCHAR_MAPPING_INDEX_START = 3, /* The starting index of 1 UChar mapping index in the mapping data array */ | |
73 | _SPREP_TWO_UCHARS_MAPPING_INDEX_START = 4, /* The starting index of 2 UChars mapping index in the mapping data array */ | |
74 | _SPREP_THREE_UCHARS_MAPPING_INDEX_START = 5, /* The starting index of 3 UChars mapping index in the mapping data array */ | |
75 | _SPREP_FOUR_UCHARS_MAPPING_INDEX_START = 6, /* The starting index of 4 UChars mapping index in the mapping data array */ | |
76 | _SPREP_OPTIONS = 7, /* Bit set of options to turn on in the profile */ | |
77 | _SPREP_INDEX_TOP=16 /* changing this requires a new formatVersion */ | |
b75a7d8f A |
78 | }; |
79 | ||
374ca955 A |
80 | typedef struct UStringPrepKey UStringPrepKey; |
81 | ||
82 | ||
83 | struct UStringPrepKey{ | |
84 | char* name; | |
85 | char* path; | |
86 | }; | |
87 | ||
88 | struct UStringPrepProfile{ | |
89 | int32_t indexes[_SPREP_INDEX_TOP]; | |
90 | UTrie sprepTrie; | |
91 | const uint16_t* mappingData; | |
92 | UDataMemory* sprepData; | |
73c04bcf | 93 | const UBiDiProps *bdp; /* used only if checkBiDi is set */ |
374ca955 | 94 | int32_t refCount; |
73c04bcf | 95 | UBool isDataLoaded; |
374ca955 A |
96 | UBool doNFKC; |
97 | UBool checkBiDi; | |
b75a7d8f A |
98 | }; |
99 | ||
374ca955 A |
100 | /** |
101 | * Helper function for populating the UParseError struct | |
102 | * @internal | |
103 | */ | |
104 | U_CAPI void U_EXPORT2 | |
105 | uprv_syntaxError(const UChar* rules, | |
b75a7d8f A |
106 | int32_t pos, |
107 | int32_t rulesLen, | |
374ca955 | 108 | UParseError* parseError); |
b75a7d8f | 109 | |
374ca955 A |
110 | |
111 | /** | |
112 | * Swap StringPrep .spp profile data. See udataswp.h. | |
113 | * @internal | |
114 | */ | |
115 | U_CAPI int32_t U_EXPORT2 | |
116 | usprep_swap(const UDataSwapper *ds, | |
117 | const void *inData, int32_t length, void *outData, | |
118 | UErrorCode *pErrorCode); | |
b75a7d8f A |
119 | |
120 | #endif /* #if !UCONFIG_NO_IDNA */ | |
121 | ||
122 | #endif | |
123 | ||
124 | /* | |
125 | * Hey, Emacs, please set the following: | |
126 | * | |
127 | * Local Variables: | |
128 | * indent-tabs-mode: nil | |
129 | * End: | |
130 | * | |
131 | */ |