summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-object.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-01-29 17:16:41 +0100
committerTor Andersson <tor.andersson@artifex.com>2018-01-31 12:09:42 +0100
commit87e2b6e20f5824d09097c9dfb2c5b1b5cddb1194 (patch)
tree232d5b528254c585332a904ef0df886dd0896f2c /source/pdf/pdf-object.c
parent99b07a5bc43bd20493c249314aa7f1ef3f38665d (diff)
downloadmupdf-87e2b6e20f5824d09097c9dfb2c5b1b5cddb1194.tar.xz
Add pdf_debug_obj function to quickly print objects from gdb command line.
Diffstat (limited to 'source/pdf/pdf-object.c')
-rw-r--r--source/pdf/pdf-object.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c
index 3d694d0c..056d6a73 100644
--- a/source/pdf/pdf-object.c
+++ b/source/pdf/pdf-object.c
@@ -2151,6 +2151,33 @@ int pdf_print_obj(fz_context *ctx, fz_output *out, pdf_obj *obj, int tight)
return pdf_print_encrypted_obj(ctx, out, obj, tight, NULL, 0, 0);
}
+static int pdf_debug_encrypted_obj(fz_context *ctx, pdf_obj *obj, int tight, pdf_crypt *crypt, int num, int gen)
+{
+ char buf[1024];
+ char *ptr;
+ int n;
+
+ n = pdf_sprint_obj(ctx, NULL, 0, obj, tight);
+ if ((n + 1) < sizeof buf)
+ {
+ pdf_sprint_encrypted_obj(ctx, buf, sizeof buf, obj, tight, crypt, num, gen);
+ fwrite(buf, 1, n, stdout);
+ }
+ else
+ {
+ ptr = fz_malloc(ctx, n + 1);
+ pdf_sprint_encrypted_obj(ctx, ptr, n + 1, obj, tight, crypt, num, gen);
+ fwrite(ptr, 1, n, stdout);
+ fz_free(ctx, ptr);
+ }
+ return n;
+}
+
+void pdf_debug_obj(fz_context *ctx, pdf_obj *obj)
+{
+ pdf_debug_encrypted_obj(ctx, obj, 0, NULL, 0, 0);
+}
+
int pdf_obj_refs(fz_context *ctx, pdf_obj *ref)
{
return (ref >= PDF_OBJ__LIMIT ? ref->refs : 0);