summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/mupdfclean.c314
-rw-r--r--apps/mupdfextract.c46
-rw-r--r--apps/mupdfinfo.c412
-rw-r--r--apps/mupdfshow.c24
-rw-r--r--fitz/base_context.c8
-rw-r--r--fitz/fitz.h88
-rw-r--r--fitz/res_font.c2
-rw-r--r--fitz/res_store.c12
-rw-r--r--pdf/base_object.c (renamed from fitz/base_object.c)585
-rw-r--r--pdf/mupdf.h179
-rw-r--r--pdf/pdf_annot.c184
-rw-r--r--pdf/pdf_cmap_load.c30
-rw-r--r--pdf/pdf_colorspace.c116
-rw-r--r--pdf/pdf_crypt.c182
-rw-r--r--pdf/pdf_font.c250
-rw-r--r--pdf/pdf_function.c138
-rw-r--r--pdf/pdf_image.c87
-rw-r--r--pdf/pdf_interpret.c314
-rw-r--r--pdf/pdf_nametree.c114
-rw-r--r--pdf/pdf_outline.c36
-rw-r--r--pdf/pdf_page.c194
-rw-r--r--pdf/pdf_parse.c196
-rw-r--r--pdf/pdf_pattern.c24
-rw-r--r--pdf/pdf_repair.c134
-rw-r--r--pdf/pdf_shade.c184
-rw-r--r--pdf/pdf_store.c35
-rw-r--r--pdf/pdf_stream.c162
-rw-r--r--pdf/pdf_type3.c88
-rw-r--r--pdf/pdf_unicode.c6
-rw-r--r--pdf/pdf_xobject.c36
-rw-r--r--pdf/pdf_xref.c217
-rw-r--r--scripts/rename2.sed75
32 files changed, 2283 insertions, 2189 deletions
diff --git a/apps/mupdfclean.c b/apps/mupdfclean.c
index 3130e3f0..f47ea2b5 100644
--- a/apps/mupdfclean.c
+++ b/apps/mupdfclean.c
@@ -53,34 +53,34 @@ static void usage(void)
* Garbage collect objects not reachable from the trailer.
*/
-static void sweepref(fz_obj *ref);
+static void sweepref(pdf_obj *ref);
-static void sweepobj(fz_obj *obj)
+static void sweepobj(pdf_obj *obj)
{
int i;
- if (fz_is_indirect(obj))
+ if (pdf_is_indirect(obj))
sweepref(obj);
- else if (fz_is_dict(obj))
+ else if (pdf_is_dict(obj))
{
- int n = fz_dict_len(obj);
+ int n = pdf_dict_len(obj);
for (i = 0; i < n; i++)
- sweepobj(fz_dict_get_val(obj, i));
+ sweepobj(pdf_dict_get_val(obj, i));
}
- else if (fz_is_array(obj))
+ else if (pdf_is_array(obj))
{
- int n = fz_array_len(obj);
+ int n = pdf_array_len(obj);
for (i = 0; i < n; i++)
- sweepobj(fz_array_get(obj, i));
+ sweepobj(pdf_array_get(obj, i));
}
}
-static void sweepref(fz_obj *obj)
+static void sweepref(pdf_obj *obj)
{
- int num = fz_to_num(obj);
- int gen = fz_to_gen(obj);
+ int num = pdf_to_num(obj);
+ int gen = pdf_to_gen(obj);
if (num < 0 || num >= xref->len)
return;
@@ -94,12 +94,12 @@ static void sweepref(fz_obj *obj)
{
if (pdf_is_stream(xref, num, gen))
{
- fz_obj *len = fz_dict_gets(obj, "Length");
- if (fz_is_indirect(len))
+ pdf_obj *len = pdf_dict_gets(obj, "Length");
+ if (pdf_is_indirect(len))
{
- uselist[fz_to_num(len)] = 0;
- len = fz_resolve_indirect(len);
- fz_dict_puts(obj, "Length", len);
+ uselist[pdf_to_num(len)] = 0;
+ len = pdf_resolve_indirect(len);
+ pdf_dict_puts(obj, "Length", len);
}
}
}
@@ -108,7 +108,7 @@ static void sweepref(fz_obj *obj)
/* Leave broken */
}
- sweepobj(fz_resolve_indirect(obj));
+ sweepobj(pdf_resolve_indirect(obj));
}
/*
@@ -124,7 +124,7 @@ static void removeduplicateobjs(void)
/* Only compare an object to objects preceding it */
for (other = 1; other < num; other++)
{
- fz_obj *a, *b;
+ pdf_obj *a, *b;
if (num == other || !uselist[num] || !uselist[other])
continue;
@@ -148,10 +148,10 @@ static void removeduplicateobjs(void)
a = xref->table[num].obj;
b = xref->table[other].obj;
- a = fz_resolve_indirect(a);
- b = fz_resolve_indirect(b);
+ a = pdf_resolve_indirect(a);
+ b = pdf_resolve_indirect(b);
- if (fz_objcmp(a, b))
+ if (pdf_objcmp(a, b))
continue;
/* Keep the lowest numbered object */
@@ -195,23 +195,23 @@ static void compactxref(void)
* removing duplicate objects and compacting the xref.
*/
-static void renumberobj(fz_obj *obj)
+static void renumberobj(pdf_obj *obj)
{
int i;
fz_context *ctx = xref->ctx;
- if (fz_is_dict(obj))
+ if (pdf_is_dict(obj))
{
- int n = fz_dict_len(obj);
+ int n = pdf_dict_len(obj);
for (i = 0; i < n; i++)
{
- fz_obj *key = fz_dict_get_key(obj, i);
- fz_obj *val = fz_dict_get_val(obj, i);
- if (fz_is_indirect(val))
+ pdf_obj *key = pdf_dict_get_key(obj, i);
+ pdf_obj *val = pdf_dict_get_val(obj, i);
+ if (pdf_is_indirect(val))
{
- val = fz_new_indirect(ctx, renumbermap[fz_to_num(val)], 0, xref);
+ val = pdf_new_indirect(ctx, renumbermap[pdf_to_num(val)], 0, xref);
fz_dict_put(obj, key, val);
- fz_drop_obj(val);
+ pdf_drop_obj(val);
}
else
{
@@ -220,17 +220,17 @@ static void renumberobj(fz_obj *obj)
}
}
- else if (fz_is_array(obj))
+ else if (pdf_is_array(obj))
{
- int n = fz_array_len(obj);
+ int n = pdf_array_len(obj);
for (i = 0; i < n; i++)
{
- fz_obj *val = fz_array_get(obj, i);
- if (fz_is_indirect(val))
+ pdf_obj *val = pdf_array_get(obj, i);
+ if (pdf_is_indirect(val))
{
- val = fz_new_indirect(ctx, renumbermap[fz_to_num(val)], 0, xref);
- fz_array_put(obj, i, val);
- fz_drop_obj(val);
+ val = pdf_new_indirect(ctx, renumbermap[pdf_to_num(val)], 0, xref);
+ pdf_array_put(obj, i, val);
+ pdf_drop_obj(val);
}
else
{
@@ -250,13 +250,13 @@ static void renumberobjs(void)
renumberobj(xref->trailer);
for (num = 0; num < xref->len; num++)
{
- fz_obj *obj = xref->table[num].obj;
+ pdf_obj *obj = xref->table[num].obj;
- if (fz_is_indirect(obj))
+ if (pdf_is_indirect(obj))
{
- obj = fz_new_indirect(ctx, renumbermap[fz_to_num(obj)], 0, xref);
+ obj = pdf_new_indirect(ctx, renumbermap[pdf_to_num(obj)], 0, xref);
pdf_update_object(xref, num, 0, obj);
- fz_drop_obj(obj);
+ pdf_drop_obj(obj);
}
else
{
@@ -282,7 +282,7 @@ static void renumberobjs(void)
else
{
if (oldxref[num].obj)
- fz_drop_obj(oldxref[num].obj);
+ pdf_drop_obj(oldxref[num].obj);
}
}
@@ -302,25 +302,25 @@ static void renumberobjs(void)
static void retainpages(int argc, char **argv)
{
- fz_obj *oldroot, *root, *pages, *kids, *countobj, *parent, *olddests;
+ pdf_obj *oldroot, *root, *pages, *kids, *countobj, *parent, *olddests;
/* Keep only pages/type and (reduced) dest entries to avoid
* references to unretained pages */
- oldroot = fz_dict_gets(xref->trailer, "Root");
- pages = fz_dict_gets(oldroot, "Pages");
+ oldroot = pdf_dict_gets(xref->trailer, "Root");
+ pages = pdf_dict_gets(oldroot, "Pages");
olddests = pdf_load_name_tree(xref, "Dests");
- root = fz_new_dict(ctx, 2);
- fz_dict_puts(root, "Type", fz_dict_gets(oldroot, "Type"));
- fz_dict_puts(root, "Pages", fz_dict_gets(oldroot, "Pages"));
+ root = pdf_new_dict(ctx, 2);
+ pdf_dict_puts(root, "Type", pdf_dict_gets(oldroot, "Type"));
+ pdf_dict_puts(root, "Pages", pdf_dict_gets(oldroot, "Pages"));
- pdf_update_object(xref, fz_to_num(oldroot), fz_to_gen(oldroot), root);
+ pdf_update_object(xref, pdf_to_num(oldroot), pdf_to_gen(oldroot), root);
- fz_drop_obj(root);
+ pdf_drop_obj(root);
/* Create a new kids array with only the pages we want to keep */
- parent = fz_new_indirect(ctx, fz_to_num(pages), fz_to_gen(pages), xref);
- kids = fz_new_array(ctx, 1);
+ parent = pdf_new_indirect(ctx, pdf_to_num(pages), pdf_to_gen(pages), xref);
+ kids = pdf_new_array(ctx, 1);
/* Retain pages specified */
while (argc - fz_optind)
@@ -357,13 +357,13 @@ static void retainpages(int argc, char **argv)
for (page = spage; page <= epage; page++)
{
- fz_obj *pageobj = xref->page_objs[page-1];
- fz_obj *pageref = xref->page_refs[page-1];
+ pdf_obj *pageobj = xref->page_objs[page-1];
+ pdf_obj *pageref = xref->page_refs[page-1];
- fz_dict_puts(pageobj, "Parent", parent);
+ pdf_dict_puts(pageobj, "Parent", parent);
/* Store page object in new kids array */
- fz_array_push(kids, pageref);
+ pdf_array_push(kids, pageref);
}
spec = fz_strsep(&pagelist, ",");
@@ -372,48 +372,48 @@ static void retainpages(int argc, char **argv)
fz_optind++;
}
- fz_drop_obj(parent);
+ pdf_drop_obj(parent);
/* Update page count and kids array */
- countobj = fz_new_int(ctx, fz_array_len(kids));
- fz_dict_puts(pages, "Count", countobj);
- fz_drop_obj(countobj);
- fz_dict_puts(pages, "Kids", kids);
- fz_drop_obj(kids);
+ countobj = pdf_new_int(ctx, pdf_array_len(kids));
+ pdf_dict_puts(pages, "Count", countobj);
+ pdf_drop_obj(countobj);
+ pdf_dict_puts(pages, "Kids", kids);
+ pdf_drop_obj(kids);
/* Also preserve the (partial) Dests name tree */
if (olddests)
{
int i;
- fz_obj *names = fz_new_dict(ctx, 1);
- fz_obj *dests = fz_new_dict(ctx, 1);
- fz_obj *names_list = fz_new_array(ctx, 32);
+ pdf_obj *names = pdf_new_dict(ctx, 1);
+ pdf_obj *dests = pdf_new_dict(ctx, 1);
+ pdf_obj *names_list = pdf_new_array(ctx, 32);
- for (i = 0; i < fz_dict_len(olddests); i++)
+ for (i = 0; i < pdf_dict_len(olddests); i++)
{
- fz_obj *key = fz_dict_get_key(olddests, i);
- fz_obj *val = fz_dict_get_val(olddests, i);
- fz_obj *key_str = fz_new_string(ctx, fz_to_name(key), strlen(fz_to_name(key)));
- fz_obj *dest = fz_dict_gets(val, "D");
+ pdf_obj *key = pdf_dict_get_key(olddests, i);
+ pdf_obj *val = pdf_dict_get_val(olddests, i);
+ pdf_obj *key_str = pdf_new_string(ctx, pdf_to_name(key), strlen(pdf_to_name(key)));
+ pdf_obj *dest = pdf_dict_gets(val, "D");
- dest = fz_array_get(dest ? dest : val, 0);
- if (fz_array_contains(fz_dict_gets(pages, "Kids"), dest))
+ dest = pdf_array_get(dest ? dest : val, 0);
+ if (pdf_array_contains(pdf_dict_gets(pages, "Kids"), dest))
{
- fz_array_push(names_list, key_str);
- fz_array_push(names_list, val);
+ pdf_array_push(names_list, key_str);
+ pdf_array_push(names_list, val);
}
- fz_drop_obj(key_str);
+ pdf_drop_obj(key_str);
}
- root = fz_dict_gets(xref->trailer, "Root");
- fz_dict_puts(dests, "Names", names_list);
- fz_dict_puts(names, "Dests", dests);
- fz_dict_puts(root, "Names", names);
+ root = pdf_dict_gets(xref->trailer, "Root");
+ pdf_dict_puts(dests, "Names", names_list);
+ pdf_dict_puts(names, "Dests", dests);
+ pdf_dict_puts(root, "Names", names);
- fz_drop_obj(names);
- fz_drop_obj(dests);
- fz_drop_obj(names_list);
- fz_drop_obj(olddests);
+ pdf_drop_obj(names);
+ pdf_drop_obj(dests);
+ pdf_drop_obj(names_list);
+ pdf_drop_obj(olddests);
}
}
@@ -423,7 +423,7 @@ static void retainpages(int argc, char **argv)
static void preloadobjstms(void)
{
- fz_obj *obj;
+ pdf_obj *obj;
int num;
for (num = 0; num < xref->len; num++)
@@ -431,7 +431,7 @@ static void preloadobjstms(void)
if (xref->table[num].type == 'o')
{
obj = pdf_load_object(xref, num, 0);
- fz_drop_obj(obj);
+ pdf_drop_obj(obj);
}
}
}
@@ -482,57 +482,57 @@ static fz_buffer *hexbuf(unsigned char *p, int n)
return buf;
}
-static void addhexfilter(fz_obj *dict)
+static void addhexfilter(pdf_obj *dict)
{
- fz_obj *f, *dp, *newf, *newdp;
- fz_obj *ahx, *nullobj;
+ pdf_obj *f, *dp, *newf, *newdp;
+ pdf_obj *ahx, *nullobj;
ahx = fz_new_name(ctx, "ASCIIHexDecode");
- nullobj = fz_new_null(ctx);
+ nullobj = pdf_new_null(ctx);
newf = newdp = NULL;
- f = fz_dict_gets(dict, "Filter");
- dp = fz_dict_gets(dict, "DecodeParms");
+ f = pdf_dict_gets(dict, "Filter");
+ dp = pdf_dict_gets(dict, "DecodeParms");
- if (fz_is_name(f))
+ if (pdf_is_name(f))
{
- newf = fz_new_array(ctx, 2);
- fz_array_push(newf, ahx);
- fz_array_push(newf, f);
+ newf = pdf_new_array(ctx, 2);
+ pdf_array_push(newf, ahx);
+ pdf_array_push(newf, f);
f = newf;
- if (fz_is_dict(dp))
+ if (pdf_is_dict(dp))
{
- newdp = fz_new_array(ctx, 2);
- fz_array_push(newdp, nullobj);
- fz_array_push(newdp, dp);
+ newdp = pdf_new_array(ctx, 2);
+ pdf_array_push(newdp, nullobj);
+ pdf_array_push(newdp, dp);
dp = newdp;
}
}
- else if (fz_is_array(f))
+ else if (pdf_is_array(f))
{
- fz_array_insert(f, ahx);
- if (fz_is_array(dp))
- fz_array_insert(dp, nullobj);
+ pdf_array_insert(f, ahx);
+ if (pdf_is_array(dp))
+ pdf_array_insert(dp, nullobj);
}
else
f = ahx;
- fz_dict_puts(dict, "Filter", f);
+ pdf_dict_puts(dict, "Filter", f);
if (dp)
- fz_dict_puts(dict, "DecodeParms", dp);
+ pdf_dict_puts(dict, "DecodeParms", dp);
- fz_drop_obj(ahx);
- fz_drop_obj(nullobj);
+ pdf_drop_obj(ahx);
+ pdf_drop_obj(nullobj);
if (newf)
- fz_drop_obj(newf);
+ pdf_drop_obj(newf);
if (newdp)
- fz_drop_obj(newdp);
+ pdf_drop_obj(newdp);
}
-static void copystream(fz_obj *obj, int num, int gen)
+static void copystream(pdf_obj *obj, int num, int gen)
{
fz_buffer *buf, *tmp;
- fz_obj *newlen;
+ pdf_obj *newlen;
buf = pdf_load_raw_stream(xref, num, gen);
@@ -544,13 +544,13 @@ static void copystream(fz_obj *obj, int num, int gen)
addhexfilter(obj);
- newlen = fz_new_int(ctx, buf->len);
- fz_dict_puts(obj, "Length", newlen);
- fz_drop_obj(newlen);
+ newlen = pdf_new_int(ctx, buf->len);
+ pdf_dict_puts(obj, "Length", newlen);
+ pdf_drop_obj(newlen);
}
fprintf(out, "%d %d obj\n", num, gen);
- fz_fprint_obj(out, obj, doexpand == 0);
+ pdf_fprint_obj(out, obj, doexpand == 0);
fprintf(out, "stream\n");
fwrite(buf->data, 1, buf->len, out);
fprintf(out, "endstream\nendobj\n\n");
@@ -558,15 +558,15 @@ static void copystream(fz_obj *obj, int num, int gen)
fz_drop_buffer(ctx, buf);
}
-static void expandstream(fz_obj *obj, int num, int gen)
+static void expandstream(pdf_obj *obj, int num, int gen)
{
fz_buffer *buf, *tmp;
- fz_obj *newlen;
+ pdf_obj *newlen;
buf = pdf_load_stream(xref, num, gen);
- fz_dict_dels(obj, "Filter");
- fz_dict_dels(obj, "DecodeParms");
+ pdf_dict_dels(obj, "Filter");
+ pdf_dict_dels(obj, "DecodeParms");
if (doascii && isbinarystream(buf))
{
@@ -577,12 +577,12 @@ static void expandstream(fz_obj *obj, int num, int gen)
addhexfilter(obj);
}
- newlen = fz_new_int(ctx, buf->len);
- fz_dict_puts(obj, "Length", newlen);
- fz_drop_obj(newlen);
+ newlen = pdf_new_int(ctx, buf->len);
+ pdf_dict_puts(obj, "Length", newlen);
+ pdf_drop_obj(newlen);
fprintf(out, "%d %d obj\n", num, gen);
- fz_fprint_obj(out, obj, doexpand == 0);
+ pdf_fprint_obj(out, obj, doexpand == 0);
fprintf(out, "stream\n");
fwrite(buf->data, 1, buf->len, out);
fprintf(out, "endstream\nendobj\n\n");
@@ -592,25 +592,25 @@ static void expandstream(fz_obj *obj, int num, int gen)
static void writeobject(int num, int gen)
{
- fz_obj *obj;
- fz_obj *type;
+ pdf_obj *obj;
+ pdf_obj *type;
obj = pdf_load_object(xref, num, gen);
/* skip ObjStm and XRef objects */
- if (fz_is_dict(obj))
+ if (pdf_is_dict(obj))
{
- type = fz_dict_gets(obj, "Type");
- if (fz_is_name(type) && !strcmp(fz_to_name(type), "ObjStm"))
+ type = pdf_dict_gets(obj, "Type");
+ if (pdf_is_name(type) && !strcmp(pdf_to_name(type), "ObjStm"))
{
uselist[num] = 0;
- fz_drop_obj(obj);
+ pdf_drop_obj(obj);
return;
}
- if (fz_is_name(type) && !strcmp(fz_to_name(type), "XRef"))
+ if (pdf_is_name(type) && !strcmp(pdf_to_name(type), "XRef"))
{
uselist[num] = 0;
- fz_drop_obj(obj);
+ pdf_drop_obj(obj);
return;
}
}
@@ -618,7 +618,7 @@ static void writeobject(int num, int gen)
if (!pdf_is_stream(xref, num, gen))
{
fprintf(out, "%d %d obj\n", num, gen);
- fz_fprint_obj(out, obj, doexpand == 0);
+ pdf_fprint_obj(out, obj, doexpand == 0);
fprintf(out, "endobj\n\n");
}
else
@@ -626,24 +626,24 @@ static void writeobject(int num, int gen)
int dontexpand = 0;
if (doexpand != 0 && doexpand != expand_all)
{
- fz_obj *o;
+ pdf_obj *o;
- if ((o = fz_dict_gets(obj, "Type"), !strcmp(fz_to_name(o), "XObject")) &&
- (o = fz_dict_gets(obj, "Subtype"), !strcmp(fz_to_name(o), "Image")))
+ if ((o = pdf_dict_gets(obj, "Type"), !strcmp(pdf_to_name(o), "XObject")) &&
+ (o = pdf_dict_gets(obj, "Subtype"), !strcmp(pdf_to_name(o), "Image")))
dontexpand = !(doexpand & expand_images);
- if (o = fz_dict_gets(obj, "Type"), !strcmp(fz_to_name(o), "Font"))
+ if (o = pdf_dict_gets(obj, "Type"), !strcmp(pdf_to_name(o), "Font"))
dontexpand = !(doexpand & expand_fonts);
- if (o = fz_dict_gets(obj, "Type"), !strcmp(fz_to_name(o), "FontDescriptor"))
+ if (o = pdf_dict_gets(obj, "Type"), !strcmp(pdf_to_name(o), "FontDescriptor"))
dontexpand = !(doexpand & expand_fonts);
- if ((o = fz_dict_gets(obj, "Length1")) != NULL)
+ if ((o = pdf_dict_gets(obj, "Length1")) != NULL)
dontexpand = !(doexpand & expand_fonts);
- if ((o = fz_dict_gets(obj, "Length2")) != NULL)
+ if ((o = pdf_dict_gets(obj, "Length2")) != NULL)
dontexpand = !(doexpand & expand_fonts);
- if ((o = fz_dict_gets(obj, "Length3")) != NULL)
+ if ((o = pdf_dict_gets(obj, "Length3")) != NULL)
dontexpand = !(doexpand & expand_fonts);
- if (o = fz_dict_gets(obj, "Subtype"), !strcmp(fz_to_name(o), "Type1C"))
+ if (o = pdf_dict_gets(obj, "Subtype"), !strcmp(pdf_to_name(o), "Type1C"))
dontexpand = !(doexpand & expand_fonts);
- if (o = fz_dict_gets(obj, "Subtype"), !strcmp(fz_to_name(o), "CIDFontType0C"))
+ if (o = pdf_dict_gets(obj, "Subtype"), !strcmp(pdf_to_name(o), "CIDFontType0C"))
dontexpand = !(doexpand & expand_fonts);
}
if (doexpand && !dontexpand && !pdf_is_jpx_image(ctx, obj))
@@ -652,13 +652,13 @@ static void writeobject(int num, int gen)
copystream(obj, num, gen);
}
- fz_drop_obj(obj);
+ pdf_drop_obj(obj);
}
static void writexref(void)
{
- fz_obj *trailer;
- fz_obj *obj;
+ pdf_obj *trailer;
+ pdf_obj *obj;
int startxref;
int num;
@@ -674,29 +674,29 @@ static void writexref(void)
}
fprintf(out, "\n");
- trailer = fz_new_dict(ctx, 5);
+ trailer = pdf_new_dict(ctx, 5);
- obj = fz_new_int(ctx, xref->len);
- fz_dict_puts(trailer, "Size", obj);
- fz_drop_obj(obj);
+ obj = pdf_new_int(ctx, xref->len);
+ pdf_dict_puts(trailer, "Size", obj);
+ pdf_drop_obj(obj);
- obj = fz_dict_gets(xref->trailer, "Info");
+ obj = pdf_dict_gets(xref->trailer, "Info");
if (obj)
- fz_dict_puts(trailer, "Info", obj);
+ pdf_dict_puts(trailer, "Info", obj);
- obj = fz_dict_gets(xref->trailer, "Root");
+ obj = pdf_dict_gets(xref->trailer, "Root");
if (obj)
- fz_dict_puts(trailer, "Root", obj);
+ pdf_dict_puts(trailer, "Root", obj);
- obj = fz_dict_gets(xref->trailer, "ID");
+ obj = pdf_dict_gets(xref->trailer, "ID");
if (obj)
- fz_dict_puts(trailer, "ID", obj);
+ pdf_dict_puts(trailer, "ID", obj);
fprintf(out, "trailer\n");
- fz_fprint_obj(out, trailer, doexpand == 0);
+ pdf_fprint_obj(out, trailer, doexpand == 0);
fprintf(out, "\n");
- fz_drop_obj(trailer);
+ pdf_drop_obj(trailer);
fprintf(out, "startxref\n%d\n%%%%EOF\n", startxref);
}
diff --git a/apps/mupdfextract.c b/apps/mupdfextract.c
index 239e9ea7..dd3066f5 100644
--- a/apps/mupdfextract.c
+++ b/apps/mupdfextract.c
@@ -17,26 +17,26 @@ static void usage(void)
exit(1);
}
-static int isimage(fz_obj *obj)
+static int isimage(pdf_obj *obj)
{
- fz_obj *type = fz_dict_gets(obj, "Subtype");
- return fz_is_name(type) && !strcmp(fz_to_name(type), "Image");
+ pdf_obj *type = pdf_dict_gets(obj, "Subtype");
+ return pdf_is_name(type) && !strcmp(pdf_to_name(type), "Image");
}
-static int isfontdesc(fz_obj *obj)
+static int isfontdesc(pdf_obj *obj)
{
- fz_obj *type = fz_dict_gets(obj, "Type");
- return fz_is_name(type) && !strcmp(fz_to_name(type), "FontDescriptor");
+ pdf_obj *type = pdf_dict_gets(obj, "Type");
+ return pdf_is_name(type) && !strcmp(pdf_to_name(type), "FontDescriptor");
}
static void saveimage(int num)
{
fz_image *image;
fz_pixmap *img;
- fz_obj *ref;
+ pdf_obj *ref;
char name[1024];
- ref = fz_new_indirect(ctx, num, 0, doc);
+ ref = pdf_new_indirect(ctx, num, 0, doc);
/* TODO: detect DCTD and save as jpeg */
@@ -67,49 +67,49 @@ static void saveimage(int num)
}
fz_drop_pixmap(ctx, img);
- fz_drop_obj(ref);
+ pdf_drop_obj(ref);
}
-static void savefont(fz_obj *dict, int num)
+static void savefont(pdf_obj *dict, int num)
{
char name[1024];
char *subtype;
fz_buffer *buf;
- fz_obj *stream = NULL;
- fz_obj *obj;
+ pdf_obj *stream = NULL;
+ pdf_obj *obj;
char *ext = "";
FILE *f;
char *fontname = "font";
int n;
- obj = fz_dict_gets(dict, "FontName");
+ obj = pdf_dict_gets(dict, "FontName");
if (obj)
- fontname = fz_to_name(obj);
+ fontname = pdf_to_name(obj);
- obj = fz_dict_gets(dict, "FontFile");
+ obj = pdf_dict_gets(dict, "FontFile");
if (obj)
{
stream = obj;
ext = "pfa";
}
- obj = fz_dict_gets(dict, "FontFile2");
+ obj = pdf_dict_gets(dict, "FontFile2");
if (obj)
{
stream = obj;
ext = "ttf";
}
- obj = fz_dict_gets(dict, "FontFile3");
+ obj = pdf_dict_gets(dict, "FontFile3");
if (obj)
{
stream = obj;
- obj = fz_dict_gets(obj, "Subtype");
- if (obj && !fz_is_name(obj))
+ obj = pdf_dict_gets(obj, "Subtype");
+ if (obj && !pdf_is_name(obj))
fz_throw(ctx, "Invalid font descriptor subtype");
- subtype = fz_to_name(obj);
+ subtype = pdf_to_name(obj);
if (!strcmp(subtype, "Type1C"))
ext = "cff";
else if (!strcmp(subtype, "CIDFontType0C"))
@@ -124,7 +124,7 @@ static void savefont(fz_obj *dict, int num)
return;
}
- buf = pdf_load_stream(doc, fz_to_num(stream), fz_to_gen(stream));
+ buf = pdf_load_stream(doc, pdf_to_num(stream), pdf_to_gen(stream));
sprintf(name, "%s-%04d.%s", fontname, num, ext);
printf("extracting font %s\n", name);
@@ -145,7 +145,7 @@ static void savefont(fz_obj *dict, int num)
static void showobject(int num)
{
- fz_obj *obj;
+ pdf_obj *obj;
if (!doc)
fz_throw(ctx, "no file specified");
@@ -157,7 +157,7 @@ static void showobject(int num)
else if (isfontdesc(obj))
savefont(obj, num);
- fz_drop_obj(obj);
+ pdf_drop_obj(obj);
}
#ifdef MUPDF_COMBINED_EXE
diff --git a/apps/mupdfinfo.c b/apps/mupdfinfo.c
index 3c98c772..90316d6f 100644
--- a/apps/mupdfinfo.c
+++ b/apps/mupdfinfo.c
@@ -28,48 +28,48 @@ enum
struct info
{
int page;
- fz_obj *pageref;
- fz_obj *pageobj;
+ pdf_obj *pageref;
+ pdf_obj *pageobj;
union {
struct {
- fz_obj *obj;
+ pdf_obj *obj;
} info;
struct {
- fz_obj *obj;
+ pdf_obj *obj;
} crypt;
struct {
- fz_obj *obj;
+ pdf_obj *obj;
fz_rect *bbox;
} dim;
struct {
- fz_obj *obj;
- fz_obj *subtype;
- fz_obj *name;
+ pdf_obj *obj;
+ pdf_obj *subtype;
+ pdf_obj *name;
} font;
struct {
- fz_obj *obj;
- fz_obj *width;
- fz_obj *height;
- fz_obj *bpc;
- fz_obj *filter;
- fz_obj *cs;
- fz_obj *altcs;
+ pdf_obj *obj;
+ pdf_obj *width;
+ pdf_obj *height;
+ pdf_obj *bpc;
+ pdf_obj *filter;
+ pdf_obj *cs;
+ pdf_obj *altcs;
} image;
struct {
- fz_obj *obj;
- fz_obj *type;
+ pdf_obj *obj;
+ pdf_obj *type;
} shading;
struct {
- fz_obj *obj;
- fz_obj *type;
- fz_obj *paint;
- fz_obj *tiling;
- fz_obj *shading;
+ pdf_obj *obj;
+ pdf_obj *type;
+ pdf_obj *paint;
+ pdf_obj *tiling;
+ pdf_obj *shading;
} pattern;
struct {
- fz_obj *obj;
- fz_obj *groupsubtype;
- fz_obj *reference;
+ pdf_obj *obj;
+ pdf_obj *groupsubtype;
+ pdf_obj *reference;
} form;
} u;
};
@@ -168,36 +168,36 @@ infousage(void)
static void
showglobalinfo(void)
{
- fz_obj *obj;
+ pdf_obj *obj;
printf("\nPDF-%d.%d\n", xref->version / 10, xref->version % 10);
- obj = fz_dict_gets(xref->trailer, "Info");
+ obj = pdf_dict_gets(xref->trailer, "Info");
if (obj)
{
- printf("Info object (%d %d R):\n", fz_to_num(obj), fz_to_gen(obj));
- fz_debug_obj(fz_resolve_indirect(obj));
+ printf("Info object (%d %d R):\n", pdf_to_num(obj), pdf_to_gen(obj));
+ pdf_debug_obj(pdf_resolve_indirect(obj));
}
- obj = fz_dict_gets(xref->trailer, "Encrypt");
+ obj = pdf_dict_gets(xref->trailer, "Encrypt");
if (obj)
{
- printf("\nEncryption object (%d %d R):\n", fz_to_num(obj), fz_to_gen(obj));
- fz_debug_obj(fz_resolve_indirect(obj));
+ printf("\nEncryption object (%d %d R):\n", pdf_to_num(obj), pdf_to_gen(obj));
+ pdf_debug_obj(pdf_resolve_indirect(obj));
}
printf("\nPages: %d\n\n", pagecount);
}
static void
-gatherdimensions(int page, fz_obj *pageref, fz_obj *pageobj)
+gatherdimensions(int page, pdf_obj *pageref, pdf_obj *pageobj)
{
fz_rect bbox;
- fz_obj *obj;
+ pdf_obj *obj;
int j;
- obj = fz_dict_gets(pageobj, "MediaBox");
- if (!fz_is_array(obj))
+ obj = pdf_dict_gets(pageobj, "MediaBox");
+ if (!pdf_is_array(obj))
return;
bbox = pdf_to_rect(ctx, obj);
@@ -222,33 +222,33 @@ gatherdimensions(int page, fz_obj *pageref, fz_obj *pageobj)
}
static void
-gatherfonts(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
+gatherfonts(int page, pdf_obj *pageref, pdf_obj *pageobj, pdf_obj *dict)
{
int i, n;
- n = fz_dict_len(dict);
+ n = pdf_dict_len(dict);
for (i = 0; i < n; i++)
{
- fz_obj *fontdict = NULL;
- fz_obj *subtype = NULL;
- fz_obj *basefont = NULL;
- fz_obj *name = NULL;
+ pdf_obj *fontdict = NULL;
+ pdf_obj *subtype = NULL;
+ pdf_obj *basefont = NULL;
+ pdf_obj *name = NULL;
int k;
- fontdict = fz_dict_get_val(dict, i);
- if (!fz_is_dict(fontdict))
+ fontdict = pdf_dict_get_val(dict, i);
+ if (!pdf_is_dict(fontdict))
{
- fz_warn(ctx, "not a font dict (%d %d R)", fz_to_num(fontdict), fz_to_gen(fontdict));
+ fz_warn(ctx, "not a font dict (%d %d R)", pdf_to_num(fontdict), pdf_to_gen(fontdict));
continue;
}
- subtype = fz_dict_gets(fontdict, "Subtype");
- basefont = fz_dict_gets(fontdict, "BaseFont");
- if (!basefont || fz_is_null(basefont))
- name = fz_dict_gets(fontdict, "Name");
+ subtype = pdf_dict_gets(fontdict, "Subtype");
+ basefont = pdf_dict_gets(fontdict, "BaseFont");
+ if (!basefont || pdf_is_null(basefont))
+ name = pdf_dict_gets(fontdict, "Name");
for (k = 0; k < fonts; k++)
- if (!fz_objcmp(font[k].u.font.obj, fontdict))
+ if (!pdf_objcmp(font[k].u.font.obj, fontdict))
break;
if (k < fonts)
@@ -267,57 +267,57 @@ gatherfonts(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
}
static void
-gatherimages(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
+gatherimages(int page, pdf_obj *pageref, pdf_obj *pageobj, pdf_obj *dict)
{
int i, n;
- n = fz_dict_len(dict);
+ n = pdf_dict_len(dict);
for (i = 0; i < n; i++)
{
- fz_obj *imagedict;
- fz_obj *type;
- fz_obj *width;
- fz_obj *height;
- fz_obj *bpc = NULL;
- fz_obj *filter = NULL;
- fz_obj *cs = NULL;
- fz_obj *altcs;
+ pdf_obj *imagedict;
+ pdf_obj *type;
+ pdf_obj *width;
+ pdf_obj *height;
+ pdf_obj *bpc = NULL;
+ pdf_obj *filter = NULL;
+ pdf_obj *cs = NULL;
+ pdf_obj *altcs;
int k;
- imagedict = fz_dict_get_val(dict, i);
- if (!fz_is_dict(imagedict))
+ imagedict = pdf_dict_get_val(dict, i);
+ if (!pdf_is_dict(imagedict))
{
- fz_warn(ctx, "not an image dict (%d %d R)", fz_to_num(imagedict), fz_to_gen(imagedict));
+ fz_warn(ctx, "not an image dict (%d %d R)", pdf_to_num(imagedict), pdf_to_gen(imagedict));
continue;
}
- type = fz_dict_gets(imagedict, "Subtype");
- if (strcmp(fz_to_name(type), "Image"))
+ type = pdf_dict_gets(imagedict, "Subtype");
+ if (strcmp(pdf_to_name(type), "Image"))
continue;
- filter = fz_dict_gets(imagedict, "Filter");
+ filter = pdf_dict_gets(imagedict, "Filter");
altcs = NULL;
- cs = fz_dict_gets(imagedict, "ColorSpace");
- if (fz_is_array(cs))
+ cs = pdf_dict_gets(imagedict, "ColorSpace");
+ if (pdf_is_array(cs))
{
- fz_obj *cses = cs;
+ pdf_obj *cses = cs;
- cs = fz_array_get(cses, 0);
- if (fz_is_name(cs) && (!strcmp(fz_to_name(cs), "DeviceN") || !strcmp(fz_to_name(cs), "Separation")))
+ cs = pdf_array_get(cses, 0);
+ if (pdf_is_name(cs) && (!strcmp(pdf_to_name(cs), "DeviceN") || !strcmp(pdf_to_name(cs), "Separation")))
{
- altcs = fz_array_get(cses, 2);
- if (fz_is_array(altcs))
- altcs = fz_array_get(altcs, 0);
+ altcs = pdf_array_get(cses, 2);
+ if (pdf_is_array(altcs))
+ altcs = pdf_array_get(altcs, 0);
}
}
- width = fz_dict_gets(imagedict, "Width");
- height = fz_dict_gets(imagedict, "Height");
- bpc = fz_dict_gets(imagedict, "BitsPerComponent");
+ width = pdf_dict_gets(imagedict, "Width");
+ height = pdf_dict_gets(imagedict, "Height");
+ bpc = pdf_dict_gets(imagedict, "BitsPerComponent");
for (k = 0; k < images; k++)
- if (!fz_objcmp(image[k].u.image.obj, imagedict))
+ if (!pdf_objcmp(image[k].u.image.obj, imagedict))
break;
if (k < images)
@@ -340,42 +340,42 @@ gatherimages(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
}
static void
-gatherforms(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
+gatherforms(int page, pdf_obj *pageref, pdf_obj *pageobj, pdf_obj *dict)
{
int i, n;
- n = fz_dict_len(dict);
+ n = pdf_dict_len(dict);
for (i = 0; i < n; i++)
{
- fz_obj *xobjdict;
- fz_obj *type;
- fz_obj *subtype;
- fz_obj *group;
- fz_obj *groupsubtype;
- fz_obj *reference;
+ pdf_obj *xobjdict;
+ pdf_obj *type;
+ pdf_obj *subtype;
+ pdf_obj *group;
+ pdf_obj *groupsubtype;
+ pdf_obj *reference;
int k;
- xobjdict = fz_dict_get_val(dict, i);
- if (!fz_is_dict(xobjdict))
+ xobjdict = pdf_dict_get_val(dict, i);
+ if (!pdf_is_dict(xobjdict))
{
- fz_warn(ctx, "not a xobject dict (%d %d R)", fz_to_num(xobjdict), fz_to_gen(xobjdict));
+ fz_warn(ctx, "not a xobject dict (%d %d R)", pdf_to_num(xobjdict), pdf_to_gen(xobjdict));
continue;
}
- type = fz_dict_gets(xobjdict, "Subtype");
- if (strcmp(fz_to_name(type), "Form"))
+ type = pdf_dict_gets(xobjdict, "Subtype");
+ if (strcmp(pdf_to_name(type), "Form"))
continue;
- subtype = fz_dict_gets(xobjdict, "Subtype2");
- if (!strcmp(fz_to_name(subtype), "PS"))
+ subtype = pdf_dict_gets(xobjdict, "Subtype2");
+ if (!strcmp(pdf_to_name(subtype), "PS"))
continue;
- group = fz_dict_gets(xobjdict, "Group");
- groupsubtype = fz_dict_gets(group, "S");
- reference = fz_dict_gets(xobjdict, "Ref");
+ group = pdf_dict_gets(xobjdict, "Group");
+ groupsubtype = pdf_dict_gets(group, "S");
+ reference = pdf_dict_gets(xobjdict, "Ref");
for (k = 0; k < forms; k++)
- if (!fz_objcmp(form[k].u.form.obj, xobjdict))
+ if (!pdf_objcmp(form[k].u.form.obj, xobjdict))
break;
if (k < forms)
@@ -394,33 +394,33 @@ gatherforms(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
}
static void
-gatherpsobjs(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
+gatherpsobjs(int page, pdf_obj *pageref, pdf_obj *pageobj, pdf_obj *dict)
{
int i, n;
- n = fz_dict_len(dict);
+ n = pdf_dict_len(dict);
for (i = 0; i < n; i++)
{
- fz_obj *xobjdict;
- fz_obj *type;
- fz_obj *subtype;
+ pdf_obj *xobjdict;
+ pdf_obj *type;
+ pdf_obj *subtype;
int k;
- xobjdict = fz_dict_get_val(dict, i);
- if (!fz_is_dict(xobjdict))
+ xobjdict = pdf_dict_get_val(dict, i);
+ if (!pdf_is_dict(xobjdict))
{
- fz_warn(ctx, "not a xobject dict (%d %d R)", fz_to_num(xobjdict), fz_to_gen(xobjdict));
+ fz_warn(ctx, "not a xobject dict (%d %d R)", pdf_to_num(xobjdict), pdf_to_gen(xobjdict));
continue;
}
- type = fz_dict_gets(xobjdict, "Subtype");
- subtype = fz_dict_gets(xobjdict, "Subtype2");
- if (strcmp(fz_to_name(type), "PS") &&
- (strcmp(fz_to_name(type), "Form") || strcmp(fz_to_name(subtype), "PS")))
+ type = pdf_dict_gets(xobjdict, "Subtype");
+ subtype = pdf_dict_gets(xobjdict, "Subtype2");
+ if (strcmp(pdf_to_name(type), "PS") &&
+ (strcmp(pdf_to_name(type), "Form") || strcmp(pdf_to_name(subtype), "PS")))
continue;
for (k = 0; k < psobjs; k++)
- if (!fz_objcmp(psobj[k].u.form.obj, xobjdict))
+ if (!pdf_objcmp(psobj[k].u.form.obj, xobjdict))
break;
if (k < psobjs)
@@ -437,33 +437,33 @@ gatherpsobjs(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
}
static void
-gathershadings(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
+gathershadings(int page, pdf_obj *pageref, pdf_obj *pageobj, pdf_obj *dict)
{
int i, n;
- n = fz_dict_len(dict);
+ n = pdf_dict_len(dict);
for (i = 0; i < n; i++)
{
- fz_obj *shade;
- fz_obj *type;
+ pdf_obj *shade;
+ pdf_obj *type;
int k;
- shade = fz_dict_get_val(dict, i);
- if (!fz_is_dict(shade))
+ shade = pdf_dict_get_val(dict, i);
+ if (!pdf_is_dict(shade))
{
- fz_warn(ctx, "not a shading dict (%d %d R)", fz_to_num(shade), fz_to_gen(shade));
+ fz_warn(ctx, "not a shading dict (%d %d R)", pdf_to_num(shade), pdf_to_gen(shade));
continue;
}
- type = fz_dict_gets(shade, "ShadingType");
- if (!fz_is_int(type) || fz_to_int(type) < 1 || fz_to_int(type) > 7)
+ type = pdf_dict_gets(shade, "ShadingType");
+ if (!pdf_is_int(type) || pdf_to_int(type) < 1 || pdf_to_int(type) > 7)
{
- fz_warn(ctx, "not a shading type (%d %d R)", fz_to_num(shade), fz_to_gen(shade));
+ fz_warn(ctx, "not a shading type (%d %d R)", pdf_to_num(shade), pdf_to_gen(shade));
type = NULL;
}
for (k = 0; k < shadings; k++)
- if (!fz_objcmp(shading[k].u.shading.obj, shade))
+ if (!pdf_objcmp(shading[k].u.shading.obj, shade))
break;
if (k < shadings)
@@ -481,57 +481,57 @@ gathershadings(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
}
static void
-gatherpatterns(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
+gatherpatterns(int page, pdf_obj *pageref, pdf_obj *pageobj, pdf_obj *dict)
{
int i, n;
- n = fz_dict_len(dict);
+ n = pdf_dict_len(dict);
for (i = 0; i < n; i++)
{
- fz_obj *patterndict;
- fz_obj *type;
- fz_obj *paint = NULL;
- fz_obj *tiling = NULL;
- fz_obj *shading = NULL;
+ pdf_obj *patterndict;
+ pdf_obj *type;
+ pdf_obj *paint = NULL;
+ pdf_obj *tiling = NULL;
+ pdf_obj *shading = NULL;
int k;
- patterndict = fz_dict_get_val(dict, i);
- if (!fz_is_dict(patterndict))
+ patterndict = pdf_dict_get_val(dict, i);
+ if (!pdf_is_dict(patterndict))
{
- fz_warn(ctx, "not a pattern dict (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict));
+ fz_warn(ctx, "not a pattern dict (%d %d R)", pdf_to_num(patterndict), pdf_to_gen(patterndict));
continue;
}
- type = fz_dict_gets(patterndict, "PatternType");
- if (!fz_is_int(type) || fz_to_int(type) < 1 || fz_to_int(type) > 2)
+ type = pdf_dict_gets(patterndict, "PatternType");
+ if (!pdf_is_int(type) || pdf_to_int(type) < 1 || pdf_to_int(type) > 2)
{
- fz_warn(ctx, "not a pattern type (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict));
+ fz_warn(ctx, "not a pattern type (%d %d R)", pdf_to_num(patterndict), pdf_to_gen(patterndict));
type = NULL;
}
- if (fz_to_int(type) == 1)
+ if (pdf_to_int(type) == 1)
{
- paint = fz_dict_gets(patterndict, "PaintType");
- if (!fz_is_int(paint) || fz_to_int(paint) < 1 || fz_to_int(paint) > 2)
+ paint = pdf_dict_gets(patterndict, "PaintType");
+ if (!pdf_is_int(paint) || pdf_to_int(paint) < 1 || pdf_to_int(paint) > 2)
{
- fz_warn(ctx, "not a pattern paint type (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict));
+ fz_warn(ctx, "not a pattern paint type (%d %d R)", pdf_to_num(patterndict), pdf_to_gen(patterndict));
paint = NULL;
}
- tiling = fz_dict_gets(patterndict, "TilingType");
- if (!fz_is_int(tiling) || fz_to_int(tiling) < 1 || fz_to_int(tiling) > 3)
+ tiling = pdf_dict_gets(patterndict, "TilingType");
+ if (!pdf_is_int(tiling) || pdf_to_int(tiling) < 1 || pdf_to_int(tiling) > 3)
{
- fz_warn(ctx, "not a pattern tiling type (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict));
+ fz_warn(ctx, "not a pattern tiling type (%d %d R)", pdf_to_num(patterndict), pdf_to_gen(patterndict));
tiling = NULL;
}
}
else
{
- shading = fz_dict_gets(patterndict, "Shading");
+ shading = pdf_dict_gets(patterndict, "Shading");
}
for (k = 0; k < patterns; k++)
- if (!fz_objcmp(pattern[k].u.pattern.obj, patterndict))
+ if (!pdf_objcmp(pattern[k].u.pattern.obj, patterndict))
break;
if (k < patterns)
@@ -552,15 +552,15 @@ gatherpatterns(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict)
}
static void
-gatherresourceinfo(int page, fz_obj *rsrc)
+gatherresourceinfo(int page, pdf_obj *rsrc)
{
- fz_obj *pageobj;
- fz_obj *pageref;
- fz_obj *font;
- fz_obj *xobj;
- fz_obj *shade;
- fz_obj *pattern;
- fz_obj *subrsrc;
+ pdf_obj *pageobj;
+ pdf_obj *pageref;
+ pdf_obj *font;
+ pdf_obj *xobj;
+ pdf_obj *shade;
+ pdf_obj *pattern;
+ pdf_obj *subrsrc;
int i;
pageobj = xref->page_objs[page-1];
@@ -569,24 +569,24 @@ gatherresourceinfo(int page, fz_obj *rsrc)
if (!pageobj)
fz_throw(ctx, "cannot retrieve info from page %d", page);
- font = fz_dict_gets(rsrc, "Font");
+ font = pdf_dict_gets(rsrc, "Font");
if (font)
{
int n;
gatherfonts(page, pageref, pageobj, font);
- n = fz_dict_len(font);
+ n = pdf_dict_len(font);
for (i = 0; i < n; i++)
{
- fz_obj *obj = fz_dict_get_val(font, i);
+ pdf_obj *obj = pdf_dict_get_val(font, i);
- subrsrc = fz_dict_gets(obj, "Resources");
- if (subrsrc && fz_objcmp(rsrc, subrsrc))
+ subrsrc = pdf_dict_gets(obj, "Resources");
+ if (subrsrc && pdf_objcmp(rsrc, subrsrc))
gatherresourceinfo(page, subrsrc);
}
}
- xobj = fz_dict_gets(rsrc, "XObject");
+ xobj = pdf_dict_gets(rsrc, "XObject");
if (xobj)
{
int n;
@@ -594,31 +594,31 @@ gatherresourceinfo(int page, fz_obj *rsrc)
gatherimages(page, pageref, pageobj, xobj);
gatherforms(page, pageref, pageobj, xobj);
gatherpsobjs(page, pageref, pageobj, xobj);
- n = fz_dict_len(xobj);
+ n = pdf_dict_len(xobj);
for (i = 0; i < n; i++)
{
- fz_obj *obj = fz_dict_get_val(xobj, i);
- subrsrc = fz_dict_gets(obj, "Resources");
- if (subrsrc && fz_objcmp(rsrc, subrsrc))
+ pdf_obj *obj = pdf_dict_get_val(xobj, i);
+ subrsrc = pdf_dict_gets(obj, "Resources");
+ if (subrsrc && pdf_objcmp(rsrc, subrsrc))
gatherresourceinfo(page, subrsrc);
}
}
- shade = fz_dict_gets(rsrc, "Shading");
+ shade = pdf_dict_gets(rsrc, "Shading");
if (shade)
gathershadings(page, pageref, pageobj, shade);
- pattern = fz_dict_gets(rsrc, "Pattern");
+ pattern = pdf_dict_gets(rsrc, "Pattern");
if (pattern)
{
int n;
gatherpatterns(page, pageref, pageobj, pattern);
- n = fz_dict_len(pattern);
+ n = pdf_dict_len(pattern);
for (i = 0; i < n; i++)
{
- fz_obj *obj = fz_dict_get_val(pattern, i);
- subrsrc = fz_dict_gets(obj, "Resources");
- if (subrsrc && fz_objcmp(rsrc, subrsrc))
+ pdf_obj *obj = pdf_dict_get_val(pattern, i);
+ subrsrc = pdf_dict_gets(obj, "Resources");
+ if (subrsrc && pdf_objcmp(rsrc, subrsrc))
gatherresourceinfo(page, subrsrc);
}
}
@@ -627,9 +627,9 @@ gatherresourceinfo(int page, fz_obj *rsrc)
static void
gatherpageinfo(int page)
{
- fz_obj *pageobj;
- fz_obj *pageref;
- fz_obj *rsrc;
+ pdf_obj *pageobj;
+ pdf_obj *pageref;
+ pdf_obj *rsrc;
pageobj = xref->page_objs[page-1];
pageref = xref->page_refs[page-1];
@@ -639,7 +639,7 @@ gatherpageinfo(int page)
gatherdimensions(page, pageref, pageobj);
- rsrc = fz_dict_gets(pageobj, "Resources");
+ rsrc = pdf_dict_gets(pageobj, "Resources");
gatherresourceinfo(page, rsrc);
}
@@ -658,7 +658,7 @@ printinfo(char *filename, int show, int page)
{
printf(PAGE_FMT "[ %g %g %g %g ]\n",
dim[i].page,
- fz_to_num(dim[i].pageref), fz_to_gen(dim[i].pageref),
+ pdf_to_num(dim[i].pageref), pdf_to_gen(dim[i].pageref),
dim[i].u.dim.bbox->x0,
dim[i].u.dim.bbox->y0,
dim[i].u.dim.bbox->x1,
@@ -674,10 +674,10 @@ printinfo(char *filename, int show, int page)
{
printf(PAGE_FMT "%s '%s' (%d %d R)\n",
font[i].page,
- fz_to_num(font[i].pageref), fz_to_gen(font[i].pageref),
- fz_to_name(font[i].u.font.subtype),
- fz_to_name(font[i].u.font.name),
- fz_to_num(font[i].u.font.obj), fz_to_gen(font[i].u.font.obj));
+ pdf_to_num(font[i].pageref), pdf_to_gen(font[i].pageref),
+ pdf_to_name(font[i].u.font.subtype),
+ pdf_to_name(font[i].u.font.name),
+ pdf_to_num(font[i].u.font.obj), pdf_to_gen(font[i].u.font.obj));
}
printf("\n");
}
@@ -692,29 +692,29 @@ printinfo(char *filename, int show, int page)
printf(PAGE_FMT "[ ",
image[i].page,
- fz_to_num(image[i].pageref), fz_to_gen(image[i].pageref));
+ pdf_to_num(image[i].pageref), pdf_to_gen(image[i].pageref));
- if (fz_is_array(image[i].u.image.filter))
+ if (pdf_is_array(image[i].u.image.filter))
{
- int n = fz_array_len(image[i].u.image.filter);
+ int n = pdf_array_len(image[i].u.image.filter);
for (j = 0; j < n; j++)
{
- fz_obj *obj = fz_array_get(image[i].u.image.filter, j);
- char *filter = fz_strdup(ctx, fz_to_name(obj));
+ pdf_obj *obj = pdf_array_get(image[i].u.image.filter, j);
+ char *filter = fz_strdup(ctx, pdf_to_name(obj));
if (strstr(filter, "Decode"))
*(strstr(filter, "Decode")) = '\0';
printf("%s%s",
filter,
- j == fz_array_len(image[i].u.image.filter) - 1 ? "" : " ");
+ j == pdf_array_len(image[i].u.image.filter) - 1 ? "" : " ");
fz_free(ctx, filter);
}
}
else if (image[i].u.image.filter)
{
- fz_obj *obj = image[i].u.image.filter;
- char *filter = fz_strdup(ctx, fz_to_name(obj));
+ pdf_obj *obj = image[i].u.image.filter;
+ char *filter = fz_strdup(ctx, pdf_to_name(obj));
if (strstr(filter, "Decode"))
*(strstr(filter, "Decode")) = '\0';
@@ -727,7 +727,7 @@ printinfo(char *filename, int show, int page)
if (image[i].u.image.cs)
{
- cs = fz_strdup(ctx, fz_to_name(image[i].u.image.cs));
+ cs = fz_strdup(ctx, pdf_to_name(image[i].u.image.cs));
if (!strncmp(cs, "Device", 6))
{
@@ -746,7 +746,7 @@ printinfo(char *filename, int show, int page)
}
if (image[i].u.image.altcs)
{
- altcs = fz_strdup(ctx, fz_to_name(image[i].u.image.altcs));
+ altcs = fz_strdup(ctx, pdf_to_name(image[i].u.image.altcs));
if (!strncmp(altcs, "Device", 6))
{
@@ -765,13 +765,13 @@ printinfo(char *filename, int show, int page)
}
printf(" ] %dx%d %dbpc %s%s%s (%d %d R)\n",
- fz_to_int(image[i].u.image.width),
- fz_to_int(image[i].u.image.height),
- image[i].u.image.bpc ? fz_to_int(image[i].u.image.bpc) : 1,
+ pdf_to_int(image[i].u.image.width),
+ pdf_to_int(image[i].u.image.height),
+ image[i].u.image.bpc ? pdf_to_int(image[i].u.image.bpc) : 1,
image[i].u.image.cs ? cs : "ImageMask",
image[i].u.image.altcs ? " " : "",
image[i].u.image.altcs ? altcs : "",
- fz_to_num(image[i].u.image.obj), fz_to_gen(image[i].u.image.obj));
+ pdf_to_num(image[i].u.image.obj), pdf_to_gen(image[i].u.image.obj));
fz_free(ctx, cs);
fz_free(ctx, altcs);
@@ -798,9 +798,9 @@ printinfo(char *filename, int show, int page)
printf(PAGE_FMT "%s (%d %d R)\n",
shading[i].page,
- fz_to_num(shading[i].pageref), fz_to_gen(shading[i].pageref),
- shadingtype[fz_to_int(shading[i].u.shading.type)],
- fz_to_num(shading[i].u.shading.obj), fz_to_gen(shading[i].u.shading.obj));
+ pdf_to_num(shading[i].pageref), pdf_to_gen(shading[i].pageref),
+ shadingtype[pdf_to_int(shading[i].u.shading.type)],
+ pdf_to_num(shading[i].u.shading.obj), pdf_to_gen(shading[i].u.shading.obj));
}
printf("\n");
}
@@ -810,7 +810,7 @@ printinfo(char *filename, int show, int page)
printf("Patterns (%d):\n", patterns);
for (i = 0; i < patterns; i++)
{
- if (fz_to_int(pattern[i].u.pattern.type) == 1)
+ if (pdf_to_int(pattern[i].u.pattern.type) == 1)
{
char *painttype[] =
{
@@ -828,18 +828,18 @@ printinfo(char *filename, int show, int page)
printf(PAGE_FMT "Tiling %s %s (%d %d R)\n",
pattern[i].page,
- fz_to_num(pattern[i].pageref), fz_to_gen(pattern[i].pageref),
- painttype[fz_to_int(pattern[i].u.pattern.paint)],
- tilingtype[fz_to_int(pattern[i].u.pattern.tiling)],
- fz_to_num(pattern[i].u.pattern.obj), fz_to_gen(pattern[i].u.pattern.obj));
+ pdf_to_num(pattern[i].pageref), pdf_to_gen(pattern[i].pageref),
+ painttype[pdf_to_int(pattern[i].u.pattern.paint)],
+ tilingtype[pdf_to_int(pattern[i].u.pattern.tiling)],
+ pdf_to_num(pattern[i].u.pattern.obj), pdf_to_gen(pattern[i].u.pattern.obj));
}
else
{
printf(PAGE_FMT "Shading %d %d R (%d %d R)\n",
pattern[i].page,
- fz_to_num(pattern[i].pageref), fz_to_gen(pattern[i].pageref),
- fz_to_num(pattern[i].u.pattern.shading), fz_to_gen(pattern[i].u.pattern.shading),
- fz_to_num(pattern[i].u.pattern.obj), fz_to_gen(pattern[i].u.pattern.obj));
+ pdf_to_num(pattern[i].pageref), pdf_to_gen(pattern[i].pageref),
+ pdf_to_num(pattern[i].u.pattern.shading), pdf_to_gen(pattern[i].u.pattern.shading),
+ pdf_to_num(pattern[i].u.pattern.obj), pdf_to_gen(pattern[i].u.pattern.obj));
}
}
printf("\n");
@@ -852,12 +852,12 @@ printinfo(char *filename, int show, int page)
{
printf(PAGE_FMT "Form%s%s%s%s (%d %d R)\n",
form[i].page,
- fz_to_num(form[i].pageref), fz_to_gen(form[i].pageref),
+ pdf_to_num(form[i].pageref), pdf_to_gen(form[i].pageref),
form[i].u.form.groupsubtype ? " " : "",
- form[i].u.form.groupsubtype ? fz_to_name(form[i].u.form.groupsubtype) : "",
+ form[i].u.form.groupsubtype ? pdf_to_name(form[i].u.form.groupsubtype) : "",
form[i].u.form.groupsubtype ? " Group" : "",
form[i].u.form.reference ? " Reference" : "",
- fz_to_num(form[i].u.form.obj), fz_to_gen(form[i].u.form.obj));
+ pdf_to_num(form[i].u.form.obj), pdf_to_gen(form[i].u.form.obj));
}
printf("\n");
}
@@ -869,8 +869,8 @@ printinfo(char *filename, int show, int page)
{
printf(PAGE_FMT "(%d %d R)\n",
psobj[i].page,
- fz_to_num(psobj[i].pageref), fz_to_gen(psobj[i].pageref),
- fz_to_num(psobj[i].u.form.obj), fz_to_gen(psobj[i].u.form.obj));
+ pdf_to_num(psobj[i].pageref), pdf_to_gen(psobj[i].pageref),
+ pdf_to_num(psobj[i].u.form.obj), pdf_to_gen(psobj[i].u.form.obj));
}
printf("\n");
}
diff --git a/apps/mupdfshow.c b/apps/mupdfshow.c
index 8dcdd17d..92fcac2d 100644
--- a/apps/mupdfshow.c
+++ b/apps/mupdfshow.c
@@ -25,7 +25,7 @@ static void showtrailer(void)
if (!doc)
fz_throw(ctx, "no file specified");
printf("trailer\n");
- fz_debug_obj(doc->trailer);
+ pdf_debug_obj(doc->trailer);
printf("\n");
}
@@ -39,7 +39,7 @@ static void showxref(void)
static void showpagetree(void)
{
- fz_obj *ref;
+ pdf_obj *ref;
int count;
int i;
@@ -50,7 +50,7 @@ static void showpagetree(void)
for (i = 0; i < count; i++)
{
ref = doc->page_refs[i];
- printf("page %d = %d %d R\n", i + 1, fz_to_num(ref), fz_to_gen(ref));
+ printf("page %d = %d %d R\n", i + 1, pdf_to_num(ref), pdf_to_gen(ref));
}
printf("\n");
}
@@ -107,7 +107,7 @@ static void showstream(int num, int gen)
static void showobject(int num, int gen)
{
- fz_obj *obj;
+ pdf_obj *obj;
if (!doc)
fz_throw(ctx, "no file specified");
@@ -123,7 +123,7 @@ static void showobject(int num, int gen)
else
{
printf("%d %d obj\n", num, gen);
- fz_debug_obj(obj);
+ pdf_debug_obj(obj);
printf("stream\n");
showstream(num, gen);
printf("endstream\n");
@@ -133,16 +133,16 @@ static void showobject(int num, int gen)
else
{
printf("%d %d obj\n", num, gen);
- fz_debug_obj(obj);
+ pdf_debug_obj(obj);
printf("endobj\n\n");
}
- fz_drop_obj(obj);
+ pdf_drop_obj(obj);
}
static void showgrep(char *filename)
{
- fz_obj *obj;
+ pdf_obj *obj;
int i;
for (i = 0; i < doc->len; i++)
@@ -159,17 +159,17 @@ static void showgrep(char *filename)
continue;
}
- fz_sort_dict(obj);
+ pdf_sort_dict(obj);
printf("%s:%d: ", filename, i);
- fz_fprint_obj(stdout, obj, 1);
+ pdf_fprint_obj(stdout, obj, 1);
- fz_drop_obj(obj);
+ pdf_drop_obj(obj);
}
}
printf("%s:trailer: ", filename);
- fz_fprint_obj(stdout, doc->trailer, 1);
+ pdf_fprint_obj(stdout, doc->trailer, 1);
}
#ifdef MUPDF_COMBINED_EXE
diff --git a/fitz/base_context.c b/fitz/base_context.c
index fe69ff8e..d1ce63ae 100644
--- a/fitz/base_context.c
+++ b/fitz/base_context.c
@@ -1,13 +1,5 @@
#include "fitz.h"
-static fz_obj *
-fz_resolve_indirect_null(fz_obj *ref)
-{
- return ref;
-}
-
-fz_obj *(*fz_resolve_indirect)(fz_obj*) = fz_resolve_indirect_null;
-
void
fz_free_context(fz_context *ctx)
{
diff --git a/fitz/fitz.h b/fitz/fitz.h
index cb7cfa4d..e24d3fbb 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -54,7 +54,6 @@
int gettimeofday(struct timeval *tv, struct timezone *tz);
#define snprintf _snprintf
-#define strtoll _strtoi64
#else /* Unix or close enough */
@@ -909,87 +908,6 @@ void aes_crypt_cbc( fz_aes *ctx, int mode, int length,
unsigned char *output );
/*
- * Dynamic objects.
- * The same type of objects as found in PDF and PostScript.
- * Used by the filters and the mupdf parser.
- */
-
-typedef struct fz_obj_s fz_obj;
-
-extern fz_obj *(*fz_resolve_indirect)(fz_obj *obj);
-
-fz_obj *fz_new_null(fz_context *ctx);
-fz_obj *fz_new_bool(fz_context *ctx, int b);
-fz_obj *fz_new_int(fz_context *ctx, int i);
-fz_obj *fz_new_real(fz_context *ctx, float f);
-fz_obj *fz_new_name(fz_context *ctx, char *str);
-fz_obj *fz_new_string(fz_context *ctx, char *str, int len);
-fz_obj *fz_new_indirect(fz_context *ctx, int num, int gen, void *doc);
-
-fz_obj *fz_new_array(fz_context *ctx, int initialcap);
-fz_obj *fz_new_dict(fz_context *ctx, int initialcap);
-fz_obj *fz_copy_array(fz_context *ctx, fz_obj *array);
-fz_obj *fz_copy_dict(fz_context *ctx, fz_obj *dict);
-
-fz_obj *fz_keep_obj(fz_obj *obj);
-void fz_drop_obj(fz_obj *obj);
-
-/* type queries */
-int fz_is_null(fz_obj *obj);
-int fz_is_bool(fz_obj *obj);
-int fz_is_int(fz_obj *obj);
-int fz_is_real(fz_obj *obj);
-int fz_is_name(fz_obj *obj);
-int fz_is_string(fz_obj *obj);
-int fz_is_array(fz_obj *obj);
-int fz_is_dict(fz_obj *obj);
-int fz_is_indirect(fz_obj *obj);
-
-int fz_objcmp(fz_obj *a, fz_obj *b);
-
-/* dict marking and unmarking functions - to avoid infinite recursions */
-int fz_dict_marked(fz_obj *obj);
-int fz_dict_mark(fz_obj *obj);
-void fz_dict_unmark(fz_obj *obj);
-
-/* safe, silent failure, no error reporting on type mismatches */
-int fz_to_bool(fz_obj *obj);
-int fz_to_int(fz_obj *obj);
-float fz_to_real(fz_obj *obj);
-char *fz_to_name(fz_obj *obj);
-char *fz_to_str_buf(fz_obj *obj);
-fz_obj *fz_to_dict(fz_obj *obj);
-int fz_to_str_len(fz_obj *obj);
-int fz_to_num(fz_obj *obj);
-int fz_to_gen(fz_obj *obj);
-
-int fz_array_len(fz_obj *array);
-fz_obj *fz_array_get(fz_obj *array, int i);
-void fz_array_put(fz_obj *array, int i, fz_obj *obj);
-void fz_array_push(fz_obj *array, fz_obj *obj);
-void fz_array_insert(fz_obj *array, fz_obj *obj);
-int fz_array_contains(fz_obj *array, fz_obj *obj);
-
-int fz_dict_len(fz_obj *dict);
-fz_obj *fz_dict_get_key(fz_obj *dict, int idx);
-fz_obj *fz_dict_get_val(fz_obj *dict, int idx);
-fz_obj *fz_dict_get(fz_obj *dict, fz_obj *key);
-fz_obj *fz_dict_gets(fz_obj *dict, char *key);
-fz_obj *fz_dict_getsa(fz_obj *dict, char *key, char *abbrev);
-void fz_dict_put(fz_obj *dict, fz_obj *key, fz_obj *val);
-void fz_dict_puts(fz_obj *dict, char *key, fz_obj *val);
-void fz_dict_del(fz_obj *dict, fz_obj *key);
-void fz_dict_dels(fz_obj *dict, char *key);
-void fz_sort_dict(fz_obj *dict);
-
-int fz_fprint_obj(FILE *fp, fz_obj *obj, int tight);
-void fz_debug_obj(fz_obj *obj);
-void fz_debug_ref(fz_obj *obj);
-
-void fz_set_str_len(fz_obj *obj, int newlen); /* private */
-void *fz_get_indirect_document(fz_obj *obj); /* private */
-
-/*
fz_buffer is a XXX
*/
typedef struct fz_buffer_s fz_buffer;
@@ -1071,6 +989,7 @@ struct fz_store_type_s
void *(*keep_key)(fz_context *,void *);
void (*drop_key)(fz_context *,void *);
int (*cmp_key)(void *, void *);
+ void (*debug)(void *);
};
void fz_new_store_context(fz_context *ctx, unsigned int max);
@@ -1558,12 +1477,13 @@ struct fz_font_s
int ft_size;
fz_matrix t3matrix;
- fz_obj *t3resources;
+ void *t3resources;
fz_buffer **t3procs; /* has 256 entries if used */
float *t3widths; /* has 256 entries if used */
char *t3flags; /* has 256 entries if used */
void *t3doc; /* a pdf_document for the callback */
- void (*t3run)(void *doc, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate);
+ void (*t3run)(void *doc, void *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate);
+ void (*t3freeres)(void *doc, void *resources);
fz_rect bbox; /* font bbox is used only for t3 fonts */
diff --git a/fitz/res_font.c b/fitz/res_font.c
index 7a194da6..e44be9b6 100644
--- a/fitz/res_font.c
+++ b/fitz/res_font.c
@@ -93,7 +93,7 @@ fz_drop_font(fz_context *ctx, fz_font *font)
if (font->t3procs)
{
if (font->t3resources)
- fz_drop_obj(font->t3resources);
+ font->t3freeres(font->t3doc, font->t3resources);
for (i = 0; i < 256; i++)
if (font->t3procs[i])
fz_drop_buffer(ctx, font->t3procs[i]);
diff --git a/fitz/res_store.c b/fitz/res_store.c
index 461ea7c8..8f9c1ad8 100644
--- a/fitz/res_store.c
+++ b/fitz/res_store.c
@@ -459,17 +459,15 @@ fz_debug_store(fz_context *ctx)
for (item = store->head; item; item = next)
{
next = item->next;
- next->val->refs++;
+ if (next)
+ next->val->refs++;
printf("store[*][refs=%d][size=%d] ", item->val->refs, item->size);
fz_unlock(ctx, FZ_LOCK_ALLOC);
- if (fz_is_indirect(item->key))
- {
- printf("(%d %d R) ", fz_to_num(item->key), fz_to_gen(item->key));
- } else
- fz_debug_obj(item->key);
+ item->type->debug(item->key);
printf(" = %p\n", item->val);
fz_lock(ctx, FZ_LOCK_ALLOC);
- next->val->refs--;
+ if (next)
+ next->val->refs--;
}
fz_unlock(ctx, FZ_LOCK_ALLOC);
}
diff --git a/fitz/base_object.c b/pdf/base_object.c
index 964c5bb4..94f1acfc 100644
--- a/fitz/base_object.c
+++ b/pdf/base_object.c
@@ -1,28 +1,29 @@
#include "fitz.h"
+#include "mupdf.h"
-typedef enum fz_objkind_e
+typedef enum pdf_objkind_e
{
- FZ_NULL,
- FZ_BOOL,
- FZ_INT,
- FZ_REAL,
- FZ_STRING,
- FZ_NAME,
- FZ_ARRAY,
- FZ_DICT,
- FZ_INDIRECT
-} fz_objkind;
+ PDF_NULL,
+ PDF_BOOL,
+ PDF_INT,
+ PDF_REAL,
+ PDF_STRING,
+ PDF_NAME,
+ PDF_ARRAY,
+ PDF_DICT,
+ PDF_INDIRECT
+} pdf_objkind;
struct keyval
{
- fz_obj *k;
- fz_obj *v;
+ pdf_obj *k;
+ pdf_obj *v;
};
-struct fz_obj_s
+struct pdf_obj_s
{
int refs;
- fz_objkind kind;
+ pdf_objkind kind;
fz_context *ctx;
union
{
@@ -37,7 +38,7 @@ struct fz_obj_s
struct {
int len;
int cap;
- fz_obj **items;
+ pdf_obj **items;
} a;
struct {
char sorted;
@@ -54,259 +55,259 @@ struct fz_obj_s
} u;
};
-fz_obj *
-fz_new_null(fz_context *ctx)
+pdf_obj *
+pdf_new_null(fz_context *ctx)
{
- fz_obj *obj;
- obj = Memento_label(fz_malloc(ctx, sizeof(fz_obj)), "fz_obj(null)");
+ pdf_obj *obj;
+ obj = Memento_label(fz_malloc(ctx, sizeof(pdf_obj)), "pdf_obj(null)");
obj->ctx = ctx;
obj->refs = 1;
- obj->kind = FZ_NULL;
+ obj->kind = PDF_NULL;
return obj;
}
-fz_obj *
-fz_new_bool(fz_context *ctx, int b)
+pdf_obj *
+pdf_new_bool(fz_context *ctx, int b)
{
- fz_obj *obj;
- obj = Memento_label(fz_malloc(ctx, sizeof(fz_obj)), "fz_obj(bool)");
+ pdf_obj *obj;
+ obj = Memento_label(fz_malloc(ctx, sizeof(pdf_obj)), "pdf_obj(bool)");
obj->ctx = ctx;
obj->refs = 1;
- obj->kind = FZ_BOOL;
+ obj->kind = PDF_BOOL;
obj->u.b = b;
return obj;
}
-fz_obj *
-fz_new_int(fz_context *ctx, int i)
+pdf_obj *
+pdf_new_int(fz_context *ctx, int i)
{
- fz_obj *obj;
- obj = Memento_label(fz_malloc(ctx, sizeof(fz_obj)), "fz_obj(int)");
+ pdf_obj *obj;
+ obj = Memento_label(fz_malloc(ctx, sizeof(pdf_obj)), "pdf_obj(int)");
obj->ctx = ctx;
obj->refs = 1;
- obj->kind = FZ_INT;
+ obj->kind = PDF_INT;
obj->u.i = i;
return obj;
}
-fz_obj *
-fz_new_real(fz_context *ctx, float f)
+pdf_obj *
+pdf_new_real(fz_context *ctx, float f)
{
- fz_obj *obj;
- obj = Memento_label(fz_malloc(ctx, sizeof(fz_obj)), "fz_obj(real)");
+ pdf_obj *obj;
+ obj = Memento_label(fz_malloc(ctx, sizeof(pdf_obj)), "pdf_obj(real)");
obj->ctx = ctx;
obj->refs = 1;
- obj->kind = FZ_REAL;
+ obj->kind = PDF_REAL;
obj->u.f = f;
return obj;
}
-fz_obj *
-fz_new_string(fz_context *ctx, char *str, int len)
+pdf_obj *
+pdf_new_string(fz_context *ctx, char *str, int len)
{
- fz_obj *obj;
- obj = Memento_label(fz_malloc(ctx, offsetof(fz_obj, u.s.buf) + len + 1), "fz_obj(string)");
+ pdf_obj *obj;
+ obj = Memento_label(fz_malloc(ctx, offsetof(pdf_obj, u.s.buf) + len + 1), "pdf_obj(string)");
obj->ctx = ctx;
obj->refs = 1;
- obj->kind = FZ_STRING;
+ obj->kind = PDF_STRING;
obj->u.s.len = len;
memcpy(obj->u.s.buf, str, len);
obj->u.s.buf[len] = '\0';
return obj;
}
-fz_obj *
+pdf_obj *
fz_new_name(fz_context *ctx, char *str)
{
- fz_obj *obj;
- obj = Memento_label(fz_malloc(ctx, offsetof(fz_obj, u.n) + strlen(str) + 1), "fz_obj(name)");
+ pdf_obj *obj;
+ obj = Memento_label(fz_malloc(ctx, offsetof(pdf_obj, u.n) + strlen(str) + 1), "pdf_obj(name)");
obj->ctx = ctx;
obj->refs = 1;
- obj->kind = FZ_NAME;
+ obj->kind = PDF_NAME;
strcpy(obj->u.n, str);
return obj;
}
-fz_obj *
-fz_new_indirect(fz_context *ctx, int num, int gen, void *xref)
+pdf_obj *
+pdf_new_indirect(fz_context *ctx, int num, int gen, void *xref)
{
- fz_obj *obj;
- obj = Memento_label(fz_malloc(ctx, sizeof(fz_obj)), "fz_obj(indirect)");
+ pdf_obj *obj;
+ obj = Memento_label(fz_malloc(ctx, sizeof(pdf_obj)), "pdf_obj(indirect)");
obj->ctx = ctx;
obj->refs = 1;
- obj->kind = FZ_INDIRECT;
+ obj->kind = PDF_INDIRECT;
obj->u.r.num = num;
obj->u.r.gen = gen;
obj->u.r.xref = xref;
return obj;
}
-fz_obj *
-fz_keep_obj(fz_obj *obj)
+pdf_obj *
+pdf_keep_obj(pdf_obj *obj)
{
assert(obj);
obj->refs ++;
return obj;
}
-int fz_is_indirect(fz_obj *obj)
+int pdf_is_indirect(pdf_obj *obj)
{
- return obj ? obj->kind == FZ_INDIRECT : 0;
+ return obj ? obj->kind == PDF_INDIRECT : 0;
}
#define RESOLVE(obj) \
do { \
- if (obj && obj->kind == FZ_INDIRECT) \
+ if (obj && obj->kind == PDF_INDIRECT) \
{\
fz_assert_lock_not_held(obj->ctx, FZ_LOCK_FILE); \
- obj = fz_resolve_indirect(obj); \
+ obj = pdf_resolve_indirect(obj); \
} \
} while (0)
-int fz_is_null(fz_obj *obj)
+int pdf_is_null(pdf_obj *obj)
{
RESOLVE(obj);
- return obj ? obj->kind == FZ_NULL : 0;
+ return obj ? obj->kind == PDF_NULL : 0;
}
-int fz_is_bool(fz_obj *obj)
+int pdf_is_bool(pdf_obj *obj)
{
RESOLVE(obj);
- return obj ? obj->kind == FZ_BOOL : 0;
+ return obj ? obj->kind == PDF_BOOL : 0;
}
-int fz_is_int(fz_obj *obj)
+int pdf_is_int(pdf_obj *obj)
{
RESOLVE(obj);
- return obj ? obj->kind == FZ_INT : 0;
+ return obj ? obj->kind == PDF_INT : 0;
}
-int fz_is_real(fz_obj *obj)
+int pdf_is_real(pdf_obj *obj)
{
RESOLVE(obj);
- return obj ? obj->kind == FZ_REAL : 0;
+ return obj ? obj->kind == PDF_REAL : 0;
}
-int fz_is_string(fz_obj *obj)
+int pdf_is_string(pdf_obj *obj)
{
RESOLVE(obj);
- return obj ? obj->kind == FZ_STRING : 0;
+ return obj ? obj->kind == PDF_STRING : 0;
}
-int fz_is_name(fz_obj *obj)
+int pdf_is_name(pdf_obj *obj)
{
RESOLVE(obj);
- return obj ? obj->kind == FZ_NAME : 0;
+ return obj ? obj->kind == PDF_NAME : 0;
}
-int fz_is_array(fz_obj *obj)
+int pdf_is_array(pdf_obj *obj)
{
RESOLVE(obj);
- return obj ? obj->kind == FZ_ARRAY : 0;
+ return obj ? obj->kind == PDF_ARRAY : 0;
}
-int fz_is_dict(fz_obj *obj)
+int pdf_is_dict(pdf_obj *obj)
{
RESOLVE(obj);
- return obj ? obj->kind == FZ_DICT : 0;
+ return obj ? obj->kind == PDF_DICT : 0;
}
-int fz_to_bool(fz_obj *obj)
+int pdf_to_bool(pdf_obj *obj)
{
RESOLVE(obj);
if (!obj)
return 0;
- return obj->kind == FZ_BOOL ? obj->u.b : 0;
+ return obj->kind == PDF_BOOL ? obj->u.b : 0;
}
-int fz_to_int(fz_obj *obj)
+int pdf_to_int(pdf_obj *obj)
{
RESOLVE(obj);
if (!obj)
return 0;
- if (obj->kind == FZ_INT)
+ if (obj->kind == PDF_INT)
return obj->u.i;
- if (obj->kind == FZ_REAL)
+ if (obj->kind == PDF_REAL)
return (int)(obj->u.f + 0.5f); /* No roundf in MSVC */
return 0;
}
-float fz_to_real(fz_obj *obj)
+float pdf_to_real(pdf_obj *obj)
{
RESOLVE(obj);
if (!obj)
return 0;
- if (obj->kind == FZ_REAL)
+ if (obj->kind == PDF_REAL)
return obj->u.f;
- if (obj->kind == FZ_INT)
+ if (obj->kind == PDF_INT)
return obj->u.i;
return 0;
}
-char *fz_to_name(fz_obj *obj)
+char *pdf_to_name(pdf_obj *obj)
{
RESOLVE(obj);
- if (!obj || obj->kind != FZ_NAME)
+ if (!obj || obj->kind != PDF_NAME)
return "";
return obj->u.n;
}
-char *fz_to_str_buf(fz_obj *obj)
+char *pdf_to_str_buf(pdf_obj *obj)
{
RESOLVE(obj);
- if (!obj || obj->kind != FZ_STRING)
+ if (!obj || obj->kind != PDF_STRING)
return "";
return obj->u.s.buf;
}
-int fz_to_str_len(fz_obj *obj)
+int pdf_to_str_len(pdf_obj *obj)
{
RESOLVE(obj);
- if (!obj || obj->kind != FZ_STRING)
+ if (!obj || obj->kind != PDF_STRING)
return 0;
return obj->u.s.len;
}
/* for use by pdf_crypt_obj_imp to decrypt AES string in place */
-void fz_set_str_len(fz_obj *obj, int newlen)
+void pdf_set_str_len(pdf_obj *obj, int newlen)
{
RESOLVE(obj);
- if (!obj || obj->kind != FZ_STRING)
+ if (!obj || obj->kind != PDF_STRING)
return; /* This should never happen */
if (newlen > obj->u.s.len)
return; /* This should never happen */
obj->u.s.len = newlen;
}
-fz_obj *fz_to_dict(fz_obj *obj)
+pdf_obj *pdf_to_dict(pdf_obj *obj)
{
RESOLVE(obj);
- return (obj && obj->kind == FZ_DICT ? obj : NULL);
+ return (obj && obj->kind == PDF_DICT ? obj : NULL);
}
-int fz_to_num(fz_obj *obj)
+int pdf_to_num(pdf_obj *obj)
{
- if (!obj || obj->kind != FZ_INDIRECT)
+ if (!obj || obj->kind != PDF_INDIRECT)
return 0;
return obj->u.r.num;
}
-int fz_to_gen(fz_obj *obj)
+int pdf_to_gen(pdf_obj *obj)
{
- if (!obj || obj->kind != FZ_INDIRECT)
+ if (!obj || obj->kind != PDF_INDIRECT)
return 0;
return obj->u.r.gen;
}
-void *fz_get_indirect_document(fz_obj *obj)
+void *pdf_get_indirect_document(pdf_obj *obj)
{
- if (!obj || obj->kind != FZ_INDIRECT)
+ if (!obj || obj->kind != PDF_INDIRECT)
return NULL;
return obj->u.r.xref;
}
int
-fz_objcmp(fz_obj *a, fz_obj *b)
+pdf_objcmp(pdf_obj *a, pdf_obj *b)
{
int i;
@@ -321,23 +322,23 @@ fz_objcmp(fz_obj *a, fz_obj *b)
switch (a->kind)
{
- case FZ_NULL:
+ case PDF_NULL:
return 0;
- case FZ_BOOL:
+ case PDF_BOOL:
return a->u.b - b->u.b;
- case FZ_INT:
+ case PDF_INT:
return a->u.i - b->u.i;
- case FZ_REAL:
+ case PDF_REAL:
if (a->u.f < b->u.f)
return -1;
if (a->u.f > b->u.f)
return 1;
return 0;
- case FZ_STRING:
+ case PDF_STRING:
if (a->u.s.len < b->u.s.len)
{
if (memcmp(a->u.s.buf, b->u.s.buf, a->u.s.len) <= 0)
@@ -352,30 +353,30 @@ fz_objcmp(fz_obj *a, fz_obj *b)
}
return memcmp(a->u.s.buf, b->u.s.buf, a->u.s.len);
- case FZ_NAME:
+ case PDF_NAME:
return strcmp(a->u.n, b->u.n);
- case FZ_INDIRECT:
+ case PDF_INDIRECT:
if (a->u.r.num == b->u.r.num)
return a->u.r.gen - b->u.r.gen;
return a->u.r.num - b->u.r.num;
- case FZ_ARRAY:
+ case PDF_ARRAY:
if (a->u.a.len != b->u.a.len)
return a->u.a.len - b->u.a.len;
for (i = 0; i < a->u.a.len; i++)
- if (fz_objcmp(a->u.a.items[i], b->u.a.items[i]))
+ if (pdf_objcmp(a->u.a.items[i], b->u.a.items[i]))
return 1;
return 0;
- case FZ_DICT:
+ case PDF_DICT:
if (a->u.d.len != b->u.d.len)
return a->u.d.len - b->u.d.len;
for (i = 0; i < a->u.d.len; i++)
{
- if (fz_objcmp(a->u.d.items[i].k, b->u.d.items[i].k))
+ if (pdf_objcmp(a->u.d.items[i].k, b->u.d.items[i].k))
return 1;
- if (fz_objcmp(a->u.d.items[i].v, b->u.d.items[i].v))
+ if (pdf_objcmp(a->u.d.items[i].v, b->u.d.items[i].v))
return 1;
}
return 0;
@@ -385,42 +386,42 @@ fz_objcmp(fz_obj *a, fz_obj *b)
}
static char *
-fz_objkindstr(fz_obj *obj)
+pdf_objkindstr(pdf_obj *obj)
{
if (!obj)
return "<NULL>";
switch (obj->kind)
{
- case FZ_NULL: return "null";
- case FZ_BOOL: return "boolean";
- case FZ_INT: return "integer";
- case FZ_REAL: return "real";
- case FZ_STRING: return "string";
- case FZ_NAME: return "name";
- case FZ_ARRAY: return "array";
- case FZ_DICT: return "dictionary";
- case FZ_INDIRECT: return "reference";
+ case PDF_NULL: return "null";
+ case PDF_BOOL: return "boolean";
+ case PDF_INT: return "integer";
+ case PDF_REAL: return "real";
+ case PDF_STRING: return "string";
+ case PDF_NAME: return "name";
+ case PDF_ARRAY: return "array";
+ case PDF_DICT: return "dictionary";
+ case PDF_INDIRECT: return "reference";
}
return "<unknown>";
}
-fz_obj *
-fz_new_array(fz_context *ctx, int initialcap)
+pdf_obj *
+pdf_new_array(fz_context *ctx, int initialcap)
{
- fz_obj *obj;
+ pdf_obj *obj;
int i;
- obj = Memento_label(fz_malloc(ctx, sizeof(fz_obj)), "fz_obj(array)");
+ obj = Memento_label(fz_malloc(ctx, sizeof(pdf_obj)), "pdf_obj(array)");
obj->ctx = ctx;
obj->refs = 1;
- obj->kind = FZ_ARRAY;
+ obj->kind = PDF_ARRAY;
obj->u.a.len = 0;
obj->u.a.cap = initialcap > 1 ? initialcap : 6;
fz_try(ctx)
{
- obj->u.a.items = Memento_label(fz_malloc_array(ctx, obj->u.a.cap, sizeof(fz_obj*)), "fz_obj(array items)");
+ obj->u.a.items = Memento_label(fz_malloc_array(ctx, obj->u.a.cap, sizeof(pdf_obj*)), "pdf_obj(array items)");
}
fz_catch(ctx)
{
@@ -434,51 +435,51 @@ fz_new_array(fz_context *ctx, int initialcap)
}
static void
-fz_array_grow(fz_obj *obj)
+pdf_array_grow(pdf_obj *obj)
{
int i;
obj->u.a.cap = (obj->u.a.cap * 3) / 2;
- obj->u.a.items = fz_resize_array(obj->ctx, obj->u.a.items, obj->u.a.cap, sizeof(fz_obj*));
+ obj->u.a.items = fz_resize_array(obj->ctx, obj->u.a.items, obj->u.a.cap, sizeof(pdf_obj*));
for (i = obj->u.a.len ; i < obj->u.a.cap; i++)
obj->u.a.items[i] = NULL;
}
-fz_obj *
-fz_copy_array(fz_context *ctx, fz_obj *obj)
+pdf_obj *
+pdf_copy_array(fz_context *ctx, pdf_obj *obj)
{
- fz_obj *arr;
+ pdf_obj *arr;
int i;
int n;
RESOLVE(obj);
- if (!obj || obj->kind != FZ_ARRAY)
- fz_warn(ctx, "assert: not an array (%s)", fz_objkindstr(obj));
+ if (!obj || obj->kind != PDF_ARRAY)
+ fz_warn(ctx, "assert: not an array (%s)", pdf_objkindstr(obj));
- arr = fz_new_array(ctx, fz_array_len(obj));
- n = fz_array_len(obj);
+ arr = pdf_new_array(ctx, pdf_array_len(obj));
+ n = pdf_array_len(obj);
for (i = 0; i < n; i++)
- fz_array_push(arr, fz_array_get(obj, i));
+ pdf_array_push(arr, pdf_array_get(obj, i));
return arr;
}
int
-fz_array_len(fz_obj *obj)
+pdf_array_len(pdf_obj *obj)
{
RESOLVE(obj);
- if (!obj || obj->kind != FZ_ARRAY)
+ if (!obj || obj->kind != PDF_ARRAY)
return 0;
return obj->u.a.len;
}
-fz_obj *
-fz_array_get(fz_obj *obj, int i)
+pdf_obj *
+pdf_array_get(pdf_obj *obj, int i)
{
RESOLVE(obj);
- if (!obj || obj->kind != FZ_ARRAY)
+ if (!obj || obj->kind != PDF_ARRAY)
return NULL;
if (i < 0 || i >= obj->u.a.len)
@@ -488,14 +489,14 @@ fz_array_get(fz_obj *obj, int i)
}
void
-fz_array_put(fz_obj *obj, int i, fz_obj *item)
+pdf_array_put(pdf_obj *obj, int i, pdf_obj *item)
{
RESOLVE(obj);
if (!obj)
return; /* Can't warn :( */
- if (obj->kind != FZ_ARRAY)
- fz_warn(obj->ctx, "assert: not an array (%s)", fz_objkindstr(obj));
+ if (obj->kind != PDF_ARRAY)
+ fz_warn(obj->ctx, "assert: not an array (%s)", pdf_objkindstr(obj));
else if (i < 0)
fz_warn(obj->ctx, "assert: index %d < 0", i);
else if (i >= obj->u.a.len)
@@ -503,55 +504,55 @@ fz_array_put(fz_obj *obj, int i, fz_obj *item)
else
{
if (obj->u.a.items[i])
- fz_drop_obj(obj->u.a.items[i]);
- obj->u.a.items[i] = fz_keep_obj(item);
+ pdf_drop_obj(obj->u.a.items[i]);
+ obj->u.a.items[i] = pdf_keep_obj(item);
}
}
void
-fz_array_push(fz_obj *obj, fz_obj *item)
+pdf_array_push(pdf_obj *obj, pdf_obj *item)
{
RESOLVE(obj);
if (!obj)
return; /* Can't warn :( */
- if (obj->kind != FZ_ARRAY)
- fz_warn(obj->ctx, "assert: not an array (%s)", fz_objkindstr(obj));
+ if (obj->kind != PDF_ARRAY)
+ fz_warn(obj->ctx, "assert: not an array (%s)", pdf_objkindstr(obj));
else
{
if (obj->u.a.len + 1 > obj->u.a.cap)
- fz_array_grow(obj);
- obj->u.a.items[obj->u.a.len] = fz_keep_obj(item);
+ pdf_array_grow(obj);
+ obj->u.a.items[obj->u.a.len] = pdf_keep_obj(item);
obj->u.a.len++;
}
}
void
-fz_array_insert(fz_obj *obj, fz_obj *item)
+pdf_array_insert(pdf_obj *obj, pdf_obj *item)
{
RESOLVE(obj);
if (!obj)
return; /* Can't warn :( */
- if (obj->kind != FZ_ARRAY)
- fz_warn(obj->ctx, "assert: not an array (%s)", fz_objkindstr(obj));
+ if (obj->kind != PDF_ARRAY)
+ fz_warn(obj->ctx, "assert: not an array (%s)", pdf_objkindstr(obj));
else
{
if (obj->u.a.len + 1 > obj->u.a.cap)
- fz_array_grow(obj);
- memmove(obj->u.a.items + 1, obj->u.a.items, obj->u.a.len * sizeof(fz_obj*));
- obj->u.a.items[0] = fz_keep_obj(item);
+ pdf_array_grow(obj);
+ memmove(obj->u.a.items + 1, obj->u.a.items, obj->u.a.len * sizeof(pdf_obj*));
+ obj->u.a.items[0] = pdf_keep_obj(item);
obj->u.a.len++;
}
}
int
-fz_array_contains(fz_obj *arr, fz_obj *obj)
+pdf_array_contains(pdf_obj *arr, pdf_obj *obj)
{
int i;
- for (i = 0; i < fz_array_len(arr); i++)
- if (!fz_objcmp(fz_array_get(arr, i), obj))
+ for (i = 0; i < pdf_array_len(arr); i++)
+ if (!pdf_objcmp(pdf_array_get(arr, i), obj))
return 1;
return 0;
@@ -563,19 +564,19 @@ static int keyvalcmp(const void *ap, const void *bp)
{
const struct keyval *a = ap;
const struct keyval *b = bp;
- return strcmp(fz_to_name(a->k), fz_to_name(b->k));
+ return strcmp(pdf_to_name(a->k), pdf_to_name(b->k));
}
-fz_obj *
-fz_new_dict(fz_context *ctx, int initialcap)
+pdf_obj *
+pdf_new_dict(fz_context *ctx, int initialcap)
{
- fz_obj *obj;
+ pdf_obj *obj;
int i;
- obj = Memento_label(fz_malloc(ctx, sizeof(fz_obj)), "fz_obj(dict)");
+ obj = Memento_label(fz_malloc(ctx, sizeof(pdf_obj)), "pdf_obj(dict)");
obj->ctx = ctx;
obj->refs = 1;
- obj->kind = FZ_DICT;
+ obj->kind = PDF_DICT;
obj->u.d.sorted = 0;
obj->u.d.marked = 0;
@@ -584,7 +585,7 @@ fz_new_dict(fz_context *ctx, int initialcap)
fz_try(ctx)
{
- obj->u.d.items = Memento_label(fz_malloc_array(ctx, obj->u.d.cap, sizeof(struct keyval)), "fz_obj(dict items)");
+ obj->u.d.items = Memento_label(fz_malloc_array(ctx, obj->u.d.cap, sizeof(struct keyval)), "pdf_obj(dict items)");
}
fz_catch(ctx)
{
@@ -601,7 +602,7 @@ fz_new_dict(fz_context *ctx, int initialcap)
}
static void
-fz_dict_grow(fz_obj *obj)
+pdf_dict_grow(pdf_obj *obj)
{
int i;
@@ -615,38 +616,38 @@ fz_dict_grow(fz_obj *obj)
}
}
-fz_obj *
-fz_copy_dict(fz_context *ctx, fz_obj *obj)
+pdf_obj *
+pdf_copy_dict(fz_context *ctx, pdf_obj *obj)
{
- fz_obj *dict;
+ pdf_obj *dict;
int i, n;
RESOLVE(obj);
- if (obj && obj->kind != FZ_DICT)
- fz_warn(ctx, "assert: not a dict (%s)", fz_objkindstr(obj));
+ if (obj && obj->kind != PDF_DICT)
+ fz_warn(ctx, "assert: not a dict (%s)", pdf_objkindstr(obj));
- n = fz_dict_len(obj);
- dict = fz_new_dict(ctx, n);
+ n = pdf_dict_len(obj);
+ dict = pdf_new_dict(ctx, n);
for (i = 0; i < n; i++)
- fz_dict_put(dict, fz_dict_get_key(obj, i), fz_dict_get_val(obj, i));
+ fz_dict_put(dict, pdf_dict_get_key(obj, i), pdf_dict_get_val(obj, i));
return dict;
}
int
-fz_dict_len(fz_obj *obj)
+pdf_dict_len(pdf_obj *obj)
{
RESOLVE(obj);
- if (!obj || obj->kind != FZ_DICT)
+ if (!obj || obj->kind != PDF_DICT)
return 0;
return obj->u.d.len;
}
-fz_obj *
-fz_dict_get_key(fz_obj *obj, int i)
+pdf_obj *
+pdf_dict_get_key(pdf_obj *obj, int i)
{
RESOLVE(obj);
- if (!obj || obj->kind != FZ_DICT)
+ if (!obj || obj->kind != PDF_DICT)
return NULL;
if (i < 0 || i >= obj->u.d.len)
@@ -655,11 +656,11 @@ fz_dict_get_key(fz_obj *obj, int i)
return obj->u.d.items[i].k;
}
-fz_obj *
-fz_dict_get_val(fz_obj *obj, int i)
+pdf_obj *
+pdf_dict_get_val(pdf_obj *obj, int i)
{
RESOLVE(obj);
- if (!obj || obj->kind != FZ_DICT)
+ if (!obj || obj->kind != PDF_DICT)
return NULL;
if (i < 0 || i >= obj->u.d.len)
@@ -669,14 +670,14 @@ fz_dict_get_val(fz_obj *obj, int i)
}
static int
-fz_dict_finds(fz_obj *obj, char *key, int *location)
+pdf_dict_finds(pdf_obj *obj, char *key, int *location)
{
if (obj->u.d.sorted && obj->u.d.len > 0)
{
int l = 0;
int r = obj->u.d.len - 1;
- if (strcmp(fz_to_name(obj->u.d.items[r].k), key) < 0)
+ if (strcmp(pdf_to_name(obj->u.d.items[r].k), key) < 0)
{
if (location)
*location = r + 1;
@@ -686,7 +687,7 @@ fz_dict_finds(fz_obj *obj, char *key, int *location)
while (l <= r)
{
int m = (l + r) >> 1;
- int c = -strcmp(fz_to_name(obj->u.d.items[m].k), key);
+ int c = -strcmp(pdf_to_name(obj->u.d.items[m].k), key);
if (c < 0)
r = m - 1;
else if (c > 0)
@@ -703,7 +704,7 @@ fz_dict_finds(fz_obj *obj, char *key, int *location)
{
int i;
for (i = 0; i < obj->u.d.len; i++)
- if (strcmp(fz_to_name(obj->u.d.items[i].k), key) == 0)
+ if (strcmp(pdf_to_name(obj->u.d.items[i].k), key) == 0)
return i;
if (location)
@@ -713,62 +714,62 @@ fz_dict_finds(fz_obj *obj, char *key, int *location)
return -1;
}
-fz_obj *
-fz_dict_gets(fz_obj *obj, char *key)
+pdf_obj *
+pdf_dict_gets(pdf_obj *obj, char *key)
{
int i;
RESOLVE(obj);
- if (!obj || obj->kind != FZ_DICT)
+ if (!obj || obj->kind != PDF_DICT)
return NULL;
- i = fz_dict_finds(obj, key, NULL);
+ i = pdf_dict_finds(obj, key, NULL);
if (i >= 0)
return obj->u.d.items[i].v;
return NULL;
}
-fz_obj *
-fz_dict_get(fz_obj *obj, fz_obj *key)
+pdf_obj *
+pdf_dict_get(pdf_obj *obj, pdf_obj *key)
{
- if (!key || key->kind != FZ_NAME)
+ if (!key || key->kind != PDF_NAME)
return NULL;
- return fz_dict_gets(obj, fz_to_name(key));
+ return pdf_dict_gets(obj, pdf_to_name(key));
}
-fz_obj *
-fz_dict_getsa(fz_obj *obj, char *key, char *abbrev)
+pdf_obj *
+pdf_dict_getsa(pdf_obj *obj, char *key, char *abbrev)
{
- fz_obj *v;
- v = fz_dict_gets(obj, key);
+ pdf_obj *v;
+ v = pdf_dict_gets(obj, key);
if (v)
return v;
- return fz_dict_gets(obj, abbrev);
+ return pdf_dict_gets(obj, abbrev);
}
void
-fz_dict_put(fz_obj *obj, fz_obj *key, fz_obj *val)
+fz_dict_put(pdf_obj *obj, pdf_obj *key, pdf_obj *val)
{
int location;
char *s;
int i;
RESOLVE(obj);
- if (!obj || obj->kind != FZ_DICT)
+ if (!obj || obj->kind != PDF_DICT)
{
- fz_warn(obj->ctx, "assert: not a dict (%s)", fz_objkindstr(obj));
+ fz_warn(obj->ctx, "assert: not a dict (%s)", pdf_objkindstr(obj));
return;
}
RESOLVE(key);
- if (!key || key->kind != FZ_NAME)
+ if (!key || key->kind != PDF_NAME)
{
- fz_warn(obj->ctx, "assert: key is not a name (%s)", fz_objkindstr(obj));
+ fz_warn(obj->ctx, "assert: key is not a name (%s)", pdf_objkindstr(obj));
return;
}
else
- s = fz_to_name(key);
+ s = pdf_to_name(key);
if (!val)
{
@@ -777,18 +778,18 @@ fz_dict_put(fz_obj *obj, fz_obj *key, fz_obj *val)
}
if (obj->u.d.len > 100 && !obj->u.d.sorted)
- fz_sort_dict(obj);
+ pdf_sort_dict(obj);
- i = fz_dict_finds(obj, s, &location);
+ i = pdf_dict_finds(obj, s, &location);
if (i >= 0 && i < obj->u.d.len)
{
- fz_drop_obj(obj->u.d.items[i].v);
- obj->u.d.items[i].v = fz_keep_obj(val);
+ pdf_drop_obj(obj->u.d.items[i].v);
+ obj->u.d.items[i].v = pdf_keep_obj(val);
}
else
{
if (obj->u.d.len + 1 > obj->u.d.cap)
- fz_dict_grow(obj);
+ pdf_dict_grow(obj);
i = location;
if (obj->u.d.sorted && obj->u.d.len > 0)
@@ -796,34 +797,34 @@ fz_dict_put(fz_obj *obj, fz_obj *key, fz_obj *val)
&obj->u.d.items[i],
(obj->u.d.len - i) * sizeof(struct keyval));
- obj->u.d.items[i].k = fz_keep_obj(key);
- obj->u.d.items[i].v = fz_keep_obj(val);
+ obj->u.d.items[i].k = pdf_keep_obj(key);
+ obj->u.d.items[i].v = pdf_keep_obj(val);
obj->u.d.len ++;
}
}
void
-fz_dict_puts(fz_obj *obj, char *key, fz_obj *val)
+pdf_dict_puts(pdf_obj *obj, char *key, pdf_obj *val)
{
- fz_obj *keyobj = fz_new_name(obj->ctx, key);
+ pdf_obj *keyobj = fz_new_name(obj->ctx, key);
fz_dict_put(obj, keyobj, val);
- fz_drop_obj(keyobj);
+ pdf_drop_obj(keyobj);
}
void
-fz_dict_dels(fz_obj *obj, char *key)
+pdf_dict_dels(pdf_obj *obj, char *key)
{
RESOLVE(obj);
- if (!obj || obj->kind != FZ_DICT)
- fz_warn(obj->ctx, "assert: not a dict (%s)", fz_objkindstr(obj));
+ if (!obj || obj->kind != PDF_DICT)
+ fz_warn(obj->ctx, "assert: not a dict (%s)", pdf_objkindstr(obj));
else
{
- int i = fz_dict_finds(obj, key, NULL);
+ int i = pdf_dict_finds(obj, key, NULL);
if (i >= 0)
{
- fz_drop_obj(obj->u.d.items[i].k);
- fz_drop_obj(obj->u.d.items[i].v);
+ pdf_drop_obj(obj->u.d.items[i].k);
+ pdf_drop_obj(obj->u.d.items[i].v);
obj->u.d.sorted = 0;
obj->u.d.items[i] = obj->u.d.items[obj->u.d.len-1];
obj->u.d.len --;
@@ -832,20 +833,20 @@ fz_dict_dels(fz_obj *obj, char *key)
}
void
-fz_dict_del(fz_obj *obj, fz_obj *key)
+pdf_dict_del(pdf_obj *obj, pdf_obj *key)
{
RESOLVE(key);
- if (!key || key->kind != FZ_NAME)
- fz_warn(obj->ctx, "assert: key is not a name (%s)", fz_objkindstr(obj));
+ if (!key || key->kind != PDF_NAME)
+ fz_warn(obj->ctx, "assert: key is not a name (%s)", pdf_objkindstr(obj));
else
- fz_dict_dels(obj, key->u.n);
+ pdf_dict_dels(obj, key->u.n);
}
void
-fz_sort_dict(fz_obj *obj)
+pdf_sort_dict(pdf_obj *obj)
{
RESOLVE(obj);
- if (!obj || obj->kind != FZ_DICT)
+ if (!obj || obj->kind != PDF_DICT)
return;
if (!obj->u.d.sorted)
{
@@ -855,20 +856,20 @@ fz_sort_dict(fz_obj *obj)
}
int
-fz_dict_marked(fz_obj *obj)
+pdf_dict_marked(pdf_obj *obj)
{
RESOLVE(obj);
- if (!obj || obj->kind != FZ_DICT)
+ if (!obj || obj->kind != PDF_DICT)
return 0;
return obj->u.d.marked;
}
int
-fz_dict_mark(fz_obj *obj)
+pdf_dict_mark(pdf_obj *obj)
{
int marked;
RESOLVE(obj);
- if (!obj || obj->kind != FZ_DICT)
+ if (!obj || obj->kind != PDF_DICT)
return 0;
marked = obj->u.d.marked;
obj->u.d.marked = 1;
@@ -876,37 +877,37 @@ fz_dict_mark(fz_obj *obj)
}
void
-fz_dict_unmark(fz_obj *obj)
+pdf_dict_unmark(pdf_obj *obj)
{
RESOLVE(obj);
- if (!obj || obj->kind != FZ_DICT)
+ if (!obj || obj->kind != PDF_DICT)
return;
obj->u.d.marked = 0;
}
static void
-fz_free_array(fz_obj *obj)
+pdf_free_array(pdf_obj *obj)
{
int i;
for (i = 0; i < obj->u.a.len; i++)
if (obj->u.a.items[i])
- fz_drop_obj(obj->u.a.items[i]);
+ pdf_drop_obj(obj->u.a.items[i]);
fz_free(obj->ctx, obj->u.a.items);
fz_free(obj->ctx, obj);
}
static void
-fz_free_dict(fz_obj *obj)
+pdf_free_dict(pdf_obj *obj)
{
int i;
for (i = 0; i < obj->u.d.len; i++) {
if (obj->u.d.items[i].k)
- fz_drop_obj(obj->u.d.items[i].k);
+ pdf_drop_obj(obj->u.d.items[i].k);
if (obj->u.d.items[i].v)
- fz_drop_obj(obj->u.d.items[i].v);
+ pdf_drop_obj(obj->u.d.items[i].v);
}
fz_free(obj->ctx, obj->u.d.items);
@@ -914,16 +915,16 @@ fz_free_dict(fz_obj *obj)
}
void
-fz_drop_obj(fz_obj *obj)
+pdf_drop_obj(pdf_obj *obj)
{
if (!obj)
return;
if (--obj->refs)
return;
- if (obj->kind == FZ_ARRAY)
- fz_free_array(obj);
- else if (obj->kind == FZ_DICT)
- fz_free_dict(obj);
+ if (obj->kind == PDF_ARRAY)
+ pdf_free_array(obj);
+ else if (obj->kind == PDF_DICT)
+ pdf_free_dict(obj);
else
fz_free(obj->ctx, obj);
}
@@ -942,7 +943,7 @@ struct fmt
int last;
};
-static void fmt_obj(struct fmt *fmt, fz_obj *obj);
+static void fmt_obj(struct fmt *fmt, pdf_obj *obj);
static inline int iswhite(int ch)
{
@@ -1006,10 +1007,10 @@ static inline void fmt_sep(struct fmt *fmt)
fmt->sep = 1;
}
-static void fmt_str(struct fmt *fmt, fz_obj *obj)
+static void fmt_str(struct fmt *fmt, pdf_obj *obj)
{
- char *s = fz_to_str_buf(obj);
- int n = fz_to_str_len(obj);
+ char *s = pdf_to_str_buf(obj);
+ int n = pdf_to_str_len(obj);
int i, c;
fmt_putc(fmt, '(');
@@ -1042,10 +1043,10 @@ static void fmt_str(struct fmt *fmt, fz_obj *obj)
fmt_putc(fmt, ')');
}
-static void fmt_hex(struct fmt *fmt, fz_obj *obj)
+static void fmt_hex(struct fmt *fmt, pdf_obj *obj)
{
- char *s = fz_to_str_buf(obj);
- int n = fz_to_str_len(obj);
+ char *s = pdf_to_str_buf(obj);
+ int n = pdf_to_str_len(obj);
int i, b, c;
fmt_putc(fmt, '<');
@@ -1059,9 +1060,9 @@ static void fmt_hex(struct fmt *fmt, fz_obj *obj)
fmt_putc(fmt, '>');
}
-static void fmt_name(struct fmt *fmt, fz_obj *obj)
+static void fmt_name(struct fmt *fmt, pdf_obj *obj)
{
- unsigned char *s = (unsigned char *) fz_to_name(obj);
+ unsigned char *s = (unsigned char *) pdf_to_name(obj);
int i, c;
fmt_putc(fmt, '/');
@@ -1084,15 +1085,15 @@ static void fmt_name(struct fmt *fmt, fz_obj *obj)
}
}
-static void fmt_array(struct fmt *fmt, fz_obj *obj)
+static void fmt_array(struct fmt *fmt, pdf_obj *obj)
{
int i, n;
- n = fz_array_len(obj);
+ n = pdf_array_len(obj);
if (fmt->tight) {
fmt_putc(fmt, '[');
for (i = 0; i < n; i++) {
- fmt_obj(fmt, fz_array_get(obj, i));
+ fmt_obj(fmt, pdf_array_get(obj, i));
fmt_sep(fmt);
}
fmt_putc(fmt, ']');
@@ -1104,7 +1105,7 @@ static void fmt_array(struct fmt *fmt, fz_obj *obj)
fmt_putc(fmt, '\n');
fmt_indent(fmt);
}
- fmt_obj(fmt, fz_array_get(obj, i));
+ fmt_obj(fmt, pdf_array_get(obj, i));
fmt_putc(fmt, ' ');
}
fmt_putc(fmt, ']');
@@ -1112,18 +1113,18 @@ static void fmt_array(struct fmt *fmt, fz_obj *obj)
}
}
-static void fmt_dict(struct fmt *fmt, fz_obj *obj)
+static void fmt_dict(struct fmt *fmt, pdf_obj *obj)
{
int i, n;
- fz_obj *key, *val;
+ pdf_obj *key, *val;
- n = fz_dict_len(obj);
+ n = pdf_dict_len(obj);
if (fmt->tight) {
fmt_puts(fmt, "<<");
for (i = 0; i < n; i++) {
- fmt_obj(fmt, fz_dict_get_key(obj, i));
+ fmt_obj(fmt, pdf_dict_get_key(obj, i));
fmt_sep(fmt);
- fmt_obj(fmt, fz_dict_get_val(obj, i));
+ fmt_obj(fmt, pdf_dict_get_val(obj, i));
fmt_sep(fmt);
}
fmt_puts(fmt, ">>");
@@ -1132,16 +1133,16 @@ static void fmt_dict(struct fmt *fmt, fz_obj *obj)
fmt_puts(fmt, "<<\n");
fmt->indent ++;
for (i = 0; i < n; i++) {
- key = fz_dict_get_key(obj, i);
- val = fz_dict_get_val(obj, i);
+ key = pdf_dict_get_key(obj, i);
+ val = pdf_dict_get_val(obj, i);
fmt_indent(fmt);
fmt_obj(fmt, key);
fmt_putc(fmt, ' ');
- if (!fz_is_indirect(val) && fz_is_array(val))
+ if (!pdf_is_indirect(val) && pdf_is_array(val))
fmt->indent ++;
fmt_obj(fmt, val);
fmt_putc(fmt, '\n');
- if (!fz_is_indirect(val) && fz_is_array(val))
+ if (!pdf_is_indirect(val) && pdf_is_array(val))
fmt->indent --;
}
fmt->indent --;
@@ -1150,37 +1151,37 @@ static void fmt_dict(struct fmt *fmt, fz_obj *obj)
}
}
-static void fmt_obj(struct fmt *fmt, fz_obj *obj)
+static void fmt_obj(struct fmt *fmt, pdf_obj *obj)
{
char buf[256];
if (!obj)
fmt_puts(fmt, "<NULL>");
- else if (fz_is_indirect(obj))
+ else if (pdf_is_indirect(obj))
{
- sprintf(buf, "%d %d R", fz_to_num(obj), fz_to_gen(obj));
+ sprintf(buf, "%d %d R", pdf_to_num(obj), pdf_to_gen(obj));
fmt_puts(fmt, buf);
}
- else if (fz_is_null(obj))
+ else if (pdf_is_null(obj))
fmt_puts(fmt, "null");
- else if (fz_is_bool(obj))
- fmt_puts(fmt, fz_to_bool(obj) ? "true" : "false");
- else if (fz_is_int(obj))
+ else if (pdf_is_bool(obj))
+ fmt_puts(fmt, pdf_to_bool(obj) ? "true" : "false");
+ else if (pdf_is_int(obj))
{
- sprintf(buf, "%d", fz_to_int(obj));
+ sprintf(buf, "%d", pdf_to_int(obj));
fmt_puts(fmt, buf);
}
- else if (fz_is_real(obj))
+ else if (pdf_is_real(obj))
{
- sprintf(buf, "%g", fz_to_real(obj));
+ sprintf(buf, "%g", pdf_to_real(obj));
if (strchr(buf, 'e')) /* bad news! */
- sprintf(buf, fabsf(fz_to_real(obj)) > 1 ? "%1.1f" : "%1.8f", fz_to_real(obj));
+ sprintf(buf, fabsf(pdf_to_real(obj)) > 1 ? "%1.1f" : "%1.8f", pdf_to_real(obj));
fmt_puts(fmt, buf);
}
- else if (fz_is_string(obj))
+ else if (pdf_is_string(obj))
{
- char *str = fz_to_str_buf(obj);
- int len = fz_to_str_len(obj);
+ char *str = pdf_to_str_buf(obj);
+ int len = pdf_to_str_len(obj);
int added = 0;
int i, c;
for (i = 0; i < len; i++) {
@@ -1195,18 +1196,18 @@ static void fmt_obj(struct fmt *fmt, fz_obj *obj)
else
fmt_hex(fmt, obj);
}
- else if (fz_is_name(obj))
+ else if (pdf_is_name(obj))
fmt_name(fmt, obj);
- else if (fz_is_array(obj))
+ else if (pdf_is_array(obj))
fmt_array(fmt, obj);
- else if (fz_is_dict(obj))
+ else if (pdf_is_dict(obj))
fmt_dict(fmt, obj);
else
fmt_puts(fmt, "<unknown object>");
}
static int
-fz_sprint_obj(char *s, int n, fz_obj *obj, int tight)
+pdf_sprint_obj(char *s, int n, pdf_obj *obj, int tight)
{
struct fmt fmt;
@@ -1228,23 +1229,23 @@ fz_sprint_obj(char *s, int n, fz_obj *obj, int tight)
}
int
-fz_fprint_obj(FILE *fp, fz_obj *obj, int tight)
+pdf_fprint_obj(FILE *fp, pdf_obj *obj, int tight)
{
char buf[1024];
char *ptr;
int n;
- n = fz_sprint_obj(NULL, 0, obj, tight);
+ n = pdf_sprint_obj(NULL, 0, obj, tight);
if ((n + 1) < sizeof buf)
{
- fz_sprint_obj(buf, sizeof buf, obj, tight);
+ pdf_sprint_obj(buf, sizeof buf, obj, tight);
fputs(buf, fp);
fputc('\n', fp);
}
else
{
ptr = fz_malloc(obj->ctx, n + 1);
- fz_sprint_obj(ptr, n + 1, obj, tight);
+ pdf_sprint_obj(ptr, n + 1, obj, tight);
fputs(ptr, fp);
fputc('\n', fp);
fz_free(obj->ctx, ptr);
@@ -1253,13 +1254,13 @@ fz_fprint_obj(FILE *fp, fz_obj *obj, int tight)
}
void
-fz_debug_obj(fz_obj *obj)
+pdf_debug_obj(pdf_obj *obj)
{
- fz_fprint_obj(stdout, obj, 0);
+ pdf_fprint_obj(stdout, obj, 0);
}
void
-fz_debug_ref(fz_obj *ref)
+pdf_debug_ref(pdf_obj *ref)
{
- fz_debug_obj(fz_resolve_indirect(ref));
+ pdf_debug_obj(pdf_resolve_indirect(ref));
}
diff --git a/pdf/mupdf.h b/pdf/mupdf.h
index 93682083..5d775044 100644
--- a/pdf/mupdf.h
+++ b/pdf/mupdf.h
@@ -6,6 +6,85 @@
#endif
/*
+ * Dynamic objects.
+ * The same type of objects as found in PDF and PostScript.
+ * Used by the filters and the mupdf parser.
+ */
+
+typedef struct pdf_obj_s pdf_obj;
+
+pdf_obj *pdf_new_null(fz_context *ctx);
+pdf_obj *pdf_new_bool(fz_context *ctx, int b);
+pdf_obj *pdf_new_int(fz_context *ctx, int i);
+pdf_obj *pdf_new_real(fz_context *ctx, float f);
+pdf_obj *fz_new_name(fz_context *ctx, char *str);
+pdf_obj *pdf_new_string(fz_context *ctx, char *str, int len);
+pdf_obj *pdf_new_indirect(fz_context *ctx, int num, int gen, void *doc);
+
+pdf_obj *pdf_new_array(fz_context *ctx, int initialcap);
+pdf_obj *pdf_new_dict(fz_context *ctx, int initialcap);
+pdf_obj *pdf_copy_array(fz_context *ctx, pdf_obj *array);
+pdf_obj *pdf_copy_dict(fz_context *ctx, pdf_obj *dict);
+
+pdf_obj *pdf_keep_obj(pdf_obj *obj);
+void pdf_drop_obj(pdf_obj *obj);
+
+/* type queries */
+int pdf_is_null(pdf_obj *obj);
+int pdf_is_bool(pdf_obj *obj);
+int pdf_is_int(pdf_obj *obj);
+int pdf_is_real(pdf_obj *obj);
+int pdf_is_name(pdf_obj *obj);
+int pdf_is_string(pdf_obj *obj);
+int pdf_is_array(pdf_obj *obj);
+int pdf_is_dict(pdf_obj *obj);
+int pdf_is_indirect(pdf_obj *obj);
+
+int pdf_objcmp(pdf_obj *a, pdf_obj *b);
+
+/* dict marking and unmarking functions - to avoid infinite recursions */
+int pdf_dict_marked(pdf_obj *obj);
+int pdf_dict_mark(pdf_obj *obj);
+void pdf_dict_unmark(pdf_obj *obj);
+
+/* safe, silent failure, no error reporting on type mismatches */
+int pdf_to_bool(pdf_obj *obj);
+int pdf_to_int(pdf_obj *obj);
+float pdf_to_real(pdf_obj *obj);
+char *pdf_to_name(pdf_obj *obj);
+char *pdf_to_str_buf(pdf_obj *obj);
+pdf_obj *pdf_to_dict(pdf_obj *obj);
+int pdf_to_str_len(pdf_obj *obj);
+int pdf_to_num(pdf_obj *obj);
+int pdf_to_gen(pdf_obj *obj);
+
+int pdf_array_len(pdf_obj *array);
+pdf_obj *pdf_array_get(pdf_obj *array, int i);
+void pdf_array_put(pdf_obj *array, int i, pdf_obj *obj);
+void pdf_array_push(pdf_obj *array, pdf_obj *obj);
+void pdf_array_insert(pdf_obj *array, pdf_obj *obj);
+int pdf_array_contains(pdf_obj *array, pdf_obj *obj);
+
+int pdf_dict_len(pdf_obj *dict);
+pdf_obj *pdf_dict_get_key(pdf_obj *dict, int idx);
+pdf_obj *pdf_dict_get_val(pdf_obj *dict, int idx);
+pdf_obj *pdf_dict_get(pdf_obj *dict, pdf_obj *key);
+pdf_obj *pdf_dict_gets(pdf_obj *dict, char *key);
+pdf_obj *pdf_dict_getsa(pdf_obj *dict, char *key, char *abbrev);
+void fz_dict_put(pdf_obj *dict, pdf_obj *key, pdf_obj *val);
+void pdf_dict_puts(pdf_obj *dict, char *key, pdf_obj *val);
+void pdf_dict_del(pdf_obj *dict, pdf_obj *key);
+void pdf_dict_dels(pdf_obj *dict, char *key);
+void pdf_sort_dict(pdf_obj *dict);
+
+int pdf_fprint_obj(FILE *fp, pdf_obj *obj, int tight);
+void pdf_debug_obj(pdf_obj *obj);
+void pdf_debug_ref(pdf_obj *obj);
+
+void pdf_set_str_len(pdf_obj *obj, int newlen); /* private */
+void *pdf_get_indirect_document(pdf_obj *obj); /* private */
+
+/*
* PDF Images
*/
@@ -132,16 +211,16 @@ struct pdf_lexbuf_large_s
int pdf_lex(fz_stream *f, pdf_lexbuf *lexbuf);
-fz_obj *pdf_parse_array(pdf_document *doc, fz_stream *f, pdf_lexbuf *buf);
-fz_obj *pdf_parse_dict(pdf_document *doc, fz_stream *f, pdf_lexbuf *buf);
-fz_obj *pdf_parse_stm_obj(pdf_document *doc, fz_stream *f, pdf_lexbuf *buf);
-fz_obj *pdf_parse_ind_obj(pdf_document *doc, fz_stream *f, pdf_lexbuf *buf, int *num, int *gen, int *stm_ofs);
+pdf_obj *pdf_parse_array(pdf_document *doc, fz_stream *f, pdf_lexbuf *buf);
+pdf_obj *pdf_parse_dict(pdf_document *doc, fz_stream *f, pdf_lexbuf *buf);
+pdf_obj *pdf_parse_stm_obj(pdf_document *doc, fz_stream *f, pdf_lexbuf *buf);
+pdf_obj *pdf_parse_ind_obj(pdf_document *doc, fz_stream *f, pdf_lexbuf *buf, int *num, int *gen, int *stm_ofs);
-fz_rect pdf_to_rect(fz_context *ctx, fz_obj *array);
-fz_matrix pdf_to_matrix(fz_context *ctx, fz_obj *array);
-char *pdf_to_utf8(fz_context *ctx, fz_obj *src);
-unsigned short *pdf_to_ucs2(fz_context *ctx, fz_obj *src);
-fz_obj *pdf_to_utf8_name(fz_context *ctx, fz_obj *src);
+fz_rect pdf_to_rect(fz_context *ctx, pdf_obj *array);
+fz_matrix pdf_to_matrix(fz_context *ctx, pdf_obj *array);
+char *pdf_to_utf8(fz_context *ctx, pdf_obj *src);
+unsigned short *pdf_to_ucs2(fz_context *ctx, pdf_obj *src);
+pdf_obj *pdf_to_utf8_name(fz_context *ctx, pdf_obj *src);
char *pdf_from_ucs2(fz_context *ctx, unsigned short *str);
/*
@@ -158,7 +237,7 @@ struct pdf_xref_entry_s
int ofs; /* file offset / objstm object number */
int gen; /* generation / objstm index */
int stm_ofs; /* on-disk stream */
- fz_obj *obj; /* stored/cached object */
+ pdf_obj *obj; /* stored/cached object */
int type; /* 0=unset (f)ree i(n)use (o)bjstm */
};
@@ -173,7 +252,7 @@ struct pdf_ocg_descriptor_s
{
int len;
pdf_ocg_entry *ocgs;
- fz_obj *intent;
+ pdf_obj *intent;
};
struct pdf_document_s
@@ -187,7 +266,7 @@ struct pdf_document_s
int startxref;
int file_size;
pdf_crypt *crypt;
- fz_obj *trailer;
+ pdf_obj *trailer;
pdf_ocg_descriptor *ocg;
int len;
@@ -195,26 +274,26 @@ struct pdf_document_s
int page_len;
int page_cap;
- fz_obj **page_objs;
- fz_obj **page_refs;
+ pdf_obj **page_objs;
+ pdf_obj **page_refs;
pdf_lexbuf_large lexbuf;
};
-fz_obj *pdf_resolve_indirect(fz_obj *ref);
+pdf_obj *pdf_resolve_indirect(pdf_obj *ref);
void pdf_cache_object(pdf_document *doc, int num, int gen);
-fz_obj *pdf_load_object(pdf_document *doc, int num, int gen);
-void pdf_update_object(pdf_document *doc, int num, int gen, fz_obj *newobj);
+pdf_obj *pdf_load_object(pdf_document *doc, int num, int gen);
+void pdf_update_object(pdf_document *doc, int num, int gen, pdf_obj *newobj);
int pdf_is_stream(pdf_document *doc, int num, int gen);
-fz_stream *pdf_open_inline_stream(pdf_document *doc, fz_obj *stmobj, int length, fz_stream *chain, pdf_image_params *params);
+fz_stream *pdf_open_inline_stream(pdf_document *doc, pdf_obj *stmobj, int length, fz_stream *chain, pdf_image_params *params);
fz_buffer *pdf_load_raw_stream(pdf_document *doc, int num, int gen);
fz_buffer *pdf_load_stream(pdf_document *doc, int num, int gen);
fz_buffer *pdf_load_image_stream(pdf_document *doc, int num, int gen, pdf_image_params *params);
fz_stream *pdf_open_raw_stream(pdf_document *doc, int num, int gen);
fz_stream *pdf_open_image_stream(pdf_document *doc, int num, int gen, pdf_image_params *params);
fz_stream *pdf_open_stream(pdf_document *doc, int num, int gen);
-fz_stream *pdf_open_stream_with_offset(pdf_document *doc, int num, int gen, fz_obj *dict, int stm_ofs);
+fz_stream *pdf_open_stream_with_offset(pdf_document *doc, int num, int gen, pdf_obj *dict, int stm_ofs);
fz_stream *pdf_open_image_decomp_stream(fz_context *ctx, fz_buffer *, pdf_image_params *params, int *factor);
/*
@@ -280,10 +359,10 @@ enum
PDF_DEFAULT_PERM_FLAGS = 0xfffc
};
-pdf_crypt *pdf_new_crypt(fz_context *ctx, fz_obj *enc, fz_obj *id);
+pdf_crypt *pdf_new_crypt(fz_context *ctx, pdf_obj *enc, pdf_obj *id);
void pdf_free_crypt(fz_context *ctx, pdf_crypt *crypt);
-void pdf_crypt_obj(fz_context *ctx, pdf_crypt *crypt, fz_obj *obj, int num, int gen);
+void pdf_crypt_obj(fz_context *ctx, pdf_crypt *crypt, pdf_obj *obj, int num, int gen);
fz_stream *pdf_open_crypt(fz_stream *chain, pdf_crypt *crypt, int num, int gen);
fz_stream *pdf_open_crypt_with_filter(fz_stream *chain, pdf_crypt *crypt, char *name, int num, int gen);
@@ -304,20 +383,20 @@ void pdf_debug_crypt(pdf_crypt *crypt);
typedef struct pdf_function_s pdf_function;
-pdf_function *pdf_load_function(pdf_document *doc, fz_obj *ref);
+pdf_function *pdf_load_function(pdf_document *doc, pdf_obj *ref);
void pdf_eval_function(fz_context *ctx, pdf_function *func, float *in, int inlen, float *out, int outlen);
pdf_function *pdf_keep_function(fz_context *ctx, pdf_function *func);
void pdf_drop_function(fz_context *ctx, pdf_function *func);
unsigned int pdf_function_size(pdf_function *func);
-fz_colorspace *pdf_load_colorspace(pdf_document *doc, fz_obj *obj);
+fz_colorspace *pdf_load_colorspace(pdf_document *doc, pdf_obj *obj);
fz_pixmap *pdf_expand_indexed_pixmap(fz_context *ctx, fz_pixmap *src);
-fz_shade *pdf_load_shading(pdf_document *doc, fz_obj *obj);
+fz_shade *pdf_load_shading(pdf_document *doc, pdf_obj *obj);
-fz_image *pdf_load_inline_image(pdf_document *doc, fz_obj *rdb, fz_obj *dict, fz_stream *file);
-fz_image *pdf_load_image(pdf_document *doc, fz_obj *obj);
-int pdf_is_jpx_image(fz_context *ctx, fz_obj *dict);
+fz_image *pdf_load_inline_image(pdf_document *doc, pdf_obj *rdb, pdf_obj *dict, fz_stream *file);
+fz_image *pdf_load_image(pdf_document *doc, pdf_obj *obj);
+int pdf_is_jpx_image(fz_context *ctx, pdf_obj *dict);
/*
* Pattern
@@ -333,11 +412,11 @@ struct pdf_pattern_s
float ystep;
fz_matrix matrix;
fz_rect bbox;
- fz_obj *resources;
+ pdf_obj *resources;
fz_buffer *contents;
};
-pdf_pattern *pdf_load_pattern(pdf_document *doc, fz_obj *obj);
+pdf_pattern *pdf_load_pattern(pdf_document *doc, pdf_obj *obj);
pdf_pattern *pdf_keep_pattern(fz_context *ctx, pdf_pattern *pat);
void pdf_drop_pattern(fz_context *ctx, pdf_pattern *pat);
@@ -356,12 +435,12 @@ struct pdf_xobject_s
int knockout;
int transparency;
fz_colorspace *colorspace;
- fz_obj *resources;
+ pdf_obj *resources;
fz_buffer *contents;
- fz_obj *me;
+ pdf_obj *me;
};
-pdf_xobject *pdf_load_xobject(pdf_document *doc, fz_obj *obj);
+pdf_xobject *pdf_load_xobject(pdf_document *doc, pdf_obj *obj);
pdf_xobject *pdf_keep_xobject(fz_context *ctx, pdf_xobject *xobj);
void pdf_drop_xobject(fz_context *ctx, pdf_xobject *xobj);
@@ -434,7 +513,7 @@ pdf_cmap *pdf_new_identity_cmap(fz_context *ctx, int wmode, int bytes);
pdf_cmap *pdf_load_cmap(fz_context *ctx, fz_stream *file);
pdf_cmap *pdf_load_system_cmap(fz_context *ctx, char *name);
pdf_cmap *pdf_load_builtin_cmap(fz_context *ctx, char *name);
-pdf_cmap *pdf_load_embedded_cmap(pdf_document *doc, fz_obj *ref);
+pdf_cmap *pdf_load_embedded_cmap(pdf_document *doc, pdf_obj *ref);
/*
* Font
@@ -536,7 +615,7 @@ void pdf_end_vmtx(fz_context *ctx, pdf_font_desc *font);
pdf_hmtx pdf_get_hmtx(fz_context *ctx, pdf_font_desc *font, int cid);
pdf_vmtx pdf_get_vmtx(fz_context *ctx, pdf_font_desc *font, int cid);
-void pdf_load_to_unicode(pdf_document *doc, pdf_font_desc *font, char **strings, char *collection, fz_obj *cmapstm);
+void pdf_load_to_unicode(pdf_document *doc, pdf_font_desc *font, char **strings, char *collection, pdf_obj *cmapstm);
int pdf_font_cid_to_gid(fz_context *ctx, pdf_font_desc *fontdesc, int cid);
@@ -544,8 +623,8 @@ unsigned char *pdf_find_builtin_font(char *name, unsigned int *len);
unsigned char *pdf_find_substitute_font(int mono, int serif, int bold, int italic, unsigned int *len);
unsigned char *pdf_find_substitute_cjk_font(int ros, int serif, unsigned int *len);
-pdf_font_desc *pdf_load_type3_font(pdf_document *doc, fz_obj *rdb, fz_obj *obj);
-pdf_font_desc *pdf_load_font(pdf_document *doc, fz_obj *rdb, fz_obj *obj);
+pdf_font_desc *pdf_load_type3_font(pdf_document *doc, pdf_obj *rdb, pdf_obj *obj);
+pdf_font_desc *pdf_load_font(pdf_document *doc, pdf_obj *rdb, pdf_obj *obj);
pdf_font_desc *pdf_new_font_desc(fz_context *ctx);
pdf_font_desc *pdf_keep_font(fz_context *ctx, pdf_font_desc *fontdesc);
@@ -561,24 +640,24 @@ typedef struct pdf_annot_s pdf_annot;
struct pdf_annot_s
{
- fz_obj *obj;
+ pdf_obj *obj;
fz_rect rect;
pdf_xobject *ap;
fz_matrix matrix;
pdf_annot *next;
};
-fz_link_dest pdf_parse_link_dest(pdf_document *doc, fz_obj *dest);
-fz_link_dest pdf_parse_action(pdf_document *doc, fz_obj *action);
-fz_obj *pdf_lookup_dest(pdf_document *doc, fz_obj *needle);
-fz_obj *pdf_lookup_name(pdf_document *doc, char *which, fz_obj *needle);
-fz_obj *pdf_load_name_tree(pdf_document *doc, char *which);
+fz_link_dest pdf_parse_link_dest(pdf_document *doc, pdf_obj *dest);
+fz_link_dest pdf_parse_action(pdf_document *doc, pdf_obj *action);
+pdf_obj *pdf_lookup_dest(pdf_document *doc, pdf_obj *needle);
+pdf_obj *pdf_lookup_name(pdf_document *doc, char *which, pdf_obj *needle);
+pdf_obj *pdf_load_name_tree(pdf_document *doc, char *which);
fz_outline *pdf_load_outline(pdf_document *doc);
-fz_link *pdf_load_link_annots(pdf_document *, fz_obj *annots, fz_matrix page_ctm);
+fz_link *pdf_load_link_annots(pdf_document *, pdf_obj *annots, fz_matrix page_ctm);
-pdf_annot *pdf_load_annots(pdf_document *, fz_obj *annots);
+pdf_annot *pdf_load_annots(pdf_document *, pdf_obj *annots);
void pdf_free_annot(fz_context *ctx, pdf_annot *link);
/*
@@ -593,13 +672,13 @@ struct pdf_page_s
fz_rect mediabox;
int rotate;
int transparency;
- fz_obj *resources;
+ pdf_obj *resources;
fz_buffer *contents;
fz_link *links;
pdf_annot *annots;
};
-int pdf_find_page_number(pdf_document *doc, fz_obj *pageobj);
+int pdf_find_page_number(pdf_document *doc, pdf_obj *pageobj);
int pdf_count_pages(pdf_document *doc);
/*
@@ -652,14 +731,14 @@ void pdf_free_page(pdf_document *doc, pdf_page *page);
void pdf_run_page(pdf_document *doc, pdf_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie);
void pdf_run_page_with_usage(pdf_document *doc, pdf_page *page, fz_device *dev, fz_matrix ctm, char *event, fz_cookie *cookie);
-void pdf_run_glyph(pdf_document *doc, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate);
+void pdf_run_glyph(pdf_document *doc, pdf_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate);
/*
* PDF interface to store
*/
-void pdf_store_item(fz_context *ctx, fz_obj *key, void *val, unsigned int itemsize);
-void *pdf_find_item(fz_context *ctx, fz_store_free_fn *free, fz_obj *key);
-void pdf_remove_item(fz_context *ctx, fz_store_free_fn *free, fz_obj *key);
+void pdf_store_item(fz_context *ctx, pdf_obj *key, void *val, unsigned int itemsize);
+void *pdf_find_item(fz_context *ctx, fz_store_free_fn *free, pdf_obj *key);
+void pdf_remove_item(fz_context *ctx, fz_store_free_fn *free, pdf_obj *key);
#endif
diff --git a/pdf/pdf_annot.c b/pdf/pdf_annot.c
index ae03f2b6..81e5d887 100644
--- a/pdf/pdf_annot.c
+++ b/pdf/pdf_annot.c
@@ -1,46 +1,46 @@
#include "fitz.h"
#include "mupdf.h"
-static fz_obj *
-resolve_dest_rec(pdf_document *xref, fz_obj *dest, int depth)
+static pdf_obj *
+resolve_dest_rec(pdf_document *xref, pdf_obj *dest, int depth)
{
if (depth > 10) /* Arbitrary to avoid infinite recursion */
return NULL;
- if (fz_is_name(dest) || fz_is_string(dest))
+ if (pdf_is_name(dest) || pdf_is_string(dest))
{
dest = pdf_lookup_dest(xref, dest);
return resolve_dest_rec(xref, dest, depth+1);
}
- else if (fz_is_array(dest))
+ else if (pdf_is_array(dest))
{
return dest;
}
- else if (fz_is_dict(dest))
+ else if (pdf_is_dict(dest))
{
- dest = fz_dict_gets(dest, "D");
+ dest = pdf_dict_gets(dest, "D");
return resolve_dest_rec(xref, dest, depth+1);
}
- else if (fz_is_indirect(dest))
+ else if (pdf_is_indirect(dest))
return dest;
return NULL;
}
-static fz_obj *
-resolve_dest(pdf_document *xref, fz_obj *dest)
+static pdf_obj *
+resolve_dest(pdf_document *xref, pdf_obj *dest)
{
return resolve_dest_rec(xref, dest, 0);
}
fz_link_dest
-pdf_parse_link_dest(pdf_document *xref, fz_obj *dest)
+pdf_parse_link_dest(pdf_document *xref, pdf_obj *dest)
{
fz_link_dest ld;
- fz_obj *obj;
+ pdf_obj *obj;
int l_from_2 = 0;
int b_from_3 = 0;
@@ -51,14 +51,14 @@ pdf_parse_link_dest(pdf_document *xref, fz_obj *dest)
int z_from_4 = 0;
dest = resolve_dest(xref, dest);
- if (dest == NULL || !fz_is_array(dest))
+ if (dest == NULL || !pdf_is_array(dest))
{
ld.kind = FZ_LINK_NONE;
return ld;
}
- obj = fz_array_get(dest, 0);
- if (fz_is_int(obj))
- ld.ld.gotor.page = fz_to_int(obj);
+ obj = pdf_array_get(dest, 0);
+ if (pdf_is_int(obj))
+ ld.ld.gotor.page = pdf_to_int(obj);
else
ld.ld.gotor.page = pdf_find_page_number(xref, obj);
@@ -71,31 +71,31 @@ pdf_parse_link_dest(pdf_document *xref, fz_obj *dest)
ld.ld.gotor.file_spec = NULL;
ld.ld.gotor.new_window = 0;
- obj = fz_array_get(dest, 1);
- if (!fz_is_name(obj))
+ obj = pdf_array_get(dest, 1);
+ if (!pdf_is_name(obj))
return ld;
- if (!strcmp("XYZ", fz_to_name(obj)))
+ if (!strcmp("XYZ", pdf_to_name(obj)))
{
l_from_2 = t_from_3 = z_from_4 = 1;
ld.ld.gotor.flags |= fz_link_flag_r_is_zoom;
}
- else if ((!strcmp("Fit", fz_to_name(obj))) || (!strcmp("FitB", fz_to_name(obj))))
+ else if ((!strcmp("Fit", pdf_to_name(obj))) || (!strcmp("FitB", pdf_to_name(obj))))
{
ld.ld.gotor.flags |= fz_link_flag_fit_h;
ld.ld.gotor.flags |= fz_link_flag_fit_v;
}
- else if ((!strcmp("FitH", fz_to_name(obj))) || (!strcmp("FitBH", fz_to_name(obj))))
+ else if ((!strcmp("FitH", pdf_to_name(obj))) || (!strcmp("FitBH", pdf_to_name(obj))))
{
t_from_2 = 1;
ld.ld.gotor.flags |= fz_link_flag_fit_h;
}
- else if ((!strcmp("FitV", fz_to_name(obj))) || (!strcmp("FitBV", fz_to_name(obj))))
+ else if ((!strcmp("FitV", pdf_to_name(obj))) || (!strcmp("FitBV", pdf_to_name(obj))))
{
l_from_2 = 1;
ld.ld.gotor.flags |= fz_link_flag_fit_v;
}
- else if (!strcmp("FitR", fz_to_name(obj)))
+ else if (!strcmp("FitR", pdf_to_name(obj)))
{
l_from_2 = b_from_3 = r_from_4 = t_from_5 = 1;
ld.ld.gotor.flags |= fz_link_flag_fit_h;
@@ -104,77 +104,77 @@ pdf_parse_link_dest(pdf_document *xref, fz_obj *dest)
if (l_from_2)
{
- obj = fz_array_get(dest, 2);
- if (fz_is_int(obj))
+ obj = pdf_array_get(dest, 2);
+ if (pdf_is_int(obj))
{
ld.ld.gotor.flags |= fz_link_flag_l_valid;
- ld.ld.gotor.lt.x = fz_to_int(obj);
+ ld.ld.gotor.lt.x = pdf_to_int(obj);
}
- else if (fz_is_real(obj))
+ else if (pdf_is_real(obj))
{
ld.ld.gotor.flags |= fz_link_flag_l_valid;
- ld.ld.gotor.lt.x = fz_to_real(obj);
+ ld.ld.gotor.lt.x = pdf_to_real(obj);
}
}
if (b_from_3)
{
- obj = fz_array_get(dest, 3);
- if (fz_is_int(obj))
+ obj = pdf_array_get(dest, 3);
+ if (pdf_is_int(obj))
{
ld.ld.gotor.flags |= fz_link_flag_b_valid;
- ld.ld.gotor.rb.y = fz_to_int(obj);
+ ld.ld.gotor.rb.y = pdf_to_int(obj);
}
- else if (fz_is_real(obj))
+ else if (pdf_is_real(obj))
{
ld.ld.gotor.flags |= fz_link_flag_b_valid;
- ld.ld.gotor.rb.y = fz_to_real(obj);
+ ld.ld.gotor.rb.y = pdf_to_real(obj);
}
}
if (r_from_4)
{
- obj = fz_array_get(dest, 4);
- if (fz_is_int(obj))
+ obj = pdf_array_get(dest, 4);
+ if (pdf_is_int(obj))
{
ld.ld.gotor.flags |= fz_link_flag_r_valid;
- ld.ld.gotor.rb.x = fz_to_int(obj);
+ ld.ld.gotor.rb.x = pdf_to_int(obj);
}
- else if (fz_is_real(obj))
+ else if (pdf_is_real(obj))
{
ld.ld.gotor.flags |= fz_link_flag_r_valid;
- ld.ld.gotor.rb.x = fz_to_real(obj);
+ ld.ld.gotor.rb.x = pdf_to_real(obj);
}
}
if (t_from_5 || t_from_3 || t_from_2)
{
if (t_from_5)
- obj = fz_array_get(dest, 5);
+ obj = pdf_array_get(dest, 5);
else if (t_from_3)
- obj = fz_array_get(dest, 3);
+ obj = pdf_array_get(dest, 3);
else
- obj = fz_array_get(dest, 2);
- if (fz_is_int(obj))
+ obj = pdf_array_get(dest, 2);
+ if (pdf_is_int(obj))
{
ld.ld.gotor.flags |= fz_link_flag_t_valid;
- ld.ld.gotor.lt.y = fz_to_int(obj);
+ ld.ld.gotor.lt.y = pdf_to_int(obj);
}
- else if (fz_is_real(obj))
+ else if (pdf_is_real(obj))
{
ld.ld.gotor.flags |= fz_link_flag_t_valid;
- ld.ld.gotor.lt.y = fz_to_real(obj);
+ ld.ld.gotor.lt.y = pdf_to_real(obj);
}
}
if (z_from_4)
{
- obj = fz_array_get(dest, 4);
- if (fz_is_int(obj))
+ obj = pdf_array_get(dest, 4);
+ if (pdf_is_int(obj))
{
ld.ld.gotor.flags |= fz_link_flag_r_valid;
- ld.ld.gotor.rb.x = fz_to_int(obj);
+ ld.ld.gotor.rb.x = pdf_to_int(obj);
}
- else if (fz_is_real(obj))
+ else if (pdf_is_real(obj))
{
ld.ld.gotor.flags |= fz_link_flag_r_valid;
- ld.ld.gotor.rb.x = fz_to_real(obj);
+ ld.ld.gotor.rb.x = pdf_to_real(obj);
}
}
@@ -192,10 +192,10 @@ pdf_parse_link_dest(pdf_document *xref, fz_obj *dest)
}
fz_link_dest
-pdf_parse_action(pdf_document *xref, fz_obj *action)
+pdf_parse_action(pdf_document *xref, pdf_obj *action)
{
fz_link_dest ld;
- fz_obj *obj, *dest;
+ pdf_obj *obj, *dest;
fz_context *ctx = xref->ctx;
ld.kind = FZ_LINK_NONE;
@@ -203,53 +203,53 @@ pdf_parse_action(pdf_document *xref, fz_obj *action)
if (!action)
return ld;
- obj = fz_dict_gets(action, "S");
- if (!strcmp(fz_to_name(obj), "GoTo"))
+ obj = pdf_dict_gets(action, "S");
+ if (!strcmp(pdf_to_name(obj), "GoTo"))
{
- dest = fz_dict_gets(action, "D");
+ dest = pdf_dict_gets(action, "D");
ld = pdf_parse_link_dest(xref, dest);
}
- else if (!strcmp(fz_to_name(obj), "URI"))
+ else if (!strcmp(pdf_to_name(obj), "URI"))
{
ld.kind = FZ_LINK_URI;
- ld.ld.uri.is_map = fz_to_bool(fz_dict_gets(action, "IsMap"));
- ld.ld.uri.uri = pdf_to_utf8(ctx, fz_dict_gets(action, "URI"));
+ ld.ld.uri.is_map = pdf_to_bool(pdf_dict_gets(action, "IsMap"));
+ ld.ld.uri.uri = pdf_to_utf8(ctx, pdf_dict_gets(action, "URI"));
}
- else if (!strcmp(fz_to_name(obj), "Launch"))
+ else if (!strcmp(pdf_to_name(obj), "Launch"))
{
ld.kind = FZ_LINK_LAUNCH;
- ld.ld.launch.file_spec = pdf_to_utf8(ctx, fz_dict_gets(action, "F"));
- ld.ld.launch.new_window = fz_to_int(fz_dict_gets(action, "NewWindow"));
+ ld.ld.launch.file_spec = pdf_to_utf8(ctx, pdf_dict_gets(action, "F"));
+ ld.ld.launch.new_window = pdf_to_int(pdf_dict_gets(action, "NewWindow"));
}
- else if (!strcmp(fz_to_name(obj), "Named"))
+ else if (!strcmp(pdf_to_name(obj), "Named"))
{
ld.kind = FZ_LINK_NAMED;
- ld.ld.named.named = pdf_to_utf8(ctx, fz_dict_gets(action, "N"));
+ ld.ld.named.named = pdf_to_utf8(ctx, pdf_dict_gets(action, "N"));
}
- else if (!strcmp(fz_to_name(obj), "GoToR"))
+ else if (!strcmp(pdf_to_name(obj), "GoToR"))
{
- dest = fz_dict_gets(action, "D");
+ dest = pdf_dict_gets(action, "D");
ld = pdf_parse_link_dest(xref, dest);
ld.kind = FZ_LINK_GOTOR;
- ld.ld.gotor.file_spec = pdf_to_utf8(ctx, fz_dict_gets(action, "F"));
- ld.ld.gotor.new_window = fz_to_int(fz_dict_gets(action, "NewWindow"));
+ ld.ld.gotor.file_spec = pdf_to_utf8(ctx, pdf_dict_gets(action, "F"));
+ ld.ld.gotor.new_window = pdf_to_int(pdf_dict_gets(action, "NewWindow"));
}
return ld;
}
static fz_link *
-pdf_load_link(pdf_document *xref, fz_obj *dict, fz_matrix page_ctm)
+pdf_load_link(pdf_document *xref, pdf_obj *dict, fz_matrix page_ctm)
{
- fz_obj *dest = NULL;
- fz_obj *action;
- fz_obj *obj;
+ pdf_obj *dest = NULL;
+ pdf_obj *action;
+ pdf_obj *obj;
fz_rect bbox;
fz_context *ctx = xref->ctx;
fz_link_dest ld;
dest = NULL;
- obj = fz_dict_gets(dict, "Rect");
+ obj = pdf_dict_gets(dict, "Rect");
if (obj)
bbox = pdf_to_rect(ctx, obj);
else
@@ -257,7 +257,7 @@ pdf_load_link(pdf_document *xref, fz_obj *dict, fz_matrix page_ctm)
bbox = fz_transform_rect(page_ctm, bbox);
- obj = fz_dict_gets(dict, "Dest");
+ obj = pdf_dict_gets(dict, "Dest");
if (obj)
{
dest = resolve_dest(xref, obj);
@@ -265,10 +265,10 @@ pdf_load_link(pdf_document *xref, fz_obj *dict, fz_matrix page_ctm)
}
else
{
- action = fz_dict_gets(dict, "A");
+ action = pdf_dict_gets(dict, "A");
/* fall back to additional action button's down/up action */
if (!action)
- action = fz_dict_getsa(fz_dict_gets(dict, "AA"), "U", "D");
+ action = pdf_dict_getsa(pdf_dict_gets(dict, "AA"), "U", "D");
ld = pdf_parse_action(xref, action);
}
@@ -278,19 +278,19 @@ pdf_load_link(pdf_document *xref, fz_obj *dict, fz_matrix page_ctm)
}
fz_link *
-pdf_load_link_annots(pdf_document *xref, fz_obj *annots, fz_matrix page_ctm)
+pdf_load_link_annots(pdf_document *xref, pdf_obj *annots, fz_matrix page_ctm)
{
fz_link *link, *head, *tail;
- fz_obj *obj;
+ pdf_obj *obj;
int i, n;
head = tail = NULL;
link = NULL;
- n = fz_array_len(annots);
+ n = pdf_array_len(annots);
for (i = 0; i < n; i++)
{
- obj = fz_array_get(annots, i);
+ obj = pdf_array_get(annots, i);
link = pdf_load_link(xref, obj, page_ctm);
if (link)
{
@@ -318,7 +318,7 @@ pdf_free_annot(fz_context *ctx, pdf_annot *annot)
if (annot->ap)
pdf_drop_xobject(ctx, annot->ap);
if (annot->obj)
- fz_drop_obj(annot->obj);
+ pdf_drop_obj(annot->obj);
fz_free(ctx, annot);
annot = next;
}
@@ -349,10 +349,10 @@ pdf_transform_annot(pdf_annot *annot)
}
pdf_annot *
-pdf_load_annots(pdf_document *xref, fz_obj *annots)
+pdf_load_annots(pdf_document *xref, pdf_obj *annots)
{
pdf_annot *annot, *head, *tail;
- fz_obj *obj, *ap, *as, *n, *rect;
+ pdf_obj *obj, *ap, *as, *n, *rect;
pdf_xobject *form;
int i, len;
fz_context *ctx = xref->ctx;
@@ -360,23 +360,23 @@ pdf_load_annots(pdf_document *xref, fz_obj *annots)
head = tail = NULL;
annot = NULL;
- len = fz_array_len(annots);
+ len = pdf_array_len(annots);
for (i = 0; i < len; i++)
{
- obj = fz_array_get(annots, i);
+ obj = pdf_array_get(annots, i);
- rect = fz_dict_gets(obj, "Rect");
- ap = fz_dict_gets(obj, "AP");
- as = fz_dict_gets(obj, "AS");
- if (fz_is_dict(ap))
+ rect = pdf_dict_gets(obj, "Rect");
+ ap = pdf_dict_gets(obj, "AP");
+ as = pdf_dict_gets(obj, "AS");
+ if (pdf_is_dict(ap))
{
- n = fz_dict_gets(ap, "N"); /* normal state */
+ n = pdf_dict_gets(ap, "N"); /* normal state */
/* lookup current state in sub-dictionary */
- if (!pdf_is_stream(xref, fz_to_num(n), fz_to_gen(n)))
- n = fz_dict_get(n, as);
+ if (!pdf_is_stream(xref, pdf_to_num(n), pdf_to_gen(n)))
+ n = pdf_dict_get(n, as);
- if (pdf_is_stream(xref, fz_to_num(n), fz_to_gen(n)))
+ if (pdf_is_stream(xref, pdf_to_num(n), pdf_to_gen(n)))
{
fz_try(ctx)
{
@@ -389,7 +389,7 @@ pdf_load_annots(pdf_document *xref, fz_obj *annots)
}
annot = fz_malloc_struct(ctx, pdf_annot);
- annot->obj = fz_keep_obj(obj);
+ annot->obj = pdf_keep_obj(obj);
annot->rect = pdf_to_rect(ctx, rect);
annot->ap = form;
annot->next = NULL;
diff --git a/pdf/pdf_cmap_load.c b/pdf/pdf_cmap_load.c
index 9e6b13ce..d4e161c8 100644
--- a/pdf/pdf_cmap_load.c
+++ b/pdf/pdf_cmap_load.c
@@ -16,13 +16,13 @@ pdf_cmap_size(fz_context *ctx, pdf_cmap *cmap)
* Load CMap stream in PDF file
*/
pdf_cmap *
-pdf_load_embedded_cmap(pdf_document *xref, fz_obj *stmobj)
+pdf_load_embedded_cmap(pdf_document *xref, pdf_obj *stmobj)
{
fz_stream *file = NULL;
pdf_cmap *cmap = NULL;
pdf_cmap *usecmap;
- fz_obj *wmode;
- fz_obj *obj = NULL;
+ pdf_obj *wmode;
+ pdf_obj *obj = NULL;
fz_context *ctx = xref->ctx;
int phase = 0;
@@ -38,24 +38,24 @@ pdf_load_embedded_cmap(pdf_document *xref, fz_obj *stmobj)
fz_try(ctx)
{
- file = pdf_open_stream(xref, fz_to_num(stmobj), fz_to_gen(stmobj));
+ file = pdf_open_stream(xref, pdf_to_num(stmobj), pdf_to_gen(stmobj));
phase = 1;
cmap = pdf_load_cmap(ctx, file);
phase = 2;
fz_close(file);
file = NULL;
- wmode = fz_dict_gets(stmobj, "WMode");
- if (fz_is_int(wmode))
- pdf_set_wmode(ctx, cmap, fz_to_int(wmode));
- obj = fz_dict_gets(stmobj, "UseCMap");
- if (fz_is_name(obj))
+ wmode = pdf_dict_gets(stmobj, "WMode");
+ if (pdf_is_int(wmode))
+ pdf_set_wmode(ctx, cmap, pdf_to_int(wmode));
+ obj = pdf_dict_gets(stmobj, "UseCMap");
+ if (pdf_is_name(obj))
{
- usecmap = pdf_load_system_cmap(ctx, fz_to_name(obj));
+ usecmap = pdf_load_system_cmap(ctx, pdf_to_name(obj));
pdf_set_usecmap(ctx, cmap, usecmap);
pdf_drop_cmap(ctx, usecmap);
}
- else if (fz_is_indirect(obj))
+ else if (pdf_is_indirect(obj))
{
phase = 3;
usecmap = pdf_load_embedded_cmap(xref, obj);
@@ -72,13 +72,13 @@ pdf_load_embedded_cmap(pdf_document *xref, fz_obj *stmobj)
if (cmap)
pdf_drop_cmap(ctx, cmap);
if (phase < 1)
- fz_throw(ctx, "cannot open cmap stream (%d %d R)", fz_to_num(stmobj), fz_to_gen(stmobj));
+ fz_throw(ctx, "cannot open cmap stream (%d %d R)", pdf_to_num(stmobj), pdf_to_gen(stmobj));
else if (phase < 2)
- fz_throw(ctx, "cannot parse cmap stream (%d %d R)", fz_to_num(stmobj), fz_to_gen(stmobj));
+ fz_throw(ctx, "cannot parse cmap stream (%d %d R)", pdf_to_num(stmobj), pdf_to_gen(stmobj));
else if (phase < 3)
- fz_throw(ctx, "cannot load system usecmap '%s'", fz_to_name(obj));
+ fz_throw(ctx, "cannot load system usecmap '%s'", pdf_to_name(obj));
else
- fz_throw(ctx, "cannot load embedded usecmap (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
+ fz_throw(ctx, "cannot load embedded usecmap (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj));
}
return cmap;
diff --git a/pdf/pdf_colorspace.c b/pdf/pdf_colorspace.c
index a6515d42..0e9423b4 100644
--- a/pdf/pdf_colorspace.c
+++ b/pdf/pdf_colorspace.c
@@ -4,11 +4,11 @@
/* ICCBased */
static fz_colorspace *
-load_icc_based(pdf_document *xref, fz_obj *dict)
+load_icc_based(pdf_document *xref, pdf_obj *dict)
{
int n;
- n = fz_to_int(fz_dict_gets(dict, "N"));
+ n = pdf_to_int(pdf_dict_gets(dict, "N"));
switch (n)
{
@@ -91,14 +91,14 @@ free_separation(fz_context *ctx, fz_colorspace *cs)
}
static fz_colorspace *
-load_separation(pdf_document *xref, fz_obj *array)
+load_separation(pdf_document *xref, pdf_obj *array)
{
fz_colorspace *cs;
struct separation *sep = NULL;
fz_context *ctx = xref->ctx;
- fz_obj *nameobj = fz_array_get(array, 1);
- fz_obj *baseobj = fz_array_get(array, 2);
- fz_obj *tintobj = fz_array_get(array, 3);
+ pdf_obj *nameobj = pdf_array_get(array, 1);
+ pdf_obj *baseobj = pdf_array_get(array, 2);
+ pdf_obj *tintobj = pdf_array_get(array, 3);
fz_colorspace *base;
pdf_function *tint = NULL;
int n;
@@ -106,8 +106,8 @@ load_separation(pdf_document *xref, fz_obj *array)
fz_var(tint);
fz_var(sep);
- if (fz_is_array(nameobj))
- n = fz_array_len(nameobj);
+ if (pdf_is_array(nameobj))
+ n = pdf_array_len(nameobj);
else
n = 1;
@@ -115,13 +115,13 @@ load_separation(pdf_document *xref, fz_obj *array)
fz_throw(ctx, "too many components in colorspace");
base = pdf_load_colorspace(xref, baseobj);
- /* RJW: "cannot load base colorspace (%d %d R)", fz_to_num(baseobj), fz_to_gen(baseobj) */
+ /* RJW: "cannot load base colorspace (%d %d R)", pdf_to_num(baseobj), pdf_to_gen(baseobj) */
fz_try(ctx)
{
tint = pdf_load_function(xref, tintobj);
/* RJW: fz_drop_colorspace(ctx, base);
- * "cannot load tint function (%d %d R)", fz_to_num(tintobj), fz_to_gen(tintobj) */
+ * "cannot load tint function (%d %d R)", pdf_to_num(tintobj), pdf_to_gen(tintobj) */
sep = fz_malloc_struct(ctx, struct separation);
sep->base = base;
@@ -218,13 +218,13 @@ pdf_expand_indexed_pixmap(fz_context *ctx, fz_pixmap *src)
}
static fz_colorspace *
-load_indexed(pdf_document *xref, fz_obj *array)
+load_indexed(pdf_document *xref, pdf_obj *array)
{
struct indexed *idx = NULL;
fz_context *ctx = xref->ctx;
- fz_obj *baseobj = fz_array_get(array, 1);
- fz_obj *highobj = fz_array_get(array, 2);
- fz_obj *lookup = fz_array_get(array, 3);
+ pdf_obj *baseobj = pdf_array_get(array, 1);
+ pdf_obj *highobj = pdf_array_get(array, 2);
+ pdf_obj *lookup = pdf_array_get(array, 3);
fz_colorspace *base = NULL;
fz_colorspace *cs = NULL;
int i, n;
@@ -236,12 +236,12 @@ load_indexed(pdf_document *xref, fz_obj *array)
fz_try(ctx)
{
base = pdf_load_colorspace(xref, baseobj);
- /* "cannot load base colorspace (%d %d R)", fz_to_num(baseobj), fz_to_gen(baseobj) */
+ /* "cannot load base colorspace (%d %d R)", pdf_to_num(baseobj), pdf_to_gen(baseobj) */
idx = fz_malloc_struct(ctx, struct indexed);
idx->lookup = NULL;
idx->base = base;
- idx->high = fz_to_int(highobj);
+ idx->high = pdf_to_int(highobj);
idx->high = CLAMP(idx->high, 0, 255);
n = base->n * (idx->high + 1);
idx->lookup = fz_malloc_array(ctx, 1, n);
@@ -252,30 +252,30 @@ load_indexed(pdf_document *xref, fz_obj *array)
cs->data = idx;
cs->size += sizeof(*idx) + n + (base ? base->size : 0);
- if (fz_is_string(lookup) && fz_to_str_len(lookup) == n)
+ if (pdf_is_string(lookup) && pdf_to_str_len(lookup) == n)
{
- unsigned char *buf = (unsigned char *) fz_to_str_buf(lookup);
+ unsigned char *buf = (unsigned char *) pdf_to_str_buf(lookup);
for (i = 0; i < n; i++)
idx->lookup[i] = buf[i];
}
- else if (fz_is_indirect(lookup))
+ else if (pdf_is_indirect(lookup))
{
fz_stream *file = NULL;
fz_try(ctx)
{
- file = pdf_open_stream(xref, fz_to_num(lookup), fz_to_gen(lookup));
+ file = pdf_open_stream(xref, pdf_to_num(lookup), pdf_to_gen(lookup));
}
fz_catch(ctx)
{
- fz_throw(ctx, "cannot open colorspace lookup table (%d 0 R)", fz_to_num(lookup));
+ fz_throw(ctx, "cannot open colorspace lookup table (%d 0 R)", pdf_to_num(lookup));
}
i = fz_read(file, idx->lookup, n);
if (i < 0)
{
fz_close(file);
- fz_throw(ctx, "cannot read colorspace lookup table (%d 0 R)", fz_to_num(lookup));
+ fz_throw(ctx, "cannot read colorspace lookup table (%d 0 R)", pdf_to_num(lookup));
}
fz_close(file);
@@ -304,93 +304,93 @@ load_indexed(pdf_document *xref, fz_obj *array)
/* Parse and create colorspace from PDF object */
static fz_colorspace *
-pdf_load_colorspace_imp(pdf_document *xref, fz_obj *obj)
+pdf_load_colorspace_imp(pdf_document *xref, pdf_obj *obj)
{
- if (fz_is_name(obj))
+ if (pdf_is_name(obj))
{
- if (!strcmp(fz_to_name(obj), "Pattern"))
+ if (!strcmp(pdf_to_name(obj), "Pattern"))
return fz_device_gray;
- else if (!strcmp(fz_to_name(obj), "G"))
+ else if (!strcmp(pdf_to_name(obj), "G"))
return fz_device_gray;
- else if (!strcmp(fz_to_name(obj), "RGB"))
+ else if (!strcmp(pdf_to_name(obj), "RGB"))
return fz_device_rgb;
- else if (!strcmp(fz_to_name(obj), "CMYK"))
+ else if (!strcmp(pdf_to_name(obj), "CMYK"))
return fz_device_cmyk;
- else if (!strcmp(fz_to_name(obj), "DeviceGray"))
+ else if (!strcmp(pdf_to_name(obj), "DeviceGray"))
return fz_device_gray;
- else if (!strcmp(fz_to_name(obj), "DeviceRGB"))
+ else if (!strcmp(pdf_to_name(obj), "DeviceRGB"))
return fz_device_rgb;
- else if (!strcmp(fz_to_name(obj), "DeviceCMYK"))
+ else if (!strcmp(pdf_to_name(obj), "DeviceCMYK"))
return fz_device_cmyk;
else
- fz_throw(xref->ctx, "unknown colorspace: %s", fz_to_name(obj));
+ fz_throw(xref->ctx, "unknown colorspace: %s", pdf_to_name(obj));
}
- else if (fz_is_array(obj))
+ else if (pdf_is_array(obj))
{
- fz_obj *name = fz_array_get(obj, 0);
+ pdf_obj *name = pdf_array_get(obj, 0);
- if (fz_is_name(name))
+ if (pdf_is_name(name))
{
/* load base colorspace instead */
- if (!strcmp(fz_to_name(name), "Pattern"))
+ if (!strcmp(pdf_to_name(name), "Pattern"))
{
- obj = fz_array_get(obj, 1);
+ obj = pdf_array_get(obj, 1);
if (!obj)
{
return fz_device_gray;
}
return pdf_load_colorspace(xref, obj);
- /* RJW: "cannot load pattern (%d %d R)", fz_to_num(obj), fz_to_gen(obj) */
+ /* RJW: "cannot load pattern (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj) */
}
- else if (!strcmp(fz_to_name(name), "G"))
+ else if (!strcmp(pdf_to_name(name), "G"))
return fz_device_gray;
- else if (!strcmp(fz_to_name(name), "RGB"))
+ else if (!strcmp(pdf_to_name(name), "RGB"))
return fz_device_rgb;
- else if (!strcmp(fz_to_name(name), "CMYK"))
+ else if (!strcmp(pdf_to_name(name), "CMYK"))
return fz_device_cmyk;
- else if (!strcmp(fz_to_name(name), "DeviceGray"))
+ else if (!strcmp(pdf_to_name(name), "DeviceGray"))
return fz_device_gray;
- else if (!strcmp(fz_to_name(name), "DeviceRGB"))
+ else if (!strcmp(pdf_to_name(name), "DeviceRGB"))
return fz_device_rgb;
- else if (!strcmp(fz_to_name(name), "DeviceCMYK"))
+ else if (!strcmp(pdf_to_name(name), "DeviceCMYK"))
return fz_device_cmyk;
- else if (!strcmp(fz_to_name(name), "CalGray"))
+ else if (!strcmp(pdf_to_name(name), "CalGray"))
return fz_device_gray;
- else if (!strcmp(fz_to_name(name), "CalRGB"))
+ else if (!strcmp(pdf_to_name(name), "CalRGB"))
return fz_device_rgb;
- else if (!strcmp(fz_to_name(name), "CalCMYK"))
+ else if (!strcmp(pdf_to_name(name), "CalCMYK"))
return fz_device_cmyk;
- else if (!strcmp(fz_to_name(name), "Lab"))
+ else if (!strcmp(pdf_to_name(name), "Lab"))
return fz_device_lab;
- else if (!strcmp(fz_to_name(name), "ICCBased"))
- return load_icc_based(xref, fz_array_get(obj, 1));
+ else if (!strcmp(pdf_to_name(name), "ICCBased"))
+ return load_icc_based(xref, pdf_array_get(obj, 1));
- else if (!strcmp(fz_to_name(name), "Indexed"))
+ else if (!strcmp(pdf_to_name(name), "Indexed"))
return load_indexed(xref, obj);
- else if (!strcmp(fz_to_name(name), "I"))
+ else if (!strcmp(pdf_to_name(name), "I"))
return load_indexed(xref, obj);
- else if (!strcmp(fz_to_name(name), "Separation"))
+ else if (!strcmp(pdf_to_name(name), "Separation"))
return load_separation(xref, obj);
- else if (!strcmp(fz_to_name(name), "DeviceN"))
+ else if (!strcmp(pdf_to_name(name), "DeviceN"))
return load_separation(xref, obj);
else
- fz_throw(xref->ctx, "syntaxerror: unknown colorspace %s", fz_to_name(name));
+ fz_throw(xref->ctx, "syntaxerror: unknown colorspace %s", pdf_to_name(name));
}
}
- fz_throw(xref->ctx, "syntaxerror: could not parse color space (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
+ fz_throw(xref->ctx, "syntaxerror: could not parse color space (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj));
return NULL; /* Stupid MSVC */
}
fz_colorspace *
-pdf_load_colorspace(pdf_document *xref, fz_obj *obj)
+pdf_load_colorspace(pdf_document *xref, pdf_obj *obj)
{
fz_context *ctx = xref->ctx;
fz_colorspace *cs;
@@ -401,7 +401,7 @@ pdf_load_colorspace(pdf_document *xref, fz_obj *obj)
}
cs = pdf_load_colorspace_imp(xref, obj);
- /* RJW: "cannot load colorspace (%d %d R)", fz_to_num(obj), fz_to_gen(obj) */
+ /* RJW: "cannot load colorspace (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj) */
pdf_store_item(ctx, obj, cs, cs->size);
diff --git a/pdf/pdf_crypt.c b/pdf/pdf_crypt.c
index 59423a38..c99e696c 100644
--- a/pdf/pdf_crypt.c
+++ b/pdf/pdf_crypt.c
@@ -20,11 +20,11 @@ struct pdf_crypt_filter_s
struct pdf_crypt_s
{
- fz_obj *id;
+ pdf_obj *id;
int v;
int length;
- fz_obj *cf;
+ pdf_obj *cf;
pdf_crypt_filter stmf;
pdf_crypt_filter strf;
@@ -40,7 +40,7 @@ struct pdf_crypt_s
fz_context *ctx;
};
-static void pdf_parse_crypt_filter(fz_context *ctx, pdf_crypt_filter *cf, fz_obj *dict, char *name, int defaultlength);
+static void pdf_parse_crypt_filter(fz_context *ctx, pdf_crypt_filter *cf, pdf_obj *dict, char *name, int defaultlength);
/*
* Create crypt object for decrypting strings and streams
@@ -48,31 +48,31 @@ static void pdf_parse_crypt_filter(fz_context *ctx, pdf_crypt_filter *cf, fz_obj
*/
pdf_crypt *
-pdf_new_crypt(fz_context *ctx, fz_obj *dict, fz_obj *id)
+pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
{
pdf_crypt *crypt;
- fz_obj *obj;
+ pdf_obj *obj;
crypt = fz_malloc_struct(ctx, pdf_crypt);
/* Common to all security handlers (PDF 1.7 table 3.18) */
- obj = fz_dict_gets(dict, "Filter");
- if (!fz_is_name(obj))
+ obj = pdf_dict_gets(dict, "Filter");
+ if (!pdf_is_name(obj))
{
pdf_free_crypt(ctx, crypt);
fz_throw(ctx, "unspecified encryption handler");
}
- if (strcmp(fz_to_name(obj), "Standard") != 0)
+ if (strcmp(pdf_to_name(obj), "Standard") != 0)
{
pdf_free_crypt(ctx, crypt);
- fz_throw(ctx, "unknown encryption handler: '%s'", fz_to_name(obj));
+ fz_throw(ctx, "unknown encryption handler: '%s'", pdf_to_name(obj));
}
crypt->v = 0;
- obj = fz_dict_gets(dict, "V");
- if (fz_is_int(obj))
- crypt->v = fz_to_int(obj);
+ obj = pdf_dict_gets(dict, "V");
+ if (pdf_is_int(obj))
+ crypt->v = pdf_to_int(obj);
if (crypt->v != 1 && crypt->v != 2 && crypt->v != 4 && crypt->v != 5)
{
pdf_free_crypt(ctx, crypt);
@@ -82,9 +82,9 @@ pdf_new_crypt(fz_context *ctx, fz_obj *dict, fz_obj *id)
crypt->length = 40;
if (crypt->v == 2 || crypt->v == 4)
{
- obj = fz_dict_gets(dict, "Length");
- if (fz_is_int(obj))
- crypt->length = fz_to_int(obj);
+ obj = pdf_dict_gets(dict, "Length");
+ if (pdf_is_int(obj))
+ crypt->length = pdf_to_int(obj);
/* work-around for pdf generators that assume length is in bytes */
if (crypt->length < 40)
@@ -122,10 +122,10 @@ pdf_new_crypt(fz_context *ctx, fz_obj *dict, fz_obj *id)
crypt->strf.method = PDF_CRYPT_NONE;
crypt->strf.length = crypt->length;
- obj = fz_dict_gets(dict, "CF");
- if (fz_is_dict(obj))
+ obj = pdf_dict_gets(dict, "CF");
+ if (pdf_is_dict(obj))
{
- crypt->cf = fz_keep_obj(obj);
+ crypt->cf = pdf_keep_obj(obj);
}
else
{
@@ -134,18 +134,18 @@ pdf_new_crypt(fz_context *ctx, fz_obj *dict, fz_obj *id)
fz_try(ctx)
{
- obj = fz_dict_gets(dict, "StmF");
- if (fz_is_name(obj))
- pdf_parse_crypt_filter(ctx, &crypt->stmf, crypt->cf, fz_to_name(obj), crypt->length);
+ obj = pdf_dict_gets(dict, "StmF");
+ if (pdf_is_name(obj))
+ pdf_parse_crypt_filter(ctx, &crypt->stmf, crypt->cf, pdf_to_name(obj), crypt->length);
- obj = fz_dict_gets(dict, "StrF");
- if (fz_is_name(obj))
- pdf_parse_crypt_filter(ctx, &crypt->strf, crypt->cf, fz_to_name(obj), crypt->length);
+ obj = pdf_dict_gets(dict, "StrF");
+ if (pdf_is_name(obj))
+ pdf_parse_crypt_filter(ctx, &crypt->strf, crypt->cf, pdf_to_name(obj), crypt->length);
}
fz_catch(ctx)
{
pdf_free_crypt(ctx, crypt);
- fz_throw(ctx, "cannot parse string crypt filter (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
+ fz_throw(ctx, "cannot parse string crypt filter (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj));
}
/* in crypt revision 4, the crypt filter determines the key length */
@@ -155,36 +155,36 @@ pdf_new_crypt(fz_context *ctx, fz_obj *dict, fz_obj *id)
/* Standard security handler (PDF 1.7 table 3.19) */
- obj = fz_dict_gets(dict, "R");
- if (fz_is_int(obj))
- crypt->r = fz_to_int(obj);
+ obj = pdf_dict_gets(dict, "R");
+ if (pdf_is_int(obj))
+ crypt->r = pdf_to_int(obj);
else
{
pdf_free_crypt(ctx, crypt);
fz_throw(ctx, "encryption dictionary missing revision value");
}
- obj = fz_dict_gets(dict, "O");
- if (fz_is_string(obj) && fz_to_str_len(obj) == 32)
- memcpy(crypt->o, fz_to_str_buf(obj), 32);
+ obj = pdf_dict_gets(dict, "O");
+ if (pdf_is_string(obj) && pdf_to_str_len(obj) == 32)
+ memcpy(crypt->o, pdf_to_str_buf(obj), 32);
/* /O and /U are supposed to be 48 bytes long for revision 5, they're often longer, though */
- else if (crypt->r == 5 && fz_is_string(obj) && fz_to_str_len(obj) >= 48)
- memcpy(crypt->o, fz_to_str_buf(obj), 48);
+ else if (crypt->r == 5 && pdf_is_string(obj) && pdf_to_str_len(obj) >= 48)
+ memcpy(crypt->o, pdf_to_str_buf(obj), 48);
else
{
pdf_free_crypt(ctx, crypt);
fz_throw(ctx, "encryption dictionary missing owner password");
}
- obj = fz_dict_gets(dict, "U");
- if (fz_is_string(obj) && fz_to_str_len(obj) == 32)
- memcpy(crypt->u, fz_to_str_buf(obj), 32);
- else if (fz_is_string(obj) && fz_to_str_len(obj) >= 48 && crypt->r == 5)
- memcpy(crypt->u, fz_to_str_buf(obj), 48);
- else if (fz_is_string(obj) && fz_to_str_len(obj) < 32)
+ obj = pdf_dict_gets(dict, "U");
+ if (pdf_is_string(obj) && pdf_to_str_len(obj) == 32)
+ memcpy(crypt->u, pdf_to_str_buf(obj), 32);
+ else if (pdf_is_string(obj) && pdf_to_str_len(obj) >= 48 && crypt->r == 5)
+ memcpy(crypt->u, pdf_to_str_buf(obj), 48);
+ else if (pdf_is_string(obj) && pdf_to_str_len(obj) < 32)
{
- fz_warn(ctx, "encryption password key too short (%d)", fz_to_str_len(obj));
- memcpy(crypt->u, fz_to_str_buf(obj), fz_to_str_len(obj));
+ fz_warn(ctx, "encryption password key too short (%d)", pdf_to_str_len(obj));
+ memcpy(crypt->u, pdf_to_str_buf(obj), pdf_to_str_len(obj));
}
else
{
@@ -192,9 +192,9 @@ pdf_new_crypt(fz_context *ctx, fz_obj *dict, fz_obj *id)
fz_throw(ctx, "encryption dictionary missing user password");
}
- obj = fz_dict_gets(dict, "P");
- if (fz_is_int(obj))
- crypt->p = fz_to_int(obj);
+ obj = pdf_dict_gets(dict, "P");
+ if (pdf_is_int(obj))
+ crypt->p = pdf_to_int(obj);
else
{
pdf_free_crypt(ctx, crypt);
@@ -203,35 +203,35 @@ pdf_new_crypt(fz_context *ctx, fz_obj *dict, fz_obj *id)
if (crypt->r == 5)
{
- obj = fz_dict_gets(dict, "OE");
- if (!fz_is_string(obj) || fz_to_str_len(obj) != 32)
+ obj = pdf_dict_gets(dict, "OE");
+ if (!pdf_is_string(obj) || pdf_to_str_len(obj) != 32)
{
pdf_free_crypt(ctx, crypt);
fz_throw(ctx, "encryption dictionary missing owner encryption key");
}
- memcpy(crypt->oe, fz_to_str_buf(obj), 32);
+ memcpy(crypt->oe, pdf_to_str_buf(obj), 32);
- obj = fz_dict_gets(dict, "UE");
- if (!fz_is_string(obj) || fz_to_str_len(obj) != 32)
+ obj = pdf_dict_gets(dict, "UE");
+ if (!pdf_is_string(obj) || pdf_to_str_len(obj) != 32)
{
pdf_free_crypt(ctx, crypt);
fz_throw(ctx, "encryption dictionary missing user encryption key");
}
- memcpy(crypt->ue, fz_to_str_buf(obj), 32);
+ memcpy(crypt->ue, pdf_to_str_buf(obj), 32);
}
crypt->encrypt_metadata = 1;
- obj = fz_dict_gets(dict, "EncryptMetadata");
- if (fz_is_bool(obj))
- crypt->encrypt_metadata = fz_to_bool(obj);
+ obj = pdf_dict_gets(dict, "EncryptMetadata");
+ if (pdf_is_bool(obj))
+ crypt->encrypt_metadata = pdf_to_bool(obj);
/* Extract file identifier string */
- if (fz_is_array(id) && fz_array_len(id) == 2)
+ if (pdf_is_array(id) && pdf_array_len(id) == 2)
{
- obj = fz_array_get(id, 0);
- if (fz_is_string(obj))
- crypt->id = fz_keep_obj(obj);
+ obj = pdf_array_get(id, 0);
+ if (pdf_is_string(obj))
+ crypt->id = pdf_keep_obj(obj);
}
else
fz_warn(ctx, "missing file identifier, may not be able to do decryption");
@@ -242,8 +242,8 @@ pdf_new_crypt(fz_context *ctx, fz_obj *dict, fz_obj *id)
void
pdf_free_crypt(fz_context *ctx, pdf_crypt *crypt)
{
- if (crypt->id) fz_drop_obj(crypt->id);
- if (crypt->cf) fz_drop_obj(crypt->cf);
+ if (crypt->id) pdf_drop_obj(crypt->id);
+ if (crypt->cf) pdf_drop_obj(crypt->cf);
fz_free(ctx, crypt);
}
@@ -252,15 +252,15 @@ pdf_free_crypt(fz_context *ctx, pdf_crypt *crypt)
*/
static void
-pdf_parse_crypt_filter(fz_context *ctx, pdf_crypt_filter *cf, fz_obj *cf_obj, char *name, int defaultlength)
+pdf_parse_crypt_filter(fz_context *ctx, pdf_crypt_filter *cf, pdf_obj *cf_obj, char *name, int defaultlength)
{
- fz_obj *obj;
- fz_obj *dict;
+ pdf_obj *obj;
+ pdf_obj *dict;
int is_identity = (strcmp(name, "Identity") == 0);
int is_stdcf = (!is_identity && (strcmp(name, "StdCF") == 0));
if (!is_identity && !is_stdcf)
- fz_throw(ctx, "Crypt Filter not Identity or StdCF (%d %d R)", fz_to_num(cf_obj), fz_to_gen(cf_obj));
+ fz_throw(ctx, "Crypt Filter not Identity or StdCF (%d %d R)", pdf_to_num(cf_obj), pdf_to_gen(cf_obj));
cf->method = PDF_CRYPT_NONE;
cf->length = defaultlength;
@@ -271,28 +271,28 @@ pdf_parse_crypt_filter(fz_context *ctx, pdf_crypt_filter *cf, fz_obj *cf_obj, ch
return;
}
- dict = fz_dict_gets(cf_obj, name);
- if (!fz_is_dict(dict))
- fz_throw(ctx, "cannot parse crypt filter (%d %d R)", fz_to_num(cf_obj), fz_to_gen(cf_obj));
+ dict = pdf_dict_gets(cf_obj, name);
+ if (!pdf_is_dict(dict))
+ fz_throw(ctx, "cannot parse crypt filter (%d %d R)", pdf_to_num(cf_obj), pdf_to_gen(cf_obj));
- obj = fz_dict_gets(dict, "CFM");
- if (fz_is_name(obj))
+ obj = pdf_dict_gets(dict, "CFM");
+ if (pdf_is_name(obj))
{
- if (!strcmp(fz_to_name(obj), "None"))
+ if (!strcmp(pdf_to_name(obj), "None"))
cf->method = PDF_CRYPT_NONE;
- else if (!strcmp(fz_to_name(obj), "V2"))
+ else if (!strcmp(pdf_to_name(obj), "V2"))
cf->method = PDF_CRYPT_RC4;
- else if (!strcmp(fz_to_name(obj), "AESV2"))
+ else if (!strcmp(pdf_to_name(obj), "AESV2"))
cf->method = PDF_CRYPT_AESV2;
- else if (!strcmp(fz_to_name(obj), "AESV3"))
+ else if (!strcmp(pdf_to_name(obj), "AESV3"))
cf->method = PDF_CRYPT_AESV3;
else
- fz_warn(ctx, "unknown encryption method: %s", fz_to_name(obj));
+ fz_warn(ctx, "unknown encryption method: %s", pdf_to_name(obj));
}
- obj = fz_dict_gets(dict, "Length");
- if (fz_is_int(obj))
- cf->length = fz_to_int(obj);
+ obj = pdf_dict_gets(dict, "Length");
+ if (pdf_is_int(obj))
+ cf->length = pdf_to_int(obj);
/* the length for crypt filters is supposed to be in bytes not bits */
if (cf->length < 40)
@@ -346,7 +346,7 @@ pdf_compute_encryption_key(pdf_crypt *crypt, unsigned char *password, int pwlen,
fz_md5_update(&md5, buf, 4);
/* Step 5 - pass first element of ID array */
- fz_md5_update(&md5, (unsigned char *)fz_to_str_buf(crypt->id), fz_to_str_len(crypt->id));
+ fz_md5_update(&md5, (unsigned char *)pdf_to_str_buf(crypt->id), pdf_to_str_len(crypt->id));
/* Step 6 (revision 4 or greater) - if metadata is not encrypted pass 0xFFFFFFFF */
if (crypt->r >= 4)
@@ -455,7 +455,7 @@ pdf_compute_user_password(pdf_crypt *crypt, unsigned char *password, int pwlen,
fz_md5_init(&md5);
fz_md5_update(&md5, padding, 32);
- fz_md5_update(&md5, (unsigned char*)fz_to_str_buf(crypt->id), fz_to_str_len(crypt->id));
+ fz_md5_update(&md5, (unsigned char*)pdf_to_str_buf(crypt->id), pdf_to_str_len(crypt->id));
fz_md5_final(&md5, digest);
fz_arc4_init(&arc4, crypt->key, n);
@@ -697,18 +697,18 @@ pdf_compute_object_key(pdf_crypt *crypt, pdf_crypt_filter *cf, int num, int gen,
*/
static void
-pdf_crypt_obj_imp(fz_context *ctx, pdf_crypt *crypt, fz_obj *obj, unsigned char *key, int keylen)
+pdf_crypt_obj_imp(fz_context *ctx, pdf_crypt *crypt, pdf_obj *obj, unsigned char *key, int keylen)
{
unsigned char *s;
int i, n;
- if (fz_is_indirect(obj))
+ if (pdf_is_indirect(obj))
return;
- if (fz_is_string(obj))
+ if (pdf_is_string(obj))
{
- s = (unsigned char *)fz_to_str_buf(obj);
- n = fz_to_str_len(obj);
+ s = (unsigned char *)pdf_to_str_buf(obj);
+ n = pdf_to_str_len(obj);
if (crypt->strf.method == PDF_CRYPT_RC4)
{
@@ -736,32 +736,32 @@ pdf_crypt_obj_imp(fz_context *ctx, pdf_crypt *crypt, fz_obj *obj, unsigned char
if (s[n - 17] < 1 || s[n - 17] > 16)
fz_warn(ctx, "aes padding out of range");
else
- fz_set_str_len(obj, n - 16 - s[n - 17]);
+ pdf_set_str_len(obj, n - 16 - s[n - 17]);
}
}
}
- else if (fz_is_array(obj))
+ else if (pdf_is_array(obj))
{
- n = fz_array_len(obj);
+ n = pdf_array_len(obj);
for (i = 0; i < n; i++)
{
- pdf_crypt_obj_imp(ctx, crypt, fz_array_get(obj, i), key, keylen);
+ pdf_crypt_obj_imp(ctx, crypt, pdf_array_get(obj, i), key, keylen);
}
}
- else if (fz_is_dict(obj))
+ else if (pdf_is_dict(obj))
{
- n = fz_dict_len(obj);
+ n = pdf_dict_len(obj);
for (i = 0; i < n; i++)
{
- pdf_crypt_obj_imp(ctx, crypt, fz_dict_get_val(obj, i), key, keylen);
+ pdf_crypt_obj_imp(ctx, crypt, pdf_dict_get_val(obj, i), key, keylen);
}
}
}
void
-pdf_crypt_obj(fz_context *ctx, pdf_crypt *crypt, fz_obj *obj, int num, int gen)
+pdf_crypt_obj(fz_context *ctx, pdf_crypt *crypt, pdf_obj *obj, int num, int gen)
{
unsigned char key[32];
int len;
diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c
index fd2afab2..5e54e0bb 100644
--- a/pdf/pdf_font.c
+++ b/pdf/pdf_font.c
@@ -5,7 +5,7 @@
#include FT_FREETYPE_H
#include FT_XFREE86_H
-static void pdf_load_font_descriptor(pdf_font_desc *fontdesc, pdf_document *xref, fz_obj *dict, char *collection, char *basefont);
+static void pdf_load_font_descriptor(pdf_font_desc *fontdesc, pdf_document *xref, pdf_obj *dict, char *collection, char *basefont);
static char *base_font_names[14][7] =
{
@@ -268,18 +268,18 @@ pdf_load_system_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fontname, c
}
static void
-pdf_load_embedded_font(pdf_font_desc *fontdesc, pdf_document *xref, fz_obj *stmref)
+pdf_load_embedded_font(pdf_font_desc *fontdesc, pdf_document *xref, pdf_obj *stmref)
{
fz_buffer *buf;
fz_context *ctx = xref->ctx;
fz_try(ctx)
{
- buf = pdf_load_stream(xref, fz_to_num(stmref), fz_to_gen(stmref));
+ buf = pdf_load_stream(xref, pdf_to_num(stmref), pdf_to_gen(stmref));
}
fz_catch(ctx)
{
- fz_throw(ctx, "cannot load font stream (%d %d R)", fz_to_num(stmref), fz_to_gen(stmref));
+ fz_throw(ctx, "cannot load font stream (%d %d R)", pdf_to_num(stmref), pdf_to_gen(stmref));
}
fz_try(ctx)
@@ -289,7 +289,7 @@ pdf_load_embedded_font(pdf_font_desc *fontdesc, pdf_document *xref, fz_obj *stmr
fz_catch(ctx)
{
fz_drop_buffer(ctx, buf);
- fz_throw(ctx, "cannot load embedded font (%d %d R)", fz_to_num(stmref), fz_to_gen(stmref));
+ fz_throw(ctx, "cannot load embedded font (%d %d R)", pdf_to_num(stmref), pdf_to_gen(stmref));
}
fontdesc->size += buf->len;
@@ -394,11 +394,11 @@ pdf_new_font_desc(fz_context *ctx)
*/
static pdf_font_desc *
-pdf_load_simple_font(pdf_document *xref, fz_obj *dict)
+pdf_load_simple_font(pdf_document *xref, pdf_obj *dict)
{
- fz_obj *descriptor;
- fz_obj *encoding;
- fz_obj *widths;
+ pdf_obj *descriptor;
+ pdf_obj *encoding;
+ pdf_obj *widths;
unsigned short *etable = NULL;
pdf_font_desc *fontdesc = NULL;
FT_Face face;
@@ -417,7 +417,7 @@ pdf_load_simple_font(pdf_document *xref, fz_obj *dict)
fz_var(fontdesc);
fz_var(etable);
- basefont = fz_to_name(fz_dict_gets(dict, "BaseFont"));
+ basefont = pdf_to_name(pdf_dict_gets(dict, "BaseFont"));
fontname = clean_font_name(basefont);
/* Load font file */
@@ -425,7 +425,7 @@ pdf_load_simple_font(pdf_document *xref, fz_obj *dict)
{
fontdesc = pdf_new_font_desc(ctx);
- descriptor = fz_dict_gets(dict, "FontDescriptor");
+ descriptor = pdf_dict_gets(dict, "FontDescriptor");
if (descriptor)
pdf_load_font_descriptor(fontdesc, xref, descriptor, NULL, basefont);
else
@@ -433,9 +433,9 @@ pdf_load_simple_font(pdf_document *xref, fz_obj *dict)
/* Some chinese documents mistakenly consider WinAnsiEncoding to be codepage 936 */
if (!*fontdesc->font->name &&
- !fz_dict_gets(dict, "ToUnicode") &&
- !strcmp(fz_to_name(fz_dict_gets(dict, "Encoding")), "WinAnsiEncoding") &&
- fz_to_int(fz_dict_gets(descriptor, "Flags")) == 4)
+ !pdf_dict_gets(dict, "ToUnicode") &&
+ !strcmp(pdf_to_name(pdf_dict_gets(dict, "Encoding")), "WinAnsiEncoding") &&
+ pdf_to_int(pdf_dict_gets(descriptor, "Flags")) == 4)
{
/* note: without the comma, pdf_load_font_descriptor would prefer /FontName over /BaseFont */
char *cp936fonts[] = {
@@ -514,34 +514,34 @@ pdf_load_simple_font(pdf_document *xref, fz_obj *dict)
etable[i] = 0;
}
- encoding = fz_dict_gets(dict, "Encoding");
+ encoding = pdf_dict_gets(dict, "Encoding");
if (encoding)
{
- if (fz_is_name(encoding))
- pdf_load_encoding(estrings, fz_to_name(encoding));
+ if (pdf_is_name(encoding))
+ pdf_load_encoding(estrings, pdf_to_name(encoding));
- if (fz_is_dict(encoding))
+ if (pdf_is_dict(encoding))
{
- fz_obj *base, *diff, *item;
+ pdf_obj *base, *diff, *item;
- base = fz_dict_gets(encoding, "BaseEncoding");
- if (fz_is_name(base))
- pdf_load_encoding(estrings, fz_to_name(base));
+ base = pdf_dict_gets(encoding, "BaseEncoding");
+ if (pdf_is_name(base))
+ pdf_load_encoding(estrings, pdf_to_name(base));
else if (!fontdesc->is_embedded && !symbolic)
pdf_load_encoding(estrings, "StandardEncoding");
- diff = fz_dict_gets(encoding, "Differences");
- if (fz_is_array(diff))
+ diff = pdf_dict_gets(encoding, "Differences");
+ if (pdf_is_array(diff))
{
- n = fz_array_len(diff);
+ n = pdf_array_len(diff);
k = 0;
for (i = 0; i < n; i++)
{
- item = fz_array_get(diff, i);
- if (fz_is_int(item))
- k = fz_to_int(item);
- if (fz_is_name(item))
- estrings[k++] = fz_to_name(item);
+ item = pdf_array_get(diff, i);
+ if (pdf_is_int(item))
+ k = pdf_to_int(item);
+ if (pdf_is_name(item))
+ estrings[k++] = pdf_to_name(item);
if (k < 0) k = 0;
if (k > 255) k = 255;
}
@@ -654,7 +654,7 @@ pdf_load_simple_font(pdf_document *xref, fz_obj *dict)
fontdesc->cid_to_gid_len = 256;
fontdesc->cid_to_gid = etable;
- pdf_load_to_unicode(xref, fontdesc, estrings, NULL, fz_dict_gets(dict, "ToUnicode"));
+ pdf_load_to_unicode(xref, fontdesc, estrings, NULL, pdf_dict_gets(dict, "ToUnicode"));
/* RJW: "cannot load to_unicode" */
skip_encoding:
@@ -663,20 +663,20 @@ pdf_load_simple_font(pdf_document *xref, fz_obj *dict)
pdf_set_default_hmtx(ctx, fontdesc, fontdesc->missing_width);
- widths = fz_dict_gets(dict, "Widths");
+ widths = pdf_dict_gets(dict, "Widths");
if (widths)
{
int first, last;
- first = fz_to_int(fz_dict_gets(dict, "FirstChar"));
- last = fz_to_int(fz_dict_gets(dict, "LastChar"));
+ first = pdf_to_int(pdf_dict_gets(dict, "FirstChar"));
+ last = pdf_to_int(pdf_dict_gets(dict, "LastChar"));
if (first < 0 || last > 255 || first > last)
first = last = 0;
for (i = 0; i < last - first + 1; i++)
{
- int wid = fz_to_int(fz_array_get(widths, i));
+ int wid = pdf_to_int(pdf_array_get(widths, i));
pdf_add_hmtx(ctx, fontdesc, i + first, i + first, wid);
}
}
@@ -700,7 +700,7 @@ pdf_load_simple_font(pdf_document *xref, fz_obj *dict)
if (fontdesc && etable != fontdesc->cid_to_gid)
fz_free(ctx, etable);
pdf_drop_font(ctx, fontdesc);
- fz_throw(ctx, "cannot load simple font (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
+ fz_throw(ctx, "cannot load simple font (%d %d R)", pdf_to_num(dict), pdf_to_gen(dict));
}
return fontdesc;
}
@@ -710,17 +710,17 @@ pdf_load_simple_font(pdf_document *xref, fz_obj *dict)
*/
static pdf_font_desc *
-load_cid_font(pdf_document *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_unicode)
+load_cid_font(pdf_document *xref, pdf_obj *dict, pdf_obj *encoding, pdf_obj *to_unicode)
{
- fz_obj *widths;
- fz_obj *descriptor;
+ pdf_obj *widths;
+ pdf_obj *descriptor;
pdf_font_desc *fontdesc;
FT_Face face;
int kind;
char collection[256];
char *basefont;
int i, k, fterr;
- fz_obj *obj;
+ pdf_obj *obj;
int dw;
fz_context *ctx = xref->ctx;
@@ -730,28 +730,28 @@ load_cid_font(pdf_document *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_uni
{
/* Get font name and CID collection */
- basefont = fz_to_name(fz_dict_gets(dict, "BaseFont"));
+ basefont = pdf_to_name(pdf_dict_gets(dict, "BaseFont"));
{
- fz_obj *cidinfo;
+ pdf_obj *cidinfo;
char tmpstr[64];
int tmplen;
- cidinfo = fz_dict_gets(dict, "CIDSystemInfo");
+ cidinfo = pdf_dict_gets(dict, "CIDSystemInfo");
if (!cidinfo)
fz_throw(ctx, "cid font is missing info");
- obj = fz_dict_gets(cidinfo, "Registry");
- tmplen = MIN(sizeof tmpstr - 1, fz_to_str_len(obj));
- memcpy(tmpstr, fz_to_str_buf(obj), tmplen);
+ obj = pdf_dict_gets(cidinfo, "Registry");
+ tmplen = MIN(sizeof tmpstr - 1, pdf_to_str_len(obj));
+ memcpy(tmpstr, pdf_to_str_buf(obj), tmplen);
tmpstr[tmplen] = '\0';
fz_strlcpy(collection, tmpstr, sizeof collection);
fz_strlcat(collection, "-", sizeof collection);
- obj = fz_dict_gets(cidinfo, "Ordering");
- tmplen = MIN(sizeof tmpstr - 1, fz_to_str_len(obj));
- memcpy(tmpstr, fz_to_str_buf(obj), tmplen);
+ obj = pdf_dict_gets(cidinfo, "Ordering");
+ tmplen = MIN(sizeof tmpstr - 1, pdf_to_str_len(obj));
+ memcpy(tmpstr, pdf_to_str_buf(obj), tmplen);
tmpstr[tmplen] = '\0';
fz_strlcat(collection, tmpstr, sizeof collection);
}
@@ -760,7 +760,7 @@ load_cid_font(pdf_document *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_uni
fontdesc = pdf_new_font_desc(ctx);
- descriptor = fz_dict_gets(dict, "FontDescriptor");
+ descriptor = pdf_dict_gets(dict, "FontDescriptor");
if (!descriptor)
fz_throw(ctx, "syntaxerror: missing font descriptor");
pdf_load_font_descriptor(fontdesc, xref, descriptor, collection, basefont);
@@ -770,16 +770,16 @@ load_cid_font(pdf_document *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_uni
/* Encoding */
- if (fz_is_name(encoding))
+ if (pdf_is_name(encoding))
{
- if (!strcmp(fz_to_name(encoding), "Identity-H"))
+ if (!strcmp(pdf_to_name(encoding), "Identity-H"))
fontdesc->encoding = pdf_new_identity_cmap(ctx, 0, 2);
- else if (!strcmp(fz_to_name(encoding), "Identity-V"))
+ else if (!strcmp(pdf_to_name(encoding), "Identity-V"))
fontdesc->encoding = pdf_new_identity_cmap(ctx, 1, 2);
else
- fontdesc->encoding = pdf_load_system_cmap(ctx, fz_to_name(encoding));
+ fontdesc->encoding = pdf_load_system_cmap(ctx, pdf_to_name(encoding));
}
- else if (fz_is_indirect(encoding))
+ else if (pdf_is_indirect(encoding))
{
fontdesc->encoding = pdf_load_embedded_cmap(xref, encoding);
}
@@ -793,14 +793,14 @@ load_cid_font(pdf_document *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_uni
if (kind == TRUETYPE)
{
- fz_obj *cidtogidmap;
+ pdf_obj *cidtogidmap;
- cidtogidmap = fz_dict_gets(dict, "CIDToGIDMap");
- if (fz_is_indirect(cidtogidmap))
+ cidtogidmap = pdf_dict_gets(dict, "CIDToGIDMap");
+ if (pdf_is_indirect(cidtogidmap))
{
fz_buffer *buf;
- buf = pdf_load_stream(xref, fz_to_num(cidtogidmap), fz_to_gen(cidtogidmap));
+ buf = pdf_load_stream(xref, pdf_to_num(cidtogidmap), pdf_to_gen(cidtogidmap));
fontdesc->cid_to_gid_len = (buf->len) / 2;
fontdesc->cid_to_gid = fz_malloc_array(ctx, fontdesc->cid_to_gid_len, sizeof(unsigned short));
@@ -842,35 +842,35 @@ load_cid_font(pdf_document *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_uni
/* Horizontal */
dw = 1000;
- obj = fz_dict_gets(dict, "DW");
+ obj = pdf_dict_gets(dict, "DW");
if (obj)
- dw = fz_to_int(obj);
+ dw = pdf_to_int(obj);
pdf_set_default_hmtx(ctx, fontdesc, dw);
- widths = fz_dict_gets(dict, "W");
+ widths = pdf_dict_gets(dict, "W");
if (widths)
{
int c0, c1, w, n, m;
- n = fz_array_len(widths);
+ n = pdf_array_len(widths);
for (i = 0; i < n; )
{
- c0 = fz_to_int(fz_array_get(widths, i));
- obj = fz_array_get(widths, i + 1);
- if (fz_is_array(obj))
+ c0 = pdf_to_int(pdf_array_get(widths, i));
+ obj = pdf_array_get(widths, i + 1);
+ if (pdf_is_array(obj))
{
- m = fz_array_len(obj);
+ m = pdf_array_len(obj);
for (k = 0; k < m; k++)
{
- w = fz_to_int(fz_array_get(obj, k));
+ w = pdf_to_int(pdf_array_get(obj, k));
pdf_add_hmtx(ctx, fontdesc, c0 + k, c0 + k, w);
}
i += 2;
}
else
{
- c1 = fz_to_int(obj);
- w = fz_to_int(fz_array_get(widths, i + 2));
+ c1 = pdf_to_int(obj);
+ w = pdf_to_int(pdf_array_get(widths, i + 2));
pdf_add_hmtx(ctx, fontdesc, c0, c1, w);
i += 3;
}
@@ -886,43 +886,43 @@ load_cid_font(pdf_document *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_uni
int dw2y = 880;
int dw2w = -1000;
- obj = fz_dict_gets(dict, "DW2");
+ obj = pdf_dict_gets(dict, "DW2");
if (obj)
{
- dw2y = fz_to_int(fz_array_get(obj, 0));
- dw2w = fz_to_int(fz_array_get(obj, 1));
+ dw2y = pdf_to_int(pdf_array_get(obj, 0));
+ dw2w = pdf_to_int(pdf_array_get(obj, 1));
}
pdf_set_default_vmtx(ctx, fontdesc, dw2y, dw2w);
- widths = fz_dict_gets(dict, "W2");
+ widths = pdf_dict_gets(dict, "W2");
if (widths)
{
int c0, c1, w, x, y, n;
- n = fz_array_len(widths);
+ n = pdf_array_len(widths);
for (i = 0; i < n; )
{
- c0 = fz_to_int(fz_array_get(widths, i));
- obj = fz_array_get(widths, i + 1);
- if (fz_is_array(obj))
+ c0 = pdf_to_int(pdf_array_get(widths, i));
+ obj = pdf_array_get(widths, i + 1);
+ if (pdf_is_array(obj))
{
- int m = fz_array_len(obj);
+ int m = pdf_array_len(obj);
for (k = 0; k * 3 < m; k ++)
{
- w = fz_to_int(fz_array_get(obj, k * 3 + 0));
- x = fz_to_int(fz_array_get(obj, k * 3 + 1));
- y = fz_to_int(fz_array_get(obj, k * 3 + 2));
+ w = pdf_to_int(pdf_array_get(obj, k * 3 + 0));
+ x = pdf_to_int(pdf_array_get(obj, k * 3 + 1));
+ y = pdf_to_int(pdf_array_get(obj, k * 3 + 2));
pdf_add_vmtx(ctx, fontdesc, c0 + k, c0 + k, x, y, w);
}
i += 2;
}
else
{
- c1 = fz_to_int(obj);
- w = fz_to_int(fz_array_get(widths, i + 2));
- x = fz_to_int(fz_array_get(widths, i + 3));
- y = fz_to_int(fz_array_get(widths, i + 4));
+ c1 = pdf_to_int(obj);
+ w = pdf_to_int(pdf_array_get(widths, i + 2));
+ x = pdf_to_int(pdf_array_get(widths, i + 3));
+ y = pdf_to_int(pdf_array_get(widths, i + 4));
pdf_add_vmtx(ctx, fontdesc, c0, c1, x, y, w);
i += 5;
}
@@ -935,38 +935,38 @@ load_cid_font(pdf_document *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_uni
fz_catch(ctx)
{
pdf_drop_font(ctx, fontdesc);
- fz_throw(ctx, "cannot load cid font (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
+ fz_throw(ctx, "cannot load cid font (%d %d R)", pdf_to_num(dict), pdf_to_gen(dict));
}
return fontdesc;
}
static pdf_font_desc *
-pdf_load_type0_font(pdf_document *xref, fz_obj *dict)
+pdf_load_type0_font(pdf_document *xref, pdf_obj *dict)
{
- fz_obj *dfonts;
- fz_obj *dfont;
- fz_obj *subtype;
- fz_obj *encoding;
- fz_obj *to_unicode;
+ pdf_obj *dfonts;
+ pdf_obj *dfont;
+ pdf_obj *subtype;
+ pdf_obj *encoding;
+ pdf_obj *to_unicode;
- dfonts = fz_dict_gets(dict, "DescendantFonts");
+ dfonts = pdf_dict_gets(dict, "DescendantFonts");
if (!dfonts)
fz_throw(xref->ctx, "cid font is missing descendant fonts");
- dfont = fz_array_get(dfonts, 0);
+ dfont = pdf_array_get(dfonts, 0);
- subtype = fz_dict_gets(dfont, "Subtype");
- encoding = fz_dict_gets(dict, "Encoding");
- to_unicode = fz_dict_gets(dict, "ToUnicode");
+ subtype = pdf_dict_gets(dfont, "Subtype");
+ encoding = pdf_dict_gets(dict, "Encoding");
+ to_unicode = pdf_dict_gets(dict, "ToUnicode");
- if (fz_is_name(subtype) && !strcmp(fz_to_name(subtype), "CIDFontType0"))
+ if (pdf_is_name(subtype) && !strcmp(pdf_to_name(subtype), "CIDFontType0"))
return load_cid_font(xref, dfont, encoding, to_unicode);
- else if (fz_is_name(subtype) && !strcmp(fz_to_name(subtype), "CIDFontType2"))
+ else if (pdf_is_name(subtype) && !strcmp(pdf_to_name(subtype), "CIDFontType2"))
return load_cid_font(xref, dfont, encoding, to_unicode);
else
fz_throw(xref->ctx, "syntaxerror: unknown cid font type");
- /* RJW: "cannot load descendant font (%d %d R)", fz_to_num(dfont), fz_to_gen(dfont) */
+ /* RJW: "cannot load descendant font (%d %d R)", pdf_to_num(dfont), pdf_to_gen(dfont) */
return NULL; /* Stupid MSVC */
}
@@ -975,34 +975,34 @@ pdf_load_type0_font(pdf_document *xref, fz_obj *dict)
*/
static void
-pdf_load_font_descriptor(pdf_font_desc *fontdesc, pdf_document *xref, fz_obj *dict, char *collection, char *basefont)
+pdf_load_font_descriptor(pdf_font_desc *fontdesc, pdf_document *xref, pdf_obj *dict, char *collection, char *basefont)
{
- fz_obj *obj1, *obj2, *obj3, *obj;
+ pdf_obj *obj1, *obj2, *obj3, *obj;
char *fontname;
char *origname;
FT_Face face;
fz_context *ctx = xref->ctx;
if (!strchr(basefont, ',') || strchr(basefont, '+'))
- origname = fz_to_name(fz_dict_gets(dict, "FontName"));
+ origname = pdf_to_name(pdf_dict_gets(dict, "FontName"));
else
origname = basefont;
fontname = clean_font_name(origname);
- fontdesc->flags = fz_to_int(fz_dict_gets(dict, "Flags"));
- fontdesc->italic_angle = fz_to_real(fz_dict_gets(dict, "ItalicAngle"));
- fontdesc->ascent = fz_to_real(fz_dict_gets(dict, "Ascent"));
- fontdesc->descent = fz_to_real(fz_dict_gets(dict, "Descent"));
- fontdesc->cap_height = fz_to_real(fz_dict_gets(dict, "CapHeight"));
- fontdesc->x_height = fz_to_real(fz_dict_gets(dict, "XHeight"));
- fontdesc->missing_width = fz_to_real(fz_dict_gets(dict, "MissingWidth"));
-
- obj1 = fz_dict_gets(dict, "FontFile");
- obj2 = fz_dict_gets(dict, "FontFile2");
- obj3 = fz_dict_gets(dict, "FontFile3");
+ fontdesc->flags = pdf_to_int(pdf_dict_gets(dict, "Flags"));
+ fontdesc->italic_angle = pdf_to_real(pdf_dict_gets(dict, "ItalicAngle"));
+ fontdesc->ascent = pdf_to_real(pdf_dict_gets(dict, "Ascent"));
+ fontdesc->descent = pdf_to_real(pdf_dict_gets(dict, "Descent"));
+ fontdesc->cap_height = pdf_to_real(pdf_dict_gets(dict, "CapHeight"));
+ fontdesc->x_height = pdf_to_real(pdf_dict_gets(dict, "XHeight"));
+ fontdesc->missing_width = pdf_to_real(pdf_dict_gets(dict, "MissingWidth"));
+
+ obj1 = pdf_dict_gets(dict, "FontFile");
+ obj2 = pdf_dict_gets(dict, "FontFile2");
+ obj3 = pdf_dict_gets(dict, "FontFile3");
obj = obj1 ? obj1 : obj2 ? obj2 : obj3;
- if (fz_is_indirect(obj))
+ if (pdf_is_indirect(obj))
{
fz_try(ctx)
{
@@ -1015,7 +1015,7 @@ pdf_load_font_descriptor(pdf_font_desc *fontdesc, pdf_document *xref, fz_obj *di
pdf_load_builtin_font(ctx, fontdesc, fontname);
else
pdf_load_system_font(ctx, fontdesc, fontname, collection);
- /* RJW: "cannot load font descriptor (%d %d R)", fz_to_num(dict), fz_to_gen(dict) */
+ /* RJW: "cannot load font descriptor (%d %d R)", pdf_to_num(dict), pdf_to_gen(dict) */
}
}
else
@@ -1024,7 +1024,7 @@ pdf_load_font_descriptor(pdf_font_desc *fontdesc, pdf_document *xref, fz_obj *di
pdf_load_builtin_font(ctx, fontdesc, fontname);
else
pdf_load_system_font(ctx, fontdesc, fontname, collection);
- /* RJW: "cannot load font descriptor (%d %d R)", fz_to_num(dict), fz_to_gen(dict) */
+ /* RJW: "cannot load font descriptor (%d %d R)", pdf_to_num(dict), pdf_to_gen(dict) */
}
fz_strlcpy(fontdesc->font->name, fontname, sizeof fontdesc->font->name);
@@ -1073,11 +1073,11 @@ pdf_make_width_table(fz_context *ctx, pdf_font_desc *fontdesc)
}
pdf_font_desc *
-pdf_load_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict)
+pdf_load_font(pdf_document *xref, pdf_obj *rdb, pdf_obj *dict)
{
char *subtype;
- fz_obj *dfonts;
- fz_obj *charprocs;
+ pdf_obj *dfonts;
+ pdf_obj *charprocs;
fz_context *ctx = xref->ctx;
pdf_font_desc *fontdesc;
@@ -1086,9 +1086,9 @@ pdf_load_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict)
return fontdesc;
}
- subtype = fz_to_name(fz_dict_gets(dict, "Subtype"));
- dfonts = fz_dict_gets(dict, "DescendantFonts");
- charprocs = fz_dict_gets(dict, "CharProcs");
+ subtype = pdf_to_name(pdf_dict_gets(dict, "Subtype"));
+ dfonts = pdf_dict_gets(dict, "DescendantFonts");
+ charprocs = pdf_dict_gets(dict, "CharProcs");
if (subtype && !strcmp(subtype, "Type0"))
fontdesc = pdf_load_type0_font(xref, dict);
@@ -1115,7 +1115,7 @@ pdf_load_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict)
fz_warn(ctx, "unknown font format, guessing type1 or truetype.");
fontdesc = pdf_load_simple_font(xref, dict);
}
- /* RJW: "cannot load font (%d %d R)", fz_to_num(dict), fz_to_gen(dict) */
+ /* RJW: "cannot load font (%d %d R)", pdf_to_num(dict), pdf_to_gen(dict) */
/* Save the widths to stretch non-CJK substitute fonts */
if (fontdesc->font->ft_substitute && !fontdesc->to_ttf_cmap)
diff --git a/pdf/pdf_function.c b/pdf/pdf_function.c
index 17373f42..4273bbc6 100644
--- a/pdf/pdf_function.c
+++ b/pdf/pdf_function.c
@@ -828,7 +828,7 @@ parse_code(pdf_function *func, fz_stream *stream, int *codeptr)
}
static void
-load_postscript_func(pdf_function *func, pdf_document *xref, fz_obj *dict, int num, int gen)
+load_postscript_func(pdf_function *func, pdf_document *xref, pdf_obj *dict, int num, int gen)
{
fz_stream *stream = NULL;
int codeptr;
@@ -900,37 +900,37 @@ eval_postscript_func(fz_context *ctx, pdf_function *func, float *in, float *out)
*/
static void
-load_sample_func(pdf_function *func, pdf_document *xref, fz_obj *dict, int num, int gen)
+load_sample_func(pdf_function *func, pdf_document *xref, pdf_obj *dict, int num, int gen)
{
fz_context *ctx = xref->ctx;
fz_stream *stream;
- fz_obj *obj;
+ pdf_obj *obj;
int samplecount;
int bps;
int i;
func->u.sa.samples = NULL;
- obj = fz_dict_gets(dict, "Size");
- if (!fz_is_array(obj) || fz_array_len(obj) != func->m)
+ obj = pdf_dict_gets(dict, "Size");
+ if (!pdf_is_array(obj) || pdf_array_len(obj) != func->m)
fz_throw(ctx, "malformed /Size");
for (i = 0; i < func->m; i++)
- func->u.sa.size[i] = fz_to_int(fz_array_get(obj, i));
+ func->u.sa.size[i] = pdf_to_int(pdf_array_get(obj, i));
- obj = fz_dict_gets(dict, "BitsPerSample");
- if (!fz_is_int(obj))
+ obj = pdf_dict_gets(dict, "BitsPerSample");
+ if (!pdf_is_int(obj))
fz_throw(ctx, "malformed /BitsPerSample");
- func->u.sa.bps = bps = fz_to_int(obj);
+ func->u.sa.bps = bps = pdf_to_int(obj);
- obj = fz_dict_gets(dict, "Encode");
- if (fz_is_array(obj))
+ obj = pdf_dict_gets(dict, "Encode");
+ if (pdf_is_array(obj))
{
- if (fz_array_len(obj) != func->m * 2)
+ if (pdf_array_len(obj) != func->m * 2)
fz_throw(ctx, "malformed /Encode");
for (i = 0; i < func->m; i++)
{
- func->u.sa.encode[i][0] = fz_to_real(fz_array_get(obj, i*2+0));
- func->u.sa.encode[i][1] = fz_to_real(fz_array_get(obj, i*2+1));
+ func->u.sa.encode[i][0] = pdf_to_real(pdf_array_get(obj, i*2+0));
+ func->u.sa.encode[i][1] = pdf_to_real(pdf_array_get(obj, i*2+1));
}
}
else
@@ -942,15 +942,15 @@ load_sample_func(pdf_function *func, pdf_document *xref, fz_obj *dict, int num,
}
}
- obj = fz_dict_gets(dict, "Decode");
- if (fz_is_array(obj))
+ obj = pdf_dict_gets(dict, "Decode");
+ if (pdf_is_array(obj))
{
- if (fz_array_len(obj) != func->n * 2)
+ if (pdf_array_len(obj) != func->n * 2)
fz_throw(ctx, "malformed /Decode");
for (i = 0; i < func->n; i++)
{
- func->u.sa.decode[i][0] = fz_to_real(fz_array_get(obj, i*2+0));
- func->u.sa.decode[i][1] = fz_to_real(fz_array_get(obj, i*2+1));
+ func->u.sa.decode[i][0] = pdf_to_real(pdf_array_get(obj, i*2+0));
+ func->u.sa.decode[i][1] = pdf_to_real(pdf_array_get(obj, i*2+1));
}
}
else
@@ -1111,27 +1111,27 @@ eval_sample_func(fz_context *ctx, pdf_function *func, float *in, float *out)
*/
static void
-load_exponential_func(fz_context *ctx, pdf_function *func, fz_obj *dict)
+load_exponential_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
{
- fz_obj *obj;
+ pdf_obj *obj;
int i;
if (func->m != 1)
fz_throw(ctx, "/Domain must be one dimension (%d)", func->m);
- obj = fz_dict_gets(dict, "N");
- if (!fz_is_int(obj) && !fz_is_real(obj))
+ obj = pdf_dict_gets(dict, "N");
+ if (!pdf_is_int(obj) && !pdf_is_real(obj))
fz_throw(ctx, "malformed /N");
- func->u.e.n = fz_to_real(obj);
+ func->u.e.n = pdf_to_real(obj);
- obj = fz_dict_gets(dict, "C0");
- if (fz_is_array(obj))
+ obj = pdf_dict_gets(dict, "C0");
+ if (pdf_is_array(obj))
{
- func->n = fz_array_len(obj);
+ func->n = pdf_array_len(obj);
if (func->n >= MAXN)
fz_throw(ctx, "exponential function result array out of range");
for (i = 0; i < func->n; i++)
- func->u.e.c0[i] = fz_to_real(fz_array_get(obj, i));
+ func->u.e.c0[i] = pdf_to_real(pdf_array_get(obj, i));
}
else
{
@@ -1139,13 +1139,13 @@ load_exponential_func(fz_context *ctx, pdf_function *func, fz_obj *dict)
func->u.e.c0[0] = 0;
}
- obj = fz_dict_gets(dict, "C1");
- if (fz_is_array(obj))
+ obj = pdf_dict_gets(dict, "C1");
+ if (pdf_is_array(obj))
{
- if (fz_array_len(obj) != func->n)
+ if (pdf_array_len(obj) != func->n)
fz_throw(ctx, "/C1 must match /C0 length");
for (i = 0; i < func->n; i++)
- func->u.e.c1[i] = fz_to_real(fz_array_get(obj, i));
+ func->u.e.c1[i] = pdf_to_real(pdf_array_get(obj, i));
}
else
{
@@ -1185,13 +1185,13 @@ eval_exponential_func(fz_context *ctx, pdf_function *func, float in, float *out)
*/
static void
-load_stitching_func(pdf_function *func, pdf_document *xref, fz_obj *dict)
+load_stitching_func(pdf_function *func, pdf_document *xref, pdf_obj *dict)
{
fz_context *ctx = xref->ctx;
pdf_function **funcs;
- fz_obj *obj;
- fz_obj *sub;
- fz_obj *num;
+ pdf_obj *obj;
+ pdf_obj *sub;
+ pdf_obj *num;
int k;
int i;
@@ -1200,11 +1200,11 @@ load_stitching_func(pdf_function *func, pdf_document *xref, fz_obj *dict)
if (func->m != 1)
fz_throw(ctx, "/Domain must be one dimension (%d)", func->m);
- obj = fz_dict_gets(dict, "Functions");
- if (!fz_is_array(obj))
+ obj = pdf_dict_gets(dict, "Functions");
+ if (!pdf_is_array(obj))
fz_throw(ctx, "stitching function has no input functions");
{
- k = fz_array_len(obj);
+ k = pdf_array_len(obj);
func->u.st.funcs = fz_malloc_array(ctx, k, sizeof(pdf_function*));
func->u.st.bounds = fz_malloc_array(ctx, k - 1, sizeof(float));
@@ -1213,9 +1213,9 @@ load_stitching_func(pdf_function *func, pdf_document *xref, fz_obj *dict)
for (i = 0; i < k; i++)
{
- sub = fz_array_get(obj, i);
+ sub = pdf_array_get(obj, i);
funcs[i] = pdf_load_function(xref, sub);
- /* RJW: "cannot load sub function %d (%d %d R)", i, fz_to_num(sub), fz_to_gen(sub) */
+ /* RJW: "cannot load sub function %d (%d %d R)", i, pdf_to_num(sub), pdf_to_gen(sub) */
if (funcs[i]->m != 1 || funcs[i]->n != funcs[0]->n)
fz_throw(ctx, "sub function %d /Domain or /Range mismatch", i);
func->size += pdf_function_size(funcs[i]);
@@ -1228,19 +1228,19 @@ load_stitching_func(pdf_function *func, pdf_document *xref, fz_obj *dict)
fz_throw(ctx, "sub function /Domain or /Range mismatch");
}
- obj = fz_dict_gets(dict, "Bounds");
- if (!fz_is_array(obj))
+ obj = pdf_dict_gets(dict, "Bounds");
+ if (!pdf_is_array(obj))
fz_throw(ctx, "stitching function has no bounds");
{
- if (fz_array_len(obj) != k - 1)
+ if (pdf_array_len(obj) != k - 1)
fz_throw(ctx, "malformed /Bounds (wrong length)");
for (i = 0; i < k-1; i++)
{
- num = fz_array_get(obj, i);
- if (!fz_is_int(num) && !fz_is_real(num))
+ num = pdf_array_get(obj, i);
+ if (!pdf_is_int(num) && !pdf_is_real(num))
fz_throw(ctx, "malformed /Bounds (item not real)");
- func->u.st.bounds[i] = fz_to_real(num);
+ func->u.st.bounds[i] = pdf_to_real(num);
if (i && func->u.st.bounds[i-1] > func->u.st.bounds[i])
fz_throw(ctx, "malformed /Bounds (item not monotonic)");
}
@@ -1250,16 +1250,16 @@ load_stitching_func(pdf_function *func, pdf_document *xref, fz_obj *dict)
fz_warn(ctx, "malformed shading function bounds (domain mismatch), proceeding anyway.");
}
- obj = fz_dict_gets(dict, "Encode");
- if (!fz_is_array(obj))
+ obj = pdf_dict_gets(dict, "Encode");
+ if (!pdf_is_array(obj))
fz_throw(ctx, "stitching function is missing encoding");
{
- if (fz_array_len(obj) != k * 2)
+ if (pdf_array_len(obj) != k * 2)
fz_throw(ctx, "malformed /Encode");
for (i = 0; i < k; i++)
{
- func->u.st.encode[i*2+0] = fz_to_real(fz_array_get(obj, i*2+0));
- func->u.st.encode[i*2+1] = fz_to_real(fz_array_get(obj, i*2+1));
+ func->u.st.encode[i*2+0] = pdf_to_real(pdf_array_get(obj, i*2+0));
+ func->u.st.encode[i*2+1] = pdf_to_real(pdf_array_get(obj, i*2+1));
}
}
}
@@ -1356,11 +1356,11 @@ pdf_function_size(pdf_function *func)
}
pdf_function *
-pdf_load_function(pdf_document *xref, fz_obj *dict)
+pdf_load_function(pdf_document *xref, pdf_obj *dict)
{
fz_context *ctx = xref->ctx;
pdf_function *func;
- fz_obj *obj;
+ pdf_obj *obj;
int i;
if ((func = pdf_find_item(ctx, pdf_free_function_imp, dict)))
@@ -1372,28 +1372,28 @@ pdf_load_function(pdf_document *xref, fz_obj *dict)
FZ_INIT_STORABLE(func, 1, pdf_free_function_imp);
func->size = sizeof(*func);
- obj = fz_dict_gets(dict, "FunctionType");
- func->type = fz_to_int(obj);
+ obj = pdf_dict_gets(dict, "FunctionType");
+ func->type = pdf_to_int(obj);
/* required for all */
- obj = fz_dict_gets(dict, "Domain");
- func->m = fz_array_len(obj) / 2;
+ obj = pdf_dict_gets(dict, "Domain");
+ func->m = pdf_array_len(obj) / 2;
for (i = 0; i < func->m; i++)
{
- func->domain[i][0] = fz_to_real(fz_array_get(obj, i * 2 + 0));
- func->domain[i][1] = fz_to_real(fz_array_get(obj, i * 2 + 1));
+ func->domain[i][0] = pdf_to_real(pdf_array_get(obj, i * 2 + 0));
+ func->domain[i][1] = pdf_to_real(pdf_array_get(obj, i * 2 + 1));
}
/* required for type0 and type4, optional otherwise */
- obj = fz_dict_gets(dict, "Range");
- if (fz_is_array(obj))
+ obj = pdf_dict_gets(dict, "Range");
+ if (pdf_is_array(obj))
{
func->has_range = 1;
- func->n = fz_array_len(obj) / 2;
+ func->n = pdf_array_len(obj) / 2;
for (i = 0; i < func->n; i++)
{
- func->range[i][0] = fz_to_real(fz_array_get(obj, i * 2 + 0));
- func->range[i][1] = fz_to_real(fz_array_get(obj, i * 2 + 1));
+ func->range[i][0] = pdf_to_real(pdf_array_get(obj, i * 2 + 0));
+ func->range[i][1] = pdf_to_real(pdf_array_get(obj, i * 2 + 1));
}
}
else
@@ -1413,7 +1413,7 @@ pdf_load_function(pdf_document *xref, fz_obj *dict)
switch(func->type)
{
case SAMPLE:
- load_sample_func(func, xref, dict, fz_to_num(dict), fz_to_gen(dict));
+ load_sample_func(func, xref, dict, pdf_to_num(dict), pdf_to_gen(dict));
break;
case EXPONENTIAL:
@@ -1425,12 +1425,12 @@ pdf_load_function(pdf_document *xref, fz_obj *dict)
break;
case POSTSCRIPT:
- load_postscript_func(func, xref, dict, fz_to_num(dict), fz_to_gen(dict));
+ load_postscript_func(func, xref, dict, pdf_to_num(dict), pdf_to_gen(dict));
break;
default:
fz_free(ctx, func);
- fz_throw(ctx, "unknown function type (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
+ fz_throw(ctx, "unknown function type (%d %d R)", pdf_to_num(dict), pdf_to_gen(dict));
}
pdf_store_item(ctx, dict, func, func->size);
@@ -1445,7 +1445,7 @@ pdf_load_function(pdf_document *xref, fz_obj *dict)
type == STITCHING ? "stitching" :
type == POSTSCRIPT ? "calculator" :
"unknown",
- fz_to_num(dict), fz_to_gen(dict));
+ pdf_to_num(dict), pdf_to_gen(dict));
}
return func;
diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c
index 22cca81d..cd2726a5 100644
--- a/pdf/pdf_image.c
+++ b/pdf/pdf_image.c
@@ -9,7 +9,7 @@ struct pdf_image_key_s {
int factor;
};
-static void pdf_load_jpx(pdf_document *xref, fz_obj *dict, pdf_image *image);
+static void pdf_load_jpx(pdf_document *xref, pdf_obj *dict, pdf_image *image);
static void
pdf_mask_color_key(fz_pixmap *pix, int n, int *colorkey)
@@ -77,12 +77,21 @@ pdf_cmp_image_key(void *k0_, void *k1_)
return k0->image == k1->image && k0->factor == k1->factor;
}
+static void
+pdf_debug_image(void *key_)
+{
+ pdf_image_key *key = (pdf_image_key *)key_;
+
+ printf("(image %d x %d sf=%d) ", key->image->w, key->image->h, key->factor);
+}
+
static fz_store_type pdf_image_store_type =
{
pdf_make_hash_image_key,
pdf_keep_image_key,
pdf_drop_image_key,
- pdf_cmp_image_key
+ pdf_cmp_image_key,
+ pdf_debug_image
};
static fz_pixmap *
@@ -281,11 +290,11 @@ pdf_image_get_pixmap(fz_context *ctx, fz_image *image_, int w, int h)
}
static pdf_image *
-pdf_load_image_imp(pdf_document *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cstm, int forcemask)
+pdf_load_image_imp(pdf_document *xref, pdf_obj *rdb, pdf_obj *dict, fz_stream *cstm, int forcemask)
{
fz_stream *stm = NULL;
pdf_image *image = NULL;
- fz_obj *obj, *res;
+ pdf_obj *obj, *res;
int w, h, bpc, n;
int imagemask;
@@ -321,11 +330,11 @@ pdf_load_image_imp(pdf_document *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cst
break; /* Out of fz_try */
}
- w = fz_to_int(fz_dict_getsa(dict, "Width", "W"));
- h = fz_to_int(fz_dict_getsa(dict, "Height", "H"));
- bpc = fz_to_int(fz_dict_getsa(dict, "BitsPerComponent", "BPC"));
- imagemask = fz_to_bool(fz_dict_getsa(dict, "ImageMask", "IM"));
- interpolate = fz_to_bool(fz_dict_getsa(dict, "Interpolate", "I"));
+ w = pdf_to_int(pdf_dict_getsa(dict, "Width", "W"));
+ h = pdf_to_int(pdf_dict_getsa(dict, "Height", "H"));
+ bpc = pdf_to_int(pdf_dict_getsa(dict, "BitsPerComponent", "BPC"));
+ imagemask = pdf_to_bool(pdf_dict_getsa(dict, "ImageMask", "IM"));
+ interpolate = pdf_to_bool(pdf_dict_getsa(dict, "Interpolate", "I"));
indexed = 0;
usecolorkey = 0;
@@ -347,13 +356,13 @@ pdf_load_image_imp(pdf_document *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cst
if (h > (1 << 16))
fz_throw(ctx, "image is too high");
- obj = fz_dict_getsa(dict, "ColorSpace", "CS");
+ obj = pdf_dict_getsa(dict, "ColorSpace", "CS");
if (obj && !imagemask && !forcemask)
{
/* colorspace resource lookup is only done for inline images */
- if (fz_is_name(obj))
+ if (pdf_is_name(obj))
{
- res = fz_dict_get(fz_dict_gets(rdb, "ColorSpace"), obj);
+ res = pdf_dict_get(pdf_dict_gets(rdb, "ColorSpace"), obj);
if (res)
obj = res;
}
@@ -371,11 +380,11 @@ pdf_load_image_imp(pdf_document *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cst
n = 1;
}
- obj = fz_dict_getsa(dict, "Decode", "D");
+ obj = pdf_dict_getsa(dict, "Decode", "D");
if (obj)
{
for (i = 0; i < n * 2; i++)
- image->decode[i] = fz_to_real(fz_array_get(obj, i));
+ image->decode[i] = pdf_to_real(pdf_array_get(obj, i));
}
else
{
@@ -384,8 +393,8 @@ pdf_load_image_imp(pdf_document *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cst
image->decode[i] = i & 1 ? maxval : 0;
}
- obj = fz_dict_getsa(dict, "SMask", "Mask");
- if (fz_is_dict(obj))
+ obj = pdf_dict_getsa(dict, "SMask", "Mask");
+ if (pdf_is_dict(obj))
{
/* Not allowed for inline images */
if (!cstm)
@@ -394,17 +403,17 @@ pdf_load_image_imp(pdf_document *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cst
/* RJW: "cannot load image mask/softmask" */
}
}
- else if (fz_is_array(obj))
+ else if (pdf_is_array(obj))
{
usecolorkey = 1;
for (i = 0; i < n * 2; i++)
{
- if (!fz_is_int(fz_array_get(obj, i)))
+ if (!pdf_is_int(pdf_array_get(obj, i)))
{
fz_warn(ctx, "invalid value in color key mask");
usecolorkey = 0;
}
- image->colorkey[i] = fz_to_int(fz_array_get(obj, i));
+ image->colorkey[i] = pdf_to_int(pdf_array_get(obj, i));
}
}
@@ -425,7 +434,7 @@ pdf_load_image_imp(pdf_document *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cst
{
/* Just load the compressed image data now and we can
* decode it on demand. */
- image->buffer = pdf_load_image_stream(xref, fz_to_num(dict), fz_to_gen(dict), &image->params);
+ image->buffer = pdf_load_image_stream(xref, pdf_to_num(dict), pdf_to_gen(dict), &image->params);
break; /* Out of fz_try */
}
@@ -437,8 +446,8 @@ pdf_load_image_imp(pdf_document *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cst
}
else
{
- stm = pdf_open_stream(xref, fz_to_num(dict), fz_to_gen(dict));
- /* RJW: "cannot open image data stream (%d 0 R)", fz_to_num(dict) */
+ stm = pdf_open_stream(xref, pdf_to_num(dict), pdf_to_gen(dict));
+ /* RJW: "cannot open image data stream (%d 0 R)", pdf_to_num(dict) */
}
image->tile = decomp_image_from_stream(ctx, stm, image, cstm != NULL, indexed, 1);
@@ -452,35 +461,35 @@ pdf_load_image_imp(pdf_document *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cst
}
fz_image *
-pdf_load_inline_image(pdf_document *xref, fz_obj *rdb, fz_obj *dict, fz_stream *file)
+pdf_load_inline_image(pdf_document *xref, pdf_obj *rdb, pdf_obj *dict, fz_stream *file)
{
return (fz_image *)pdf_load_image_imp(xref, rdb, dict, file, 0);
/* RJW: "cannot load inline image" */
}
int
-pdf_is_jpx_image(fz_context *ctx, fz_obj *dict)
+pdf_is_jpx_image(fz_context *ctx, pdf_obj *dict)
{
- fz_obj *filter;
+ pdf_obj *filter;
int i, n;
- filter = fz_dict_gets(dict, "Filter");
- if (!strcmp(fz_to_name(filter), "JPXDecode"))
+ filter = pdf_dict_gets(dict, "Filter");
+ if (!strcmp(pdf_to_name(filter), "JPXDecode"))
return 1;
- n = fz_array_len(filter);
+ n = pdf_array_len(filter);
for (i = 0; i < n; i++)
- if (!strcmp(fz_to_name(fz_array_get(filter, i)), "JPXDecode"))
+ if (!strcmp(pdf_to_name(pdf_array_get(filter, i)), "JPXDecode"))
return 1;
return 0;
}
static void
-pdf_load_jpx(pdf_document *xref, fz_obj *dict, pdf_image *image)
+pdf_load_jpx(pdf_document *xref, pdf_obj *dict, pdf_image *image)
{
fz_buffer *buf = NULL;
fz_colorspace *colorspace = NULL;
fz_pixmap *img = NULL;
- fz_obj *obj;
+ pdf_obj *obj;
fz_context *ctx = xref->ctx;
int indexed = 0;
@@ -488,13 +497,13 @@ pdf_load_jpx(pdf_document *xref, fz_obj *dict, pdf_image *image)
fz_var(buf);
fz_var(colorspace);
- buf = pdf_load_stream(xref, fz_to_num(dict), fz_to_gen(dict));
+ buf = pdf_load_stream(xref, pdf_to_num(dict), pdf_to_gen(dict));
/* RJW: "cannot load jpx image data" */
/* FIXME: We can't handle decode arrays for indexed images currently */
fz_try(ctx)
{
- obj = fz_dict_gets(dict, "ColorSpace");
+ obj = pdf_dict_gets(dict, "ColorSpace");
if (obj)
{
colorspace = pdf_load_colorspace(xref, obj);
@@ -511,21 +520,21 @@ pdf_load_jpx(pdf_document *xref, fz_obj *dict, pdf_image *image)
fz_drop_buffer(ctx, buf);
buf = NULL;
- obj = fz_dict_getsa(dict, "SMask", "Mask");
- if (fz_is_dict(obj))
+ obj = pdf_dict_getsa(dict, "SMask", "Mask");
+ if (pdf_is_dict(obj))
{
image->base.mask = (fz_image *)pdf_load_image_imp(xref, NULL, obj, NULL, 1);
/* RJW: "cannot load image mask/softmask" */
}
- obj = fz_dict_getsa(dict, "Decode", "D");
+ obj = pdf_dict_getsa(dict, "Decode", "D");
if (obj && !indexed)
{
float decode[FZ_MAX_COLORS * 2];
int i;
for (i = 0; i < img->n * 2; i++)
- decode[i] = fz_to_real(fz_array_get(obj, i));
+ decode[i] = pdf_to_real(pdf_array_get(obj, i));
fz_decode_tile(img, decode);
}
@@ -562,7 +571,7 @@ pdf_image_size(fz_context *ctx, pdf_image *im)
}
fz_image *
-pdf_load_image(pdf_document *xref, fz_obj *dict)
+pdf_load_image(pdf_document *xref, pdf_obj *dict)
{
fz_context *ctx = xref->ctx;
pdf_image *image;
@@ -573,7 +582,7 @@ pdf_load_image(pdf_document *xref, fz_obj *dict)
}
image = pdf_load_image_imp(xref, NULL, dict, NULL, 0);
- /* RJW: "cannot load image (%d 0 R)", fz_to_num(dict) */
+ /* RJW: "cannot load image (%d 0 R)", pdf_to_num(dict) */
pdf_store_item(ctx, dict, image, pdf_image_size(ctx, image));
diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c
index 1cfe6a96..d2270eaa 100644
--- a/pdf/pdf_interpret.c
+++ b/pdf/pdf_interpret.c
@@ -70,7 +70,7 @@ struct pdf_csi_s
char *event; /* "View", "Print", "Export" */
/* interpreter stack */
- fz_obj *obj;
+ pdf_obj *obj;
char name[256];
unsigned char string[256];
int string_len;
@@ -104,8 +104,8 @@ struct pdf_csi_s
fz_cookie *cookie;
};
-static void pdf_run_buffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents);
-static void pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix transform);
+static void pdf_run_buffer(pdf_csi *csi, pdf_obj *rdb, fz_buffer *contents);
+static void pdf_run_xobject(pdf_csi *csi, pdf_obj *resources, pdf_xobject *xobj, fz_matrix transform);
static void pdf_show_pattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what);
static int
@@ -120,20 +120,20 @@ ocg_intents_include(pdf_ocg_descriptor *desc, char *name)
if (!desc->intent)
return (strcmp(name, "View") == 0);
- if (fz_is_name(desc->intent))
+ if (pdf_is_name(desc->intent))
{
- char *intent = fz_to_name(desc->intent);
+ char *intent = pdf_to_name(desc->intent);
if (strcmp(intent, "All") == 0)
return 1;
return (strcmp(intent, name) == 0);
}
- if (!fz_is_array(desc->intent))
+ if (!pdf_is_array(desc->intent))
return 0;
- len = fz_array_len(desc->intent);
+ len = pdf_array_len(desc->intent);
for (i=0; i < len; i++)
{
- char *intent = fz_to_name(fz_array_get(desc->intent, i));
+ char *intent = pdf_to_name(pdf_array_get(desc->intent, i));
if (strcmp(intent, "All") == 0)
return 1;
if (strcmp(intent, name) == 0)
@@ -143,10 +143,10 @@ ocg_intents_include(pdf_ocg_descriptor *desc, char *name)
}
static int
-pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
+pdf_is_hidden_ocg(pdf_obj *ocg, pdf_csi *csi, pdf_obj *rdb)
{
char event_state[16];
- fz_obj *obj, *obj2;
+ pdf_obj *obj, *obj2;
char *type;
pdf_ocg_descriptor *desc = csi->xref->ocg;
@@ -155,9 +155,9 @@ pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
return 0;
/* If we've been handed a name, look it up in the properties. */
- if (fz_is_name(ocg))
+ if (pdf_is_name(ocg))
{
- ocg = fz_dict_gets(fz_dict_gets(rdb, "Properties"), fz_to_name(ocg));
+ ocg = pdf_dict_gets(pdf_dict_gets(rdb, "Properties"), pdf_to_name(ocg));
}
/* If we haven't been given an ocg at all, then we're visible */
if (!ocg)
@@ -166,13 +166,13 @@ pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
fz_strlcpy(event_state, csi->event, sizeof event_state);
fz_strlcat(event_state, "State", sizeof event_state);
- type = fz_to_name(fz_dict_gets(ocg, "Type"));
+ type = pdf_to_name(pdf_dict_gets(ocg, "Type"));
if (strcmp(type, "OCG") == 0)
{
/* An Optional Content Group */
- int num = fz_to_num(ocg);
- int gen = fz_to_gen(ocg);
+ int num = pdf_to_num(ocg);
+ int gen = pdf_to_gen(ocg);
int len = desc->len;
int i;
@@ -188,19 +188,19 @@ pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
/* Check Intents; if our intent is not part of the set given
* by the current config, we should ignore it. */
- obj = fz_dict_gets(ocg, "Intent");
- if (fz_is_name(obj))
+ obj = pdf_dict_gets(ocg, "Intent");
+ if (pdf_is_name(obj))
{
/* If it doesn't match, it's hidden */
- if (ocg_intents_include(desc, fz_to_name(obj)) == 0)
+ if (ocg_intents_include(desc, pdf_to_name(obj)) == 0)
return 1;
}
- else if (fz_is_array(obj))
+ else if (pdf_is_array(obj))
{
int match = 0;
- len = fz_array_len(obj);
+ len = pdf_array_len(obj);
for (i=0; i<len; i++) {
- match |= ocg_intents_include(desc, fz_to_name(fz_array_get(obj, i)));
+ match |= ocg_intents_include(desc, pdf_to_name(pdf_array_get(obj, i)));
if (match)
break;
}
@@ -224,15 +224,15 @@ pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
* correspond to entries in the AS list in the OCG config.
* Given that we don't handle Zoom or User, or Language
* dicts, this is not really a problem. */
- obj = fz_dict_gets(ocg, "Usage");
- if (!fz_is_dict(obj))
+ obj = pdf_dict_gets(ocg, "Usage");
+ if (!pdf_is_dict(obj))
return 0;
/* FIXME: Should look at Zoom (and return hidden if out of
* max/min range) */
/* FIXME: Could provide hooks to the caller to check if
* User is appropriate - if not return hidden. */
- obj2 = fz_dict_gets(obj, csi->event);
- if (strcmp(fz_to_name(fz_dict_gets(obj2, event_state)), "OFF") == 0)
+ obj2 = pdf_dict_gets(obj, csi->event);
+ if (strcmp(pdf_to_name(pdf_dict_gets(obj2, event_state)), "OFF") == 0)
{
return 1;
}
@@ -244,12 +244,12 @@ pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
char *name;
int combine, on;
- obj = fz_dict_gets(ocg, "VE");
- if (fz_is_array(obj)) {
+ obj = pdf_dict_gets(ocg, "VE");
+ if (pdf_is_array(obj)) {
/* FIXME: Calculate visibility from array */
return 0;
}
- name = fz_to_name(fz_dict_gets(ocg, "P"));
+ name = pdf_to_name(pdf_dict_gets(ocg, "P"));
/* Set combine; Bit 0 set => AND, Bit 1 set => true means
* Off, otherwise true means On */
if (strcmp(name, "AllOn") == 0)
@@ -269,15 +269,15 @@ pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
combine = 0;
}
- obj = fz_dict_gets(ocg, "OCGs");
+ obj = pdf_dict_gets(ocg, "OCGs");
on = combine & 1;
- if (fz_is_array(obj)) {
+ if (pdf_is_array(obj)) {
int i, len;
- len = fz_array_len(obj);
+ len = pdf_array_len(obj);
for (i = 0; i < len; i++)
{
int hidden;
- hidden = pdf_is_hidden_ocg(fz_array_get(obj, i), csi, rdb);
+ hidden = pdf_is_hidden_ocg(pdf_array_get(obj, i), csi, rdb);
if ((combine & 1) == 0)
hidden = !hidden;
if (combine & 2)
@@ -831,26 +831,26 @@ pdf_show_string(pdf_csi *csi, unsigned char *buf, int len)
}
static void
-pdf_show_text(pdf_csi *csi, fz_obj *text)
+pdf_show_text(pdf_csi *csi, pdf_obj *text)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
int i;
- if (fz_is_array(text))
+ if (pdf_is_array(text))
{
- int n = fz_array_len(text);
+ int n = pdf_array_len(text);
for (i = 0; i < n; i++)
{
- fz_obj *item = fz_array_get(text, i);
- if (fz_is_string(item))
- pdf_show_string(csi, (unsigned char *)fz_to_str_buf(item), fz_to_str_len(item));
+ pdf_obj *item = pdf_array_get(text, i);
+ if (pdf_is_string(item))
+ pdf_show_string(csi, (unsigned char *)pdf_to_str_buf(item), pdf_to_str_len(item));
else
- pdf_show_space(csi, - fz_to_real(item) * gstate->size * 0.001f);
+ pdf_show_space(csi, - pdf_to_real(item) * gstate->size * 0.001f);
}
}
- else if (fz_is_string(text))
+ else if (pdf_is_string(text))
{
- pdf_show_string(csi, (unsigned char *)fz_to_str_buf(text), fz_to_str_len(text));
+ pdf_show_string(csi, (unsigned char *)pdf_to_str_buf(text), pdf_to_str_len(text));
}
}
@@ -1004,7 +1004,7 @@ pdf_clear_stack(pdf_csi *csi)
int i;
if (csi->obj)
- fz_drop_obj(csi->obj);
+ pdf_drop_obj(csi->obj);
csi->obj = NULL;
csi->name[0] = 0;
@@ -1335,7 +1335,7 @@ pdf_show_pattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what)
}
static void
-pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix transform)
+pdf_run_xobject(pdf_csi *csi, pdf_obj *resources, pdf_xobject *xobj, fz_matrix transform)
{
fz_context *ctx = csi->dev->ctx;
pdf_gstate *gstate = NULL;
@@ -1344,7 +1344,7 @@ pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tr
int popmask;
/* Avoid infinite recursion */
- if (xobj == NULL || fz_dict_mark(xobj->me))
+ if (xobj == NULL || pdf_dict_mark(xobj->me))
return;
fz_var(gstate);
@@ -1425,7 +1425,7 @@ pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tr
pdf_grestore(csi);
}
- fz_dict_unmark(xobj->me);
+ pdf_dict_unmark(xobj->me);
}
fz_catch(ctx)
{
@@ -1442,7 +1442,7 @@ pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tr
}
static void
-pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
+pdf_run_extgstate(pdf_csi *csi, pdf_obj *rdb, pdf_obj *extgstate)
{
fz_context *ctx = csi->dev->ctx;
pdf_gstate *gstate = csi->gstate + csi->gtop;
@@ -1451,18 +1451,18 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
pdf_flush_text(csi);
- n = fz_dict_len(extgstate);
+ n = pdf_dict_len(extgstate);
for (i = 0; i < n; i++)
{
- fz_obj *key = fz_dict_get_key(extgstate, i);
- fz_obj *val = fz_dict_get_val(extgstate, i);
- char *s = fz_to_name(key);
+ pdf_obj *key = pdf_dict_get_key(extgstate, i);
+ pdf_obj *val = pdf_dict_get_val(extgstate, i);
+ char *s = pdf_to_name(key);
if (!strcmp(s, "Font"))
{
- if (fz_is_array(val) && fz_array_len(val) == 2)
+ if (pdf_is_array(val) && pdf_array_len(val) == 2)
{
- fz_obj *font = fz_array_get(val, 0);
+ pdf_obj *font = pdf_array_get(val, 0);
if (gstate->font)
{
@@ -1471,10 +1471,10 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
}
gstate->font = pdf_load_font(csi->xref, rdb, font);
- /* RJW: "cannot load font (%d %d R)", fz_to_num(font), fz_to_gen(font) */
+ /* RJW: "cannot load font (%d %d R)", pdf_to_num(font), pdf_to_gen(font) */
if (!gstate->font)
fz_throw(ctx, "cannot find font in store");
- gstate->size = fz_to_real(fz_array_get(val, 1));
+ gstate->size = pdf_to_real(pdf_array_get(val, 1));
}
else
fz_throw(ctx, "malformed /Font dictionary");
@@ -1483,59 +1483,59 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
else if (!strcmp(s, "LC"))
{
csi->dev->flags &= ~(FZ_DEVFLAG_STARTCAP_UNDEFINED | FZ_DEVFLAG_DASHCAP_UNDEFINED | FZ_DEVFLAG_ENDCAP_UNDEFINED);
- gstate->stroke_state.start_cap = fz_to_int(val);
- gstate->stroke_state.dash_cap = fz_to_int(val);
- gstate->stroke_state.end_cap = fz_to_int(val);
+ gstate->stroke_state.start_cap = pdf_to_int(val);
+ gstate->stroke_state.dash_cap = pdf_to_int(val);
+ gstate->stroke_state.end_cap = pdf_to_int(val);
}
else if (!strcmp(s, "LW"))
{
csi->dev->flags &= ~FZ_DEVFLAG_LINEWIDTH_UNDEFINED;
- gstate->stroke_state.linewidth = fz_to_real(val);
+ gstate->stroke_state.linewidth = pdf_to_real(val);
}
else if (!strcmp(s, "LJ"))
{
csi->dev->flags &= ~FZ_DEVFLAG_LINEJOIN_UNDEFINED;
- gstate->stroke_state.linejoin = fz_to_int(val);
+ gstate->stroke_state.linejoin = pdf_to_int(val);
}
else if (!strcmp(s, "ML"))
{
csi->dev->flags &= ~FZ_DEVFLAG_MITERLIMIT_UNDEFINED;
- gstate->stroke_state.miterlimit = fz_to_real(val);
+ gstate->stroke_state.miterlimit = pdf_to_real(val);
}
else if (!strcmp(s, "D"))
{
- if (fz_is_array(val) && fz_array_len(val) == 2)
+ if (pdf_is_array(val) && pdf_array_len(val) == 2)
{
- fz_obj *dashes = fz_array_get(val, 0);
- gstate->stroke_state.dash_len = MAX(fz_array_len(dashes), 32);
+ pdf_obj *dashes = pdf_array_get(val, 0);
+ gstate->stroke_state.dash_len = MAX(pdf_array_len(dashes), 32);
for (k = 0; k < gstate->stroke_state.dash_len; k++)
- gstate->stroke_state.dash_list[k] = fz_to_real(fz_array_get(dashes, k));
- gstate->stroke_state.dash_phase = fz_to_real(fz_array_get(val, 1));
+ gstate->stroke_state.dash_list[k] = pdf_to_real(pdf_array_get(dashes, k));
+ gstate->stroke_state.dash_phase = pdf_to_real(pdf_array_get(val, 1));
}
else
fz_throw(ctx, "malformed /D");
}
else if (!strcmp(s, "CA"))
- gstate->stroke.alpha = fz_to_real(val);
+ gstate->stroke.alpha = pdf_to_real(val);
else if (!strcmp(s, "ca"))
- gstate->fill.alpha = fz_to_real(val);
+ gstate->fill.alpha = pdf_to_real(val);
else if (!strcmp(s, "BM"))
{
- if (fz_is_array(val))
- val = fz_array_get(val, 0);
- gstate->blendmode = fz_find_blendmode(fz_to_name(val));
+ if (pdf_is_array(val))
+ val = pdf_array_get(val, 0);
+ gstate->blendmode = fz_find_blendmode(pdf_to_name(val));
}
else if (!strcmp(s, "SMask"))
{
- if (fz_is_dict(val))
+ if (pdf_is_dict(val))
{
pdf_xobject *xobj;
- fz_obj *group, *luminosity, *bc;
+ pdf_obj *group, *luminosity, *bc;
if (gstate->softmask)
{
@@ -1543,11 +1543,11 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
gstate->softmask = NULL;
}
- group = fz_dict_gets(val, "G");
+ group = pdf_dict_gets(val, "G");
if (!group)
- fz_throw(ctx, "cannot load softmask xobject (%d %d R)", fz_to_num(val), fz_to_gen(val));
+ fz_throw(ctx, "cannot load softmask xobject (%d %d R)", pdf_to_num(val), pdf_to_gen(val));
xobj = pdf_load_xobject(csi->xref, group);
- /* RJW: "cannot load xobject (%d %d R)", fz_to_num(val), fz_to_gen(val) */
+ /* RJW: "cannot load xobject (%d %d R)", pdf_to_num(val), pdf_to_gen(val) */
colorspace = xobj->colorspace;
if (!colorspace)
@@ -1558,20 +1558,20 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
for (k = 0; k < colorspace->n; k++)
gstate->softmask_bc[k] = 0;
- bc = fz_dict_gets(val, "BC");
- if (fz_is_array(bc))
+ bc = pdf_dict_gets(val, "BC");
+ if (pdf_is_array(bc))
{
for (k = 0; k < colorspace->n; k++)
- gstate->softmask_bc[k] = fz_to_real(fz_array_get(bc, k));
+ gstate->softmask_bc[k] = pdf_to_real(pdf_array_get(bc, k));
}
- luminosity = fz_dict_gets(val, "S");
- if (fz_is_name(luminosity) && !strcmp(fz_to_name(luminosity), "Luminosity"))
+ luminosity = pdf_dict_gets(val, "S");
+ if (pdf_is_name(luminosity) && !strcmp(pdf_to_name(luminosity), "Luminosity"))
gstate->luminosity = 1;
else
gstate->luminosity = 0;
}
- else if (fz_is_name(val) && !strcmp(fz_to_name(val), "None"))
+ else if (pdf_is_name(val) && !strcmp(pdf_to_name(val), "None"))
{
if (gstate->softmask)
{
@@ -1583,7 +1583,7 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
else if (!strcmp(s, "TR"))
{
- if (!fz_is_name(val) || strcmp(fz_to_name(val), "Identity"))
+ if (!pdf_is_name(val) || strcmp(pdf_to_name(val), "Identity"))
fz_warn(ctx, "ignoring transfer function");
}
}
@@ -1593,9 +1593,9 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
* Operators
*/
-static void pdf_run_BDC(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_BDC(pdf_csi *csi, pdf_obj *rdb)
{
- fz_obj *ocg;
+ pdf_obj *ocg;
/* If we are already in a hidden OCG, then we'll still be hidden -
* just increment the depth so we pop back to visibility when we've
@@ -1606,14 +1606,14 @@ static void pdf_run_BDC(pdf_csi *csi, fz_obj *rdb)
return;
}
- ocg = fz_dict_gets(fz_dict_gets(rdb, "Properties"), csi->name);
+ ocg = pdf_dict_gets(pdf_dict_gets(rdb, "Properties"), csi->name);
if (!ocg)
{
/* No Properties array, or name not found in the properties
* means visible. */
return;
}
- if (strcmp(fz_to_name(fz_dict_gets(ocg, "Type")), "OCG") != 0)
+ if (strcmp(pdf_to_name(pdf_dict_gets(ocg, "Type")), "OCG") != 0)
{
/* Wrong type of property */
return;
@@ -1622,12 +1622,12 @@ static void pdf_run_BDC(pdf_csi *csi, fz_obj *rdb)
csi->in_hidden_ocg++;
}
-static void pdf_run_BI(pdf_csi *csi, fz_obj *rdb, fz_stream *file)
+static void pdf_run_BI(pdf_csi *csi, pdf_obj *rdb, fz_stream *file)
{
fz_context *ctx = csi->dev->ctx;
int ch;
fz_image *img;
- fz_obj *obj;
+ pdf_obj *obj;
obj = pdf_parse_dict(csi->xref, file, &csi->xref->lexbuf.base);
/* RJW: "cannot parse inline image dictionary" */
@@ -1639,7 +1639,7 @@ static void pdf_run_BI(pdf_csi *csi, fz_obj *rdb, fz_stream *file)
fz_read_byte(file);
img = pdf_load_inline_image(csi->xref, rdb, obj, file);
- fz_drop_obj(obj);
+ pdf_drop_obj(obj);
/* RJW: "cannot load inline image" */
pdf_show_image(csi, img);
@@ -1688,11 +1688,11 @@ static void pdf_run_Bstar(pdf_csi *csi)
pdf_show_path(csi, 0, 1, 1, 1);
}
-static void pdf_run_cs_imp(pdf_csi *csi, fz_obj *rdb, int what)
+static void pdf_run_cs_imp(pdf_csi *csi, pdf_obj *rdb, int what)
{
fz_context *ctx = csi->dev->ctx;
fz_colorspace *colorspace;
- fz_obj *obj, *dict;
+ pdf_obj *obj, *dict;
if (!strcmp(csi->name, "Pattern"))
{
@@ -1708,14 +1708,14 @@ static void pdf_run_cs_imp(pdf_csi *csi, fz_obj *rdb, int what)
colorspace = fz_device_cmyk; /* No fz_keep_colorspace as static */
else
{
- dict = fz_dict_gets(rdb, "ColorSpace");
+ dict = pdf_dict_gets(rdb, "ColorSpace");
if (!dict)
fz_throw(ctx, "cannot find ColorSpace dictionary");
- obj = fz_dict_gets(dict, csi->name);
+ obj = pdf_dict_gets(dict, csi->name);
if (!obj)
fz_throw(ctx, "cannot find colorspace resource '%s'", csi->name);
colorspace = pdf_load_colorspace(csi->xref, obj);
- /* RJW: "cannot load colorspace (%d 0 R)", fz_to_num(obj) */
+ /* RJW: "cannot load colorspace (%d 0 R)", pdf_to_num(obj) */
}
pdf_set_colorspace(csi, what, colorspace);
@@ -1724,7 +1724,7 @@ static void pdf_run_cs_imp(pdf_csi *csi, fz_obj *rdb, int what)
}
}
-static void pdf_run_CS(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_CS(pdf_csi *csi, pdf_obj *rdb)
{
csi->dev->flags &= ~FZ_DEVFLAG_STROKECOLOR_UNDEFINED;
@@ -1732,7 +1732,7 @@ static void pdf_run_CS(pdf_csi *csi, fz_obj *rdb)
/* RJW: "cannot set colorspace" */
}
-static void pdf_run_cs(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_cs(pdf_csi *csi, pdf_obj *rdb)
{
csi->dev->flags &= ~FZ_DEVFLAG_FILLCOLOR_UNDEFINED;
@@ -1744,41 +1744,41 @@ static void pdf_run_DP(pdf_csi *csi)
{
}
-static void pdf_run_Do(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_Do(pdf_csi *csi, pdf_obj *rdb)
{
fz_context *ctx = csi->dev->ctx;
- fz_obj *dict;
- fz_obj *obj;
- fz_obj *subtype;
+ pdf_obj *dict;
+ pdf_obj *obj;
+ pdf_obj *subtype;
- dict = fz_dict_gets(rdb, "XObject");
+ dict = pdf_dict_gets(rdb, "XObject");
if (!dict)
fz_throw(ctx, "cannot find XObject dictionary when looking for: '%s'", csi->name);
- obj = fz_dict_gets(dict, csi->name);
+ obj = pdf_dict_gets(dict, csi->name);
if (!obj)
fz_throw(ctx, "cannot find xobject resource: '%s'", csi->name);
- subtype = fz_dict_gets(obj, "Subtype");
- if (!fz_is_name(subtype))
+ subtype = pdf_dict_gets(obj, "Subtype");
+ if (!pdf_is_name(subtype))
fz_throw(ctx, "no XObject subtype specified");
- if (pdf_is_hidden_ocg(fz_dict_gets(obj, "OC"), csi, rdb))
+ if (pdf_is_hidden_ocg(pdf_dict_gets(obj, "OC"), csi, rdb))
return;
- if (!strcmp(fz_to_name(subtype), "Form") && fz_dict_gets(obj, "Subtype2"))
- subtype = fz_dict_gets(obj, "Subtype2");
+ if (!strcmp(pdf_to_name(subtype), "Form") && pdf_dict_gets(obj, "Subtype2"))
+ subtype = pdf_dict_gets(obj, "Subtype2");
- if (!strcmp(fz_to_name(subtype), "Form"))
+ if (!strcmp(pdf_to_name(subtype), "Form"))
{
pdf_xobject *xobj;
xobj = pdf_load_xobject(csi->xref, obj);
- /* RJW: "cannot load xobject (%d %d R)", fz_to_num(obj), fz_to_gen(obj) */
+ /* RJW: "cannot load xobject (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj) */
/* Inherit parent resources, in case this one was empty XXX check where it's loaded */
if (!xobj->resources)
- xobj->resources = fz_keep_obj(rdb);
+ xobj->resources = pdf_keep_obj(rdb);
fz_try(ctx)
{
@@ -1787,18 +1787,18 @@ static void pdf_run_Do(pdf_csi *csi, fz_obj *rdb)
fz_catch(ctx)
{
pdf_drop_xobject(ctx, xobj);
- fz_throw(ctx, "cannot draw xobject (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
+ fz_throw(ctx, "cannot draw xobject (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj));
}
pdf_drop_xobject(ctx, xobj);
}
- else if (!strcmp(fz_to_name(subtype), "Image"))
+ else if (!strcmp(pdf_to_name(subtype), "Image"))
{
if ((csi->dev->hints & FZ_IGNORE_IMAGE) == 0)
{
fz_image *img = pdf_load_image(csi->xref, obj);
- /* RJW: "cannot load image (%d %d R)", fz_to_num(obj), fz_to_gen(obj) */
+ /* RJW: "cannot load image (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj) */
fz_try(ctx)
{
pdf_show_image(csi, img);
@@ -1814,14 +1814,14 @@ static void pdf_run_Do(pdf_csi *csi, fz_obj *rdb)
}
}
- else if (!strcmp(fz_to_name(subtype), "PS"))
+ else if (!strcmp(pdf_to_name(subtype), "PS"))
{
fz_warn(ctx, "ignoring XObject with subtype PS");
}
else
{
- fz_throw(ctx, "unknown XObject subtype: '%s'", fz_to_name(subtype));
+ fz_throw(ctx, "unknown XObject subtype: '%s'", pdf_to_name(subtype));
}
}
@@ -1899,12 +1899,12 @@ static void pdf_run_S(pdf_csi *csi)
pdf_show_path(csi, 0, 0, 1, 0);
}
-static void pdf_run_SC_imp(pdf_csi *csi, fz_obj *rdb, int what, pdf_material *mat)
+static void pdf_run_SC_imp(pdf_csi *csi, pdf_obj *rdb, int what, pdf_material *mat)
{
fz_context *ctx = csi->dev->ctx;
- fz_obj *patterntype;
- fz_obj *dict;
- fz_obj *obj;
+ pdf_obj *patterntype;
+ pdf_obj *dict;
+ pdf_obj *obj;
int kind;
kind = mat->kind;
@@ -1921,35 +1921,35 @@ static void pdf_run_SC_imp(pdf_csi *csi, fz_obj *rdb, int what, pdf_material *ma
break;
case PDF_MAT_PATTERN:
- dict = fz_dict_gets(rdb, "Pattern");
+ dict = pdf_dict_gets(rdb, "Pattern");
if (!dict)
fz_throw(ctx, "cannot find Pattern dictionary");
- obj = fz_dict_gets(dict, csi->name);
+ obj = pdf_dict_gets(dict, csi->name);
if (!obj)
fz_throw(ctx, "cannot find pattern resource '%s'", csi->name);
- patterntype = fz_dict_gets(obj, "PatternType");
+ patterntype = pdf_dict_gets(obj, "PatternType");
- if (fz_to_int(patterntype) == 1)
+ if (pdf_to_int(patterntype) == 1)
{
pdf_pattern *pat;
pat = pdf_load_pattern(csi->xref, obj);
- /* RJW: "cannot load pattern (%d 0 R)", fz_to_num(obj) */
+ /* RJW: "cannot load pattern (%d 0 R)", pdf_to_num(obj) */
pdf_set_pattern(csi, what, pat, csi->top > 0 ? csi->stack : NULL);
pdf_drop_pattern(ctx, pat);
}
- else if (fz_to_int(patterntype) == 2)
+ else if (pdf_to_int(patterntype) == 2)
{
fz_shade *shd;
shd = pdf_load_shading(csi->xref, obj);
- /* RJW: "cannot load shading (%d 0 R)", fz_to_num(obj) */
+ /* RJW: "cannot load shading (%d 0 R)", pdf_to_num(obj) */
pdf_set_shade(csi, what, shd);
fz_drop_shade(ctx, shd);
}
else
{
- fz_throw(ctx, "unknown pattern type: %d", fz_to_int(patterntype));
+ fz_throw(ctx, "unknown pattern type: %d", pdf_to_int(patterntype));
}
break;
@@ -1958,7 +1958,7 @@ static void pdf_run_SC_imp(pdf_csi *csi, fz_obj *rdb, int what, pdf_material *ma
}
}
-static void pdf_run_SC(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_SC(pdf_csi *csi, pdf_obj *rdb)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
csi->dev->flags &= ~FZ_DEVFLAG_STROKECOLOR_UNDEFINED;
@@ -1966,7 +1966,7 @@ static void pdf_run_SC(pdf_csi *csi, fz_obj *rdb)
/* RJW: "cannot set color and colorspace" */
}
-static void pdf_run_sc(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_sc(pdf_csi *csi, pdf_obj *rdb)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
csi->dev->flags &= ~FZ_DEVFLAG_FILLCOLOR_UNDEFINED;
@@ -2000,28 +2000,28 @@ static void pdf_run_TL(pdf_csi *csi)
gstate->leading = csi->stack[0];
}
-static void pdf_run_Tf(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_Tf(pdf_csi *csi, pdf_obj *rdb)
{
fz_context *ctx = csi->dev->ctx;
pdf_gstate *gstate = csi->gstate + csi->gtop;
- fz_obj *dict;
- fz_obj *obj;
+ pdf_obj *dict;
+ pdf_obj *obj;
gstate->size = csi->stack[0];
if (gstate->font)
pdf_drop_font(ctx, gstate->font);
gstate->font = NULL;
- dict = fz_dict_gets(rdb, "Font");
+ dict = pdf_dict_gets(rdb, "Font");
if (!dict)
fz_throw(ctx, "cannot find Font dictionary");
- obj = fz_dict_gets(dict, csi->name);
+ obj = pdf_dict_gets(dict, csi->name);
if (!obj)
fz_throw(ctx, "cannot find font resource: '%s'", csi->name);
gstate->font = pdf_load_font(csi->xref, rdb, obj);
- /* RJW: "cannot load font (%d 0 R)", fz_to_num(obj) */
+ /* RJW: "cannot load font (%d 0 R)", pdf_to_num(obj) */
}
static void pdf_run_Tr(pdf_csi *csi)
@@ -2141,13 +2141,13 @@ static void pdf_run_cm(pdf_csi *csi)
static void pdf_run_d(pdf_csi *csi)
{
pdf_gstate *gstate = csi->gstate + csi->gtop;
- fz_obj *array;
+ pdf_obj *array;
int i;
array = csi->obj;
- gstate->stroke_state.dash_len = MIN(fz_array_len(array), nelem(gstate->stroke_state.dash_list));
+ gstate->stroke_state.dash_len = MIN(pdf_array_len(array), nelem(gstate->stroke_state.dash_list));
for (i = 0; i < gstate->stroke_state.dash_len; i++)
- gstate->stroke_state.dash_list[i] = fz_to_real(fz_array_get(array, i));
+ gstate->stroke_state.dash_list[i] = pdf_to_real(pdf_array_get(array, i));
gstate->stroke_state.dash_phase = csi->stack[0];
}
@@ -2186,22 +2186,22 @@ static void pdf_run_g(pdf_csi *csi)
pdf_set_color(csi, PDF_FILL, csi->stack);
}
-static void pdf_run_gs(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_gs(pdf_csi *csi, pdf_obj *rdb)
{
- fz_obj *dict;
- fz_obj *obj;
+ pdf_obj *dict;
+ pdf_obj *obj;
fz_context *ctx = csi->dev->ctx;
- dict = fz_dict_gets(rdb, "ExtGState");
+ dict = pdf_dict_gets(rdb, "ExtGState");
if (!dict)
fz_throw(ctx, "cannot find ExtGState dictionary");
- obj = fz_dict_gets(dict, csi->name);
+ obj = pdf_dict_gets(dict, csi->name);
if (!obj)
fz_throw(ctx, "cannot find extgstate resource '%s'", csi->name);
pdf_run_extgstate(csi, rdb, obj);
- /* RJW: "cannot set ExtGState (%d 0 R)", fz_to_num(obj) */
+ /* RJW: "cannot set ExtGState (%d 0 R)", pdf_to_num(obj) */
}
static void pdf_run_h(pdf_csi *csi)
@@ -2286,25 +2286,25 @@ static void pdf_run(pdf_csi *csi)
pdf_show_path(csi, 1, 0, 1, 0);
}
-static void pdf_run_sh(pdf_csi *csi, fz_obj *rdb)
+static void pdf_run_sh(pdf_csi *csi, pdf_obj *rdb)
{
fz_context *ctx = csi->dev->ctx;
- fz_obj *dict;
- fz_obj *obj;
+ pdf_obj *dict;
+ pdf_obj *obj;
fz_shade *shd;
- dict = fz_dict_gets(rdb, "Shading");
+ dict = pdf_dict_gets(rdb, "Shading");
if (!dict)
fz_throw(ctx, "cannot find shading dictionary");
- obj = fz_dict_gets(dict, csi->name);
+ obj = pdf_dict_gets(dict, csi->name);
if (!obj)
fz_throw(ctx, "cannot find shading resource: '%s'", csi->name);
if ((csi->dev->hints & FZ_IGNORE_SHADE) == 0)
{
shd = pdf_load_shading(csi->xref, obj);
- /* RJW: "cannot load shading (%d %d R)", fz_to_num(obj), fz_to_gen(obj) */
+ /* RJW: "cannot load shading (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj) */
fz_try(ctx)
{
pdf_show_shade(csi, shd);
@@ -2384,7 +2384,7 @@ static void pdf_run_dquote(pdf_csi *csi)
#define C(a,b,c) (a | b << 8 | c << 16)
static void
-pdf_run_keyword(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf)
+pdf_run_keyword(pdf_csi *csi, pdf_obj *rdb, fz_stream *file, char *buf)
{
fz_context *ctx = csi->dev->ctx;
int key;
@@ -2522,7 +2522,7 @@ pdf_run_keyword(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf)
}
static void
-pdf_run_stream(pdf_csi *csi, fz_obj *rdb, fz_stream *file, pdf_lexbuf *buf)
+pdf_run_stream(pdf_csi *csi, pdf_obj *rdb, fz_stream *file, pdf_lexbuf *buf)
{
fz_context *ctx = csi->dev->ctx;
int tok, in_array;
@@ -2631,7 +2631,7 @@ pdf_run_stream(pdf_csi *csi, fz_obj *rdb, fz_stream *file, pdf_lexbuf *buf)
}
else
{
- csi->obj = fz_new_string(ctx, buf->scratch, buf->len);
+ csi->obj = pdf_new_string(ctx, buf->scratch, buf->len);
}
break;
@@ -2652,7 +2652,7 @@ pdf_run_stream(pdf_csi *csi, fz_obj *rdb, fz_stream *file, pdf_lexbuf *buf)
*/
static void
-pdf_run_buffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents)
+pdf_run_buffer(pdf_csi *csi, pdf_obj *rdb, fz_buffer *contents)
{
fz_context *ctx = csi->dev->ctx;
pdf_lexbuf_large *buf;
@@ -2736,7 +2736,7 @@ pdf_run_page_with_usage(pdf_document *xref, pdf_page *page, fz_device *dev, fz_m
cookie->progress++;
}
- flags = fz_to_int(fz_dict_gets(annot->obj, "F"));
+ flags = pdf_to_int(pdf_dict_gets(annot->obj, "F"));
/* TODO: NoZoom and NoRotate */
if (flags & (1 << 0)) /* Invisible */
@@ -2749,7 +2749,7 @@ pdf_run_page_with_usage(pdf_document *xref, pdf_page *page, fz_device *dev, fz_m
continue;
csi = pdf_new_csi(xref, dev, ctm, event, cookie, NULL);
- if (!pdf_is_hidden_ocg(fz_dict_gets(annot->obj, "OC"), csi, page->resources))
+ if (!pdf_is_hidden_ocg(pdf_dict_gets(annot->obj, "OC"), csi, page->resources))
{
fz_try(ctx)
{
@@ -2775,7 +2775,7 @@ pdf_run_page(pdf_document *xref, pdf_page *page, fz_device *dev, fz_matrix ctm,
}
void
-pdf_run_glyph(pdf_document *xref, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate)
+pdf_run_glyph(pdf_document *xref, pdf_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate)
{
pdf_csi *csi = pdf_new_csi(xref, dev, ctm, "View", NULL, gstate);
fz_context *ctx = xref->ctx;
diff --git a/pdf/pdf_nametree.c b/pdf/pdf_nametree.c
index c78e238d..98a10241 100644
--- a/pdf/pdf_nametree.c
+++ b/pdf/pdf_nametree.c
@@ -1,55 +1,55 @@
#include "fitz.h"
#include "mupdf.h"
-static fz_obj *
-pdf_lookup_name_imp(fz_context *ctx, fz_obj *node, fz_obj *needle)
+static pdf_obj *
+pdf_lookup_name_imp(fz_context *ctx, pdf_obj *node, pdf_obj *needle)
{
- fz_obj *kids = fz_dict_gets(node, "Kids");
- fz_obj *names = fz_dict_gets(node, "Names");
+ pdf_obj *kids = pdf_dict_gets(node, "Kids");
+ pdf_obj *names = pdf_dict_gets(node, "Names");
- if (fz_is_array(kids))
+ if (pdf_is_array(kids))
{
int l = 0;
- int r = fz_array_len(kids) - 1;
+ int r = pdf_array_len(kids) - 1;
while (l <= r)
{
int m = (l + r) >> 1;
- fz_obj *kid = fz_array_get(kids, m);
- fz_obj *limits = fz_dict_gets(kid, "Limits");
- fz_obj *first = fz_array_get(limits, 0);
- fz_obj *last = fz_array_get(limits, 1);
+ pdf_obj *kid = pdf_array_get(kids, m);
+ pdf_obj *limits = pdf_dict_gets(kid, "Limits");
+ pdf_obj *first = pdf_array_get(limits, 0);
+ pdf_obj *last = pdf_array_get(limits, 1);
- if (fz_objcmp(needle, first) < 0)
+ if (pdf_objcmp(needle, first) < 0)
r = m - 1;
- else if (fz_objcmp(needle, last) > 0)
+ else if (pdf_objcmp(needle, last) > 0)
l = m + 1;
else
{
- fz_obj *obj;
+ pdf_obj *obj;
- if (fz_dict_mark(node))
+ if (pdf_dict_mark(node))
break;
obj = pdf_lookup_name_imp(ctx, kid, needle);
- fz_dict_unmark(node);
+ pdf_dict_unmark(node);
return obj;
}
}
}
- if (fz_is_array(names))
+ if (pdf_is_array(names))
{
int l = 0;
- int r = (fz_array_len(names) / 2) - 1;
+ int r = (pdf_array_len(names) / 2) - 1;
while (l <= r)
{
int m = (l + r) >> 1;
int c;
- fz_obj *key = fz_array_get(names, m * 2);
- fz_obj *val = fz_array_get(names, m * 2 + 1);
+ pdf_obj *key = pdf_array_get(names, m * 2);
+ pdf_obj *val = pdf_array_get(names, m * 2 + 1);
- c = fz_objcmp(needle, key);
+ c = pdf_objcmp(needle, key);
if (c < 0)
r = m - 1;
else if (c > 0)
@@ -61,49 +61,49 @@ pdf_lookup_name_imp(fz_context *ctx, fz_obj *node, fz_obj *needle)
/* Spec says names should be sorted (hence the binary search,
* above), but Acrobat copes with non-sorted. Drop back to a
* simple search if the binary search fails. */
- r = fz_array_len(names)/2;
+ r = pdf_array_len(names)/2;
for (l = 0; l < r; l++)
- if (!fz_objcmp(needle, fz_array_get(names, l * 2)))
- return fz_array_get(names, l * 2 + 1);
+ if (!pdf_objcmp(needle, pdf_array_get(names, l * 2)))
+ return pdf_array_get(names, l * 2 + 1);
}
return NULL;
}
-fz_obj *
-pdf_lookup_name(pdf_document *xref, char *which, fz_obj *needle)
+pdf_obj *
+pdf_lookup_name(pdf_document *xref, char *which, pdf_obj *needle)
{
fz_context *ctx = xref->ctx;
- fz_obj *root = fz_dict_gets(xref->trailer, "Root");
- fz_obj *names = fz_dict_gets(root, "Names");
- fz_obj *tree = fz_dict_gets(names, which);
+ pdf_obj *root = pdf_dict_gets(xref->trailer, "Root");
+ pdf_obj *names = pdf_dict_gets(root, "Names");
+ pdf_obj *tree = pdf_dict_gets(names, which);
return pdf_lookup_name_imp(ctx, tree, needle);
}
-fz_obj *
-pdf_lookup_dest(pdf_document *xref, fz_obj *needle)
+pdf_obj *
+pdf_lookup_dest(pdf_document *xref, pdf_obj *needle)
{
fz_context *ctx = xref->ctx;
- fz_obj *root = fz_dict_gets(xref->trailer, "Root");
- fz_obj *dests = fz_dict_gets(root, "Dests");
- fz_obj *names = fz_dict_gets(root, "Names");
- fz_obj *dest = NULL;
+ pdf_obj *root = pdf_dict_gets(xref->trailer, "Root");
+ pdf_obj *dests = pdf_dict_gets(root, "Dests");
+ pdf_obj *names = pdf_dict_gets(root, "Names");
+ pdf_obj *dest = NULL;
/* PDF 1.1 has destinations in a dictionary */
if (dests)
{
- if (fz_is_name(needle))
- return fz_dict_get(dests, needle);
+ if (pdf_is_name(needle))
+ return pdf_dict_get(dests, needle);
else
- return fz_dict_gets(dests, fz_to_str_buf(needle));
+ return pdf_dict_gets(dests, pdf_to_str_buf(needle));
}
/* PDF 1.2 has destinations in a name tree */
if (names && !dest)
{
- fz_obj *tree = fz_dict_gets(names, "Dests");
+ pdf_obj *tree = pdf_dict_gets(names, "Dests");
return pdf_lookup_name_imp(ctx, tree, needle);
}
@@ -111,33 +111,33 @@ pdf_lookup_dest(pdf_document *xref, fz_obj *needle)
}
static void
-pdf_load_name_tree_imp(fz_obj *dict, pdf_document *xref, fz_obj *node)
+pdf_load_name_tree_imp(pdf_obj *dict, pdf_document *xref, pdf_obj *node)
{
fz_context *ctx = xref->ctx;
- fz_obj *kids = fz_dict_gets(node, "Kids");
- fz_obj *names = fz_dict_gets(node, "Names");
+ pdf_obj *kids = pdf_dict_gets(node, "Kids");
+ pdf_obj *names = pdf_dict_gets(node, "Names");
int i;
- if (kids && !fz_dict_mark(node))
+ if (kids && !pdf_dict_mark(node))
{
- for (i = 0; i < fz_array_len(kids); i++)
- pdf_load_name_tree_imp(dict, xref, fz_array_get(kids, i));
- fz_dict_unmark(node);
+ for (i = 0; i < pdf_array_len(kids); i++)
+ pdf_load_name_tree_imp(dict, xref, pdf_array_get(kids, i));
+ pdf_dict_unmark(node);
}
if (names)
{
- for (i = 0; i + 1 < fz_array_len(names); i += 2)
+ for (i = 0; i + 1 < pdf_array_len(names); i += 2)
{
- fz_obj *key = fz_array_get(names, i);
- fz_obj *val = fz_array_get(names, i + 1);
- if (fz_is_string(key))
+ pdf_obj *key = pdf_array_get(names, i);
+ pdf_obj *val = pdf_array_get(names, i + 1);
+ if (pdf_is_string(key))
{
key = pdf_to_utf8_name(ctx, key);
fz_dict_put(dict, key, val);
- fz_drop_obj(key);
+ pdf_drop_obj(key);
}
- else if (fz_is_name(key))
+ else if (pdf_is_name(key))
{
fz_dict_put(dict, key, val);
}
@@ -145,17 +145,17 @@ pdf_load_name_tree_imp(fz_obj *dict, pdf_document *xref, fz_obj *node)
}
}
-fz_obj *
+pdf_obj *
pdf_load_name_tree(pdf_document *xref, char *which)
{
fz_context *ctx = xref->ctx;
- fz_obj *root = fz_dict_gets(xref->trailer, "Root");
- fz_obj *names = fz_dict_gets(root, "Names");
- fz_obj *tree = fz_dict_gets(names, which);
- if (fz_is_dict(tree))
+ pdf_obj *root = pdf_dict_gets(xref->trailer, "Root");
+ pdf_obj *names = pdf_dict_gets(root, "Names");
+ pdf_obj *tree = pdf_dict_gets(names, which);
+ if (pdf_is_dict(tree))
{
- fz_obj *dict = fz_new_dict(ctx, 100);
+ pdf_obj *dict = pdf_new_dict(ctx, 100);
pdf_load_name_tree_imp(dict, xref, tree);
return dict;
}
diff --git a/pdf/pdf_outline.c b/pdf/pdf_outline.c
index e5c87f8c..793b5f77 100644
--- a/pdf/pdf_outline.c
+++ b/pdf/pdf_outline.c
@@ -2,12 +2,12 @@
#include "mupdf.h"
static fz_outline *
-pdf_load_outline_imp(pdf_document *xref, fz_obj *dict)
+pdf_load_outline_imp(pdf_document *xref, pdf_obj *dict)
{
fz_context *ctx = xref->ctx;
fz_outline *node, **prev, *first;
- fz_obj *obj;
- fz_obj *odict = dict;
+ pdf_obj *obj;
+ pdf_obj *odict = dict;
fz_var(dict);
@@ -15,9 +15,9 @@ pdf_load_outline_imp(pdf_document *xref, fz_obj *dict)
{
first = NULL;
prev = &first;
- while (dict && fz_is_dict(dict))
+ while (dict && pdf_is_dict(dict))
{
- if (fz_dict_mark(dict))
+ if (pdf_dict_mark(dict))
break;
node = fz_malloc_struct(ctx, fz_outline);
node->title = NULL;
@@ -27,31 +27,31 @@ pdf_load_outline_imp(pdf_document *xref, fz_obj *dict)
*prev = node;
prev = &node->next;
- obj = fz_dict_gets(dict, "Title");
+ obj = pdf_dict_gets(dict, "Title");
if (obj)
node->title = pdf_to_utf8(ctx, obj);
- if ((obj = fz_dict_gets(dict, "Dest")))
+ if ((obj = pdf_dict_gets(dict, "Dest")))
node->dest = pdf_parse_link_dest(xref, obj);
- else if ((obj = fz_dict_gets(dict, "A")))
+ else if ((obj = pdf_dict_gets(dict, "A")))
node->dest = pdf_parse_action(xref, obj);
- obj = fz_dict_gets(dict, "First");
+ obj = pdf_dict_gets(dict, "First");
if (obj)
node->down = pdf_load_outline_imp(xref, obj);
- dict = fz_dict_gets(dict, "Next");
+ dict = pdf_dict_gets(dict, "Next");
}
}
fz_catch(ctx)
{
- for (dict = odict; dict && fz_dict_marked(dict); dict = fz_dict_gets(dict, "Next"))
- fz_dict_unmark(dict);
+ for (dict = odict; dict && pdf_dict_marked(dict); dict = pdf_dict_gets(dict, "Next"))
+ pdf_dict_unmark(dict);
fz_rethrow(ctx);
}
- for (dict = odict; dict && fz_dict_marked(dict); dict = fz_dict_gets(dict, "Next"))
- fz_dict_unmark(dict);
+ for (dict = odict; dict && pdf_dict_marked(dict); dict = pdf_dict_gets(dict, "Next"))
+ pdf_dict_unmark(dict);
return first;
}
@@ -59,11 +59,11 @@ pdf_load_outline_imp(pdf_document *xref, fz_obj *dict)
fz_outline *
pdf_load_outline(pdf_document *xref)
{
- fz_obj *root, *obj, *first;
+ pdf_obj *root, *obj, *first;
- root = fz_dict_gets(xref->trailer, "Root");
- obj = fz_dict_gets(root, "Outlines");
- first = fz_dict_gets(obj, "First");
+ root = pdf_dict_gets(xref->trailer, "Root");
+ obj = pdf_dict_gets(root, "Outlines");
+ first = pdf_dict_gets(obj, "First");
if (first)
return pdf_load_outline_imp(xref, first);
diff --git a/pdf/pdf_page.c b/pdf/pdf_page.c
index de8e7051..ca38aacf 100644
--- a/pdf/pdf_page.c
+++ b/pdf/pdf_page.c
@@ -3,126 +3,126 @@
struct info
{
- fz_obj *resources;
- fz_obj *mediabox;
- fz_obj *cropbox;
- fz_obj *rotate;
+ pdf_obj *resources;
+ pdf_obj *mediabox;
+ pdf_obj *cropbox;
+ pdf_obj *rotate;
};
static void
-put_marker_bool(fz_context *ctx, fz_obj *rdb, char *marker, int val)
+put_marker_bool(fz_context *ctx, pdf_obj *rdb, char *marker, int val)
{
- fz_obj *tmp;
+ pdf_obj *tmp;
- tmp = fz_new_bool(ctx, val);
+ tmp = pdf_new_bool(ctx, val);
fz_try(ctx)
{
- fz_dict_puts(rdb, marker, tmp);
+ pdf_dict_puts(rdb, marker, tmp);
}
fz_catch(ctx)
{
- fz_drop_obj(tmp);
+ pdf_drop_obj(tmp);
fz_rethrow(ctx);
}
- fz_drop_obj(tmp);
+ pdf_drop_obj(tmp);
}
static void
-pdf_load_page_tree_node(pdf_document *xref, fz_obj *node, struct info info)
+pdf_load_page_tree_node(pdf_document *xref, pdf_obj *node, struct info info)
{
- fz_obj *dict, *kids, *count;
- fz_obj *obj;
+ pdf_obj *dict, *kids, *count;
+ pdf_obj *obj;
int i, n;
fz_context *ctx = xref->ctx;
/* prevent infinite recursion */
- if (!node || fz_dict_mark(node))
+ if (!node || pdf_dict_mark(node))
return;
fz_try(ctx)
{
- kids = fz_dict_gets(node, "Kids");
- count = fz_dict_gets(node, "Count");
+ kids = pdf_dict_gets(node, "Kids");
+ count = pdf_dict_gets(node, "Count");
- if (fz_is_array(kids) && fz_is_int(count))
+ if (pdf_is_array(kids) && pdf_is_int(count))
{
- obj = fz_dict_gets(node, "Resources");
+ obj = pdf_dict_gets(node, "Resources");
if (obj)
info.resources = obj;
- obj = fz_dict_gets(node, "MediaBox");
+ obj = pdf_dict_gets(node, "MediaBox");
if (obj)
info.mediabox = obj;
- obj = fz_dict_gets(node, "CropBox");
+ obj = pdf_dict_gets(node, "CropBox");
if (obj)
info.cropbox = obj;
- obj = fz_dict_gets(node, "Rotate");
+ obj = pdf_dict_gets(node, "Rotate");
if (obj)
info.rotate = obj;
- n = fz_array_len(kids);
+ n = pdf_array_len(kids);
for (i = 0; i < n; i++)
{
- obj = fz_array_get(kids, i);
+ obj = pdf_array_get(kids, i);
pdf_load_page_tree_node(xref, obj, info);
}
}
- else if ((dict = fz_to_dict(node)) != NULL)
+ else if ((dict = pdf_to_dict(node)) != NULL)
{
- if (info.resources && !fz_dict_gets(dict, "Resources"))
- fz_dict_puts(dict, "Resources", info.resources);
- if (info.mediabox && !fz_dict_gets(dict, "MediaBox"))
- fz_dict_puts(dict, "MediaBox", info.mediabox);
- if (info.cropbox && !fz_dict_gets(dict, "CropBox"))
- fz_dict_puts(dict, "CropBox", info.cropbox);
- if (info.rotate && !fz_dict_gets(dict, "Rotate"))
- fz_dict_puts(dict, "Rotate", info.rotate);
+ if (info.resources && !pdf_dict_gets(dict, "Resources"))
+ pdf_dict_puts(dict, "Resources", info.resources);
+ if (info.mediabox && !pdf_dict_gets(dict, "MediaBox"))
+ pdf_dict_puts(dict, "MediaBox", info.mediabox);
+ if (info.cropbox && !pdf_dict_gets(dict, "CropBox"))
+ pdf_dict_puts(dict, "CropBox", info.cropbox);
+ if (info.rotate && !pdf_dict_gets(dict, "Rotate"))
+ pdf_dict_puts(dict, "Rotate", info.rotate);
if (xref->page_len == xref->page_cap)
{
fz_warn(ctx, "found more pages than expected");
xref->page_cap ++;
- xref->page_refs = fz_resize_array(ctx, xref->page_refs, xref->page_cap, sizeof(fz_obj*));
- xref->page_objs = fz_resize_array(ctx, xref->page_objs, xref->page_cap, sizeof(fz_obj*));
+ xref->page_refs = fz_resize_array(ctx, xref->page_refs, xref->page_cap, sizeof(pdf_obj*));
+ xref->page_objs = fz_resize_array(ctx, xref->page_objs, xref->page_cap, sizeof(pdf_obj*));
}
- xref->page_refs[xref->page_len] = fz_keep_obj(node);
- xref->page_objs[xref->page_len] = fz_keep_obj(dict);
+ xref->page_refs[xref->page_len] = pdf_keep_obj(node);
+ xref->page_objs[xref->page_len] = pdf_keep_obj(dict);
xref->page_len ++;
}
}
fz_catch(ctx)
{
- fz_dict_unmark(node);
+ pdf_dict_unmark(node);
fz_rethrow(ctx);
}
- fz_dict_unmark(node);
+ pdf_dict_unmark(node);
}
static void
pdf_load_page_tree(pdf_document *xref)
{
fz_context *ctx = xref->ctx;
- fz_obj *catalog;
- fz_obj *pages;
- fz_obj *count;
+ pdf_obj *catalog;
+ pdf_obj *pages;
+ pdf_obj *count;
struct info info;
if (xref->page_len)
return;
- catalog = fz_dict_gets(xref->trailer, "Root");
- pages = fz_dict_gets(catalog, "Pages");
- count = fz_dict_gets(pages, "Count");
+ catalog = pdf_dict_gets(xref->trailer, "Root");
+ pages = pdf_dict_gets(catalog, "Pages");
+ count = pdf_dict_gets(pages, "Count");
- if (!fz_is_dict(pages))
+ if (!pdf_is_dict(pages))
fz_throw(ctx, "missing page tree");
- if (!fz_is_int(count))
+ if (!pdf_is_int(count))
fz_throw(ctx, "missing page count");
- xref->page_cap = fz_to_int(count);
+ xref->page_cap = pdf_to_int(count);
xref->page_len = 0;
- xref->page_refs = fz_malloc_array(ctx, xref->page_cap, sizeof(fz_obj*));
- xref->page_objs = fz_malloc_array(ctx, xref->page_cap, sizeof(fz_obj*));
+ xref->page_refs = fz_malloc_array(ctx, xref->page_cap, sizeof(pdf_obj*));
+ xref->page_objs = fz_malloc_array(ctx, xref->page_cap, sizeof(pdf_obj*));
info.resources = NULL;
info.mediabox = NULL;
@@ -140,84 +140,84 @@ pdf_count_pages(pdf_document *xref)
}
int
-pdf_find_page_number(pdf_document *xref, fz_obj *page)
+pdf_find_page_number(pdf_document *xref, pdf_obj *page)
{
- int i, num = fz_to_num(page);
+ int i, num = pdf_to_num(page);
pdf_load_page_tree(xref);
for (i = 0; i < xref->page_len; i++)
- if (num == fz_to_num(xref->page_refs[i]))
+ if (num == pdf_to_num(xref->page_refs[i]))
return i;
return -1;
}
/* We need to know whether to install a page-level transparency group */
-static int pdf_resources_use_blending(fz_context *ctx, fz_obj *rdb);
+static int pdf_resources_use_blending(fz_context *ctx, pdf_obj *rdb);
static int
-pdf_extgstate_uses_blending(fz_context *ctx, fz_obj *dict)
+pdf_extgstate_uses_blending(fz_context *ctx, pdf_obj *dict)
{
- fz_obj *obj = fz_dict_gets(dict, "BM");
- if (fz_is_name(obj) && strcmp(fz_to_name(obj), "Normal"))
+ pdf_obj *obj = pdf_dict_gets(dict, "BM");
+ if (pdf_is_name(obj) && strcmp(pdf_to_name(obj), "Normal"))
return 1;
return 0;
}
static int
-pdf_pattern_uses_blending(fz_context *ctx, fz_obj *dict)
+pdf_pattern_uses_blending(fz_context *ctx, pdf_obj *dict)
{
- fz_obj *obj;
- obj = fz_dict_gets(dict, "Resources");
+ pdf_obj *obj;
+ obj = pdf_dict_gets(dict, "Resources");
if (pdf_resources_use_blending(ctx, obj))
return 1;
- obj = fz_dict_gets(dict, "ExtGState");
+ obj = pdf_dict_gets(dict, "ExtGState");
return pdf_extgstate_uses_blending(ctx, obj);
}
static int
-pdf_xobject_uses_blending(fz_context *ctx, fz_obj *dict)
+pdf_xobject_uses_blending(fz_context *ctx, pdf_obj *dict)
{
- fz_obj *obj = fz_dict_gets(dict, "Resources");
+ pdf_obj *obj = pdf_dict_gets(dict, "Resources");
return pdf_resources_use_blending(ctx, obj);
}
static int
-pdf_resources_use_blending(fz_context *ctx, fz_obj *rdb)
+pdf_resources_use_blending(fz_context *ctx, pdf_obj *rdb)
{
- fz_obj *obj;
+ pdf_obj *obj;
int i, n, useBM = 0;
if (!rdb)
return 0;
/* Have we been here before and stashed an answer? */
- obj = fz_dict_gets(rdb, ".useBM");
+ obj = pdf_dict_gets(rdb, ".useBM");
if (obj)
- return fz_to_bool(obj);
+ return pdf_to_bool(obj);
/* stop on cyclic resource dependencies */
- if (fz_dict_mark(rdb))
+ if (pdf_dict_mark(rdb))
return 0;
fz_try(ctx)
{
- obj = fz_dict_gets(rdb, "ExtGState");
- n = fz_dict_len(obj);
+ obj = pdf_dict_gets(rdb, "ExtGState");
+ n = pdf_dict_len(obj);
for (i = 0; i < n; i++)
- if (pdf_extgstate_uses_blending(ctx, fz_dict_get_val(obj, i)))
+ if (pdf_extgstate_uses_blending(ctx, pdf_dict_get_val(obj, i)))
goto found;
- obj = fz_dict_gets(rdb, "Pattern");
- n = fz_dict_len(obj);
+ obj = pdf_dict_gets(rdb, "Pattern");
+ n = pdf_dict_len(obj);
for (i = 0; i < n; i++)
- if (pdf_pattern_uses_blending(ctx, fz_dict_get_val(obj, i)))
+ if (pdf_pattern_uses_blending(ctx, pdf_dict_get_val(obj, i)))
goto found;
- obj = fz_dict_gets(rdb, "XObject");
- n = fz_dict_len(obj);
+ obj = pdf_dict_gets(rdb, "XObject");
+ n = pdf_dict_len(obj);
for (i = 0; i < n; i++)
- if (pdf_xobject_uses_blending(ctx, fz_dict_get_val(obj, i)))
+ if (pdf_xobject_uses_blending(ctx, pdf_dict_get_val(obj, i)))
goto found;
if (0)
{
@@ -227,10 +227,10 @@ found:
}
fz_catch(ctx)
{
- fz_dict_unmark(rdb);
+ pdf_dict_unmark(rdb);
fz_rethrow(ctx);
}
- fz_dict_unmark(rdb);
+ pdf_dict_unmark(rdb);
put_marker_bool(ctx, rdb, ".useBM", useBM);
return useBM;
@@ -239,7 +239,7 @@ found:
/* we need to combine all sub-streams into one for the content stream interpreter */
static fz_buffer *
-pdf_load_page_contents_array(pdf_document *xref, fz_obj *list)
+pdf_load_page_contents_array(pdf_document *xref, pdf_obj *list)
{
fz_buffer *big;
fz_buffer *one;
@@ -248,14 +248,14 @@ pdf_load_page_contents_array(pdf_document *xref, fz_obj *list)
big = fz_new_buffer(ctx, 32 * 1024);
- n = fz_array_len(list);
+ n = pdf_array_len(list);
fz_var(i); /* Workaround Mac compiler bug */
for (i = 0; i < n; i++)
{
- fz_obj *stm = fz_array_get(list, i);
+ pdf_obj *stm = pdf_array_get(list, i);
fz_try(ctx)
{
- one = pdf_load_stream(xref, fz_to_num(stm), fz_to_gen(stm));
+ one = pdf_load_stream(xref, pdf_to_num(stm), pdf_to_gen(stm));
}
fz_catch(ctx)
{
@@ -283,19 +283,19 @@ pdf_load_page_contents_array(pdf_document *xref, fz_obj *list)
}
static fz_buffer *
-pdf_load_page_contents(pdf_document *xref, fz_obj *obj)
+pdf_load_page_contents(pdf_document *xref, pdf_obj *obj)
{
fz_context *ctx = xref->ctx;
- if (fz_is_array(obj))
+ if (pdf_is_array(obj))
{
return pdf_load_page_contents_array(xref, obj);
/* RJW: "cannot load content stream array" */
}
- else if (pdf_is_stream(xref, fz_to_num(obj), fz_to_gen(obj)))
+ else if (pdf_is_stream(xref, pdf_to_num(obj), pdf_to_gen(obj)))
{
- return pdf_load_stream(xref, fz_to_num(obj), fz_to_gen(obj));
- /* RJW: "cannot load content stream (%d 0 R)", fz_to_num(obj) */
+ return pdf_load_stream(xref, pdf_to_num(obj), pdf_to_gen(obj));
+ /* RJW: "cannot load content stream (%d 0 R)", pdf_to_num(obj) */
}
fz_warn(ctx, "page contents missing, leaving page blank");
@@ -308,7 +308,7 @@ pdf_load_page(pdf_document *xref, int number)
fz_context *ctx = xref->ctx;
pdf_page *page;
pdf_annot *annot;
- fz_obj *pageobj, *pageref, *obj;
+ pdf_obj *pageobj, *pageref, *obj;
fz_rect mediabox, cropbox, realbox;
fz_matrix ctm;
@@ -326,7 +326,7 @@ pdf_load_page(pdf_document *xref, int number)
page->links = NULL;
page->annots = NULL;
- mediabox = pdf_to_rect(ctx, fz_dict_gets(pageobj, "MediaBox"));
+ mediabox = pdf_to_rect(ctx, pdf_dict_gets(pageobj, "MediaBox"));
if (fz_is_empty_rect(mediabox))
{
fz_warn(ctx, "cannot find page size for page %d", number + 1);
@@ -336,7 +336,7 @@ pdf_load_page(pdf_document *xref, int number)
mediabox.y1 = 792;
}
- cropbox = pdf_to_rect(ctx, fz_dict_gets(pageobj, "CropBox"));
+ cropbox = pdf_to_rect(ctx, pdf_dict_gets(pageobj, "CropBox"));
if (!fz_is_empty_rect(cropbox))
mediabox = fz_intersect_rect(mediabox, cropbox);
@@ -351,24 +351,24 @@ pdf_load_page(pdf_document *xref, int number)
page->mediabox = fz_unit_rect;
}
- page->rotate = fz_to_int(fz_dict_gets(pageobj, "Rotate"));
+ page->rotate = pdf_to_int(pdf_dict_gets(pageobj, "Rotate"));
ctm = fz_concat(fz_rotate(-page->rotate), fz_scale(1, -1));
realbox = fz_transform_rect(ctm, page->mediabox);
page->ctm = fz_concat(ctm, fz_translate(-realbox.x0, -realbox.y0));
- obj = fz_dict_gets(pageobj, "Annots");
+ obj = pdf_dict_gets(pageobj, "Annots");
if (obj)
{
page->links = pdf_load_link_annots(xref, obj, page->ctm);
page->annots = pdf_load_annots(xref, obj);
}
- page->resources = fz_dict_gets(pageobj, "Resources");
+ page->resources = pdf_dict_gets(pageobj, "Resources");
if (page->resources)
- fz_keep_obj(page->resources);
+ pdf_keep_obj(page->resources);
- obj = fz_dict_gets(pageobj, "Contents");
+ obj = pdf_dict_gets(pageobj, "Contents");
fz_try(ctx)
{
page->contents = pdf_load_page_contents(xref, obj);
@@ -383,7 +383,7 @@ pdf_load_page(pdf_document *xref, int number)
fz_catch(ctx)
{
pdf_free_page(xref, page);
- fz_throw(ctx, "cannot load page %d contents (%d 0 R)", number + 1, fz_to_num(pageref));
+ fz_throw(ctx, "cannot load page %d contents (%d 0 R)", number + 1, pdf_to_num(pageref));
}
return page;
@@ -409,7 +409,7 @@ void
pdf_free_page(pdf_document *xref, pdf_page *page)
{
if (page->resources)
- fz_drop_obj(page->resources);
+ pdf_drop_obj(page->resources);
if (page->contents)
fz_drop_buffer(xref->ctx, page->contents);
if (page->links)
diff --git a/pdf/pdf_parse.c b/pdf/pdf_parse.c
index fb6cb7ef..e171e698 100644
--- a/pdf/pdf_parse.c
+++ b/pdf/pdf_parse.c
@@ -2,13 +2,13 @@
#include "mupdf.h"
fz_rect
-pdf_to_rect(fz_context *ctx, fz_obj *array)
+pdf_to_rect(fz_context *ctx, pdf_obj *array)
{
fz_rect r;
- float a = fz_to_real(fz_array_get(array, 0));
- float b = fz_to_real(fz_array_get(array, 1));
- float c = fz_to_real(fz_array_get(array, 2));
- float d = fz_to_real(fz_array_get(array, 3));
+ float a = pdf_to_real(pdf_array_get(array, 0));
+ float b = pdf_to_real(pdf_array_get(array, 1));
+ float c = pdf_to_real(pdf_array_get(array, 2));
+ float d = pdf_to_real(pdf_array_get(array, 3));
r.x0 = MIN(a, c);
r.y0 = MIN(b, d);
r.x1 = MAX(a, c);
@@ -17,25 +17,25 @@ pdf_to_rect(fz_context *ctx, fz_obj *array)
}
fz_matrix
-pdf_to_matrix(fz_context *ctx, fz_obj *array)
+pdf_to_matrix(fz_context *ctx, pdf_obj *array)
{
fz_matrix m;
- m.a = fz_to_real(fz_array_get(array, 0));
- m.b = fz_to_real(fz_array_get(array, 1));
- m.c = fz_to_real(fz_array_get(array, 2));
- m.d = fz_to_real(fz_array_get(array, 3));
- m.e = fz_to_real(fz_array_get(array, 4));
- m.f = fz_to_real(fz_array_get(array, 5));
+ m.a = pdf_to_real(pdf_array_get(array, 0));
+ m.b = pdf_to_real(pdf_array_get(array, 1));
+ m.c = pdf_to_real(pdf_array_get(array, 2));
+ m.d = pdf_to_real(pdf_array_get(array, 3));
+ m.e = pdf_to_real(pdf_array_get(array, 4));
+ m.f = pdf_to_real(pdf_array_get(array, 5));
return m;
}
/* Convert Unicode/PdfDocEncoding string into utf-8 */
char *
-pdf_to_utf8(fz_context *ctx, fz_obj *src)
+pdf_to_utf8(fz_context *ctx, pdf_obj *src)
{
- unsigned char *srcptr = (unsigned char *) fz_to_str_buf(src);
+ unsigned char *srcptr = (unsigned char *) pdf_to_str_buf(src);
char *dstptr, *dst;
- int srclen = fz_to_str_len(src);
+ int srclen = pdf_to_str_len(src);
int dstlen = 0;
int ucs;
int i;
@@ -92,11 +92,11 @@ pdf_to_utf8(fz_context *ctx, fz_obj *src)
/* Convert Unicode/PdfDocEncoding string into ucs-2 */
unsigned short *
-pdf_to_ucs2(fz_context *ctx, fz_obj *src)
+pdf_to_ucs2(fz_context *ctx, pdf_obj *src)
{
- unsigned char *srcptr = (unsigned char *) fz_to_str_buf(src);
+ unsigned char *srcptr = (unsigned char *) pdf_to_str_buf(src);
unsigned short *dstptr, *dst;
- int srclen = fz_to_str_len(src);
+ int srclen = pdf_to_str_len(src);
int i;
if (srclen >= 2 && srcptr[0] == 254 && srcptr[1] == 255)
@@ -161,28 +161,28 @@ pdf_from_ucs2(fz_context *ctx, unsigned short *src)
return docstr;
}
-fz_obj *
-pdf_to_utf8_name(fz_context *ctx, fz_obj *src)
+pdf_obj *
+pdf_to_utf8_name(fz_context *ctx, pdf_obj *src)
{
char *buf = pdf_to_utf8(ctx, src);
- fz_obj *dst = fz_new_name(ctx, buf);
+ pdf_obj *dst = fz_new_name(ctx, buf);
fz_free(ctx, buf);
return dst;
}
-fz_obj *
+pdf_obj *
pdf_parse_array(pdf_document *xref, fz_stream *file, pdf_lexbuf *buf)
{
- fz_obj *ary = NULL;
- fz_obj *obj = NULL;
+ pdf_obj *ary = NULL;
+ pdf_obj *obj = NULL;
int a = 0, b = 0, n = 0;
int tok;
fz_context *ctx = file->ctx;
- fz_obj *op;
+ pdf_obj *op;
fz_var(obj);
- ary = fz_new_array(ctx, 4);
+ ary = pdf_new_array(ctx, 4);
fz_try(ctx)
{
@@ -194,16 +194,16 @@ pdf_parse_array(pdf_document *xref, fz_stream *file, pdf_lexbuf *buf)
{
if (n > 0)
{
- obj = fz_new_int(ctx, a);
- fz_array_push(ary, obj);
- fz_drop_obj(obj);
+ obj = pdf_new_int(ctx, a);
+ pdf_array_push(ary, obj);
+ pdf_drop_obj(obj);
obj = NULL;
}
if (n > 1)
{
- obj = fz_new_int(ctx, b);
- fz_array_push(ary, obj);
- fz_drop_obj(obj);
+ obj = pdf_new_int(ctx, b);
+ pdf_array_push(ary, obj);
+ pdf_drop_obj(obj);
obj = NULL;
}
n = 0;
@@ -211,9 +211,9 @@ pdf_parse_array(pdf_document *xref, fz_stream *file, pdf_lexbuf *buf)
if (tok == PDF_TOK_INT && n == 2)
{
- obj = fz_new_int(ctx, a);
- fz_array_push(ary, obj);
- fz_drop_obj(obj);
+ obj = pdf_new_int(ctx, a);
+ pdf_array_push(ary, obj);
+ pdf_drop_obj(obj);
obj = NULL;
a = b;
n --;
@@ -236,61 +236,61 @@ pdf_parse_array(pdf_document *xref, fz_stream *file, pdf_lexbuf *buf)
case PDF_TOK_R:
if (n != 2)
fz_throw(ctx, "cannot parse indirect reference in array");
- obj = fz_new_indirect(ctx, a, b, xref);
- fz_array_push(ary, obj);
- fz_drop_obj(obj);
+ obj = pdf_new_indirect(ctx, a, b, xref);
+ pdf_array_push(ary, obj);
+ pdf_drop_obj(obj);
obj = NULL;
n = 0;
break;
case PDF_TOK_OPEN_ARRAY:
obj = pdf_parse_array(xref, file, buf);
- fz_array_push(ary, obj);
- fz_drop_obj(obj);
+ pdf_array_push(ary, obj);
+ pdf_drop_obj(obj);
obj = NULL;
break;
case PDF_TOK_OPEN_DICT:
obj = pdf_parse_dict(xref, file, buf);
- fz_array_push(ary, obj);
- fz_drop_obj(obj);
+ pdf_array_push(ary, obj);
+ pdf_drop_obj(obj);
obj = NULL;
break;
case PDF_TOK_NAME:
obj = fz_new_name(ctx, buf->scratch);
- fz_array_push(ary, obj);
- fz_drop_obj(obj);
+ pdf_array_push(ary, obj);
+ pdf_drop_obj(obj);
obj = NULL;
break;
case PDF_TOK_REAL:
- obj = fz_new_real(ctx, buf->f);
- fz_array_push(ary, obj);
- fz_drop_obj(obj);
+ obj = pdf_new_real(ctx, buf->f);
+ pdf_array_push(ary, obj);
+ pdf_drop_obj(obj);
obj = NULL;
break;
case PDF_TOK_STRING:
- obj = fz_new_string(ctx, buf->scratch, buf->len);
- fz_array_push(ary, obj);
- fz_drop_obj(obj);
+ obj = pdf_new_string(ctx, buf->scratch, buf->len);
+ pdf_array_push(ary, obj);
+ pdf_drop_obj(obj);
obj = NULL;
break;
case PDF_TOK_TRUE:
- obj = fz_new_bool(ctx, 1);
- fz_array_push(ary, obj);
- fz_drop_obj(obj);
+ obj = pdf_new_bool(ctx, 1);
+ pdf_array_push(ary, obj);
+ pdf_drop_obj(obj);
obj = NULL;
break;
case PDF_TOK_FALSE:
- obj = fz_new_bool(ctx, 0);
- fz_array_push(ary, obj);
- fz_drop_obj(obj);
+ obj = pdf_new_bool(ctx, 0);
+ pdf_array_push(ary, obj);
+ pdf_drop_obj(obj);
obj = NULL;
break;
case PDF_TOK_NULL:
- obj = fz_new_null(ctx);
- fz_array_push(ary, obj);
- fz_drop_obj(obj);
+ obj = pdf_new_null(ctx);
+ pdf_array_push(ary, obj);
+ pdf_drop_obj(obj);
obj = NULL;
break;
@@ -303,19 +303,19 @@ end:
}
fz_catch(ctx)
{
- fz_drop_obj(obj);
- fz_drop_obj(ary);
+ pdf_drop_obj(obj);
+ pdf_drop_obj(ary);
fz_throw(ctx, "cannot parse array");
}
return op;
}
-fz_obj *
+pdf_obj *
pdf_parse_dict(pdf_document *xref, fz_stream *file, pdf_lexbuf *buf)
{
- fz_obj *dict = NULL;
- fz_obj *key = NULL;
- fz_obj *val = NULL;
+ pdf_obj *dict = NULL;
+ pdf_obj *key = NULL;
+ pdf_obj *val = NULL;
int tok;
int a, b;
fz_context *ctx = file->ctx;
@@ -324,7 +324,7 @@ pdf_parse_dict(pdf_document *xref, fz_stream *file, pdf_lexbuf *buf)
fz_var(key);
fz_var(val);
- dict = fz_new_dict(ctx, 8);
+ dict = pdf_new_dict(ctx, 8);
fz_try(ctx)
{
@@ -357,11 +357,11 @@ pdf_parse_dict(pdf_document *xref, fz_stream *file, pdf_lexbuf *buf)
break;
case PDF_TOK_NAME: val = fz_new_name(ctx, buf->scratch); break;
- case PDF_TOK_REAL: val = fz_new_real(ctx, buf->f); break;
- case PDF_TOK_STRING: val = fz_new_string(ctx, buf->scratch, buf->len); break;
- case PDF_TOK_TRUE: val = fz_new_bool(ctx, 1); break;
- case PDF_TOK_FALSE: val = fz_new_bool(ctx, 0); break;
- case PDF_TOK_NULL: val = fz_new_null(ctx); break;
+ case PDF_TOK_REAL: val = pdf_new_real(ctx, buf->f); break;
+ case PDF_TOK_STRING: val = pdf_new_string(ctx, buf->scratch, buf->len); break;
+ case PDF_TOK_TRUE: val = pdf_new_bool(ctx, 1); break;
+ case PDF_TOK_FALSE: val = pdf_new_bool(ctx, 0); break;
+ case PDF_TOK_NULL: val = pdf_new_null(ctx); break;
case PDF_TOK_INT:
/* 64-bit to allow for numbers > INT_MAX and overflow */
@@ -370,11 +370,11 @@ pdf_parse_dict(pdf_document *xref, fz_stream *file, pdf_lexbuf *buf)
if (tok == PDF_TOK_CLOSE_DICT || tok == PDF_TOK_NAME ||
(tok == PDF_TOK_KEYWORD && !strcmp(buf->scratch, "ID")))
{
- val = fz_new_int(ctx, a);
+ val = pdf_new_int(ctx, a);
fz_dict_put(dict, key, val);
- fz_drop_obj(val);
+ pdf_drop_obj(val);
val = NULL;
- fz_drop_obj(key);
+ pdf_drop_obj(key);
key = NULL;
goto skip;
}
@@ -384,7 +384,7 @@ pdf_parse_dict(pdf_document *xref, fz_stream *file, pdf_lexbuf *buf)
tok = pdf_lex(file, buf);
if (tok == PDF_TOK_R)
{
- val = fz_new_indirect(ctx, a, b, xref);
+ val = pdf_new_indirect(ctx, a, b, xref);
break;
}
}
@@ -395,23 +395,23 @@ pdf_parse_dict(pdf_document *xref, fz_stream *file, pdf_lexbuf *buf)
}
fz_dict_put(dict, key, val);
- fz_drop_obj(val);
+ pdf_drop_obj(val);
val = NULL;
- fz_drop_obj(key);
+ pdf_drop_obj(key);
key = NULL;
}
}
fz_catch(ctx)
{
- fz_drop_obj(dict);
- fz_drop_obj(key);
- fz_drop_obj(val);
+ pdf_drop_obj(dict);
+ pdf_drop_obj(key);
+ pdf_drop_obj(val);
fz_throw(ctx, "cannot parse dict");
}
return dict;
}
-fz_obj *
+pdf_obj *
pdf_parse_stm_obj(pdf_document *xref, fz_stream *file, pdf_lexbuf *buf)
{
int tok;
@@ -429,23 +429,23 @@ pdf_parse_stm_obj(pdf_document *xref, fz_stream *file, pdf_lexbuf *buf)
return pdf_parse_dict(xref, file, buf);
/* RJW: "cannot parse object stream" */
case PDF_TOK_NAME: return fz_new_name(ctx, buf->scratch); break;
- case PDF_TOK_REAL: return fz_new_real(ctx, buf->f); break;
- case PDF_TOK_STRING: return fz_new_string(ctx, buf->scratch, buf->len); break;
- case PDF_TOK_TRUE: return fz_new_bool(ctx, 1); break;
- case PDF_TOK_FALSE: return fz_new_bool(ctx, 0); break;
- case PDF_TOK_NULL: return fz_new_null(ctx); break;
- case PDF_TOK_INT: return fz_new_int(ctx, buf->i); break;
+ case PDF_TOK_REAL: return pdf_new_real(ctx, buf->f); break;
+ case PDF_TOK_STRING: return pdf_new_string(ctx, buf->scratch, buf->len); break;
+ case PDF_TOK_TRUE: return pdf_new_bool(ctx, 1); break;
+ case PDF_TOK_FALSE: return pdf_new_bool(ctx, 0); break;
+ case PDF_TOK_NULL: return pdf_new_null(ctx); break;
+ case PDF_TOK_INT: return pdf_new_int(ctx, buf->i); break;
default: fz_throw(ctx, "unknown token in object stream");
}
return NULL; /* Stupid MSVC */
}
-fz_obj *
+pdf_obj *
pdf_parse_ind_obj(pdf_document *xref,
fz_stream *file, pdf_lexbuf *buf,
int *onum, int *ogen, int *ostmofs)
{
- fz_obj *obj = NULL;
+ pdf_obj *obj = NULL;
int num = 0, gen = 0, stm_ofs;
int tok;
int a, b;
@@ -486,11 +486,11 @@ pdf_parse_ind_obj(pdf_document *xref,
break;
case PDF_TOK_NAME: obj = fz_new_name(ctx, buf->scratch); break;
- case PDF_TOK_REAL: obj = fz_new_real(ctx, buf->f); break;
- case PDF_TOK_STRING: obj = fz_new_string(ctx, buf->scratch, buf->len); break;
- case PDF_TOK_TRUE: obj = fz_new_bool(ctx, 1); break;
- case PDF_TOK_FALSE: obj = fz_new_bool(ctx, 0); break;
- case PDF_TOK_NULL: obj = fz_new_null(ctx); break;
+ case PDF_TOK_REAL: obj = pdf_new_real(ctx, buf->f); break;
+ case PDF_TOK_STRING: obj = pdf_new_string(ctx, buf->scratch, buf->len); break;
+ case PDF_TOK_TRUE: obj = pdf_new_bool(ctx, 1); break;
+ case PDF_TOK_FALSE: obj = pdf_new_bool(ctx, 0); break;
+ case PDF_TOK_NULL: obj = pdf_new_null(ctx); break;
case PDF_TOK_INT:
a = buf->i;
@@ -498,7 +498,7 @@ pdf_parse_ind_obj(pdf_document *xref,
/* "cannot parse indirect object (%d %d R)", num, gen */
if (tok == PDF_TOK_STREAM || tok == PDF_TOK_ENDOBJ)
{
- obj = fz_new_int(ctx, a);
+ obj = pdf_new_int(ctx, a);
goto skip;
}
if (tok == PDF_TOK_INT)
@@ -508,14 +508,14 @@ pdf_parse_ind_obj(pdf_document *xref,
/* RJW: "cannot parse indirect object (%d %d R)", num, gen); */
if (tok == PDF_TOK_R)
{
- obj = fz_new_indirect(ctx, a, b, xref);
+ obj = pdf_new_indirect(ctx, a, b, xref);
break;
}
}
fz_throw(ctx, "expected 'R' keyword (%d %d R)", num, gen);
case PDF_TOK_ENDOBJ:
- obj = fz_new_null(ctx);
+ obj = pdf_new_null(ctx);
goto skip;
default:
@@ -528,7 +528,7 @@ pdf_parse_ind_obj(pdf_document *xref,
}
fz_catch(ctx)
{
- fz_drop_obj(obj);
+ pdf_drop_obj(obj);
fz_throw(ctx, "cannot parse indirect object (%d %d R)", num, gen);
}
diff --git a/pdf/pdf_pattern.c b/pdf/pdf_pattern.c
index c1869474..00e4b8fb 100644
--- a/pdf/pdf_pattern.c
+++ b/pdf/pdf_pattern.c
@@ -19,7 +19,7 @@ pdf_free_pattern_imp(fz_context *ctx, fz_storable *pat_)
pdf_pattern *pat = (pdf_pattern *)pat_;
if (pat->resources)
- fz_drop_obj(pat->resources);
+ pdf_drop_obj(pat->resources);
if (pat->contents)
fz_drop_buffer(ctx, pat->contents);
fz_free(ctx, pat);
@@ -34,10 +34,10 @@ pdf_pattern_size(pdf_pattern *pat)
}
pdf_pattern *
-pdf_load_pattern(pdf_document *xref, fz_obj *dict)
+pdf_load_pattern(pdf_document *xref, pdf_obj *dict)
{
pdf_pattern *pat;
- fz_obj *obj;
+ pdf_obj *obj;
fz_context *ctx = xref->ctx;
if ((pat = pdf_find_item(ctx, pdf_free_pattern_imp, dict)))
@@ -53,32 +53,32 @@ pdf_load_pattern(pdf_document *xref, fz_obj *dict)
/* Store pattern now, to avoid possible recursion if objects refer back to this one */
pdf_store_item(ctx, dict, pat, pdf_pattern_size(pat));
- pat->ismask = fz_to_int(fz_dict_gets(dict, "PaintType")) == 2;
- pat->xstep = fz_to_real(fz_dict_gets(dict, "XStep"));
- pat->ystep = fz_to_real(fz_dict_gets(dict, "YStep"));
+ pat->ismask = pdf_to_int(pdf_dict_gets(dict, "PaintType")) == 2;
+ pat->xstep = pdf_to_real(pdf_dict_gets(dict, "XStep"));
+ pat->ystep = pdf_to_real(pdf_dict_gets(dict, "YStep"));
- obj = fz_dict_gets(dict, "BBox");
+ obj = pdf_dict_gets(dict, "BBox");
pat->bbox = pdf_to_rect(ctx, obj);
- obj = fz_dict_gets(dict, "Matrix");
+ obj = pdf_dict_gets(dict, "Matrix");
if (obj)
pat->matrix = pdf_to_matrix(ctx, obj);
else
pat->matrix = fz_identity;
- pat->resources = fz_dict_gets(dict, "Resources");
+ pat->resources = pdf_dict_gets(dict, "Resources");
if (pat->resources)
- fz_keep_obj(pat->resources);
+ pdf_keep_obj(pat->resources);
fz_try(ctx)
{
- pat->contents = pdf_load_stream(xref, fz_to_num(dict), fz_to_gen(dict));
+ pat->contents = pdf_load_stream(xref, pdf_to_num(dict), pdf_to_gen(dict));
}
fz_catch(ctx)
{
pdf_remove_item(ctx, pdf_free_pattern_imp, dict);
pdf_drop_pattern(ctx, pat);
- fz_throw(ctx, "cannot load pattern stream (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
+ fz_throw(ctx, "cannot load pattern stream (%d %d R)", pdf_to_num(dict), pdf_to_gen(dict));
}
return pat;
}
diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c
index c70df3e2..f42198eb 100644
--- a/pdf/pdf_repair.c
+++ b/pdf/pdf_repair.c
@@ -13,7 +13,7 @@ struct entry
};
static void
-pdf_repair_obj(fz_stream *file, pdf_lexbuf *buf, int *stmofsp, int *stmlenp, fz_obj **encrypt, fz_obj **id)
+pdf_repair_obj(fz_stream *file, pdf_lexbuf *buf, int *stmofsp, int *stmlenp, pdf_obj **encrypt, pdf_obj **id)
{
int tok;
int stm_len;
@@ -29,7 +29,7 @@ pdf_repair_obj(fz_stream *file, pdf_lexbuf *buf, int *stmofsp, int *stmlenp, fz_
/* RJW: "cannot parse object" */
if (tok == PDF_TOK_OPEN_DICT)
{
- fz_obj *dict, *obj;
+ pdf_obj *dict, *obj;
/* Send NULL xref so we don't try to resolve references */
fz_try(ctx)
@@ -42,34 +42,34 @@ pdf_repair_obj(fz_stream *file, pdf_lexbuf *buf, int *stmofsp, int *stmlenp, fz_
if (file->eof)
fz_throw(ctx, "broken object at EOF ignored");
/* Silently swallow the error */
- dict = fz_new_dict(ctx, 2);
+ dict = pdf_new_dict(ctx, 2);
}
- obj = fz_dict_gets(dict, "Type");
- if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "XRef"))
+ obj = pdf_dict_gets(dict, "Type");
+ if (pdf_is_name(obj) && !strcmp(pdf_to_name(obj), "XRef"))
{
- obj = fz_dict_gets(dict, "Encrypt");
+ obj = pdf_dict_gets(dict, "Encrypt");
if (obj)
{
if (*encrypt)
- fz_drop_obj(*encrypt);
- *encrypt = fz_keep_obj(obj);
+ pdf_drop_obj(*encrypt);
+ *encrypt = pdf_keep_obj(obj);
}
- obj = fz_dict_gets(dict, "ID");
+ obj = pdf_dict_gets(dict, "ID");
if (obj)
{
if (*id)
- fz_drop_obj(*id);
- *id = fz_keep_obj(obj);
+ pdf_drop_obj(*id);
+ *id = pdf_keep_obj(obj);
}
}
- obj = fz_dict_gets(dict, "Length");
- if (!fz_is_indirect(obj) && fz_is_int(obj))
- stm_len = fz_to_int(obj);
+ obj = pdf_dict_gets(dict, "Length");
+ if (!pdf_is_indirect(obj) && pdf_is_int(obj))
+ stm_len = pdf_to_int(obj);
- fz_drop_obj(dict);
+ pdf_drop_obj(dict);
}
while ( tok != PDF_TOK_STREAM &&
@@ -142,7 +142,7 @@ atobjend:
static void
pdf_repair_obj_stm(pdf_document *xref, int num, int gen)
{
- fz_obj *obj;
+ pdf_obj *obj;
fz_stream *stm = NULL;
int tok;
int i, n, count;
@@ -157,9 +157,9 @@ pdf_repair_obj_stm(pdf_document *xref, int num, int gen)
{
obj = pdf_load_object(xref, num, gen);
- count = fz_to_int(fz_dict_gets(obj, "N"));
+ count = pdf_to_int(pdf_dict_gets(obj, "N"));
- fz_drop_obj(obj);
+ pdf_drop_obj(obj);
stm = pdf_open_stream(xref, num, gen);
@@ -176,7 +176,7 @@ pdf_repair_obj_stm(pdf_document *xref, int num, int gen)
xref->table[n].ofs = num;
xref->table[n].gen = i;
xref->table[n].stm_ofs = 0;
- fz_drop_obj(xref->table[n].obj);
+ pdf_drop_obj(xref->table[n].obj);
xref->table[n].obj = NULL;
xref->table[n].type = 'o';
@@ -198,13 +198,13 @@ pdf_repair_obj_stm(pdf_document *xref, int num, int gen)
void
pdf_repair_xref(pdf_document *xref, pdf_lexbuf *buf)
{
- fz_obj *dict, *obj;
- fz_obj *length;
+ pdf_obj *dict, *obj;
+ pdf_obj *length;
- fz_obj *encrypt = NULL;
- fz_obj *id = NULL;
- fz_obj *root = NULL;
- fz_obj *info = NULL;
+ pdf_obj *encrypt = NULL;
+ pdf_obj *id = NULL;
+ pdf_obj *root = NULL;
+ pdf_obj *info = NULL;
struct entry *list = NULL;
int listlen;
@@ -332,39 +332,39 @@ pdf_repair_xref(pdf_document *xref, pdf_lexbuf *buf)
break;
}
- obj = fz_dict_gets(dict, "Encrypt");
+ obj = pdf_dict_gets(dict, "Encrypt");
if (obj)
{
if (encrypt)
- fz_drop_obj(encrypt);
- encrypt = fz_keep_obj(obj);
+ pdf_drop_obj(encrypt);
+ encrypt = pdf_keep_obj(obj);
}
- obj = fz_dict_gets(dict, "ID");
+ obj = pdf_dict_gets(dict, "ID");
if (obj)
{
if (id)
- fz_drop_obj(id);
- id = fz_keep_obj(obj);
+ pdf_drop_obj(id);
+ id = pdf_keep_obj(obj);
}
- obj = fz_dict_gets(dict, "Root");
+ obj = pdf_dict_gets(dict, "Root");
if (obj)
{
if (root)
- fz_drop_obj(root);
- root = fz_keep_obj(obj);
+ pdf_drop_obj(root);
+ root = pdf_keep_obj(obj);
}
- obj = fz_dict_gets(dict, "Info");
+ obj = pdf_dict_gets(dict, "Info");
if (obj)
{
if (info)
- fz_drop_obj(info);
- info = fz_keep_obj(obj);
+ pdf_drop_obj(info);
+ info = pdf_keep_obj(obj);
}
- fz_drop_obj(dict);
+ pdf_drop_obj(dict);
}
else if (tok == PDF_TOK_ERROR)
@@ -394,11 +394,11 @@ pdf_repair_xref(pdf_document *xref, pdf_lexbuf *buf)
fz_lock(ctx, FZ_LOCK_FILE);
/* RJW: "cannot load stream object (%d %d R)", list[i].num, list[i].gen */
- length = fz_new_int(ctx, list[i].stm_len);
- fz_dict_puts(dict, "Length", length);
- fz_drop_obj(length);
+ length = pdf_new_int(ctx, list[i].stm_len);
+ pdf_dict_puts(dict, "Length", length);
+ pdf_drop_obj(length);
- fz_drop_obj(dict);
+ pdf_drop_obj(dict);
}
}
@@ -423,57 +423,57 @@ pdf_repair_xref(pdf_document *xref, pdf_lexbuf *buf)
/* create a repaired trailer, Root will be added later */
- xref->trailer = fz_new_dict(ctx, 5);
+ xref->trailer = pdf_new_dict(ctx, 5);
- obj = fz_new_int(ctx, maxnum + 1);
- fz_dict_puts(xref->trailer, "Size", obj);
- fz_drop_obj(obj);
+ obj = pdf_new_int(ctx, maxnum + 1);
+ pdf_dict_puts(xref->trailer, "Size", obj);
+ pdf_drop_obj(obj);
if (root)
{
- fz_dict_puts(xref->trailer, "Root", root);
- fz_drop_obj(root);
+ pdf_dict_puts(xref->trailer, "Root", root);
+ pdf_drop_obj(root);
}
if (info)
{
- fz_dict_puts(xref->trailer, "Info", info);
- fz_drop_obj(info);
+ pdf_dict_puts(xref->trailer, "Info", info);
+ pdf_drop_obj(info);
}
if (encrypt)
{
- if (fz_is_indirect(encrypt))
+ if (pdf_is_indirect(encrypt))
{
/* create new reference with non-NULL xref pointer */
- obj = fz_new_indirect(ctx, fz_to_num(encrypt), fz_to_gen(encrypt), xref);
- fz_drop_obj(encrypt);
+ obj = pdf_new_indirect(ctx, pdf_to_num(encrypt), pdf_to_gen(encrypt), xref);
+ pdf_drop_obj(encrypt);
encrypt = obj;
}
- fz_dict_puts(xref->trailer, "Encrypt", encrypt);
- fz_drop_obj(encrypt);
+ pdf_dict_puts(xref->trailer, "Encrypt", encrypt);
+ pdf_drop_obj(encrypt);
}
if (id)
{
- if (fz_is_indirect(id))
+ if (pdf_is_indirect(id))
{
/* create new reference with non-NULL xref pointer */
- obj = fz_new_indirect(ctx, fz_to_num(id), fz_to_gen(id), xref);
- fz_drop_obj(id);
+ obj = pdf_new_indirect(ctx, pdf_to_num(id), pdf_to_gen(id), xref);
+ pdf_drop_obj(id);
id = obj;
}
- fz_dict_puts(xref->trailer, "ID", id);
- fz_drop_obj(id);
+ pdf_dict_puts(xref->trailer, "ID", id);
+ pdf_drop_obj(id);
}
fz_free(ctx, list);
}
fz_catch(ctx)
{
- if (encrypt) fz_drop_obj(encrypt);
- if (id) fz_drop_obj(id);
- if (root) fz_drop_obj(root);
- if (info) fz_drop_obj(info);
+ if (encrypt) pdf_drop_obj(encrypt);
+ if (id) pdf_drop_obj(id);
+ if (root) pdf_drop_obj(root);
+ if (info) pdf_drop_obj(info);
fz_free(ctx, list);
fz_rethrow(ctx);
}
@@ -482,7 +482,7 @@ pdf_repair_xref(pdf_document *xref, pdf_lexbuf *buf)
void
pdf_repair_obj_stms(pdf_document *xref)
{
- fz_obj *dict;
+ pdf_obj *dict;
int i;
for (i = 0; i < xref->len; i++)
@@ -490,9 +490,9 @@ pdf_repair_obj_stms(pdf_document *xref)
if (xref->table[i].stm_ofs)
{
dict = pdf_load_object(xref, i, 0);
- if (!strcmp(fz_to_name(fz_dict_gets(dict, "Type")), "ObjStm"))
+ if (!strcmp(pdf_to_name(pdf_dict_gets(dict, "Type")), "ObjStm"))
pdf_repair_obj_stm(xref, i, 0);
- fz_drop_obj(dict);
+ pdf_drop_obj(dict);
}
}
diff --git a/pdf/pdf_shade.c b/pdf/pdf_shade.c
index 1be2bb15..c3bddcbc 100644
--- a/pdf/pdf_shade.c
+++ b/pdf/pdf_shade.c
@@ -363,9 +363,9 @@ pdf_sample_shade_function(fz_context *ctx, fz_shade *shade, int funcs, pdf_funct
/* Type 1-3 -- Function-based, axial and radial shadings */
static void
-pdf_load_function_based_shading(fz_shade *shade, pdf_document *xref, fz_obj *dict, pdf_function *func)
+pdf_load_function_based_shading(fz_shade *shade, pdf_document *xref, pdf_obj *dict, pdf_function *func)
{
- fz_obj *obj;
+ pdf_obj *obj;
float x0, y0, x1, y1;
fz_matrix matrix;
struct vertex v[4];
@@ -377,18 +377,18 @@ pdf_load_function_based_shading(fz_shade *shade, pdf_document *xref, fz_obj *dic
x0 = y0 = 0;
x1 = y1 = 1;
- obj = fz_dict_gets(dict, "Domain");
- if (fz_array_len(obj) == 4)
+ obj = pdf_dict_gets(dict, "Domain");
+ if (pdf_array_len(obj) == 4)
{
- x0 = fz_to_real(fz_array_get(obj, 0));
- x1 = fz_to_real(fz_array_get(obj, 1));
- y0 = fz_to_real(fz_array_get(obj, 2));
- y1 = fz_to_real(fz_array_get(obj, 3));
+ x0 = pdf_to_real(pdf_array_get(obj, 0));
+ x1 = pdf_to_real(pdf_array_get(obj, 1));
+ y0 = pdf_to_real(pdf_array_get(obj, 2));
+ y1 = pdf_to_real(pdf_array_get(obj, 3));
}
matrix = fz_identity;
- obj = fz_dict_gets(dict, "Matrix");
- if (fz_array_len(obj) == 6)
+ obj = pdf_dict_gets(dict, "Matrix");
+ if (pdf_array_len(obj) == 6)
matrix = pdf_to_matrix(ctx, obj);
for (yy = 0; yy < FUNSEGS; yy++)
@@ -428,36 +428,36 @@ pdf_load_function_based_shading(fz_shade *shade, pdf_document *xref, fz_obj *dic
}
static void
-pdf_load_axial_shading(fz_shade *shade, pdf_document *xref, fz_obj *dict, int funcs, pdf_function **func)
+pdf_load_axial_shading(fz_shade *shade, pdf_document *xref, pdf_obj *dict, int funcs, pdf_function **func)
{
- fz_obj *obj;
+ pdf_obj *obj;
float d0, d1;
int e0, e1;
float x0, y0, x1, y1;
struct vertex p1, p2;
fz_context *ctx = xref->ctx;
- obj = fz_dict_gets(dict, "Coords");
- x0 = fz_to_real(fz_array_get(obj, 0));
- y0 = fz_to_real(fz_array_get(obj, 1));
- x1 = fz_to_real(fz_array_get(obj, 2));
- y1 = fz_to_real(fz_array_get(obj, 3));
+ obj = pdf_dict_gets(dict, "Coords");
+ x0 = pdf_to_real(pdf_array_get(obj, 0));
+ y0 = pdf_to_real(pdf_array_get(obj, 1));
+ x1 = pdf_to_real(pdf_array_get(obj, 2));
+ y1 = pdf_to_real(pdf_array_get(obj, 3));
d0 = 0;
d1 = 1;
- obj = fz_dict_gets(dict, "Domain");
- if (fz_array_len(obj) == 2)
+ obj = pdf_dict_gets(dict, "Domain");
+ if (pdf_array_len(obj) == 2)
{
- d0 = fz_to_real(fz_array_get(obj, 0));
- d1 = fz_to_real(fz_array_get(obj, 1));
+ d0 = pdf_to_real(pdf_array_get(obj, 0));
+ d1 = pdf_to_real(pdf_array_get(obj, 1));
}
e0 = e1 = 0;
- obj = fz_dict_gets(dict, "Extend");
- if (fz_array_len(obj) == 2)
+ obj = pdf_dict_gets(dict, "Extend");
+ if (pdf_array_len(obj) == 2)
{
- e0 = fz_to_bool(fz_array_get(obj, 0));
- e1 = fz_to_bool(fz_array_get(obj, 1));
+ e0 = pdf_to_bool(pdf_array_get(obj, 0));
+ e1 = pdf_to_bool(pdf_array_get(obj, 1));
}
pdf_sample_shade_function(ctx, shade, funcs, func, d0, d1);
@@ -479,38 +479,38 @@ pdf_load_axial_shading(fz_shade *shade, pdf_document *xref, fz_obj *dict, int fu
}
static void
-pdf_load_radial_shading(fz_shade *shade, pdf_document *xref, fz_obj *dict, int funcs, pdf_function **func)
+pdf_load_radial_shading(fz_shade *shade, pdf_document *xref, pdf_obj *dict, int funcs, pdf_function **func)
{
- fz_obj *obj;
+ pdf_obj *obj;
float d0, d1;
int e0, e1;
float x0, y0, r0, x1, y1, r1;
struct vertex p1, p2;
fz_context *ctx = xref->ctx;
- obj = fz_dict_gets(dict, "Coords");
- x0 = fz_to_real(fz_array_get(obj, 0));
- y0 = fz_to_real(fz_array_get(obj, 1));
- r0 = fz_to_real(fz_array_get(obj, 2));
- x1 = fz_to_real(fz_array_get(obj, 3));
- y1 = fz_to_real(fz_array_get(obj, 4));
- r1 = fz_to_real(fz_array_get(obj, 5));
+ obj = pdf_dict_gets(dict, "Coords");
+ x0 = pdf_to_real(pdf_array_get(obj, 0));
+ y0 = pdf_to_real(pdf_array_get(obj, 1));
+ r0 = pdf_to_real(pdf_array_get(obj, 2));
+ x1 = pdf_to_real(pdf_array_get(obj, 3));
+ y1 = pdf_to_real(pdf_array_get(obj, 4));
+ r1 = pdf_to_real(pdf_array_get(obj, 5));
d0 = 0;
d1 = 1;
- obj = fz_dict_gets(dict, "Domain");
- if (fz_array_len(obj) == 2)
+ obj = pdf_dict_gets(dict, "Domain");
+ if (pdf_array_len(obj) == 2)
{
- d0 = fz_to_real(fz_array_get(obj, 0));
- d1 = fz_to_real(fz_array_get(obj, 1));
+ d0 = pdf_to_real(pdf_array_get(obj, 0));
+ d1 = pdf_to_real(pdf_array_get(obj, 1));
}
e0 = e1 = 0;
- obj = fz_dict_gets(dict, "Extend");
- if (fz_array_len(obj) == 2)
+ obj = pdf_dict_gets(dict, "Extend");
+ if (pdf_array_len(obj) == 2)
{
- e0 = fz_to_bool(fz_array_get(obj, 0));
- e1 = fz_to_bool(fz_array_get(obj, 1));
+ e0 = pdf_to_bool(pdf_array_get(obj, 0));
+ e1 = pdf_to_bool(pdf_array_get(obj, 1));
}
pdf_sample_shade_function(ctx, shade, funcs, func, d0, d1);
@@ -553,9 +553,9 @@ struct mesh_params
};
static void
-pdf_load_mesh_params(pdf_document *xref, fz_obj *dict, struct mesh_params *p)
+pdf_load_mesh_params(pdf_document *xref, pdf_obj *dict, struct mesh_params *p)
{
- fz_obj *obj;
+ pdf_obj *obj;
int i, n;
p->x0 = p->y0 = 0;
@@ -566,23 +566,23 @@ pdf_load_mesh_params(pdf_document *xref, fz_obj *dict, struct mesh_params *p)
p->c1[i] = 1;
}
- p->vprow = fz_to_int(fz_dict_gets(dict, "VerticesPerRow"));
- p->bpflag = fz_to_int(fz_dict_gets(dict, "BitsPerFlag"));
- p->bpcoord = fz_to_int(fz_dict_gets(dict, "BitsPerCoordinate"));
- p->bpcomp = fz_to_int(fz_dict_gets(dict, "BitsPerComponent"));
+ p->vprow = pdf_to_int(pdf_dict_gets(dict, "VerticesPerRow"));
+ p->bpflag = pdf_to_int(pdf_dict_gets(dict, "BitsPerFlag"));
+ p->bpcoord = pdf_to_int(pdf_dict_gets(dict, "BitsPerCoordinate"));
+ p->bpcomp = pdf_to_int(pdf_dict_gets(dict, "BitsPerComponent"));
- obj = fz_dict_gets(dict, "Decode");
- if (fz_array_len(obj) >= 6)
+ obj = pdf_dict_gets(dict, "Decode");
+ if (pdf_array_len(obj) >= 6)
{
- n = (fz_array_len(obj) - 4) / 2;
- p->x0 = fz_to_real(fz_array_get(obj, 0));
- p->x1 = fz_to_real(fz_array_get(obj, 1));
- p->y0 = fz_to_real(fz_array_get(obj, 2));
- p->y1 = fz_to_real(fz_array_get(obj, 3));
+ n = (pdf_array_len(obj) - 4) / 2;
+ p->x0 = pdf_to_real(pdf_array_get(obj, 0));
+ p->x1 = pdf_to_real(pdf_array_get(obj, 1));
+ p->y0 = pdf_to_real(pdf_array_get(obj, 2));
+ p->y1 = pdf_to_real(pdf_array_get(obj, 3));
for (i = 0; i < n; i++)
{
- p->c0[i] = fz_to_real(fz_array_get(obj, 4 + i * 2));
- p->c1[i] = fz_to_real(fz_array_get(obj, 5 + i * 2));
+ p->c0[i] = pdf_to_real(pdf_array_get(obj, 4 + i * 2));
+ p->c1[i] = pdf_to_real(pdf_array_get(obj, 5 + i * 2));
}
}
@@ -603,7 +603,7 @@ pdf_load_mesh_params(pdf_document *xref, fz_obj *dict, struct mesh_params *p)
}
static void
-pdf_load_type4_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict,
+pdf_load_type4_shade(fz_shade *shade, pdf_document *xref, pdf_obj *dict,
int funcs, pdf_function **func)
{
fz_context *ctx = xref->ctx;
@@ -624,7 +624,7 @@ pdf_load_type4_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict,
else
ncomp = shade->colorspace->n;
- stream = pdf_open_stream(xref, fz_to_num(dict), fz_to_gen(dict));
+ stream = pdf_open_stream(xref, pdf_to_num(dict), pdf_to_gen(dict));
while (!fz_is_eof_bits(stream))
{
@@ -672,7 +672,7 @@ pdf_load_type4_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict,
}
static void
-pdf_load_type5_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict,
+pdf_load_type5_shade(fz_shade *shade, pdf_document *xref, pdf_obj *dict,
int funcs, pdf_function **func)
{
fz_context *ctx = xref->ctx;
@@ -697,7 +697,7 @@ pdf_load_type5_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict,
buf = fz_malloc_array(ctx, p.vprow, sizeof(struct vertex));
first = 1;
- stream = pdf_open_stream(xref, fz_to_num(dict), fz_to_gen(dict));
+ stream = pdf_open_stream(xref, pdf_to_num(dict), pdf_to_gen(dict));
while (!fz_is_eof_bits(stream))
{
@@ -726,7 +726,7 @@ pdf_load_type5_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict,
/* Type 6 & 7 -- Patch mesh shadings */
static void
-pdf_load_type6_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict,
+pdf_load_type6_shade(fz_shade *shade, pdf_document *xref, pdf_obj *dict,
int funcs, pdf_function **func)
{
fz_context *ctx = xref->ctx;
@@ -750,7 +750,7 @@ pdf_load_type6_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict,
hasprevpatch = 0;
- stream = pdf_open_stream(xref, fz_to_num(dict), fz_to_gen(dict));
+ stream = pdf_open_stream(xref, pdf_to_num(dict), pdf_to_gen(dict));
while (!fz_is_eof_bits(stream))
{
@@ -849,7 +849,7 @@ pdf_load_type6_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict,
}
static void
-pdf_load_type7_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict,
+pdf_load_type7_shade(fz_shade *shade, pdf_document *xref, pdf_obj *dict,
int funcs, pdf_function **func)
{
fz_context *ctx = xref->ctx;
@@ -873,7 +873,7 @@ pdf_load_type7_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict,
hasprevpatch = 0;
- stream = pdf_open_stream(xref, fz_to_num(dict), fz_to_gen(dict));
+ stream = pdf_open_stream(xref, pdf_to_num(dict), pdf_to_gen(dict));
while (!fz_is_eof_bits(stream))
{
@@ -974,11 +974,11 @@ pdf_load_type7_shade(fz_shade *shade, pdf_document *xref, fz_obj *dict,
/* Load all of the shading dictionary parameters, then switch on the shading type. */
static fz_shade *
-pdf_load_shading_dict(pdf_document *xref, fz_obj *dict, fz_matrix transform)
+pdf_load_shading_dict(pdf_document *xref, pdf_obj *dict, fz_matrix transform)
{
fz_shade *shade = NULL;
pdf_function *func[FZ_MAX_COLORS] = { NULL };
- fz_obj *obj;
+ pdf_obj *obj;
int funcs = 0;
int type = 0;
int i;
@@ -1009,49 +1009,49 @@ pdf_load_shading_dict(pdf_document *xref, fz_obj *dict, fz_matrix transform)
funcs = 0;
- obj = fz_dict_gets(dict, "ShadingType");
- type = fz_to_int(obj);
+ obj = pdf_dict_gets(dict, "ShadingType");
+ type = pdf_to_int(obj);
- obj = fz_dict_gets(dict, "ColorSpace");
+ obj = pdf_dict_gets(dict, "ColorSpace");
if (!obj)
fz_throw(ctx, "shading colorspace is missing");
shade->colorspace = pdf_load_colorspace(xref, obj);
- /* RJW: "cannot load colorspace (%d %d R)", fz_to_num(obj), fz_to_gen(obj) */
+ /* RJW: "cannot load colorspace (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj) */
- obj = fz_dict_gets(dict, "Background");
+ obj = pdf_dict_gets(dict, "Background");
if (obj)
{
shade->use_background = 1;
for (i = 0; i < shade->colorspace->n; i++)
- shade->background[i] = fz_to_real(fz_array_get(obj, i));
+ shade->background[i] = pdf_to_real(pdf_array_get(obj, i));
}
- obj = fz_dict_gets(dict, "BBox");
- if (fz_is_array(obj))
+ obj = pdf_dict_gets(dict, "BBox");
+ if (pdf_is_array(obj))
{
shade->bbox = pdf_to_rect(ctx, obj);
}
- obj = fz_dict_gets(dict, "Function");
- if (fz_is_dict(obj))
+ obj = pdf_dict_gets(dict, "Function");
+ if (pdf_is_dict(obj))
{
funcs = 1;
func[0] = pdf_load_function(xref, obj);
if (!func[0])
- fz_throw(ctx, "cannot load shading function (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
+ fz_throw(ctx, "cannot load shading function (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj));
}
- else if (fz_is_array(obj))
+ else if (pdf_is_array(obj))
{
- funcs = fz_array_len(obj);
+ funcs = pdf_array_len(obj);
if (funcs != 1 && funcs != shade->colorspace->n)
fz_throw(ctx, "incorrect number of shading functions");
for (i = 0; i < funcs; i++)
{
- func[i] = pdf_load_function(xref, fz_array_get(obj, i));
+ func[i] = pdf_load_function(xref, pdf_array_get(obj, i));
if (!func[i])
- fz_throw(ctx, "cannot load shading function (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
+ fz_throw(ctx, "cannot load shading function (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj));
}
}
@@ -1079,7 +1079,7 @@ pdf_load_shading_dict(pdf_document *xref, fz_obj *dict, fz_matrix transform)
pdf_drop_function(ctx, func[i]);
fz_drop_shade(ctx, shade);
- fz_throw(ctx, "cannot load shading type %d (%d %d R)", type, fz_to_num(dict), fz_to_gen(dict));
+ fz_throw(ctx, "cannot load shading type %d (%d %d R)", type, pdf_to_num(dict), pdf_to_gen(dict));
}
return shade;
}
@@ -1093,10 +1093,10 @@ fz_shade_size(fz_shade *s)
}
fz_shade *
-pdf_load_shading(pdf_document *xref, fz_obj *dict)
+pdf_load_shading(pdf_document *xref, pdf_obj *dict)
{
fz_matrix mat;
- fz_obj *obj;
+ pdf_obj *obj;
fz_context *ctx = xref->ctx;
fz_shade *shade;
@@ -1106,36 +1106,36 @@ pdf_load_shading(pdf_document *xref, fz_obj *dict)
}
/* Type 2 pattern dictionary */
- if (fz_dict_gets(dict, "PatternType"))
+ if (pdf_dict_gets(dict, "PatternType"))
{
- obj = fz_dict_gets(dict, "Matrix");
+ obj = pdf_dict_gets(dict, "Matrix");
if (obj)
mat = pdf_to_matrix(ctx, obj);
else
mat = fz_identity;
- obj = fz_dict_gets(dict, "ExtGState");
+ obj = pdf_dict_gets(dict, "ExtGState");
if (obj)
{
- if (fz_dict_gets(obj, "CA") || fz_dict_gets(obj, "ca"))
+ if (pdf_dict_gets(obj, "CA") || pdf_dict_gets(obj, "ca"))
{
fz_warn(ctx, "shading with alpha not supported");
}
}
- obj = fz_dict_gets(dict, "Shading");
+ obj = pdf_dict_gets(dict, "Shading");
if (!obj)
fz_throw(ctx, "syntaxerror: missing shading dictionary");
shade = pdf_load_shading_dict(xref, obj, mat);
- /* RJW: "cannot load shading dictionary (%d %d R)", fz_to_num(obj), fz_to_gen(obj) */
+ /* RJW: "cannot load shading dictionary (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj) */
}
/* Naked shading dictionary */
else
{
shade = pdf_load_shading_dict(xref, dict, fz_identity);
- /* RJW: "cannot load shading dictionary (%d %d R)", fz_to_num(dict), fz_to_gen(dict) */
+ /* RJW: "cannot load shading dictionary (%d %d R)", pdf_to_num(dict), pdf_to_gen(dict) */
}
pdf_store_item(ctx, dict, shade, fz_shade_size(shade));
diff --git a/pdf/pdf_store.c b/pdf/pdf_store.c
index 4f51526d..faa81b80 100644
--- a/pdf/pdf_store.c
+++ b/pdf/pdf_store.c
@@ -4,31 +4,43 @@
static int
pdf_make_hash_key(fz_store_hash *hash, void *key_)
{
- fz_obj *key = (fz_obj *)key_;
+ pdf_obj *key = (pdf_obj *)key_;
- if (!fz_is_indirect(key))
+ if (!pdf_is_indirect(key))
return 0;
- hash->u.i.i0 = fz_to_num(key);
- hash->u.i.i1 = fz_to_gen(key);
+ hash->u.i.i0 = pdf_to_num(key);
+ hash->u.i.i1 = pdf_to_gen(key);
return 1;
}
static void *
pdf_keep_key(fz_context *ctx, void *key)
{
- return (void *)fz_keep_obj((fz_obj *)key);
+ return (void *)pdf_keep_obj((pdf_obj *)key);
}
static void
pdf_drop_key(fz_context *ctx, void *key)
{
- fz_drop_obj((fz_obj *)key);
+ pdf_drop_obj((pdf_obj *)key);
}
static int
pdf_cmp_key(void *k0, void *k1)
{
- return fz_objcmp((fz_obj *)k0, (fz_obj *)k1);
+ return pdf_objcmp((pdf_obj *)k0, (pdf_obj *)k1);
+}
+
+static void
+pdf_debug_key(void *key_)
+{
+ pdf_obj *key = (pdf_obj *)key_;
+
+ if (pdf_is_indirect(key))
+ {
+ printf("(%d %d R) ", pdf_to_num(key), pdf_to_gen(key));
+ } else
+ pdf_debug_obj(key);
}
static fz_store_type pdf_obj_store_type =
@@ -36,23 +48,24 @@ static fz_store_type pdf_obj_store_type =
pdf_make_hash_key,
pdf_keep_key,
pdf_drop_key,
- pdf_cmp_key
+ pdf_cmp_key,
+ pdf_debug_key
};
void
-pdf_store_item(fz_context *ctx, fz_obj *key, void *val, unsigned int itemsize)
+pdf_store_item(fz_context *ctx, pdf_obj *key, void *val, unsigned int itemsize)
{
fz_store_item(ctx, key, val, itemsize, &pdf_obj_store_type);
}
void *
-pdf_find_item(fz_context *ctx, fz_store_free_fn *free, fz_obj *key)
+pdf_find_item(fz_context *ctx, fz_store_free_fn *free, pdf_obj *key)
{
return fz_find_item(ctx, free, key, &pdf_obj_store_type);
}
void
-pdf_remove_item(fz_context *ctx, fz_store_free_fn *free, fz_obj *key)
+pdf_remove_item(fz_context *ctx, fz_store_free_fn *free, pdf_obj *key)
{
fz_remove_item(ctx, free, key, &pdf_obj_store_type);
}
diff --git a/pdf/pdf_stream.c b/pdf/pdf_stream.c
index 28fc616f..6afb2cdb 100644
--- a/pdf/pdf_stream.c
+++ b/pdf/pdf_stream.c
@@ -20,24 +20,24 @@ pdf_is_stream(pdf_document *xref, int num, int gen)
* Scan stream dictionary for an explicit /Crypt filter
*/
static int
-pdf_stream_has_crypt(fz_context *ctx, fz_obj *stm)
+pdf_stream_has_crypt(fz_context *ctx, pdf_obj *stm)
{
- fz_obj *filters;
- fz_obj *obj;
+ pdf_obj *filters;
+ pdf_obj *obj;
int i;
- filters = fz_dict_getsa(stm, "Filter", "F");
+ filters = pdf_dict_getsa(stm, "Filter", "F");
if (filters)
{
- if (!strcmp(fz_to_name(filters), "Crypt"))
+ if (!strcmp(pdf_to_name(filters), "Crypt"))
return 1;
- if (fz_is_array(filters))
+ if (pdf_is_array(filters))
{
- int n = fz_array_len(filters);
+ int n = pdf_array_len(filters);
for (i = 0; i < n; i++)
{
- obj = fz_array_get(filters, i);
- if (!strcmp(fz_to_name(obj), "Crypt"))
+ obj = pdf_array_get(filters, i);
+ if (!strcmp(pdf_to_name(obj), "Crypt"))
return 1;
}
}
@@ -49,15 +49,15 @@ pdf_stream_has_crypt(fz_context *ctx, fz_obj *stm)
* Create a filter given a name and param dictionary.
*/
static fz_stream *
-build_filter(fz_stream *chain, pdf_document * xref, fz_obj * f, fz_obj * p, int num, int gen, pdf_image_params *params)
+build_filter(fz_stream *chain, pdf_document * xref, pdf_obj * f, pdf_obj * p, int num, int gen, pdf_image_params *params)
{
fz_context *ctx = chain->ctx;
- char *s = fz_to_name(f);
+ char *s = pdf_to_name(f);
- int predictor = fz_to_int(fz_dict_gets(p, "Predictor"));
- int columns = fz_to_int(fz_dict_gets(p, "Columns"));
- int colors = fz_to_int(fz_dict_gets(p, "Colors"));
- int bpc = fz_to_int(fz_dict_gets(p, "BitsPerComponent"));
+ int predictor = pdf_to_int(pdf_dict_gets(p, "Predictor"));
+ int columns = pdf_to_int(pdf_dict_gets(p, "Columns"));
+ int colors = pdf_to_int(pdf_dict_gets(p, "Colors"));
+ int bpc = pdf_to_int(pdf_dict_gets(p, "BitsPerComponent"));
if (predictor == 0) predictor = 1;
if (columns == 0) columns = 1;
@@ -72,47 +72,47 @@ build_filter(fz_stream *chain, pdf_document * xref, fz_obj * f, fz_obj * p, int
else if (!strcmp(s, "CCITTFaxDecode") || !strcmp(s, "CCF"))
{
- fz_obj *k = fz_dict_gets(p, "K");
- fz_obj *eol = fz_dict_gets(p, "EndOfLine");
- fz_obj *eba = fz_dict_gets(p, "EncodedByteAlign");
- fz_obj *columns = fz_dict_gets(p, "Columns");
- fz_obj *rows = fz_dict_gets(p, "Rows");
- fz_obj *eob = fz_dict_gets(p, "EndOfBlock");
- fz_obj *bi1 = fz_dict_gets(p, "BlackIs1");
+ pdf_obj *k = pdf_dict_gets(p, "K");
+ pdf_obj *eol = pdf_dict_gets(p, "EndOfLine");
+ pdf_obj *eba = pdf_dict_gets(p, "EncodedByteAlign");
+ pdf_obj *columns = pdf_dict_gets(p, "Columns");
+ pdf_obj *rows = pdf_dict_gets(p, "Rows");
+ pdf_obj *eob = pdf_dict_gets(p, "EndOfBlock");
+ pdf_obj *bi1 = pdf_dict_gets(p, "BlackIs1");
if (params)
{
/* We will shortstop here */
params->type = PDF_IMAGE_FAX;
- params->u.fax.k = (k ? fz_to_int(k) : 0);
- params->u.fax.eol = (eol ? fz_to_bool(eol) : 0);
- params->u.fax.eba = (eba ? fz_to_bool(eba) : 0);
- params->u.fax.columns = (columns ? fz_to_int(columns) : 1728);
- params->u.fax.rows = (rows ? fz_to_int(rows) : 0);
- params->u.fax.eob = (eob ? fz_to_bool(eob) : 1);
- params->u.fax.bi1 = (bi1 ? fz_to_bool(bi1) : 0);
+ params->u.fax.k = (k ? pdf_to_int(k) : 0);
+ params->u.fax.eol = (eol ? pdf_to_bool(eol) : 0);
+ params->u.fax.eba = (eba ? pdf_to_bool(eba) : 0);
+ params->u.fax.columns = (columns ? pdf_to_int(columns) : 1728);
+ params->u.fax.rows = (rows ? pdf_to_int(rows) : 0);
+ params->u.fax.eob = (eob ? pdf_to_bool(eob) : 1);
+ params->u.fax.bi1 = (bi1 ? pdf_to_bool(bi1) : 0);
return chain;
}
return fz_open_faxd(chain,
- k ? fz_to_int(k) : 0,
- eol ? fz_to_bool(eol) : 0,
- eba ? fz_to_bool(eba) : 0,
- columns ? fz_to_int(columns) : 1728,
- rows ? fz_to_int(rows) : 0,
- eob ? fz_to_bool(eob) : 1,
- bi1 ? fz_to_bool(bi1) : 0);
+ k ? pdf_to_int(k) : 0,
+ eol ? pdf_to_bool(eol) : 0,
+ eba ? pdf_to_bool(eba) : 0,
+ columns ? pdf_to_int(columns) : 1728,
+ rows ? pdf_to_int(rows) : 0,
+ eob ? pdf_to_bool(eob) : 1,
+ bi1 ? pdf_to_bool(bi1) : 0);
}
else if (!strcmp(s, "DCTDecode") || !strcmp(s, "DCT"))
{
- fz_obj *ct = fz_dict_gets(p, "ColorTransform");
+ pdf_obj *ct = pdf_dict_gets(p, "ColorTransform");
if (params)
{
/* We will shortstop here */
params->type = PDF_IMAGE_JPEG;
- params->u.jpeg.ct = (ct ? fz_to_int(ct) : -1);
+ params->u.jpeg.ct = (ct ? pdf_to_int(ct) : -1);
return chain;
}
- return fz_open_dctd(chain, ct ? fz_to_int(ct) : -1);
+ return fz_open_dctd(chain, ct ? pdf_to_int(ct) : -1);
}
else if (!strcmp(s, "RunLengthDecode") || !strcmp(s, "RL"))
@@ -145,7 +145,7 @@ build_filter(fz_stream *chain, pdf_document * xref, fz_obj * f, fz_obj * p, int
else if (!strcmp(s, "LZWDecode") || !strcmp(s, "LZW"))
{
- fz_obj *ec = fz_dict_gets(p, "EarlyChange");
+ pdf_obj *ec = pdf_dict_gets(p, "EarlyChange");
if (params)
{
/* We will shortstop here */
@@ -154,10 +154,10 @@ build_filter(fz_stream *chain, pdf_document * xref, fz_obj * f, fz_obj * p, int
params->u.lzw.columns = columns;
params->u.lzw.colors = colors;
params->u.lzw.bpc = bpc;
- params->u.lzw.ec = (ec ? fz_to_int(ec) : 1);
+ params->u.lzw.ec = (ec ? pdf_to_int(ec) : 1);
return chain;
}
- chain = fz_open_lzwd(chain, ec ? fz_to_int(ec) : 1);
+ chain = fz_open_lzwd(chain, ec ? pdf_to_int(ec) : 1);
if (predictor > 1)
chain = fz_open_predict(chain, predictor, columns, colors, bpc);
return chain;
@@ -166,9 +166,9 @@ build_filter(fz_stream *chain, pdf_document * xref, fz_obj * f, fz_obj * p, int
else if (!strcmp(s, "JBIG2Decode"))
{
fz_buffer *globals = NULL;
- fz_obj *obj = fz_dict_gets(p, "JBIG2Globals");
+ pdf_obj *obj = pdf_dict_gets(p, "JBIG2Globals");
if (obj)
- globals = pdf_load_stream(xref, fz_to_num(obj), fz_to_gen(obj));
+ globals = pdf_load_stream(xref, pdf_to_num(obj), pdf_to_gen(obj));
/* fz_open_jbig2d takes possession of globals */
return fz_open_jbig2d(chain, globals);
}
@@ -178,7 +178,7 @@ build_filter(fz_stream *chain, pdf_document * xref, fz_obj * f, fz_obj * p, int
else if (!strcmp(s, "Crypt"))
{
- fz_obj *name;
+ pdf_obj *name;
if (!xref->crypt)
{
@@ -186,9 +186,9 @@ build_filter(fz_stream *chain, pdf_document * xref, fz_obj * f, fz_obj * p, int
return chain;
}
- name = fz_dict_gets(p, "Name");
- if (fz_is_name(name))
- return pdf_open_crypt_with_filter(chain, xref->crypt, fz_to_name(name), num, gen);
+ name = pdf_dict_gets(p, "Name");
+ if (pdf_is_name(name))
+ return pdf_open_crypt_with_filter(chain, xref->crypt, pdf_to_name(name), num, gen);
return chain;
}
@@ -203,17 +203,17 @@ build_filter(fz_stream *chain, pdf_document * xref, fz_obj * f, fz_obj * p, int
* Assume ownership of head.
*/
static fz_stream *
-build_filter_chain(fz_stream *chain, pdf_document *xref, fz_obj *fs, fz_obj *ps, int num, int gen, pdf_image_params *params)
+build_filter_chain(fz_stream *chain, pdf_document *xref, pdf_obj *fs, pdf_obj *ps, int num, int gen, pdf_image_params *params)
{
- fz_obj *f;
- fz_obj *p;
+ pdf_obj *f;
+ pdf_obj *p;
int i, n;
- n = fz_array_len(fs);
+ n = pdf_array_len(fs);
for (i = 0; i < n; i++)
{
- f = fz_array_get(fs, i);
- p = fz_array_get(ps, i);
+ f = pdf_array_get(fs, i);
+ p = pdf_array_get(ps, i);
chain = build_filter(chain, xref, f, p, num, gen, (i == n-1 ? params : NULL));
}
@@ -226,7 +226,7 @@ build_filter_chain(fz_stream *chain, pdf_document *xref, fz_obj *fs, fz_obj *ps,
* stream length, followed by a decryption filter.
*/
static fz_stream *
-pdf_open_raw_filter(fz_stream *chain, pdf_document *xref, fz_obj *stmobj, int num, int gen)
+pdf_open_raw_filter(fz_stream *chain, pdf_document *xref, pdf_obj *stmobj, int num, int gen)
{
int hascrypt;
int len;
@@ -235,7 +235,7 @@ pdf_open_raw_filter(fz_stream *chain, pdf_document *xref, fz_obj *stmobj, int nu
/* don't close chain when we close this filter */
fz_keep_stream(chain);
- len = fz_to_int(fz_dict_gets(stmobj, "Length"));
+ len = pdf_to_int(pdf_dict_gets(stmobj, "Length"));
chain = fz_open_null(chain, len);
fz_try(ctx)
@@ -258,19 +258,19 @@ pdf_open_raw_filter(fz_stream *chain, pdf_document *xref, fz_obj *stmobj, int nu
* to stream length and decrypting.
*/
static fz_stream *
-pdf_open_filter(fz_stream *chain, pdf_document *xref, fz_obj *stmobj, int num, int gen, pdf_image_params *imparams)
+pdf_open_filter(fz_stream *chain, pdf_document *xref, pdf_obj *stmobj, int num, int gen, pdf_image_params *imparams)
{
- fz_obj *filters;
- fz_obj *params;
+ pdf_obj *filters;
+ pdf_obj *params;
- filters = fz_dict_getsa(stmobj, "Filter", "F");
- params = fz_dict_getsa(stmobj, "DecodeParms", "DP");
+ filters = pdf_dict_getsa(stmobj, "Filter", "F");
+ params = pdf_dict_getsa(stmobj, "DecodeParms", "DP");
chain = pdf_open_raw_filter(chain, xref, stmobj, num, gen);
- if (fz_is_name(filters))
+ if (pdf_is_name(filters))
chain = build_filter(chain, xref, filters, params, num, gen, imparams);
- else if (fz_array_len(filters) > 0)
+ else if (pdf_array_len(filters) > 0)
chain = build_filter_chain(chain, xref, filters, params, num, gen, imparams);
fz_lock_stream(chain);
@@ -282,20 +282,20 @@ pdf_open_filter(fz_stream *chain, pdf_document *xref, fz_obj *stmobj, int num, i
* constraining to stream length, and without decryption.
*/
fz_stream *
-pdf_open_inline_stream(pdf_document *xref, fz_obj *stmobj, int length, fz_stream *chain, pdf_image_params *imparams)
+pdf_open_inline_stream(pdf_document *xref, pdf_obj *stmobj, int length, fz_stream *chain, pdf_image_params *imparams)
{
- fz_obj *filters;
- fz_obj *params;
+ pdf_obj *filters;
+ pdf_obj *params;
- filters = fz_dict_getsa(stmobj, "Filter", "F");
- params = fz_dict_getsa(stmobj, "DecodeParms", "DP");
+ filters = pdf_dict_getsa(stmobj, "Filter", "F");
+ params = pdf_dict_getsa(stmobj, "DecodeParms", "DP");
/* don't close chain when we close this filter */
fz_keep_stream(chain);
- if (fz_is_name(filters))
+ if (pdf_is_name(filters))
return build_filter(chain, xref, filters, params, 0, 0, imparams);
- if (fz_array_len(filters) > 0)
+ if (pdf_array_len(filters) > 0)
return build_filter_chain(chain, xref, filters, params, 0, 0, imparams);
return fz_open_null(chain, length);
@@ -408,7 +408,7 @@ pdf_open_image_decomp_stream(fz_context *ctx, fz_buffer *buffer, pdf_image_param
}
fz_stream *
-pdf_open_stream_with_offset(pdf_document *xref, int num, int gen, fz_obj *dict, int stm_ofs)
+pdf_open_stream_with_offset(pdf_document *xref, int num, int gen, pdf_obj *dict, int stm_ofs)
{
fz_stream *stm;
@@ -427,16 +427,16 @@ fz_buffer *
pdf_load_raw_stream(pdf_document *xref, int num, int gen)
{
fz_stream *stm;
- fz_obj *dict;
+ pdf_obj *dict;
int len;
fz_buffer *buf;
dict = pdf_load_object(xref, num, gen);
/* RJW: "cannot load stream dictionary (%d %d R)", num, gen */
- len = fz_to_int(fz_dict_gets(dict, "Length"));
+ len = pdf_to_int(pdf_dict_gets(dict, "Length"));
- fz_drop_obj(dict);
+ pdf_drop_obj(dict);
stm = pdf_open_raw_stream(xref, num, gen);
/* RJW: "cannot open raw stream (%d %d R)", num, gen */
@@ -478,7 +478,7 @@ pdf_load_image_stream(pdf_document *xref, int num, int gen, pdf_image_params *pa
{
fz_context *ctx = xref->ctx;
fz_stream *stm = NULL;
- fz_obj *dict, *obj;
+ pdf_obj *dict, *obj;
int i, len, n;
fz_buffer *buf;
@@ -487,14 +487,14 @@ pdf_load_image_stream(pdf_document *xref, int num, int gen, pdf_image_params *pa
dict = pdf_load_object(xref, num, gen);
/* RJW: "cannot load stream dictionary (%d %d R)", num, gen */
- len = fz_to_int(fz_dict_gets(dict, "Length"));
- obj = fz_dict_gets(dict, "Filter");
- len = pdf_guess_filter_length(len, fz_to_name(obj));
- n = fz_array_len(obj);
+ len = pdf_to_int(pdf_dict_gets(dict, "Length"));
+ obj = pdf_dict_gets(dict, "Filter");
+ len = pdf_guess_filter_length(len, pdf_to_name(obj));
+ n = pdf_array_len(obj);
for (i = 0; i < n; i++)
- len = pdf_guess_filter_length(len, fz_to_name(fz_array_get(obj, i)));
+ len = pdf_guess_filter_length(len, pdf_to_name(pdf_array_get(obj, i)));
- fz_drop_obj(dict);
+ pdf_drop_obj(dict);
stm = pdf_open_image_stream(xref, num, gen, params);
/* RJW: "cannot open stream (%d %d R)", num, gen */
diff --git a/pdf/pdf_type3.c b/pdf/pdf_type3.c
index 777ff756..7a3b985f 100644
--- a/pdf/pdf_type3.c
+++ b/pdf/pdf_type3.c
@@ -2,21 +2,30 @@
#include "mupdf.h"
static void
-pdf_run_glyph_func(void *doc, fz_obj *rdb, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate)
+pdf_run_glyph_func(void *doc, void *rdb_, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate)
{
+ pdf_obj *rdb = (pdf_obj *)rdb_;
pdf_run_glyph(doc, rdb, contents, dev, ctm, gstate);
}
+static void
+pdf_t3_free_resources(void *doc, void *rdb_)
+{
+ pdf_obj *rdb = (pdf_obj *)rdb;
+ pdf_drop_obj(rdb);
+}
+
+
pdf_font_desc *
-pdf_load_type3_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict)
+pdf_load_type3_font(pdf_document *xref, pdf_obj *rdb, pdf_obj *dict)
{
char buf[256];
char *estrings[256];
pdf_font_desc *fontdesc = NULL;
- fz_obj *encoding;
- fz_obj *widths;
- fz_obj *charprocs;
- fz_obj *obj;
+ pdf_obj *encoding;
+ pdf_obj *widths;
+ pdf_obj *charprocs;
+ pdf_obj *obj;
int first, last;
int i, k, n;
fz_rect bbox;
@@ -27,18 +36,18 @@ pdf_load_type3_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict)
fz_try(ctx)
{
- obj = fz_dict_gets(dict, "Name");
- if (fz_is_name(obj))
- fz_strlcpy(buf, fz_to_name(obj), sizeof buf);
+ obj = pdf_dict_gets(dict, "Name");
+ if (pdf_is_name(obj))
+ fz_strlcpy(buf, pdf_to_name(obj), sizeof buf);
else
sprintf(buf, "Unnamed-T3");
fontdesc = pdf_new_font_desc(ctx);
- obj = fz_dict_gets(dict, "FontMatrix");
+ obj = pdf_dict_gets(dict, "FontMatrix");
matrix = pdf_to_matrix(ctx, obj);
- obj = fz_dict_gets(dict, "FontBBox");
+ obj = pdf_dict_gets(dict, "FontBBox");
bbox = pdf_to_rect(ctx, obj);
bbox = fz_transform_rect(matrix, bbox);
@@ -52,35 +61,35 @@ pdf_load_type3_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict)
for (i = 0; i < 256; i++)
estrings[i] = NULL;
- encoding = fz_dict_gets(dict, "Encoding");
+ encoding = pdf_dict_gets(dict, "Encoding");
if (!encoding)
{
fz_throw(ctx, "syntaxerror: Type3 font missing Encoding");
}
- if (fz_is_name(encoding))
- pdf_load_encoding(estrings, fz_to_name(encoding));
+ if (pdf_is_name(encoding))
+ pdf_load_encoding(estrings, pdf_to_name(encoding));
- if (fz_is_dict(encoding))
+ if (pdf_is_dict(encoding))
{
- fz_obj *base, *diff, *item;
+ pdf_obj *base, *diff, *item;
- base = fz_dict_gets(encoding, "BaseEncoding");
- if (fz_is_name(base))
- pdf_load_encoding(estrings, fz_to_name(base));
+ base = pdf_dict_gets(encoding, "BaseEncoding");
+ if (pdf_is_name(base))
+ pdf_load_encoding(estrings, pdf_to_name(base));
- diff = fz_dict_gets(encoding, "Differences");
- if (fz_is_array(diff))
+ diff = pdf_dict_gets(encoding, "Differences");
+ if (pdf_is_array(diff))
{
- n = fz_array_len(diff);
+ n = pdf_array_len(diff);
k = 0;
for (i = 0; i < n; i++)
{
- item = fz_array_get(diff, i);
- if (fz_is_int(item))
- k = fz_to_int(item);
- if (fz_is_name(item))
- estrings[k++] = fz_to_name(item);
+ item = pdf_array_get(diff, i);
+ if (pdf_is_int(item))
+ k = pdf_to_int(item);
+ if (pdf_is_name(item))
+ estrings[k++] = pdf_to_name(item);
if (k < 0) k = 0;
if (k > 255) k = 255;
}
@@ -90,16 +99,16 @@ pdf_load_type3_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict)
fontdesc->encoding = pdf_new_identity_cmap(ctx, 0, 1);
fontdesc->size += pdf_cmap_size(ctx, fontdesc->encoding);
- pdf_load_to_unicode(xref, fontdesc, estrings, NULL, fz_dict_gets(dict, "ToUnicode"));
+ pdf_load_to_unicode(xref, fontdesc, estrings, NULL, pdf_dict_gets(dict, "ToUnicode"));
/* Widths */
pdf_set_default_hmtx(ctx, fontdesc, 0);
- first = fz_to_int(fz_dict_gets(dict, "FirstChar"));
- last = fz_to_int(fz_dict_gets(dict, "LastChar"));
+ first = pdf_to_int(pdf_dict_gets(dict, "FirstChar"));
+ last = pdf_to_int(pdf_dict_gets(dict, "LastChar"));
- widths = fz_dict_gets(dict, "Widths");
+ widths = pdf_dict_gets(dict, "Widths");
if (!widths)
{
fz_throw(ctx, "syntaxerror: Type3 font missing Widths");
@@ -107,7 +116,7 @@ pdf_load_type3_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict)
for (i = first; i <= last; i++)
{
- float w = fz_to_real(fz_array_get(widths, i - first));
+ float w = pdf_to_real(pdf_array_get(widths, i - first));
w = fontdesc->font->t3matrix.a * w * 1000;
fontdesc->font->t3widths[i] = w * 0.001f;
pdf_add_hmtx(ctx, fontdesc, i, i, w);
@@ -117,11 +126,12 @@ pdf_load_type3_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict)
/* Resources -- inherit page resources if the font doesn't have its own */
- fontdesc->font->t3resources = fz_dict_gets(dict, "Resources");
+ fontdesc->font->t3freeres = pdf_t3_free_resources;
+ fontdesc->font->t3resources = pdf_dict_gets(dict, "Resources");
if (!fontdesc->font->t3resources)
fontdesc->font->t3resources = rdb;
if (fontdesc->font->t3resources)
- fz_keep_obj(fontdesc->font->t3resources);
+ pdf_keep_obj(fontdesc->font->t3resources);
if (!fontdesc->font->t3resources)
fz_warn(ctx, "no resource dictionary for type 3 font!");
@@ -130,7 +140,7 @@ pdf_load_type3_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict)
/* CharProcs */
- charprocs = fz_dict_gets(dict, "CharProcs");
+ charprocs = pdf_dict_gets(dict, "CharProcs");
if (!charprocs)
{
fz_throw(ctx, "syntaxerror: Type3 font missing CharProcs");
@@ -140,10 +150,10 @@ pdf_load_type3_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict)
{
if (estrings[i])
{
- obj = fz_dict_gets(charprocs, estrings[i]);
- if (pdf_is_stream(xref, fz_to_num(obj), fz_to_gen(obj)))
+ obj = pdf_dict_gets(charprocs, estrings[i]);
+ if (pdf_is_stream(xref, pdf_to_num(obj), pdf_to_gen(obj)))
{
- fontdesc->font->t3procs[i] = pdf_load_stream(xref, fz_to_num(obj), fz_to_gen(obj));
+ fontdesc->font->t3procs[i] = pdf_load_stream(xref, pdf_to_num(obj), pdf_to_gen(obj));
fontdesc->size += fontdesc->font->t3procs[i]->cap;
}
}
@@ -154,7 +164,7 @@ pdf_load_type3_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict)
if (fontdesc)
fz_drop_font(ctx, fontdesc->font);
fz_free(ctx, fontdesc);
- fz_throw(ctx, "cannot load type3 font (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
+ fz_throw(ctx, "cannot load type3 font (%d %d R)", pdf_to_num(dict), pdf_to_gen(dict));
}
return fontdesc;
}
diff --git a/pdf/pdf_unicode.c b/pdf/pdf_unicode.c
index d2534612..edfda708 100644
--- a/pdf/pdf_unicode.c
+++ b/pdf/pdf_unicode.c
@@ -5,7 +5,7 @@
void
pdf_load_to_unicode(pdf_document *xref, pdf_font_desc *font,
- char **strings, char *collection, fz_obj *cmapstm)
+ char **strings, char *collection, pdf_obj *cmapstm)
{
pdf_cmap *cmap;
int cid;
@@ -14,10 +14,10 @@ pdf_load_to_unicode(pdf_document *xref, pdf_font_desc *font,
int i;
fz_context *ctx = xref->ctx;
- if (pdf_is_stream(xref, fz_to_num(cmapstm), fz_to_gen(cmapstm)))
+ if (pdf_is_stream(xref, pdf_to_num(cmapstm), pdf_to_gen(cmapstm)))
{
cmap = pdf_load_embedded_cmap(xref, cmapstm);
- /* RJW: "cannot load embedded cmap (%d %d R)", fz_to_num(cmapstm), fz_to_gen(cmapstm) */
+ /* RJW: "cannot load embedded cmap (%d %d R)", pdf_to_num(cmapstm), pdf_to_gen(cmapstm) */
font->to_unicode = pdf_new_cmap(ctx);
diff --git a/pdf/pdf_xobject.c b/pdf/pdf_xobject.c
index 9f6d10ce..36c5c483 100644
--- a/pdf/pdf_xobject.c
+++ b/pdf/pdf_xobject.c
@@ -21,10 +21,10 @@ pdf_free_xobject_imp(fz_context *ctx, fz_storable *xobj_)
if (xobj->colorspace)
fz_drop_colorspace(ctx, xobj->colorspace);
if (xobj->resources)
- fz_drop_obj(xobj->resources);
+ pdf_drop_obj(xobj->resources);
if (xobj->contents)
fz_drop_buffer(ctx, xobj->contents);
- fz_drop_obj(xobj->me);
+ pdf_drop_obj(xobj->me);
fz_free(ctx, xobj);
}
@@ -37,10 +37,10 @@ pdf_xobject_size(pdf_xobject *xobj)
}
pdf_xobject *
-pdf_load_xobject(pdf_document *xref, fz_obj *dict)
+pdf_load_xobject(pdf_document *xref, pdf_obj *dict)
{
pdf_xobject *form;
- fz_obj *obj;
+ pdf_obj *obj;
fz_context *ctx = xref->ctx;
if ((form = pdf_find_item(ctx, pdf_free_xobject_imp, dict)))
@@ -58,10 +58,10 @@ pdf_load_xobject(pdf_document *xref, fz_obj *dict)
/* Store item immediately, to avoid possible recursion if objects refer back to this one */
pdf_store_item(ctx, dict, form, pdf_xobject_size(form));
- obj = fz_dict_gets(dict, "BBox");
+ obj = pdf_dict_gets(dict, "BBox");
form->bbox = pdf_to_rect(ctx, obj);
- obj = fz_dict_gets(dict, "Matrix");
+ obj = pdf_dict_gets(dict, "Matrix");
if (obj)
form->matrix = pdf_to_matrix(ctx, obj);
else
@@ -71,19 +71,19 @@ pdf_load_xobject(pdf_document *xref, fz_obj *dict)
form->knockout = 0;
form->transparency = 0;
- obj = fz_dict_gets(dict, "Group");
+ obj = pdf_dict_gets(dict, "Group");
if (obj)
{
- fz_obj *attrs = obj;
+ pdf_obj *attrs = obj;
- form->isolated = fz_to_bool(fz_dict_gets(attrs, "I"));
- form->knockout = fz_to_bool(fz_dict_gets(attrs, "K"));
+ form->isolated = pdf_to_bool(pdf_dict_gets(attrs, "I"));
+ form->knockout = pdf_to_bool(pdf_dict_gets(attrs, "K"));
- obj = fz_dict_gets(attrs, "S");
- if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "Transparency"))
+ obj = pdf_dict_gets(attrs, "S");
+ if (pdf_is_name(obj) && !strcmp(pdf_to_name(obj), "Transparency"))
form->transparency = 1;
- obj = fz_dict_gets(attrs, "CS");
+ obj = pdf_dict_gets(attrs, "CS");
if (obj)
{
form->colorspace = pdf_load_colorspace(xref, obj);
@@ -92,21 +92,21 @@ pdf_load_xobject(pdf_document *xref, fz_obj *dict)
}
}
- form->resources = fz_dict_gets(dict, "Resources");
+ form->resources = pdf_dict_gets(dict, "Resources");
if (form->resources)
- fz_keep_obj(form->resources);
+ pdf_keep_obj(form->resources);
fz_try(ctx)
{
- form->contents = pdf_load_stream(xref, fz_to_num(dict), fz_to_gen(dict));
+ form->contents = pdf_load_stream(xref, pdf_to_num(dict), pdf_to_gen(dict));
}
fz_catch(ctx)
{
pdf_remove_item(ctx, pdf_free_xobject_imp, dict);
pdf_drop_xobject(ctx, form);
- fz_throw(ctx, "cannot load xobject content stream (%d %d R)", fz_to_num(dict), fz_to_gen(dict));
+ fz_throw(ctx, "cannot load xobject content stream (%d %d R)", pdf_to_num(dict), pdf_to_gen(dict));
}
- form->me = fz_keep_obj(dict);
+ form->me = pdf_keep_obj(dict);
return form;
}
diff --git a/pdf/pdf_xref.c b/pdf/pdf_xref.c
index 383747a7..3fec0ab6 100644
--- a/pdf/pdf_xref.c
+++ b/pdf/pdf_xref.c
@@ -178,7 +178,7 @@ pdf_resize_xref(pdf_document *xref, int newlen)
xref->len = newlen;
}
-static fz_obj *
+static pdf_obj *
pdf_read_old_xref(pdf_document *xref, pdf_lexbuf *buf)
{
int ofs, len;
@@ -187,7 +187,7 @@ pdf_read_old_xref(pdf_document *xref, pdf_lexbuf *buf)
int tok;
int i;
int c;
- fz_obj *trailer;
+ pdf_obj *trailer;
fz_read_line(xref->file, buf->scratch, buf->size);
if (strncmp(buf->scratch, "xref", 4) != 0)
@@ -295,13 +295,13 @@ pdf_read_new_xref_section(pdf_document *xref, fz_stream *stm, int i0, int i1, in
/* Entered with file locked. Drops the lock in the middle, but then picks
* it up again before exiting. */
-static fz_obj *
+static pdf_obj *
pdf_read_new_xref(pdf_document *xref, pdf_lexbuf *buf)
{
fz_stream *stm = NULL;
- fz_obj *trailer = NULL;
- fz_obj *index = NULL;
- fz_obj *obj = NULL;
+ pdf_obj *trailer = NULL;
+ pdf_obj *index = NULL;
+ pdf_obj *obj = NULL;
int num, gen, stm_ofs;
int size, w0, w1, w2;
int t;
@@ -322,25 +322,25 @@ pdf_read_new_xref(pdf_document *xref, pdf_lexbuf *buf)
fz_try(ctx)
{
fz_unlock(ctx, FZ_LOCK_FILE);
- obj = fz_dict_gets(trailer, "Size");
+ obj = pdf_dict_gets(trailer, "Size");
if (!obj)
fz_throw(ctx, "xref stream missing Size entry (%d %d R)", num, gen);
- size = fz_to_int(obj);
+ size = pdf_to_int(obj);
if (size > xref->len)
pdf_resize_xref(xref, size);
if (num < 0 || num >= xref->len)
fz_throw(ctx, "object id (%d %d R) out of range (0..%d)", num, gen, xref->len - 1);
- obj = fz_dict_gets(trailer, "W");
+ obj = pdf_dict_gets(trailer, "W");
if (!obj)
fz_throw(ctx, "xref stream missing W entry (%d %d R)", num, gen);
- w0 = fz_to_int(fz_array_get(obj, 0));
- w1 = fz_to_int(fz_array_get(obj, 1));
- w2 = fz_to_int(fz_array_get(obj, 2));
+ w0 = pdf_to_int(pdf_array_get(obj, 0));
+ w1 = pdf_to_int(pdf_array_get(obj, 1));
+ w2 = pdf_to_int(pdf_array_get(obj, 2));
- index = fz_dict_gets(trailer, "Index");
+ index = pdf_dict_gets(trailer, "Index");
stm = pdf_open_stream_with_offset(xref, num, gen, trailer, stm_ofs);
/* RJW: Ensure pdf_open_stream does fz_throw(ctx, "cannot open compressed xref stream (%d %d R)", num, gen); */
@@ -352,11 +352,11 @@ pdf_read_new_xref(pdf_document *xref, pdf_lexbuf *buf)
}
else
{
- int n = fz_array_len(index);
+ int n = pdf_array_len(index);
for (t = 0; t < n; t += 2)
{
- int i0 = fz_to_int(fz_array_get(index, t + 0));
- int i1 = fz_to_int(fz_array_get(index, t + 1));
+ int i0 = pdf_to_int(pdf_array_get(index, t + 0));
+ int i1 = pdf_to_int(pdf_array_get(index, t + 1));
pdf_read_new_xref_section(xref, stm, i0, i1, w0, w1, w2);
}
}
@@ -367,8 +367,8 @@ pdf_read_new_xref(pdf_document *xref, pdf_lexbuf *buf)
}
fz_catch(ctx)
{
- fz_drop_obj(trailer);
- fz_drop_obj(index);
+ pdf_drop_obj(trailer);
+ pdf_drop_obj(index);
fz_rethrow(ctx);
}
fz_lock(ctx, FZ_LOCK_FILE);
@@ -377,12 +377,12 @@ pdf_read_new_xref(pdf_document *xref, pdf_lexbuf *buf)
}
/* File is locked on entry, and exit (but may be dropped in the middle) */
-static fz_obj *
+static pdf_obj *
pdf_read_xref(pdf_document *xref, int ofs, pdf_lexbuf *buf)
{
int c;
fz_context *ctx = xref->ctx;
- fz_obj *trailer;
+ pdf_obj *trailer;
fz_seek(xref->file, ofs, 0);
@@ -409,9 +409,9 @@ pdf_read_xref(pdf_document *xref, int ofs, pdf_lexbuf *buf)
static void
pdf_read_xref_sections(pdf_document *xref, int ofs, pdf_lexbuf *buf)
{
- fz_obj *trailer = NULL;
- fz_obj *xrefstm = NULL;
- fz_obj *prev = NULL;
+ pdf_obj *trailer = NULL;
+ pdf_obj *xrefstm = NULL;
+ pdf_obj *prev = NULL;
fz_context *ctx = xref->ctx;
fz_try(ctx)
@@ -419,21 +419,21 @@ pdf_read_xref_sections(pdf_document *xref, int ofs, pdf_lexbuf *buf)
trailer = pdf_read_xref(xref, ofs, buf);
/* FIXME: do we overwrite free entries properly? */
- xrefstm = fz_dict_gets(trailer, "XRefStm");
+ xrefstm = pdf_dict_gets(trailer, "XRefStm");
if (xrefstm)
- pdf_read_xref_sections(xref, fz_to_int(xrefstm), buf);
+ pdf_read_xref_sections(xref, pdf_to_int(xrefstm), buf);
- prev = fz_dict_gets(trailer, "Prev");
+ prev = pdf_dict_gets(trailer, "Prev");
if (prev)
- pdf_read_xref_sections(xref, fz_to_int(prev), buf);
+ pdf_read_xref_sections(xref, pdf_to_int(prev), buf);
}
fz_catch(ctx)
{
- fz_drop_obj(trailer);
+ pdf_drop_obj(trailer);
fz_throw(ctx, "cannot read xref at offset %d", ofs);
}
- fz_drop_obj(trailer);
+ pdf_drop_obj(trailer);
}
/*
@@ -443,7 +443,7 @@ pdf_read_xref_sections(pdf_document *xref, int ofs, pdf_lexbuf *buf)
static void
pdf_load_xref(pdf_document *xref, pdf_lexbuf *buf)
{
- fz_obj *size;
+ pdf_obj *size;
int i;
fz_context *ctx = xref->ctx;
@@ -453,11 +453,11 @@ pdf_load_xref(pdf_document *xref, pdf_lexbuf *buf)
pdf_read_trailer(xref, buf);
- size = fz_dict_gets(xref->trailer, "Size");
+ size = pdf_dict_gets(xref->trailer, "Size");
if (!size)
fz_throw(ctx, "trailer missing Size entry");
- pdf_resize_xref(xref, fz_to_int(size));
+ pdf_resize_xref(xref, pdf_to_int(size));
pdf_read_xref_sections(xref, xref->startxref, buf);
@@ -488,10 +488,10 @@ pdf_ocg_set_config(pdf_document *xref, int config)
{
int i, j, len, len2;
pdf_ocg_descriptor *desc = xref->ocg;
- fz_obj *obj, *cobj;
+ pdf_obj *obj, *cobj;
char *name;
- obj = fz_dict_gets(fz_dict_gets(xref->trailer, "Root"), "OCProperties");
+ obj = pdf_dict_gets(pdf_dict_gets(xref->trailer, "Root"), "OCProperties");
if (!obj)
{
if (config == 0)
@@ -501,25 +501,25 @@ pdf_ocg_set_config(pdf_document *xref, int config)
}
if (config == 0)
{
- cobj = fz_dict_gets(obj, "D");
+ cobj = pdf_dict_gets(obj, "D");
if (!cobj)
fz_throw(xref->ctx, "No default OCG config");
}
else
{
- cobj = fz_array_get(fz_dict_gets(obj, "Configs"), config);
+ cobj = pdf_array_get(pdf_dict_gets(obj, "Configs"), config);
if (!cobj)
fz_throw(xref->ctx, "Illegal OCG config");
}
if (desc->intent)
- fz_drop_obj(desc->intent);
- desc->intent = fz_dict_gets(cobj, "Intent");
+ pdf_drop_obj(desc->intent);
+ desc->intent = pdf_dict_gets(cobj, "Intent");
if (desc->intent)
- fz_keep_obj(desc->intent);
+ pdf_keep_obj(desc->intent);
len = desc->len;
- name = fz_to_name(fz_dict_gets(cobj, "BaseState"));
+ name = pdf_to_name(pdf_dict_gets(cobj, "BaseState"));
if (strcmp(name, "Unchanged") == 0)
{
/* Do nothing */
@@ -539,13 +539,13 @@ pdf_ocg_set_config(pdf_document *xref, int config)
}
}
- obj = fz_dict_gets(cobj, "ON");
- len2 = fz_array_len(obj);
+ obj = pdf_dict_gets(cobj, "ON");
+ len2 = pdf_array_len(obj);
for (i = 0; i < len2; i++)
{
- fz_obj *o = fz_array_get(obj, i);
- int n = fz_to_num(o);
- int g = fz_to_gen(o);
+ pdf_obj *o = pdf_array_get(obj, i);
+ int n = pdf_to_num(o);
+ int g = pdf_to_gen(o);
for (j=0; j < len; j++)
{
if (desc->ocgs[j].num == n && desc->ocgs[j].gen == g)
@@ -556,13 +556,13 @@ pdf_ocg_set_config(pdf_document *xref, int config)
}
}
- obj = fz_dict_gets(cobj, "OFF");
- len2 = fz_array_len(obj);
+ obj = pdf_dict_gets(cobj, "OFF");
+ len2 = pdf_array_len(obj);
for (i = 0; i < len2; i++)
{
- fz_obj *o = fz_array_get(obj, i);
- int n = fz_to_num(o);
- int g = fz_to_gen(o);
+ pdf_obj *o = pdf_array_get(obj, i);
+ int n = pdf_to_num(o);
+ int g = pdf_to_gen(o);
for (j=0; j < len; j++)
{
if (desc->ocgs[j].num == n && desc->ocgs[j].gen == g)
@@ -591,21 +591,21 @@ pdf_ocg_set_config(pdf_document *xref, int config)
static void
pdf_read_ocg(pdf_document *xref)
{
- fz_obj *obj, *ocg;
+ pdf_obj *obj, *ocg;
int len, i;
pdf_ocg_descriptor *desc;
fz_context *ctx = xref->ctx;
fz_var(desc);
- obj = fz_dict_gets(fz_dict_gets(xref->trailer, "Root"), "OCProperties");
+ obj = pdf_dict_gets(pdf_dict_gets(xref->trailer, "Root"), "OCProperties");
if (!obj)
return;
- ocg = fz_dict_gets(obj, "OCGs");
- if (!ocg || !fz_is_array(ocg))
+ ocg = pdf_dict_gets(obj, "OCGs");
+ if (!ocg || !pdf_is_array(ocg))
/* Not ever supposed to happen, but live with it. */
return;
- len = fz_array_len(ocg);
+ len = pdf_array_len(ocg);
fz_try(ctx)
{
desc = fz_calloc(ctx, 1, sizeof(*desc));
@@ -614,9 +614,9 @@ pdf_read_ocg(pdf_document *xref)
desc->intent = NULL;
for (i=0; i < len; i++)
{
- fz_obj *o = fz_array_get(ocg, i);
- desc->ocgs[i].num = fz_to_num(o);
- desc->ocgs[i].gen = fz_to_gen(o);
+ pdf_obj *o = pdf_array_get(ocg, i);
+ desc->ocgs[i].num = pdf_to_num(o);
+ desc->ocgs[i].gen = pdf_to_gen(o);
desc->ocgs[i].state = 0;
}
xref->ocg = desc;
@@ -639,7 +639,7 @@ pdf_free_ocg(fz_context *ctx, pdf_ocg_descriptor *desc)
return;
if (desc->intent)
- fz_drop_obj(desc->intent);
+ pdf_drop_obj(desc->intent);
fz_free(ctx, desc->ocgs);
fz_free(ctx, desc);
}
@@ -655,10 +655,10 @@ pdf_document *
pdf_open_document_with_stream(fz_stream *file)
{
pdf_document *xref;
- fz_obj *encrypt, *id;
- fz_obj *dict = NULL;
- fz_obj *obj;
- fz_obj *nobj = NULL;
+ pdf_obj *encrypt, *id;
+ pdf_obj *dict = NULL;
+ pdf_obj *obj;
+ pdf_obj *nobj = NULL;
int i, repaired = 0;
int locked;
fz_context *ctx = file->ctx;
@@ -667,12 +667,9 @@ pdf_open_document_with_stream(fz_stream *file)
fz_var(nobj);
fz_var(locked);
- /* install pdf specific callback */
- fz_resolve_indirect = pdf_resolve_indirect;
-
xref = fz_malloc_struct(ctx, pdf_document);
pdf_init_document(xref);
- xref->lexbuf.base.size = PDF_LEXBUF_LARGE;
+ xref->lexbuf.base.size = PDF_LEXBUF_LARGE;
xref->file = fz_keep_stream(file);
xref->ctx = ctx;
@@ -694,7 +691,7 @@ pdf_open_document_with_stream(fz_stream *file)
}
if (xref->trailer)
{
- fz_drop_obj(xref->trailer);
+ pdf_drop_obj(xref->trailer);
xref->trailer = NULL;
}
fz_warn(xref->ctx, "trying to repair broken xref");
@@ -711,9 +708,9 @@ pdf_open_document_with_stream(fz_stream *file)
fz_unlock(ctx, FZ_LOCK_FILE);
locked = 0;
- encrypt = fz_dict_gets(xref->trailer, "Encrypt");
- id = fz_dict_gets(xref->trailer, "ID");
- if (fz_is_dict(encrypt))
+ encrypt = pdf_dict_gets(xref->trailer, "Encrypt");
+ id = pdf_dict_gets(xref->trailer, "ID");
+ if (pdf_is_dict(encrypt))
xref->crypt = pdf_new_crypt(ctx, encrypt, id);
/* Allow lazy clients to read encrypted files with a blank password */
@@ -723,8 +720,8 @@ pdf_open_document_with_stream(fz_stream *file)
{
pdf_repair_obj_stms(xref);
- hasroot = (fz_dict_gets(xref->trailer, "Root") != NULL);
- hasinfo = (fz_dict_gets(xref->trailer, "Info") != NULL);
+ hasroot = (pdf_dict_gets(xref->trailer, "Root") != NULL);
+ hasinfo = (pdf_dict_gets(xref->trailer, "Info") != NULL);
for (i = 1; i < xref->len; i++)
{
@@ -743,28 +740,28 @@ pdf_open_document_with_stream(fz_stream *file)
if (!hasroot)
{
- obj = fz_dict_gets(dict, "Type");
- if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "Catalog"))
+ obj = pdf_dict_gets(dict, "Type");
+ if (pdf_is_name(obj) && !strcmp(pdf_to_name(obj), "Catalog"))
{
- nobj = fz_new_indirect(ctx, i, 0, xref);
- fz_dict_puts(xref->trailer, "Root", nobj);
- fz_drop_obj(nobj);
+ nobj = pdf_new_indirect(ctx, i, 0, xref);
+ pdf_dict_puts(xref->trailer, "Root", nobj);
+ pdf_drop_obj(nobj);
nobj = NULL;
}
}
if (!hasinfo)
{
- if (fz_dict_gets(dict, "Creator") || fz_dict_gets(dict, "Producer"))
+ if (pdf_dict_gets(dict, "Creator") || pdf_dict_gets(dict, "Producer"))
{
- nobj = fz_new_indirect(ctx, i, 0, xref);
- fz_dict_puts(xref->trailer, "Info", nobj);
- fz_drop_obj(nobj);
+ nobj = pdf_new_indirect(ctx, i, 0, xref);
+ pdf_dict_puts(xref->trailer, "Info", nobj);
+ pdf_drop_obj(nobj);
nobj = NULL;
}
}
- fz_drop_obj(dict);
+ pdf_drop_obj(dict);
dict = NULL;
}
}
@@ -776,8 +773,8 @@ pdf_open_document_with_stream(fz_stream *file)
}
fz_catch(ctx)
{
- fz_drop_obj(dict);
- fz_drop_obj(nobj);
+ pdf_drop_obj(dict);
+ pdf_drop_obj(nobj);
pdf_close_document(xref);
fz_throw(ctx, "cannot open document");
}
@@ -810,7 +807,7 @@ pdf_close_document(pdf_document *xref)
{
if (xref->table[i].obj)
{
- fz_drop_obj(xref->table[i].obj);
+ pdf_drop_obj(xref->table[i].obj);
xref->table[i].obj = NULL;
}
}
@@ -820,21 +817,21 @@ pdf_close_document(pdf_document *xref)
if (xref->page_objs)
{
for (i = 0; i < xref->page_len; i++)
- fz_drop_obj(xref->page_objs[i]);
+ pdf_drop_obj(xref->page_objs[i]);
fz_free(ctx, xref->page_objs);
}
if (xref->page_refs)
{
for (i = 0; i < xref->page_len; i++)
- fz_drop_obj(xref->page_refs[i]);
+ pdf_drop_obj(xref->page_refs[i]);
fz_free(ctx, xref->page_refs);
}
if (xref->file)
fz_close(xref->file);
if (xref->trailer)
- fz_drop_obj(xref->trailer);
+ pdf_drop_obj(xref->trailer);
if (xref->crypt)
pdf_free_crypt(ctx, xref->crypt);
@@ -868,11 +865,11 @@ static void
pdf_load_obj_stm(pdf_document *xref, int num, int gen, pdf_lexbuf *buf)
{
fz_stream *stm = NULL;
- fz_obj *objstm = NULL;
+ pdf_obj *objstm = NULL;
int *numbuf = NULL;
int *ofsbuf = NULL;
- fz_obj *obj;
+ pdf_obj *obj;
int first;
int count;
int i;
@@ -888,8 +885,8 @@ pdf_load_obj_stm(pdf_document *xref, int num, int gen, pdf_lexbuf *buf)
{
objstm = pdf_load_object(xref, num, gen);
- count = fz_to_int(fz_dict_gets(objstm, "N"));
- first = fz_to_int(fz_dict_gets(objstm, "First"));
+ count = pdf_to_int(pdf_dict_gets(objstm, "N"));
+ first = pdf_to_int(pdf_dict_gets(objstm, "First"));
numbuf = fz_calloc(ctx, count, sizeof(int));
ofsbuf = fz_calloc(ctx, count, sizeof(int));
@@ -919,19 +916,19 @@ pdf_load_obj_stm(pdf_document *xref, int num, int gen, pdf_lexbuf *buf)
if (numbuf[i] < 1 || numbuf[i] >= xref->len)
{
- fz_drop_obj(obj);
+ pdf_drop_obj(obj);
fz_throw(ctx, "object id (%d 0 R) out of range (0..%d)", numbuf[i], xref->len - 1);
}
if (xref->table[numbuf[i]].type == 'o' && xref->table[numbuf[i]].ofs == num)
{
if (xref->table[numbuf[i]].obj)
- fz_drop_obj(xref->table[numbuf[i]].obj);
+ pdf_drop_obj(xref->table[numbuf[i]].obj);
xref->table[numbuf[i]].obj = obj;
}
else
{
- fz_drop_obj(obj);
+ pdf_drop_obj(obj);
}
}
}
@@ -940,7 +937,7 @@ pdf_load_obj_stm(pdf_document *xref, int num, int gen, pdf_lexbuf *buf)
fz_close(stm);
fz_free(xref->ctx, ofsbuf);
fz_free(xref->ctx, numbuf);
- fz_drop_obj(objstm);
+ pdf_drop_obj(objstm);
}
fz_catch(ctx)
{
@@ -969,7 +966,7 @@ pdf_cache_object(pdf_document *xref, int num, int gen)
if (x->type == 'f')
{
- x->obj = fz_new_null(ctx);
+ x->obj = pdf_new_null(ctx);
return;
}
else if (x->type == 'n')
@@ -990,7 +987,7 @@ pdf_cache_object(pdf_document *xref, int num, int gen)
if (rnum != num)
{
- fz_drop_obj(x->obj);
+ pdf_drop_obj(x->obj);
x->obj = NULL;
fz_unlock(ctx, FZ_LOCK_FILE);
fz_throw(ctx, "found object (%d %d R) instead of (%d %d R)", rnum, rgen, num, gen);
@@ -1022,7 +1019,7 @@ pdf_cache_object(pdf_document *xref, int num, int gen)
}
}
-fz_obj *
+pdf_obj *
pdf_load_object(pdf_document *xref, int num, int gen)
{
fz_context *ctx = xref->ctx;
@@ -1038,11 +1035,11 @@ pdf_load_object(pdf_document *xref, int num, int gen)
assert(xref->table[num].obj);
- return fz_keep_obj(xref->table[num].obj);
+ return pdf_keep_obj(xref->table[num].obj);
}
-fz_obj *
-pdf_resolve_indirect(fz_obj *ref)
+pdf_obj *
+pdf_resolve_indirect(pdf_obj *ref)
{
int sanity = 10;
int num;
@@ -1050,16 +1047,16 @@ pdf_resolve_indirect(fz_obj *ref)
fz_context *ctx = NULL; /* Avoid warning for stupid compilers */
pdf_document *xref;
- while (fz_is_indirect(ref))
+ while (pdf_is_indirect(ref))
{
if (--sanity == 0)
fz_throw(ctx, "Too many indirections (possible indirection cycle involving %d %d R)", num, gen);
- xref = fz_get_indirect_document(ref);
+ xref = pdf_get_indirect_document(ref);
if (!xref)
return NULL;
ctx = xref->ctx;
- num = fz_to_num(ref);
- gen = fz_to_gen(ref);
+ num = pdf_to_num(ref);
+ gen = pdf_to_gen(ref);
fz_try(ctx)
{
pdf_cache_object(xref, num, gen);
@@ -1079,7 +1076,7 @@ pdf_resolve_indirect(fz_obj *ref)
/* Replace numbered object -- for use by pdfclean and similar tools */
void
-pdf_update_object(pdf_document *xref, int num, int gen, fz_obj *newobj)
+pdf_update_object(pdf_document *xref, int num, int gen, pdf_obj *newobj)
{
pdf_xref_entry *x;
@@ -1092,9 +1089,9 @@ pdf_update_object(pdf_document *xref, int num, int gen, fz_obj *newobj)
x = &xref->table[num];
if (x->obj)
- fz_drop_obj(x->obj);
+ pdf_drop_obj(x->obj);
- x->obj = fz_keep_obj(newobj);
+ x->obj = pdf_keep_obj(newobj);
x->type = 'n';
x->ofs = 0;
}
diff --git a/scripts/rename2.sed b/scripts/rename2.sed
new file mode 100644
index 00000000..152d9613
--- /dev/null
+++ b/scripts/rename2.sed
@@ -0,0 +1,75 @@
+s/fz_obj/pdf_obj/g
+s/pdf_resolve_indirect/pdf_resolve_indirect_imp/g
+s/fz_resolve_indirect/pdf_resolve_indirect/g
+s/fz_new_null/pdf_new_null/g
+s/fz_new_bool/pdf_new_bool/g
+s/fz_new_int/pdf_new_int/g
+s/fz_new_real/pdf_new_real/g
+s/fz_new_string/pdf_new_string/g
+s/fz_new_indirect/pdf_new_indirect/g
+s/fz_new_array/pdf_new_array/g
+s/fz_new_dict/pdf_new_dict/g
+s/fz_copy_array/pdf_copy_array/g
+s/fz_copy_dict/pdf_copy_dict/g
+s/fz_keep_obj/pdf_keep_obj/g
+s/fz_drop_obj/pdf_drop_obj/g
+s/fz_is_null/pdf_is_null/g
+s/fz_is_bool/pdf_is_bool/g
+s/fz_is_int/pdf_is_int/g
+s/fz_is_real/pdf_is_real/g
+s/fz_is_name/pdf_is_name/g
+s/fz_is_string/pdf_is_string/g
+s/fz_is_array/pdf_is_array/g
+s/fz_is_dict/pdf_is_dict/g
+s/fz_is_indirect/pdf_is_indirect/g
+s/fz_objcmp/pdf_objcmp/g
+s/fz_dict_marked/pdf_dict_marked/g
+s/fz_dict_mark/pdf_dict_mark/g
+s/fz_dict_unmark/pdf_dict_unmark/g
+s/fz_to_bool/pdf_to_bool/g
+s/fz_to_int/pdf_to_int/g
+s/fz_to_real/pdf_to_real/g
+s/fz_to_name/pdf_to_name/g
+s/fz_to_str_buf/pdf_to_str_buf/g
+s/fz_to_dict/pdf_to_dict/g
+s/fz_to_str_len/pdf_to_str_len/g
+s/fz_to_num/pdf_to_num/g
+s/fz_to_gen/pdf_to_gen/g
+s/fz_array_len/pdf_array_len/g
+s/fz_array_get/pdf_array_get/g
+s/fz_array_put/pdf_array_put/g
+s/fz_array_push/pdf_array_push/g
+s/fz_array_insert/pdf_array_insert/g
+s/fz_array_contains/pdf_array_contains/g
+s/fz_dict_len/pdf_dict_len/g
+s/fz_dict_get_val/pdf_dict_get_val/g
+s/fz_dict_get_key/pdf_dict_get_key/g
+s/fz_dict_get/pdf_dict_get/g
+s/fz_dict_gets/pdf_dict_gets/g
+s/fz_dict_getsa/pdf_dict_getsa/g
+s/fz_dict_put/fz_dict_put/g
+s/fz_dict_puts/pdf_dict_puts/g
+s/fz_dict_del/pdf_dict_del/g
+s/fz_dict_dels/pdf_dict_dels/g
+s/fz_sort_dict/pdf_sort_dict/g
+s/fz_fprint_obj/pdf_fprint_obj/g
+s/fz_debug_obj/pdf_debug_obj/g
+s/fz_debug_ref/pdf_debug_ref/g
+s/fz_set_str_len/pdf_set_str_len/g
+s/fz_get_indirect_document/pdf_get_indirect_document/g
+s/FZ_NULL/PDF_NULL/g
+s/FZ_BOOL/PDF_BOOL/g
+s/FZ_INT/PDF_INT/g
+s/FZ_REAL/PDF_REAL/g
+s/FZ_STRING/PDF_STRING/g
+s/FZ_NAME/PDF_NAME/g
+s/FZ_ARRAY/PDF_ARRAY/g
+s/FZ_DICT/PDF_DICT/g
+s/FZ_INDIRECT/PDF_INDIRECT/g
+s/fz_objkindstr/pdf_objkindstr/g
+s/fz_array_grow/pdf_array_grow/g
+s/fz_dict_grow/pdf_dict_grow/g
+s/fz_dict_finds/pdf_dict_finds/g
+s/fz_free_array/pdf_free_array/g
+s/fz_free_dict/pdf_free_dict/g
+s/fz_sprint_obj/pdf_sprint_obj/g