1 //========================================================================
5 // Copyright 1996 Derek B. Noonburg
7 //========================================================================
22 //------------------------------------------------------------------------
24 //------------------------------------------------------------------------
35 // Constructor. Read xref table from stream.
36 XRef(BaseStream *str, GString *userPassword);
41 // Is xref table valid?
42 GBool isOk() { return ok; }
44 // Is the file encrypted?
46 GBool isEncrypted() { return encrypted; }
48 GBool isEncrypted() { return gFalse; }
51 // Check various permissions.
57 // Get catalog object.
58 Object *getCatalog(Object *obj) { return fetch(rootNum, rootGen, obj); }
60 // Fetch an indirect reference.
61 Object *fetch(int num, int gen, Object *obj);
63 // Return the document's Info dictionary (if any).
64 Object *getDocInfo(Object *obj);
66 // Return the number of objects in the xref table.
67 int getNumObjects() { return size; }
69 // Return the offset of the last xref table.
70 int getLastXRefPos() { return lastXRefPos; }
72 // Return the catalog object reference.
73 int getRootNum() { return rootNum; }
74 int getRootGen() { return rootGen; }
76 // Get end position for a stream in a damaged file.
77 // Returns -1 if unknown or file is not damaged.
78 int getStreamEnd(int start);
82 BaseStream *str; // input stream
83 int start; // offset in file (to allow for garbage
84 // at beginning of file)
85 XRefEntry *entries; // xref entries
86 int size; // size of <entries> array
87 int rootNum, rootGen; // catalog dict
88 GBool ok; // true if xref table is valid
89 Object trailerDict; // trailer dictionary
90 int lastXRefPos; // offset of last xref table
91 int *streamEnds; // 'endstream' positions - only used in
93 int streamEndsLen; // number of valid entries in streamEnds
95 GBool encrypted; // true if file is encrypted
96 int permFlags; // permission bits
97 Guchar fileKey[16]; // file decryption key
101 GBool readXRef(int *pos);
102 GBool constructXRef();
103 GBool checkEncrypted(GString *userPassword);
106 //------------------------------------------------------------------------
107 // The global xref table
108 //------------------------------------------------------------------------