summaryrefslogtreecommitdiff
path: root/source/luametatex/source/libraries/pplib/ppxref.h
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2022-09-16 15:53:42 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2022-09-16 15:53:42 +0200
commitc161b7d6fe142231346cc1844e6e27c0ab7718c1 (patch)
tree3fd877b8986137703e987e4651a2db8e946a0f72 /source/luametatex/source/libraries/pplib/ppxref.h
parente94fa4dc30ec28a6727aa85e17aaac18b76aeadb (diff)
downloadcontext-c161b7d6fe142231346cc1844e6e27c0ab7718c1.tar.gz
2022-09-16 14:41:00
Diffstat (limited to 'source/luametatex/source/libraries/pplib/ppxref.h')
-rw-r--r--source/luametatex/source/libraries/pplib/ppxref.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/source/luametatex/source/libraries/pplib/ppxref.h b/source/luametatex/source/libraries/pplib/ppxref.h
new file mode 100644
index 000000000..fbb83bece
--- /dev/null
+++ b/source/luametatex/source/libraries/pplib/ppxref.h
@@ -0,0 +1,35 @@
+
+#ifndef PP_XREF_H
+#define PP_XREF_H
+
+/*
+What we call xref is actually "xref section" in PDF spec and what we call section is "xref subsection".
+Our ppxref is a list of sections, sorted by xrefsection->first and xrefsection->last bounds. Every section
+keeps a list of ppref *refs, enumerated from xrefsection->first to xrefsection->last. To find a reference
+by number we make a binary search over sections bounds, then jump to the proper ppref *ref.
+*/
+
+typedef struct {
+ ppuint first; // first reference number in section
+ ppuint last; // last reference number in section
+ ppref *refs; // references list
+} ppxsec;
+
+struct ppxref {
+ ppxsec *sects; // subsections list
+ size_t size; // actual sections size
+ size_t space; // available sections space
+ ppobj trailer; // trailer dict or stream
+ ppuint count; // count of references in all sections
+ ppxref *prev; // previous xref
+ ppdoc *pdf; // parent pdf to access entries in linearized docs
+ size_t offset; // file offset of xref
+ //ppcrypt *crypt; // per xref encryption state?
+};
+
+ppxref * ppxref_create (ppdoc *pdf, size_t initsize, size_t xrefoffset);
+ppxsec * ppxref_push_section (ppxref *xref, ppheap *heap);
+int ppxref_sort (ppxref *xref);
+ppref * ppxref_find_local (ppxref *xref, ppuint refnumber);
+
+#endif \ No newline at end of file