summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/pdfdebug.c18
-rw-r--r--apps/samshow.c27
2 files changed, 24 insertions, 21 deletions
diff --git a/apps/pdfdebug.c b/apps/pdfdebug.c
index bb2d57e2..1ae84d7c 100644
--- a/apps/pdfdebug.c
+++ b/apps/pdfdebug.c
@@ -43,47 +43,49 @@ void printsafe(unsigned char *buf, int n)
void decodestream(pdf_xref *xref, int oid, int gid)
{
fz_error *error;
+ fz_stream *stm;
unsigned char buf[512];
safecol = 0;
- error = pdf_openstream(xref, oid, gid);
+ error = pdf_openstream(&stm, xref, oid, gid);
if (error) fz_abort(error);
while (1)
{
- int n = fz_read(xref->stream, buf, sizeof buf);
+ int n = fz_read(stm, buf, sizeof buf);
if (n == 0)
break;
if (n < 0)
- fz_abort(fz_ferror(xref->stream));
+ fz_abort(fz_throw("ioerror: read failed"));
printsafe(buf, n);
}
- pdf_closestream(xref);
+ fz_dropstream(stm);
}
void copystream(pdf_xref *xref, int oid, int gid)
{
fz_error *error;
+ fz_stream *stm;
unsigned char buf[512];
safecol = 0;
- error = pdf_openrawstream(xref, oid, gid);
+ error = pdf_openrawstream(&stm, xref, oid, gid);
if (error) fz_abort(error);
while (1)
{
- int n = fz_read(xref->stream, buf, sizeof buf);
+ int n = fz_read(stm, buf, sizeof buf);
if (n == 0)
break;
if (n < 0)
- fz_abort(fz_ferror(xref->stream));
+ fz_abort(fz_throw("ioerror: read failed"));
printsafe(buf, n);
}
- pdf_closestream(xref);
+ fz_dropstream(stm);
}
void printobject(pdf_xref *xref, int oid, int gid)
diff --git a/apps/samshow.c b/apps/samshow.c
index d84799a0..aa4030cc 100644
--- a/apps/samshow.c
+++ b/apps/samshow.c
@@ -5,8 +5,9 @@ int runzip(int argc, char **argv)
{
fz_error *error;
fz_buffer *buf;
+ fz_stream *stm;
sa_zip *zip;
- int i;
+ int i, n;
error = sa_openzip(&zip, argv[1]);
if (error)
@@ -17,13 +18,13 @@ int runzip(int argc, char **argv)
for (i = 2; i < argc; i++)
{
- error = sa_openzipentry(zip, argv[i]);
+ error = sa_openzipentry(&stm, zip, argv[i]);
if (error)
fz_abort(error);
- error = fz_readfile(&buf, zip->file);
- if (error)
- fz_abort(error);
- sa_closezipentry(zip);
+ n = fz_readall(&buf, stm);
+ if (n < 0)
+ fz_abort(fz_throw("ioerror: readall failed"));
+ fz_dropstream(stm);
fwrite(buf->rp, 1, buf->wp - buf->rp, stdout);
@@ -38,11 +39,11 @@ int runzip(int argc, char **argv)
int runxml(int argc, char **argv)
{
fz_error *error;
- fz_file *file;
+ fz_stream *file;
sa_xmlparser *parser;
sa_xmlitem *item;
- error = fz_openfile(&file, argv[1], FZ_READ);
+ error = fz_openrfile(&file, argv[1]);
if (error)
fz_abort(error);
@@ -55,19 +56,19 @@ int runxml(int argc, char **argv)
sa_debugxml(item, 0);
sa_closexml(parser);
- fz_closefile(file);
+ fz_dropstream(file);
return 0;
}
-extern fz_error *sa_readtiff(fz_file *);
+extern fz_error *sa_readtiff(fz_stream *);
int runtiff(int argc, char **argv)
{
fz_error *error;
- fz_file *file;
+ fz_stream *file;
- error = fz_openfile(&file, argv[1], FZ_READ);
+ error = fz_openrfile(&file, argv[1]);
if (error)
fz_abort(error);
@@ -75,7 +76,7 @@ int runtiff(int argc, char **argv)
if (error)
fz_abort(error);
- fz_closefile(file);
+ fz_dropstream(file);
return 0;
}