summaryrefslogtreecommitdiff
path: root/src/document.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2018-02-03 23:04:49 +0000
committerVincent Sanders <vince@kyllikki.org>2018-02-03 23:04:49 +0000
commiteeb93199c64db0c47dc73bb1b5a3c7d16d8172e2 (patch)
tree34aca0598b291654dd1823965cb813d927d34e11 /src/document.c
parente6af9e997df381f053f3f8c85a678ad07677c791 (diff)
downloadlibnspdf-eeb93199c64db0c47dc73bb1b5a3c7d16d8172e2.tar.gz
libnspdf-eeb93199c64db0c47dc73bb1b5a3c7d16d8172e2.tar.bz2
make value extraction the same interface as getting
Diffstat (limited to 'src/document.c')
-rw-r--r--src/document.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/document.c b/src/document.c
index dcf8395..bd3d314 100644
--- a/src/document.c
+++ b/src/document.c
@@ -240,7 +240,7 @@ decode_xref_trailer(struct nspdf_doc *doc, unsigned int xref_offset)
goto decode_xref_trailer_failed;
}
- res = cos_extract_dictionary_value(trailer, "Root", &doc->root);
+ res = cos_extract_dictionary_value(NULL, trailer, "Root", &doc->root);
if (res != NSPDFERROR_OK) {
printf("no Root!\n");
goto decode_xref_trailer_failed;
@@ -251,17 +251,17 @@ decode_xref_trailer(struct nspdf_doc *doc, unsigned int xref_offset)
goto decode_xref_trailer_failed;
}
- res = cos_extract_dictionary_value(trailer, "Encrypt", &doc->encrypt);
+ res = cos_extract_dictionary_value(NULL, trailer, "Encrypt", &doc->encrypt);
if ((res != NSPDFERROR_OK) && (res != NSPDFERROR_NOTFOUND)) {
goto decode_xref_trailer_failed;
}
- res = cos_extract_dictionary_value(trailer, "Info", &doc->info);
+ res = cos_extract_dictionary_value(NULL, trailer, "Info", &doc->info);
if ((res != NSPDFERROR_OK) && (res != NSPDFERROR_NOTFOUND)) {
goto decode_xref_trailer_failed;
}
- res = cos_extract_dictionary_value(trailer, "ID", &doc->id);
+ res = cos_extract_dictionary_value(NULL, trailer, "ID", &doc->id);
if ((res != NSPDFERROR_OK) && (res != NSPDFERROR_NOTFOUND)) {
goto decode_xref_trailer_failed;
}
@@ -353,7 +353,7 @@ static nspdferror decode_catalog(struct nspdf_doc *doc)
return res;
}
- // Type = Catalog
+ /* Type = Catalog */
res = cos_get_dictionary_name(doc, catalog, "Type", &type);
if (res != NSPDFERROR_OK) {
return res;
@@ -362,7 +362,13 @@ static nspdferror decode_catalog(struct nspdf_doc *doc)
return NSPDFERROR_FORMAT;
}
- // Pages
+ /* Pages */
+
+ /** todo this should get the dictionary Pages object and check it is an
+ * indirect reference (spec says it *must* be) then below has the reference
+ * to free in xref table
+ */
+
res = cos_get_dictionary_dictionary(doc, catalog, "Pages", &pages);
if (res != NSPDFERROR_OK) {
return res;
@@ -373,6 +379,10 @@ static nspdferror decode_catalog(struct nspdf_doc *doc)
return res;
}
+ /** \todo need to free referenced object when page resources tree is copied
+ * instead of being owned by the reference. Right now we leak like a seive
+ */
+
return res;
}