summaryrefslogtreecommitdiff
path: root/apps/pdfshow.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2012-01-19 00:58:09 +0100
committerTor Andersson <tor.andersson@artifex.com>2012-01-19 17:48:49 +0100
commit75b6425fe9ce8136dbc852415471708d365b4d25 (patch)
tree3d5533b150d5eb5fd3fe8efa8b667512a44edef7 /apps/pdfshow.c
parent08e84b18e5c1dbe8f3d32dd0aeb4b4c43debce9f (diff)
downloadmupdf-75b6425fe9ce8136dbc852415471708d365b4d25.tar.xz
Remove confusing optional 'password' argument to pdf_open_xref.
Require that clients call pdf_needs_password/pdf_authenticate_password instead. For dumb clients, we still allow for decrypting a file with a blank password without calling those functions.
Diffstat (limited to 'apps/pdfshow.c')
-rw-r--r--apps/pdfshow.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/apps/pdfshow.c b/apps/pdfshow.c
index a84e962b..2fbfdc2f 100644
--- a/apps/pdfshow.c
+++ b/apps/pdfshow.c
@@ -205,26 +205,35 @@ int main(int argc, char **argv)
exit(1);
}
- xref = pdf_open_xref(ctx, filename, password);
+ fz_var(xref);
+ fz_try(ctx)
+ {
+ xref = pdf_open_xref(ctx, filename);
+ if (pdf_needs_password(xref))
+ if (!pdf_authenticate_password(xref, password))
+ fz_throw(ctx, "cannot authenticate password: %s", filename);
- if (fz_optind == argc)
- showtrailer();
+ if (fz_optind == argc)
+ showtrailer();
- while (fz_optind < argc)
- {
- switch (argv[fz_optind][0])
+ while (fz_optind < argc)
{
- case 't': showtrailer(); break;
- case 'x': showxref(); break;
- case 'p': showpagetree(); break;
- case 'g': showgrep(filename); break;
- default: showobject(atoi(argv[fz_optind]), 0); break;
+ switch (argv[fz_optind][0])
+ {
+ case 't': showtrailer(); break;
+ case 'x': showxref(); break;
+ case 'p': showpagetree(); break;
+ case 'g': showgrep(filename); break;
+ default: showobject(atoi(argv[fz_optind]), 0); break;
+ }
+ fz_optind++;
}
- fz_optind++;
+ }
+ fz_catch(ctx)
+ {
}
pdf_free_xref(xref);
- fz_flush_warnings(ctx);
fz_free_context(ctx);
return 0;
}