diff options
author | Sebastian Rasmussen <sebras@hotmail.com> | 2010-07-15 10:27:03 +0000 |
---|---|---|
committer | Sebastian Rasmussen <sebras@hotmail.com> | 2010-07-15 10:27:03 +0000 |
commit | 76ee87db8f10c111ef73b7460a011386114e4f3e (patch) | |
tree | 27196c71e478df3dc9f61bef95665db30d2b705c /apps | |
parent | 3a3fb509e4aa097227ce6e1f73ffd18fce98db29 (diff) | |
download | mupdf-76ee87db8f10c111ef73b7460a011386114e4f3e.tar.xz |
Combine info gathering and printing in pdfinfo.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/pdfinfo.c | 72 |
1 files changed, 19 insertions, 53 deletions
diff --git a/apps/pdfinfo.c b/apps/pdfinfo.c index 49b156ec..8ac9295c 100644 --- a/apps/pdfinfo.c +++ b/apps/pdfinfo.c @@ -63,8 +63,6 @@ struct info } u; }; -static struct info *info = nil; -static struct info *cryptinfo = nil; static struct info **dim = nil; static int dims = 0; static struct info **font = nil; @@ -84,12 +82,6 @@ static void local_cleanup(void) { int i; - if (info) - { - free(info); - info = nil; - } - if (dim) { for (i = 0; i < dims; i++) @@ -169,29 +161,27 @@ infousage(void) } static void -gatherglobalinfo(void) +showglobalinfo(void) { - info = fz_malloc(sizeof (struct info)); - - info->page = -1; - info->pageobj = nil; - info->u.info.obj = nil; + fz_obj *obj; - info->u.info.obj = fz_dictgets(xref->trailer, "Info"); - if (!fz_isindirect(info->u.info.obj)) - die(fz_throw("not an indirect info object")); + printf("\nPDF-%d.%d\n", xref->version / 10, xref->version % 10); - cryptinfo = fz_malloc(sizeof (struct info)); + obj = fz_dictgets(xref->trailer, "Info"); + if (obj) + { + printf("Info object (%d %d R):\n", fz_tonum(obj), fz_togen(obj)); + fz_debugobj(fz_resolveindirect(obj)); + } - cryptinfo->page = -1; - cryptinfo->pageobj = nil; - cryptinfo->u.crypt.obj = nil; + obj = fz_dictgets(xref->trailer, "Encrypt"); + if (obj) + { + printf("\nEncryption object (%d %d R):\n", fz_tonum(obj), fz_togen(obj)); + fz_debugobj(fz_resolveindirect(obj)); + } - cryptinfo->u.info.obj = fz_dictgets(xref->trailer, "Encrypt"); - if (cryptinfo->u.info.obj && - !fz_isdict(cryptinfo->u.info.obj) && - !fz_isindirect(cryptinfo->u.info.obj)) - die(fz_throw("not an indirect crypt object")); + printf("\nPages: %d\n\n", pagecount); } static fz_error @@ -611,6 +601,7 @@ gatherinfo(int show, int page) { fz_error error; fz_obj *pageobj; + fz_obj *pageref; fz_obj *rsrc; fz_obj *font; fz_obj *xobj; @@ -618,6 +609,7 @@ gatherinfo(int show, int page) fz_obj *pattern; pageobj = pdf_getpageobject(xref, page); + pageref = pdf_getpageref(xref, page); if (!pageobj) die(fz_throw("cannot retrieve info from page %d", page)); @@ -683,26 +675,6 @@ gatherinfo(int show, int page) } static void -printglobalinfo(void) -{ - printf("\nPDF-%d.%d\n", xref->version / 10, xref->version % 10); - - if (info->u.info.obj) - { - printf("Info object (%d %d R):\n", fz_tonum(info->u.info.obj), fz_togen(info->u.info.obj)); - fz_debugobj(info->u.info.obj); - } - - if (cryptinfo->u.crypt.obj) - { - printf("\nEncryption object (%d %d R):\n", fz_tonum(cryptinfo->u.info.obj), fz_togen(cryptinfo->u.info.obj)); - fz_debugobj(cryptinfo->u.crypt.obj); - } - - printf("\nPages: %d\n\n", pagecount); -} - -static void printinfo(char *filename, int show, int page) { int i; @@ -1011,7 +983,6 @@ int main(int argc, char **argv) { if (state == NO_INFO_GATHERED) { - printglobalinfo(); showinfo(filename, show, "1-"); closexref(); } @@ -1020,13 +991,11 @@ int main(int argc, char **argv) filename = argv[fz_optind]; printf("%s:\n", filename); openxref(filename, password, 0, 1); - gatherglobalinfo(); + showglobalinfo(); state = NO_INFO_GATHERED; } else { - if (state == NO_INFO_GATHERED) - printglobalinfo(); showinfo(filename, show, argv[fz_optind]); state = INFO_SHOWN; } @@ -1035,10 +1004,7 @@ int main(int argc, char **argv) } if (state == NO_INFO_GATHERED) - { - printglobalinfo(); showinfo(filename, show, "1-"); - } closexref(); |