summaryrefslogtreecommitdiff
path: root/source/tools/pdfshow.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2015-01-21 16:42:45 +0100
committerTor Andersson <tor.andersson@artifex.com>2015-02-17 18:05:39 +0100
commitf84a189d5f94250e46d2cbd1a75aba00130e2dd6 (patch)
tree8ee614ab90de1baa8941f91ae4946ed5c2e70721 /source/tools/pdfshow.c
parent681039767f2ccc72e236246178893eb0989169c9 (diff)
downloadmupdf-f84a189d5f94250e46d2cbd1a75aba00130e2dd6.tar.xz
Add ctx parameter and remove embedded contexts for API regularity.
Purge several embedded contexts: Remove embedded context in fz_output. Remove embedded context in fz_stream. Remove embedded context in fz_device. Remove fz_rebind_stream (since it is no longer necessary). Remove embedded context in svg_device. Remove embedded context in XML parser. Add ctx argument to fz_document functions. Remove embedded context in fz_document. Remove embedded context in pdf_document. Remove embedded context in pdf_obj. Make fz_page independent of fz_document in the interface. We shouldn't need to pass the document to all functions handling a page. If a page is tied to the source document, it's redundant; otherwise it's just pointless. Fix reference counting oddity in fz_new_image_from_pixmap.
Diffstat (limited to 'source/tools/pdfshow.c')
-rw-r--r--source/tools/pdfshow.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/source/tools/pdfshow.c b/source/tools/pdfshow.c
index 344f4c40..d084c080 100644
--- a/source/tools/pdfshow.c
+++ b/source/tools/pdfshow.c
@@ -27,7 +27,7 @@ static void showtrailer(void)
if (!doc)
fz_throw(ctx, FZ_ERROR_GENERIC, "no file specified");
fprintf(out, "trailer\n");
- pdf_fprint_obj(out, pdf_trailer(doc), 0);
+ pdf_fprint_obj(ctx, out, pdf_trailer(ctx, doc), 0);
fprintf(out, "\n");
}
@@ -37,11 +37,11 @@ static void showencrypt(void)
if (!doc)
fz_throw(ctx, FZ_ERROR_GENERIC, "no file specified");
- encrypt = pdf_dict_gets(pdf_trailer(doc), "Encrypt");
+ encrypt = pdf_dict_gets(ctx, pdf_trailer(ctx, doc), "Encrypt");
if (!encrypt)
fz_throw(ctx, FZ_ERROR_GENERIC, "document not encrypted");
fprintf(out, "encryption dictionary\n");
- pdf_fprint_obj(out, pdf_resolve_indirect(encrypt), 0);
+ pdf_fprint_obj(ctx, out, pdf_resolve_indirect(ctx, encrypt), 0);
fprintf(out, "\n");
}
@@ -49,7 +49,7 @@ static void showxref(void)
{
if (!doc)
fz_throw(ctx, FZ_ERROR_GENERIC, "no file specified");
- pdf_print_xref(doc);
+ pdf_print_xref(ctx, doc);
fprintf(out, "\n");
}
@@ -62,11 +62,11 @@ static void showpagetree(void)
if (!doc)
fz_throw(ctx, FZ_ERROR_GENERIC, "no file specified");
- count = pdf_count_pages(doc);
+ count = pdf_count_pages(ctx, doc);
for (i = 0; i < count; i++)
{
- ref = pdf_lookup_page_obj(doc, i);
- fprintf(out, "page %d = %d %d R\n", i + 1, pdf_to_num(ref), pdf_to_gen(ref));
+ ref = pdf_lookup_page_obj(ctx, doc, i);
+ fprintf(out, "page %d = %d %d R\n", i + 1, pdf_to_num(ctx, ref), pdf_to_gen(ctx, ref));
}
fprintf(out, "\n");
}
@@ -103,13 +103,13 @@ static void showstream(int num, int gen)
showcolumn = 0;
if (showdecode)
- stm = pdf_open_stream(doc, num, gen);
+ stm = pdf_open_stream(ctx, doc, num, gen);
else
- stm = pdf_open_raw_stream(doc, num, gen);
+ stm = pdf_open_raw_stream(ctx, doc, num, gen);
while (1)
{
- n = fz_read(stm, buf, sizeof buf);
+ n = fz_read(ctx, stm, buf, sizeof buf);
if (n == 0)
break;
if (showbinary)
@@ -118,7 +118,7 @@ static void showstream(int num, int gen)
showsafe(buf, n);
}
- fz_drop_stream(stm);
+ fz_drop_stream(ctx, stm);
}
static void showobject(int num, int gen)
@@ -128,9 +128,9 @@ static void showobject(int num, int gen)
if (!doc)
fz_throw(ctx, FZ_ERROR_GENERIC, "no file specified");
- obj = pdf_load_object(doc, num, gen);
+ obj = pdf_load_object(ctx, doc, num, gen);
- if (pdf_is_stream(doc, num, gen))
+ if (pdf_is_stream(ctx, doc, num, gen))
{
if (showbinary)
{
@@ -139,7 +139,7 @@ static void showobject(int num, int gen)
else
{
fprintf(out, "%d %d obj\n", num, gen);
- pdf_fprint_obj(out, obj, 0);
+ pdf_fprint_obj(ctx, out, obj, 0);
fprintf(out, "stream\n");
showstream(num, gen);
fprintf(out, "endstream\n");
@@ -149,11 +149,11 @@ static void showobject(int num, int gen)
else
{
fprintf(out, "%d %d obj\n", num, gen);
- pdf_fprint_obj(out, obj, 0);
+ pdf_fprint_obj(ctx, out, obj, 0);
fprintf(out, "endobj\n\n");
}
- pdf_drop_obj(obj);
+ pdf_drop_obj(ctx, obj);
}
static void showgrep(char *filename)
@@ -161,15 +161,15 @@ static void showgrep(char *filename)
pdf_obj *obj;
int i, len;
- len = pdf_count_objects(doc);
+ len = pdf_count_objects(ctx, doc);
for (i = 0; i < len; i++)
{
- pdf_xref_entry *entry = pdf_get_xref_entry(doc, i);
+ pdf_xref_entry *entry = pdf_get_xref_entry(ctx, doc, i);
if (entry->type == 'n' || entry->type == 'o')
{
fz_try(ctx)
{
- obj = pdf_load_object(doc, i, 0);
+ obj = pdf_load_object(ctx, doc, i, 0);
}
fz_catch(ctx)
{
@@ -177,17 +177,17 @@ static void showgrep(char *filename)
continue;
}
- pdf_sort_dict(obj);
+ pdf_sort_dict(ctx, obj);
fprintf(out, "%s:%d: ", filename, i);
- pdf_fprint_obj(out, obj, 1);
+ pdf_fprint_obj(ctx, out, obj, 1);
- pdf_drop_obj(obj);
+ pdf_drop_obj(ctx, obj);
}
}
fprintf(out, "%s:trailer: ", filename);
- pdf_fprint_obj(out, pdf_trailer(doc), 1);
+ pdf_fprint_obj(ctx, out, pdf_trailer(ctx, doc), 1);
}
int pdfshow_main(int argc, char **argv)
@@ -236,8 +236,8 @@ int pdfshow_main(int argc, char **argv)
fz_try(ctx)
{
doc = pdf_open_document_no_run(ctx, filename);
- if (pdf_needs_password(doc))
- if (!pdf_authenticate_password(doc, password))
+ if (pdf_needs_password(ctx, doc))
+ if (!pdf_authenticate_password(ctx, doc, password))
fz_warn(ctx, "cannot authenticate password: %s", filename);
if (fz_optind == argc)
@@ -264,7 +264,7 @@ int pdfshow_main(int argc, char **argv)
if (out != stdout)
fclose(out);
- pdf_close_document(doc);
+ pdf_close_document(ctx, doc);
fz_drop_context(ctx);
return 0;
}