diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-02-01 13:28:26 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-02-01 15:04:55 +0100 |
commit | b42f3e1d15203927776a5b0954782287c901300f (patch) | |
tree | 047fd96e9ece0630d1e36585d41f10a90e51994a /libqpdf | |
parent | cc5485dac1f224f856ce48781278b357f61f74bd (diff) | |
download | qpdf-b42f3e1d15203927776a5b0954782287c901300f.tar.zst |
Move more code from qpdf.cc into QPDFJob
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDFJob.cc | 89 |
1 files changed, 64 insertions, 25 deletions
diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc index a06f87bc..bea8e358 100644 --- a/libqpdf/QPDFJob.cc +++ b/libqpdf/QPDFJob.cc @@ -629,10 +629,28 @@ QPDFJob::run() { this->m->warnings = true; } + if (this->m->warnings && (! this->m->suppress_warnings)) + { + if (createsOutput()) + { + (*this->m->cerr) + << this->m->message_prefix + << ": operation succeeded with warnings;" + << " resulting file may have some problems" + << std::endl; + } + else + { + (*this->m->cerr) + << this->m->message_prefix + << ": operation succeeded with warnings" + << std::endl; + } + } } bool -QPDFJob::hasWarnings() +QPDFJob::hasWarnings() const { return this->m->warnings; } @@ -643,6 +661,51 @@ QPDFJob::createsOutput() const return ((m->outfilename != nullptr) || m->replace_input); } +int +QPDFJob::getExitCode() const +{ + if (this->m->check_is_encrypted) + { + if (this->m->encryption_status & qpdf_es_encrypted) + { + QTC::TC("qpdf", "qpdf check encrypted encrypted"); + return 0; + } + else + { + QTC::TC("qpdf", "qpdf check encrypted not encrypted"); + return EXIT_IS_NOT_ENCRYPTED; + } + } + else if (this->m->check_requires_password) + { + if (this->m->encryption_status & qpdf_es_encrypted) + { + if (this->m->encryption_status & qpdf_es_password_incorrect) + { + QTC::TC("qpdf", "qpdf check password password incorrect"); + return 0; + } + else + { + QTC::TC("qpdf", "qpdf check password password correct"); + return EXIT_CORRECT_PASSWORD; + } + } + else + { + QTC::TC("qpdf", "qpdf check password not encrypted"); + return EXIT_IS_NOT_ENCRYPTED; + } + } + + if (this->m->warnings && (! this->m->warnings_exit_zero)) + { + return EXIT_WARNING; + } + return 0; +} + void QPDFJob::checkConfiguration() { @@ -726,30 +789,6 @@ QPDFJob::checkConfiguration() } } -bool -QPDFJob::suppressWarnings() -{ - return this->m->suppress_warnings; -} - -bool -QPDFJob::warningsExitZero() -{ - return this->m->warnings_exit_zero; -} - -bool -QPDFJob::checkRequiresPassword() -{ - return this->m->check_requires_password; -} - -bool -QPDFJob::checkIsEncrypted() -{ - return this->m->check_is_encrypted; -} - unsigned long QPDFJob::getEncryptionStatus() { |