Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * HTMLparser.h : inf=terface for an HTML 4.0 non-verifying parser |
| 3 | * |
| 4 | * See Copyright for the status of this software. |
| 5 | * |
| 6 | * Daniel.Veillard@w3.org |
| 7 | */ |
| 8 | |
| 9 | #ifndef __HTML_PARSER_H__ |
| 10 | #define __HTML_PARSER_H__ |
| 11 | #include <libxml/parser.h> |
| 12 | |
| 13 | #ifdef __cplusplus |
| 14 | extern "C" { |
| 15 | #endif |
| 16 | |
| 17 | /* |
| 18 | * Most of the back-end structures from XML and HTML are shared |
| 19 | */ |
| 20 | typedef xmlParserCtxt htmlParserCtxt; |
| 21 | typedef xmlParserCtxtPtr htmlParserCtxtPtr; |
| 22 | typedef xmlParserNodeInfo htmlParserNodeInfo; |
| 23 | typedef xmlSAXHandler htmlSAXHandler; |
| 24 | typedef xmlSAXHandlerPtr htmlSAXHandlerPtr; |
| 25 | typedef xmlParserInput htmlParserInput; |
| 26 | typedef xmlParserInputPtr htmlParserInputPtr; |
| 27 | typedef xmlDocPtr htmlDocPtr; |
| 28 | typedef xmlNodePtr htmlNodePtr; |
| 29 | |
| 30 | /* |
| 31 | * Internal description of an HTML element |
| 32 | */ |
| 33 | typedef struct _htmlElemDesc htmlElemDesc; |
| 34 | typedef htmlElemDesc *htmlElemDescPtr; |
| 35 | struct _htmlElemDesc { |
| 36 | const char *name; /* The tag name */ |
| 37 | char startTag; /* Whether the start tag can be implied */ |
| 38 | char endTag; /* Whether the end tag can be implied */ |
| 39 | char saveEndTag; /* Whether the end tag should be saved */ |
| 40 | char empty; /* Is this an empty element ? */ |
| 41 | char depr; /* Is this a deprecated element ? */ |
| 42 | char dtd; /* 1: only in Loose DTD, 2: only Frameset one */ |
| 43 | const char *desc; /* the description */ |
| 44 | }; |
| 45 | |
| 46 | /* |
| 47 | * Internal description of an HTML entity |
| 48 | */ |
| 49 | typedef struct _htmlEntityDesc htmlEntityDesc; |
| 50 | typedef htmlEntityDesc *htmlEntityDescPtr; |
| 51 | struct _htmlEntityDesc { |
| 52 | int value; /* the UNICODE value for the character */ |
| 53 | const char *name; /* The entity name */ |
| 54 | const char *desc; /* the description */ |
| 55 | }; |
| 56 | |
| 57 | /* |
| 58 | * There is only few public functions. |
| 59 | */ |
| 60 | htmlElemDescPtr htmlTagLookup (const xmlChar *tag); |
| 61 | htmlEntityDescPtr htmlEntityLookup(const xmlChar *name); |
| 62 | htmlEntityDescPtr htmlEntityValueLookup(int value); |
| 63 | |
| 64 | int htmlIsAutoClosed(htmlDocPtr doc, |
| 65 | htmlNodePtr elem); |
| 66 | int htmlAutoCloseTag(htmlDocPtr doc, |
| 67 | const xmlChar *name, |
| 68 | htmlNodePtr elem); |
| 69 | htmlEntityDescPtr htmlParseEntityRef(htmlParserCtxtPtr ctxt, |
| 70 | xmlChar **str); |
| 71 | int htmlParseCharRef(htmlParserCtxtPtr ctxt); |
| 72 | void htmlParseElement(htmlParserCtxtPtr ctxt); |
| 73 | |
| 74 | htmlDocPtr htmlSAXParseDoc (xmlChar *cur, |
| 75 | const char *encoding, |
| 76 | htmlSAXHandlerPtr sax, |
| 77 | void *userData); |
| 78 | htmlDocPtr htmlParseDoc (xmlChar *cur, |
| 79 | const char *encoding); |
| 80 | htmlDocPtr htmlSAXParseFile(const char *filename, |
| 81 | const char *encoding, |
| 82 | htmlSAXHandlerPtr sax, |
| 83 | void *userData); |
| 84 | htmlDocPtr htmlParseFile (const char *filename, |
| 85 | const char *encoding); |
| 86 | int UTF8ToHtml (unsigned char* out, |
| 87 | int *outlen, |
| 88 | const unsigned char* in, |
| 89 | int *inlen); |
| 90 | int htmlEncodeEntities(unsigned char* out, |
| 91 | int *outlen, |
| 92 | const unsigned char* in, |
| 93 | int *inlen, int quoteChar); |
| 94 | int htmlIsScriptAttribute(const xmlChar *name); |
| 95 | int htmlHandleOmittedElem(int val); |
| 96 | |
| 97 | /** |
| 98 | * Interfaces for the Push mode |
| 99 | */ |
| 100 | void htmlFreeParserCtxt (htmlParserCtxtPtr ctxt); |
| 101 | htmlParserCtxtPtr htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, |
| 102 | void *user_data, |
| 103 | const char *chunk, |
| 104 | int size, |
| 105 | const char *filename, |
| 106 | xmlCharEncoding enc); |
| 107 | int htmlParseChunk (htmlParserCtxtPtr ctxt, |
| 108 | const char *chunk, |
| 109 | int size, |
| 110 | int terminate); |
| 111 | #ifdef __cplusplus |
| 112 | } |
| 113 | #endif |
| 114 | |
| 115 | #endif /* __HTML_PARSER_H__ */ |