aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-01-25 17:14:43 +0100
committerJay Berkenbilt <ejb@ql.org>2022-01-30 19:11:03 +0100
commitbf255ccc896dc9cf54b13e0f60371f7429035b50 (patch)
tree25ab65593fab57f24124ad409de66cdb238954c6 /libqpdf
parent21c897aad0c3edc6e47e88754ab279e0f076cd06 (diff)
downloadqpdf-bf255ccc896dc9cf54b13e0f60371f7429035b50.tar.zst
QPDFJob: convert password in two tables
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDFJob_argv.cc13
-rw-r--r--libqpdf/QPDFJob_config.cc9
-rw-r--r--libqpdf/qpdf/auto_job_decl.hh2
-rw-r--r--libqpdf/qpdf/auto_job_init.hh4
4 files changed, 11 insertions, 17 deletions
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
@@ -186,12 +186,6 @@ ArgParser::argShowCrypto()
}
void
-ArgParser::argPassword(char* parameter)
-{
- o.password = QUtil::make_shared_cstr(parameter);
-}
-
-void
ArgParser::argPasswordFile(char* parameter)
{
std::list<std::string> lines;
@@ -895,13 +889,6 @@ ArgParser::argCopyAttPositional(char* arg)
}
void
-ArgParser::argCopyAttPassword(char* parameter)
-{
- // QXXXQ @TRIVIAL
- c_copy_att->password(parameter);
-}
-
-void
ArgParser::argEndCopyAttachment()
{
c_copy_att->end();
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
@@ -299,6 +299,13 @@ QPDFJob::Config::optimizeImages()
}
QPDFJob::Config&
+QPDFJob::Config::password(char const* parameter)
+{
+ o.password = QUtil::make_shared_cstr(parameter);
+ return *this;
+}
+
+QPDFJob::Config&
QPDFJob::Config::passwordIsHexKey()
{
o.password_is_hex_key = true;
@@ -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");