aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFJob_json.cc
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2023-05-27 19:19:52 +0200
committerm-holger <m-holger@kubitscheck.org>2023-06-02 17:00:40 +0200
commit3c5700c255f4603b5df9c6d183d13dd71a083cc3 (patch)
tree0f01c62c54b56d009b341922fa3441907a2e560b /libqpdf/QPDFJob_json.cc
parent6e6a73d28f5f61f038209a61a3e85995dc71aa32 (diff)
downloadqpdf-3c5700c255f4603b5df9c6d183d13dd71a083cc3.tar.zst
Code tidy - reflow comments and strings
Diffstat (limited to 'libqpdf/QPDFJob_json.cc')
-rw-r--r--libqpdf/QPDFJob_json.cc49
1 files changed, 20 insertions, 29 deletions
diff --git a/libqpdf/QPDFJob_json.cc b/libqpdf/QPDFJob_json.cc
index 126f9a13..92488df1 100644
--- a/libqpdf/QPDFJob_json.cc
+++ b/libqpdf/QPDFJob_json.cc
@@ -30,27 +30,20 @@ namespace
typedef std::function<void(char const*)> param_handler_t;
typedef std::function<void(JSON)> json_handler_t;
- // The code that calls these methods is automatically
- // generated by generate_auto_job. This describes how we
- // implement what it does. We keep a stack of handlers in
- // json_handlers. The top of the stack is the "current" json
- // handler, intially for the top-level object. Whenever we
- // encounter a scalar, we add a handler using addBare,
- // addParameter, or addChoices. Whenever we encounter a
- // dictionary, we first add the dictionary handlers. Then we
- // walk into the dictionary and, for each key, we register a
- // dict key handler and push it to the stack, then do the same
- // process for the key's value. Then we pop the key handler
- // off the stack. When we encounter an array, we add the array
- // handlers, push an item handler to the stack, call
- // recursively for the array's single item (as this is what is
- // expected in a schema), and pop the item handler. Note that
- // we don't pop dictionary start/end handlers. The dictionary
- // handlers and the key handlers are at the same level in
- // JSONHandler. This logic is subtle and took several tries to
- // get right. It's best understood by carefully understanding
- // the behavior of JSONHandler, the JSON schema, and the code
- // in generate_auto_job.
+ // The code that calls these methods is automatically generated by generate_auto_job. This
+ // describes how we implement what it does. We keep a stack of handlers in json_handlers.
+ // The top of the stack is the "current" json handler, intially for the top-level object.
+ // Whenever we encounter a scalar, we add a handler using addBare, addParameter, or
+ // addChoices. Whenever we encounter a dictionary, we first add the dictionary handlers.
+ // Then we walk into the dictionary and, for each key, we register a dict key handler and
+ // push it to the stack, then do the same process for the key's value. Then we pop the key
+ // handler off the stack. When we encounter an array, we add the array handlers, push an
+ // item handler to the stack, call recursively for the array's single item (as this is what
+ // is expected in a schema), and pop the item handler. Note that we don't pop dictionary
+ // start/end handlers. The dictionary handlers and the key handlers are at the same level in
+ // JSONHandler. This logic is subtle and took several tries to get right. It's best
+ // understood by carefully understanding the behavior of JSONHandler, the JSON schema, and
+ // the code in generate_auto_job.
void addBare(bare_handler_t);
void addParameter(param_handler_t);
@@ -261,9 +254,8 @@ Handlers::setupReplaceInput()
void
Handlers::beginEncrypt(JSON j)
{
- // This method is only called if the overall JSON structure
- // matches the schema, so we already know that keys that are
- // present have the right types.
+ // This method is only called if the overall JSON structure matches the schema, so we already
+ // know that keys that are present have the right types.
int key_len = 0;
std::string user_password;
std::string owner_password;
@@ -284,14 +276,13 @@ Handlers::beginEncrypt(JSON j)
});
if (key_len == 0) {
QTC::TC("qpdf", "QPDFJob json encrypt no key length");
- usage("exactly one of 40bit, 128bit, or 256bit must be given;"
- " an empty dictionary may be supplied for one of them"
- " to set the key length without imposing any restrictions");
+ usage("exactly one of 40bit, 128bit, or 256bit must be given; an empty dictionary may be "
+ "supplied for one of them to set the key length without imposing any restrictions");
}
if (!(user_password_seen && owner_password_seen)) {
QTC::TC("qpdf", "QPDFJob json encrypt missing password");
- usage("the user and owner password are both required; use the empty"
- " string for the user password if you don't want a password");
+ usage("the user and owner password are both required; use the empty string for the user "
+ "password if you don't want a password");
}
this->c_enc = c_main->encrypt(key_len, user_password, owner_password);
}