diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-09-21 00:11:22 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-09-21 00:11:22 +0200 |
commit | 69ed4a8f4dbfac7f2f1de925e34807e4fee3b27c (patch) | |
tree | b7f82296a259d360ce90f0826e475321d630a222 /apps | |
parent | 99ba154018b7c4a2c47b4c7e721ffe6d9164f9f3 (diff) | |
download | mupdf-69ed4a8f4dbfac7f2f1de925e34807e4fee3b27c.tar.xz |
Don't thread ctx through safe fz_obj functions.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/pdfapp.c | 10 | ||||
-rw-r--r-- | apps/pdfclean.c | 166 | ||||
-rw-r--r-- | apps/pdfextract.c | 28 | ||||
-rw-r--r-- | apps/pdfinfo.c | 188 | ||||
-rw-r--r-- | apps/pdfshow.c | 16 |
5 files changed, 204 insertions, 204 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c index 0e328a0a..36985010 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -145,10 +145,10 @@ static void pdfapp_open_pdf(pdfapp_t *app, char *filename, int fd) app->doctitle = strrchr(app->doctitle, '\\') + 1; if (strrchr(app->doctitle, '/')) app->doctitle = strrchr(app->doctitle, '/') + 1; - info = fz_dict_gets(app->ctx, app->xref->trailer, "Info"); + info = fz_dict_gets(app->xref->trailer, "Info"); if (info) { - obj = fz_dict_gets(app->ctx, info, "Title"); + obj = fz_dict_gets(info, "Title"); if (obj) app->doctitle = pdf_to_utf8(app->ctx, obj); } @@ -432,9 +432,9 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai static void pdfapp_gotouri(pdfapp_t *app, fz_obj *uri) { char *buf; - int n = fz_to_str_len(app->ctx, uri); + int n = fz_to_str_len(uri); buf = fz_malloc(app->ctx, n + 1); - memcpy(buf, fz_to_str_buf(app->ctx, uri), n); + memcpy(buf, fz_to_str_buf(uri), n); buf[n] = 0; winopenuri(app, buf); fz_free(app->ctx, buf); @@ -1001,7 +1001,7 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta if (link->kind == PDF_LINK_URI) pdfapp_gotouri(app, link->dest); else if (link->kind == PDF_LINK_GOTO) - pdfapp_gotopage(app, fz_array_get(app->ctx, link->dest, 0)); /* [ pageobj ... ] */ + pdfapp_gotopage(app, fz_array_get(link->dest, 0)); /* [ pageobj ... ] */ return; } } diff --git a/apps/pdfclean.c b/apps/pdfclean.c index 2a8c54f2..302970bc 100644 --- a/apps/pdfclean.c +++ b/apps/pdfclean.c @@ -61,18 +61,18 @@ static void sweepobj(fz_obj *obj) if (fz_is_indirect(obj)) sweepref(obj); - else if (fz_is_dict(ctx, obj)) + else if (fz_is_dict(obj)) { - int n = fz_dict_len(ctx, obj); + int n = fz_dict_len(obj); for (i = 0; i < n; i++) - sweepobj(fz_dict_get_val(ctx, obj, i)); + sweepobj(fz_dict_get_val(obj, i)); } - else if (fz_is_array(ctx, obj)) + else if (fz_is_array(obj)) { - int n = fz_array_len(ctx, obj); + int n = fz_array_len(obj); for (i = 0; i < n; i++) - sweepobj(fz_array_get(ctx, obj, i)); + sweepobj(fz_array_get(obj, i)); } } @@ -91,16 +91,16 @@ static void sweepref(fz_obj *obj) /* Bake in /Length in stream objects */ if (pdf_is_stream(xref, num, gen)) { - fz_obj *len = fz_dict_gets(ctx, obj, "Length"); + fz_obj *len = fz_dict_gets(obj, "Length"); if (fz_is_indirect(len)) { uselist[fz_to_num(len)] = 0; - len = fz_resolve_indirect(xref->ctx, len); - fz_dict_puts(ctx, obj, "Length", len); + len = fz_resolve_indirect(len); + fz_dict_puts(obj, "Length", len); } } - sweepobj(fz_resolve_indirect(xref->ctx, obj)); + sweepobj(fz_resolve_indirect(obj)); } /* @@ -133,8 +133,8 @@ static void removeduplicateobjs(void) a = xref->table[num].obj; b = xref->table[other].obj; - a = fz_resolve_indirect(xref->ctx, a); - b = fz_resolve_indirect(xref->ctx, b); + a = fz_resolve_indirect(a); + b = fz_resolve_indirect(b); if (fz_objcmp(a, b)) continue; @@ -185,18 +185,18 @@ static void renumberobj(fz_obj *obj) int i; fz_context *ctx = xref->ctx; - if (fz_is_dict(ctx, obj)) + if (fz_is_dict(obj)) { - int n = fz_dict_len(ctx, obj); + int n = fz_dict_len(obj); for (i = 0; i < n; i++) { - fz_obj *key = fz_dict_get_key(ctx, obj, i); - fz_obj *val = fz_dict_get_val(ctx, obj, i); + fz_obj *key = fz_dict_get_key(obj, i); + fz_obj *val = fz_dict_get_val(obj, i); if (fz_is_indirect(val)) { val = fz_new_indirect(ctx, renumbermap[fz_to_num(val)], 0, xref); - fz_dict_put(ctx, obj, key, val); - fz_drop_obj(ctx, val); + fz_dict_put(obj, key, val); + fz_drop_obj(val); } else { @@ -205,17 +205,17 @@ static void renumberobj(fz_obj *obj) } } - else if (fz_is_array(ctx, obj)) + else if (fz_is_array(obj)) { - int n = fz_array_len(ctx, obj); + int n = fz_array_len(obj); for (i = 0; i < n; i++) { - fz_obj *val = fz_array_get(ctx, obj, i); + fz_obj *val = fz_array_get(obj, i); if (fz_is_indirect(val)) { val = fz_new_indirect(ctx, renumbermap[fz_to_num(val)], 0, xref); - fz_array_put(ctx, obj, i, val); - fz_drop_obj(ctx, val); + fz_array_put(obj, i, val); + fz_drop_obj(val); } else { @@ -241,7 +241,7 @@ static void renumberobjs(void) { obj = fz_new_indirect(ctx, renumbermap[fz_to_num(obj)], 0, xref); pdf_update_object(xref, num, 0, obj); - fz_drop_obj(ctx, obj); + fz_drop_obj(obj); } else { @@ -267,7 +267,7 @@ static void renumberobjs(void) else { if (oldxref[num].obj) - fz_drop_obj(ctx, oldxref[num].obj); + fz_drop_obj(oldxref[num].obj); } } @@ -296,16 +296,16 @@ static void retainpages(int argc, char **argv) die(fz_error_note(error, "cannot load page tree")); /* Keep only pages/type entry to avoid references to unretained pages */ - oldroot = fz_dict_gets(ctx, xref->trailer, "Root"); - pages = fz_dict_gets(ctx, oldroot, "Pages"); + oldroot = fz_dict_gets(xref->trailer, "Root"); + pages = fz_dict_gets(oldroot, "Pages"); root = fz_new_dict(ctx, 2); - fz_dict_puts(ctx, root, "Type", fz_dict_gets(ctx, oldroot, "Type")); - fz_dict_puts(ctx, root, "Pages", fz_dict_gets(ctx, oldroot, "Pages")); + fz_dict_puts(root, "Type", fz_dict_gets(oldroot, "Type")); + fz_dict_puts(root, "Pages", fz_dict_gets(oldroot, "Pages")); pdf_update_object(xref, fz_to_num(oldroot), fz_to_gen(oldroot), root); - fz_drop_obj(ctx, root); + fz_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); @@ -349,10 +349,10 @@ static void retainpages(int argc, char **argv) fz_obj *pageobj = xref->page_objs[page-1]; fz_obj *pageref = xref->page_refs[page-1]; - fz_dict_puts(ctx, pageobj, "Parent", parent); + fz_dict_puts(pageobj, "Parent", parent); /* Store page object in new kids array */ - fz_array_push(ctx, kids, pageref); + fz_array_push(kids, pageref); } spec = fz_strsep(&pagelist, ","); @@ -361,14 +361,14 @@ static void retainpages(int argc, char **argv) fz_optind++; } - fz_drop_obj(ctx, parent); + fz_drop_obj(parent); /* Update page count and kids array */ - countobj = fz_new_int(ctx, fz_array_len(ctx, kids)); - fz_dict_puts(ctx, pages, "Count", countobj); - fz_drop_obj(ctx, countobj); - fz_dict_puts(ctx, pages, "Kids", kids); - fz_drop_obj(ctx, kids); + 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); } /* @@ -388,7 +388,7 @@ static void preloadobjstms(void) error = pdf_load_object(&obj, xref, num, 0); if (error) die(error); - fz_drop_obj(ctx, obj); + fz_drop_obj(obj); } } } @@ -448,42 +448,42 @@ static void addhexfilter(fz_obj *dict) nullobj = fz_new_null(ctx); newf = newdp = NULL; - f = fz_dict_gets(ctx, dict, "Filter"); - dp = fz_dict_gets(ctx, dict, "DecodeParms"); + f = fz_dict_gets(dict, "Filter"); + dp = fz_dict_gets(dict, "DecodeParms"); - if (fz_is_name(ctx, f)) + if (fz_is_name(f)) { newf = fz_new_array(ctx, 2); - fz_array_push(ctx, newf, ahx); - fz_array_push(ctx, newf, f); + fz_array_push(newf, ahx); + fz_array_push(newf, f); f = newf; - if (fz_is_dict(ctx, dp)) + if (fz_is_dict(dp)) { newdp = fz_new_array(ctx, 2); - fz_array_push(ctx, newdp, nullobj); - fz_array_push(ctx, newdp, dp); + fz_array_push(newdp, nullobj); + fz_array_push(newdp, dp); dp = newdp; } } - else if (fz_is_array(ctx, f)) + else if (fz_is_array(f)) { - fz_array_insert(ctx, f, ahx); - if (fz_is_array(ctx, dp)) - fz_array_insert(ctx, dp, nullobj); + fz_array_insert(f, ahx); + if (fz_is_array(dp)) + fz_array_insert(dp, nullobj); } else f = ahx; - fz_dict_puts(ctx, dict, "Filter", f); + fz_dict_puts(dict, "Filter", f); if (dp) - fz_dict_puts(ctx, dict, "DecodeParms", dp); + fz_dict_puts(dict, "DecodeParms", dp); - fz_drop_obj(ctx, ahx); - fz_drop_obj(ctx, nullobj); + fz_drop_obj(ahx); + fz_drop_obj(nullobj); if (newf) - fz_drop_obj(ctx, newf); + fz_drop_obj(newf); if (newdp) - fz_drop_obj(ctx, newdp); + fz_drop_obj(newdp); } static void copystream(fz_obj *obj, int num, int gen) @@ -505,12 +505,12 @@ static void copystream(fz_obj *obj, int num, int gen) addhexfilter(obj); newlen = fz_new_int(ctx, buf->len); - fz_dict_puts(ctx, obj, "Length", newlen); - fz_drop_obj(ctx, newlen); + fz_dict_puts(obj, "Length", newlen); + fz_drop_obj(newlen); } fprintf(out, "%d %d obj\n", num, gen); - fz_fprint_obj(ctx, out, obj, !doexpand); + fz_fprint_obj(out, obj, !doexpand); fprintf(out, "stream\n"); fwrite(buf->data, 1, buf->len, out); fprintf(out, "endstream\nendobj\n\n"); @@ -528,8 +528,8 @@ static void expandstream(fz_obj *obj, int num, int gen) if (error) die(error); - fz_dict_dels(ctx, obj, "Filter"); - fz_dict_dels(ctx, obj, "DecodeParms"); + fz_dict_dels(obj, "Filter"); + fz_dict_dels(obj, "DecodeParms"); if (doascii && isbinarystream(buf)) { @@ -541,11 +541,11 @@ static void expandstream(fz_obj *obj, int num, int gen) } newlen = fz_new_int(ctx, buf->len); - fz_dict_puts(ctx, obj, "Length", newlen); - fz_drop_obj(ctx, newlen); + fz_dict_puts(obj, "Length", newlen); + fz_drop_obj(newlen); fprintf(out, "%d %d obj\n", num, gen); - fz_fprint_obj(ctx, out, obj, !doexpand); + fz_fprint_obj(out, obj, !doexpand); fprintf(out, "stream\n"); fwrite(buf->data, 1, buf->len, out); fprintf(out, "endstream\nendobj\n\n"); @@ -564,19 +564,19 @@ static void writeobject(int num, int gen) die(error); /* skip ObjStm and XRef objects */ - if (fz_is_dict(ctx, obj)) + if (fz_is_dict(obj)) { - type = fz_dict_gets(ctx, obj, "Type"); - if (fz_is_name(ctx, type) && !strcmp(fz_to_name(ctx, type), "ObjStm")) + type = fz_dict_gets(obj, "Type"); + if (fz_is_name(type) && !strcmp(fz_to_name(type), "ObjStm")) { uselist[num] = 0; - fz_drop_obj(ctx, obj); + fz_drop_obj(obj); return; } - if (fz_is_name(ctx, type) && !strcmp(fz_to_name(ctx, type), "XRef")) + if (fz_is_name(type) && !strcmp(fz_to_name(type), "XRef")) { uselist[num] = 0; - fz_drop_obj(ctx, obj); + fz_drop_obj(obj); return; } } @@ -584,7 +584,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(ctx, out, obj, !doexpand); + fz_fprint_obj(out, obj, !doexpand); fprintf(out, "endobj\n\n"); } else @@ -595,7 +595,7 @@ static void writeobject(int num, int gen) copystream(obj, num, gen); } - fz_drop_obj(ctx, obj); + fz_drop_obj(obj); } static void writexref(void) @@ -620,26 +620,26 @@ static void writexref(void) trailer = fz_new_dict(ctx, 5); obj = fz_new_int(ctx, xref->len); - fz_dict_puts(ctx, trailer, "Size", obj); - fz_drop_obj(ctx, obj); + fz_dict_puts(trailer, "Size", obj); + fz_drop_obj(obj); - obj = fz_dict_gets(ctx, xref->trailer, "Info"); + obj = fz_dict_gets(xref->trailer, "Info"); if (obj) - fz_dict_puts(ctx, trailer, "Info", obj); + fz_dict_puts(trailer, "Info", obj); - obj = fz_dict_gets(ctx, xref->trailer, "Root"); + obj = fz_dict_gets(xref->trailer, "Root"); if (obj) - fz_dict_puts(ctx, trailer, "Root", obj); + fz_dict_puts(trailer, "Root", obj); - obj = fz_dict_gets(ctx, xref->trailer, "ID"); + obj = fz_dict_gets(xref->trailer, "ID"); if (obj) - fz_dict_puts(ctx, trailer, "ID", obj); + fz_dict_puts(trailer, "ID", obj); fprintf(out, "trailer\n"); - fz_fprint_obj(ctx, out, trailer, !doexpand); + fz_fprint_obj(out, trailer, !doexpand); fprintf(out, "\n"); - fz_drop_obj(ctx, trailer); + fz_drop_obj(trailer); fprintf(out, "startxref\n%d\n%%%%EOF\n", startxref); } diff --git a/apps/pdfextract.c b/apps/pdfextract.c index 96ea7e87..490a8c1e 100644 --- a/apps/pdfextract.c +++ b/apps/pdfextract.c @@ -27,14 +27,14 @@ static void usage(void) static int isimage(fz_obj *obj) { - fz_obj *type = fz_dict_gets(ctx, obj, "Subtype"); - return fz_is_name(ctx, type) && !strcmp(fz_to_name(ctx, type), "Image"); + fz_obj *type = fz_dict_gets(obj, "Subtype"); + return fz_is_name(type) && !strcmp(fz_to_name(type), "Image"); } static int isfontdesc(fz_obj *obj) { - fz_obj *type = fz_dict_gets(ctx, obj, "Type"); - return fz_is_name(ctx, type) && !strcmp(fz_to_name(ctx, type), "FontDescriptor"); + fz_obj *type = fz_dict_gets(obj, "Type"); + return fz_is_name(type) && !strcmp(fz_to_name(type), "FontDescriptor"); } static void saveimage(int num) @@ -75,7 +75,7 @@ static void saveimage(int num) } fz_drop_pixmap(ctx, img); - fz_drop_obj(ctx, ref); + fz_drop_obj(ref); } static void savefont(fz_obj *dict, int num) @@ -91,34 +91,34 @@ static void savefont(fz_obj *dict, int num) char *fontname = "font"; int n; - obj = fz_dict_gets(ctx, dict, "FontName"); + obj = fz_dict_gets(dict, "FontName"); if (obj) - fontname = fz_to_name(ctx, obj); + fontname = fz_to_name(obj); - obj = fz_dict_gets(ctx, dict, "FontFile"); + obj = fz_dict_gets(dict, "FontFile"); if (obj) { stream = obj; ext = "pfa"; } - obj = fz_dict_gets(ctx, dict, "FontFile2"); + obj = fz_dict_gets(dict, "FontFile2"); if (obj) { stream = obj; ext = "ttf"; } - obj = fz_dict_gets(ctx, dict, "FontFile3"); + obj = fz_dict_gets(dict, "FontFile3"); if (obj) { stream = obj; - obj = fz_dict_gets(ctx, obj, "Subtype"); - if (obj && !fz_is_name(ctx, obj)) + obj = fz_dict_gets(obj, "Subtype"); + if (obj && !fz_is_name(obj)) die(fz_error_make("Invalid font descriptor subtype")); - subtype = fz_to_name(ctx, obj); + subtype = fz_to_name(obj); if (!strcmp(subtype, "Type1C")) ext = "cff"; else if (!strcmp(subtype, "CIDFontType0C")) @@ -173,7 +173,7 @@ static void showobject(int num) else if (isfontdesc(obj)) savefont(obj, num); - fz_drop_obj(ctx, obj); + fz_drop_obj(obj); } int main(int argc, char **argv) diff --git a/apps/pdfinfo.c b/apps/pdfinfo.c index 2006b0be..cf81105c 100644 --- a/apps/pdfinfo.c +++ b/apps/pdfinfo.c @@ -185,18 +185,18 @@ showglobalinfo(void) printf("\nPDF-%d.%d\n", xref->version / 10, xref->version % 10); - obj = fz_dict_gets(ctx, xref->trailer, "Info"); + obj = fz_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(ctx, fz_resolve_indirect(xref->ctx, obj)); + fz_debug_obj(fz_resolve_indirect(obj)); } - obj = fz_dict_gets(ctx, xref->trailer, "Encrypt"); + obj = fz_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(ctx, fz_resolve_indirect(xref->ctx, obj)); + fz_debug_obj(fz_resolve_indirect(obj)); } printf("\nPages: %d\n\n", pagecount); @@ -209,8 +209,8 @@ gatherdimensions(int page, fz_obj *pageref, fz_obj *pageobj) fz_obj *obj; int j; - obj = fz_dict_gets(ctx, pageobj, "MediaBox"); - if (!fz_is_array(ctx, obj)) + obj = fz_dict_gets(pageobj, "MediaBox"); + if (!fz_is_array(obj)) return; bbox = pdf_to_rect(ctx, obj); @@ -239,7 +239,7 @@ gatherfonts(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) { int i, n; - n = fz_dict_len(ctx, dict); + n = fz_dict_len(dict); for (i = 0; i < n; i++) { fz_obj *fontdict = NULL; @@ -248,17 +248,17 @@ gatherfonts(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) fz_obj *name = NULL; int k; - fontdict = fz_dict_get_val(ctx, dict, i); - if (!fz_is_dict(ctx, fontdict)) + fontdict = fz_dict_get_val(dict, i); + if (!fz_is_dict(fontdict)) { fz_warn("not a font dict (%d %d R)", fz_to_num(fontdict), fz_to_gen(fontdict)); continue; } - subtype = fz_dict_gets(ctx, fontdict, "Subtype"); - basefont = fz_dict_gets(ctx, fontdict, "BaseFont"); - if (!basefont || fz_is_null(ctx, basefont)) - name = fz_dict_gets(ctx, fontdict, "Name"); + subtype = fz_dict_gets(fontdict, "Subtype"); + basefont = fz_dict_gets(fontdict, "BaseFont"); + if (!basefont || fz_is_null(basefont)) + name = fz_dict_gets(fontdict, "Name"); for (k = 0; k < fonts; k++) if (!fz_objcmp(font[k].u.font.obj, fontdict)) @@ -284,7 +284,7 @@ gatherimages(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) { int i, n; - n = fz_dict_len(ctx, dict); + n = fz_dict_len(dict); for (i = 0; i < n; i++) { fz_obj *imagedict; @@ -297,37 +297,37 @@ gatherimages(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) fz_obj *altcs; int k; - imagedict = fz_dict_get_val(ctx, dict, i); - if (!fz_is_dict(ctx, imagedict)) + imagedict = fz_dict_get_val(dict, i); + if (!fz_is_dict(imagedict)) { fz_warn("not an image dict (%d %d R)", fz_to_num(imagedict), fz_to_gen(imagedict)); continue; } - type = fz_dict_gets(ctx, imagedict, "Subtype"); - if (strcmp(fz_to_name(ctx, type), "Image")) + type = fz_dict_gets(imagedict, "Subtype"); + if (strcmp(fz_to_name(type), "Image")) continue; - filter = fz_dict_gets(ctx, imagedict, "Filter"); + filter = fz_dict_gets(imagedict, "Filter"); altcs = NULL; - cs = fz_dict_gets(ctx, imagedict, "ColorSpace"); - if (fz_is_array(ctx, cs)) + cs = fz_dict_gets(imagedict, "ColorSpace"); + if (fz_is_array(cs)) { fz_obj *cses = cs; - cs = fz_array_get(ctx, cses, 0); - if (fz_is_name(ctx, cs) && (!strcmp(fz_to_name(ctx, cs), "DeviceN") || !strcmp(fz_to_name(ctx, cs), "Separation"))) + cs = fz_array_get(cses, 0); + if (fz_is_name(cs) && (!strcmp(fz_to_name(cs), "DeviceN") || !strcmp(fz_to_name(cs), "Separation"))) { - altcs = fz_array_get(ctx, cses, 2); - if (fz_is_array(ctx, altcs)) - altcs = fz_array_get(ctx, altcs, 0); + altcs = fz_array_get(cses, 2); + if (fz_is_array(altcs)) + altcs = fz_array_get(altcs, 0); } } - width = fz_dict_gets(ctx, imagedict, "Width"); - height = fz_dict_gets(ctx, imagedict, "Height"); - bpc = fz_dict_gets(ctx, imagedict, "BitsPerComponent"); + width = fz_dict_gets(imagedict, "Width"); + height = fz_dict_gets(imagedict, "Height"); + bpc = fz_dict_gets(imagedict, "BitsPerComponent"); for (k = 0; k < images; k++) if (!fz_objcmp(image[k].u.image.obj, imagedict)) @@ -357,7 +357,7 @@ gatherforms(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) { int i, n; - n = fz_dict_len(ctx, dict); + n = fz_dict_len(dict); for (i = 0; i < n; i++) { fz_obj *xobjdict; @@ -368,24 +368,24 @@ gatherforms(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) fz_obj *reference; int k; - xobjdict = fz_dict_get_val(ctx, dict, i); - if (!fz_is_dict(ctx, xobjdict)) + xobjdict = fz_dict_get_val(dict, i); + if (!fz_is_dict(xobjdict)) { fz_warn("not a xobject dict (%d %d R)", fz_to_num(xobjdict), fz_to_gen(xobjdict)); continue; } - type = fz_dict_gets(ctx, xobjdict, "Subtype"); - if (strcmp(fz_to_name(ctx, type), "Form")) + type = fz_dict_gets(xobjdict, "Subtype"); + if (strcmp(fz_to_name(type), "Form")) continue; - subtype = fz_dict_gets(ctx, xobjdict, "Subtype2"); - if (!strcmp(fz_to_name(ctx, subtype), "PS")) + subtype = fz_dict_gets(xobjdict, "Subtype2"); + if (!strcmp(fz_to_name(subtype), "PS")) continue; - group = fz_dict_gets(ctx, xobjdict, "Group"); - groupsubtype = fz_dict_gets(ctx, group, "S"); - reference = fz_dict_gets(ctx, xobjdict, "Ref"); + group = fz_dict_gets(xobjdict, "Group"); + groupsubtype = fz_dict_gets(group, "S"); + reference = fz_dict_gets(xobjdict, "Ref"); for (k = 0; k < forms; k++) if (!fz_objcmp(form[k].u.form.obj, xobjdict)) @@ -411,7 +411,7 @@ gatherpsobjs(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) { int i, n; - n = fz_dict_len(ctx, dict); + n = fz_dict_len(dict); for (i = 0; i < n; i++) { fz_obj *xobjdict; @@ -419,17 +419,17 @@ gatherpsobjs(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) fz_obj *subtype; int k; - xobjdict = fz_dict_get_val(ctx, dict, i); - if (!fz_is_dict(ctx, xobjdict)) + xobjdict = fz_dict_get_val(dict, i); + if (!fz_is_dict(xobjdict)) { fz_warn("not a xobject dict (%d %d R)", fz_to_num(xobjdict), fz_to_gen(xobjdict)); continue; } - type = fz_dict_gets(ctx, xobjdict, "Subtype"); - subtype = fz_dict_gets(ctx, xobjdict, "Subtype2"); - if (strcmp(fz_to_name(ctx, type), "PS") && - (strcmp(fz_to_name(ctx, type), "Form") || strcmp(fz_to_name(ctx, subtype), "PS"))) + 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"))) continue; for (k = 0; k < psobjs; k++) @@ -454,22 +454,22 @@ gathershadings(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) { int i, n; - n = fz_dict_len(ctx, dict); + n = fz_dict_len(dict); for (i = 0; i < n; i++) { fz_obj *shade; fz_obj *type; int k; - shade = fz_dict_get_val(ctx, dict, i); - if (!fz_is_dict(ctx, shade)) + shade = fz_dict_get_val(dict, i); + if (!fz_is_dict(shade)) { fz_warn("not a shading dict (%d %d R)", fz_to_num(shade), fz_to_gen(shade)); continue; } - type = fz_dict_gets(ctx, shade, "ShadingType"); - if (!fz_is_int(ctx, type) || fz_to_int(ctx, type) < 1 || fz_to_int(ctx, type) > 7) + type = fz_dict_gets(shade, "ShadingType"); + if (!fz_is_int(type) || fz_to_int(type) < 1 || fz_to_int(type) > 7) { fz_warn("not a shading type (%d %d R)", fz_to_num(shade), fz_to_gen(shade)); type = NULL; @@ -498,7 +498,7 @@ gatherpatterns(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) { int i, n; - n = fz_dict_len(ctx, dict); + n = fz_dict_len(dict); for (i = 0; i < n; i++) { fz_obj *patterndict; @@ -508,31 +508,31 @@ gatherpatterns(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) fz_obj *shading = NULL; int k; - patterndict = fz_dict_get_val(ctx, dict, i); - if (!fz_is_dict(ctx, patterndict)) + patterndict = fz_dict_get_val(dict, i); + if (!fz_is_dict(patterndict)) { fz_warn("not a pattern dict (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict)); continue; } - type = fz_dict_gets(ctx, patterndict, "PatternType"); - if (!fz_is_int(ctx, type) || fz_to_int(ctx, type) < 1 || fz_to_int(ctx, type) > 2) + type = fz_dict_gets(patterndict, "PatternType"); + if (!fz_is_int(type) || fz_to_int(type) < 1 || fz_to_int(type) > 2) { fz_warn("not a pattern type (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict)); type = NULL; } - if (fz_to_int(ctx, type) == 1) + if (fz_to_int(type) == 1) { - paint = fz_dict_gets(ctx, patterndict, "PaintType"); - if (!fz_is_int(ctx, paint) || fz_to_int(ctx, paint) < 1 || fz_to_int(ctx, paint) > 2) + paint = fz_dict_gets(patterndict, "PaintType"); + if (!fz_is_int(paint) || fz_to_int(paint) < 1 || fz_to_int(paint) > 2) { fz_warn("not a pattern paint type (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict)); paint = NULL; } - tiling = fz_dict_gets(ctx, patterndict, "TilingType"); - if (!fz_is_int(ctx, tiling) || fz_to_int(ctx, tiling) < 1 || fz_to_int(ctx, tiling) > 3) + tiling = fz_dict_gets(patterndict, "TilingType"); + if (!fz_is_int(tiling) || fz_to_int(tiling) < 1 || fz_to_int(tiling) > 3) { fz_warn("not a pattern tiling type (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict)); tiling = NULL; @@ -540,7 +540,7 @@ gatherpatterns(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) } else { - shading = fz_dict_gets(ctx, patterndict, "Shading"); + shading = fz_dict_gets(patterndict, "Shading"); } for (k = 0; k < patterns; k++) @@ -582,24 +582,24 @@ gatherresourceinfo(int page, fz_obj *rsrc) if (!pageobj) die(fz_error_make("cannot retrieve info from page %d", page)); - font = fz_dict_gets(ctx, rsrc, "Font"); + font = fz_dict_gets(rsrc, "Font"); if (font) { int n; gatherfonts(page, pageref, pageobj, font); - n = fz_dict_len(ctx, font); + n = fz_dict_len(font); for (i = 0; i < n; i++) { - fz_obj *obj = fz_dict_get_val(ctx, font, i); + fz_obj *obj = fz_dict_get_val(font, i); - subrsrc = fz_dict_gets(ctx, obj, "Resources"); + subrsrc = fz_dict_gets(obj, "Resources"); if (subrsrc && fz_objcmp(rsrc, subrsrc)) gatherresourceinfo(page, subrsrc); } } - xobj = fz_dict_gets(ctx, rsrc, "XObject"); + xobj = fz_dict_gets(rsrc, "XObject"); if (xobj) { int n; @@ -607,30 +607,30 @@ 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(ctx, xobj); + n = fz_dict_len(xobj); for (i = 0; i < n; i++) { - fz_obj *obj = fz_dict_get_val(ctx, xobj, i); - subrsrc = fz_dict_gets(ctx, obj, "Resources"); + fz_obj *obj = fz_dict_get_val(xobj, i); + subrsrc = fz_dict_gets(obj, "Resources"); if (subrsrc && fz_objcmp(rsrc, subrsrc)) gatherresourceinfo(page, subrsrc); } } - shade = fz_dict_gets(ctx, rsrc, "Shading"); + shade = fz_dict_gets(rsrc, "Shading"); if (shade) gathershadings(page, pageref, pageobj, shade); - pattern = fz_dict_gets(ctx, rsrc, "Pattern"); + pattern = fz_dict_gets(rsrc, "Pattern"); if (pattern) { int n; gatherpatterns(page, pageref, pageobj, pattern); - n = fz_dict_len(ctx, pattern); + n = fz_dict_len(pattern); for (i = 0; i < n; i++) { - fz_obj *obj = fz_dict_get_val(ctx, pattern, i); - subrsrc = fz_dict_gets(ctx, obj, "Resources"); + fz_obj *obj = fz_dict_get_val(pattern, i); + subrsrc = fz_dict_gets(obj, "Resources"); if (subrsrc && fz_objcmp(rsrc, subrsrc)) gatherresourceinfo(page, subrsrc); } @@ -652,7 +652,7 @@ gatherpageinfo(int page) gatherdimensions(page, pageref, pageobj); - rsrc = fz_dict_gets(ctx, pageobj, "Resources"); + rsrc = fz_dict_gets(pageobj, "Resources"); gatherresourceinfo(page, rsrc); } @@ -688,8 +688,8 @@ 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(ctx, font[i].u.font.subtype), - fz_to_name(ctx, font[i].u.font.name), + 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)); } printf("\n"); @@ -707,27 +707,27 @@ printinfo(char *filename, int show, int page) image[i].page, fz_to_num(image[i].pageref), fz_to_gen(image[i].pageref)); - if (fz_is_array(ctx, image[i].u.image.filter)) + if (fz_is_array(image[i].u.image.filter)) { - int n = fz_array_len(ctx, image[i].u.image.filter); + int n = fz_array_len(image[i].u.image.filter); for (j = 0; j < n; j++) { - fz_obj *obj = fz_array_get(ctx, image[i].u.image.filter, j); - char *filter = fz_strdup(ctx, fz_to_name(ctx, obj)); + fz_obj *obj = fz_array_get(image[i].u.image.filter, j); + char *filter = fz_strdup(ctx, fz_to_name(obj)); if (strstr(filter, "Decode")) *(strstr(filter, "Decode")) = '\0'; printf("%s%s", filter, - j == fz_array_len(ctx, image[i].u.image.filter) - 1 ? "" : " "); + j == fz_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(ctx, obj)); + char *filter = fz_strdup(ctx, fz_to_name(obj)); if (strstr(filter, "Decode")) *(strstr(filter, "Decode")) = '\0'; @@ -740,7 +740,7 @@ printinfo(char *filename, int show, int page) if (image[i].u.image.cs) { - cs = fz_strdup(ctx, fz_to_name(ctx, image[i].u.image.cs)); + cs = fz_strdup(ctx, fz_to_name(image[i].u.image.cs)); if (!strncmp(cs, "Device", 6)) { @@ -759,7 +759,7 @@ printinfo(char *filename, int show, int page) } if (image[i].u.image.altcs) { - altcs = fz_strdup(ctx, fz_to_name(ctx, image[i].u.image.altcs)); + altcs = fz_strdup(ctx, fz_to_name(image[i].u.image.altcs)); if (!strncmp(altcs, "Device", 6)) { @@ -778,9 +778,9 @@ printinfo(char *filename, int show, int page) } printf(" ] %dx%d %dbpc %s%s%s (%d %d R)\n", - fz_to_int(ctx, image[i].u.image.width), - fz_to_int(ctx, image[i].u.image.height), - image[i].u.image.bpc ? fz_to_int(ctx, image[i].u.image.bpc) : 1, + 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, image[i].u.image.cs ? cs : "ImageMask", image[i].u.image.altcs ? " " : "", image[i].u.image.altcs ? altcs : "", @@ -812,7 +812,7 @@ 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(ctx, shading[i].u.shading.type)], + 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)); } printf("\n"); @@ -823,7 +823,7 @@ printinfo(char *filename, int show, int page) printf("Patterns (%d):\n", patterns); for (i = 0; i < patterns; i++) { - if (fz_to_int(ctx, pattern[i].u.pattern.type) == 1) + if (fz_to_int(pattern[i].u.pattern.type) == 1) { char *painttype[] = { @@ -842,8 +842,8 @@ 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(ctx, pattern[i].u.pattern.paint)], - tilingtype[fz_to_int(ctx, pattern[i].u.pattern.tiling)], + 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)); } else @@ -867,7 +867,7 @@ printinfo(char *filename, int show, int page) form[i].page, fz_to_num(form[i].pageref), fz_to_gen(form[i].pageref), form[i].u.form.groupsubtype ? " " : "", - form[i].u.form.groupsubtype ? fz_to_name(ctx, form[i].u.form.groupsubtype) : "", + form[i].u.form.groupsubtype ? fz_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)); diff --git a/apps/pdfshow.c b/apps/pdfshow.c index 653ffff6..0fd49010 100644 --- a/apps/pdfshow.c +++ b/apps/pdfshow.c @@ -33,7 +33,7 @@ static void showtrailer(void) if (!xref) die(fz_error_make("no file specified")); printf("trailer\n"); - fz_debug_obj(ctx, xref->trailer); + fz_debug_obj(xref->trailer); printf("\n"); } @@ -147,7 +147,7 @@ static void showobject(int num, int gen) else { printf("%d %d obj\n", num, gen); - fz_debug_obj(ctx, obj); + fz_debug_obj(obj); printf("stream\n"); showstream(num, gen); printf("endstream\n"); @@ -157,11 +157,11 @@ static void showobject(int num, int gen) else { printf("%d %d obj\n", num, gen); - fz_debug_obj(ctx, obj); + fz_debug_obj(obj); printf("endobj\n\n"); } - fz_drop_obj(ctx, obj); + fz_drop_obj(obj); } static void showgrep(char *filename) @@ -178,17 +178,17 @@ static void showgrep(char *filename) if (error) die(error); - fz_sort_dict(ctx, obj); + fz_sort_dict(obj); printf("%s:%d: ", filename, i); - fz_fprint_obj(ctx, stdout, obj, 1); + fz_fprint_obj(stdout, obj, 1); - fz_drop_obj(ctx, obj); + fz_drop_obj(obj); } } printf("%s:trailer: ", filename); - fz_fprint_obj(ctx, stdout, xref->trailer, 1); + fz_fprint_obj(stdout, xref->trailer, 1); } int main(int argc, char **argv) |