diff options
author | Vincent Sanders <vince@kyllikki.org> | 2017-12-21 23:49:13 +0000 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2017-12-21 23:49:13 +0000 |
commit | 897a8900bf77db2d804b0f78bc4b41371e05347f (patch) | |
tree | 31dfd1c54ceaef746bfb867a4657b7cdcc3d5c61 /src/cos_object.h | |
parent | b22daf7d9b39210a0c7f8b5522a884a828b656b0 (diff) | |
download | libnspdf-897a8900bf77db2d804b0f78bc4b41371e05347f.tar.gz libnspdf-897a8900bf77db2d804b0f78bc4b41371e05347f.tar.bz2 |
split code up a bit
Diffstat (limited to 'src/cos_object.h')
-rw-r--r-- | src/cos_object.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/cos_object.h b/src/cos_object.h new file mode 100644 index 0000000..65b3ed5 --- /dev/null +++ b/src/cos_object.h @@ -0,0 +1,98 @@ +struct pdf_doc; + +enum cos_type { + COS_TYPE_NULL, + COS_TYPE_BOOL, + COS_TYPE_INT, + COS_TYPE_REAL, + COS_TYPE_NAME, + COS_TYPE_STRING, + COS_TYPE_ARRAY, + COS_TYPE_DICTIONARY, + COS_TYPE_NAMETREE, + COS_TYPE_NUMBERTREE, + COS_TYPE_STREAM, + COS_TYPE_REFERENCE, +}; + +struct cos_object; + +struct cos_dictionary_entry { + /** next key/value in dictionary */ + struct cos_dictionary_entry *next; + + /** key (name) */ + struct cos_object *key; + + /** value */ + struct cos_object *value; +}; + +struct cos_array_entry { + /** next value in array */ + struct cos_array_entry *next; + + /** value */ + struct cos_object *value; +}; + +struct cos_string { + uint8_t *data; + size_t length; + size_t alloc; +}; + +struct cos_reference { + /** id of indirect object */ + uint64_t id; + + /* generation of indirect object */ + uint64_t generation; +}; + +struct cos_object { + int type; + union { + /** boolean */ + bool b; + + /** integer */ + int64_t i; + + /** real */ + double r; + + /** name */ + char *n; + + /** string */ + struct cos_string *s; + + /** stream data */ + uint8_t *stream; + + /* dictionary */ + struct cos_dictionary_entry *dictionary; + + /* array */ + struct cos_array_entry *array; + + /** reference */ + struct cos_reference *reference; + + } u; +}; + +int cos_decode_object(struct pdf_doc *doc, uint64_t *offset_out, struct cos_object **cosobj_out); + +nspdferror cos_free_object(struct cos_object *cos_obj); + +nspdferror cos_dictionary_get_value(struct cos_object *dict, const char *key, struct cos_object **value_out); + +nspdferror cos_dictionary_extract_value(struct cos_object *dict, const char *key, struct cos_object **value_out); + +nspdferror cos_get_int(struct cos_object *cobj, int64_t *value_out); + +nspdferror cos_get_dictionary(struct cos_object *cobj, struct cos_object **value_out); + + |