aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/OffsetInputSource.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2012-12-25 20:38:18 +0100
committerJay Berkenbilt <ejb@ql.org>2012-12-25 20:43:37 +0100
commit7f84239cad2ec58166245394e56a4647085e025e (patch)
treede91917df48f54d645c90f67a1cb1a49214b5d5f /libqpdf/OffsetInputSource.cc
parentbcfc9847beb0f059a98ef5c8c02646b43fab4272 (diff)
downloadqpdf-7f84239cad2ec58166245394e56a4647085e025e.tar.zst
Find PDF header anywhere in the first 1024 bytes
Diffstat (limited to 'libqpdf/OffsetInputSource.cc')
-rw-r--r--libqpdf/OffsetInputSource.cc61
1 files changed, 61 insertions, 0 deletions
diff --git a/libqpdf/OffsetInputSource.cc b/libqpdf/OffsetInputSource.cc
new file mode 100644
index 00000000..c1ec4102
--- /dev/null
+++ b/libqpdf/OffsetInputSource.cc
@@ -0,0 +1,61 @@
+#include <qpdf/OffsetInputSource.hh>
+
+OffsetInputSource::OffsetInputSource(PointerHolder<InputSource> proxied,
+ qpdf_offset_t global_offset) :
+ proxied(proxied),
+ global_offset(global_offset)
+{
+}
+
+OffsetInputSource::~OffsetInputSource()
+{
+}
+
+qpdf_offset_t
+OffsetInputSource::findAndSkipNextEOL()
+{
+ return this->proxied->findAndSkipNextEOL() - this->global_offset;
+}
+
+std::string const&
+OffsetInputSource::getName() const
+{
+ return this->proxied->getName();
+}
+
+qpdf_offset_t
+OffsetInputSource::tell()
+{
+ return this->proxied->tell() - this->global_offset;
+}
+
+void
+OffsetInputSource::seek(qpdf_offset_t offset, int whence)
+{
+ if (whence == SEEK_SET)
+ {
+ this->proxied->seek(offset + global_offset, whence);
+ }
+ else
+ {
+ this->proxied->seek(offset, whence);
+ }
+}
+
+void
+OffsetInputSource::rewind()
+{
+ seek(0, SEEK_SET);
+}
+
+size_t
+OffsetInputSource::read(char* buffer, size_t length)
+{
+ return this->proxied->read(buffer, length);
+}
+
+void
+OffsetInputSource::unreadCh(char ch)
+{
+ this->proxied->unreadCh(ch);
+}