| 1 |
|
| 2 |
#ifndef PP_XREF_H |
| 3 |
#define PP_XREF_H |
| 4 |
|
| 5 |
/* |
| 6 |
What we call xref is actually "xref section" in PDF spec and what we call section is "xref subsection". |
| 7 |
Our ppxref is a list of sections, sorted by xrefsection->first and xrefsection->last bounds. Every section |
| 8 |
keeps a list of ppref *refs, enumerated from xrefsection->first to xrefsection->last. To find a reference |
| 9 |
by number we make a binary search over sections bounds, then jump to the proper ppref *ref. |
| 10 |
*/ |
| 11 |
|
| 12 |
typedef struct { |
| 13 |
ppuint first; // first reference number in section |
| 14 |
ppuint last; // last reference number in section |
| 15 |
ppref *refs; // references list |
| 16 |
} ppxsec; |
| 17 |
|
| 18 |
struct ppxref { |
| 19 |
ppxsec *sects; // subsections list |
| 20 |
size_t size; // actual sections size |
| 21 |
size_t space; // available sections space |
| 22 |
ppobj trailer; // trailer dict or stream |
| 23 |
ppuint count; // count of references in all sections |
| 24 |
ppxref *prev; // previous xref |
| 25 |
ppdoc *pdf; // parent pdf to access entries in linearized docs |
| 26 |
size_t offset; // file offset of xref |
| 27 |
//ppcrypt *crypt; // per xref encryption state? |
| 28 |
}; |
| 29 |
|
| 30 |
ppxref * ppxref_create (ppdoc *pdf, size_t initsize, size_t xrefoffset); |
| 31 |
ppxsec * ppxref_push_section (ppxref *xref, ppheap *heap); |
| 32 |
int ppxref_sort (ppxref *xref); |
| 33 |
ppref * ppxref_find_local (ppxref *xref, ppuint refnumber); |
| 34 |
|
| 35 |
#endif |