cpython/Modules/expat/xmlrole.c

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

   Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
   Copyright (c) 2000      Clark Cooper <[email protected]>
   Copyright (c) 2002      Greg Stein <[email protected]>
   Copyright (c) 2002-2006 Karl Waclawek <[email protected]>
   Copyright (c) 2002-2003 Fred L. Drake, Jr. <[email protected]>
   Copyright (c) 2005-2009 Steven Solie <[email protected]>
   Copyright (c) 2016-2023 Sebastian Pipping <[email protected]>
   Copyright (c) 2017      Rhodri James <[email protected]>
   Copyright (c) 2019      David Loffredo <[email protected]>
   Copyright (c) 2021      Donghee Na <[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.
*/

#include "expat_config.h"

#include <stddef.h>

#ifdef _WIN32
#  include "winconfig.h"
#endif

#include "expat_external.h"
#include "internal.h"
#include "xmlrole.h"
#include "ascii.h"

/* Doesn't check:

 that ,| are not mixed in a model group
 content of literals

*/

static const char KW_ANY[] =;
static const char KW_ATTLIST[]
    =;
static const char KW_CDATA[]
    =;
static const char KW_DOCTYPE[]
    =;
static const char KW_ELEMENT[]
    =;
static const char KW_EMPTY[]
    =;
static const char KW_ENTITIES[] =;
static const char KW_ENTITY[]
    =;
static const char KW_FIXED[]
    =;
static const char KW_ID[] =;
static const char KW_IDREF[]
    =;
static const char KW_IDREFS[]
    =;
#ifdef XML_DTD
static const char KW_IGNORE[]
    =;
#endif
static const char KW_IMPLIED[]
    =;
#ifdef XML_DTD
static const char KW_INCLUDE[]
    =;
#endif
static const char KW_NDATA[]
    =;
static const char KW_NMTOKEN[]
    =;
static const char KW_NMTOKENS[] =;
static const char KW_NOTATION[] =;
static const char KW_PCDATA[]
    =;
static const char KW_PUBLIC[]
    =;
static const char KW_REQUIRED[] =;
static const char KW_SYSTEM[]
    =;

#ifndef MIN_BYTES_PER_CHAR
#define MIN_BYTES_PER_CHAR(enc)
#endif

#ifdef XML_DTD
#define setTopLevel(state)
#else /* not XML_DTD */
#define setTopLevel
#endif /* not XML_DTD */

PROLOG_HANDLER;

static PROLOG_HANDLER prolog0, prolog1, prolog2, doctype0, doctype1, doctype2,
    doctype3, doctype4, doctype5, internalSubset, entity0, entity1, entity2,
    entity3, entity4, entity5, entity6, entity7, entity8, entity9, entity10,
    notation0, notation1, notation2, notation3, notation4, attlist0, attlist1,
    attlist2, attlist3, attlist4, attlist5, attlist6, attlist7, attlist8,
    attlist9, element0, element1, element2, element3, element4, element5,
    element6, element7,
#ifdef XML_DTD
    externalSubset0, externalSubset1, condSect0, condSect1, condSect2,
#endif /* XML_DTD */
    declClose, error;

static int FASTCALL common(PROLOG_STATE *state, int tok);

static int PTRCALL
prolog0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
        const ENCODING *enc) {}

static int PTRCALL
prolog1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
        const ENCODING *enc) {}

static int PTRCALL
prolog2(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
        const ENCODING *enc) {}

static int PTRCALL
doctype0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
doctype1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
doctype2(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
doctype3(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
doctype4(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
doctype5(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
internalSubset(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
               const ENCODING *enc) {}

#ifdef XML_DTD

static int PTRCALL
externalSubset0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
                const ENCODING *enc) {}

static int PTRCALL
externalSubset1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
                const ENCODING *enc) {}

#endif /* XML_DTD */

static int PTRCALL
entity0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
        const ENCODING *enc) {}

static int PTRCALL
entity1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
        const ENCODING *enc) {}

static int PTRCALL
entity2(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
        const ENCODING *enc) {}

static int PTRCALL
entity3(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
        const ENCODING *enc) {}

static int PTRCALL
entity4(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
        const ENCODING *enc) {}

static int PTRCALL
entity5(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
        const ENCODING *enc) {}

static int PTRCALL
entity6(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
        const ENCODING *enc) {}

static int PTRCALL
entity7(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
        const ENCODING *enc) {}

static int PTRCALL
entity8(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
        const ENCODING *enc) {}

static int PTRCALL
entity9(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
        const ENCODING *enc) {}

static int PTRCALL
entity10(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
notation0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
          const ENCODING *enc) {}

static int PTRCALL
notation1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
          const ENCODING *enc) {}

static int PTRCALL
notation2(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
          const ENCODING *enc) {}

static int PTRCALL
notation3(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
          const ENCODING *enc) {}

static int PTRCALL
notation4(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
          const ENCODING *enc) {}

static int PTRCALL
attlist0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
attlist1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
attlist2(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
attlist3(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
attlist4(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
attlist5(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
attlist6(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
attlist7(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

/* default value */
static int PTRCALL
attlist8(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
attlist9(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
element0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
element1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
element2(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
element3(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
element4(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
element5(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
element6(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

static int PTRCALL
element7(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
         const ENCODING *enc) {}

#ifdef XML_DTD

static int PTRCALL
condSect0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
          const ENCODING *enc) {}

static int PTRCALL
condSect1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
          const ENCODING *enc) {}

static int PTRCALL
condSect2(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
          const ENCODING *enc) {}

#endif /* XML_DTD */

static int PTRCALL
declClose(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
          const ENCODING *enc) {}

/* This function will only be invoked if the internal logic of the
 * parser has broken down.  It is used in two cases:
 *
 * 1: When the XML prolog has been finished.  At this point the
 * processor (the parser level above these role handlers) should
 * switch from prologProcessor to contentProcessor and reinitialise
 * the handler function.
 *
 * 2: When an error has been detected (via common() below).  At this
 * point again the processor should be switched to errorProcessor,
 * which will never call a handler.
 *
 * The result of this is that error() can only be called if the
 * processor switch failed to happen, which is an internal error and
 * therefore we shouldn't be able to provoke it simply by using the
 * library.  It is a necessary backstop, however, so we merely exclude
 * it from the coverage statistics.
 *
 * LCOV_EXCL_START
 */
static int PTRCALL
error(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
      const ENCODING *enc) {}
/* LCOV_EXCL_STOP */

static int FASTCALL
common(PROLOG_STATE *state, int tok) {}

void
XmlPrologStateInit(PROLOG_STATE *state) {}

#ifdef XML_DTD

void
XmlPrologStateInitExternalEntity(PROLOG_STATE *state) {}

#endif /* XML_DTD */