diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-06-30 15:21:56 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-07-06 13:34:37 +0200 |
commit | 255776a778b519183d6935ff0cb4b766644fa830 (patch) | |
tree | 16c2d411870b31cc25a2941d90ca862c10083667 /source/tools/pdfshow.c | |
parent | b644ed1360d0e47c03a637bbc568000d57d0cdbf (diff) | |
download | mupdf-255776a778b519183d6935ff0cb4b766644fa830.tar.xz |
pdf: Drop generation number from public interfaces.
The generation number is only needed for decryption, and is assumed
to be zero or irrelevant for all other uses.
Store the original object number and generation in the xref slot, so
that we can decrypt them even when the objects have been renumbered,
without needing to pass the original object number around through
the stream loading APIs.
Diffstat (limited to 'source/tools/pdfshow.c')
-rw-r--r-- | source/tools/pdfshow.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/source/tools/pdfshow.c b/source/tools/pdfshow.c index d56cbcd6..3ff479a5 100644 --- a/source/tools/pdfshow.c +++ b/source/tools/pdfshow.c @@ -65,7 +65,7 @@ static void showpagetree(void) for (i = 0; i < count; i++) { ref = pdf_lookup_page_obj(ctx, doc, i); - fz_printf(ctx, out, "page %d = %d %d R\n", i + 1, pdf_to_num(ctx, ref), pdf_to_gen(ctx, ref)); + fz_printf(ctx, out, "page %d = %d 0 R\n", i + 1, pdf_to_num(ctx, ref)); } fz_printf(ctx, out, "\n"); } @@ -93,7 +93,7 @@ static void showsafe(unsigned char *buf, size_t n) } } -static void showstream(int num, int gen) +static void showstream(int num) { fz_stream *stm; unsigned char buf[2048]; @@ -102,9 +102,9 @@ static void showstream(int num, int gen) showcolumn = 0; if (showdecode) - stm = pdf_open_stream(ctx, doc, num, gen); + stm = pdf_open_stream(ctx, doc, num); else - stm = pdf_open_raw_stream(ctx, doc, num, gen); + stm = pdf_open_raw_stream(ctx, doc, num); while (1) { @@ -120,34 +120,34 @@ static void showstream(int num, int gen) fz_drop_stream(ctx, stm); } -static void showobject(int num, int gen) +static void showobject(int num) { pdf_obj *obj; if (!doc) fz_throw(ctx, FZ_ERROR_GENERIC, "no file specified"); - obj = pdf_load_object(ctx, doc, num, gen); + obj = pdf_load_object(ctx, doc, num); if (pdf_is_stream(ctx, obj)) { if (showbinary) { - showstream(num, gen); + showstream(num); } else { - fz_printf(ctx, out, "%d %d obj\n", num, gen); + fz_printf(ctx, out, "%d 0 obj\n", num); pdf_print_obj(ctx, out, obj, 0); fz_printf(ctx, out, "\nstream\n"); - showstream(num, gen); + showstream(num); fz_printf(ctx, out, "endstream\n"); fz_printf(ctx, out, "endobj\n\n"); } } else { - fz_printf(ctx, out, "%d %d obj\n", num, gen); + fz_printf(ctx, out, "%d 0 obj\n", num); pdf_print_obj(ctx, out, obj, 0); fz_printf(ctx, out, "\nendobj\n\n"); } @@ -168,7 +168,7 @@ static void showgrep(char *filename) { fz_try(ctx) { - obj = pdf_load_object(ctx, doc, i, 0); + obj = pdf_load_object(ctx, doc, i); } fz_catch(ctx) { @@ -268,7 +268,7 @@ int pdfshow_main(int argc, char **argv) case 'p': showpagetree(); break; case 'g': showgrep(filename); break; case 'o': showoutline(); break; - default: showobject(atoi(argv[fz_optind]), 0); break; + default: showobject(atoi(argv[fz_optind])); break; } fz_optind++; } |