Home | History | Annotate | Line # | Download | only in lib
      1 /*
      2                             __  __            _
      3                          ___\ \/ /_ __   __ _| |_
      4                         / _ \\  /| '_ \ / _` | __|
      5                        |  __//  \| |_) | (_| | |_
      6                         \___/_/\_\ .__/ \__,_|\__|
      7                                  |_| XML parser
      8 
      9    Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
     10    Copyright (c) 2000      Clark Cooper <coopercc (at) users.sourceforge.net>
     11    Copyright (c) 2002      Karl Waclawek <karl (at) waclawek.net>
     12    Copyright (c) 2002      Fred L. Drake, Jr. <fdrake (at) users.sourceforge.net>
     13    Copyright (c) 2017-2026 Sebastian Pipping <sebastian (at) pipping.org>
     14    Licensed under the MIT license:
     15 
     16    Permission is  hereby granted,  free of charge,  to any  person obtaining
     17    a  copy  of  this  software   and  associated  documentation  files  (the
     18    "Software"),  to  deal in  the  Software  without restriction,  including
     19    without  limitation the  rights  to use,  copy,  modify, merge,  publish,
     20    distribute, sublicense, and/or sell copies of the Software, and to permit
     21    persons  to whom  the Software  is  furnished to  do so,  subject to  the
     22    following conditions:
     23 
     24    The above copyright  notice and this permission notice  shall be included
     25    in all copies or substantial portions of the Software.
     26 
     27    THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY  OF  ANY  KIND,
     28    EXPRESS  OR IMPLIED,  INCLUDING  BUT  NOT LIMITED  TO  THE WARRANTIES  OF
     29    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
     30    NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
     31    DAMAGES OR  OTHER LIABILITY, WHETHER  IN AN  ACTION OF CONTRACT,  TORT OR
     32    OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
     33    USE OR OTHER DEALINGS IN THE SOFTWARE.
     34 
     35    SPDX-License-Identifier: MIT
     36 */
     37 
     38 #ifndef XmlRole_INCLUDED
     39 #  define XmlRole_INCLUDED 1
     40 
     41 #  include "xmltok.h"
     42 
     43 enum {
     44   XML_ROLE_ERROR = -1,
     45   XML_ROLE_NONE = 0,
     46   XML_ROLE_XML_DECL,
     47   XML_ROLE_INSTANCE_START,
     48   XML_ROLE_DOCTYPE_NONE,
     49   XML_ROLE_DOCTYPE_NAME,
     50   XML_ROLE_DOCTYPE_SYSTEM_ID,
     51   XML_ROLE_DOCTYPE_PUBLIC_ID,
     52   XML_ROLE_DOCTYPE_INTERNAL_SUBSET,
     53   XML_ROLE_DOCTYPE_CLOSE,
     54   XML_ROLE_GENERAL_ENTITY_NAME,
     55   XML_ROLE_PARAM_ENTITY_NAME,
     56   XML_ROLE_ENTITY_NONE,
     57   XML_ROLE_ENTITY_VALUE,
     58   XML_ROLE_ENTITY_SYSTEM_ID,
     59   XML_ROLE_ENTITY_PUBLIC_ID,
     60   XML_ROLE_ENTITY_COMPLETE,
     61   XML_ROLE_ENTITY_NOTATION_NAME,
     62   XML_ROLE_NOTATION_NONE,
     63   XML_ROLE_NOTATION_NAME,
     64   XML_ROLE_NOTATION_SYSTEM_ID,
     65   XML_ROLE_NOTATION_NO_SYSTEM_ID,
     66   XML_ROLE_NOTATION_PUBLIC_ID,
     67   XML_ROLE_ATTRIBUTE_NAME,
     68   XML_ROLE_ATTRIBUTE_TYPE_CDATA,
     69   XML_ROLE_ATTRIBUTE_TYPE_ID,
     70   XML_ROLE_ATTRIBUTE_TYPE_IDREF,
     71   XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
     72   XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
     73   XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
     74   XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
     75   XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
     76   XML_ROLE_ATTRIBUTE_ENUM_VALUE,
     77   XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
     78   XML_ROLE_ATTLIST_NONE,
     79   XML_ROLE_ATTLIST_ELEMENT_NAME,
     80   XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
     81   XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
     82   XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
     83   XML_ROLE_FIXED_ATTRIBUTE_VALUE,
     84   XML_ROLE_ELEMENT_NONE,
     85   XML_ROLE_ELEMENT_NAME,
     86   XML_ROLE_CONTENT_ANY,
     87   XML_ROLE_CONTENT_EMPTY,
     88   XML_ROLE_CONTENT_PCDATA,
     89   XML_ROLE_GROUP_OPEN,
     90   XML_ROLE_GROUP_CLOSE,
     91   XML_ROLE_GROUP_CLOSE_REP,
     92   XML_ROLE_GROUP_CLOSE_OPT,
     93   XML_ROLE_GROUP_CLOSE_PLUS,
     94   XML_ROLE_GROUP_CHOICE,
     95   XML_ROLE_GROUP_SEQUENCE,
     96   XML_ROLE_CONTENT_ELEMENT,
     97   XML_ROLE_CONTENT_ELEMENT_REP,
     98   XML_ROLE_CONTENT_ELEMENT_OPT,
     99   XML_ROLE_CONTENT_ELEMENT_PLUS,
    100   XML_ROLE_PI,
    101   XML_ROLE_COMMENT,
    102 #  ifdef XML_DTD
    103   XML_ROLE_TEXT_DECL,
    104   XML_ROLE_IGNORE_SECT,
    105   XML_ROLE_INNER_PARAM_ENTITY_REF,
    106 #  endif /* XML_DTD */
    107   XML_ROLE_PARAM_ENTITY_REF
    108 };
    109 
    110 typedef struct prolog_state {
    111   int (*handler)(struct prolog_state *state, int tok, const char *ptr,
    112                  const char *end, const ENCODING *enc);
    113   unsigned level;
    114   int role_none;
    115 #  ifdef XML_DTD
    116   unsigned includeLevel;
    117   int documentEntity;
    118   int inEntityValue;
    119 #  endif /* XML_DTD */
    120 } PROLOG_STATE;
    121 
    122 void XmlPrologStateInit(PROLOG_STATE *state);
    123 #  ifdef XML_DTD
    124 void XmlPrologStateInitExternalEntity(PROLOG_STATE *state);
    125 #  endif /* XML_DTD */
    126 
    127 #  define XmlTokenRole(state, tok, ptr, end, enc)                              \
    128     (((state)->handler)(state, tok, ptr, end, enc))
    129 
    130 #endif /* not XmlRole_INCLUDED */
    131