Commit e01bbccb40d4714f8fd1551d7f7cca694d607091
1 parent
ce3406e9
QPDFJob: incorporate change to JSONHandler for dict start function
Showing
7 changed files
with
124 additions
and
115 deletions
generate_auto_job
| ... | ... | @@ -516,11 +516,11 @@ class Main: |
| 516 | 516 | def build_schema(j, s, flag, path): |
| 517 | 517 | if flag: |
| 518 | 518 | identifier = self.to_identifier(path, '', False) |
| 519 | - self.json_decls.append(f'void begin{identifier}();') | |
| 519 | + self.json_decls.append(f'void begin{identifier}(JSON);') | |
| 520 | 520 | self.json_decls.append(f'void end{identifier}();') |
| 521 | 521 | self.json_init.append( |
| 522 | 522 | f'beginDict("{flag}",' |
| 523 | - f' bindBare(&Handlers::begin{identifier}),' | |
| 523 | + f' bindJSON(&Handlers::begin{identifier}),' | |
| 524 | 524 | f' bindBare(&Handlers::end{identifier})); // {path}') |
| 525 | 525 | for k, v in j.items(): |
| 526 | 526 | is_trivial = False | ... | ... |
job.sums
| 1 | 1 | # Generated by generate_auto_job |
| 2 | -generate_auto_job 53b2b81e8cb38f1bfa0053f351f37fe9e9437eb2cef808ff0c01cfc56ca20946 | |
| 2 | +generate_auto_job e4a071599697cc0f4d985367735ac6ed6110575e2cbfa01406d048780466d546 | |
| 3 | 3 | include/qpdf/auto_job_c_att.hh 7ad43bb374c1370ef32ebdcdcb7b73a61d281f7f4e3f12755585872ab30fb60e |
| 4 | 4 | include/qpdf/auto_job_c_copy_att.hh 32275d03cdc69b703dd7e02ba0bbe15756e714e9ad185484773a6178dc09e1ee |
| 5 | 5 | include/qpdf/auto_job_c_enc.hh 72e138c7b96ed5aacdce78c1dec04b1c20d361faec4f8faf52f64c1d6be99265 |
| 6 | 6 | include/qpdf/auto_job_c_main.hh 516adb23cc7e44e614e436880be870d0574e4ebbc706cd855a1360000eed31bb |
| 7 | 7 | include/qpdf/auto_job_c_pages.hh 931840b329a36ca0e41401190e04537b47f2867671a6643bfd8da74014202671 |
| 8 | 8 | include/qpdf/auto_job_c_uo.hh 0585b7de459fa479d9e51a45fa92de0ff6dee748efc9ec1cedd0dde6cee1ad50 |
| 9 | -job.yml d9be74c397e1f272ac6a81981a528c332f8bd7b98d58ae6ba6f60875391567e8 | |
| 9 | +job.yml 7433861fa281197aa275d624a334aa324ec63839c5e56a24448ab64d0b75587c | |
| 10 | 10 | libqpdf/qpdf/auto_job_decl.hh 9f79396ec459f191be4c5fe34cf88c265cf47355a1a945fa39169d1c94cf04f6 |
| 11 | 11 | libqpdf/qpdf/auto_job_help.hh 23c79f1d2c02bda28f64aace17f69487205c797e7ae2234892cbbabab49d6d47 |
| 12 | 12 | libqpdf/qpdf/auto_job_init.hh 8e9e31b6099a662497339b27f6e2d7f779f35011e88a834bee8811c33405a0fe |
| 13 | -libqpdf/qpdf/auto_job_json_decl.hh d729213332b92ee0da89d1cad0318ab96aec443f37d208fbbc8d56e9d1398ac2 | |
| 14 | -libqpdf/qpdf/auto_job_json_init.hh a28c2c2b83d1c0036d3d07172dffb1eac1b75ce3d6a615a87111e9f3bd3dad58 | |
| 15 | -libqpdf/qpdf/auto_job_schema.hh 9962f09f3260c01d4165a6ddf2814a0621395dcb5d80a3d310f580a1b7d3baba | |
| 13 | +libqpdf/qpdf/auto_job_json_decl.hh d315f920a32d7a5a2272807e6813d463c3e1877a9d735e44e8417b5f1461b87a | |
| 14 | +libqpdf/qpdf/auto_job_json_init.hh 08e6ee8a509bc592e3aa6f7a1d3a6d18cdf4803e6220147855caf675e0a299ce | |
| 15 | +libqpdf/qpdf/auto_job_schema.hh 6ec5b9dd3b4709b49fb3b928c4d9cde8b35ad938a0945f81c9a3da6c3bf9a3c1 | |
| 16 | 16 | manual/_ext/qpdf.py e9ac9d6c70642a3d29281ee5ad92ae2422dee8be9306fb8a0bc9dba0ed5e28f3 |
| 17 | 17 | manual/cli.rst 79140e023faa0cb77afe0b1dc512dd120ee5617f4db82f842596e4f239f93882 | ... | ... |
job.yml
| ... | ... | @@ -249,16 +249,20 @@ json: |
| 249 | 249 | # QPDFJob looks like. If a key starts with underscore or has a value |
| 250 | 250 | # that is a string, it does not map to a command-line argument. If |
| 251 | 251 | # value is null, its properties and help come from other information |
| 252 | - # known by generate_auto_job. This information is used to construct | |
| 253 | - # a "schema" (as in JSON.hh) for the json input to QPDFJob. The | |
| 254 | - # leading underscore is removed. | |
| 252 | + # known by generate_auto_job. Otherwise, it has to match a | |
| 253 | + # command-line option. This information is used to construct a | |
| 254 | + # "schema" (as in JSON.hh) for the json input to QPDFJob. The | |
| 255 | + # leading underscore is removed. *NOTE*: all keys are converted to | |
| 256 | + # camelCase for the schema and must be appear that way in the | |
| 257 | + # user-supplied json. This makes it more convenient to populate JSON | |
| 258 | + # objects in some languages. | |
| 255 | 259 | _input: |
| 256 | - _fileName: "input filename" | |
| 260 | + _filename: "input filename" | |
| 257 | 261 | main.password: |
| 258 | 262 | password-file: |
| 259 | 263 | empty: |
| 260 | 264 | _output: |
| 261 | - _fileName: "output filename" | |
| 265 | + _filename: "output filename" | |
| 262 | 266 | _replace-input: "set to true to replace input" |
| 263 | 267 | _options: |
| 264 | 268 | qdf: |
| ... | ... | @@ -283,15 +287,14 @@ json: |
| 283 | 287 | progress: |
| 284 | 288 | split-pages: |
| 285 | 289 | encrypt: |
| 286 | - key-length: "key length: 48, 128, 256" | |
| 287 | 290 | user-password: "user password" |
| 288 | 291 | owner-password: "owner password" |
| 289 | - _40-bit: | |
| 292 | + _40bit: | |
| 290 | 293 | Enc40.annotate: |
| 291 | 294 | Enc40.extract: |
| 292 | 295 | Enc40.modify: |
| 293 | 296 | Enc40.print: |
| 294 | - _128-bit: | |
| 297 | + _128bit: | |
| 295 | 298 | Enc128.accessibility: |
| 296 | 299 | Enc128.annotate: |
| 297 | 300 | Enc128.assemble: |
| ... | ... | @@ -303,7 +306,7 @@ json: |
| 303 | 306 | Enc128.print: |
| 304 | 307 | force-V4: |
| 305 | 308 | use-aes: |
| 306 | - _256-bit: | |
| 309 | + _256bit: | |
| 307 | 310 | Enc256.accessibility: |
| 308 | 311 | Enc256.annotate: |
| 309 | 312 | Enc256.assemble: | ... | ... |
libqpdf/QPDFJob_json.cc
| 1 | 1 | #include <qpdf/QPDFJob.hh> |
| 2 | 2 | #include <qpdf/JSONHandler.hh> |
| 3 | 3 | #include <qpdf/QPDFUsage.hh> |
| 4 | +#include <qpdf/QUtil.hh> | |
| 4 | 5 | |
| 5 | 6 | #include <memory> |
| 6 | 7 | #include <stdexcept> |
| ... | ... | @@ -25,6 +26,7 @@ namespace |
| 25 | 26 | |
| 26 | 27 | typedef std::function<void()> bare_handler_t; |
| 27 | 28 | typedef std::function<void(char const*)> param_handler_t; |
| 29 | + typedef std::function<void(JSON)> json_handler_t; | |
| 28 | 30 | typedef std::function<void(std::string const& key)> setup_handler_t; |
| 29 | 31 | |
| 30 | 32 | void addBare(std::string const& key, bare_handler_t); |
| ... | ... | @@ -33,11 +35,12 @@ namespace |
| 33 | 35 | param_handler_t); |
| 34 | 36 | void doSetup(std::string const& key, setup_handler_t); |
| 35 | 37 | void beginDict(std::string const& key, |
| 36 | - bare_handler_t start_fn, | |
| 38 | + json_handler_t start_fn, | |
| 37 | 39 | bare_handler_t end_fn); |
| 38 | 40 | void endDict(); |
| 39 | 41 | |
| 40 | 42 | bare_handler_t bindBare(void (Handlers::*f)()); |
| 43 | + json_handler_t bindJSON(void (Handlers::*f)(JSON)); | |
| 41 | 44 | setup_handler_t bindSetup(void (Handlers::*f)(std::string const&)); |
| 42 | 45 | |
| 43 | 46 | std::list<std::shared_ptr<JSONHandler>> json_handlers; |
| ... | ... | @@ -70,6 +73,12 @@ Handlers::bindBare(void (Handlers::*f)()) |
| 70 | 73 | return std::bind(std::mem_fn(f), this); |
| 71 | 74 | } |
| 72 | 75 | |
| 76 | +Handlers::json_handler_t | |
| 77 | +Handlers::bindJSON(void (Handlers::*f)(JSON)) | |
| 78 | +{ | |
| 79 | + return std::bind(std::mem_fn(f), this, std::placeholders::_1); | |
| 80 | +} | |
| 81 | + | |
| 73 | 82 | Handlers::setup_handler_t |
| 74 | 83 | Handlers::bindSetup(void (Handlers::*f)(std::string const&)) |
| 75 | 84 | { |
| ... | ... | @@ -82,7 +91,7 @@ Handlers::initHandlers() |
| 82 | 91 | this->json_handlers.push_back(std::make_shared<JSONHandler>()); |
| 83 | 92 | this->jh = this->json_handlers.back().get(); |
| 84 | 93 | jh->addDictHandlers( |
| 85 | - [](std::string const&){}, | |
| 94 | + [](std::string const&, JSON){}, | |
| 86 | 95 | [this](std::string const&){c_main->checkConfiguration();}); |
| 87 | 96 | |
| 88 | 97 | # include <qpdf/auto_job_json_init.hh> |
| ... | ... | @@ -172,12 +181,12 @@ Handlers::doSetup(std::string const& key, setup_handler_t fn) |
| 172 | 181 | |
| 173 | 182 | void |
| 174 | 183 | Handlers::beginDict(std::string const& key, |
| 175 | - bare_handler_t start_fn, | |
| 184 | + json_handler_t start_fn, | |
| 176 | 185 | bare_handler_t end_fn) |
| 177 | 186 | { |
| 178 | 187 | auto new_jh = std::make_shared<JSONHandler>(); |
| 179 | 188 | new_jh->addDictHandlers( |
| 180 | - [start_fn](std::string const&){ start_fn(); }, | |
| 189 | + [start_fn](std::string const&, JSON j){ start_fn(j); }, | |
| 181 | 190 | [end_fn](std::string const&){ end_fn(); }); |
| 182 | 191 | this->jh->addDictKeyHandler(key, new_jh); |
| 183 | 192 | this->json_handlers.push_back(new_jh); |
| ... | ... | @@ -198,7 +207,7 @@ Handlers::handle(JSON& j) |
| 198 | 207 | } |
| 199 | 208 | |
| 200 | 209 | void |
| 201 | -Handlers::beginInput() | |
| 210 | +Handlers::beginInput(JSON) | |
| 202 | 211 | { |
| 203 | 212 | // nothing needed |
| 204 | 213 | } |
| ... | ... | @@ -210,7 +219,7 @@ Handlers::endInput() |
| 210 | 219 | } |
| 211 | 220 | |
| 212 | 221 | void |
| 213 | -Handlers::setupInputFileName(std::string const& key) | |
| 222 | +Handlers::setupInputFilename(std::string const& key) | |
| 214 | 223 | { |
| 215 | 224 | addParameter(key, [this](char const* p) { |
| 216 | 225 | c_main->inputFile(p); |
| ... | ... | @@ -232,7 +241,7 @@ Handlers::setupInputEmpty(std::string const& key) |
| 232 | 241 | } |
| 233 | 242 | |
| 234 | 243 | void |
| 235 | -Handlers::beginOutput() | |
| 244 | +Handlers::beginOutput(JSON) | |
| 236 | 245 | { |
| 237 | 246 | // nothing needed |
| 238 | 247 | } |
| ... | ... | @@ -244,7 +253,7 @@ Handlers::endOutput() |
| 244 | 253 | } |
| 245 | 254 | |
| 246 | 255 | void |
| 247 | -Handlers::setupOutputFileName(std::string const& key) | |
| 256 | +Handlers::setupOutputFilename(std::string const& key) | |
| 248 | 257 | { |
| 249 | 258 | addParameter(key, [this](char const* p) { |
| 250 | 259 | c_main->outputFile(p); |
| ... | ... | @@ -260,7 +269,7 @@ Handlers::setupOutputReplaceInput(std::string const& key) |
| 260 | 269 | } |
| 261 | 270 | |
| 262 | 271 | void |
| 263 | -Handlers::beginOutputOptions() | |
| 272 | +Handlers::beginOutputOptions(JSON) | |
| 264 | 273 | { |
| 265 | 274 | // nothing needed |
| 266 | 275 | } |
| ... | ... | @@ -272,9 +281,15 @@ Handlers::endOutputOptions() |
| 272 | 281 | } |
| 273 | 282 | |
| 274 | 283 | void |
| 275 | -Handlers::beginOutputOptionsEncrypt() | |
| 284 | +Handlers::beginOutputOptionsEncrypt(JSON) | |
| 276 | 285 | { |
| 277 | 286 | // QXXXQ |
| 287 | +// if (this->keylen_seen == 0) | |
| 288 | +// { | |
| 289 | +// usage("exactly one of 40bit, 128bit, or 256bit must be given;" | |
| 290 | +// " an empty dictionary may be supplied for one of them" | |
| 291 | +// " to set the key length without imposing any restrictions"); | |
| 292 | +// } | |
| 278 | 293 | } |
| 279 | 294 | |
| 280 | 295 | void |
| ... | ... | @@ -284,61 +299,55 @@ Handlers::endOutputOptionsEncrypt() |
| 284 | 299 | } |
| 285 | 300 | |
| 286 | 301 | void |
| 287 | -Handlers::setupOutputOptionsEncryptKeyLength(std::string const& key) | |
| 288 | -{ | |
| 289 | - // QXXXQ | |
| 290 | -} | |
| 291 | - | |
| 292 | -void | |
| 293 | 302 | Handlers::setupOutputOptionsEncryptUserPassword(std::string const& key) |
| 294 | 303 | { |
| 295 | - // QXXXQ | |
| 304 | + // Key handled in beginOutputOptionsEncrypt | |
| 296 | 305 | } |
| 297 | 306 | |
| 298 | 307 | void |
| 299 | 308 | Handlers::setupOutputOptionsEncryptOwnerPassword(std::string const& key) |
| 300 | 309 | { |
| 301 | - // QXXXQ | |
| 310 | + // Key handled in beginOutputOptionsEncrypt | |
| 302 | 311 | } |
| 303 | 312 | |
| 304 | 313 | void |
| 305 | -Handlers::beginOutputOptionsEncrypt40Bit() | |
| 314 | +Handlers::beginOutputOptionsEncrypt40bit(JSON) | |
| 306 | 315 | { |
| 307 | - // QXXXQ | |
| 316 | + // nothing needed | |
| 308 | 317 | } |
| 309 | 318 | |
| 310 | 319 | void |
| 311 | -Handlers::endOutputOptionsEncrypt40Bit() | |
| 320 | +Handlers::endOutputOptionsEncrypt40bit() | |
| 312 | 321 | { |
| 313 | - // QXXXQ | |
| 322 | + // nothing needed | |
| 314 | 323 | } |
| 315 | 324 | |
| 316 | 325 | void |
| 317 | -Handlers::beginOutputOptionsEncrypt128Bit() | |
| 326 | +Handlers::beginOutputOptionsEncrypt128bit(JSON) | |
| 318 | 327 | { |
| 319 | - // QXXXQ | |
| 328 | + // nothing needed | |
| 320 | 329 | } |
| 321 | 330 | |
| 322 | 331 | void |
| 323 | -Handlers::endOutputOptionsEncrypt128Bit() | |
| 332 | +Handlers::endOutputOptionsEncrypt128bit() | |
| 324 | 333 | { |
| 325 | - // QXXXQ | |
| 334 | + // nothing needed | |
| 326 | 335 | } |
| 327 | 336 | |
| 328 | 337 | void |
| 329 | -Handlers::beginOutputOptionsEncrypt256Bit() | |
| 338 | +Handlers::beginOutputOptionsEncrypt256bit(JSON) | |
| 330 | 339 | { |
| 331 | - // QXXXQ | |
| 340 | + // nothing needed | |
| 332 | 341 | } |
| 333 | 342 | |
| 334 | 343 | void |
| 335 | -Handlers::endOutputOptionsEncrypt256Bit() | |
| 344 | +Handlers::endOutputOptionsEncrypt256bit() | |
| 336 | 345 | { |
| 337 | - // QXXXQ | |
| 346 | + // nothing needed | |
| 338 | 347 | } |
| 339 | 348 | |
| 340 | 349 | void |
| 341 | -Handlers::beginOptions() | |
| 350 | +Handlers::beginOptions(JSON) | |
| 342 | 351 | { |
| 343 | 352 | // nothing needed |
| 344 | 353 | } |
| ... | ... | @@ -350,7 +359,7 @@ Handlers::endOptions() |
| 350 | 359 | } |
| 351 | 360 | |
| 352 | 361 | void |
| 353 | -Handlers::beginInspect() | |
| 362 | +Handlers::beginInspect(JSON) | |
| 354 | 363 | { |
| 355 | 364 | // nothing needed |
| 356 | 365 | } |
| ... | ... | @@ -362,7 +371,7 @@ Handlers::endInspect() |
| 362 | 371 | } |
| 363 | 372 | |
| 364 | 373 | void |
| 365 | -Handlers::beginTransform() | |
| 374 | +Handlers::beginTransform(JSON) | |
| 366 | 375 | { |
| 367 | 376 | // nothing needed |
| 368 | 377 | } |
| ... | ... | @@ -374,7 +383,7 @@ Handlers::endTransform() |
| 374 | 383 | } |
| 375 | 384 | |
| 376 | 385 | void |
| 377 | -Handlers::beginModify() | |
| 386 | +Handlers::beginModify(JSON) | |
| 378 | 387 | { |
| 379 | 388 | // nothing needed |
| 380 | 389 | } |
| ... | ... | @@ -386,7 +395,7 @@ Handlers::endModify() |
| 386 | 395 | } |
| 387 | 396 | |
| 388 | 397 | void |
| 389 | -Handlers::beginModifyAddAttachment() | |
| 398 | +Handlers::beginModifyAddAttachment(JSON) | |
| 390 | 399 | { |
| 391 | 400 | // QXXXQ |
| 392 | 401 | } |
| ... | ... | @@ -400,11 +409,11 @@ Handlers::endModifyAddAttachment() |
| 400 | 409 | void |
| 401 | 410 | Handlers::setupModifyAddAttachmentPath(std::string const& key) |
| 402 | 411 | { |
| 403 | - // QXXXQ | |
| 412 | + // QXXXQ setup | |
| 404 | 413 | } |
| 405 | 414 | |
| 406 | 415 | void |
| 407 | -Handlers::beginModifyCopyAttachmentsFrom() | |
| 416 | +Handlers::beginModifyCopyAttachmentsFrom(JSON) | |
| 408 | 417 | { |
| 409 | 418 | // QXXXQ |
| 410 | 419 | } |
| ... | ... | @@ -418,17 +427,17 @@ Handlers::endModifyCopyAttachmentsFrom() |
| 418 | 427 | void |
| 419 | 428 | Handlers::setupModifyCopyAttachmentsFromPath(std::string const& key) |
| 420 | 429 | { |
| 421 | - // QXXXQ | |
| 430 | + // QXXXQ setup | |
| 422 | 431 | } |
| 423 | 432 | |
| 424 | 433 | void |
| 425 | 434 | Handlers::setupModifyCopyAttachmentsFromPassword(std::string const& key) |
| 426 | 435 | { |
| 427 | - // QXXXQ | |
| 436 | + // QXXXQ setup | |
| 428 | 437 | } |
| 429 | 438 | |
| 430 | 439 | void |
| 431 | -Handlers::beginModifyPages() | |
| 440 | +Handlers::beginModifyPages(JSON) | |
| 432 | 441 | { |
| 433 | 442 | // QXXXQ |
| 434 | 443 | } |
| ... | ... | @@ -442,23 +451,23 @@ Handlers::endModifyPages() |
| 442 | 451 | void |
| 443 | 452 | Handlers::setupModifyPagesFile(std::string const& key) |
| 444 | 453 | { |
| 445 | - // QXXXQ | |
| 454 | + // QXXXQ setup | |
| 446 | 455 | } |
| 447 | 456 | |
| 448 | 457 | void |
| 449 | 458 | Handlers::setupModifyPagesPassword(std::string const& key) |
| 450 | 459 | { |
| 451 | - // QXXXQ | |
| 460 | + // QXXXQ setup | |
| 452 | 461 | } |
| 453 | 462 | |
| 454 | 463 | void |
| 455 | 464 | Handlers::setupModifyPagesRange(std::string const& key) |
| 456 | 465 | { |
| 457 | - // QXXXQ | |
| 466 | + // QXXXQ setup | |
| 458 | 467 | } |
| 459 | 468 | |
| 460 | 469 | void |
| 461 | -Handlers::beginModifyOverlay() | |
| 470 | +Handlers::beginModifyOverlay(JSON) | |
| 462 | 471 | { |
| 463 | 472 | // QXXXQ |
| 464 | 473 | } |
| ... | ... | @@ -472,17 +481,17 @@ Handlers::endModifyOverlay() |
| 472 | 481 | void |
| 473 | 482 | Handlers::setupModifyOverlayFile(std::string const& key) |
| 474 | 483 | { |
| 475 | - // QXXXQ | |
| 484 | + // QXXXQ setup | |
| 476 | 485 | } |
| 477 | 486 | |
| 478 | 487 | void |
| 479 | 488 | Handlers::setupModifyOverlayPassword(std::string const& key) |
| 480 | 489 | { |
| 481 | - // QXXXQ | |
| 490 | + // QXXXQ setup | |
| 482 | 491 | } |
| 483 | 492 | |
| 484 | 493 | void |
| 485 | -Handlers::beginModifyUnderlay() | |
| 494 | +Handlers::beginModifyUnderlay(JSON) | |
| 486 | 495 | { |
| 487 | 496 | // QXXXQ |
| 488 | 497 | } |
| ... | ... | @@ -496,13 +505,13 @@ Handlers::endModifyUnderlay() |
| 496 | 505 | void |
| 497 | 506 | Handlers::setupModifyUnderlayFile(std::string const& key) |
| 498 | 507 | { |
| 499 | - // QXXXQ | |
| 508 | + // QXXXQ setup | |
| 500 | 509 | } |
| 501 | 510 | |
| 502 | 511 | void |
| 503 | 512 | Handlers::setupModifyUnderlayPassword(std::string const& key) |
| 504 | 513 | { |
| 505 | - // QXXXQ | |
| 514 | + // QXXXQ setup | |
| 506 | 515 | } |
| 507 | 516 | |
| 508 | 517 | void | ... | ... |
libqpdf/qpdf/auto_job_json_decl.hh
| ... | ... | @@ -3,53 +3,52 @@ |
| 3 | 3 | // Edits will be automatically overwritten if the build is |
| 4 | 4 | // run in maintainer mode. |
| 5 | 5 | // |
| 6 | -void beginInput(); | |
| 6 | +void beginInput(JSON); | |
| 7 | 7 | void endInput(); |
| 8 | -void setupInputFileName(std::string const&); | |
| 8 | +void setupInputFilename(std::string const&); | |
| 9 | 9 | void setupInputPassword(std::string const&); |
| 10 | 10 | void setupInputEmpty(std::string const&); |
| 11 | -void beginOutput(); | |
| 11 | +void beginOutput(JSON); | |
| 12 | 12 | void endOutput(); |
| 13 | -void setupOutputFileName(std::string const&); | |
| 13 | +void setupOutputFilename(std::string const&); | |
| 14 | 14 | void setupOutputReplaceInput(std::string const&); |
| 15 | -void beginOutputOptions(); | |
| 15 | +void beginOutputOptions(JSON); | |
| 16 | 16 | void endOutputOptions(); |
| 17 | -void beginOutputOptionsEncrypt(); | |
| 17 | +void beginOutputOptionsEncrypt(JSON); | |
| 18 | 18 | void endOutputOptionsEncrypt(); |
| 19 | -void setupOutputOptionsEncryptKeyLength(std::string const&); | |
| 20 | 19 | void setupOutputOptionsEncryptUserPassword(std::string const&); |
| 21 | 20 | void setupOutputOptionsEncryptOwnerPassword(std::string const&); |
| 22 | -void beginOutputOptionsEncrypt40Bit(); | |
| 23 | -void endOutputOptionsEncrypt40Bit(); | |
| 24 | -void beginOutputOptionsEncrypt128Bit(); | |
| 25 | -void endOutputOptionsEncrypt128Bit(); | |
| 26 | -void beginOutputOptionsEncrypt256Bit(); | |
| 27 | -void endOutputOptionsEncrypt256Bit(); | |
| 28 | -void beginOptions(); | |
| 21 | +void beginOutputOptionsEncrypt40bit(JSON); | |
| 22 | +void endOutputOptionsEncrypt40bit(); | |
| 23 | +void beginOutputOptionsEncrypt128bit(JSON); | |
| 24 | +void endOutputOptionsEncrypt128bit(); | |
| 25 | +void beginOutputOptionsEncrypt256bit(JSON); | |
| 26 | +void endOutputOptionsEncrypt256bit(); | |
| 27 | +void beginOptions(JSON); | |
| 29 | 28 | void endOptions(); |
| 30 | -void beginInspect(); | |
| 29 | +void beginInspect(JSON); | |
| 31 | 30 | void endInspect(); |
| 32 | -void beginTransform(); | |
| 31 | +void beginTransform(JSON); | |
| 33 | 32 | void endTransform(); |
| 34 | -void beginModify(); | |
| 33 | +void beginModify(JSON); | |
| 35 | 34 | void endModify(); |
| 36 | -void beginModifyAddAttachment(); | |
| 35 | +void beginModifyAddAttachment(JSON); | |
| 37 | 36 | void endModifyAddAttachment(); |
| 38 | 37 | void setupModifyAddAttachmentPath(std::string const&); |
| 39 | -void beginModifyCopyAttachmentsFrom(); | |
| 38 | +void beginModifyCopyAttachmentsFrom(JSON); | |
| 40 | 39 | void endModifyCopyAttachmentsFrom(); |
| 41 | 40 | void setupModifyCopyAttachmentsFromPath(std::string const&); |
| 42 | 41 | void setupModifyCopyAttachmentsFromPassword(std::string const&); |
| 43 | -void beginModifyPages(); | |
| 42 | +void beginModifyPages(JSON); | |
| 44 | 43 | void endModifyPages(); |
| 45 | 44 | void setupModifyPagesFile(std::string const&); |
| 46 | 45 | void setupModifyPagesPassword(std::string const&); |
| 47 | 46 | void setupModifyPagesRange(std::string const&); |
| 48 | -void beginModifyOverlay(); | |
| 47 | +void beginModifyOverlay(JSON); | |
| 49 | 48 | void endModifyOverlay(); |
| 50 | 49 | void setupModifyOverlayFile(std::string const&); |
| 51 | 50 | void setupModifyOverlayPassword(std::string const&); |
| 52 | -void beginModifyUnderlay(); | |
| 51 | +void beginModifyUnderlay(JSON); | |
| 53 | 52 | void endModifyUnderlay(); |
| 54 | 53 | void setupModifyUnderlayFile(std::string const&); |
| 55 | 54 | void setupModifyUnderlayPassword(std::string const&); | ... | ... |
libqpdf/qpdf/auto_job_json_init.hh
| ... | ... | @@ -14,16 +14,16 @@ static char const* json_key_choices[] = {"acroform", "attachments", "encrypt", " |
| 14 | 14 | static char const* print128_choices[] = {"full", "low", "none", 0}; |
| 15 | 15 | static char const* modify128_choices[] = {"all", "annotate", "form", "assembly", "none", 0}; |
| 16 | 16 | |
| 17 | -beginDict("input", bindBare(&Handlers::beginInput), bindBare(&Handlers::endInput)); // .input | |
| 18 | -doSetup("fileName", bindSetup(&Handlers::setupInputFileName)); | |
| 17 | +beginDict("input", bindJSON(&Handlers::beginInput), bindBare(&Handlers::endInput)); // .input | |
| 18 | +doSetup("filename", bindSetup(&Handlers::setupInputFilename)); | |
| 19 | 19 | doSetup("password", bindSetup(&Handlers::setupInputPassword)); |
| 20 | 20 | addParameter("passwordFile", [this](char const* p) { c_main->passwordFile(p); }); |
| 21 | 21 | doSetup("empty", bindSetup(&Handlers::setupInputEmpty)); |
| 22 | 22 | endDict(); // .input |
| 23 | -beginDict("output", bindBare(&Handlers::beginOutput), bindBare(&Handlers::endOutput)); // .output | |
| 24 | -doSetup("fileName", bindSetup(&Handlers::setupOutputFileName)); | |
| 23 | +beginDict("output", bindJSON(&Handlers::beginOutput), bindBare(&Handlers::endOutput)); // .output | |
| 24 | +doSetup("filename", bindSetup(&Handlers::setupOutputFilename)); | |
| 25 | 25 | doSetup("replaceInput", bindSetup(&Handlers::setupOutputReplaceInput)); |
| 26 | -beginDict("options", bindBare(&Handlers::beginOutputOptions), bindBare(&Handlers::endOutputOptions)); // .output.options | |
| 26 | +beginDict("options", bindJSON(&Handlers::beginOutputOptions), bindBare(&Handlers::endOutputOptions)); // .output.options | |
| 27 | 27 | addBare("qdf", [this]() { c_main->qdf(); }); |
| 28 | 28 | addBare("preserveUnreferenced", [this]() { c_main->preserveUnreferenced(); }); |
| 29 | 29 | addBare("newlineBeforeEndstream", [this]() { c_main->newlineBeforeEndstream(); }); |
| ... | ... | @@ -45,17 +45,16 @@ addParameter("minVersion", [this](char const* p) { c_main->minVersion(p); }); |
| 45 | 45 | addParameter("forceVersion", [this](char const* p) { c_main->forceVersion(p); }); |
| 46 | 46 | addBare("progress", [this]() { c_main->progress(); }); |
| 47 | 47 | addParameter("splitPages", [this](char const* p) { c_main->splitPages(p); }); |
| 48 | -beginDict("encrypt", bindBare(&Handlers::beginOutputOptionsEncrypt), bindBare(&Handlers::endOutputOptionsEncrypt)); // .output.options.encrypt | |
| 49 | -doSetup("keyLength", bindSetup(&Handlers::setupOutputOptionsEncryptKeyLength)); | |
| 48 | +beginDict("encrypt", bindJSON(&Handlers::beginOutputOptionsEncrypt), bindBare(&Handlers::endOutputOptionsEncrypt)); // .output.options.encrypt | |
| 50 | 49 | doSetup("userPassword", bindSetup(&Handlers::setupOutputOptionsEncryptUserPassword)); |
| 51 | 50 | doSetup("ownerPassword", bindSetup(&Handlers::setupOutputOptionsEncryptOwnerPassword)); |
| 52 | -beginDict("40Bit", bindBare(&Handlers::beginOutputOptionsEncrypt40Bit), bindBare(&Handlers::endOutputOptionsEncrypt40Bit)); // .output.options.encrypt.40Bit | |
| 51 | +beginDict("40bit", bindJSON(&Handlers::beginOutputOptionsEncrypt40bit), bindBare(&Handlers::endOutputOptionsEncrypt40bit)); // .output.options.encrypt.40bit | |
| 53 | 52 | addChoices("annotate", yn_choices, [this](char const* p) { c_enc->annotate(p); }); |
| 54 | 53 | addChoices("extract", yn_choices, [this](char const* p) { c_enc->extract(p); }); |
| 55 | 54 | addChoices("modify", modify128_choices, [this](char const* p) { c_enc->modify(p); }); |
| 56 | 55 | addChoices("print", print128_choices, [this](char const* p) { c_enc->print(p); }); |
| 57 | -endDict(); // .output.options.encrypt.40Bit | |
| 58 | -beginDict("128Bit", bindBare(&Handlers::beginOutputOptionsEncrypt128Bit), bindBare(&Handlers::endOutputOptionsEncrypt128Bit)); // .output.options.encrypt.128Bit | |
| 56 | +endDict(); // .output.options.encrypt.40bit | |
| 57 | +beginDict("128bit", bindJSON(&Handlers::beginOutputOptionsEncrypt128bit), bindBare(&Handlers::endOutputOptionsEncrypt128bit)); // .output.options.encrypt.128bit | |
| 59 | 58 | addChoices("accessibility", yn_choices, [this](char const* p) { c_enc->accessibility(p); }); |
| 60 | 59 | addChoices("annotate", yn_choices, [this](char const* p) { c_enc->annotate(p); }); |
| 61 | 60 | addChoices("assemble", yn_choices, [this](char const* p) { c_enc->assemble(p); }); |
| ... | ... | @@ -67,8 +66,8 @@ addChoices("modify", modify128_choices, [this](char const* p) { c_enc->modify(p) |
| 67 | 66 | addChoices("print", print128_choices, [this](char const* p) { c_enc->print(p); }); |
| 68 | 67 | addBare("forceV4", [this]() { c_enc->forceV4(); }); |
| 69 | 68 | addChoices("useAes", yn_choices, [this](char const* p) { c_enc->useAes(p); }); |
| 70 | -endDict(); // .output.options.encrypt.128Bit | |
| 71 | -beginDict("256Bit", bindBare(&Handlers::beginOutputOptionsEncrypt256Bit), bindBare(&Handlers::endOutputOptionsEncrypt256Bit)); // .output.options.encrypt.256Bit | |
| 69 | +endDict(); // .output.options.encrypt.128bit | |
| 70 | +beginDict("256bit", bindJSON(&Handlers::beginOutputOptionsEncrypt256bit), bindBare(&Handlers::endOutputOptionsEncrypt256bit)); // .output.options.encrypt.256bit | |
| 72 | 71 | addChoices("accessibility", yn_choices, [this](char const* p) { c_enc->accessibility(p); }); |
| 73 | 72 | addChoices("annotate", yn_choices, [this](char const* p) { c_enc->annotate(p); }); |
| 74 | 73 | addChoices("assemble", yn_choices, [this](char const* p) { c_enc->assemble(p); }); |
| ... | ... | @@ -80,11 +79,11 @@ addChoices("modify", modify128_choices, [this](char const* p) { c_enc->modify(p) |
| 80 | 79 | addChoices("print", print128_choices, [this](char const* p) { c_enc->print(p); }); |
| 81 | 80 | addBare("allowInsecure", [this]() { c_enc->allowInsecure(); }); |
| 82 | 81 | addBare("forceR5", [this]() { c_enc->forceR5(); }); |
| 83 | -endDict(); // .output.options.encrypt.256Bit | |
| 82 | +endDict(); // .output.options.encrypt.256bit | |
| 84 | 83 | endDict(); // .output.options.encrypt |
| 85 | 84 | endDict(); // .output.options |
| 86 | 85 | endDict(); // .output |
| 87 | -beginDict("options", bindBare(&Handlers::beginOptions), bindBare(&Handlers::endOptions)); // .options | |
| 86 | +beginDict("options", bindJSON(&Handlers::beginOptions), bindBare(&Handlers::endOptions)); // .options | |
| 88 | 87 | addBare("allowWeakCrypto", [this]() { c_main->allowWeakCrypto(); }); |
| 89 | 88 | addBare("deterministicId", [this]() { c_main->deterministicId(); }); |
| 90 | 89 | addChoices("keepFilesOpen", yn_choices, [this](char const* p) { c_main->keepFilesOpen(p); }); |
| ... | ... | @@ -98,7 +97,7 @@ addChoices("passwordMode", password_mode_choices, [this](char const* p) { c_main |
| 98 | 97 | addBare("suppressPasswordRecovery", [this]() { c_main->suppressPasswordRecovery(); }); |
| 99 | 98 | addBare("suppressRecovery", [this]() { c_main->suppressRecovery(); }); |
| 100 | 99 | endDict(); // .options |
| 101 | -beginDict("inspect", bindBare(&Handlers::beginInspect), bindBare(&Handlers::endInspect)); // .inspect | |
| 100 | +beginDict("inspect", bindJSON(&Handlers::beginInspect), bindBare(&Handlers::endInspect)); // .inspect | |
| 102 | 101 | addBare("check", [this]() { c_main->check(); }); |
| 103 | 102 | addBare("checkLinearization", [this]() { c_main->checkLinearization(); }); |
| 104 | 103 | addBare("filteredStreamData", [this]() { c_main->filteredStreamData(); }); |
| ... | ... | @@ -119,15 +118,15 @@ addBare("json", [this]() { c_main->json(); }); |
| 119 | 118 | addChoices("jsonKey", json_key_choices, [this](char const* p) { c_main->jsonKey(p); }); |
| 120 | 119 | addParameter("jsonObject", [this](char const* p) { c_main->jsonObject(p); }); |
| 121 | 120 | endDict(); // .inspect |
| 122 | -beginDict("transform", bindBare(&Handlers::beginTransform), bindBare(&Handlers::endTransform)); // .transform | |
| 121 | +beginDict("transform", bindJSON(&Handlers::beginTransform), bindBare(&Handlers::endTransform)); // .transform | |
| 123 | 122 | addBare("coalesceContents", [this]() { c_main->coalesceContents(); }); |
| 124 | 123 | addParameter("compressionLevel", [this](char const* p) { c_main->compressionLevel(p); }); |
| 125 | 124 | addBare("externalizeInlineImages", [this]() { c_main->externalizeInlineImages(); }); |
| 126 | 125 | addParameter("iiMinBytes", [this](char const* p) { c_main->iiMinBytes(p); }); |
| 127 | 126 | addChoices("removeUnreferencedResources", remove_unref_choices, [this](char const* p) { c_main->removeUnreferencedResources(p); }); |
| 128 | 127 | endDict(); // .transform |
| 129 | -beginDict("modify", bindBare(&Handlers::beginModify), bindBare(&Handlers::endModify)); // .modify | |
| 130 | -beginDict("addAttachment", bindBare(&Handlers::beginModifyAddAttachment), bindBare(&Handlers::endModifyAddAttachment)); // .modify.addAttachment | |
| 128 | +beginDict("modify", bindJSON(&Handlers::beginModify), bindBare(&Handlers::endModify)); // .modify | |
| 129 | +beginDict("addAttachment", bindJSON(&Handlers::beginModifyAddAttachment), bindBare(&Handlers::endModifyAddAttachment)); // .modify.addAttachment | |
| 131 | 130 | doSetup("path", bindSetup(&Handlers::setupModifyAddAttachmentPath)); |
| 132 | 131 | addParameter("creationdate", [this](char const* p) { c_att->creationdate(p); }); |
| 133 | 132 | addParameter("description", [this](char const* p) { c_att->description(p); }); |
| ... | ... | @@ -138,7 +137,7 @@ addParameter("moddate", [this](char const* p) { c_att->moddate(p); }); |
| 138 | 137 | addBare("replace", [this]() { c_att->replace(); }); |
| 139 | 138 | endDict(); // .modify.addAttachment |
| 140 | 139 | addParameter("removeAttachment", [this](char const* p) { c_main->removeAttachment(p); }); |
| 141 | -beginDict("copyAttachmentsFrom", bindBare(&Handlers::beginModifyCopyAttachmentsFrom), bindBare(&Handlers::endModifyCopyAttachmentsFrom)); // .modify.copyAttachmentsFrom | |
| 140 | +beginDict("copyAttachmentsFrom", bindJSON(&Handlers::beginModifyCopyAttachmentsFrom), bindBare(&Handlers::endModifyCopyAttachmentsFrom)); // .modify.copyAttachmentsFrom | |
| 142 | 141 | doSetup("path", bindSetup(&Handlers::setupModifyCopyAttachmentsFromPath)); |
| 143 | 142 | doSetup("password", bindSetup(&Handlers::setupModifyCopyAttachmentsFromPassword)); |
| 144 | 143 | addParameter("prefix", [this](char const* p) { c_copy_att->prefix(p); }); |
| ... | ... | @@ -152,21 +151,21 @@ addParameter("oiMinArea", [this](char const* p) { c_main->oiMinArea(p); }); |
| 152 | 151 | addParameter("oiMinHeight", [this](char const* p) { c_main->oiMinHeight(p); }); |
| 153 | 152 | addParameter("oiMinWidth", [this](char const* p) { c_main->oiMinWidth(p); }); |
| 154 | 153 | addBare("optimizeImages", [this]() { c_main->optimizeImages(); }); |
| 155 | -beginDict("pages", bindBare(&Handlers::beginModifyPages), bindBare(&Handlers::endModifyPages)); // .modify.pages | |
| 154 | +beginDict("pages", bindJSON(&Handlers::beginModifyPages), bindBare(&Handlers::endModifyPages)); // .modify.pages | |
| 156 | 155 | doSetup("file", bindSetup(&Handlers::setupModifyPagesFile)); |
| 157 | 156 | doSetup("password", bindSetup(&Handlers::setupModifyPagesPassword)); |
| 158 | 157 | doSetup("range", bindSetup(&Handlers::setupModifyPagesRange)); |
| 159 | 158 | endDict(); // .modify.pages |
| 160 | 159 | addBare("removePageLabels", [this]() { c_main->removePageLabels(); }); |
| 161 | 160 | addParameter("rotate", [this](char const* p) { c_main->rotate(p); }); |
| 162 | -beginDict("overlay", bindBare(&Handlers::beginModifyOverlay), bindBare(&Handlers::endModifyOverlay)); // .modify.overlay | |
| 161 | +beginDict("overlay", bindJSON(&Handlers::beginModifyOverlay), bindBare(&Handlers::endModifyOverlay)); // .modify.overlay | |
| 163 | 162 | doSetup("file", bindSetup(&Handlers::setupModifyOverlayFile)); |
| 164 | 163 | doSetup("password", bindSetup(&Handlers::setupModifyOverlayPassword)); |
| 165 | 164 | addParameter("from", [this](char const* p) { c_uo->from(p); }); |
| 166 | 165 | addParameter("repeat", [this](char const* p) { c_uo->repeat(p); }); |
| 167 | 166 | addParameter("to", [this](char const* p) { c_uo->to(p); }); |
| 168 | 167 | endDict(); // .modify.overlay |
| 169 | -beginDict("underlay", bindBare(&Handlers::beginModifyUnderlay), bindBare(&Handlers::endModifyUnderlay)); // .modify.underlay | |
| 168 | +beginDict("underlay", bindJSON(&Handlers::beginModifyUnderlay), bindBare(&Handlers::endModifyUnderlay)); // .modify.underlay | |
| 170 | 169 | doSetup("file", bindSetup(&Handlers::setupModifyUnderlayFile)); |
| 171 | 170 | doSetup("password", bindSetup(&Handlers::setupModifyUnderlayPassword)); |
| 172 | 171 | addParameter("from", [this](char const* p) { c_uo->from(p); }); | ... | ... |
libqpdf/qpdf/auto_job_schema.hh
| 1 | 1 | static constexpr char const* JOB_SCHEMA_DATA = R"({ |
| 2 | 2 | "input": { |
| 3 | - "fileName": "input filename", | |
| 3 | + "filename": "input filename", | |
| 4 | 4 | "password": "specify password", |
| 5 | 5 | "passwordFile": "read password from a file", |
| 6 | 6 | "empty": "empty input file" |
| 7 | 7 | }, |
| 8 | 8 | "output": { |
| 9 | - "fileName": "output filename", | |
| 9 | + "filename": "output filename", | |
| 10 | 10 | "replaceInput": "set to true to replace input", |
| 11 | 11 | "options": { |
| 12 | 12 | "qdf": "enable viewing PDF code in a text editor", |
| ... | ... | @@ -31,16 +31,15 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({ |
| 31 | 31 | "progress": "show progress when writing", |
| 32 | 32 | "splitPages": "write pages to separate files", |
| 33 | 33 | "encrypt": { |
| 34 | - "keyLength": "key length: 48, 128, 256", | |
| 35 | 34 | "userPassword": "user password", |
| 36 | 35 | "ownerPassword": "owner password", |
| 37 | - "40Bit": { | |
| 36 | + "40bit": { | |
| 38 | 37 | "annotate": "restrict document annotation", |
| 39 | 38 | "extract": "restrict text/graphic extraction", |
| 40 | 39 | "modify": "restrict document modification", |
| 41 | 40 | "print": "restrict printing" |
| 42 | 41 | }, |
| 43 | - "128Bit": { | |
| 42 | + "128bit": { | |
| 44 | 43 | "accessibility": "restrict document accessibility", |
| 45 | 44 | "annotate": "restrict document annotation", |
| 46 | 45 | "assemble": "restrict document assembly", |
| ... | ... | @@ -53,7 +52,7 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({ |
| 53 | 52 | "forceV4": "force V=4 in encryption dictionary", |
| 54 | 53 | "useAes": "use AES with 128-bit encryption" |
| 55 | 54 | }, |
| 56 | - "256Bit": { | |
| 55 | + "256bit": { | |
| 57 | 56 | "accessibility": "restrict document accessibility", |
| 58 | 57 | "annotate": "restrict document annotation", |
| 59 | 58 | "assemble": "restrict document assembly", | ... | ... |