summaryrefslogtreecommitdiff
path: root/apps/pdfshow.c
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@hotmail.com>2009-07-05 12:01:17 +0200
committerSebastian Rasmussen <sebras@hotmail.com>2009-07-05 12:01:17 +0200
commit4ebd84900f7f5d0afda14e09c518e614d9fde60d (patch)
tree8db9f1086d0edcf313178b66f878466f9f0d2409 /apps/pdfshow.c
parente7dfbee9389406555bf48ed5118f3c486129a7b6 (diff)
downloadmupdf-4ebd84900f7f5d0afda14e09c518e614d9fde60d.tar.xz
Refactor xref opening and closing to a common file for all pdf tools.
Diffstat (limited to 'apps/pdfshow.c')
-rw-r--r--apps/pdfshow.c60
1 files changed, 2 insertions, 58 deletions
diff --git a/apps/pdfshow.c b/apps/pdfshow.c
index 44d50774..164daca0 100644
--- a/apps/pdfshow.c
+++ b/apps/pdfshow.c
@@ -2,63 +2,7 @@
* pdfshow -- the ultimate pdf debugging tool
*/
-#include "fitz.h"
-#include "mupdf.h"
-
-pdf_xref *xref = NULL;
-
-void die(fz_error eo)
-{
- fz_catch(eo, "aborting");
- exit(1);
-}
-
-void openxref(char *filename, char *password)
-{
- fz_error error;
- fz_obj *obj;
-
- error = pdf_newxref(&xref);
- if (error)
- die(error);
-
- error = pdf_loadxref(xref, filename);
- if (error)
- {
- fz_catch(error, "trying to repair");
- error = pdf_repairxref(xref, filename);
- if (error)
- die(error);
- }
-
- error = pdf_decryptxref(xref);
- if (error)
- die(error);
-
- if (xref->crypt)
- {
- int okay = pdf_setpassword(xref->crypt, password);
- if (!okay)
- fz_warn("invalid password, attempting to continue.");
- }
-
- /* TODO: move into mupdf lib, see pdfapp_open in pdfapp.c */
- obj = fz_dictgets(xref->trailer, "Root");
- xref->root = fz_resolveindirect(obj);
- if (xref->root)
- fz_keepobj(xref->root);
-
- obj = fz_dictgets(xref->trailer, "Info");
- xref->info = fz_resolveindirect(obj);
- if (xref->info)
- fz_keepobj(xref->info);
-}
-
-void closexref()
-{
- pdf_closexref(xref);
- xref = nil;
-}
+#include "pdftool.h"
int showbinary = 0;
int showdecode = 0;
@@ -197,7 +141,7 @@ int main(int argc, char **argv)
if (fz_optind == argc)
showusage();
- openxref(argv[fz_optind++], password);
+ openxref(argv[fz_optind++], password, 0);
if (fz_optind == argc)
showtrailer();