xcsinc.c revision 1.1 1 1.1 jdc /* This file is included from other .c files!
2 1.1 jdc __ __ _
3 1.1 jdc ___\ \/ /_ __ __ _| |_
4 1.1 jdc / _ \\ /| '_ \ / _` | __|
5 1.1 jdc | __// \| |_) | (_| | |_
6 1.1 jdc \___/_/\_\ .__/ \__,_|\__|
7 1.1 jdc |_| XML parser
8 1.1 jdc
9 1.1 jdc Copyright (c) 2022 Sebastian Pipping <sebastian (at) pipping.org>
10 1.1 jdc Licensed under the MIT license:
11 1.1 jdc
12 1.1 jdc Permission is hereby granted, free of charge, to any person obtaining
13 1.1 jdc a copy of this software and associated documentation files (the
14 1.1 jdc "Software"), to deal in the Software without restriction, including
15 1.1 jdc without limitation the rights to use, copy, modify, merge, publish,
16 1.1 jdc distribute, sublicense, and/or sell copies of the Software, and to permit
17 1.1 jdc persons to whom the Software is furnished to do so, subject to the
18 1.1 jdc following conditions:
19 1.1 jdc
20 1.1 jdc The above copyright notice and this permission notice shall be included
21 1.1 jdc in all copies or substantial portions of the Software.
22 1.1 jdc
23 1.1 jdc THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 1.1 jdc EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 1.1 jdc MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
26 1.1 jdc NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
27 1.1 jdc DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
28 1.1 jdc OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
29 1.1 jdc USE OR OTHER DEALINGS IN THE SOFTWARE.
30 1.1 jdc */
31 1.1 jdc
32 1.1 jdc static size_t
33 1.1 jdc xcslen(const XML_Char *s) {
34 1.1 jdc #ifdef XML_UNICODE
35 1.1 jdc # ifdef XML_UNICODE_WCHAR_T
36 1.1 jdc return wcslen(s);
37 1.1 jdc # else
38 1.1 jdc // XML_Char is unsigned short
39 1.1 jdc size_t len = 0;
40 1.1 jdc while (s[len]) {
41 1.1 jdc len++;
42 1.1 jdc }
43 1.1 jdc return len;
44 1.1 jdc # endif
45 1.1 jdc #else
46 1.1 jdc return strlen(s);
47 1.1 jdc #endif
48 1.1 jdc }
49