cpython/Modules/expat/xmltok.h

/*
                            __  __            _
                         ___\ \/ /_ __   __ _| |_
                        / _ \\  /| '_ \ / _` | __|
                       |  __//  \| |_) | (_| | |_
                        \___/_/\_\ .__/ \__,_|\__|
                                 |_| XML parser

   Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
   Copyright (c) 2000      Clark Cooper <[email protected]>
   Copyright (c) 2002      Fred L. Drake, Jr. <[email protected]>
   Copyright (c) 2002-2005 Karl Waclawek <[email protected]>
   Copyright (c) 2016-2024 Sebastian Pipping <[email protected]>
   Copyright (c) 2017      Rhodri James <[email protected]>
   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.
*/

#ifndef XmlTok_INCLUDED
#define XmlTok_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

/* The following token may be returned by XmlContentTok */
#define XML_TOK_TRAILING_RSQB
/* The following tokens may be returned by both XmlPrologTok and
   XmlContentTok.
*/
#define XML_TOK_NONE
#define XML_TOK_TRAILING_CR
#define XML_TOK_PARTIAL_CHAR
#define XML_TOK_PARTIAL
#define XML_TOK_INVALID

/* The following tokens are returned by XmlContentTok; some are also
   returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok.
*/
#define XML_TOK_START_TAG_WITH_ATTS
#define XML_TOK_START_TAG_NO_ATTS
#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS
#define XML_TOK_EMPTY_ELEMENT_NO_ATTS
#define XML_TOK_END_TAG
#define XML_TOK_DATA_CHARS
#define XML_TOK_DATA_NEWLINE
#define XML_TOK_CDATA_SECT_OPEN
#define XML_TOK_ENTITY_REF
#define XML_TOK_CHAR_REF

/* The following tokens may be returned by both XmlPrologTok and
   XmlContentTok.
*/
#define XML_TOK_PI
#define XML_TOK_XML_DECL
#define XML_TOK_COMMENT
#define XML_TOK_BOM

/* The following tokens are returned only by XmlPrologTok */
#define XML_TOK_PROLOG_S
#define XML_TOK_DECL_OPEN
#define XML_TOK_DECL_CLOSE
#define XML_TOK_NAME
#define XML_TOK_NMTOKEN
#define XML_TOK_POUND_NAME
#define XML_TOK_OR
#define XML_TOK_PERCENT
#define XML_TOK_OPEN_PAREN
#define XML_TOK_CLOSE_PAREN
#define XML_TOK_OPEN_BRACKET
#define XML_TOK_CLOSE_BRACKET
#define XML_TOK_LITERAL
#define XML_TOK_PARAM_ENTITY_REF
#define XML_TOK_INSTANCE_START

/* The following occur only in element type declarations */
#define XML_TOK_NAME_QUESTION
#define XML_TOK_NAME_ASTERISK
#define XML_TOK_NAME_PLUS
#define XML_TOK_COND_SECT_OPEN
#define XML_TOK_COND_SECT_CLOSE
#define XML_TOK_CLOSE_PAREN_QUESTION
#define XML_TOK_CLOSE_PAREN_ASTERISK
#define XML_TOK_CLOSE_PAREN_PLUS
#define XML_TOK_COMMA

/* The following token is returned only by XmlAttributeValueTok */
#define XML_TOK_ATTRIBUTE_VALUE_S

/* The following token is returned only by XmlCdataSectionTok */
#define XML_TOK_CDATA_SECT_CLOSE

/* With namespace processing this is returned by XmlPrologTok for a
   name with a colon.
*/
#define XML_TOK_PREFIXED_NAME

#ifdef XML_DTD
#define XML_TOK_IGNORE_SECT
#endif /* XML_DTD */

#ifdef XML_DTD
#define XML_N_STATES
#else /* not XML_DTD */
#define XML_N_STATES
#endif /* not XML_DTD */

#define XML_PROLOG_STATE
#define XML_CONTENT_STATE
#define XML_CDATA_SECTION_STATE
#ifdef XML_DTD
#define XML_IGNORE_SECTION_STATE
#endif /* XML_DTD */

#define XML_N_LITERAL_TYPES
#define XML_ATTRIBUTE_VALUE_LITERAL
#define XML_ENTITY_VALUE_LITERAL

/* The size of the buffer passed to XmlUtf8Encode must be at least this. */
#define XML_UTF8_ENCODE_MAX
/* The size of the buffer passed to XmlUtf16Encode must be at least this. */
#define XML_UTF16_ENCODE_MAX

POSITION;

ATTRIBUTE;

struct encoding;
ENCODING;

SCANNER;

enum XML_Convert_Result {};

struct encoding {};

/* Scan the string starting at ptr until the end of the next complete
   token, but do not scan past eptr.  Return an integer giving the
   type of token.

   Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set.

   Return XML_TOK_PARTIAL when the string does not contain a complete
   token; nextTokPtr will not be set.

   Return XML_TOK_INVALID when the string does not start a valid
   token; nextTokPtr will be set to point to the character which made
   the token invalid.

   Otherwise the string starts with a valid token; nextTokPtr will be
   set to point to the character following the end of that token.

   Each data character counts as a single token, but adjacent data
   characters may be returned together.  Similarly for characters in
   the prolog outside literals, comments and processing instructions.
*/

#define XmlTok(enc, state, ptr, end, nextTokPtr)

#define XmlPrologTok(enc, ptr, end, nextTokPtr)

#define XmlContentTok(enc, ptr, end, nextTokPtr)

#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr)

#ifdef XML_DTD

#define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr)

#endif /* XML_DTD */

/* This is used for performing a 2nd-level tokenization on the content
   of a literal that has already been returned by XmlTok.
*/
#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr)

#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr)

#define XmlEntityValueTok(enc, ptr, end, nextTokPtr)

#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2)

#define XmlNameLength(enc, ptr)

#define XmlSkipS(enc, ptr)

#define XmlGetAttributes(enc, ptr, attsMax, atts)

#define XmlCharRefNumber(enc, ptr)

#define XmlPredefinedEntityName(enc, ptr, end)

#define XmlUpdatePosition(enc, ptr, end, pos)

#define XmlIsPublicId(enc, ptr, end, badPtr)

#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim)

#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim)

INIT_ENCODING;

int XmlParseXmlDecl(int isGeneralTextEntity, const ENCODING *enc,
                    const char *ptr, const char *end, const char **badPtr,
                    const char **versionPtr, const char **versionEndPtr,
                    const char **encodingNamePtr,
                    const ENCODING **namedEncodingPtr, int *standalonePtr);

int XmlInitEncoding(INIT_ENCODING *p, const ENCODING **encPtr,
                    const char *name);
const ENCODING *XmlGetUtf8InternalEncoding(void);
const ENCODING *XmlGetUtf16InternalEncoding(void);
int FASTCALL XmlUtf8Encode(int charNumber, char *buf);
int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf);
int XmlSizeOfUnknownEncoding(void);

CONVERTER;

ENCODING *XmlInitUnknownEncoding(void *mem, int *table, CONVERTER convert,
                                 void *userData);

int XmlParseXmlDeclNS(int isGeneralTextEntity, const ENCODING *enc,
                      const char *ptr, const char *end, const char **badPtr,
                      const char **versionPtr, const char **versionEndPtr,
                      const char **encodingNamePtr,
                      const ENCODING **namedEncodingPtr, int *standalonePtr);

int XmlInitEncodingNS(INIT_ENCODING *p, const ENCODING **encPtr,
                      const char *name);
const ENCODING *XmlGetUtf8InternalEncodingNS(void);
const ENCODING *XmlGetUtf16InternalEncodingNS(void);
ENCODING *XmlInitUnknownEncodingNS(void *mem, int *table, CONVERTER convert,
                                   void *userData);
#ifdef __cplusplus
}
#endif

#endif /* not XmlTok_INCLUDED */