summaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2012-06-21 13:59:56 +0200
committerJay Berkenbilt <ejb@ql.org>2012-06-21 14:00:35 +0200
commitbc1c4bb57864c4dbe9b7e42a77e0653c0d473071 (patch)
tree1c4549bdeb5cbbe70aef0ad87ba3389565219d56 /libqpdf/QPDF.cc
parented6a56a3cdb7fcaa41d87bf90bc0b8c7ef0d761c (diff)
downloadqpdf-bc1c4bb57864c4dbe9b7e42a77e0653c0d473071.tar.zst
Add QPDF::processFile that takes an open FILE*
Diffstat (limited to 'libqpdf/QPDF.cc')
-rw-r--r--libqpdf/QPDF.cc23
1 files changed, 22 insertions, 1 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index 7ed00c98..1c47d893 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -80,6 +80,7 @@ QPDF::InputSource::readLine()
}
QPDF::FileInputSource::FileInputSource() :
+ close_file(false),
file(0)
{
}
@@ -89,10 +90,21 @@ QPDF::FileInputSource::setFilename(char const* filename)
{
destroy();
this->filename = filename;
+ this->close_file = true;
this->file = QUtil::fopen_wrapper(std::string("open ") + this->filename,
fopen(this->filename.c_str(), "rb"));
}
+void
+QPDF::FileInputSource::setFile(FILE* f)
+{
+ destroy();
+ this->filename = "stdio FILE";
+ this->close_file = false;
+ this->file = f;
+ this->seek(0, SEEK_SET);
+}
+
QPDF::FileInputSource::~FileInputSource()
{
destroy();
@@ -101,7 +113,7 @@ QPDF::FileInputSource::~FileInputSource()
void
QPDF::FileInputSource::destroy()
{
- if (this->file)
+ if (this->file && this->close_file)
{
fclose(this->file);
this->file = 0;
@@ -317,6 +329,15 @@ QPDF::processFile(char const* filename, char const* password)
}
void
+QPDF::processFile(FILE* filep, char const* password)
+{
+ FileInputSource* fi = new FileInputSource();
+ this->file = fi;
+ fi->setFile(filep);
+ parse(password);
+}
+
+void
QPDF::processMemoryFile(char const* description,
char const* buf, size_t length,
char const* password)