From bf255ccc896dc9cf54b13e0f60371f7429035b50 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Tue, 25 Jan 2022 11:14:43 -0500 Subject: QPDFJob: convert password in two tables --- libqpdf/QPDFJob_argv.cc | 13 ------------- libqpdf/QPDFJob_config.cc | 9 +++++++++ libqpdf/qpdf/auto_job_decl.hh | 2 -- libqpdf/qpdf/auto_job_init.hh | 4 ++-- 4 files changed, 11 insertions(+), 17 deletions(-) (limited to 'libqpdf') diff --git a/libqpdf/QPDFJob_argv.cc b/libqpdf/QPDFJob_argv.cc index 9a78018e..af7ce13f 100644 --- a/libqpdf/QPDFJob_argv.cc +++ b/libqpdf/QPDFJob_argv.cc @@ -185,12 +185,6 @@ ArgParser::argShowCrypto() } } -void -ArgParser::argPassword(char* parameter) -{ - o.password = QUtil::make_shared_cstr(parameter); -} - void ArgParser::argPasswordFile(char* parameter) { @@ -894,13 +888,6 @@ ArgParser::argCopyAttPositional(char* arg) c_copy_att->filename(arg); } -void -ArgParser::argCopyAttPassword(char* parameter) -{ - // QXXXQ @TRIVIAL - c_copy_att->password(parameter); -} - void ArgParser::argEndCopyAttachment() { diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc index 923d9302..34f15b9f 100644 --- a/libqpdf/QPDFJob_config.cc +++ b/libqpdf/QPDFJob_config.cc @@ -298,6 +298,13 @@ QPDFJob::Config::optimizeImages() return *this; } +QPDFJob::Config& +QPDFJob::Config::password(char const* parameter) +{ + o.password = QUtil::make_shared_cstr(parameter); + return *this; +} + QPDFJob::Config& QPDFJob::Config::passwordIsHexKey() { @@ -527,6 +534,8 @@ QPDFJob::CopyAttConfig::end() { if (this->caf.path.empty()) { + // QXXXQ usage, json, and config exceptions need to be unified + // in some fashion. throw std::runtime_error("copy attachments: no path specified"); } this->config.o.attachments_to_copy.push_back(this->caf); diff --git a/libqpdf/qpdf/auto_job_decl.hh b/libqpdf/qpdf/auto_job_decl.hh index 8718c3e4..1ea25372 100644 --- a/libqpdf/qpdf/auto_job_decl.hh +++ b/libqpdf/qpdf/auto_job_decl.hh @@ -25,7 +25,6 @@ void argOverlay(); void argPages(); void argUnderlay(); void argJobJsonFile(char *); -void argPassword(char *); void argPasswordFile(char *); void argRotate(char *); void argShowObject(char *); @@ -75,5 +74,4 @@ void argAttMimetype(char *); void argAttDescription(char *); void argEndAttachment(); void argCopyAttPositional(char*); -void argCopyAttPassword(char *); void argEndCopyAttachment(); diff --git a/libqpdf/qpdf/auto_job_init.hh b/libqpdf/qpdf/auto_job_init.hh index cba6347d..7ceff2ae 100644 --- a/libqpdf/qpdf/auto_job_init.hh +++ b/libqpdf/qpdf/auto_job_init.hh @@ -94,7 +94,7 @@ this->ap.addRequiredParameter("min-version", [this](char *x){c_main->minVersion( this->ap.addRequiredParameter("oi-min-area", [this](char *x){c_main->oiMinArea(x);}, "minimum"); this->ap.addRequiredParameter("oi-min-height", [this](char *x){c_main->oiMinHeight(x);}, "minimum"); this->ap.addRequiredParameter("oi-min-width", [this](char *x){c_main->oiMinWidth(x);}, "minimum"); -this->ap.addRequiredParameter("password", p(&ArgParser::argPassword), "password"); +this->ap.addRequiredParameter("password", [this](char *x){c_main->password(x);}, "password"); this->ap.addRequiredParameter("password-file", p(&ArgParser::argPasswordFile), "password"); this->ap.addRequiredParameter("remove-attachment", [this](char *x){c_main->removeAttachment(x);}, "attachment"); this->ap.addRequiredParameter("rotate", p(&ArgParser::argRotate), "[+|-]angle"); @@ -153,7 +153,7 @@ this->ap.addRequiredParameter("description", p(&ArgParser::argAttDescription), " this->ap.registerOptionTable("copy attachment", b(&ArgParser::argEndCopyAttachment)); this->ap.addPositional(p(&ArgParser::argCopyAttPositional)); this->ap.addRequiredParameter("prefix", [this](char *x){c_copy_att->prefix(x);}, "prefix"); -this->ap.addRequiredParameter("password", p(&ArgParser::argCopyAttPassword), "password"); +this->ap.addRequiredParameter("password", [this](char *x){c_copy_att->password(x);}, "password"); this->ap.selectOptionTable("256-bit encryption"); this->ap.copyFromOtherTable("cleartext-metadata", "128-bit encryption"); this->ap.copyFromOtherTable("accessibility", "128-bit encryption"); -- cgit v1.2.3-54-g00ecf