File:  [Public] / XML / SGMLparser.h
Revision 1.1: download - view: text, annotated - select for diffs
Tue Aug 29 23:37:07 2000 UTC (23 years, 9 months ago) by veillard
Branches: MAIN
CVS tags: LIBXML_2_2_8, LIBXML_2_2_6, HEAD
Played with docbook, this may never end-up in a libxml release, Daniel

/*
 * SGMLparser.h : inf=terface for an SGML 4.0 non-verifying parser
 *
 * See Copyright for the status of this software.
 *
 * Daniel.Veillard@w3.org
 */

#ifndef __SGML_PARSER_H__
#define __SGML_PARSER_H__
#include <libxml/parser.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Most of the back-end structures from XML and SGML are shared
 */
typedef xmlParserCtxt sgmlParserCtxt;
typedef xmlParserCtxtPtr sgmlParserCtxtPtr;
typedef xmlParserNodeInfo sgmlParserNodeInfo;
typedef xmlSAXHandler sgmlSAXHandler;
typedef xmlSAXHandlerPtr sgmlSAXHandlerPtr;
typedef xmlParserInput sgmlParserInput;
typedef xmlParserInputPtr sgmlParserInputPtr;
typedef xmlDocPtr sgmlDocPtr;
typedef xmlNodePtr sgmlNodePtr;

/*
 * Internal description of an SGML element
 */
typedef struct _sgmlElemDesc sgmlElemDesc;
typedef sgmlElemDesc *sgmlElemDescPtr;
struct _sgmlElemDesc {
    const char *name;	/* The tag name */
    int startTag;       /* Whether the start tag can be implied */
    int endTag;         /* Whether the end tag can be implied */
    int empty;          /* Is this an empty element ? */
    int depr;           /* Is this a deprecated element ? */
    int dtd;            /* 1: only in Loose DTD, 2: only Frameset one */
    const char *desc;   /* the description */
};

/*
 * Internal description of an SGML entity
 */
typedef struct _sgmlEntityDesc sgmlEntityDesc;
typedef sgmlEntityDesc *sgmlEntityDescPtr;
struct _sgmlEntityDesc {
    int value;		/* the UNICODE value for the character */
    const char *name;	/* The entity name */
    const char *desc;   /* the description */
};

/*
 * There is only few public functions.
 */
sgmlElemDescPtr		sgmlTagLookup	(const xmlChar *tag);
sgmlEntityDescPtr	sgmlEntityLookup(const xmlChar *name);
sgmlEntityDescPtr	sgmlEntityValueLookup(int value);

int			sgmlIsAutoClosed(sgmlDocPtr doc,
					 sgmlNodePtr elem);
int			sgmlAutoCloseTag(sgmlDocPtr doc,
					 const xmlChar *name,
					 sgmlNodePtr elem);
sgmlEntityDescPtr	sgmlParseEntityRef(sgmlParserCtxtPtr ctxt,
					 xmlChar **str);
int			sgmlParseCharRef(sgmlParserCtxtPtr ctxt);
void			sgmlParseElement(sgmlParserCtxtPtr ctxt);

sgmlDocPtr		sgmlSAXParseDoc	(xmlChar *cur,
					 const char *encoding,
					 sgmlSAXHandlerPtr sax,
					 void *userData);
sgmlDocPtr		sgmlParseDoc	(xmlChar *cur,
					 const char *encoding);
sgmlDocPtr		sgmlSAXParseFile(const char *filename,
					 const char *encoding,
					 sgmlSAXHandlerPtr sax,
					 void *userData);
sgmlDocPtr		sgmlParseFile	(const char *filename,
					 const char *encoding);
int			UTF8ToSgml	(unsigned char* out,
					 int *outlen,
					 const unsigned char* in,
					 int *inlen);
int			sgmlEncodeEntities(unsigned char* out,
					 int *outlen,
					 const unsigned char* in,
					 int *inlen, int quoteChar);

/**
 * Interfaces for the Push mode
 */
void			sgmlFreeParserCtxt	(sgmlParserCtxtPtr ctxt);
sgmlParserCtxtPtr	sgmlCreatePushParserCtxt(sgmlSAXHandlerPtr sax,
						 void *user_data,
						 const char *chunk,
						 int size,
						 const char *filename,
						 xmlCharEncoding enc);
int			sgmlParseChunk		(sgmlParserCtxtPtr ctxt,
						 const char *chunk,
						 int size,
						 int terminate);
#ifdef __cplusplus
}
#endif

#endif /* __SGML_PARSER_H__ */

Webmaster