Diffstat (limited to 'noncore/unsupported/qpdf/xpdf/Stream.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/qpdf/xpdf/Stream.h | 113 |
1 files changed, 95 insertions, 18 deletions
diff --git a/noncore/unsupported/qpdf/xpdf/Stream.h b/noncore/unsupported/qpdf/xpdf/Stream.h index 1f9c561..3319dcc 100644 --- a/noncore/unsupported/qpdf/xpdf/Stream.h +++ b/noncore/unsupported/qpdf/xpdf/Stream.h | |||
@@ -4,3 +4,3 @@ | |||
4 | // | 4 | // |
5 | // Copyright 1996 Derek B. Noonburg | 5 | // Copyright 1996-2002 Glyph & Cog, LLC |
6 | // | 6 | // |
@@ -80,4 +80,6 @@ public: | |||
80 | 80 | ||
81 | // Go to a position in the stream. | 81 | // Go to a position in the stream. If <dir> is negative, the |
82 | virtual void setPos(int pos) = 0; | 82 | // position is from the end of the file; otherwise the position is |
83 | // from the start of the file. | ||
84 | virtual void setPos(Guint pos, int dir = 0) = 0; | ||
83 | 85 | ||
@@ -120,4 +122,5 @@ public: | |||
120 | virtual ~BaseStream(); | 122 | virtual ~BaseStream(); |
121 | virtual Stream *makeSubStream(int start, int length, Object *dict) = 0; | 123 | virtual Stream *makeSubStream(Guint start, GBool limited, |
122 | virtual void setPos(int pos) = 0; | 124 | Guint length, Object *dict) = 0; |
125 | virtual void setPos(Guint pos, int dir = 0) = 0; | ||
123 | virtual BaseStream *getBaseStream() { return this; } | 126 | virtual BaseStream *getBaseStream() { return this; } |
@@ -126,3 +129,3 @@ public: | |||
126 | // Get/set position of first byte of stream within the file. | 129 | // Get/set position of first byte of stream within the file. |
127 | virtual int getStart() = 0; | 130 | virtual Guint getStart() = 0; |
128 | virtual void moveStart(int delta) = 0; | 131 | virtual void moveStart(int delta) = 0; |
@@ -131,3 +134,4 @@ public: | |||
131 | // Set decryption for this stream. | 134 | // Set decryption for this stream. |
132 | void doDecryption(Guchar *fileKey, int keyLength, int objNum, int objGen); | 135 | virtual void doDecryption(Guchar *fileKey, int keyLength, |
136 | int objNum, int objGen); | ||
133 | #endif | 137 | #endif |
@@ -158,3 +162,3 @@ public: | |||
158 | virtual int getPos() { return str->getPos(); } | 162 | virtual int getPos() { return str->getPos(); } |
159 | virtual void setPos(int pos); | 163 | virtual void setPos(Guint pos, int dir = 0); |
160 | virtual BaseStream *getBaseStream() { return str->getBaseStream(); } | 164 | virtual BaseStream *getBaseStream() { return str->getBaseStream(); } |
@@ -244,5 +248,7 @@ public: | |||
244 | 248 | ||
245 | FileStream(FILE *fA, int startA, int lengthA, Object *dictA); | 249 | FileStream(FILE *fA, Guint startA, GBool limitedA, |
250 | Guint lengthA, Object *dictA); | ||
246 | virtual ~FileStream(); | 251 | virtual ~FileStream(); |
247 | virtual Stream *makeSubStream(int startA, int lengthA, Object *dictA); | 252 | virtual Stream *makeSubStream(Guint startA, GBool limitedA, |
253 | Guint lengthA, Object *dictA); | ||
248 | virtual StreamKind getKind() { return strFile; } | 254 | virtual StreamKind getKind() { return strFile; } |
@@ -255,5 +261,5 @@ public: | |||
255 | virtual int getPos() { return bufPos + (bufPtr - buf); } | 261 | virtual int getPos() { return bufPos + (bufPtr - buf); } |
256 | virtual void setPos(int pos); | 262 | virtual void setPos(Guint pos, int dir = 0); |
257 | virtual GBool isBinary(GBool last = gTrue) { return last; } | 263 | virtual GBool isBinary(GBool last = gTrue) { return last; } |
258 | virtual int getStart() { return start; } | 264 | virtual Guint getStart() { return start; } |
259 | virtual void moveStart(int delta); | 265 | virtual void moveStart(int delta); |
@@ -265,4 +271,5 @@ private: | |||
265 | FILE *f; | 271 | FILE *f; |
266 | int start; | 272 | Guint start; |
267 | int length; | 273 | GBool limited; |
274 | Guint length; | ||
268 | char buf[fileStreamBufSize]; | 275 | char buf[fileStreamBufSize]; |
@@ -270,4 +277,42 @@ private: | |||
270 | char *bufEnd; | 277 | char *bufEnd; |
271 | int bufPos; | 278 | Guint bufPos; |
272 | int savePos; | 279 | int savePos; |
280 | GBool saved; | ||
281 | }; | ||
282 | |||
283 | //------------------------------------------------------------------------ | ||
284 | // MemStream | ||
285 | //------------------------------------------------------------------------ | ||
286 | |||
287 | class MemStream: public BaseStream { | ||
288 | public: | ||
289 | |||
290 | MemStream(char *bufA, Guint lengthA, Object *dictA); | ||
291 | virtual ~MemStream(); | ||
292 | virtual Stream *makeSubStream(Guint start, GBool limited, | ||
293 | Guint lengthA, Object *dictA); | ||
294 | virtual StreamKind getKind() { return strWeird; } | ||
295 | virtual void reset(); | ||
296 | virtual void close(); | ||
297 | virtual int getChar() | ||
298 | { return (bufPtr < bufEnd) ? (*bufPtr++ & 0xff) : EOF; } | ||
299 | virtual int lookChar() | ||
300 | { return (bufPtr < bufEnd) ? (*bufPtr & 0xff) : EOF; } | ||
301 | virtual int getPos() { return bufPtr - buf; } | ||
302 | virtual void setPos(Guint pos, int dir = 0); | ||
303 | virtual GBool isBinary(GBool last = gTrue) { return last; } | ||
304 | virtual Guint getStart() { return 0; } | ||
305 | virtual void moveStart(int delta); | ||
306 | #ifndef NO_DECRYPTION | ||
307 | virtual void doDecryption(Guchar *fileKey, int keyLength, | ||
308 | int objNum, int objGen); | ||
309 | #endif | ||
310 | |||
311 | private: | ||
312 | |||
313 | char *buf; | ||
314 | Guint length; | ||
315 | GBool needFree; | ||
316 | char *bufEnd; | ||
317 | char *bufPtr; | ||
273 | }; | 318 | }; |
@@ -289,3 +334,4 @@ public: | |||
289 | virtual ~EmbedStream(); | 334 | virtual ~EmbedStream(); |
290 | virtual Stream *makeSubStream(int start, int length, Object *dictA); | 335 | virtual Stream *makeSubStream(Guint start, GBool limited, |
336 | Guint length, Object *dictA); | ||
291 | virtual StreamKind getKind() { return str->getKind(); } | 337 | virtual StreamKind getKind() { return str->getKind(); } |
@@ -295,5 +341,5 @@ public: | |||
295 | virtual int getPos() { return str->getPos(); } | 341 | virtual int getPos() { return str->getPos(); } |
296 | virtual void setPos(int pos); | 342 | virtual void setPos(Guint pos, int dir = 0); |
297 | virtual GBool isBinary(GBool last = gTrue) { return last; } | 343 | virtual GBool isBinary(GBool last = gTrue) { return last; } |
298 | virtual int getStart(); | 344 | virtual Guint getStart(); |
299 | virtual void moveStart(int delta); | 345 | virtual void moveStart(int delta); |
@@ -661,2 +707,33 @@ private: | |||
661 | //------------------------------------------------------------------------ | 707 | //------------------------------------------------------------------------ |
708 | // ASCIIHexEncoder | ||
709 | //------------------------------------------------------------------------ | ||
710 | |||
711 | class ASCIIHexEncoder: public FilterStream { | ||
712 | public: | ||
713 | |||
714 | ASCIIHexEncoder(Stream *strA); | ||
715 | virtual ~ASCIIHexEncoder(); | ||
716 | virtual StreamKind getKind() { return strWeird; } | ||
717 | virtual void reset(); | ||
718 | virtual void close(); | ||
719 | virtual int getChar() | ||
720 | { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); } | ||
721 | virtual int lookChar() | ||
722 | { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); } | ||
723 | virtual GString *getPSFilter(char *indent) { return NULL; } | ||
724 | virtual GBool isBinary(GBool last = gTrue) { return gFalse; } | ||
725 | virtual GBool isEncoder() { return gTrue; } | ||
726 | |||
727 | private: | ||
728 | |||
729 | char buf[4]; | ||
730 | char *bufPtr; | ||
731 | char *bufEnd; | ||
732 | int lineLen; | ||
733 | GBool eof; | ||
734 | |||
735 | GBool fillBuf(); | ||
736 | }; | ||
737 | |||
738 | //------------------------------------------------------------------------ | ||
662 | // ASCII85Encoder | 739 | // ASCII85Encoder |