1 /* libxml2 - Library for parsing XML documents
2  * Copyright (C) 2006-2019 Free Software Foundation, Inc.
3  *
4  * This file is not part of the GNU gettext program, but is used with
5  * GNU gettext.
6  *
7  * The original copyright notice is as follows:
8  */
9 
10 /*
11  * Copyright (C) 1998-2012 Daniel Veillard.  All Rights Reserved.
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a copy
14  * of this software and associated documentation files (the "Software"), to deal
15  * in the Software without restriction, including without limitation the rights
16  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17  * copies of the Software, and to permit persons to whom the Software is fur-
18  * nished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included in
21  * all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
25  * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
26  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29  * THE SOFTWARE.
30  */
31 
32 /*
33  * Summary: Unicode character range checking
34  * Description: this module exports interfaces for the character
35  *               range validation APIs
36  *
37  * This file is automatically generated from the cvs source
38  * definition files using the genChRanges.py Python script
39  *
40  * Generation date: Mon Mar 27 11:09:48 2006
41  * Sources: chvalid.def
42  * Author: William Brack <wbrack@mmm.com.hk>
43  */
44 
45 #ifndef __XML_CHVALID_H__
46 #define __XML_CHVALID_H__
47 
48 #include <libxml/xmlversion.h>
49 #include <libxml/xmlstring.h>
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 /*
56  * Define our typedefs and structures
57  *
58  */
59 typedef struct _xmlChSRange xmlChSRange;
60 typedef xmlChSRange *xmlChSRangePtr;
61 struct _xmlChSRange {
62     unsigned short	low;
63     unsigned short	high;
64 };
65 
66 typedef struct _xmlChLRange xmlChLRange;
67 typedef xmlChLRange *xmlChLRangePtr;
68 struct _xmlChLRange {
69     unsigned int	low;
70     unsigned int	high;
71 };
72 
73 typedef struct _xmlChRangeGroup xmlChRangeGroup;
74 typedef xmlChRangeGroup *xmlChRangeGroupPtr;
75 struct _xmlChRangeGroup {
76     int			nbShortRange;
77     int			nbLongRange;
78     const xmlChSRange	*shortRange;	/* points to an array of ranges */
79     const xmlChLRange	*longRange;
80 };
81 
82 /**
83  * Range checking routine
84  */
85 XMLPUBFUN int XMLCALL
86 		xmlCharInRange(unsigned int val, const xmlChRangeGroup *group);
87 
88 
89 /**
90  * xmlIsBaseChar_ch:
91  * @c: char to validate
92  *
93  * Automatically generated by genChRanges.py
94  */
95 #define xmlIsBaseChar_ch(c)	(((0x41 <= (c)) && ((c) <= 0x5a)) || \
96 				 ((0x61 <= (c)) && ((c) <= 0x7a)) || \
97 				 ((0xc0 <= (c)) && ((c) <= 0xd6)) || \
98 				 ((0xd8 <= (c)) && ((c) <= 0xf6)) || \
99 				  (0xf8 <= (c)))
100 
101 /**
102  * xmlIsBaseCharQ:
103  * @c: char to validate
104  *
105  * Automatically generated by genChRanges.py
106  */
107 #define xmlIsBaseCharQ(c)	(((c) < 0x100) ? \
108 				 xmlIsBaseChar_ch((c)) : \
109 				 xmlCharInRange((c), &xmlIsBaseCharGroup))
110 
111 XMLPUBVAR const xmlChRangeGroup xmlIsBaseCharGroup;
112 
113 /**
114  * xmlIsBlank_ch:
115  * @c: char to validate
116  *
117  * Automatically generated by genChRanges.py
118  */
119 #define xmlIsBlank_ch(c)	(((c) == 0x20) || \
120 				 ((0x9 <= (c)) && ((c) <= 0xa)) || \
121 				 ((c) == 0xd))
122 
123 /**
124  * xmlIsBlankQ:
125  * @c: char to validate
126  *
127  * Automatically generated by genChRanges.py
128  */
129 #define xmlIsBlankQ(c)		(((c) < 0x100) ? \
130 				 xmlIsBlank_ch((c)) : 0)
131 
132 
133 /**
134  * xmlIsChar_ch:
135  * @c: char to validate
136  *
137  * Automatically generated by genChRanges.py
138  */
139 #define xmlIsChar_ch(c)		(((0x9 <= (c)) && ((c) <= 0xa)) || \
140 				 ((c) == 0xd) || \
141 				  (0x20 <= (c)))
142 
143 /**
144  * xmlIsCharQ:
145  * @c: char to validate
146  *
147  * Automatically generated by genChRanges.py
148  */
149 #define xmlIsCharQ(c)		(((c) < 0x100) ? \
150 				 xmlIsChar_ch((c)) :\
151 				(((0x100 <= (c)) && ((c) <= 0xd7ff)) || \
152 				 ((0xe000 <= (c)) && ((c) <= 0xfffd)) || \
153 				 ((0x10000 <= (c)) && ((c) <= 0x10ffff))))
154 
155 XMLPUBVAR const xmlChRangeGroup xmlIsCharGroup;
156 
157 /**
158  * xmlIsCombiningQ:
159  * @c: char to validate
160  *
161  * Automatically generated by genChRanges.py
162  */
163 #define xmlIsCombiningQ(c)	(((c) < 0x100) ? \
164 				 0 : \
165 				 xmlCharInRange((c), &xmlIsCombiningGroup))
166 
167 XMLPUBVAR const xmlChRangeGroup xmlIsCombiningGroup;
168 
169 /**
170  * xmlIsDigit_ch:
171  * @c: char to validate
172  *
173  * Automatically generated by genChRanges.py
174  */
175 #define xmlIsDigit_ch(c)	(((0x30 <= (c)) && ((c) <= 0x39)))
176 
177 /**
178  * xmlIsDigitQ:
179  * @c: char to validate
180  *
181  * Automatically generated by genChRanges.py
182  */
183 #define xmlIsDigitQ(c)		(((c) < 0x100) ? \
184 				 xmlIsDigit_ch((c)) : \
185 				 xmlCharInRange((c), &xmlIsDigitGroup))
186 
187 XMLPUBVAR const xmlChRangeGroup xmlIsDigitGroup;
188 
189 /**
190  * xmlIsExtender_ch:
191  * @c: char to validate
192  *
193  * Automatically generated by genChRanges.py
194  */
195 #define xmlIsExtender_ch(c)	(((c) == 0xb7))
196 
197 /**
198  * xmlIsExtenderQ:
199  * @c: char to validate
200  *
201  * Automatically generated by genChRanges.py
202  */
203 #define xmlIsExtenderQ(c)	(((c) < 0x100) ? \
204 				 xmlIsExtender_ch((c)) : \
205 				 xmlCharInRange((c), &xmlIsExtenderGroup))
206 
207 XMLPUBVAR const xmlChRangeGroup xmlIsExtenderGroup;
208 
209 /**
210  * xmlIsIdeographicQ:
211  * @c: char to validate
212  *
213  * Automatically generated by genChRanges.py
214  */
215 #define xmlIsIdeographicQ(c)	(((c) < 0x100) ? \
216 				 0 :\
217 				(((0x4e00 <= (c)) && ((c) <= 0x9fa5)) || \
218 				 ((c) == 0x3007) || \
219 				 ((0x3021 <= (c)) && ((c) <= 0x3029))))
220 
221 XMLPUBVAR const xmlChRangeGroup xmlIsIdeographicGroup;
222 XMLPUBVAR const unsigned char xmlIsPubidChar_tab[256];
223 
224 /**
225  * xmlIsPubidChar_ch:
226  * @c: char to validate
227  *
228  * Automatically generated by genChRanges.py
229  */
230 #define xmlIsPubidChar_ch(c)	(xmlIsPubidChar_tab[(c)])
231 
232 /**
233  * xmlIsPubidCharQ:
234  * @c: char to validate
235  *
236  * Automatically generated by genChRanges.py
237  */
238 #define xmlIsPubidCharQ(c)	(((c) < 0x100) ? \
239 				 xmlIsPubidChar_ch((c)) : 0)
240 
241 XMLPUBFUN int XMLCALL
242 		xmlIsBaseChar(unsigned int ch);
243 XMLPUBFUN int XMLCALL
244 		xmlIsBlank(unsigned int ch);
245 XMLPUBFUN int XMLCALL
246 		xmlIsChar(unsigned int ch);
247 XMLPUBFUN int XMLCALL
248 		xmlIsCombining(unsigned int ch);
249 XMLPUBFUN int XMLCALL
250 		xmlIsDigit(unsigned int ch);
251 XMLPUBFUN int XMLCALL
252 		xmlIsExtender(unsigned int ch);
253 XMLPUBFUN int XMLCALL
254 		xmlIsIdeographic(unsigned int ch);
255 XMLPUBFUN int XMLCALL
256 		xmlIsPubidChar(unsigned int ch);
257 
258 #ifdef __cplusplus
259 }
260 #endif
261 #endif /* __XML_CHVALID_H__ */
262