libmobi
C library for handling MOBI format ebook documents
xmlwriter.h
Go to the documentation of this file.
1 
11 #ifndef mobi_minixml_h
12 #define mobi_minixml_h
13 
14 #include <stdio.h>
15 #include "buffer.h"
16 #include "structure.h"
17 
18 #define BAD_CAST (xmlChar *)
19 #define LIBXML_TEST_VERSION
20 
21 #define xmlCleanupParser()
22 
23 typedef unsigned char xmlChar;
24 
29 typedef struct {
30  xmlChar *content;
32 } xmlBuffer;
33 typedef xmlBuffer *xmlBufferPtr;
34 
38 typedef enum {
39  MOBI_XMLMODE_NONE = 0,
40  MOBI_XMLMODE_NAME,
41  MOBI_XMLMODE_ATTR,
42  MOBI_XMLMODE_TEXT
44 
50 typedef struct MOBIXmlState {
51  char *name;
53  struct MOBIXmlState *next;
55 
59 typedef struct {
62  char *nsname;
63  char *nsvalue;
65  bool indent_next;
68 
70 void xmlBufferFree(xmlBufferPtr buf);
73 int xmlTextWriterStartDocument(xmlTextWriterPtr writer, const char *version,
74  const char *encoding, const char *standalone);
76 int xmlTextWriterStartElement(xmlTextWriterPtr writer, const xmlChar *name);
78 int xmlTextWriterWriteAttribute(xmlTextWriterPtr writer, const xmlChar *name,
79  const xmlChar *content);
82  const xmlChar * prefix, const xmlChar * name,
83  const xmlChar * namespaceURI,
84  const xmlChar * content);
86  const xmlChar *prefix, const xmlChar *name,
87  const xmlChar * namespaceURI);
88 int xmlTextWriterWriteElementNS(xmlTextWriterPtr writer, const xmlChar *prefix,
89  const xmlChar *name, const xmlChar *namespaceURI,
90  const xmlChar *content);
91 int xmlTextWriterWriteString(xmlTextWriterPtr writer, const xmlChar *content);
92 int xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent);
93 
94 #endif
Buffer to read to/write from.
Definition: buffer.h:20
Xml writer states list structure First element in the list is currently processed element....
Definition: xmlwriter.h:50
MOBI_XML_MODE mode
Definition: xmlwriter.h:52
char * name
Definition: xmlwriter.h:51
struct MOBIXmlState * next
Definition: xmlwriter.h:53
Buffer for xml output. For libxml2 compatibility, it is a wrapper for MOBIBuffer.
Definition: xmlwriter.h:29
MOBIBuffer * mobibuffer
Definition: xmlwriter.h:31
xmlChar * content
Definition: xmlwriter.h:30
Xml TextWriter structure.
Definition: xmlwriter.h:59
MOBIXmlState * states
Definition: xmlwriter.h:61
char * nsname
Definition: xmlwriter.h:62
char * nsvalue
Definition: xmlwriter.h:63
xmlBufferPtr xmlbuf
Definition: xmlwriter.h:60
bool indent_next
Definition: xmlwriter.h:65
bool indent_enable
Definition: xmlwriter.h:64
struct MOBIXmlState MOBIXmlState
Xml writer states list structure First element in the list is currently processed element....
xmlBufferPtr xmlBufferCreate(void)
Create xml buffer.
Definition: xmlwriter.c:365
int xmlTextWriterEndElement(xmlTextWriterPtr writer)
End current element.
Definition: xmlwriter.c:567
MOBI_XML_MODE
Xml writer states.
Definition: xmlwriter.h:38
int xmlTextWriterStartElement(xmlTextWriterPtr writer, const xmlChar *name)
Start xml element.
Definition: xmlwriter.c:520
int xmlTextWriterStartDocument(xmlTextWriterPtr writer, const char *version, const char *encoding, const char *standalone)
Start xml document.
Definition: xmlwriter.c:451
int xmlTextWriterWriteElementNS(xmlTextWriterPtr writer, const xmlChar *prefix, const xmlChar *name, const xmlChar *namespaceURI, const xmlChar *content)
Write element with namespace support.
Definition: xmlwriter.c:847
int xmlTextWriterWriteAttribute(xmlTextWriterPtr writer, const xmlChar *name, const xmlChar *content)
Write attribute with given name and content.
Definition: xmlwriter.c:692
int xmlTextWriterWriteAttributeNS(xmlTextWriterPtr writer, const xmlChar *prefix, const xmlChar *name, const xmlChar *namespaceURI, const xmlChar *content)
Write attribute with namespace support.
Definition: xmlwriter.c:771
void xmlBufferFree(xmlBufferPtr buf)
Free XML buffer.
Definition: xmlwriter.c:388
int xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent)
Set indentation option.
Definition: xmlwriter.c:910
void xmlFreeTextWriter(xmlTextWriterPtr writer)
Deallocate TextWriter instance and all its resources.
Definition: xmlwriter.c:429
int xmlTextWriterEndDocument(xmlTextWriterPtr writer)
End xml document.
Definition: xmlwriter.c:485
int xmlTextWriterEndAttribute(xmlTextWriterPtr writer)
End current attribute.
Definition: xmlwriter.c:662
xmlTextWriterPtr xmlNewTextWriterMemory(xmlBufferPtr xmlbuf, int compression)
Initialize TextWriter structure.
Definition: xmlwriter.c:403
int xmlTextWriterWriteString(xmlTextWriterPtr writer, const xmlChar *content)
Write xml string.
Definition: xmlwriter.c:863
int xmlTextWriterStartElementNS(xmlTextWriterPtr writer, const xmlChar *prefix, const xmlChar *name, const xmlChar *namespaceURI)
Start element with namespace support.
Definition: xmlwriter.c:791