diff options
Diffstat (limited to 'apps/pdfclean.c')
-rw-r--r-- | apps/pdfclean.c | 166 |
1 files changed, 83 insertions, 83 deletions
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); } |