summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2017-12-30 00:38:07 +0000
committerVincent Sanders <vince@kyllikki.org>2017-12-30 00:38:07 +0000
commit31b1f792826f51e9271475d124c3a1df4aa5116b (patch)
tree3e0c1083064ba66398dee4fa0aa1c464be3b5325 /include
parent5422dd50a49fe1a282271f22cd324f815e592e07 (diff)
downloadlibnspdf-31b1f792826f51e9271475d124c3a1df4aa5116b.tar.gz
libnspdf-31b1f792826f51e9271475d124c3a1df4aa5116b.tar.bz2
make an actual library
Diffstat (limited to 'include')
-rw-r--r--include/nspdf/document.h45
-rw-r--r--include/nspdf/errors.h29
2 files changed, 74 insertions, 0 deletions
diff --git a/include/nspdf/document.h b/include/nspdf/document.h
new file mode 100644
index 0000000..4e4931d
--- /dev/null
+++ b/include/nspdf/document.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2018 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of libnspdf.
+ *
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ */
+
+/**
+ * \file
+ * NetSurf PDF library document handling
+ */
+
+#ifndef NSPDF_DOCUMENT_H_
+#define NSPDF_DOCUMENT_H_
+
+#include <nspdf/errors.h>
+
+struct nspdf_doc;
+
+/**
+ * create a new PDF document
+ */
+nspdferror nspdf_document_create(struct nspdf_doc **doc_out);
+
+/**
+ * destroys a previously created document
+ *
+ * any allocated resources are freed but any buffers passed for parse are not
+ * altered and may now be freed by the caller.
+ */
+nspdferror nspdf_document_destroy(struct nspdf_doc *doc);
+
+/**
+ * parse a PDF from a memory buffer
+ *
+ * reads all metadata and validates header, trailer, xref table and page tree
+ * ready to render pages. The passed buffer ownership is transfered and must
+ * not be altered untill the document is destroyed.
+ */
+nspdferror nspdf_document_parse(struct nspdf_doc *doc, const uint8_t *buffer, uint64_t buffer_length);
+
+
+#endif /* NSPDF_DOCUMENT_H_ */
diff --git a/include/nspdf/errors.h b/include/nspdf/errors.h
new file mode 100644
index 0000000..f2142ff
--- /dev/null
+++ b/include/nspdf/errors.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2018 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of libnspdf.
+ *
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ */
+
+/**
+ * \file
+ * NetSurf PDF library return codes
+ */
+
+#ifndef NSPDF_ERRORS_H_
+#define NSPDF_ERRORS_H_
+
+typedef enum {
+ NSPDFERROR_OK, /**< no error */
+ NSPDFERROR_NOMEM, /**< memory allocation error */
+ NSPDFERROR_SYNTAX, /**< syntax error in parse */
+ NSPDFERROR_SIZE, /**< not enough input data */
+ NSPDFERROR_RANGE, /**< value outside type range */
+ NSPDFERROR_TYPE, /**< wrong type error */
+ NSPDFERROR_NOTFOUND, /**< key not found */
+ NSPDFERROR_FORMAT, /**< objects do not cornform to expected format */
+} nspdferror;
+
+#endif