summaryrefslogtreecommitdiff
path: root/src/pdf_doc.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2017-12-21 23:49:13 +0000
committerVincent Sanders <vince@kyllikki.org>2017-12-21 23:49:13 +0000
commit897a8900bf77db2d804b0f78bc4b41371e05347f (patch)
tree31dfd1c54ceaef746bfb867a4657b7cdcc3d5c61 /src/pdf_doc.c
parentb22daf7d9b39210a0c7f8b5522a884a828b656b0 (diff)
downloadlibnspdf-897a8900bf77db2d804b0f78bc4b41371e05347f.tar.gz
libnspdf-897a8900bf77db2d804b0f78bc4b41371e05347f.tar.bz2
split code up a bit
Diffstat (limited to 'src/pdf_doc.c')
-rw-r--r--src/pdf_doc.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/pdf_doc.c b/src/pdf_doc.c
new file mode 100644
index 0000000..9b92bd0
--- /dev/null
+++ b/src/pdf_doc.c
@@ -0,0 +1,47 @@
+
+#include <stdint.h>
+#include <stddef.h>
+#include <stdbool.h>
+
+#include "nspdferror.h"
+#include "byte_class.h"
+#include "cos_object.h"
+#include "pdf_doc.h"
+
+/**
+ * move offset to next non whitespace byte
+ */
+int doc_skip_ws(struct pdf_doc *doc, uint64_t *offset)
+{
+ uint8_t c;
+ /* TODO sort out keeping offset in range */
+ c = DOC_BYTE(doc, *offset);
+ while ((bclass[c] & (BC_WSPC | BC_CMNT) ) != 0) {
+ (*offset)++;
+ /* skip comments */
+ if ((bclass[c] & BC_CMNT) != 0) {
+ c = DOC_BYTE(doc, *offset);
+ while ((bclass[c] & BC_EOLM ) == 0) {
+ (*offset)++;
+ c = DOC_BYTE(doc, *offset);
+ }
+ }
+ c = DOC_BYTE(doc, *offset);
+ }
+ return 0;
+}
+
+/**
+ * move offset to next non eol byte
+ */
+int doc_skip_eol(struct pdf_doc *doc, uint64_t *offset)
+{
+ uint8_t c;
+ /* TODO sort out keeping offset in range */
+ c = DOC_BYTE(doc, *offset);
+ while ((bclass[c] & BC_EOLM) != 0) {
+ (*offset)++;
+ c = DOC_BYTE(doc, *offset);
+ }
+ return 0;
+}