2017-08-12 14:56:14 -04:00
|
|
|
/*
|
|
|
|
__ __ _
|
|
|
|
___\ \/ /_ __ __ _| |_
|
|
|
|
/ _ \\ /| '_ \ / _` | __|
|
|
|
|
| __// \| |_) | (_| | |_
|
|
|
|
\___/_/\_\ .__/ \__,_|\__|
|
|
|
|
|_| XML parser
|
|
|
|
|
|
|
|
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
|
|
|
Copyright (c) 2000-2017 Expat development team
|
|
|
|
Licensed under the MIT license:
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
a copy of this software and associated documentation files (the
|
|
|
|
"Software"), to deal in the Software without restriction, including
|
|
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
|
persons to whom the Software is furnished to do so, subject to the
|
|
|
|
following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included
|
|
|
|
in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
|
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
|
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
|
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
|
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2000-04-21 00:20:31 -04:00
|
|
|
*/
|
1998-04-05 11:11:29 -04:00
|
|
|
|
1997-11-14 20:05:11 -05:00
|
|
|
#ifndef XmlRole_INCLUDED
|
|
|
|
#define XmlRole_INCLUDED 1
|
|
|
|
|
2002-06-05 00:13:10 -04:00
|
|
|
#ifdef __VMS
|
|
|
|
/* 0 1 2 3 0 1 2 3
|
|
|
|
1234567890123456789012345678901 1234567890123456789012345678901 */
|
2019-08-03 14:34:54 -04:00
|
|
|
# define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt
|
2002-06-05 00:13:10 -04:00
|
|
|
#endif
|
|
|
|
|
1997-11-14 20:05:11 -05:00
|
|
|
#include "xmltok.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
enum {
|
|
|
|
XML_ROLE_ERROR = -1,
|
|
|
|
XML_ROLE_NONE = 0,
|
1997-12-10 02:44:19 -05:00
|
|
|
XML_ROLE_XML_DECL,
|
|
|
|
XML_ROLE_INSTANCE_START,
|
2002-08-22 10:52:44 -04:00
|
|
|
XML_ROLE_DOCTYPE_NONE,
|
1997-11-14 20:05:11 -05:00
|
|
|
XML_ROLE_DOCTYPE_NAME,
|
|
|
|
XML_ROLE_DOCTYPE_SYSTEM_ID,
|
|
|
|
XML_ROLE_DOCTYPE_PUBLIC_ID,
|
2000-09-21 17:20:18 -04:00
|
|
|
XML_ROLE_DOCTYPE_INTERNAL_SUBSET,
|
1997-11-14 20:05:11 -05:00
|
|
|
XML_ROLE_DOCTYPE_CLOSE,
|
|
|
|
XML_ROLE_GENERAL_ENTITY_NAME,
|
|
|
|
XML_ROLE_PARAM_ENTITY_NAME,
|
2002-08-22 10:52:44 -04:00
|
|
|
XML_ROLE_ENTITY_NONE,
|
1997-11-14 20:05:11 -05:00
|
|
|
XML_ROLE_ENTITY_VALUE,
|
|
|
|
XML_ROLE_ENTITY_SYSTEM_ID,
|
|
|
|
XML_ROLE_ENTITY_PUBLIC_ID,
|
2000-09-21 17:20:18 -04:00
|
|
|
XML_ROLE_ENTITY_COMPLETE,
|
1997-11-14 20:05:11 -05:00
|
|
|
XML_ROLE_ENTITY_NOTATION_NAME,
|
2002-08-22 10:52:44 -04:00
|
|
|
XML_ROLE_NOTATION_NONE,
|
1997-11-14 20:05:11 -05:00
|
|
|
XML_ROLE_NOTATION_NAME,
|
|
|
|
XML_ROLE_NOTATION_SYSTEM_ID,
|
1998-05-31 23:59:07 -04:00
|
|
|
XML_ROLE_NOTATION_NO_SYSTEM_ID,
|
1997-11-14 20:05:11 -05:00
|
|
|
XML_ROLE_NOTATION_PUBLIC_ID,
|
|
|
|
XML_ROLE_ATTRIBUTE_NAME,
|
|
|
|
XML_ROLE_ATTRIBUTE_TYPE_CDATA,
|
|
|
|
XML_ROLE_ATTRIBUTE_TYPE_ID,
|
|
|
|
XML_ROLE_ATTRIBUTE_TYPE_IDREF,
|
|
|
|
XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
|
|
|
|
XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
|
|
|
|
XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
|
|
|
|
XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
|
|
|
|
XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
|
|
|
|
XML_ROLE_ATTRIBUTE_ENUM_VALUE,
|
|
|
|
XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
|
2002-08-22 10:52:44 -04:00
|
|
|
XML_ROLE_ATTLIST_NONE,
|
1997-11-14 20:05:11 -05:00
|
|
|
XML_ROLE_ATTLIST_ELEMENT_NAME,
|
|
|
|
XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
|
|
|
|
XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
|
|
|
|
XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
|
|
|
|
XML_ROLE_FIXED_ATTRIBUTE_VALUE,
|
2002-08-22 10:52:44 -04:00
|
|
|
XML_ROLE_ELEMENT_NONE,
|
1997-11-14 20:05:11 -05:00
|
|
|
XML_ROLE_ELEMENT_NAME,
|
|
|
|
XML_ROLE_CONTENT_ANY,
|
|
|
|
XML_ROLE_CONTENT_EMPTY,
|
|
|
|
XML_ROLE_CONTENT_PCDATA,
|
1997-12-10 02:44:19 -05:00
|
|
|
XML_ROLE_GROUP_OPEN,
|
|
|
|
XML_ROLE_GROUP_CLOSE,
|
|
|
|
XML_ROLE_GROUP_CLOSE_REP,
|
|
|
|
XML_ROLE_GROUP_CLOSE_OPT,
|
|
|
|
XML_ROLE_GROUP_CLOSE_PLUS,
|
1997-11-14 20:05:11 -05:00
|
|
|
XML_ROLE_GROUP_CHOICE,
|
|
|
|
XML_ROLE_GROUP_SEQUENCE,
|
|
|
|
XML_ROLE_CONTENT_ELEMENT,
|
|
|
|
XML_ROLE_CONTENT_ELEMENT_REP,
|
|
|
|
XML_ROLE_CONTENT_ELEMENT_OPT,
|
1997-12-13 01:39:04 -05:00
|
|
|
XML_ROLE_CONTENT_ELEMENT_PLUS,
|
2002-08-22 10:52:44 -04:00
|
|
|
XML_ROLE_PI,
|
|
|
|
XML_ROLE_COMMENT,
|
1999-06-25 06:58:20 -04:00
|
|
|
#ifdef XML_DTD
|
|
|
|
XML_ROLE_TEXT_DECL,
|
|
|
|
XML_ROLE_IGNORE_SECT,
|
|
|
|
XML_ROLE_INNER_PARAM_ENTITY_REF,
|
|
|
|
#endif /* XML_DTD */
|
2000-09-21 17:20:18 -04:00
|
|
|
XML_ROLE_PARAM_ENTITY_REF
|
1997-11-14 20:05:11 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct prolog_state {
|
2019-08-03 14:34:54 -04:00
|
|
|
int(PTRCALL *handler)(struct prolog_state *state, int tok, const char *ptr,
|
|
|
|
const char *end, const ENCODING *enc);
|
1997-11-14 20:05:11 -05:00
|
|
|
unsigned level;
|
2002-08-22 10:52:44 -04:00
|
|
|
int role_none;
|
1999-06-25 06:58:20 -04:00
|
|
|
#ifdef XML_DTD
|
|
|
|
unsigned includeLevel;
|
|
|
|
int documentEntity;
|
2002-05-17 23:34:44 -04:00
|
|
|
int inEntityValue;
|
1999-06-25 06:58:20 -04:00
|
|
|
#endif /* XML_DTD */
|
1997-11-14 20:05:11 -05:00
|
|
|
} PROLOG_STATE;
|
|
|
|
|
2000-09-28 13:53:00 -04:00
|
|
|
void XmlPrologStateInit(PROLOG_STATE *);
|
1999-06-25 06:58:20 -04:00
|
|
|
#ifdef XML_DTD
|
2000-09-28 13:53:00 -04:00
|
|
|
void XmlPrologStateInitExternalEntity(PROLOG_STATE *);
|
1999-06-25 06:58:20 -04:00
|
|
|
#endif /* XML_DTD */
|
1997-11-14 20:05:11 -05:00
|
|
|
|
2019-08-03 14:34:54 -04:00
|
|
|
#define XmlTokenRole(state, tok, ptr, end, enc) \
|
|
|
|
(((state)->handler)(state, tok, ptr, end, enc))
|
1997-11-14 20:05:11 -05:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* not XmlRole_INCLUDED */
|