parserInternals.h

00001 /*
00002 
00003  * Summary: internals routines exported by the parser.
00004 
00005  * Description: this module exports a number of internal parsing routines
00006 
00007  *              they are not really all intended for applications but
00008 
00009  *              can prove useful doing low level processing.
00010 
00011  *
00012 
00013  * Copy: See Copyright for the status of this software.
00014 
00015  *
00016 
00017  * Author: Daniel Veillard
00018 
00019  */
00020 
00021 
00022 
00023 #ifndef __XML_PARSER_INTERNALS_H__
00024 
00025 #define __XML_PARSER_INTERNALS_H__
00026 
00027 
00028 
00029 #include <libxml/xmlversion.h>
00030 
00031 #include <libxml/parser.h>
00032 
00033 #include <libxml/HTMLparser.h>
00034 
00035 #include <libxml/chvalid.h>
00036 
00037 
00038 
00039 #ifdef __cplusplus
00040 
00041 extern "C" {
00042 
00043 #endif
00044 
00045 
00046 
00061 XMLPUBVAR unsigned int xmlParserMaxDepth;
00062 
00063 
00064 
00077 #define XML_MAX_NAMELEN 100
00078 
00079 
00080 
00093 #define INPUT_CHUNK     250
00094 
00095 
00096 
00097 /************************************************************************
00098 
00099  *                                                                      *
00100 
00101  * UNICODE version of the macros.                                       *
00102 
00103  *                                                                      *
00104 
00105  ************************************************************************/
00106 
00125 #define IS_BYTE_CHAR(c)  xmlIsChar_ch(c)
00126 
00127 
00128 
00149 #define IS_CHAR(c)   xmlIsCharQ(c)
00150 
00151 
00152 
00165 #define IS_CHAR_CH(c)  xmlIsChar_ch(c)
00166 
00167 
00168 
00185 #define IS_BLANK(c)  xmlIsBlankQ(c)
00186 
00187 
00188 
00201 #define IS_BLANK_CH(c)  xmlIsBlank_ch(c)
00202 
00203 
00204 
00221 #define IS_BASECHAR(c) xmlIsBaseCharQ(c)
00222 
00223 
00224 
00241 #define IS_DIGIT(c) xmlIsDigitQ(c)
00242 
00243 
00244 
00257 #define IS_DIGIT_CH(c)  xmlIsDigit_ch(c)
00258 
00259 
00260 
00277 #define IS_COMBINING(c) xmlIsCombiningQ(c)
00278 
00279 
00280 
00293 #define IS_COMBINING_CH(c) 0 
00294 
00295 
00296 
00319 #define IS_EXTENDER(c) xmlIsExtenderQ(c)
00320 
00321 
00322 
00335 #define IS_EXTENDER_CH(c)  xmlIsExtender_ch(c)
00336 
00337 
00338 
00357 #define IS_IDEOGRAPHIC(c) xmlIsIdeographicQ(c)
00358 
00359 
00360 
00379 #define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))
00380 
00381 
00382 
00397 #define IS_LETTER_CH(c) xmlIsBaseChar_ch(c)
00398 
00399 
00400 
00415 #define IS_ASCII_LETTER(c)      (((0x41 <= (c)) && ((c) <= 0x5a)) || \
00416 
00417                                  ((0x61 <= (c)) && ((c) <= 0x7a)))
00418 
00419 
00420 
00435 #define IS_ASCII_DIGIT(c)       ((0x30 <= (c)) && ((c) <= 0x39))
00436 
00437 
00438 
00457 #define IS_PUBIDCHAR(c) xmlIsPubidCharQ(c)
00458 
00459 
00460 
00473 #define IS_PUBIDCHAR_CH(c) xmlIsPubidChar_ch(c)
00474 
00475 
00476 
00489 #define SKIP_EOL(p)                                                     \
00490 
00491     if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; }                  \
00492 
00493     if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; }
00494 
00495 
00496 
00509 #define MOVETO_ENDTAG(p)                                                \
00510 
00511     while ((*p) && (*(p) != '>')) (p)++
00512 
00513 
00514 
00527 #define MOVETO_STARTTAG(p)                                              \
00528 
00529     while ((*p) && (*(p) != '<')) (p)++
00530 
00531 
00532 
00539 XMLPUBVAR const xmlChar xmlStringText[];
00540 
00541 XMLPUBVAR const xmlChar xmlStringTextNoenc[];
00542 
00543 XMLPUBVAR const xmlChar xmlStringComment[];
00544 
00545 
00546 
00547 /*
00548 
00549  * Function to finish the work of the macros where needed.
00550 
00551  */
00552 
00553 XMLPUBFUN int XMLCALL                   xmlIsLetter     (int c);
00554 
00555 
00556 
00563 XMLPUBFUN xmlParserCtxtPtr XMLCALL      
00564 
00565                         xmlCreateFileParserCtxt (const char *filename);
00566 
00567 XMLPUBFUN xmlParserCtxtPtr XMLCALL      
00568 
00569                         xmlCreateURLParserCtxt  (const char *filename,
00570 
00571                                                  int options);
00572 
00573 XMLPUBFUN xmlParserCtxtPtr XMLCALL      
00574 
00575                         xmlCreateMemoryParserCtxt(const char *buffer,
00576 
00577                                                  int size);
00578 
00579 XMLPUBFUN xmlParserCtxtPtr XMLCALL      
00580 
00581                         xmlCreateEntityParserCtxt(const xmlChar *URL,
00582 
00583                                                  const xmlChar *ID,
00584 
00585                                                  const xmlChar *base);
00586 
00587 XMLPUBFUN int XMLCALL                   
00588 
00589                         xmlSwitchEncoding       (xmlParserCtxtPtr ctxt,
00590 
00591                                                  xmlCharEncoding enc);
00592 
00593 XMLPUBFUN int XMLCALL                   
00594 
00595                         xmlSwitchToEncoding     (xmlParserCtxtPtr ctxt,
00596 
00597                                          xmlCharEncodingHandlerPtr handler);
00598 
00599 XMLPUBFUN int XMLCALL                   
00600 
00601                         xmlSwitchInputEncoding  (xmlParserCtxtPtr ctxt,
00602 
00603                                                  xmlParserInputPtr input,
00604 
00605                                          xmlCharEncodingHandlerPtr handler);
00606 
00607 
00608 
00609 #ifdef IN_LIBXML
00610 
00611 /* internal error reporting */
00612 
00613 XMLPUBFUN void XMLCALL
00614 
00615                         __xmlErrEncoding        (xmlParserCtxtPtr ctxt,
00616 
00617                                                  xmlParserErrors xmlerr,
00618 
00619                                                  const char *msg,
00620 
00621                                                  const xmlChar * str1,
00622 
00623                                                  const xmlChar * str2);
00624 
00625 #endif
00626 
00627 
00628 
00635 XMLPUBFUN xmlParserInputPtr XMLCALL     
00636 
00637                         xmlNewStringInputStream (xmlParserCtxtPtr ctxt,
00638 
00639                                                  const xmlChar *buffer);
00640 
00641 XMLPUBFUN xmlParserInputPtr XMLCALL     
00642 
00643                         xmlNewEntityInputStream (xmlParserCtxtPtr ctxt,
00644 
00645                                                  xmlEntityPtr entity);
00646 
00647 XMLPUBFUN void XMLCALL                  
00648 
00649                         xmlPushInput            (xmlParserCtxtPtr ctxt,
00650 
00651                                                  xmlParserInputPtr input);
00652 
00653 XMLPUBFUN xmlChar XMLCALL                       
00654 
00655                         xmlPopInput             (xmlParserCtxtPtr ctxt);
00656 
00657 XMLPUBFUN void XMLCALL                  
00658 
00659                         xmlFreeInputStream      (xmlParserInputPtr input);
00660 
00661 XMLPUBFUN xmlParserInputPtr XMLCALL     
00662 
00663                         xmlNewInputFromFile     (xmlParserCtxtPtr ctxt,
00664 
00665                                                  const char *filename);
00666 
00667 XMLPUBFUN xmlParserInputPtr XMLCALL     
00668 
00669                         xmlNewInputStream       (xmlParserCtxtPtr ctxt);
00670 
00671 
00672 
00679 XMLPUBFUN xmlChar * XMLCALL             
00680 
00681                         xmlSplitQName           (xmlParserCtxtPtr ctxt,
00682 
00683                                                  const xmlChar *name,
00684 
00685                                                  xmlChar **prefix);
00686 
00687 
00688 
00695 XMLPUBFUN const xmlChar * XMLCALL               
00696 
00697                         xmlParseName            (xmlParserCtxtPtr ctxt);
00698 
00699 XMLPUBFUN xmlChar * XMLCALL             
00700 
00701                         xmlParseNmtoken         (xmlParserCtxtPtr ctxt);
00702 
00703 XMLPUBFUN xmlChar * XMLCALL             
00704 
00705                         xmlParseEntityValue     (xmlParserCtxtPtr ctxt,
00706 
00707                                                  xmlChar **orig);
00708 
00709 XMLPUBFUN xmlChar * XMLCALL             
00710 
00711                         xmlParseAttValue        (xmlParserCtxtPtr ctxt);
00712 
00713 XMLPUBFUN xmlChar * XMLCALL             
00714 
00715                         xmlParseSystemLiteral   (xmlParserCtxtPtr ctxt);
00716 
00717 XMLPUBFUN xmlChar * XMLCALL             
00718 
00719                         xmlParsePubidLiteral    (xmlParserCtxtPtr ctxt);
00720 
00721 XMLPUBFUN void XMLCALL                  
00722 
00723                         xmlParseCharData        (xmlParserCtxtPtr ctxt,
00724 
00725                                                  int cdata);
00726 
00727 XMLPUBFUN xmlChar * XMLCALL             
00728 
00729                         xmlParseExternalID      (xmlParserCtxtPtr ctxt,
00730 
00731                                                  xmlChar **publicID,
00732 
00733                                                  int strict);
00734 
00735 XMLPUBFUN void XMLCALL                  
00736 
00737                         xmlParseComment         (xmlParserCtxtPtr ctxt);
00738 
00739 XMLPUBFUN const xmlChar * XMLCALL               
00740 
00741                         xmlParsePITarget        (xmlParserCtxtPtr ctxt);
00742 
00743 XMLPUBFUN void XMLCALL                  
00744 
00745                         xmlParsePI              (xmlParserCtxtPtr ctxt);
00746 
00747 XMLPUBFUN void XMLCALL                  
00748 
00749                         xmlParseNotationDecl    (xmlParserCtxtPtr ctxt);
00750 
00751 XMLPUBFUN void XMLCALL                  
00752 
00753                         xmlParseEntityDecl      (xmlParserCtxtPtr ctxt);
00754 
00755 XMLPUBFUN int XMLCALL                   
00756 
00757                         xmlParseDefaultDecl     (xmlParserCtxtPtr ctxt,
00758 
00759                                                  xmlChar **value);
00760 
00761 XMLPUBFUN xmlEnumerationPtr XMLCALL     
00762 
00763                         xmlParseNotationType    (xmlParserCtxtPtr ctxt);
00764 
00765 XMLPUBFUN xmlEnumerationPtr XMLCALL     
00766 
00767                         xmlParseEnumerationType (xmlParserCtxtPtr ctxt);
00768 
00769 XMLPUBFUN int XMLCALL                   
00770 
00771                         xmlParseEnumeratedType  (xmlParserCtxtPtr ctxt,
00772 
00773                                                  xmlEnumerationPtr *tree);
00774 
00775 XMLPUBFUN int XMLCALL                   
00776 
00777                         xmlParseAttributeType   (xmlParserCtxtPtr ctxt,
00778 
00779                                                  xmlEnumerationPtr *tree);
00780 
00781 XMLPUBFUN void XMLCALL                  
00782 
00783                         xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt);
00784 
00785 XMLPUBFUN xmlElementContentPtr XMLCALL  
00786 
00787                         xmlParseElementMixedContentDecl
00788 
00789                                                 (xmlParserCtxtPtr ctxt,
00790 
00791                                                  int inputchk);
00792 
00793 XMLPUBFUN xmlElementContentPtr XMLCALL  
00794 
00795                         xmlParseElementChildrenContentDecl
00796 
00797                                                 (xmlParserCtxtPtr ctxt,
00798 
00799                                                  int inputchk);
00800 
00801 XMLPUBFUN int XMLCALL                   
00802 
00803                         xmlParseElementContentDecl(xmlParserCtxtPtr ctxt,
00804 
00805                                                  const xmlChar *name,
00806 
00807                                                  xmlElementContentPtr *result);
00808 
00809 XMLPUBFUN int XMLCALL                   
00810 
00811                         xmlParseElementDecl     (xmlParserCtxtPtr ctxt);
00812 
00813 XMLPUBFUN void XMLCALL                  
00814 
00815                         xmlParseMarkupDecl      (xmlParserCtxtPtr ctxt);
00816 
00817 XMLPUBFUN int XMLCALL                   
00818 
00819                         xmlParseCharRef         (xmlParserCtxtPtr ctxt);
00820 
00821 XMLPUBFUN xmlEntityPtr XMLCALL          
00822 
00823                         xmlParseEntityRef       (xmlParserCtxtPtr ctxt);
00824 
00825 XMLPUBFUN void XMLCALL                  
00826 
00827                         xmlParseReference       (xmlParserCtxtPtr ctxt);
00828 
00829 XMLPUBFUN void XMLCALL                  
00830 
00831                         xmlParsePEReference     (xmlParserCtxtPtr ctxt);
00832 
00833 XMLPUBFUN void XMLCALL                  
00834 
00835                         xmlParseDocTypeDecl     (xmlParserCtxtPtr ctxt);
00836 
00837 #ifdef LIBXML_SAX1_ENABLED
00838 
00839 XMLPUBFUN const xmlChar * XMLCALL               
00840 
00841                         xmlParseAttribute       (xmlParserCtxtPtr ctxt,
00842 
00843                                                  xmlChar **value);
00844 
00845 XMLPUBFUN const xmlChar * XMLCALL               
00846 
00847                         xmlParseStartTag        (xmlParserCtxtPtr ctxt);
00848 
00849 XMLPUBFUN void XMLCALL                  
00850 
00851                         xmlParseEndTag          (xmlParserCtxtPtr ctxt);
00852 
00853 #endif /* LIBXML_SAX1_ENABLED */
00854 
00855 XMLPUBFUN void XMLCALL                  
00856 
00857                         xmlParseCDSect          (xmlParserCtxtPtr ctxt);
00858 
00859 XMLPUBFUN void XMLCALL                  
00860 
00861                         xmlParseContent         (xmlParserCtxtPtr ctxt);
00862 
00863 XMLPUBFUN void XMLCALL                  
00864 
00865                         xmlParseElement         (xmlParserCtxtPtr ctxt);
00866 
00867 XMLPUBFUN xmlChar * XMLCALL             
00868 
00869                         xmlParseVersionNum      (xmlParserCtxtPtr ctxt);
00870 
00871 XMLPUBFUN xmlChar * XMLCALL             
00872 
00873                         xmlParseVersionInfo     (xmlParserCtxtPtr ctxt);
00874 
00875 XMLPUBFUN xmlChar * XMLCALL             
00876 
00877                         xmlParseEncName         (xmlParserCtxtPtr ctxt);
00878 
00879 XMLPUBFUN const xmlChar * XMLCALL               
00880 
00881                         xmlParseEncodingDecl    (xmlParserCtxtPtr ctxt);
00882 
00883 XMLPUBFUN int XMLCALL                   
00884 
00885                         xmlParseSDDecl          (xmlParserCtxtPtr ctxt);
00886 
00887 XMLPUBFUN void XMLCALL                  
00888 
00889                         xmlParseXMLDecl         (xmlParserCtxtPtr ctxt);
00890 
00891 XMLPUBFUN void XMLCALL                  
00892 
00893                         xmlParseTextDecl        (xmlParserCtxtPtr ctxt);
00894 
00895 XMLPUBFUN void XMLCALL                  
00896 
00897                         xmlParseMisc            (xmlParserCtxtPtr ctxt);
00898 
00899 XMLPUBFUN void XMLCALL                  
00900 
00901                         xmlParseExternalSubset  (xmlParserCtxtPtr ctxt,
00902 
00903                                                  const xmlChar *ExternalID,
00904 
00905                                                  const xmlChar *SystemID); 
00906 
00917 #define XML_SUBSTITUTE_NONE     0
00918 
00929 #define XML_SUBSTITUTE_REF      1
00930 
00941 #define XML_SUBSTITUTE_PEREF    2
00942 
00953 #define XML_SUBSTITUTE_BOTH     3
00954 
00955 
00956 
00957 XMLPUBFUN xmlChar * XMLCALL
00958 
00959                 xmlStringDecodeEntities         (xmlParserCtxtPtr ctxt,
00960 
00961                                                  const xmlChar *str,
00962 
00963                                                  int what,
00964 
00965                                                  xmlChar end,
00966 
00967                                                  xmlChar  end2,
00968 
00969                                                  xmlChar end3);
00970 
00971 XMLPUBFUN xmlChar * XMLCALL
00972 
00973                 xmlStringLenDecodeEntities      (xmlParserCtxtPtr ctxt,
00974 
00975                                                  const xmlChar *str,
00976 
00977                                                  int len,
00978 
00979                                                  int what,
00980 
00981                                                  xmlChar end,
00982 
00983                                                  xmlChar  end2,
00984 
00985                                                  xmlChar end3);
00986 
00987 
00988 
00989 /*
00990 
00991  * Generated by MACROS on top of parser.c c.f. PUSH_AND_POP.
00992 
00993  */
00994 
00995 XMLPUBFUN int XMLCALL                   nodePush                (xmlParserCtxtPtr ctxt,
00996 
00997                                                  xmlNodePtr value);
00998 
00999 XMLPUBFUN xmlNodePtr XMLCALL            nodePop                 (xmlParserCtxtPtr ctxt);
01000 
01001 XMLPUBFUN int XMLCALL                   inputPush               (xmlParserCtxtPtr ctxt,
01002 
01003                                                  xmlParserInputPtr value);
01004 
01005 XMLPUBFUN xmlParserInputPtr XMLCALL     inputPop                (xmlParserCtxtPtr ctxt);
01006 
01007 XMLPUBFUN const xmlChar * XMLCALL       namePop                 (xmlParserCtxtPtr ctxt);
01008 
01009 XMLPUBFUN int XMLCALL                   namePush                (xmlParserCtxtPtr ctxt,
01010 
01011                                                  const xmlChar *value);
01012 
01013 
01014 
01015 /*
01016 
01017  * other commodities shared between parser.c and parserInternals.
01018 
01019  */
01020 
01021 XMLPUBFUN int XMLCALL                   xmlSkipBlankChars       (xmlParserCtxtPtr ctxt);
01022 
01023 XMLPUBFUN int XMLCALL                   xmlStringCurrentChar    (xmlParserCtxtPtr ctxt,
01024 
01025                                                  const xmlChar *cur,
01026 
01027                                                  int *len);
01028 
01029 XMLPUBFUN void XMLCALL                  xmlParserHandlePEReference(xmlParserCtxtPtr ctxt);
01030 
01031 XMLPUBFUN int XMLCALL                   xmlCheckLanguageID      (const xmlChar *lang);
01032 
01033 
01034 
01035 /*
01036 
01037  * Really core function shared with HTML parser.
01038 
01039  */
01040 
01041 XMLPUBFUN int XMLCALL                   xmlCurrentChar          (xmlParserCtxtPtr ctxt,
01042 
01043                                                  int *len);
01044 
01045 XMLPUBFUN int XMLCALL           xmlCopyCharMultiByte    (xmlChar *out,
01046 
01047                                                  int val);
01048 
01049 XMLPUBFUN int XMLCALL                   xmlCopyChar             (int len,
01050 
01051                                                  xmlChar *out,
01052 
01053                                                  int val);
01054 
01055 XMLPUBFUN void XMLCALL                  xmlNextChar             (xmlParserCtxtPtr ctxt);
01056 
01057 XMLPUBFUN void XMLCALL                  xmlParserInputShrink    (xmlParserInputPtr in);
01058 
01059 
01060 
01061 #ifdef LIBXML_HTML_ENABLED
01062 
01063 /*
01064 
01065  * Actually comes from the HTML parser but launched from the init stuff.
01066 
01067  */
01068 
01069 XMLPUBFUN void XMLCALL                  htmlInitAutoClose       (void);
01070 
01071 XMLPUBFUN htmlParserCtxtPtr XMLCALL     htmlCreateFileParserCtxt(const char *filename,
01072 
01073                                                  const char *encoding);
01074 
01075 #endif
01076 
01077 
01078 
01079 /*
01080 
01081  * Specific function to keep track of entities references
01082 
01083  * and used by the XSLT debugger.
01084 
01085  */
01086 
01087 #ifdef LIBXML_LEGACY_ENABLED
01088 
01107 typedef void    (*xmlEntityReferenceFunc)       (xmlEntityPtr ent,
01108 
01109                                                  xmlNodePtr firstNode,
01110 
01111                                                  xmlNodePtr lastNode);
01112 
01113   
01114 
01115 XMLPUBFUN void XMLCALL          xmlSetEntityReferenceFunc       (xmlEntityReferenceFunc func);
01116 
01117 
01118 
01119 XMLPUBFUN xmlChar * XMLCALL             
01120 
01121                         xmlParseQuotedString    (xmlParserCtxtPtr ctxt);
01122 
01123 XMLPUBFUN void XMLCALL
01124 
01125                         xmlParseNamespace       (xmlParserCtxtPtr ctxt);
01126 
01127 XMLPUBFUN xmlChar * XMLCALL             
01128 
01129                         xmlNamespaceParseNSDef  (xmlParserCtxtPtr ctxt);
01130 
01131 XMLPUBFUN xmlChar * XMLCALL             
01132 
01133                         xmlScanName             (xmlParserCtxtPtr ctxt);
01134 
01135 XMLPUBFUN xmlChar * XMLCALL             
01136 
01137                         xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt);
01138 
01139 XMLPUBFUN void XMLCALL  xmlParserHandleReference(xmlParserCtxtPtr ctxt);
01140 
01141 XMLPUBFUN xmlChar * XMLCALL             
01142 
01143                         xmlNamespaceParseQName  (xmlParserCtxtPtr ctxt,
01144 
01145                                                  xmlChar **prefix);
01146 
01153 XMLPUBFUN xmlChar * XMLCALL
01154 
01155                 xmlDecodeEntities               (xmlParserCtxtPtr ctxt,
01156 
01157                                                  int len,
01158 
01159                                                  int what,
01160 
01161                                                  xmlChar end,
01162 
01163                                                  xmlChar  end2,
01164 
01165                                                  xmlChar end3);
01166 
01167 XMLPUBFUN void XMLCALL                  
01168 
01169                         xmlHandleEntity         (xmlParserCtxtPtr ctxt,
01170 
01171                                                  xmlEntityPtr entity);
01172 
01173 
01174 
01175 #endif /* LIBXML_LEGACY_ENABLED */
01176 
01177 
01178 
01179 #ifdef IN_LIBXML
01180 
01181 /*
01182 
01183  * internal only
01184 
01185  */
01186 
01187 XMLPUBFUN void XMLCALL
01188 
01189         xmlErrMemory            (xmlParserCtxtPtr ctxt,
01190 
01191                                  const char *extra);
01192 
01193 #endif
01194 
01195 
01196 
01197 #ifdef __cplusplus
01198 
01199 }
01200 
01201 #endif
01202 
01203 #endif /* __XML_PARSER_INTERNALS_H__ */
01204 

Generated on Wed Jul 26 13:30:46 2006 for XSB by  doxygen 1.4.5