diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2012-11-24 15:42:10 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-11-26 12:49:50 +0000 |
commit | a980d3d030b6cad801110a36ff9b09d5ec38b7d1 (patch) | |
tree | aba7c816b3717d4bfea541618b7d9d1d48c86be4 | |
parent | 11032ab74abc9f74161a7c2d138e894c7a7854da (diff) | |
download | mupdf-a980d3d030b6cad801110a36ff9b09d5ec38b7d1.tar.xz |
Move XML parser into fitz directory.
-rw-r--r-- | fitz/base_xml.c (renamed from xps/xps_xml.c) | 6 | ||||
-rw-r--r-- | fitz/fitz.h | 53 | ||||
-rw-r--r-- | win32/libmupdf.vcproj | 8 | ||||
-rw-r--r-- | xps/muxps.h | 16 |
4 files changed, 60 insertions, 23 deletions
diff --git a/xps/xps_xml.c b/fitz/base_xml.c index 739c00ec..ac63659a 100644 --- a/xps/xps_xml.c +++ b/fitz/base_xml.c @@ -1,4 +1,4 @@ -#include "muxps.h" +#include "fitz.h" struct parser { @@ -26,7 +26,7 @@ static inline void indent(int n) while (n--) putchar(' '); } -void fz_print_xml(fz_xml *item, int level) +void fz_debug_xml(fz_xml *item, int level) { while (item) { if (item->text) { @@ -39,7 +39,7 @@ void fz_print_xml(fz_xml *item, int level) printf(" %s=\"%s\"", att->name, att->value); if (item->down) { printf(">\n"); - fz_print_xml(item->down, level + 1); + fz_debug_xml(item->down, level + 1); indent(level); printf("</%s>\n", item->name); } diff --git a/fitz/fitz.h b/fitz/fitz.h index 77e690e7..0ea3cb2c 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -656,6 +656,59 @@ extern int fz_optind; extern char *fz_optarg; /* + XML document model +*/ + +typedef struct fz_xml_s fz_xml; + +/* + fz_parse_xml: Parse a zero-terminated string into a tree of xml nodes. +*/ +fz_xml *fz_parse_xml(fz_context *ctx, unsigned char *buf, int len); + +/* + fz_xml_next: Return next sibling of XML node. +*/ +fz_xml *fz_xml_next(fz_xml *item); + +/* + fz_xml_down: Return first child of XML node. +*/ +fz_xml *fz_xml_down(fz_xml *item); + +/* + fz_xml_tag: Return tag of XML node. Return the empty string for text nodes. +*/ +char *fz_xml_tag(fz_xml *item); + +/* + fz_xml_att: Return the value of an attribute of an XML node. + NULL if the attribute doesn't exist. +*/ +char *fz_xml_att(fz_xml *item, const char *att); + +/* + fz_xml_text: Return the text content of an XML node. + NULL if the node is a tag. +*/ +char *fz_xml_text(fz_xml *item); + +/* + fz_free_xml: Free the XML node and all its children and siblings. +*/ +void fz_free_xml(fz_context *doc, fz_xml *item); + +/* + fz_detach_xml: Detach a node from the tree, unlinking it from its parent. +*/ +void fz_detach_xml(fz_xml *node); + +/* + fz_debug_xml: Pretty-print an XML tree to stdout. +*/ +void fz_debug_xml(fz_xml *item, int level); + +/* fz_point is a point in a two-dimensional space. */ typedef struct fz_point_s fz_point; diff --git a/win32/libmupdf.vcproj b/win32/libmupdf.vcproj index e563fc80..1195ccee 100644 --- a/win32/libmupdf.vcproj +++ b/win32/libmupdf.vcproj @@ -402,6 +402,10 @@ > </File> <File + RelativePath="..\fitz\base_xml.c" + > + </File> + <File RelativePath="..\fitz\crypt_aes.c" > </File> @@ -670,10 +674,6 @@ > </File> <File - RelativePath="..\xps\xps_xml.c" - > - </File> - <File RelativePath="..\xps\xps_zip.c" > </File> diff --git a/xps/muxps.h b/xps/muxps.h index c784a01a..007f4452 100644 --- a/xps/muxps.h +++ b/xps/muxps.h @@ -7,22 +7,6 @@ typedef struct xps_document_s xps_document; typedef struct xps_page_s xps_page; /* - * XML document model - */ - -typedef struct fz_xml_s fz_xml; - -fz_xml *fz_parse_xml(fz_context *doc, unsigned char *buf, int len); -fz_xml *fz_xml_next(fz_xml *item); -fz_xml *fz_xml_down(fz_xml *item); -char *fz_xml_tag(fz_xml *item); -char *fz_xml_att(fz_xml *item, const char *att); -char *fz_xml_text(fz_xml *item); -void fz_free_xml(fz_context *doc, fz_xml *item); -void fz_print_xml(fz_xml *item, int level); -void fz_detach_xml(fz_xml *node); - -/* xps_open_document: Open a document. Open a document for reading so the library is able to locate |