wine/dlls/xmllite/xmllite_private.h
2023-07-24 21:28:04 +02:00

82 lines
2.3 KiB
C

/*
* XMLLite private things
*
* Copyright 2012 Nikolay Sivov for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __XMLLITE_PRIVATE__
#define __XMLLITE_PRIVATE__
static inline void *m_alloc(IMalloc *imalloc, size_t len)
{
if (imalloc)
return IMalloc_Alloc(imalloc, len);
else
return malloc(len);
}
static inline void *m_realloc(IMalloc *imalloc, void *mem, size_t len)
{
if (imalloc)
return IMalloc_Realloc(imalloc, mem, len);
else
return realloc(mem, len);
}
static inline void m_free(IMalloc *imalloc, void *mem)
{
if (imalloc)
IMalloc_Free(imalloc, mem);
else
free(mem);
}
typedef enum
{
XmlEncoding_USASCII,
XmlEncoding_UTF16,
XmlEncoding_UTF8,
XmlEncoding_Unknown
} xml_encoding;
xml_encoding parse_encoding_name(const WCHAR*,int);
HRESULT get_code_page(xml_encoding,UINT*);
const WCHAR *get_encoding_name(xml_encoding);
xml_encoding get_encoding_from_codepage(UINT);
BOOL is_ncnamechar(WCHAR ch);
BOOL is_pubchar(WCHAR ch);
BOOL is_namestartchar(WCHAR ch);
BOOL is_namechar(WCHAR ch);
/* [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] */
static inline BOOL is_char(WCHAR ch)
{
return (ch == '\t') || (ch == '\r') || (ch == '\n') ||
(ch >= 0x20 && ch <= 0xd7ff) ||
(ch >= 0xd800 && ch <= 0xdbff) || /* high surrogate */
(ch >= 0xdc00 && ch <= 0xdfff) || /* low surrogate */
(ch >= 0xe000 && ch <= 0xfffd);
}
/* [3] S ::= (#x20 | #x9 | #xD | #xA)+ */
static inline BOOL is_wchar_space(WCHAR ch)
{
return ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n';
}
#endif /* __XMLLITE_PRIVATE__ */