summaryrefslogtreecommitdiff
path: root/source/html
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-11-11 16:05:30 +0000
committerRobin Watts <robin.watts@artifex.com>2016-11-14 16:09:39 +0000
commit37f95f87bdfb2e0b01d649afae5fffe60bf99d3a (patch)
treeda3491c62d6af86c1a5bc4e523e8f9ebe19793d1 /source/html
parentc0e1dfdab1a13def046e94d771f8a821ba2a10d9 (diff)
downloadmupdf-37f95f87bdfb2e0b01d649afae5fffe60bf99d3a.tar.xz
Make fz_buffer structure private to fitz.
Move the definition of the structure contents into new fitz-imp.h file. Make all code outside of fitz access the buffer through the defined API. Add a convenience API for people that want to get buffers as null terminated C strings.
Diffstat (limited to 'source/html')
-rw-r--r--source/html/epub-doc.c13
-rw-r--r--source/html/html-layout.c7
2 files changed, 14 insertions, 6 deletions
diff --git a/source/html/epub-doc.c b/source/html/epub-doc.c
index f5f3ca67..6c776bfa 100644
--- a/source/html/epub-doc.c
+++ b/source/html/epub-doc.c
@@ -334,12 +334,15 @@ epub_parse_ncx(fz_context *ctx, epub_document *doc, const char *path)
fz_buffer *buf;
fz_xml *ncx;
char base_uri[2048];
+ unsigned char *data;
+ size_t len;
fz_dirname(base_uri, path, sizeof base_uri);
buf = fz_read_archive_entry(ctx, zip, path);
fz_write_buffer_byte(ctx, buf, 0);
- ncx = fz_parse_xml(ctx, buf->data, buf->len, 0);
+ len = fz_buffer_storage(ctx, buf, &data);
+ ncx = fz_parse_xml(ctx, data, len, 0);
fz_drop_buffer(ctx, buf);
doc->outline = epub_parse_ncx_imp(ctx, doc, fz_xml_find_down(ncx, "navMap"), base_uri);
@@ -369,6 +372,8 @@ epub_parse_header(fz_context *ctx, epub_document *doc)
const char *version;
char ncx[2048], s[2048];
epub_chapter **tailp;
+ size_t len;
+ unsigned char *data;
if (fz_has_archive_entry(ctx, zip, "META-INF/rights.xml"))
fz_throw(ctx, FZ_ERROR_GENERIC, "EPUB is locked by DRM");
@@ -379,7 +384,8 @@ epub_parse_header(fz_context *ctx, epub_document *doc)
buf = fz_read_archive_entry(ctx, zip, "META-INF/container.xml");
fz_write_buffer_byte(ctx, buf, 0);
- container_xml = fz_parse_xml(ctx, buf->data, buf->len, 0);
+ len = fz_buffer_storage(ctx, buf, &data);
+ container_xml = fz_parse_xml(ctx, data, len, 0);
fz_drop_buffer(ctx, buf);
container = fz_xml_find(container_xml, "container");
@@ -395,7 +401,8 @@ epub_parse_header(fz_context *ctx, epub_document *doc)
buf = fz_read_archive_entry(ctx, zip, full_path);
fz_write_buffer_byte(ctx, buf, 0);
- content_opf = fz_parse_xml(ctx, buf->data, buf->len, 0);
+ len = fz_buffer_storage(ctx, buf, &data);
+ content_opf = fz_parse_xml(ctx, data, len, 0);
fz_drop_buffer(ctx, buf);
package = fz_xml_find(content_opf, "package");
diff --git a/source/html/html-layout.c b/source/html/html-layout.c
index 8b7a08db..945149f4 100644
--- a/source/html/html-layout.c
+++ b/source/html/html-layout.c
@@ -2117,8 +2117,7 @@ html_load_css(fz_context *ctx, fz_archive *zip, const char *base_uri, fz_css *cs
fz_try(ctx)
{
buf = fz_read_archive_entry(ctx, zip, path);
- fz_write_buffer_byte(ctx, buf, 0);
- fz_parse_css(ctx, css, (char*)buf->data, path);
+ fz_parse_css(ctx, css, fz_string_from_buffer(ctx, buf), path);
}
fz_always(ctx)
fz_drop_buffer(ctx, buf);
@@ -2500,6 +2499,8 @@ fz_parse_html(fz_context *ctx, fz_html_font_set *set, fz_archive *zip, const cha
{
fz_xml *xml;
fz_html *html;
+ unsigned char *data;
+ size_t len = fz_buffer_storage(ctx, buf, &data);
fz_css_match match;
struct genstate g;
@@ -2512,7 +2513,7 @@ fz_parse_html(fz_context *ctx, fz_html_font_set *set, fz_archive *zip, const cha
g.emit_white = 0;
g.last_brk_cls = UCDN_LINEBREAK_CLASS_OP;
- xml = fz_parse_xml(ctx, buf->data, buf->len, 1);
+ xml = fz_parse_xml(ctx, data, len, 1);
g.css = fz_new_css(ctx);
fz_try(ctx)