summaryrefslogtreecommitdiff
path: root/test/pdfdebug.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/pdfdebug.c')
-rw-r--r--test/pdfdebug.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/test/pdfdebug.c b/test/pdfdebug.c
index ddc10dff..1009849f 100644
--- a/test/pdfdebug.c
+++ b/test/pdfdebug.c
@@ -5,10 +5,11 @@ static char *password = "";
static int dodecode = 0;
static int dorepair = 0;
static int doprintxref = 0;
+static int dosave = 0;
void usage()
{
- fprintf(stderr, "usage: pdfdebug [-drx] [-u password] file.pdf [oid ...]\n");
+ fprintf(stderr, "usage: pdfdebug [-drxs] [-u password] file.pdf [oid ...]\n");
exit(1);
}
@@ -43,9 +44,13 @@ void printsafe(unsigned char *buf, int n)
void decodestream(pdf_xref *xref, fz_obj *stream, int oid, int gid, int ofs)
{
+ FILE *copy;
fz_error *error;
unsigned char buf[512];
+ if (dosave)
+ copy = fopen("/tmp/dump.stm", "wb");
+
safecol = 0;
error = pdf_openstream0(xref, stream, oid, gid, ofs);
@@ -59,8 +64,14 @@ void decodestream(pdf_xref *xref, fz_obj *stream, int oid, int gid, int ofs)
if (n < 0)
fz_abort(fz_ferror(xref->file));
printsafe(buf, n);
+
+ if (dosave)
+ fwrite(buf, 1, n, copy);
}
+ if (dosave)
+ fclose(copy);
+
pdf_closestream(xref);
}
@@ -133,10 +144,13 @@ int main(int argc, char **argv)
pdf_xref *xref;
int c;
- while ((c = getopt(argc, argv, "drxopu:")) != -1)
+ while ((c = getopt(argc, argv, "drxsopu:")) != -1)
{
switch (c)
{
+ case 's':
+ dodecode ++;
+ dosave ++;
case 'd':
dodecode ++;
break;