From b030c24ba11fc78dd4165c97e66316c8e09705d5 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Mon, 10 May 2021 21:01:02 -0400 Subject: [PATCH] Add pdfioObjGetArray. --- pdfio-object.c | 20 ++++++++++++++++++++ pdfio.h | 1 + 2 files changed, 21 insertions(+) diff --git a/pdfio-object.c b/pdfio-object.c index 2027313..57efde7 100644 --- a/pdfio-object.c +++ b/pdfio-object.c @@ -60,6 +60,26 @@ _pdfioObjDelete(pdfio_obj_t *obj) // I - Object } +// +// 'pdfioObjGetArray()' - Get the array associated with an object. +// + +pdfio_array_t * // O - Array or `NULL` on error +pdfioObjGetArray(pdfio_obj_t *obj) // I - Object +{ + if (!obj) + return (NULL); + + if (obj->value.type == PDFIO_VALTYPE_NONE) + _pdfioObjLoad(obj); + + if (obj->value.type == PDFIO_VALTYPE_ARRAY) + return (obj->value.value.array); + else + return (NULL); +} + + // // 'pdfioObjGetDict()' - Get the dictionary associated with an object. // diff --git a/pdfio.h b/pdfio.h index 53084a4..d17888a 100644 --- a/pdfio.h +++ b/pdfio.h @@ -162,6 +162,7 @@ extern pdfio_file_t *pdfioFileOpen(const char *filename, pdfio_error_cb_t error_ extern bool pdfioObjClose(pdfio_obj_t *obj) PDFIO_PUBLIC; extern pdfio_stream_t *pdfioObjCreateStream(pdfio_obj_t *obj, pdfio_filter_t compression) PDFIO_PUBLIC; +extern pdfio_array_t *pdfioObjGetArray(pdfio_obj_t *obj) PDFIO_PUBLIC; extern pdfio_dict_t *pdfioObjGetDict(pdfio_obj_t *obj) PDFIO_PUBLIC; extern unsigned short pdfioObjGetGeneration(pdfio_obj_t *obj) PDFIO_PUBLIC; extern size_t pdfioObjGetLength(pdfio_obj_t *obj) PDFIO_PUBLIC;