home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _dbca1a9939790b0a208929d2d92afd8e < prev    next >
Encoding:
Text File  |  2004-06-01  |  26.4 KB  |  718 lines

  1. /*
  2. The contents of this file are subject to the Mozilla Public License
  3. Version 1.1 (the "License"); you may not use this file except in
  4. compliance with the License. You may obtain a copy of the License at
  5. http://www.mozilla.org/MPL/
  6.  
  7. Software distributed under the License is distributed on an "AS IS"
  8. basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  9. License for the specific language governing rights and limitations
  10. under the License.
  11.  
  12. The Original Code is expat.
  13.  
  14. The Initial Developer of the Original Code is James Clark.
  15. Portions created by James Clark are Copyright (C) 1998, 1999
  16. James Clark. All Rights Reserved.
  17.  
  18. Contributor(s):
  19.  
  20. Clark Cooper (coopercc@netheaven.com) added declaration handlers
  21. for elements, attlist, and entities.
  22.  
  23. Alternatively, the contents of this file may be used under the terms
  24. of the GNU General Public License (the "GPL"), in which case the
  25. provisions of the GPL are applicable instead of those above.  If you
  26. wish to allow use of your version of this file only under the terms of
  27. the GPL and not to allow others to use your version of this file under
  28. the MPL, indicate your decision by deleting the provisions above and
  29. replace them with the notice and other provisions required by the
  30. GPL. If you do not delete the provisions above, a recipient may use
  31. your version of this file under either the MPL or the GPL.
  32. */
  33.  
  34. #ifndef XmlParse_INCLUDED
  35. #define XmlParse_INCLUDED 1
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #ifndef XMLPARSEAPI
  42. #define XMLPARSEAPI /* as nothing */
  43. #endif
  44.  
  45. typedef void *XML_Parser;
  46.  
  47. #ifdef XML_UNICODE_WCHAR_T
  48.  
  49. /* XML_UNICODE_WCHAR_T will work only if sizeof(wchar_t) == 2 and wchar_t
  50. uses Unicode. */
  51. /* Information is UTF-16 encoded as wchar_ts */
  52.  
  53. #ifndef XML_UNICODE
  54. #define XML_UNICODE
  55. #endif
  56.  
  57. #include <stddef.h>
  58. typedef wchar_t XML_Char;
  59. typedef wchar_t XML_LChar;
  60.  
  61. #else /* not XML_UNICODE_WCHAR_T */
  62.  
  63. #ifdef XML_UNICODE
  64.  
  65. /* Information is UTF-16 encoded as unsigned shorts */
  66. typedef unsigned short XML_Char;
  67. typedef char XML_LChar;
  68.  
  69. #else /* not XML_UNICODE */
  70.  
  71. /* Information is UTF-8 encoded. */
  72. typedef char XML_Char;
  73. typedef char XML_LChar;
  74.  
  75. #endif /* not XML_UNICODE */
  76.  
  77. #endif /* not XML_UNICODE_WCHAR_T */
  78.  
  79.  
  80. enum XML_Content_Type {
  81.   XML_CTYPE_EMPTY = 1,
  82.   XML_CTYPE_ANY,
  83.   XML_CTYPE_MIXED,
  84.   XML_CTYPE_NAME,
  85.   XML_CTYPE_CHOICE,
  86.   XML_CTYPE_SEQ
  87. };
  88.  
  89. enum XML_Content_Quant {
  90.   XML_CQUANT_NONE,
  91.   XML_CQUANT_OPT,
  92.   XML_CQUANT_REP,
  93.   XML_CQUANT_PLUS
  94. };
  95.  
  96. /* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
  97.    XML_CQUANT_NONE, and the other fields will be zero or NULL.
  98.    If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
  99.    numchildren will contain number of elements that may be mixed in
  100.    and children point to an array of XML_Content cells that will be
  101.    all of XML_CTYPE_NAME type with no quantification.
  102.  
  103.    If type == XML_CTYPE_NAME, then the name points to the name, and
  104.    the numchildren field will be zero and children will be NULL. The
  105.    quant fields indicates any quantifiers placed on the name.
  106.  
  107.    CHOICE and SEQ will have name NULL, the number of children in
  108.    numchildren and children will point, recursively, to an array
  109.    of XML_Content cells.
  110.  
  111.    The EMPTY, ANY, and MIXED types will only occur at top level.
  112. */
  113.  
  114. typedef struct XML_cp XML_Content;
  115.  
  116. struct XML_cp {
  117.   enum XML_Content_Type        type;
  118.   enum XML_Content_Quant    quant;
  119.   const XML_Char *        name;
  120.   unsigned int            numchildren;
  121.   XML_Content *            children;
  122. };
  123.  
  124.  
  125. /* This is called for an element declaration. See above for
  126.    description of the model argument. It's the caller's responsibility
  127.    to free model when finished with it by calling XML_ContentFree.
  128. */
  129.  
  130. typedef void (*XML_ElementDeclHandler) (void *userData,
  131.                     const XML_Char *name,
  132.                     XML_Content *model);
  133.  
  134. void XMLPARSEAPI
  135. XML_SetElementDeclHandler(XML_Parser parser,
  136.               XML_ElementDeclHandler eldecl);
  137.  
  138.  
  139. void XMLPARSEAPI
  140. XML_ContentFree(XML_Content *content);
  141.  
  142. /*
  143.   The Attlist declaration handler is called for *each* attribute. So
  144.   a single Attlist declaration with multiple attributes declared will
  145.   generate multiple calls to this handler. The "default" parameter
  146.   may be NULL in the case of the "#IMPLIED" or "#REQUIRED" keyword.
  147.   The "isrequired" parameter will be true and the default value will
  148.   be NULL in the case of "#REQUIRED". If "isrequired" is true and
  149.   default is non-NULL, then this is a "#FIXED" default.
  150.  */
  151.  
  152. typedef void (*XML_AttlistDeclHandler) (void        *userData,
  153.                     const XML_Char    *elname,
  154.                     const XML_Char    *attname,
  155.                     const XML_Char    *att_type,
  156.                     const XML_Char    *dflt,
  157.                     int        isrequired);
  158.  
  159. void XMLPARSEAPI
  160. XML_SetAttlistDeclHandler(XML_Parser parser,
  161.               XML_AttlistDeclHandler attdecl);
  162.  
  163.  
  164.   /* The XML declaration handler is called for *both* XML declarations and
  165.      text declarations. The way to distinguish is that the version parameter
  166.      will be null for text declarations. The encoding parameter may be null
  167.      for XML declarations. The standalone parameter will be -1, 0, or 1
  168.      indicating respectively that there was no standalone parameter in
  169.      the declaration, that it was given as no, or that it was given as yes.
  170.   */
  171.  
  172. typedef void (*XML_XmlDeclHandler) (void        *userData,
  173.                     const XML_Char    *version,
  174.                     const XML_Char    *encoding,
  175.                     int            standalone);
  176.  
  177.  
  178.  
  179. void XMLPARSEAPI
  180. XML_SetXmlDeclHandler(XML_Parser parser,
  181.               XML_XmlDeclHandler xmldecl);
  182.  
  183. /* Constructs a new parser; encoding is the encoding specified by the external
  184. protocol or null if there is none specified. */
  185.  
  186. XML_Parser XMLPARSEAPI
  187. XML_ParserCreate(const XML_Char *encoding);
  188.  
  189. /* Constructs a new parser and namespace processor.  Element type names
  190. and attribute names that belong to a namespace will be expanded;
  191. unprefixed attribute names are never expanded; unprefixed element type
  192. names are expanded only if there is a default namespace. The expanded
  193. name is the concatenation of the namespace URI, the namespace separator character,
  194. and the local part of the name.  If the namespace separator is '\0' then
  195. the namespace URI and the local part will be concatenated without any
  196. separator.  When a namespace is not declared, the name and prefix will be
  197. passed through without expansion. */
  198.  
  199. XML_Parser XMLPARSEAPI
  200. XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
  201.  
  202.  
  203. /* atts is array of name/value pairs, terminated by 0;
  204.    names and values are 0 terminated. */
  205.  
  206. typedef void (*XML_StartElementHandler)(void *userData,
  207.                     const XML_Char *name,
  208.                     const XML_Char **atts);
  209.  
  210. typedef void (*XML_EndElementHandler)(void *userData,
  211.                       const XML_Char *name);
  212.  
  213. /* s is not 0 terminated. */
  214. typedef void (*XML_CharacterDataHandler)(void *userData,
  215.                      const XML_Char *s,
  216.                      int len);
  217.  
  218. /* target and data are 0 terminated */
  219. typedef void (*XML_ProcessingInstructionHandler)(void *userData,
  220.                          const XML_Char *target,
  221.                          const XML_Char *data);
  222.  
  223. /* data is 0 terminated */
  224. typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data);
  225.  
  226. typedef void (*XML_StartCdataSectionHandler)(void *userData);
  227. typedef void (*XML_EndCdataSectionHandler)(void *userData);
  228.  
  229. /* This is called for any characters in the XML document for
  230. which there is no applicable handler.  This includes both
  231. characters that are part of markup which is of a kind that is
  232. not reported (comments, markup declarations), or characters
  233. that are part of a construct which could be reported but
  234. for which no handler has been supplied. The characters are passed
  235. exactly as they were in the XML document except that
  236. they will be encoded in UTF-8.  Line boundaries are not normalized.
  237. Note that a byte order mark character is not passed to the default handler.
  238. There are no guarantees about how characters are divided between calls
  239. to the default handler: for example, a comment might be split between
  240. multiple calls. */
  241.  
  242. typedef void (*XML_DefaultHandler)(void *userData,
  243.                    const XML_Char *s,
  244.                    int len);
  245.  
  246. /* This is called for the start of the DOCTYPE declaration, before
  247.    any DTD or internal subset is parsed. */
  248.  
  249. typedef void (*XML_StartDoctypeDeclHandler)(void *userData,
  250.                         const XML_Char *doctypeName,
  251.                         const XML_Char *sysid,
  252.                         const XML_Char *pubid,
  253.                         int has_internal_subset
  254.                         );
  255.  
  256. /* This is called for the start of the DOCTYPE declaration when the
  257. closing > is encountered, but after processing any external subset. */
  258. typedef void (*XML_EndDoctypeDeclHandler)(void *userData);
  259.  
  260. /* This is called for entity declarations. The is_parameter_entity
  261.    argument will be non-zero if the entity is a parameter entity, zero
  262.    otherwise.
  263.  
  264.    For internal entities (<!ENTITY foo "bar">), value will
  265.    be non-null and systemId, publicID, and notationName will be null.
  266.    The value string is NOT null terminated; the length is provided in
  267.    the value_length argument. Since it is legal to have zero-length
  268.    values, do not use this argument to test for internal entities.
  269.  
  270.    For external entities, value will be null and systemId will be non-null.
  271.    The publicId argument will be null unless a public identifier was
  272.    provided. The notationName argument will have a non-null value only
  273.    for unparsed entity declarations.
  274. */
  275.  
  276. typedef void (*XML_EntityDeclHandler) (void *userData,
  277.                        const XML_Char *entityName,
  278.                        int is_parameter_entity,
  279.                        const XML_Char *value,
  280.                        int value_length,
  281.                        const XML_Char *base,
  282.                        const XML_Char *systemId,
  283.                        const XML_Char *publicId,
  284.                        const XML_Char *notationName);
  285.                        
  286. void XMLPARSEAPI
  287. XML_SetEntityDeclHandler(XML_Parser parser,
  288.              XML_EntityDeclHandler handler);
  289.  
  290. /* OBSOLETE -- OBSOLETE -- OBSOLETE
  291.    This handler has been superceded by the EntityDeclHandler above.
  292.    It is provided here for backward compatibility.
  293. This is called for a declaration of an unparsed (NDATA)
  294. entity.  The base argument is whatever was set by XML_SetBase.
  295. The entityName, systemId and notationName arguments will never be null.
  296. The other arguments may be. */
  297.  
  298. typedef void (*XML_UnparsedEntityDeclHandler)(void *userData,
  299.                           const XML_Char *entityName,
  300.                           const XML_Char *base,
  301.                           const XML_Char *systemId,
  302.                           const XML_Char *publicId,
  303.                           const XML_Char *notationName);
  304.  
  305. /* This is called for a declaration of notation.
  306. The base argument is whatever was set by XML_SetBase.
  307. The notationName will never be null.  The other arguments can be. */
  308.  
  309. typedef void (*XML_NotationDeclHandler)(void *userData,
  310.                     const XML_Char *notationName,
  311.                     const XML_Char *base,
  312.                     const XML_Char *systemId,
  313.                     const XML_Char *publicId);
  314.  
  315. /* When namespace processing is enabled, these are called once for
  316. each namespace declaration. The call to the start and end element
  317. handlers occur between the calls to the start and end namespace
  318. declaration handlers. For an xmlns attribute, prefix will be null.
  319. For an xmlns="" attribute, uri will be null. */
  320.  
  321. typedef void (*XML_StartNamespaceDeclHandler)(void *userData,
  322.                           const XML_Char *prefix,
  323.                           const XML_Char *uri);
  324.  
  325. typedef void (*XML_EndNamespaceDeclHandler)(void *userData,
  326.                         const XML_Char *prefix);
  327.  
  328. /* This is called if the document is not standalone (it has an
  329. external subset or a reference to a parameter entity, but does not
  330. have standalone="yes"). If this handler returns 0, then processing
  331. will not continue, and the parser will return a
  332. XML_ERROR_NOT_STANDALONE error. */
  333.  
  334. typedef int (*XML_NotStandaloneHandler)(void *userData);
  335.  
  336. /* This is called for a reference to an external parsed general entity.
  337. The referenced entity is not automatically parsed.
  338. The application can parse it immediately or later using
  339. XML_ExternalEntityParserCreate.
  340. The parser argument is the parser parsing the entity containing the reference;
  341. it can be passed as the parser argument to XML_ExternalEntityParserCreate.
  342. The systemId argument is the system identifier as specified in the entity declaration;
  343. it will not be null.
  344. The base argument is the system identifier that should be used as the base for
  345. resolving systemId if systemId was relative; this is set by XML_SetBase;
  346. it may be null.
  347. The publicId argument is the public identifier as specified in the entity declaration,
  348. or null if none was specified; the whitespace in the public identifier
  349. will have been normalized as required by the XML spec.
  350. The context argument specifies the parsing context in the format
  351. expected by the context argument to
  352. XML_ExternalEntityParserCreate; context is valid only until the handler
  353. returns, so if the referenced entity is to be parsed later, it must be copied.
  354. The handler should return 0 if processing should not continue because of
  355. a fatal error in the handling of the external entity.
  356. In this case the calling parser will return an XML_ERROR_EXTERNAL_ENTITY_HANDLING
  357. error.
  358. Note that unlike other handlers the first argument is the parser, not userData. */
  359.  
  360. typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser,
  361.                         const XML_Char *context,
  362.                         const XML_Char *base,
  363.                         const XML_Char *systemId,
  364.                         const XML_Char *publicId);
  365.  
  366. /* This structure is filled in by the XML_UnknownEncodingHandler
  367. to provide information to the parser about encodings that are unknown
  368. to the parser.
  369. The map[b] member gives information about byte sequences
  370. whose first byte is b.
  371. If map[b] is c where c is >= 0, then b by itself encodes the Unicode scalar value c.
  372. If map[b] is -1, then the byte sequence is malformed.
  373. If map[b] is -n, where n >= 2, then b is the first byte of an n-byte
  374. sequence that encodes a single Unicode scalar value.
  375. The data member will be passed as the first argument to the convert function.
  376. The convert function is used to convert multibyte sequences;
  377. s will point to a n-byte sequence where map[(unsigned char)*s] == -n.
  378. The convert function must return the Unicode scalar value
  379. represented by this byte sequence or -1 if the byte sequence is malformed.
  380. The convert function may be null if the encoding is a single-byte encoding,
  381. that is if map[b] >= -1 for all bytes b.
  382. When the parser is finished with the encoding, then if release is not null,
  383. it will call release passing it the data member;
  384. once release has been called, the convert function will not be called again.
  385.  
  386. Expat places certain restrictions on the encodings that are supported
  387. using this mechanism.
  388.  
  389. 1. Every ASCII character that can appear in a well-formed XML document,
  390. other than the characters
  391.  
  392.   $@\^`{}~
  393.  
  394. must be represented by a single byte, and that byte must be the
  395. same byte that represents that character in ASCII.
  396.  
  397. 2. No character may require more than 4 bytes to encode.
  398.  
  399. 3. All characters encoded must have Unicode scalar values <= 0xFFFF,
  400. (ie characters that would be encoded by surrogates in UTF-16
  401. are  not allowed).  Note that this restriction doesn't apply to
  402. the built-in support for UTF-8 and UTF-16.
  403.  
  404. 4. No Unicode character may be encoded by more than one distinct sequence
  405. of bytes. */
  406.  
  407. typedef struct {
  408.   int map[256];
  409.   void *data;
  410.   int (*convert)(void *data, const char *s);
  411.   void (*release)(void *data);
  412. } XML_Encoding;
  413.  
  414. /* This is called for an encoding that is unknown to the parser.
  415. The encodingHandlerData argument is that which was passed as the
  416. second argument to XML_SetUnknownEncodingHandler.
  417. The name argument gives the name of the encoding as specified in
  418. the encoding declaration.
  419. If the callback can provide information about the encoding,
  420. it must fill in the XML_Encoding structure, and return 1.
  421. Otherwise it must return 0.
  422. If info does not describe a suitable encoding,
  423. then the parser will return an XML_UNKNOWN_ENCODING error. */
  424.  
  425. typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData,
  426.                       const XML_Char *name,
  427.                       XML_Encoding *info);
  428.  
  429. void XMLPARSEAPI
  430. XML_SetElementHandler(XML_Parser parser,
  431.               XML_StartElementHandler start,
  432.               XML_EndElementHandler end);
  433.  
  434. void XMLPARSEAPI
  435. XML_SetStartElementHandler(XML_Parser parser, XML_StartElementHandler);
  436.  
  437. void XMLPARSEAPI
  438. XML_SetEndElementHandler(XML_Parser parser, XML_EndElementHandler);
  439.  
  440. void XMLPARSEAPI
  441. XML_SetCharacterDataHandler(XML_Parser parser,
  442.                 XML_CharacterDataHandler handler);
  443.  
  444. void XMLPARSEAPI
  445. XML_SetProcessingInstructionHandler(XML_Parser parser,
  446.                     XML_ProcessingInstructionHandler handler);
  447. void XMLPARSEAPI
  448. XML_SetCommentHandler(XML_Parser parser,
  449.                       XML_CommentHandler handler);
  450.  
  451. void XMLPARSEAPI
  452. XML_SetCdataSectionHandler(XML_Parser parser,
  453.                XML_StartCdataSectionHandler start,
  454.                XML_EndCdataSectionHandler end);
  455.  
  456. void XMLPARSEAPI
  457. XML_SetStartCdataSectionHandler(XML_Parser parser,
  458.                 XML_StartCdataSectionHandler start);
  459.  
  460. void XMLPARSEAPI
  461. XML_SetEndCdataSectionHandler(XML_Parser parser,
  462.                   XML_EndCdataSectionHandler end);
  463.  
  464. /* This sets the default handler and also inhibits expansion of internal entities.
  465. The entity reference will be passed to the default handler. */
  466.  
  467. void XMLPARSEAPI
  468. XML_SetDefaultHandler(XML_Parser parser,
  469.               XML_DefaultHandler handler);
  470.  
  471. /* This sets the default handler but does not inhibit expansion of internal entities.
  472. The entity reference will not be passed to the default handler. */
  473.  
  474. void XMLPARSEAPI
  475. XML_SetDefaultHandlerExpand(XML_Parser parser,
  476.                     XML_DefaultHandler handler);
  477.  
  478. void XMLPARSEAPI
  479. XML_SetDoctypeDeclHandler(XML_Parser parser,
  480.               XML_StartDoctypeDeclHandler start,
  481.               XML_EndDoctypeDeclHandler end);
  482.  
  483. void XMLPARSEAPI
  484. XML_SetStartDoctypeDeclHandler(XML_Parser parser,
  485.                    XML_StartDoctypeDeclHandler start);
  486.  
  487. void XMLPARSEAPI
  488. XML_SetEndDoctypeDeclHandler(XML_Parser parser,
  489.                  XML_EndDoctypeDeclHandler end);
  490.  
  491. void XMLPARSEAPI
  492. XML_SetEntityDeclHandler(XML_Parser parser,
  493.              XML_EntityDeclHandler handler);
  494.  
  495. void XMLPARSEAPI
  496. XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
  497.                  XML_UnparsedEntityDeclHandler handler);
  498.  
  499. void XMLPARSEAPI
  500. XML_SetNotationDeclHandler(XML_Parser parser,
  501.                XML_NotationDeclHandler handler);
  502.  
  503. void XMLPARSEAPI
  504. XML_SetNamespaceDeclHandler(XML_Parser parser,
  505.                 XML_StartNamespaceDeclHandler start,
  506.                 XML_EndNamespaceDeclHandler end);
  507.  
  508. void XMLPARSEAPI
  509. XML_SetStartNamespaceDeclHandler(XML_Parser parser,
  510.                  XML_StartNamespaceDeclHandler start);
  511.  
  512. void XMLPARSEAPI
  513. XML_SetEndNamespaceDeclHandler(XML_Parser parser,
  514.                    XML_EndNamespaceDeclHandler end);
  515.  
  516.  
  517. void XMLPARSEAPI
  518. XML_SetNotStandaloneHandler(XML_Parser parser,
  519.                 XML_NotStandaloneHandler handler);
  520.  
  521. void XMLPARSEAPI
  522. XML_SetExternalEntityRefHandler(XML_Parser parser,
  523.                 XML_ExternalEntityRefHandler handler);
  524.  
  525. /* If a non-null value for arg is specified here, then it will be passed
  526. as the first argument to the external entity ref handler instead
  527. of the parser object. */
  528. void XMLPARSEAPI
  529. XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
  530.  
  531. void XMLPARSEAPI
  532. XML_SetUnknownEncodingHandler(XML_Parser parser,
  533.                   XML_UnknownEncodingHandler handler,
  534.                   void *encodingHandlerData);
  535.  
  536. /* This can be called within a handler for a start element, end element,
  537. processing instruction or character data.  It causes the corresponding
  538. markup to be passed to the default handler. */
  539. void XMLPARSEAPI XML_DefaultCurrent(XML_Parser parser);
  540.  
  541. /* This value is passed as the userData argument to callbacks. */
  542. void XMLPARSEAPI
  543. XML_SetUserData(XML_Parser parser, void *userData);
  544.  
  545. /* Returns the last value set by XML_SetUserData or null. */
  546. #define XML_GetUserData(parser) (*(void **)(parser))
  547.  
  548. /* This is equivalent to supplying an encoding argument
  549. to XML_ParserCreate. It must not be called after XML_Parse
  550. or XML_ParseBuffer. */
  551.  
  552. int XMLPARSEAPI
  553. XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
  554.  
  555. /* If this function is called, then the parser will be passed
  556. as the first argument to callbacks instead of userData.
  557. The userData will still be accessible using XML_GetUserData. */
  558.  
  559. void XMLPARSEAPI
  560. XML_UseParserAsHandlerArg(XML_Parser parser);
  561.  
  562. /* Sets the base to be used for resolving relative URIs in system identifiers in
  563. declarations.  Resolving relative identifiers is left to the application:
  564. this value will be passed through as the base argument to the
  565. XML_ExternalEntityRefHandler, XML_NotationDeclHandler
  566. and XML_UnparsedEntityDeclHandler. The base argument will be copied.
  567. Returns zero if out of memory, non-zero otherwise. */
  568.  
  569. int XMLPARSEAPI
  570. XML_SetBase(XML_Parser parser, const XML_Char *base);
  571.  
  572. const XML_Char XMLPARSEAPI *
  573. XML_GetBase(XML_Parser parser);
  574.  
  575. /* Returns the number of the attributes passed in last call to the
  576. XML_StartElementHandler that were specified in the start-tag rather
  577. than defaulted. */
  578.  
  579. int XMLPARSEAPI XML_GetSpecifiedAttributeCount(XML_Parser parser);
  580.  
  581. /* Parses some input. Returns 0 if a fatal error is detected.
  582. The last call to XML_Parse must have isFinal true;
  583. len may be zero for this call (or any other). */
  584. int XMLPARSEAPI
  585. XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
  586.  
  587. void XMLPARSEAPI *
  588. XML_GetBuffer(XML_Parser parser, int len);
  589.  
  590. int XMLPARSEAPI
  591. XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
  592.  
  593. /* Creates an XML_Parser object that can parse an external general entity;
  594. context is a '\0'-terminated string specifying the parse context;
  595. encoding is a '\0'-terminated string giving the name of the externally specified encoding,
  596. or null if there is no externally specified encoding.
  597. The context string consists of a sequence of tokens separated by formfeeds (\f);
  598. a token consisting of a name specifies that the general entity of the name
  599. is open; a token of the form prefix=uri specifies the namespace for a particular
  600. prefix; a token of the form =uri specifies the default namespace.
  601. This can be called at any point after the first call to an ExternalEntityRefHandler
  602. so longer as the parser has not yet been freed.
  603. The new parser is completely independent and may safely be used in a separate thread.
  604. The handlers and userData are initialized from the parser argument.
  605. Returns 0 if out of memory.  Otherwise returns a new XML_Parser object. */
  606. XML_Parser XMLPARSEAPI
  607. XML_ExternalEntityParserCreate(XML_Parser parser,
  608.                    const XML_Char *context,
  609.                    const XML_Char *encoding);
  610.  
  611. enum XML_ParamEntityParsing {
  612.   XML_PARAM_ENTITY_PARSING_NEVER,
  613.   XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
  614.   XML_PARAM_ENTITY_PARSING_ALWAYS
  615. };
  616.  
  617. /* Controls parsing of parameter entities (including the external DTD
  618. subset). If parsing of parameter entities is enabled, then references
  619. to external parameter entities (including the external DTD subset)
  620. will be passed to the handler set with
  621. XML_SetExternalEntityRefHandler.  The context passed will be 0.
  622. Unlike external general entities, external parameter entities can only
  623. be parsed synchronously.  If the external parameter entity is to be
  624. parsed, it must be parsed during the call to the external entity ref
  625. handler: the complete sequence of XML_ExternalEntityParserCreate,
  626. XML_Parse/XML_ParseBuffer and XML_ParserFree calls must be made during
  627. this call.  After XML_ExternalEntityParserCreate has been called to
  628. create the parser for the external parameter entity (context must be 0
  629. for this call), it is illegal to make any calls on the old parser
  630. until XML_ParserFree has been called on the newly created parser.  If
  631. the library has been compiled without support for parameter entity
  632. parsing (ie without XML_DTD being defined), then
  633. XML_SetParamEntityParsing will return 0 if parsing of parameter
  634. entities is requested; otherwise it will return non-zero. */
  635.  
  636. int XMLPARSEAPI
  637. XML_SetParamEntityParsing(XML_Parser parser,
  638.               enum XML_ParamEntityParsing parsing);
  639.  
  640. enum XML_Error {
  641.   XML_ERROR_NONE,
  642.   XML_ERROR_NO_MEMORY,
  643.   XML_ERROR_SYNTAX,
  644.   XML_ERROR_NO_ELEMENTS,
  645.   XML_ERROR_INVALID_TOKEN,
  646.   XML_ERROR_UNCLOSED_TOKEN,
  647.   XML_ERROR_PARTIAL_CHAR,
  648.   XML_ERROR_TAG_MISMATCH,
  649.   XML_ERROR_DUPLICATE_ATTRIBUTE,
  650.   XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
  651.   XML_ERROR_PARAM_ENTITY_REF,
  652.   XML_ERROR_UNDEFINED_ENTITY,
  653.   XML_ERROR_RECURSIVE_ENTITY_REF,
  654.   XML_ERROR_ASYNC_ENTITY,
  655.   XML_ERROR_BAD_CHAR_REF,
  656.   XML_ERROR_BINARY_ENTITY_REF,
  657.   XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
  658.   XML_ERROR_MISPLACED_XML_PI,
  659.   XML_ERROR_UNKNOWN_ENCODING,
  660.   XML_ERROR_INCORRECT_ENCODING,
  661.   XML_ERROR_UNCLOSED_CDATA_SECTION,
  662.   XML_ERROR_EXTERNAL_ENTITY_HANDLING,
  663.   XML_ERROR_NOT_STANDALONE
  664. };
  665.  
  666. /* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode
  667. returns information about the error. */
  668.  
  669. enum XML_Error XMLPARSEAPI XML_GetErrorCode(XML_Parser parser);
  670.  
  671. /* These functions return information about the current parse location.
  672. They may be called when XML_Parse or XML_ParseBuffer return 0;
  673. in this case the location is the location of the character at which
  674. the error was detected.
  675. They may also be called from any other callback called to report
  676. some parse event; in this the location is the location of the first
  677. of the sequence of characters that generated the event. */
  678.  
  679. int XMLPARSEAPI XML_GetCurrentLineNumber(XML_Parser parser);
  680. int XMLPARSEAPI XML_GetCurrentColumnNumber(XML_Parser parser);
  681. long XMLPARSEAPI XML_GetCurrentByteIndex(XML_Parser parser);
  682.  
  683. /* Return the number of bytes in the current event.
  684. Returns 0 if the event is in an internal entity. */
  685.  
  686. int XMLPARSEAPI XML_GetCurrentByteCount(XML_Parser parser);
  687.  
  688. /* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
  689.    the integer pointed to by offset to the offset within this buffer
  690.    of the current parse position, and sets the integer pointed to by size
  691.    to the size of this buffer (the number of input bytes). Otherwise
  692.    returns a null pointer. Also returns a null pointer if a parse isn't active.
  693.  
  694.    NOTE: The character pointer returned should not be used outside
  695.    the handler that makes the call. */
  696.  
  697. const char XMLPARSEAPI * XML_GetInputContext(XML_Parser parser,
  698.                          int *offset,
  699.                          int *size);
  700.  
  701. /* For backwards compatibility with previous versions. */
  702. #define XML_GetErrorLineNumber XML_GetCurrentLineNumber
  703. #define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
  704. #define XML_GetErrorByteIndex XML_GetCurrentByteIndex
  705.  
  706. /* Frees memory used by the parser. */
  707. void XMLPARSEAPI
  708. XML_ParserFree(XML_Parser parser);
  709.  
  710. /* Returns a string describing the error. */
  711. const XML_LChar XMLPARSEAPI *XML_ErrorString(int code);
  712.  
  713. #ifdef __cplusplus
  714. }
  715. #endif
  716.  
  717. #endif /* not XmlParse_INCLUDED */
  718.