summaryrefslogtreecommitdiff
path: root/src/cos_object.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2018-01-18 00:21:10 +0000
committerVincent Sanders <vince@kyllikki.org>2018-01-18 00:21:10 +0000
commitb1e0e4414ecd3161c0f947daceb8643b5889e51c (patch)
treeab63f66b3651856f3528bb51e9acf522d0854521 /src/cos_object.c
parentc27eb52f96f8070c4be77a387e603508fc4092ce (diff)
downloadlibnspdf-b1e0e4414ecd3161c0f947daceb8643b5889e51c.tar.gz
libnspdf-b1e0e4414ecd3161c0f947daceb8643b5889e51c.tar.bz2
start to alter parseing to read from cos_stream object
Diffstat (limited to 'src/cos_object.c')
-rw-r--r--src/cos_object.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/cos_object.c b/src/cos_object.c
index 3dc5efa..4398822 100644
--- a/src/cos_object.c
+++ b/src/cos_object.c
@@ -17,6 +17,7 @@
#include <nspdf/errors.h>
#include "cos_object.h"
+#include "cos_parse.h"
#include "pdf_doc.h"
@@ -369,6 +370,54 @@ cos_get_stream(struct nspdf_doc *doc,
/*
+ * get object from object reference
+ */
+nspdferror
+cos_get_object(struct nspdf_doc *doc,
+ struct cos_object *cobj,
+ struct cos_object **value_out)
+{
+ nspdferror res;
+ res = nspdf__xref_get_referenced(doc, &cobj);
+ if (res == NSPDFERROR_OK) {
+ *value_out = cobj;
+ }
+ return res;
+}
+
+
+nspdferror
+cos_get_content(struct nspdf_doc *doc,
+ struct cos_object *cobj,
+ struct cos_content **content_out)
+{
+ nspdferror res;
+ struct cos_object *content_obj;
+
+ res = nspdf__xref_get_referenced(doc, &cobj);
+ if (res == NSPDFERROR_OK) {
+ if (cobj->type == COS_TYPE_STREAM) {
+ res = cos_parse_content_stream(doc, cobj->u.stream, &content_obj);
+ if (res == NSPDFERROR_OK) {
+ /* replace stream object with parsed content operations */
+ struct cos_object tmpobj;
+ tmpobj = *cobj;
+ *cobj = *content_obj;
+ *content_obj = tmpobj;
+ cos_free_object(content_obj);
+
+ *content_out = cobj->u.content;
+ }
+ } else if (cobj->type == COS_TYPE_CONTENT) {
+ *content_out = cobj->u.content;
+ } else {
+ res = NSPDFERROR_TYPE;
+ }
+ }
+ return res;
+}
+
+/*
* get a value for a key from a dictionary
*/
nspdferror