Commit b02d37bc0ae0b7af6077637f855be8579c768c22

Authored by Jay Berkenbilt
1 parent bc4e2320

Make QPDFArgParser accept const argv

This makes it much more convention to use the initializeFromArgv
functions since you can use string literals.
generate_auto_job
@@ -111,13 +111,14 @@ from contextlib import contextmanager @@ -111,13 +111,14 @@ from contextlib import contextmanager
111 # Every command-line option in the main option table has a 111 # Every command-line option in the main option table has a
112 # corresponding method in Config whose name is the option converted to 112 # corresponding method in Config whose name is the option converted to
113 # camel case. For bare options and options with optional parameters, a 113 # camel case. For bare options and options with optional parameters, a
114 -# version exists that takes no arguments. For others, a version exists  
115 -# that takes a char const*. For example, the --qdf flag implies a  
116 -# qdf() method in Config, and the --object-streams flag implies an  
117 -# objectStreams(char const*) method in Config. For flags in option  
118 -# tables, the method is declared inside a config class specific to the  
119 -# option table. The mapping between option tables and config classes  
120 -# is explicit in job.yml. Positional arguments are handled 114 +# version exists that takes no arguments. For other than bare options,
  115 +# a version exist, possibly in addition, that takes a std::string
  116 +# const&. For example, the --qdf flag implies a qdf() method in
  117 +# Config, and the --object-streams flag implies an
  118 +# objectStreams(std::string const&) method in Config. For flags in
  119 +# option tables, the method is declared inside a config class specific
  120 +# to the option table. The mapping between option tables and config
  121 +# classes is explicit in job.yml. Positional arguments are handled
121 # individually and manually -- see QPDFJob.hh in the CONFIGURATION 122 # individually and manually -- see QPDFJob.hh in the CONFIGURATION
122 # section for details. See examples/qpdf-job.cc for an example. 123 # section for details. See examples/qpdf-job.cc for an example.
123 # 124 #
@@ -460,29 +461,33 @@ class Main: @@ -460,29 +461,33 @@ class Main:
460 self.init.append(f'this->ap.addBare("{i}", ' 461 self.init.append(f'this->ap.addBare("{i}", '
461 f'[this](){{{cfg}->{identifier}();}});') 462 f'[this](){{{cfg}->{identifier}();}});')
462 elif kind == 'required_parameter': 463 elif kind == 'required_parameter':
463 - self.init.append(f'this->ap.addRequiredParameter("{i}", '  
464 - f'[this](char *x){{{cfg}->{identifier}(x);}}'  
465 - f', "{v}");') 464 + self.init.append(
  465 + f'this->ap.addRequiredParameter("{i}", '
  466 + f'[this](std::string const& x){{{cfg}->{identifier}(x);}}'
  467 + f', "{v}");')
466 elif kind == 'optional_parameter': 468 elif kind == 'optional_parameter':
467 decl_arg_optional = True 469 decl_arg_optional = True
468 - self.init.append(f'this->ap.addOptionalParameter("{i}", '  
469 - f'[this](char *x){{{cfg}->{identifier}(x);}});') 470 + self.init.append(
  471 + f'this->ap.addOptionalParameter("{i}", '
  472 + f'[this](std::string const& x){{{cfg}->{identifier}(x);}});')
470 elif kind == 'required_choices': 473 elif kind == 'required_choices':
471 - self.init.append(f'this->ap.addChoices("{i}", '  
472 - f'[this](char *x){{{cfg}->{identifier}(x);}}'  
473 - f', true, {v}_choices);') 474 + self.init.append(
  475 + f'this->ap.addChoices("{i}", '
  476 + f'[this](std::string const& x){{{cfg}->{identifier}(x);}}'
  477 + f', true, {v}_choices);')
474 elif kind == 'optional_choices': 478 elif kind == 'optional_choices':
475 decl_arg_optional = True 479 decl_arg_optional = True
476 - self.init.append(f'this->ap.addChoices("{i}", '  
477 - f'[this](char *x){{{cfg}->{identifier}(x);}}'  
478 - f', false, {v}_choices);') 480 + self.init.append(
  481 + f'this->ap.addChoices("{i}", '
  482 + f'[this](std::string const& x){{{cfg}->{identifier}(x);}}'
  483 + f', false, {v}_choices);')
479 484
480 # Generate declarations for config methods separately by 485 # Generate declarations for config methods separately by
481 # config object. 486 # config object.
482 config_prefix = prefix + 'Config' 487 config_prefix = prefix + 'Config'
483 arg = '' 488 arg = ''
484 if decl_arg: 489 if decl_arg:
485 - arg = 'char const* parameter' 490 + arg = 'std::string const& parameter'
486 fn = f'{config_prefix}* {identifier}({arg})' 491 fn = f'{config_prefix}* {identifier}({arg})'
487 if fn not in self.declared_configs: 492 if fn not in self.declared_configs:
488 self.declared_configs.add(fn) 493 self.declared_configs.add(fn)
@@ -510,21 +515,21 @@ class Main: @@ -510,21 +515,21 @@ class Main:
510 self.init.append(f'this->ap.addBare("{i}", ' 515 self.init.append(f'this->ap.addBare("{i}", '
511 f'b(&ArgParser::{identifier}));') 516 f'b(&ArgParser::{identifier}));')
512 elif kind == 'required_parameter': 517 elif kind == 'required_parameter':
513 - self.decls.append(f'void {identifier}(char *);') 518 + self.decls.append(f'void {identifier}(std::string const&);')
514 self.init.append(f'this->ap.addRequiredParameter("{i}", ' 519 self.init.append(f'this->ap.addRequiredParameter("{i}", '
515 f'p(&ArgParser::{identifier})' 520 f'p(&ArgParser::{identifier})'
516 f', "{v}");') 521 f', "{v}");')
517 elif kind == 'optional_parameter': 522 elif kind == 'optional_parameter':
518 - self.decls.append(f'void {identifier}(char *);') 523 + self.decls.append(f'void {identifier}(std::string const&);')
519 self.init.append(f'this->ap.addOptionalParameter("{i}", ' 524 self.init.append(f'this->ap.addOptionalParameter("{i}", '
520 f'p(&ArgParser::{identifier}));') 525 f'p(&ArgParser::{identifier}));')
521 elif kind == 'required_choices': 526 elif kind == 'required_choices':
522 - self.decls.append(f'void {identifier}(char *);') 527 + self.decls.append(f'void {identifier}(std::string const&);')
523 self.init.append(f'this->ap.addChoices("{i}", ' 528 self.init.append(f'this->ap.addChoices("{i}", '
524 f'p(&ArgParser::{identifier})' 529 f'p(&ArgParser::{identifier})'
525 f', true, {v}_choices);') 530 f', true, {v}_choices);')
526 elif kind == 'optional_choices': 531 elif kind == 'optional_choices':
527 - self.decls.append(f'void {identifier}(char *);') 532 + self.decls.append(f'void {identifier}(std::string const&);')
528 self.init.append(f'this->ap.addChoices("{i}", ' 533 self.init.append(f'this->ap.addChoices("{i}", '
529 f'p(&ArgParser::{identifier})' 534 f'p(&ArgParser::{identifier})'
530 f', false, {v}_choices);') 535 f', false, {v}_choices);')
@@ -555,7 +560,8 @@ class Main: @@ -555,7 +560,8 @@ class Main:
555 self.init.append('auto b = [this](void (ArgParser::*f)()) {') 560 self.init.append('auto b = [this](void (ArgParser::*f)()) {')
556 self.init.append(' return QPDFArgParser::bindBare(f, this);') 561 self.init.append(' return QPDFArgParser::bindBare(f, this);')
557 self.init.append('};') 562 self.init.append('};')
558 - self.init.append('auto p = [this](void (ArgParser::*f)(char *)) {') 563 + self.init.append(
  564 + 'auto p = [this](void (ArgParser::*f)(std::string const&)) {')
559 self.init.append(' return QPDFArgParser::bindParam(f, this);') 565 self.init.append(' return QPDFArgParser::bindParam(f, this);')
560 self.init.append('};') 566 self.init.append('};')
561 self.init.append('') 567 self.init.append('')
@@ -615,7 +621,8 @@ class Main: @@ -615,7 +621,8 @@ class Main:
615 self.init.append(f'this->ap.registerOptionTable("{table}",' 621 self.init.append(f'this->ap.registerOptionTable("{table}",'
616 f' b(&ArgParser::{identifier}));') 622 f' b(&ArgParser::{identifier}));')
617 if o.get('positional', False): 623 if o.get('positional', False):
618 - self.decls.append(f'void {arg_prefix}Positional(char*);') 624 + self.decls.append(
  625 + f'void {arg_prefix}Positional(std::string const&);')
619 self.init.append('this->ap.addPositional(' 626 self.init.append('this->ap.addPositional('
620 f'p(&ArgParser::{arg_prefix}Positional));') 627 f'p(&ArgParser::{arg_prefix}Positional));')
621 628
@@ -667,16 +674,18 @@ class Main: @@ -667,16 +674,18 @@ class Main:
667 # so the handler has to deal with it. The empty string is 674 # so the handler has to deal with it. The empty string is
668 # also allowed for non-optional. 675 # also allowed for non-optional.
669 self.json_init.append( 676 self.json_init.append(
670 - f'addParameter([this](char const* p)' 677 + f'addParameter([this](std::string const& p)'
671 f' {{ {config}->{flag_key}(p); }});') 678 f' {{ {config}->{flag_key}(p); }});')
672 elif kind == 'required_choices': 679 elif kind == 'required_choices':
673 self.json_init.append( 680 self.json_init.append(
674 f'addChoices({v}_choices, true,' 681 f'addChoices({v}_choices, true,'
675 - f' [this](char const* p) {{ {config}->{flag_key}(p); }});') 682 + f' [this](std::string const& p)'
  683 + f' {{ {config}->{flag_key}(p); }});')
676 elif kind == 'optional_choices': 684 elif kind == 'optional_choices':
677 self.json_init.append( 685 self.json_init.append(
678 f'addChoices({v}_choices, false,' 686 f'addChoices({v}_choices, false,'
679 - f' [this](char const* p) {{ {config}->{flag_key}(p); }});') 687 + f' [this](std::string const& p)'
  688 + f' {{ {config}->{flag_key}(p); }});')
680 689
681 def handle_json_manual(self, path): 690 def handle_json_manual(self, path):
682 method = re.sub(r'\.([a-zA-Z0-9])', 691 method = re.sub(r'\.([a-zA-Z0-9])',
include/qpdf/QPDFJob.hh
@@ -77,7 +77,7 @@ class QPDFJob @@ -77,7 +77,7 @@ class QPDFJob
77 // arguments to UTF-8. This method will mutate arguments that are 77 // arguments to UTF-8. This method will mutate arguments that are
78 // passed to it. 78 // passed to it.
79 QPDF_DLL 79 QPDF_DLL
80 - void initializeFromArgv(int argc, char* argv[], 80 + void initializeFromArgv(int argc, char const* const argv[],
81 char const* progname_env = nullptr); 81 char const* progname_env = nullptr);
82 82
83 // Initialize a QPDFJob from json. Passing partial = true prevents 83 // Initialize a QPDFJob from json. Passing partial = true prevents
@@ -205,7 +205,7 @@ class QPDFJob @@ -205,7 +205,7 @@ class QPDFJob
205 QPDF_DLL 205 QPDF_DLL
206 Config* endAddAttachment(); 206 Config* endAddAttachment();
207 QPDF_DLL 207 QPDF_DLL
208 - AttConfig* file(char const* parameter); 208 + AttConfig* file(std::string const& parameter);
209 209
210 # include <qpdf/auto_job_c_att.hh> 210 # include <qpdf/auto_job_c_att.hh>
211 211
@@ -225,7 +225,7 @@ class QPDFJob @@ -225,7 +225,7 @@ class QPDFJob
225 QPDF_DLL 225 QPDF_DLL
226 Config* endCopyAttachmentsFrom(); 226 Config* endCopyAttachmentsFrom();
227 QPDF_DLL 227 QPDF_DLL
228 - CopyAttConfig* file(char const* parameter); 228 + CopyAttConfig* file(std::string const& parameter);
229 229
230 # include <qpdf/auto_job_c_copy_att.hh> 230 # include <qpdf/auto_job_c_copy_att.hh>
231 231
@@ -266,7 +266,7 @@ class QPDFJob @@ -266,7 +266,7 @@ class QPDFJob
266 QPDF_DLL 266 QPDF_DLL
267 Config* endUnderlayOverlay(); 267 Config* endUnderlayOverlay();
268 QPDF_DLL 268 QPDF_DLL
269 - UOConfig* file(char const* parameter); 269 + UOConfig* file(std::string const& parameter);
270 270
271 # include <qpdf/auto_job_c_uo.hh> 271 # include <qpdf/auto_job_c_uo.hh>
272 272
@@ -285,7 +285,7 @@ class QPDFJob @@ -285,7 +285,7 @@ class QPDFJob
285 QPDF_DLL 285 QPDF_DLL
286 Config* endEncrypt(); 286 Config* endEncrypt();
287 QPDF_DLL 287 QPDF_DLL
288 - EncConfig* file(char const* parameter); 288 + EncConfig* file(std::string const& parameter);
289 289
290 # include <qpdf/auto_job_c_enc.hh> 290 # include <qpdf/auto_job_c_enc.hh>
291 291
@@ -305,11 +305,11 @@ class QPDFJob @@ -305,11 +305,11 @@ class QPDFJob
305 void checkConfiguration(); 305 void checkConfiguration();
306 306
307 QPDF_DLL 307 QPDF_DLL
308 - Config* inputFile(char const* filename); 308 + Config* inputFile(std::string const& filename);
309 QPDF_DLL 309 QPDF_DLL
310 Config* emptyInput(); 310 Config* emptyInput();
311 QPDF_DLL 311 QPDF_DLL
312 - Config* outputFile(char const* filename); 312 + Config* outputFile(std::string const& filename);
313 QPDF_DLL 313 QPDF_DLL
314 Config* replaceInput(); 314 Config* replaceInput();
315 315
include/qpdf/QUtil.hh
@@ -435,8 +435,13 @@ namespace QUtil @@ -435,8 +435,13 @@ namespace QUtil
435 // invoked, convert all UTF-16 encoded strings to UTF-8, and call 435 // invoked, convert all UTF-16 encoded strings to UTF-8, and call
436 // another main. 436 // another main.
437 QPDF_DLL 437 QPDF_DLL
438 - int call_main_from_wmain(int argc, wchar_t* argv[],  
439 - std::function<int(int, char*[])> realmain); 438 + int call_main_from_wmain(
  439 + int argc, wchar_t* argv[],
  440 + std::function<int(int, char*[])> realmain);
  441 + QPDF_DLL
  442 + int call_main_from_wmain(
  443 + int argc, wchar_t const* const argv[],
  444 + std::function<int(int, char const* const[])> realmain);
440 #endif // QPDF_NO_WCHAR_T 445 #endif // QPDF_NO_WCHAR_T
441 }; 446 };
442 447
include/qpdf/auto_job_c_att.hh
@@ -4,9 +4,9 @@ @@ -4,9 +4,9 @@
4 // run in maintainer mode. 4 // run in maintainer mode.
5 // 5 //
6 QPDF_DLL AttConfig* replace(); 6 QPDF_DLL AttConfig* replace();
7 -QPDF_DLL AttConfig* key(char const* parameter);  
8 -QPDF_DLL AttConfig* filename(char const* parameter);  
9 -QPDF_DLL AttConfig* creationdate(char const* parameter);  
10 -QPDF_DLL AttConfig* moddate(char const* parameter);  
11 -QPDF_DLL AttConfig* mimetype(char const* parameter);  
12 -QPDF_DLL AttConfig* description(char const* parameter); 7 +QPDF_DLL AttConfig* key(std::string const& parameter);
  8 +QPDF_DLL AttConfig* filename(std::string const& parameter);
  9 +QPDF_DLL AttConfig* creationdate(std::string const& parameter);
  10 +QPDF_DLL AttConfig* moddate(std::string const& parameter);
  11 +QPDF_DLL AttConfig* mimetype(std::string const& parameter);
  12 +QPDF_DLL AttConfig* description(std::string const& parameter);
include/qpdf/auto_job_c_copy_att.hh
@@ -3,5 +3,5 @@ @@ -3,5 +3,5 @@
3 // Edits will be automatically overwritten if the build is 3 // Edits will be automatically overwritten if the build is
4 // run in maintainer mode. 4 // run in maintainer mode.
5 // 5 //
6 -QPDF_DLL CopyAttConfig* prefix(char const* parameter);  
7 -QPDF_DLL CopyAttConfig* password(char const* parameter); 6 +QPDF_DLL CopyAttConfig* prefix(std::string const& parameter);
  7 +QPDF_DLL CopyAttConfig* password(std::string const& parameter);
include/qpdf/auto_job_c_enc.hh
@@ -3,16 +3,16 @@ @@ -3,16 +3,16 @@
3 // Edits will be automatically overwritten if the build is 3 // Edits will be automatically overwritten if the build is
4 // run in maintainer mode. 4 // run in maintainer mode.
5 // 5 //
6 -QPDF_DLL EncConfig* extract(char const* parameter);  
7 -QPDF_DLL EncConfig* annotate(char const* parameter);  
8 -QPDF_DLL EncConfig* print(char const* parameter);  
9 -QPDF_DLL EncConfig* modify(char const* parameter); 6 +QPDF_DLL EncConfig* extract(std::string const& parameter);
  7 +QPDF_DLL EncConfig* annotate(std::string const& parameter);
  8 +QPDF_DLL EncConfig* print(std::string const& parameter);
  9 +QPDF_DLL EncConfig* modify(std::string const& parameter);
10 QPDF_DLL EncConfig* cleartextMetadata(); 10 QPDF_DLL EncConfig* cleartextMetadata();
11 QPDF_DLL EncConfig* forceV4(); 11 QPDF_DLL EncConfig* forceV4();
12 -QPDF_DLL EncConfig* accessibility(char const* parameter);  
13 -QPDF_DLL EncConfig* assemble(char const* parameter);  
14 -QPDF_DLL EncConfig* form(char const* parameter);  
15 -QPDF_DLL EncConfig* modifyOther(char const* parameter);  
16 -QPDF_DLL EncConfig* useAes(char const* parameter); 12 +QPDF_DLL EncConfig* accessibility(std::string const& parameter);
  13 +QPDF_DLL EncConfig* assemble(std::string const& parameter);
  14 +QPDF_DLL EncConfig* form(std::string const& parameter);
  15 +QPDF_DLL EncConfig* modifyOther(std::string const& parameter);
  16 +QPDF_DLL EncConfig* useAes(std::string const& parameter);
17 QPDF_DLL EncConfig* forceR5(); 17 QPDF_DLL EncConfig* forceR5();
18 QPDF_DLL EncConfig* allowInsecure(); 18 QPDF_DLL EncConfig* allowInsecure();
include/qpdf/auto_job_c_main.hh
@@ -44,38 +44,38 @@ QPDF_DLL Config* suppressRecovery(); @@ -44,38 +44,38 @@ QPDF_DLL Config* suppressRecovery();
44 QPDF_DLL Config* verbose(); 44 QPDF_DLL Config* verbose();
45 QPDF_DLL Config* warningExit0(); 45 QPDF_DLL Config* warningExit0();
46 QPDF_DLL Config* withImages(); 46 QPDF_DLL Config* withImages();
47 -QPDF_DLL Config* compressionLevel(char const* parameter);  
48 -QPDF_DLL Config* copyEncryption(char const* parameter);  
49 -QPDF_DLL Config* encryptionFilePassword(char const* parameter);  
50 -QPDF_DLL Config* forceVersion(char const* parameter);  
51 -QPDF_DLL Config* iiMinBytes(char const* parameter);  
52 -QPDF_DLL Config* jobJsonFile(char const* parameter);  
53 -QPDF_DLL Config* jsonObject(char const* parameter);  
54 -QPDF_DLL Config* keepFilesOpenThreshold(char const* parameter);  
55 -QPDF_DLL Config* linearizePass1(char const* parameter);  
56 -QPDF_DLL Config* minVersion(char const* parameter);  
57 -QPDF_DLL Config* oiMinArea(char const* parameter);  
58 -QPDF_DLL Config* oiMinHeight(char const* parameter);  
59 -QPDF_DLL Config* oiMinWidth(char const* parameter);  
60 -QPDF_DLL Config* password(char const* parameter);  
61 -QPDF_DLL Config* passwordFile(char const* parameter);  
62 -QPDF_DLL Config* removeAttachment(char const* parameter);  
63 -QPDF_DLL Config* rotate(char const* parameter);  
64 -QPDF_DLL Config* showAttachment(char const* parameter);  
65 -QPDF_DLL Config* showObject(char const* parameter);  
66 -QPDF_DLL Config* collate(char const* parameter); 47 +QPDF_DLL Config* compressionLevel(std::string const& parameter);
  48 +QPDF_DLL Config* copyEncryption(std::string const& parameter);
  49 +QPDF_DLL Config* encryptionFilePassword(std::string const& parameter);
  50 +QPDF_DLL Config* forceVersion(std::string const& parameter);
  51 +QPDF_DLL Config* iiMinBytes(std::string const& parameter);
  52 +QPDF_DLL Config* jobJsonFile(std::string const& parameter);
  53 +QPDF_DLL Config* jsonObject(std::string const& parameter);
  54 +QPDF_DLL Config* keepFilesOpenThreshold(std::string const& parameter);
  55 +QPDF_DLL Config* linearizePass1(std::string const& parameter);
  56 +QPDF_DLL Config* minVersion(std::string const& parameter);
  57 +QPDF_DLL Config* oiMinArea(std::string const& parameter);
  58 +QPDF_DLL Config* oiMinHeight(std::string const& parameter);
  59 +QPDF_DLL Config* oiMinWidth(std::string const& parameter);
  60 +QPDF_DLL Config* password(std::string const& parameter);
  61 +QPDF_DLL Config* passwordFile(std::string const& parameter);
  62 +QPDF_DLL Config* removeAttachment(std::string const& parameter);
  63 +QPDF_DLL Config* rotate(std::string const& parameter);
  64 +QPDF_DLL Config* showAttachment(std::string const& parameter);
  65 +QPDF_DLL Config* showObject(std::string const& parameter);
  66 +QPDF_DLL Config* collate(std::string const& parameter);
67 QPDF_DLL Config* collate(); 67 QPDF_DLL Config* collate();
68 -QPDF_DLL Config* splitPages(char const* parameter); 68 +QPDF_DLL Config* splitPages(std::string const& parameter);
69 QPDF_DLL Config* splitPages(); 69 QPDF_DLL Config* splitPages();
70 -QPDF_DLL Config* compressStreams(char const* parameter);  
71 -QPDF_DLL Config* decodeLevel(char const* parameter);  
72 -QPDF_DLL Config* flattenAnnotations(char const* parameter);  
73 -QPDF_DLL Config* jsonKey(char const* parameter);  
74 -QPDF_DLL Config* keepFilesOpen(char const* parameter);  
75 -QPDF_DLL Config* normalizeContent(char const* parameter);  
76 -QPDF_DLL Config* objectStreams(char const* parameter);  
77 -QPDF_DLL Config* passwordMode(char const* parameter);  
78 -QPDF_DLL Config* removeUnreferencedResources(char const* parameter);  
79 -QPDF_DLL Config* streamData(char const* parameter);  
80 -QPDF_DLL Config* json(char const* parameter); 70 +QPDF_DLL Config* compressStreams(std::string const& parameter);
  71 +QPDF_DLL Config* decodeLevel(std::string const& parameter);
  72 +QPDF_DLL Config* flattenAnnotations(std::string const& parameter);
  73 +QPDF_DLL Config* jsonKey(std::string const& parameter);
  74 +QPDF_DLL Config* keepFilesOpen(std::string const& parameter);
  75 +QPDF_DLL Config* normalizeContent(std::string const& parameter);
  76 +QPDF_DLL Config* objectStreams(std::string const& parameter);
  77 +QPDF_DLL Config* passwordMode(std::string const& parameter);
  78 +QPDF_DLL Config* removeUnreferencedResources(std::string const& parameter);
  79 +QPDF_DLL Config* streamData(std::string const& parameter);
  80 +QPDF_DLL Config* json(std::string const& parameter);
81 QPDF_DLL Config* json(); 81 QPDF_DLL Config* json();
include/qpdf/auto_job_c_uo.hh
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 // Edits will be automatically overwritten if the build is 3 // Edits will be automatically overwritten if the build is
4 // run in maintainer mode. 4 // run in maintainer mode.
5 // 5 //
6 -QPDF_DLL UOConfig* to(char const* parameter);  
7 -QPDF_DLL UOConfig* from(char const* parameter);  
8 -QPDF_DLL UOConfig* repeat(char const* parameter);  
9 -QPDF_DLL UOConfig* password(char const* parameter); 6 +QPDF_DLL UOConfig* to(std::string const& parameter);
  7 +QPDF_DLL UOConfig* from(std::string const& parameter);
  8 +QPDF_DLL UOConfig* repeat(std::string const& parameter);
  9 +QPDF_DLL UOConfig* password(std::string const& parameter);
include/qpdf/qpdfjob-c.h
@@ -52,7 +52,7 @@ extern &quot;C&quot; { @@ -52,7 +52,7 @@ extern &quot;C&quot; {
52 * qpdfjob_run_from_wide_argv instead. 52 * qpdfjob_run_from_wide_argv instead.
53 */ 53 */
54 QPDF_DLL 54 QPDF_DLL
55 - int qpdfjob_run_from_argv(int argc, char* argv[]); 55 + int qpdfjob_run_from_argv(int argc, char const* const argv[]);
56 56
57 #ifndef QPDF_NO_WCHAR_T 57 #ifndef QPDF_NO_WCHAR_T
58 /* This function is the same as qpdfjob_run_from_argv except argv 58 /* This function is the same as qpdfjob_run_from_argv except argv
@@ -60,7 +60,7 @@ extern &quot;C&quot; { @@ -60,7 +60,7 @@ extern &quot;C&quot; {
60 * calling from a Windows wmain function. 60 * calling from a Windows wmain function.
61 */ 61 */
62 QPDF_DLL 62 QPDF_DLL
63 - int qpdfjob_run_from_wide_argv(int argc, wchar_t* argv[]); 63 + int qpdfjob_run_from_wide_argv(int argc, wchar_t const* const argv[]);
64 #endif /* QPDF_NO_WCHAR_T */ 64 #endif /* QPDF_NO_WCHAR_T */
65 65
66 /* This function runs QPDFJob from a job JSON file. See the "QPDF 66 /* This function runs QPDFJob from a job JSON file. See the "QPDF
job.sums
1 # Generated by generate_auto_job 1 # Generated by generate_auto_job
2 -generate_auto_job 5d6ec1e4f0b94d8f73df665061d8a2188cbbe8f25ea42be78ec576547261d5ac  
3 -include/qpdf/auto_job_c_att.hh 7ad43bb374c1370ef32ebdcdcb7b73a61d281f7f4e3f12755585872ab30fb60e  
4 -include/qpdf/auto_job_c_copy_att.hh 32275d03cdc69b703dd7e02ba0bbe15756e714e9ad185484773a6178dc09e1ee  
5 -include/qpdf/auto_job_c_enc.hh 72e138c7b96ed5aacdce78c1dec04b1c20d361faec4f8faf52f64c1d6be99265  
6 -include/qpdf/auto_job_c_main.hh 69d5ea26098bcb6ec5b5e37ba0bca9e7d16a784d2618e0c05d635046848d5123 2 +generate_auto_job e7c7b33330d398552de77b369abbda5299f1a6aa66034bbeef47be61e2363091
  3 +include/qpdf/auto_job_c_att.hh 1f5d589ccf6684b09a203da261c31fc90a866e6eefe906b673e2d6d5a08ef753
  4 +include/qpdf/auto_job_c_copy_att.hh 65bdce5382a60f1815214297cf005072f17556ec4a15317b600f9ecc9cb89ea4
  5 +include/qpdf/auto_job_c_enc.hh 37ca99a124a34bb613f154c6c8934761bd7e7cc5a2719798ccec7edf05b4aeb9
  6 +include/qpdf/auto_job_c_main.hh 1130a203a513659fbfdd3ab8e435779e402d4f519a11f572ab421b8e937f1d7a
7 include/qpdf/auto_job_c_pages.hh 931840b329a36ca0e41401190e04537b47f2867671a6643bfd8da74014202671 7 include/qpdf/auto_job_c_pages.hh 931840b329a36ca0e41401190e04537b47f2867671a6643bfd8da74014202671
8 -include/qpdf/auto_job_c_uo.hh 0585b7de459fa479d9e51a45fa92de0ff6dee748efc9ec1cedd0dde6cee1ad50 8 +include/qpdf/auto_job_c_uo.hh 4a1148f815a5d0833d2c519dac940be34825294c8c26f77da65e48fdc75f178e
9 job.yml 9544c6e046b25d3274731fbcd07ba25b300fd67055021ac4364ad8a91f77c6b6 9 job.yml 9544c6e046b25d3274731fbcd07ba25b300fd67055021ac4364ad8a91f77c6b6
10 -libqpdf/qpdf/auto_job_decl.hh 9f79396ec459f191be4c5fe34cf88c265cf47355a1a945fa39169d1c94cf04f6 10 +libqpdf/qpdf/auto_job_decl.hh c15c5c4f25f32a8086d579fc40d64326467a74a08209b8fbccf9f996ca2970ab
11 libqpdf/qpdf/auto_job_help.hh 43184f01816b5210bbc981de8de48446546fb94f4fd6e63cfc7f2fbac3578e6b 11 libqpdf/qpdf/auto_job_help.hh 43184f01816b5210bbc981de8de48446546fb94f4fd6e63cfc7f2fbac3578e6b
12 -libqpdf/qpdf/auto_job_init.hh fd13b9f730e6275a39a15d193bd9af19cf37f4495699ec1886c2b208d7811ab1 12 +libqpdf/qpdf/auto_job_init.hh 4d6c4641347e9ee9ea8d057a37d008c9f0f73484c6a04eb879b7a2f8889828bd
13 libqpdf/qpdf/auto_job_json_decl.hh c5e3fd38a3b0c569eb0c6b4c60953a09cd6bc7d3361a357a81f64fe36af2b0cf 13 libqpdf/qpdf/auto_job_json_decl.hh c5e3fd38a3b0c569eb0c6b4c60953a09cd6bc7d3361a357a81f64fe36af2b0cf
14 -libqpdf/qpdf/auto_job_json_init.hh 3f86ce40931ca8f417d050fcd49104d73c1fa4e977ad19d54b372831a8ea17ed 14 +libqpdf/qpdf/auto_job_json_init.hh b070350d304d137ba594c1ba40b373137e8459735f04b8ca0f8a2ffd1908c69e
15 libqpdf/qpdf/auto_job_schema.hh 18a3780671d95224cb9a27dcac627c421cae509d59f33a63e6bda0ab53cce923 15 libqpdf/qpdf/auto_job_schema.hh 18a3780671d95224cb9a27dcac627c421cae509d59f33a63e6bda0ab53cce923
16 manual/_ext/qpdf.py e9ac9d6c70642a3d29281ee5ad92ae2422dee8be9306fb8a0bc9dba0ed5e28f3 16 manual/_ext/qpdf.py e9ac9d6c70642a3d29281ee5ad92ae2422dee8be9306fb8a0bc9dba0ed5e28f3
17 manual/cli.rst 3746df6c4f115387cca0d921f25619a6b8407fc10b0e4c9dcf40b0b1656c6f8a 17 manual/cli.rst 3746df6c4f115387cca0d921f25619a6b8407fc10b0e4c9dcf40b0b1656c6f8a
libqpdf/QPDFArgParser.cc
@@ -8,11 +8,10 @@ @@ -8,11 +8,10 @@
8 #include <cstdlib> 8 #include <cstdlib>
9 9
10 QPDFArgParser::Members::Members( 10 QPDFArgParser::Members::Members(
11 - int argc, char* argv[], char const* progname_env) : 11 + int argc, char const* const argv[], char const* progname_env) :
12 12
13 argc(argc), 13 argc(argc),
14 argv(argv), 14 argv(argv),
15 - whoami(QUtil::getWhoami(argv[0])),  
16 progname_env(progname_env), 15 progname_env(progname_env),
17 cur_arg(0), 16 cur_arg(0),
18 bash_completion(false), 17 bash_completion(false),
@@ -20,14 +19,18 @@ QPDFArgParser::Members::Members( @@ -20,14 +19,18 @@ QPDFArgParser::Members::Members(
20 option_table(nullptr), 19 option_table(nullptr),
21 final_check_handler(nullptr) 20 final_check_handler(nullptr)
22 { 21 {
  22 + auto tmp = QUtil::make_shared_cstr(argv[0]);
  23 + char* p = QUtil::getWhoami(tmp.get());
23 // Remove prefix added by libtool for consistency during testing. 24 // Remove prefix added by libtool for consistency during testing.
24 - if (strncmp(whoami, "lt-", 3) == 0) 25 + if (strncmp(p, "lt-", 3) == 0)
25 { 26 {
26 - whoami += 3; 27 + p += 3;
27 } 28 }
  29 + whoami = p;
28 } 30 }
29 31
30 -QPDFArgParser::QPDFArgParser(int argc, char* argv[], char const* progname_env) : 32 +QPDFArgParser::QPDFArgParser(int argc, char const* const argv[],
  33 + char const* progname_env) :
31 m(new Members(argc, argv, progname_env)) 34 m(new Members(argc, argv, progname_env))
32 { 35 {
33 selectHelpOptionTable(); 36 selectHelpOptionTable();
@@ -250,17 +253,17 @@ QPDFArgParser::argCompletionZsh() @@ -250,17 +253,17 @@ QPDFArgParser::argCompletionZsh()
250 } 253 }
251 254
252 void 255 void
253 -QPDFArgParser::argHelp(char* p) 256 +QPDFArgParser::argHelp(std::string const& p)
254 { 257 {
255 std::cout << getHelp(p); 258 std::cout << getHelp(p);
256 exit(0); 259 exit(0);
257 } 260 }
258 261
259 void 262 void
260 -QPDFArgParser::invalidHelpArg(char* p) 263 +QPDFArgParser::invalidHelpArg(std::string const& p)
261 { 264 {
262 usage(std::string("unknown help option") + 265 usage(std::string("unknown help option") +
263 - (p ? (std::string(" ") + p) : "")); 266 + (p.empty() ? "" : (" " + p)));
264 } 267 }
265 268
266 void 269 void
@@ -272,7 +275,7 @@ QPDFArgParser::handleArgFileArguments() @@ -272,7 +275,7 @@ QPDFArgParser::handleArgFileArguments()
272 this->m->new_argv.push_back(QUtil::make_shared_cstr(this->m->argv[0])); 275 this->m->new_argv.push_back(QUtil::make_shared_cstr(this->m->argv[0]));
273 for (int i = 1; i < this->m->argc; ++i) 276 for (int i = 1; i < this->m->argc; ++i)
274 { 277 {
275 - char* argfile = 0; 278 + char const* argfile = 0;
276 if ((strlen(this->m->argv[i]) > 1) && (this->m->argv[i][0] == '@')) 279 if ((strlen(this->m->argv[i]) > 1) && (this->m->argv[i][0] == '@'))
277 { 280 {
278 argfile = 1 + this->m->argv[i]; 281 argfile = 1 + this->m->argv[i];
@@ -295,16 +298,16 @@ QPDFArgParser::handleArgFileArguments() @@ -295,16 +298,16 @@ QPDFArgParser::handleArgFileArguments()
295 QUtil::make_shared_cstr(this->m->argv[i])); 298 QUtil::make_shared_cstr(this->m->argv[i]));
296 } 299 }
297 } 300 }
298 - this->m->argv_ph = std::shared_ptr<char*>(  
299 - new char*[1 + this->m->new_argv.size()],  
300 - std::default_delete<char*[]>());  
301 - this->m->argv = this->m->argv_ph.get(); 301 + this->m->argv_ph = std::shared_ptr<char const*>(
  302 + new char const*[1 + this->m->new_argv.size()],
  303 + std::default_delete<char const*[]>());
302 for (size_t i = 0; i < this->m->new_argv.size(); ++i) 304 for (size_t i = 0; i < this->m->new_argv.size(); ++i)
303 { 305 {
304 - this->m->argv[i] = this->m->new_argv.at(i).get(); 306 + this->m->argv_ph.get()[i] = this->m->new_argv.at(i).get();
305 } 307 }
306 this->m->argc = QIntC::to_int(this->m->new_argv.size()); 308 this->m->argc = QIntC::to_int(this->m->new_argv.size());
307 - this->m->argv[this->m->argc] = 0; 309 + this->m->argv_ph.get()[this->m->argc] = nullptr;
  310 + this->m->argv = this->m->argv_ph.get();
308 } 311 }
309 312
310 void 313 void
@@ -400,16 +403,16 @@ QPDFArgParser::handleBashArguments() @@ -400,16 +403,16 @@ QPDFArgParser::handleBashArguments()
400 } 403 }
401 // Explicitly discard any non-space-terminated word. The "current 404 // Explicitly discard any non-space-terminated word. The "current
402 // word" is handled specially. 405 // word" is handled specially.
403 - this->m->bash_argv_ph = std::shared_ptr<char*>(  
404 - new char*[1 + this->m->bash_argv.size()],  
405 - std::default_delete<char*[]>());  
406 - this->m->argv = this->m->bash_argv_ph.get(); 406 + this->m->bash_argv_ph = std::shared_ptr<char const*>(
  407 + new char const*[1 + this->m->bash_argv.size()],
  408 + std::default_delete<char const*[]>());
407 for (size_t i = 0; i < this->m->bash_argv.size(); ++i) 409 for (size_t i = 0; i < this->m->bash_argv.size(); ++i)
408 { 410 {
409 - this->m->argv[i] = this->m->bash_argv.at(i).get(); 411 + this->m->bash_argv_ph.get()[i] = this->m->bash_argv.at(i).get();
410 } 412 }
411 this->m->argc = QIntC::to_int(this->m->bash_argv.size()); 413 this->m->argc = QIntC::to_int(this->m->bash_argv.size());
412 - this->m->argv[this->m->argc] = 0; 414 + this->m->bash_argv_ph.get()[this->m->argc] = nullptr;
  415 + this->m->argv = this->m->bash_argv_ph.get();
413 } 416 }
414 417
415 void 418 void
@@ -424,10 +427,10 @@ QPDFArgParser::usage(std::string const&amp; message) @@ -424,10 +427,10 @@ QPDFArgParser::usage(std::string const&amp; message)
424 } 427 }
425 428
426 void 429 void
427 -QPDFArgParser::readArgsFromFile(char const* filename) 430 +QPDFArgParser::readArgsFromFile(std::string const& filename)
428 { 431 {
429 std::list<std::string> lines; 432 std::list<std::string> lines;
430 - if (strcmp(filename, "-") == 0) 433 + if (filename == "-")
431 { 434 {
432 QTC::TC("libtests", "QPDFArgParser read args from stdin"); 435 QTC::TC("libtests", "QPDFArgParser read args from stdin");
433 lines = QUtil::read_lines_from_file(std::cin); 436 lines = QUtil::read_lines_from_file(std::cin);
@@ -435,7 +438,7 @@ QPDFArgParser::readArgsFromFile(char const* filename) @@ -435,7 +438,7 @@ QPDFArgParser::readArgsFromFile(char const* filename)
435 else 438 else
436 { 439 {
437 QTC::TC("libtests", "QPDFArgParser read args from file"); 440 QTC::TC("libtests", "QPDFArgParser read args from file");
438 - lines = QUtil::read_lines_from_file(filename); 441 + lines = QUtil::read_lines_from_file(filename.c_str());
439 } 442 }
440 for (auto const& line: lines) 443 for (auto const& line: lines)
441 { 444 {
@@ -547,8 +550,9 @@ QPDFArgParser::parseArgs() @@ -547,8 +550,9 @@ QPDFArgParser::parseArgs()
547 bool help_option = false; 550 bool help_option = false;
548 bool end_option = false; 551 bool end_option = false;
549 auto oep = this->m->option_table->end(); 552 auto oep = this->m->option_table->end();
550 - char* arg = this->m->argv[this->m->cur_arg];  
551 - char* parameter = nullptr; 553 + char const* arg = this->m->argv[this->m->cur_arg];
  554 + std::string parameter;
  555 + bool have_parameter = false;
552 std::string o_arg(arg); 556 std::string o_arg(arg);
553 std::string arg_s(arg); 557 std::string arg_s(arg);
554 if ((strcmp(arg, "--") == 0) && 558 if ((strcmp(arg, "--") == 0) &&
@@ -577,20 +581,25 @@ QPDFArgParser::parseArgs() @@ -577,20 +581,25 @@ QPDFArgParser::parseArgs()
577 { 581 {
578 QTC::TC("libtests", "QPDFArgParser single dash"); 582 QTC::TC("libtests", "QPDFArgParser single dash");
579 } 583 }
580 - if (strlen(arg) > 0) 584 +
  585 + // Prevent --=something from being treated as an empty arg
  586 + // by searching for = from after the first character. We
  587 + // do this since the empty string in the option table is
  588 + // for positional arguments. Besides, it doesn't make
  589 + // sense to have an empty option.
  590 + arg_s = arg;
  591 + size_t equal_pos = std::string::npos;
  592 + if (arg_s.length() > 0)
581 { 593 {
582 - // Prevent --=something from being treated as an empty  
583 - // arg since the empty string in the option table is  
584 - // for positional arguments.  
585 - parameter = const_cast<char*>(strchr(1 + arg, '=')); 594 + equal_pos = arg_s.find('=', 1);
586 } 595 }
587 - if (parameter) 596 + if (equal_pos != std::string::npos)
588 { 597 {
589 - *parameter++ = 0; 598 + have_parameter = true;
  599 + parameter = arg_s.substr(equal_pos + 1);
  600 + arg_s = arg_s.substr(0, equal_pos);
590 } 601 }
591 602
592 - arg_s = arg;  
593 -  
594 if ((! this->m->bash_completion) && 603 if ((! this->m->bash_completion) &&
595 (this->m->argc == 2) && (this->m->cur_arg == 1) && 604 (this->m->argc == 2) && (this->m->cur_arg == 1) &&
596 this->m->help_option_table.count(arg_s)) 605 this->m->help_option_table.count(arg_s))
@@ -629,8 +638,8 @@ QPDFArgParser::parseArgs() @@ -629,8 +638,8 @@ QPDFArgParser::parseArgs()
629 } 638 }
630 639
631 OptionEntry& oe = oep->second; 640 OptionEntry& oe = oep->second;
632 - if ((oe.parameter_needed && (nullptr == parameter)) ||  
633 - ((! oe.choices.empty() && (nullptr != parameter) && 641 + if ((oe.parameter_needed && (! have_parameter)) ||
  642 + ((! oe.choices.empty() && have_parameter &&
634 (0 == oe.choices.count(parameter))))) 643 (0 == oe.choices.count(parameter)))))
635 { 644 {
636 std::string message = 645 std::string message =
@@ -977,16 +986,15 @@ QPDFArgParser::getTopicHelp(std::string const&amp; name, @@ -977,16 +986,15 @@ QPDFArgParser::getTopicHelp(std::string const&amp; name,
977 } 986 }
978 987
979 std::string 988 std::string
980 -QPDFArgParser::getHelp(char const* topic_or_option) 989 +QPDFArgParser::getHelp(std::string const& arg)
981 { 990 {
982 std::ostringstream msg; 991 std::ostringstream msg;
983 - if ((topic_or_option == nullptr) || (strlen(topic_or_option) == 0)) 992 + if (arg.empty())
984 { 993 {
985 getTopHelp(msg); 994 getTopHelp(msg);
986 } 995 }
987 else 996 else
988 { 997 {
989 - std::string arg(topic_or_option);  
990 if (arg == "all") 998 if (arg == "all")
991 { 999 {
992 getAllHelp(msg); 1000 getAllHelp(msg);
libqpdf/QPDFJob_argv.cc
@@ -39,8 +39,8 @@ namespace @@ -39,8 +39,8 @@ namespace
39 std::shared_ptr<QPDFJob::PagesConfig> c_pages; 39 std::shared_ptr<QPDFJob::PagesConfig> c_pages;
40 std::shared_ptr<QPDFJob::UOConfig> c_uo; 40 std::shared_ptr<QPDFJob::UOConfig> c_uo;
41 std::shared_ptr<QPDFJob::EncConfig> c_enc; 41 std::shared_ptr<QPDFJob::EncConfig> c_enc;
42 - std::vector<char*> accumulated_args; // points to member in ap  
43 - char* pages_password; 42 + std::vector<std::string> accumulated_args;
  43 + std::shared_ptr<char> pages_password;
44 bool gave_input; 44 bool gave_input;
45 bool gave_output; 45 bool gave_output;
46 }; 46 };
@@ -70,7 +70,7 @@ ArgParser::initOptionTables() @@ -70,7 +70,7 @@ ArgParser::initOptionTables()
70 } 70 }
71 71
72 void 72 void
73 -ArgParser::argPositional(char* arg) 73 +ArgParser::argPositional(std::string const& arg)
74 { 74 {
75 if (! this->gave_input) 75 if (! this->gave_input)
76 { 76 {
@@ -84,7 +84,7 @@ ArgParser::argPositional(char* arg) @@ -84,7 +84,7 @@ ArgParser::argPositional(char* arg)
84 } 84 }
85 else 85 else
86 { 86 {
87 - usage(std::string("unknown argument ") + arg); 87 + usage("unknown argument " + arg);
88 } 88 }
89 } 89 }
90 90
@@ -188,7 +188,7 @@ ArgParser::argEncrypt() @@ -188,7 +188,7 @@ ArgParser::argEncrypt()
188 } 188 }
189 189
190 void 190 void
191 -ArgParser::argEncPositional(char* arg) 191 +ArgParser::argEncPositional(std::string const& arg)
192 { 192 {
193 this->accumulated_args.push_back(arg); 193 this->accumulated_args.push_back(arg);
194 size_t n_args = this->accumulated_args.size(); 194 size_t n_args = this->accumulated_args.size();
@@ -244,9 +244,9 @@ ArgParser::argPages() @@ -244,9 +244,9 @@ ArgParser::argPages()
244 } 244 }
245 245
246 void 246 void
247 -ArgParser::argPagesPassword(char* parameter) 247 +ArgParser::argPagesPassword(std::string const& parameter)
248 { 248 {
249 - if (this->pages_password != nullptr) 249 + if (this->pages_password)
250 { 250 {
251 QTC::TC("qpdf", "QPDFJob duplicated pages password"); 251 QTC::TC("qpdf", "QPDFJob duplicated pages password");
252 usage("--password already specified for this file"); 252 usage("--password already specified for this file");
@@ -256,13 +256,13 @@ ArgParser::argPagesPassword(char* parameter) @@ -256,13 +256,13 @@ ArgParser::argPagesPassword(char* parameter)
256 QTC::TC("qpdf", "QPDFJob misplaced pages password"); 256 QTC::TC("qpdf", "QPDFJob misplaced pages password");
257 usage("in --pages, --password must immediately follow a file name"); 257 usage("in --pages, --password must immediately follow a file name");
258 } 258 }
259 - this->pages_password = parameter; 259 + this->pages_password = QUtil::make_shared_cstr(parameter);
260 } 260 }
261 261
262 void 262 void
263 -ArgParser::argPagesPositional(char* arg) 263 +ArgParser::argPagesPositional(std::string const& arg)
264 { 264 {
265 - if (arg == nullptr) 265 + if (arg.empty())
266 { 266 {
267 if (this->accumulated_args.empty()) 267 if (this->accumulated_args.empty())
268 { 268 {
@@ -274,25 +274,26 @@ ArgParser::argPagesPositional(char* arg) @@ -274,25 +274,26 @@ ArgParser::argPagesPositional(char* arg)
274 this->accumulated_args.push_back(arg); 274 this->accumulated_args.push_back(arg);
275 } 275 }
276 276
277 - char const* file = this->accumulated_args.at(0);  
278 - char const* range = nullptr; 277 + std::string file = this->accumulated_args.at(0);
  278 + char const* range_p = nullptr;
279 279
280 size_t n_args = this->accumulated_args.size(); 280 size_t n_args = this->accumulated_args.size();
281 if (n_args >= 2) 281 if (n_args >= 2)
282 { 282 {
283 - range = this->accumulated_args.at(1); 283 + // will be copied before accumulated_args is cleared
  284 + range_p = this->accumulated_args.at(1).c_str();
284 } 285 }
285 286
286 // See if the user omitted the range entirely, in which case we 287 // See if the user omitted the range entirely, in which case we
287 // assume "1-z". 288 // assume "1-z".
288 - char* next_file = nullptr;  
289 - if (range == nullptr) 289 + std::string next_file;
  290 + if (range_p == nullptr)
290 { 291 {
291 - if (arg == nullptr) 292 + if (arg.empty())
292 { 293 {
293 // The filename or password was the last argument 294 // The filename or password was the last argument
294 QTC::TC("qpdf", "QPDFJob pages range omitted at end", 295 QTC::TC("qpdf", "QPDFJob pages range omitted at end",
295 - this->pages_password == nullptr ? 0 : 1); 296 + this->pages_password ? 0 : 1);
296 } 297 }
297 else 298 else
298 { 299 {
@@ -304,17 +305,17 @@ ArgParser::argPagesPositional(char* arg) @@ -304,17 +305,17 @@ ArgParser::argPagesPositional(char* arg)
304 { 305 {
305 try 306 try
306 { 307 {
307 - QUtil::parse_numrange(range, 0); 308 + QUtil::parse_numrange(range_p, 0);
308 } 309 }
309 catch (std::runtime_error& e1) 310 catch (std::runtime_error& e1)
310 { 311 {
311 // The range is invalid. Let's see if it's a file. 312 // The range is invalid. Let's see if it's a file.
312 - if (strcmp(range, ".") == 0) 313 + if (strcmp(range_p, ".") == 0)
313 { 314 {
314 // "." means the input file. 315 // "." means the input file.
315 QTC::TC("qpdf", "QPDFJob pages range omitted with ."); 316 QTC::TC("qpdf", "QPDFJob pages range omitted with .");
316 } 317 }
317 - else if (QUtil::file_can_be_opened(range)) 318 + else if (QUtil::file_can_be_opened(range_p))
318 { 319 {
319 QTC::TC("qpdf", "QPDFJob pages range omitted in middle"); 320 QTC::TC("qpdf", "QPDFJob pages range omitted in middle");
320 // Yup, it's a file. 321 // Yup, it's a file.
@@ -324,18 +325,15 @@ ArgParser::argPagesPositional(char* arg) @@ -324,18 +325,15 @@ ArgParser::argPagesPositional(char* arg)
324 // Give the range error 325 // Give the range error
325 usage(e1.what()); 326 usage(e1.what());
326 } 327 }
327 - next_file = const_cast<char*>(range);  
328 - range = nullptr; 328 + next_file = range_p;
  329 + range_p = nullptr;
329 } 330 }
330 } 331 }
331 - if (range == nullptr)  
332 - {  
333 - range = "1-z";  
334 - }  
335 - this->c_pages->pageSpec(file, range, this->pages_password); 332 + std::string range(range_p ? range_p : "1-z");
  333 + this->c_pages->pageSpec(file, range, this->pages_password.get());
336 this->accumulated_args.clear(); 334 this->accumulated_args.clear();
337 this->pages_password = nullptr; 335 this->pages_password = nullptr;
338 - if (next_file != nullptr) 336 + if (! next_file.empty())
339 { 337 {
340 this->accumulated_args.push_back(next_file); 338 this->accumulated_args.push_back(next_file);
341 } 339 }
@@ -344,7 +342,7 @@ ArgParser::argPagesPositional(char* arg) @@ -344,7 +342,7 @@ ArgParser::argPagesPositional(char* arg)
344 void 342 void
345 ArgParser::argEndPages() 343 ArgParser::argEndPages()
346 { 344 {
347 - argPagesPositional(nullptr); 345 + argPagesPositional("");
348 c_pages->endPages(); 346 c_pages->endPages();
349 c_pages = nullptr; 347 c_pages = nullptr;
350 } 348 }
@@ -403,7 +401,7 @@ ArgParser::argEnd256BitEncryption() @@ -403,7 +401,7 @@ ArgParser::argEnd256BitEncryption()
403 } 401 }
404 402
405 void 403 void
406 -ArgParser::argUOPositional(char* arg) 404 +ArgParser::argUOPositional(std::string const& arg)
407 { 405 {
408 c_uo->file(arg); 406 c_uo->file(arg);
409 } 407 }
@@ -416,7 +414,7 @@ ArgParser::argEndUnderlayOverlay() @@ -416,7 +414,7 @@ ArgParser::argEndUnderlayOverlay()
416 } 414 }
417 415
418 void 416 void
419 -ArgParser::argAttPositional(char* arg) 417 +ArgParser::argAttPositional(std::string const& arg)
420 { 418 {
421 c_att->file(arg); 419 c_att->file(arg);
422 } 420 }
@@ -429,7 +427,7 @@ ArgParser::argEndAttachment() @@ -429,7 +427,7 @@ ArgParser::argEndAttachment()
429 } 427 }
430 428
431 void 429 void
432 -ArgParser::argCopyAttPositional(char* arg) 430 +ArgParser::argCopyAttPositional(std::string const& arg)
433 { 431 {
434 c_copy_att->file(arg); 432 c_copy_att->file(arg);
435 } 433 }
@@ -467,7 +465,8 @@ ArgParser::parseOptions() @@ -467,7 +465,8 @@ ArgParser::parseOptions()
467 } 465 }
468 466
469 void 467 void
470 -QPDFJob::initializeFromArgv(int argc, char* argv[], char const* progname_env) 468 +QPDFJob::initializeFromArgv(int argc, char const* const argv[],
  469 + char const* progname_env)
471 { 470 {
472 if (progname_env == nullptr) 471 if (progname_env == nullptr)
473 { 472 {
libqpdf/QPDFJob_config.cc
1 #include <qpdf/QPDFJob.hh> 1 #include <qpdf/QPDFJob.hh>
2 #include <qpdf/QUtil.hh> 2 #include <qpdf/QUtil.hh>
3 #include <qpdf/QTC.hh> 3 #include <qpdf/QTC.hh>
4 -#include <cstring>  
5 4
6 void 5 void
7 QPDFJob::Config::checkConfiguration() 6 QPDFJob::Config::checkConfiguration()
@@ -10,7 +9,7 @@ QPDFJob::Config::checkConfiguration() @@ -10,7 +9,7 @@ QPDFJob::Config::checkConfiguration()
10 } 9 }
11 10
12 QPDFJob::Config* 11 QPDFJob::Config*
13 -QPDFJob::Config::inputFile(char const* filename) 12 +QPDFJob::Config::inputFile(std::string const& filename)
14 { 13 {
15 if (o.m->infilename == 0) 14 if (o.m->infilename == 0)
16 { 15 {
@@ -46,7 +45,7 @@ QPDFJob::Config::emptyInput() @@ -46,7 +45,7 @@ QPDFJob::Config::emptyInput()
46 } 45 }
47 46
48 QPDFJob::Config* 47 QPDFJob::Config*
49 -QPDFJob::Config::outputFile(char const* filename) 48 +QPDFJob::Config::outputFile(std::string const& filename)
50 { 49 {
51 if ((o.m->outfilename == 0) && (! o.m->replace_input)) 50 if ((o.m->outfilename == 0) && (! o.m->replace_input))
52 { 51 {
@@ -107,35 +106,34 @@ QPDFJob::Config::coalesceContents() @@ -107,35 +106,34 @@ QPDFJob::Config::coalesceContents()
107 QPDFJob::Config* 106 QPDFJob::Config*
108 QPDFJob::Config::collate() 107 QPDFJob::Config::collate()
109 { 108 {
110 - return collate(nullptr); 109 + return collate("");
111 } 110 }
112 111
113 QPDFJob::Config* 112 QPDFJob::Config*
114 -QPDFJob::Config::collate(char const* parameter) 113 +QPDFJob::Config::collate(std::string const& parameter)
115 { 114 {
116 - auto n = (((parameter == 0) || (strlen(parameter) == 0)) ? 1 :  
117 - QUtil::string_to_uint(parameter)); 115 + auto n = (parameter.empty() ? 1 : QUtil::string_to_uint(parameter.c_str()));
118 o.m->collate = QIntC::to_size(n); 116 o.m->collate = QIntC::to_size(n);
119 return this; 117 return this;
120 } 118 }
121 119
122 QPDFJob::Config* 120 QPDFJob::Config*
123 -QPDFJob::Config::compressStreams(char const* parameter) 121 +QPDFJob::Config::compressStreams(std::string const& parameter)
124 { 122 {
125 o.m->compress_streams_set = true; 123 o.m->compress_streams_set = true;
126 - o.m->compress_streams = (strcmp(parameter, "y") == 0); 124 + o.m->compress_streams = (parameter == "y");
127 return this; 125 return this;
128 } 126 }
129 127
130 QPDFJob::Config* 128 QPDFJob::Config*
131 -QPDFJob::Config::compressionLevel(char const* parameter) 129 +QPDFJob::Config::compressionLevel(std::string const& parameter)
132 { 130 {
133 - o.m->compression_level = QUtil::string_to_int(parameter); 131 + o.m->compression_level = QUtil::string_to_int(parameter.c_str());
134 return this; 132 return this;
135 } 133 }
136 134
137 QPDFJob::Config* 135 QPDFJob::Config*
138 -QPDFJob::Config::copyEncryption(char const* parameter) 136 +QPDFJob::Config::copyEncryption(std::string const& parameter)
139 { 137 {
140 o.m->encryption_file = parameter; 138 o.m->encryption_file = parameter;
141 o.m->copy_encryption = true; 139 o.m->copy_encryption = true;
@@ -161,7 +159,7 @@ QPDFJob::Config::deterministicId() @@ -161,7 +159,7 @@ QPDFJob::Config::deterministicId()
161 } 159 }
162 160
163 QPDFJob::Config* 161 QPDFJob::Config*
164 -QPDFJob::Config::encryptionFilePassword(char const* parameter) 162 +QPDFJob::Config::encryptionFilePassword(std::string const& parameter)
165 { 163 {
166 o.m->encryption_file_password = QUtil::make_shared_cstr(parameter); 164 o.m->encryption_file_password = QUtil::make_shared_cstr(parameter);
167 return this; 165 return this;
@@ -182,17 +180,21 @@ QPDFJob::Config::filteredStreamData() @@ -182,17 +180,21 @@ QPDFJob::Config::filteredStreamData()
182 } 180 }
183 181
184 QPDFJob::Config* 182 QPDFJob::Config*
185 -QPDFJob::Config::flattenAnnotations(char const* parameter) 183 +QPDFJob::Config::flattenAnnotations(std::string const& parameter)
186 { 184 {
187 o.m->flatten_annotations = true; 185 o.m->flatten_annotations = true;
188 - if (strcmp(parameter, "screen") == 0) 186 + if (parameter == "screen")
189 { 187 {
190 o.m->flatten_annotations_forbidden |= an_no_view; 188 o.m->flatten_annotations_forbidden |= an_no_view;
191 } 189 }
192 - else if (strcmp(parameter, "print") == 0) 190 + else if (parameter == "print")
193 { 191 {
194 o.m->flatten_annotations_required |= an_print; 192 o.m->flatten_annotations_required |= an_print;
195 } 193 }
  194 + else if (parameter != "all")
  195 + {
  196 + usage("invalid flatten-annotations option");
  197 + }
196 return this; 198 return this;
197 } 199 }
198 200
@@ -204,7 +206,7 @@ QPDFJob::Config::flattenRotation() @@ -204,7 +206,7 @@ QPDFJob::Config::flattenRotation()
204 } 206 }
205 207
206 QPDFJob::Config* 208 QPDFJob::Config*
207 -QPDFJob::Config::forceVersion(char const* parameter) 209 +QPDFJob::Config::forceVersion(std::string const& parameter)
208 { 210 {
209 o.m->force_version = parameter; 211 o.m->force_version = parameter;
210 return this; 212 return this;
@@ -225,9 +227,9 @@ QPDFJob::Config::ignoreXrefStreams() @@ -225,9 +227,9 @@ QPDFJob::Config::ignoreXrefStreams()
225 } 227 }
226 228
227 QPDFJob::Config* 229 QPDFJob::Config*
228 -QPDFJob::Config::iiMinBytes(char const* parameter) 230 +QPDFJob::Config::iiMinBytes(std::string const& parameter)
229 { 231 {
230 - o.m->ii_min_bytes = QUtil::string_to_uint(parameter); 232 + o.m->ii_min_bytes = QUtil::string_to_uint(parameter.c_str());
231 return this; 233 return this;
232 } 234 }
233 235
@@ -242,27 +244,25 @@ QPDFJob::Config::isEncrypted() @@ -242,27 +244,25 @@ QPDFJob::Config::isEncrypted()
242 QPDFJob::Config* 244 QPDFJob::Config*
243 QPDFJob::Config::json() 245 QPDFJob::Config::json()
244 { 246 {
245 - return json(nullptr); 247 + return json("");
246 } 248 }
247 249
248 QPDFJob::Config* 250 QPDFJob::Config*
249 -QPDFJob::Config::json(char const* parameter) 251 +QPDFJob::Config::json(std::string const& parameter)
250 { 252 {
251 - if (parameter && strlen(parameter)) 253 + if (parameter.empty())
252 { 254 {
253 - if (strcmp(parameter, "latest") == 0)  
254 - {  
255 - o.m->json_version = 1;  
256 - }  
257 - else  
258 - {  
259 - o.m->json_version = QUtil::string_to_int(parameter);  
260 - } 255 + // The default value is 1 for backward compatibility.
  256 + o.m->json_version = 1;
261 } 257 }
262 - else 258 + else if (parameter == "latest")
263 { 259 {
264 o.m->json_version = 1; 260 o.m->json_version = 1;
265 } 261 }
  262 + else
  263 + {
  264 + o.m->json_version = QUtil::string_to_int(parameter.c_str());
  265 + }
266 if (o.m->json_version != 1) 266 if (o.m->json_version != 1)
267 { 267 {
268 usage(std::string("unsupported json version ") + parameter); 268 usage(std::string("unsupported json version ") + parameter);
@@ -272,31 +272,31 @@ QPDFJob::Config::json(char const* parameter) @@ -272,31 +272,31 @@ QPDFJob::Config::json(char const* parameter)
272 } 272 }
273 273
274 QPDFJob::Config* 274 QPDFJob::Config*
275 -QPDFJob::Config::jsonKey(char const* parameter) 275 +QPDFJob::Config::jsonKey(std::string const& parameter)
276 { 276 {
277 o.m->json_keys.insert(parameter); 277 o.m->json_keys.insert(parameter);
278 return this; 278 return this;
279 } 279 }
280 280
281 QPDFJob::Config* 281 QPDFJob::Config*
282 -QPDFJob::Config::jsonObject(char const* parameter) 282 +QPDFJob::Config::jsonObject(std::string const& parameter)
283 { 283 {
284 o.m->json_objects.insert(parameter); 284 o.m->json_objects.insert(parameter);
285 return this; 285 return this;
286 } 286 }
287 287
288 QPDFJob::Config* 288 QPDFJob::Config*
289 -QPDFJob::Config::keepFilesOpen(char const* parameter) 289 +QPDFJob::Config::keepFilesOpen(std::string const& parameter)
290 { 290 {
291 o.m->keep_files_open_set = true; 291 o.m->keep_files_open_set = true;
292 - o.m->keep_files_open = (strcmp(parameter, "y") == 0); 292 + o.m->keep_files_open = (parameter == "y");
293 return this; 293 return this;
294 } 294 }
295 295
296 QPDFJob::Config* 296 QPDFJob::Config*
297 -QPDFJob::Config::keepFilesOpenThreshold(char const* parameter) 297 +QPDFJob::Config::keepFilesOpenThreshold(std::string const& parameter)
298 { 298 {
299 - o.m->keep_files_open_threshold = QUtil::string_to_uint(parameter); 299 + o.m->keep_files_open_threshold = QUtil::string_to_uint(parameter.c_str());
300 return this; 300 return this;
301 } 301 }
302 302
@@ -315,7 +315,7 @@ QPDFJob::Config::linearize() @@ -315,7 +315,7 @@ QPDFJob::Config::linearize()
315 } 315 }
316 316
317 QPDFJob::Config* 317 QPDFJob::Config*
318 -QPDFJob::Config::linearizePass1(char const* parameter) 318 +QPDFJob::Config::linearizePass1(std::string const& parameter)
319 { 319 {
320 o.m->linearize_pass1 = parameter; 320 o.m->linearize_pass1 = parameter;
321 return this; 321 return this;
@@ -330,7 +330,7 @@ QPDFJob::Config::listAttachments() @@ -330,7 +330,7 @@ QPDFJob::Config::listAttachments()
330 } 330 }
331 331
332 QPDFJob::Config* 332 QPDFJob::Config*
333 -QPDFJob::Config::minVersion(char const* parameter) 333 +QPDFJob::Config::minVersion(std::string const& parameter)
334 { 334 {
335 o.m->min_version = parameter; 335 o.m->min_version = parameter;
336 return this; 336 return this;
@@ -358,31 +358,31 @@ QPDFJob::Config::noWarn() @@ -358,31 +358,31 @@ QPDFJob::Config::noWarn()
358 } 358 }
359 359
360 QPDFJob::Config* 360 QPDFJob::Config*
361 -QPDFJob::Config::normalizeContent(char const* parameter) 361 +QPDFJob::Config::normalizeContent(std::string const& parameter)
362 { 362 {
363 o.m->normalize_set = true; 363 o.m->normalize_set = true;
364 - o.m->normalize = (strcmp(parameter, "y") == 0); 364 + o.m->normalize = (parameter == "y");
365 return this; 365 return this;
366 } 366 }
367 367
368 QPDFJob::Config* 368 QPDFJob::Config*
369 -QPDFJob::Config::oiMinArea(char const* parameter) 369 +QPDFJob::Config::oiMinArea(std::string const& parameter)
370 { 370 {
371 - o.m->oi_min_area = QUtil::string_to_uint(parameter); 371 + o.m->oi_min_area = QUtil::string_to_uint(parameter.c_str());
372 return this; 372 return this;
373 } 373 }
374 374
375 QPDFJob::Config* 375 QPDFJob::Config*
376 -QPDFJob::Config::oiMinHeight(char const* parameter) 376 +QPDFJob::Config::oiMinHeight(std::string const& parameter)
377 { 377 {
378 - o.m->oi_min_height = QUtil::string_to_uint(parameter); 378 + o.m->oi_min_height = QUtil::string_to_uint(parameter.c_str());
379 return this; 379 return this;
380 } 380 }
381 381
382 QPDFJob::Config* 382 QPDFJob::Config*
383 -QPDFJob::Config::oiMinWidth(char const* parameter) 383 +QPDFJob::Config::oiMinWidth(std::string const& parameter)
384 { 384 {
385 - o.m->oi_min_width = QUtil::string_to_uint(parameter); 385 + o.m->oi_min_width = QUtil::string_to_uint(parameter.c_str());
386 return this; 386 return this;
387 } 387 }
388 388
@@ -394,7 +394,7 @@ QPDFJob::Config::optimizeImages() @@ -394,7 +394,7 @@ QPDFJob::Config::optimizeImages()
394 } 394 }
395 395
396 QPDFJob::Config* 396 QPDFJob::Config*
397 -QPDFJob::Config::password(char const* parameter) 397 +QPDFJob::Config::password(std::string const& parameter)
398 { 398 {
399 o.m->password = QUtil::make_shared_cstr(parameter); 399 o.m->password = QUtil::make_shared_cstr(parameter);
400 return this; 400 return this;
@@ -451,7 +451,7 @@ QPDFJob::Config::recompressFlate() @@ -451,7 +451,7 @@ QPDFJob::Config::recompressFlate()
451 } 451 }
452 452
453 QPDFJob::Config* 453 QPDFJob::Config*
454 -QPDFJob::Config::removeAttachment(char const* parameter) 454 +QPDFJob::Config::removeAttachment(std::string const& parameter)
455 { 455 {
456 o.m->attachments_to_remove.push_back(parameter); 456 o.m->attachments_to_remove.push_back(parameter);
457 return this; 457 return this;
@@ -473,7 +473,7 @@ QPDFJob::Config::requiresPassword() @@ -473,7 +473,7 @@ QPDFJob::Config::requiresPassword()
473 } 473 }
474 474
475 QPDFJob::Config* 475 QPDFJob::Config*
476 -QPDFJob::Config::showAttachment(char const* parameter) 476 +QPDFJob::Config::showAttachment(std::string const& parameter)
477 { 477 {
478 o.m->attachment_to_show = parameter; 478 o.m->attachment_to_show = parameter;
479 o.m->require_outfile = false; 479 o.m->require_outfile = false;
@@ -530,14 +530,13 @@ QPDFJob::Config::showXref() @@ -530,14 +530,13 @@ QPDFJob::Config::showXref()
530 QPDFJob::Config* 530 QPDFJob::Config*
531 QPDFJob::Config::splitPages() 531 QPDFJob::Config::splitPages()
532 { 532 {
533 - return splitPages(nullptr); 533 + return splitPages("");
534 } 534 }
535 535
536 QPDFJob::Config* 536 QPDFJob::Config*
537 -QPDFJob::Config::splitPages(char const* parameter) 537 +QPDFJob::Config::splitPages(std::string const& parameter)
538 { 538 {
539 - int n = (((parameter == 0) || (strlen(parameter) == 0)) ? 1 :  
540 - QUtil::string_to_int(parameter)); 539 + int n = (parameter.empty() ? 1 : QUtil::string_to_int(parameter.c_str()));
541 o.m->split_pages = n; 540 o.m->split_pages = n;
542 return this; 541 return this;
543 } 542 }
@@ -592,10 +591,10 @@ QPDFJob::Config::withImages() @@ -592,10 +591,10 @@ QPDFJob::Config::withImages()
592 } 591 }
593 592
594 QPDFJob::Config* 593 QPDFJob::Config*
595 -QPDFJob::Config::passwordFile(char const* parameter) 594 +QPDFJob::Config::passwordFile(std::string const& parameter)
596 { 595 {
597 std::list<std::string> lines; 596 std::list<std::string> lines;
598 - if (strcmp(parameter, "-") == 0) 597 + if (parameter == "-")
599 { 598 {
600 QTC::TC("qpdf", "QPDFJob_config password stdin"); 599 QTC::TC("qpdf", "QPDFJob_config password stdin");
601 lines = QUtil::read_lines_from_file(std::cin); 600 lines = QUtil::read_lines_from_file(std::cin);
@@ -603,7 +602,7 @@ QPDFJob::Config::passwordFile(char const* parameter) @@ -603,7 +602,7 @@ QPDFJob::Config::passwordFile(char const* parameter)
603 else 602 else
604 { 603 {
605 QTC::TC("qpdf", "QPDFJob_config password file"); 604 QTC::TC("qpdf", "QPDFJob_config password file");
606 - lines = QUtil::read_lines_from_file(parameter); 605 + lines = QUtil::read_lines_from_file(parameter.c_str());
607 } 606 }
608 if (lines.size() >= 1) 607 if (lines.size() >= 1)
609 { 608 {
@@ -620,21 +619,21 @@ QPDFJob::Config::passwordFile(char const* parameter) @@ -620,21 +619,21 @@ QPDFJob::Config::passwordFile(char const* parameter)
620 } 619 }
621 620
622 QPDFJob::Config* 621 QPDFJob::Config*
623 -QPDFJob::Config::passwordMode(char const* parameter) 622 +QPDFJob::Config::passwordMode(std::string const& parameter)
624 { 623 {
625 - if (strcmp(parameter, "bytes") == 0) 624 + if (parameter == "bytes")
626 { 625 {
627 o.m->password_mode = QPDFJob::pm_bytes; 626 o.m->password_mode = QPDFJob::pm_bytes;
628 } 627 }
629 - else if (strcmp(parameter, "hex-bytes") == 0) 628 + else if (parameter == "hex-bytes")
630 { 629 {
631 o.m->password_mode = QPDFJob::pm_hex_bytes; 630 o.m->password_mode = QPDFJob::pm_hex_bytes;
632 } 631 }
633 - else if (strcmp(parameter, "unicode") == 0) 632 + else if (parameter == "unicode")
634 { 633 {
635 o.m->password_mode = QPDFJob::pm_unicode; 634 o.m->password_mode = QPDFJob::pm_unicode;
636 } 635 }
637 - else if (strcmp(parameter, "auto") == 0) 636 + else if (parameter == "auto")
638 { 637 {
639 o.m->password_mode = QPDFJob::pm_auto; 638 o.m->password_mode = QPDFJob::pm_auto;
640 } 639 }
@@ -646,18 +645,18 @@ QPDFJob::Config::passwordMode(char const* parameter) @@ -646,18 +645,18 @@ QPDFJob::Config::passwordMode(char const* parameter)
646 } 645 }
647 646
648 QPDFJob::Config* 647 QPDFJob::Config*
649 -QPDFJob::Config::streamData(char const* parameter) 648 +QPDFJob::Config::streamData(std::string const& parameter)
650 { 649 {
651 o.m->stream_data_set = true; 650 o.m->stream_data_set = true;
652 - if (strcmp(parameter, "compress") == 0) 651 + if (parameter == "compress")
653 { 652 {
654 o.m->stream_data_mode = qpdf_s_compress; 653 o.m->stream_data_mode = qpdf_s_compress;
655 } 654 }
656 - else if (strcmp(parameter, "preserve") == 0) 655 + else if (parameter == "preserve")
657 { 656 {
658 o.m->stream_data_mode = qpdf_s_preserve; 657 o.m->stream_data_mode = qpdf_s_preserve;
659 } 658 }
660 - else if (strcmp(parameter, "uncompress") == 0) 659 + else if (parameter == "uncompress")
661 { 660 {
662 o.m->stream_data_mode = qpdf_s_uncompress; 661 o.m->stream_data_mode = qpdf_s_uncompress;
663 } 662 }
@@ -669,22 +668,22 @@ QPDFJob::Config::streamData(char const* parameter) @@ -669,22 +668,22 @@ QPDFJob::Config::streamData(char const* parameter)
669 } 668 }
670 669
671 QPDFJob::Config* 670 QPDFJob::Config*
672 -QPDFJob::Config::decodeLevel(char const* parameter) 671 +QPDFJob::Config::decodeLevel(std::string const& parameter)
673 { 672 {
674 o.m->decode_level_set = true; 673 o.m->decode_level_set = true;
675 - if (strcmp(parameter, "none") == 0) 674 + if (parameter == "none")
676 { 675 {
677 o.m->decode_level = qpdf_dl_none; 676 o.m->decode_level = qpdf_dl_none;
678 } 677 }
679 - else if (strcmp(parameter, "generalized") == 0) 678 + else if (parameter == "generalized")
680 { 679 {
681 o.m->decode_level = qpdf_dl_generalized; 680 o.m->decode_level = qpdf_dl_generalized;
682 } 681 }
683 - else if (strcmp(parameter, "specialized") == 0) 682 + else if (parameter == "specialized")
684 { 683 {
685 o.m->decode_level = qpdf_dl_specialized; 684 o.m->decode_level = qpdf_dl_specialized;
686 } 685 }
687 - else if (strcmp(parameter, "all") == 0) 686 + else if (parameter == "all")
688 { 687 {
689 o.m->decode_level = qpdf_dl_all; 688 o.m->decode_level = qpdf_dl_all;
690 } 689 }
@@ -696,18 +695,18 @@ QPDFJob::Config::decodeLevel(char const* parameter) @@ -696,18 +695,18 @@ QPDFJob::Config::decodeLevel(char const* parameter)
696 } 695 }
697 696
698 QPDFJob::Config* 697 QPDFJob::Config*
699 -QPDFJob::Config::objectStreams(char const* parameter) 698 +QPDFJob::Config::objectStreams(std::string const& parameter)
700 { 699 {
701 o.m->object_stream_set = true; 700 o.m->object_stream_set = true;
702 - if (strcmp(parameter, "disable") == 0) 701 + if (parameter == "disable")
703 { 702 {
704 o.m->object_stream_mode = qpdf_o_disable; 703 o.m->object_stream_mode = qpdf_o_disable;
705 } 704 }
706 - else if (strcmp(parameter, "preserve") == 0) 705 + else if (parameter == "preserve")
707 { 706 {
708 o.m->object_stream_mode = qpdf_o_preserve; 707 o.m->object_stream_mode = qpdf_o_preserve;
709 } 708 }
710 - else if (strcmp(parameter, "generate") == 0) 709 + else if (parameter == "generate")
711 { 710 {
712 o.m->object_stream_mode = qpdf_o_generate; 711 o.m->object_stream_mode = qpdf_o_generate;
713 } 712 }
@@ -719,17 +718,17 @@ QPDFJob::Config::objectStreams(char const* parameter) @@ -719,17 +718,17 @@ QPDFJob::Config::objectStreams(char const* parameter)
719 } 718 }
720 719
721 QPDFJob::Config* 720 QPDFJob::Config*
722 -QPDFJob::Config::removeUnreferencedResources(char const* parameter) 721 +QPDFJob::Config::removeUnreferencedResources(std::string const& parameter)
723 { 722 {
724 - if (strcmp(parameter, "auto") == 0) 723 + if (parameter == "auto")
725 { 724 {
726 o.m->remove_unreferenced_page_resources = QPDFJob::re_auto; 725 o.m->remove_unreferenced_page_resources = QPDFJob::re_auto;
727 } 726 }
728 - else if (strcmp(parameter, "yes") == 0) 727 + else if (parameter == "yes")
729 { 728 {
730 o.m->remove_unreferenced_page_resources = QPDFJob::re_yes; 729 o.m->remove_unreferenced_page_resources = QPDFJob::re_yes;
731 } 730 }
732 - else if (strcmp(parameter, "no") == 0) 731 + else if (parameter == "no")
733 { 732 {
734 o.m->remove_unreferenced_page_resources = QPDFJob::re_no; 733 o.m->remove_unreferenced_page_resources = QPDFJob::re_no;
735 } 734 }
@@ -741,7 +740,7 @@ QPDFJob::Config::removeUnreferencedResources(char const* parameter) @@ -741,7 +740,7 @@ QPDFJob::Config::removeUnreferencedResources(char const* parameter)
741 } 740 }
742 741
743 QPDFJob::Config* 742 QPDFJob::Config*
744 -QPDFJob::Config::showObject(char const* parameter) 743 +QPDFJob::Config::showObject(std::string const& parameter)
745 { 744 {
746 QPDFJob::parse_object_id( 745 QPDFJob::parse_object_id(
747 parameter, o.m->show_trailer, o.m->show_obj, o.m->show_gen); 746 parameter, o.m->show_trailer, o.m->show_obj, o.m->show_gen);
@@ -750,11 +749,11 @@ QPDFJob::Config::showObject(char const* parameter) @@ -750,11 +749,11 @@ QPDFJob::Config::showObject(char const* parameter)
750 } 749 }
751 750
752 QPDFJob::Config* 751 QPDFJob::Config*
753 -QPDFJob::Config::jobJsonFile(char const* parameter) 752 +QPDFJob::Config::jobJsonFile(std::string const& parameter)
754 { 753 {
755 PointerHolder<char> file_buf; 754 PointerHolder<char> file_buf;
756 size_t size; 755 size_t size;
757 - QUtil::read_file_into_memory(parameter, file_buf, size); 756 + QUtil::read_file_into_memory(parameter.c_str(), file_buf, size);
758 try 757 try
759 { 758 {
760 o.initializeFromJson(std::string(file_buf.getPointer(), size), true); 759 o.initializeFromJson(std::string(file_buf.getPointer(), size), true);
@@ -770,7 +769,7 @@ QPDFJob::Config::jobJsonFile(char const* parameter) @@ -770,7 +769,7 @@ QPDFJob::Config::jobJsonFile(char const* parameter)
770 } 769 }
771 770
772 QPDFJob::Config* 771 QPDFJob::Config*
773 -QPDFJob::Config::rotate(char const* parameter) 772 +QPDFJob::Config::rotate(std::string const& parameter)
774 { 773 {
775 o.parseRotationParameter(parameter); 774 o.parseRotationParameter(parameter);
776 return this; 775 return this;
@@ -788,21 +787,21 @@ QPDFJob::CopyAttConfig::CopyAttConfig(Config* c) : @@ -788,21 +787,21 @@ QPDFJob::CopyAttConfig::CopyAttConfig(Config* c) :
788 } 787 }
789 788
790 QPDFJob::CopyAttConfig* 789 QPDFJob::CopyAttConfig*
791 -QPDFJob::CopyAttConfig::file(char const* parameter) 790 +QPDFJob::CopyAttConfig::file(std::string const& parameter)
792 { 791 {
793 this->caf.path = parameter; 792 this->caf.path = parameter;
794 return this; 793 return this;
795 } 794 }
796 795
797 QPDFJob::CopyAttConfig* 796 QPDFJob::CopyAttConfig*
798 -QPDFJob::CopyAttConfig::prefix(char const* parameter) 797 +QPDFJob::CopyAttConfig::prefix(std::string const& parameter)
799 { 798 {
800 this->caf.prefix = parameter; 799 this->caf.prefix = parameter;
801 return this; 800 return this;
802 } 801 }
803 802
804 QPDFJob::CopyAttConfig* 803 QPDFJob::CopyAttConfig*
805 -QPDFJob::CopyAttConfig::password(char const* parameter) 804 +QPDFJob::CopyAttConfig::password(std::string const& parameter)
806 { 805 {
807 this->caf.password = parameter; 806 this->caf.password = parameter;
808 return this; 807 return this;
@@ -831,28 +830,28 @@ QPDFJob::Config::addAttachment() @@ -831,28 +830,28 @@ QPDFJob::Config::addAttachment()
831 } 830 }
832 831
833 QPDFJob::AttConfig* 832 QPDFJob::AttConfig*
834 -QPDFJob::AttConfig::file(char const* parameter) 833 +QPDFJob::AttConfig::file(std::string const& parameter)
835 { 834 {
836 this->att.path = parameter; 835 this->att.path = parameter;
837 return this; 836 return this;
838 } 837 }
839 838
840 QPDFJob::AttConfig* 839 QPDFJob::AttConfig*
841 -QPDFJob::AttConfig::key(char const* parameter) 840 +QPDFJob::AttConfig::key(std::string const& parameter)
842 { 841 {
843 this->att.key = parameter; 842 this->att.key = parameter;
844 return this; 843 return this;
845 } 844 }
846 845
847 QPDFJob::AttConfig* 846 QPDFJob::AttConfig*
848 -QPDFJob::AttConfig::filename(char const* parameter) 847 +QPDFJob::AttConfig::filename(std::string const& parameter)
849 { 848 {
850 this->att.filename = parameter; 849 this->att.filename = parameter;
851 return this; 850 return this;
852 } 851 }
853 852
854 QPDFJob::AttConfig* 853 QPDFJob::AttConfig*
855 -QPDFJob::AttConfig::creationdate(char const* parameter) 854 +QPDFJob::AttConfig::creationdate(std::string const& parameter)
856 { 855 {
857 if (! QUtil::pdf_time_to_qpdf_time(parameter)) 856 if (! QUtil::pdf_time_to_qpdf_time(parameter))
858 { 857 {
@@ -863,7 +862,7 @@ QPDFJob::AttConfig::creationdate(char const* parameter) @@ -863,7 +862,7 @@ QPDFJob::AttConfig::creationdate(char const* parameter)
863 } 862 }
864 863
865 QPDFJob::AttConfig* 864 QPDFJob::AttConfig*
866 -QPDFJob::AttConfig::moddate(char const* parameter) 865 +QPDFJob::AttConfig::moddate(std::string const& parameter)
867 { 866 {
868 if (! QUtil::pdf_time_to_qpdf_time(parameter)) 867 if (! QUtil::pdf_time_to_qpdf_time(parameter))
869 { 868 {
@@ -874,9 +873,9 @@ QPDFJob::AttConfig::moddate(char const* parameter) @@ -874,9 +873,9 @@ QPDFJob::AttConfig::moddate(char const* parameter)
874 } 873 }
875 874
876 QPDFJob::AttConfig* 875 QPDFJob::AttConfig*
877 -QPDFJob::AttConfig::mimetype(char const* parameter) 876 +QPDFJob::AttConfig::mimetype(std::string const& parameter)
878 { 877 {
879 - if (strchr(parameter, '/') == nullptr) 878 + if (parameter.find('/') == std::string::npos)
880 { 879 {
881 usage("mime type should be specified as type/subtype"); 880 usage("mime type should be specified as type/subtype");
882 } 881 }
@@ -885,7 +884,7 @@ QPDFJob::AttConfig::mimetype(char const* parameter) @@ -885,7 +884,7 @@ QPDFJob::AttConfig::mimetype(char const* parameter)
885 } 884 }
886 885
887 QPDFJob::AttConfig* 886 QPDFJob::AttConfig*
888 -QPDFJob::AttConfig::description(char const* parameter) 887 +QPDFJob::AttConfig::description(std::string const& parameter)
889 { 888 {
890 this->att.description = parameter; 889 this->att.description = parameter;
891 return this; 890 return this;
@@ -999,7 +998,7 @@ QPDFJob::UOConfig::endUnderlayOverlay() @@ -999,7 +998,7 @@ QPDFJob::UOConfig::endUnderlayOverlay()
999 } 998 }
1000 999
1001 QPDFJob::UOConfig* 1000 QPDFJob::UOConfig*
1002 -QPDFJob::UOConfig::file(char const* parameter) 1001 +QPDFJob::UOConfig::file(std::string const& parameter)
1003 { 1002 {
1004 if (! config->o.m->under_overlay->filename.empty()) 1003 if (! config->o.m->under_overlay->filename.empty())
1005 { 1004 {
@@ -1013,37 +1012,37 @@ QPDFJob::UOConfig::file(char const* parameter) @@ -1013,37 +1012,37 @@ QPDFJob::UOConfig::file(char const* parameter)
1013 } 1012 }
1014 1013
1015 QPDFJob::UOConfig* 1014 QPDFJob::UOConfig*
1016 -QPDFJob::UOConfig::to(char const* parameter) 1015 +QPDFJob::UOConfig::to(std::string const& parameter)
1017 { 1016 {
1018 - config->o.parseNumrange(parameter, 0); 1017 + config->o.parseNumrange(parameter.c_str(), 0);
1019 config->o.m->under_overlay->to_nr = parameter; 1018 config->o.m->under_overlay->to_nr = parameter;
1020 return this; 1019 return this;
1021 } 1020 }
1022 1021
1023 QPDFJob::UOConfig* 1022 QPDFJob::UOConfig*
1024 -QPDFJob::UOConfig::from(char const* parameter) 1023 +QPDFJob::UOConfig::from(std::string const& parameter)
1025 { 1024 {
1026 - if (strlen(parameter)) 1025 + if (! parameter.empty())
1027 { 1026 {
1028 - config->o.parseNumrange(parameter, 0); 1027 + config->o.parseNumrange(parameter.c_str(), 0);
1029 } 1028 }
1030 config->o.m->under_overlay->from_nr = parameter; 1029 config->o.m->under_overlay->from_nr = parameter;
1031 return this; 1030 return this;
1032 } 1031 }
1033 1032
1034 QPDFJob::UOConfig* 1033 QPDFJob::UOConfig*
1035 -QPDFJob::UOConfig::repeat(char const* parameter) 1034 +QPDFJob::UOConfig::repeat(std::string const& parameter)
1036 { 1035 {
1037 - if (strlen(parameter)) 1036 + if (! parameter.empty())
1038 { 1037 {
1039 - config->o.parseNumrange(parameter, 0); 1038 + config->o.parseNumrange(parameter.c_str(), 0);
1040 } 1039 }
1041 config->o.m->under_overlay->repeat_nr = parameter; 1040 config->o.m->under_overlay->repeat_nr = parameter;
1042 return this; 1041 return this;
1043 } 1042 }
1044 1043
1045 QPDFJob::UOConfig* 1044 QPDFJob::UOConfig*
1046 -QPDFJob::UOConfig::password(char const* parameter) 1045 +QPDFJob::UOConfig::password(std::string const& parameter)
1047 { 1046 {
1048 config->o.m->under_overlay->password = QUtil::make_shared_cstr(parameter); 1047 config->o.m->under_overlay->password = QUtil::make_shared_cstr(parameter);
1049 return this; 1048 return this;
@@ -1086,42 +1085,42 @@ QPDFJob::EncConfig::allowInsecure() @@ -1086,42 +1085,42 @@ QPDFJob::EncConfig::allowInsecure()
1086 } 1085 }
1087 1086
1088 QPDFJob::EncConfig* 1087 QPDFJob::EncConfig*
1089 -QPDFJob::EncConfig::accessibility(char const* parameter) 1088 +QPDFJob::EncConfig::accessibility(std::string const& parameter)
1090 { 1089 {
1091 - config->o.m->r3_accessibility = (strcmp(parameter, "y") == 0); 1090 + config->o.m->r3_accessibility = (parameter == "y");
1092 return this; 1091 return this;
1093 } 1092 }
1094 1093
1095 QPDFJob::EncConfig* 1094 QPDFJob::EncConfig*
1096 -QPDFJob::EncConfig::extract(char const* parameter) 1095 +QPDFJob::EncConfig::extract(std::string const& parameter)
1097 { 1096 {
1098 if (config->o.m->keylen == 40) 1097 if (config->o.m->keylen == 40)
1099 { 1098 {
1100 - config->o.m->r2_extract = (strcmp(parameter, "y") == 0); 1099 + config->o.m->r2_extract = (parameter == "y");
1101 } 1100 }
1102 else 1101 else
1103 { 1102 {
1104 - config->o.m->r3_extract = (strcmp(parameter, "y") == 0); 1103 + config->o.m->r3_extract = (parameter == "y");
1105 } 1104 }
1106 return this; 1105 return this;
1107 } 1106 }
1108 1107
1109 QPDFJob::EncConfig* 1108 QPDFJob::EncConfig*
1110 -QPDFJob::EncConfig::print(char const* parameter) 1109 +QPDFJob::EncConfig::print(std::string const& parameter)
1111 { 1110 {
1112 if (config->o.m->keylen == 40) 1111 if (config->o.m->keylen == 40)
1113 { 1112 {
1114 - config->o.m->r2_print = (strcmp(parameter, "y") == 0); 1113 + config->o.m->r2_print = (parameter == "y");
1115 } 1114 }
1116 - else if (strcmp(parameter, "full") == 0) 1115 + else if (parameter == "full")
1117 { 1116 {
1118 config->o.m->r3_print = qpdf_r3p_full; 1117 config->o.m->r3_print = qpdf_r3p_full;
1119 } 1118 }
1120 - else if (strcmp(parameter, "low") == 0) 1119 + else if (parameter == "low")
1121 { 1120 {
1122 config->o.m->r3_print = qpdf_r3p_low; 1121 config->o.m->r3_print = qpdf_r3p_low;
1123 } 1122 }
1124 - else if (strcmp(parameter, "none") == 0) 1123 + else if (parameter == "none")
1125 { 1124 {
1126 config->o.m->r3_print = qpdf_r3p_none; 1125 config->o.m->r3_print = qpdf_r3p_none;
1127 } 1126 }
@@ -1133,41 +1132,41 @@ QPDFJob::EncConfig::print(char const* parameter) @@ -1133,41 +1132,41 @@ QPDFJob::EncConfig::print(char const* parameter)
1133 } 1132 }
1134 1133
1135 QPDFJob::EncConfig* 1134 QPDFJob::EncConfig*
1136 -QPDFJob::EncConfig::modify(char const* parameter) 1135 +QPDFJob::EncConfig::modify(std::string const& parameter)
1137 { 1136 {
1138 if (config->o.m->keylen == 40) 1137 if (config->o.m->keylen == 40)
1139 { 1138 {
1140 - config->o.m->r2_modify = (strcmp(parameter, "y") == 0); 1139 + config->o.m->r2_modify = (parameter == "y");
1141 } 1140 }
1142 - else if (strcmp(parameter, "all") == 0) 1141 + else if (parameter == "all")
1143 { 1142 {
1144 config->o.m->r3_assemble = true; 1143 config->o.m->r3_assemble = true;
1145 config->o.m->r3_annotate_and_form = true; 1144 config->o.m->r3_annotate_and_form = true;
1146 config->o.m->r3_form_filling = true; 1145 config->o.m->r3_form_filling = true;
1147 config->o.m->r3_modify_other = true; 1146 config->o.m->r3_modify_other = true;
1148 } 1147 }
1149 - else if (strcmp(parameter, "annotate") == 0) 1148 + else if (parameter == "annotate")
1150 { 1149 {
1151 config->o.m->r3_assemble = true; 1150 config->o.m->r3_assemble = true;
1152 config->o.m->r3_annotate_and_form = true; 1151 config->o.m->r3_annotate_and_form = true;
1153 config->o.m->r3_form_filling = true; 1152 config->o.m->r3_form_filling = true;
1154 config->o.m->r3_modify_other = false; 1153 config->o.m->r3_modify_other = false;
1155 } 1154 }
1156 - else if (strcmp(parameter, "form") == 0) 1155 + else if (parameter == "form")
1157 { 1156 {
1158 config->o.m->r3_assemble = true; 1157 config->o.m->r3_assemble = true;
1159 config->o.m->r3_annotate_and_form = false; 1158 config->o.m->r3_annotate_and_form = false;
1160 config->o.m->r3_form_filling = true; 1159 config->o.m->r3_form_filling = true;
1161 config->o.m->r3_modify_other = false; 1160 config->o.m->r3_modify_other = false;
1162 } 1161 }
1163 - else if (strcmp(parameter, "assembly") == 0) 1162 + else if (parameter == "assembly")
1164 { 1163 {
1165 config->o.m->r3_assemble = true; 1164 config->o.m->r3_assemble = true;
1166 config->o.m->r3_annotate_and_form = false; 1165 config->o.m->r3_annotate_and_form = false;
1167 config->o.m->r3_form_filling = false; 1166 config->o.m->r3_form_filling = false;
1168 config->o.m->r3_modify_other = false; 1167 config->o.m->r3_modify_other = false;
1169 } 1168 }
1170 - else if (strcmp(parameter, "none") == 0) 1169 + else if (parameter == "none")
1171 { 1170 {
1172 config->o.m->r3_assemble = false; 1171 config->o.m->r3_assemble = false;
1173 config->o.m->r3_annotate_and_form = false; 1172 config->o.m->r3_annotate_and_form = false;
@@ -1189,44 +1188,44 @@ QPDFJob::EncConfig::cleartextMetadata() @@ -1189,44 +1188,44 @@ QPDFJob::EncConfig::cleartextMetadata()
1189 } 1188 }
1190 1189
1191 QPDFJob::EncConfig* 1190 QPDFJob::EncConfig*
1192 -QPDFJob::EncConfig::assemble(char const* parameter) 1191 +QPDFJob::EncConfig::assemble(std::string const& parameter)
1193 { 1192 {
1194 - config->o.m->r3_assemble = (strcmp(parameter, "y") == 0); 1193 + config->o.m->r3_assemble = (parameter == "y");
1195 return this; 1194 return this;
1196 } 1195 }
1197 1196
1198 QPDFJob::EncConfig* 1197 QPDFJob::EncConfig*
1199 -QPDFJob::EncConfig::annotate(char const* parameter) 1198 +QPDFJob::EncConfig::annotate(std::string const& parameter)
1200 { 1199 {
1201 if (config->o.m->keylen == 40) 1200 if (config->o.m->keylen == 40)
1202 { 1201 {
1203 - config->o.m->r2_annotate = (strcmp(parameter, "y") == 0); 1202 + config->o.m->r2_annotate = (parameter == "y");
1204 } 1203 }
1205 else 1204 else
1206 { 1205 {
1207 - config->o.m->r3_annotate_and_form = (strcmp(parameter, "y") == 0); 1206 + config->o.m->r3_annotate_and_form = (parameter == "y");
1208 } 1207 }
1209 return this; 1208 return this;
1210 } 1209 }
1211 1210
1212 QPDFJob::EncConfig* 1211 QPDFJob::EncConfig*
1213 -QPDFJob::EncConfig::form(char const* parameter) 1212 +QPDFJob::EncConfig::form(std::string const& parameter)
1214 { 1213 {
1215 - config->o.m->r3_form_filling = (strcmp(parameter, "y") == 0); 1214 + config->o.m->r3_form_filling = (parameter == "y");
1216 return this; 1215 return this;
1217 } 1216 }
1218 1217
1219 QPDFJob::EncConfig* 1218 QPDFJob::EncConfig*
1220 -QPDFJob::EncConfig::modifyOther(char const* parameter) 1219 +QPDFJob::EncConfig::modifyOther(std::string const& parameter)
1221 { 1220 {
1222 - config->o.m->r3_modify_other = (strcmp(parameter, "y") == 0); 1221 + config->o.m->r3_modify_other = (parameter == "y");
1223 return this; 1222 return this;
1224 } 1223 }
1225 1224
1226 QPDFJob::EncConfig* 1225 QPDFJob::EncConfig*
1227 -QPDFJob::EncConfig::useAes(char const* parameter) 1226 +QPDFJob::EncConfig::useAes(std::string const& parameter)
1228 { 1227 {
1229 - config->o.m->use_aes = (strcmp(parameter, "y") == 0); 1228 + config->o.m->use_aes = (parameter == "y");
1230 return this; 1229 return this;
1231 } 1230 }
1232 1231
libqpdf/QUtil.cc
@@ -2615,9 +2615,9 @@ QUtil::possible_repaired_encodings(std::string supplied) @@ -2615,9 +2615,9 @@ QUtil::possible_repaired_encodings(std::string supplied)
2615 } 2615 }
2616 2616
2617 #ifndef QPDF_NO_WCHAR_T 2617 #ifndef QPDF_NO_WCHAR_T
2618 -int  
2619 -QUtil::call_main_from_wmain(int argc, wchar_t* argv[],  
2620 - std::function<int(int, char*[])> realmain) 2618 +static int
  2619 +call_main_from_wmain(bool, int argc, wchar_t const* const argv[],
  2620 + std::function<int(int, char*[])> realmain)
2621 { 2621 {
2622 // argv contains UTF-16-encoded strings with a 16-bit wchar_t. 2622 // argv contains UTF-16-encoded strings with a 16-bit wchar_t.
2623 // Convert this to UTF-8-encoded strings for compatibility with 2623 // Convert this to UTF-8-encoded strings for compatibility with
@@ -2640,7 +2640,8 @@ QUtil::call_main_from_wmain(int argc, wchar_t* argv[], @@ -2640,7 +2640,8 @@ QUtil::call_main_from_wmain(int argc, wchar_t* argv[],
2640 utf8_argv.push_back(QUtil::make_shared_cstr(utf8)); 2640 utf8_argv.push_back(QUtil::make_shared_cstr(utf8));
2641 } 2641 }
2642 auto utf8_argv_sp = 2642 auto utf8_argv_sp =
2643 - std::shared_ptr<char*>(new char*[1+utf8_argv.size()], std::default_delete<char*[]>()); 2643 + std::shared_ptr<char*>(
  2644 + new char*[1+utf8_argv.size()], std::default_delete<char*[]>());
2644 char** new_argv = utf8_argv_sp.get(); 2645 char** new_argv = utf8_argv_sp.get();
2645 for (size_t i = 0; i < utf8_argv.size(); ++i) 2646 for (size_t i = 0; i < utf8_argv.size(); ++i)
2646 { 2647 {
@@ -2650,4 +2651,23 @@ QUtil::call_main_from_wmain(int argc, wchar_t* argv[], @@ -2650,4 +2651,23 @@ QUtil::call_main_from_wmain(int argc, wchar_t* argv[],
2650 new_argv[argc] = 0; 2651 new_argv[argc] = 0;
2651 return realmain(argc, new_argv); 2652 return realmain(argc, new_argv);
2652 } 2653 }
  2654 +
  2655 +int
  2656 +QUtil::call_main_from_wmain(int argc, wchar_t* argv[],
  2657 + std::function<int(int, char*[])> realmain)
  2658 +{
  2659 + return ::call_main_from_wmain(true, argc, argv, realmain);
  2660 +}
  2661 +
  2662 +int
  2663 +QUtil::call_main_from_wmain(
  2664 + int argc, wchar_t const* const argv[],
  2665 + std::function<int(int, char const* const[])> realmain)
  2666 +{
  2667 + return ::call_main_from_wmain(
  2668 + true, argc, argv, [realmain](int new_argc, char* new_argv[]) {
  2669 + return realmain(new_argc, new_argv);
  2670 + });
  2671 +}
  2672 +
2653 #endif // QPDF_NO_WCHAR_T 2673 #endif // QPDF_NO_WCHAR_T
libqpdf/qpdf/QPDFArgParser.hh
@@ -21,16 +21,6 @@ @@ -21,16 +21,6 @@
21 // done mostly by automatically-generated code (one-off code for 21 // done mostly by automatically-generated code (one-off code for
22 // qpdf), though the handlers themselves are hand-coded. See 22 // qpdf), though the handlers themselves are hand-coded. See
23 // generate_auto_job at the top of the source tree for details. 23 // generate_auto_job at the top of the source tree for details.
24 -  
25 -// Note about memory: there is code that expects argv to be a char*[],  
26 -// meaning that arguments are writable. Several operations, including  
27 -// reading arguments from a file or parsing a line for bash  
28 -// completion, involve fabricating an argv array. To ensure that the  
29 -// memory is valid and is cleaned up properly, we keep various vectors  
30 -// of smart character pointers that argv points into. In order for  
31 -// those pointers to remain valid, the QPDFArgParser instance must  
32 -// remain in scope for the life of any code that may reference  
33 -// anything from argv.  
34 class QPDFArgParser 24 class QPDFArgParser
35 { 25 {
36 public: 26 public:
@@ -38,7 +28,7 @@ class QPDFArgParser @@ -38,7 +28,7 @@ class QPDFArgParser
38 // name of the executable for setting up completion. This may be 28 // name of the executable for setting up completion. This may be
39 // needed if the program is invoked by a wrapper. 29 // needed if the program is invoked by a wrapper.
40 QPDF_DLL 30 QPDF_DLL
41 - QPDFArgParser(int argc, char* argv[], char const* progname_env); 31 + QPDFArgParser(int argc, char const* const argv[], char const* progname_env);
42 32
43 // Calls exit(0) if a help option is given or if in completion 33 // Calls exit(0) if a help option is given or if in completion
44 // mode. If there are argument parsing errors, QPDFUsage is 34 // mode. If there are argument parsing errors, QPDFUsage is
@@ -60,7 +50,7 @@ class QPDFArgParser @@ -60,7 +50,7 @@ class QPDFArgParser
60 // a series of options that end with `--`. 50 // a series of options that end with `--`.
61 51
62 typedef std::function<void()> bare_arg_handler_t; 52 typedef std::function<void()> bare_arg_handler_t;
63 - typedef std::function<void(char*)> param_arg_handler_t; 53 + typedef std::function<void(std::string const&)> param_arg_handler_t;
64 54
65 QPDF_DLL 55 QPDF_DLL
66 void selectMainOptionTable(); 56 void selectMainOptionTable();
@@ -163,7 +153,7 @@ class QPDFArgParser @@ -163,7 +153,7 @@ class QPDFArgParser
163 // unknown value returns a string directing the user to run the 153 // unknown value returns a string directing the user to run the
164 // top-level --help option. 154 // top-level --help option.
165 QPDF_DLL 155 QPDF_DLL
166 - std::string getHelp(char const* topic_or_option); 156 + std::string getHelp(std::string const& topic_or_option);
167 157
168 // Convenience methods for adding member functions of a class as 158 // Convenience methods for adding member functions of a class as
169 // handlers. 159 // handlers.
@@ -173,7 +163,7 @@ class QPDFArgParser @@ -173,7 +163,7 @@ class QPDFArgParser
173 return std::bind(std::mem_fn(f), o); 163 return std::bind(std::mem_fn(f), o);
174 } 164 }
175 template <class T> 165 template <class T>
176 - static param_arg_handler_t bindParam(void (T::*f)(char *), T* o) 166 + static param_arg_handler_t bindParam(void (T::*f)(std::string const&), T* o)
177 { 167 {
178 return std::bind(std::mem_fn(f), o, std::placeholders::_1); 168 return std::bind(std::mem_fn(f), o, std::placeholders::_1);
179 } 169 }
@@ -238,13 +228,13 @@ class QPDFArgParser @@ -238,13 +228,13 @@ class QPDFArgParser
238 228
239 void argCompletionBash(); 229 void argCompletionBash();
240 void argCompletionZsh(); 230 void argCompletionZsh();
241 - void argHelp(char*);  
242 - void invalidHelpArg(char*); 231 + void argHelp(std::string const&);
  232 + void invalidHelpArg(std::string const&);
243 233
244 void checkCompletion(); 234 void checkCompletion();
245 void handleArgFileArguments(); 235 void handleArgFileArguments();
246 void handleBashArguments(); 236 void handleBashArguments();
247 - void readArgsFromFile(char const* filename); 237 + void readArgsFromFile(std::string const& filename);
248 void doFinalChecks(); 238 void doFinalChecks();
249 void addOptionsToCompletions(option_table_t&); 239 void addOptionsToCompletions(option_table_t&);
250 void addChoicesToCompletions( 240 void addChoicesToCompletions(
@@ -267,12 +257,12 @@ class QPDFArgParser @@ -267,12 +257,12 @@ class QPDFArgParser
267 ~Members() = default; 257 ~Members() = default;
268 258
269 private: 259 private:
270 - Members(int argc, char* argv[], char const* progname_env); 260 + Members(int argc, char const* const argv[], char const* progname_env);
271 Members(Members const&) = delete; 261 Members(Members const&) = delete;
272 262
273 int argc; 263 int argc;
274 - char** argv;  
275 - char const* whoami; 264 + char const* const* argv;
  265 + std::string whoami;
276 std::string progname_env; 266 std::string progname_env;
277 int cur_arg; 267 int cur_arg;
278 bool bash_completion; 268 bool bash_completion;
@@ -287,10 +277,10 @@ class QPDFArgParser @@ -287,10 +277,10 @@ class QPDFArgParser
287 option_table_t* option_table; 277 option_table_t* option_table;
288 std::string option_table_name; 278 std::string option_table_name;
289 bare_arg_handler_t final_check_handler; 279 bare_arg_handler_t final_check_handler;
290 - std::vector<std::shared_ptr<char>> new_argv;  
291 - std::vector<std::shared_ptr<char>> bash_argv;  
292 - std::shared_ptr<char*> argv_ph;  
293 - std::shared_ptr<char*> bash_argv_ph; 280 + std::vector<std::shared_ptr<char const>> new_argv;
  281 + std::vector<std::shared_ptr<char const>> bash_argv;
  282 + std::shared_ptr<char const*> argv_ph;
  283 + std::shared_ptr<char const*> bash_argv_ph;
294 std::map<std::string, HelpTopic> help_topics; 284 std::map<std::string, HelpTopic> help_topics;
295 std::map<std::string, HelpTopic> option_help; 285 std::map<std::string, HelpTopic> option_help;
296 std::string help_footer; 286 std::string help_footer;
libqpdf/qpdf/auto_job_decl.hh
@@ -17,7 +17,7 @@ void argCopyright(); @@ -17,7 +17,7 @@ void argCopyright();
17 void argJsonHelp(); 17 void argJsonHelp();
18 void argShowCrypto(); 18 void argShowCrypto();
19 void argJobJsonHelp(); 19 void argJobJsonHelp();
20 -void argPositional(char*); 20 +void argPositional(std::string const&);
21 void argAddAttachment(); 21 void argAddAttachment();
22 void argCopyAttachmentsFrom(); 22 void argCopyAttachmentsFrom();
23 void argEmpty(); 23 void argEmpty();
@@ -26,17 +26,17 @@ void argOverlay(); @@ -26,17 +26,17 @@ void argOverlay();
26 void argPages(); 26 void argPages();
27 void argReplaceInput(); 27 void argReplaceInput();
28 void argUnderlay(); 28 void argUnderlay();
29 -void argPagesPositional(char*);  
30 -void argPagesPassword(char *); 29 +void argPagesPositional(std::string const&);
  30 +void argPagesPassword(std::string const&);
31 void argEndPages(); 31 void argEndPages();
32 -void argEncPositional(char*); 32 +void argEncPositional(std::string const&);
33 void argEndEncryption(); 33 void argEndEncryption();
34 void argEnd40BitEncryption(); 34 void argEnd40BitEncryption();
35 void argEnd128BitEncryption(); 35 void argEnd128BitEncryption();
36 void argEnd256BitEncryption(); 36 void argEnd256BitEncryption();
37 -void argUOPositional(char*); 37 +void argUOPositional(std::string const&);
38 void argEndUnderlayOverlay(); 38 void argEndUnderlayOverlay();
39 -void argAttPositional(char*); 39 +void argAttPositional(std::string const&);
40 void argEndAttachment(); 40 void argEndAttachment();
41 -void argCopyAttPositional(char*); 41 +void argCopyAttPositional(std::string const&);
42 void argEndCopyAttachment(); 42 void argEndCopyAttachment();
libqpdf/qpdf/auto_job_init.hh
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 auto b = [this](void (ArgParser::*f)()) { 6 auto b = [this](void (ArgParser::*f)()) {
7 return QPDFArgParser::bindBare(f, this); 7 return QPDFArgParser::bindBare(f, this);
8 }; 8 };
9 -auto p = [this](void (ArgParser::*f)(char *)) { 9 +auto p = [this](void (ArgParser::*f)(std::string const&)) {
10 return QPDFArgParser::bindParam(f, this); 10 return QPDFArgParser::bindParam(f, this);
11 }; 11 };
12 12
@@ -79,88 +79,88 @@ this-&gt;ap.addBare(&quot;underlay&quot;, b(&amp;ArgParser::argUnderlay)); @@ -79,88 +79,88 @@ this-&gt;ap.addBare(&quot;underlay&quot;, b(&amp;ArgParser::argUnderlay));
79 this->ap.addBare("verbose", [this](){c_main->verbose();}); 79 this->ap.addBare("verbose", [this](){c_main->verbose();});
80 this->ap.addBare("warning-exit-0", [this](){c_main->warningExit0();}); 80 this->ap.addBare("warning-exit-0", [this](){c_main->warningExit0();});
81 this->ap.addBare("with-images", [this](){c_main->withImages();}); 81 this->ap.addBare("with-images", [this](){c_main->withImages();});
82 -this->ap.addRequiredParameter("compression-level", [this](char *x){c_main->compressionLevel(x);}, "level");  
83 -this->ap.addRequiredParameter("copy-encryption", [this](char *x){c_main->copyEncryption(x);}, "file");  
84 -this->ap.addRequiredParameter("encryption-file-password", [this](char *x){c_main->encryptionFilePassword(x);}, "password");  
85 -this->ap.addRequiredParameter("force-version", [this](char *x){c_main->forceVersion(x);}, "version");  
86 -this->ap.addRequiredParameter("ii-min-bytes", [this](char *x){c_main->iiMinBytes(x);}, "minimum");  
87 -this->ap.addRequiredParameter("job-json-file", [this](char *x){c_main->jobJsonFile(x);}, "file");  
88 -this->ap.addRequiredParameter("json-object", [this](char *x){c_main->jsonObject(x);}, "trailer");  
89 -this->ap.addRequiredParameter("keep-files-open-threshold", [this](char *x){c_main->keepFilesOpenThreshold(x);}, "count");  
90 -this->ap.addRequiredParameter("linearize-pass1", [this](char *x){c_main->linearizePass1(x);}, "filename");  
91 -this->ap.addRequiredParameter("min-version", [this](char *x){c_main->minVersion(x);}, "version");  
92 -this->ap.addRequiredParameter("oi-min-area", [this](char *x){c_main->oiMinArea(x);}, "minimum");  
93 -this->ap.addRequiredParameter("oi-min-height", [this](char *x){c_main->oiMinHeight(x);}, "minimum");  
94 -this->ap.addRequiredParameter("oi-min-width", [this](char *x){c_main->oiMinWidth(x);}, "minimum");  
95 -this->ap.addRequiredParameter("password", [this](char *x){c_main->password(x);}, "password");  
96 -this->ap.addRequiredParameter("password-file", [this](char *x){c_main->passwordFile(x);}, "password");  
97 -this->ap.addRequiredParameter("remove-attachment", [this](char *x){c_main->removeAttachment(x);}, "attachment");  
98 -this->ap.addRequiredParameter("rotate", [this](char *x){c_main->rotate(x);}, "[+|-]angle");  
99 -this->ap.addRequiredParameter("show-attachment", [this](char *x){c_main->showAttachment(x);}, "attachment");  
100 -this->ap.addRequiredParameter("show-object", [this](char *x){c_main->showObject(x);}, "trailer");  
101 -this->ap.addOptionalParameter("collate", [this](char *x){c_main->collate(x);});  
102 -this->ap.addOptionalParameter("split-pages", [this](char *x){c_main->splitPages(x);});  
103 -this->ap.addChoices("compress-streams", [this](char *x){c_main->compressStreams(x);}, true, yn_choices);  
104 -this->ap.addChoices("decode-level", [this](char *x){c_main->decodeLevel(x);}, true, decode_level_choices);  
105 -this->ap.addChoices("flatten-annotations", [this](char *x){c_main->flattenAnnotations(x);}, true, flatten_choices);  
106 -this->ap.addChoices("json-key", [this](char *x){c_main->jsonKey(x);}, true, json_key_choices);  
107 -this->ap.addChoices("keep-files-open", [this](char *x){c_main->keepFilesOpen(x);}, true, yn_choices);  
108 -this->ap.addChoices("normalize-content", [this](char *x){c_main->normalizeContent(x);}, true, yn_choices);  
109 -this->ap.addChoices("object-streams", [this](char *x){c_main->objectStreams(x);}, true, object_streams_choices);  
110 -this->ap.addChoices("password-mode", [this](char *x){c_main->passwordMode(x);}, true, password_mode_choices);  
111 -this->ap.addChoices("remove-unreferenced-resources", [this](char *x){c_main->removeUnreferencedResources(x);}, true, remove_unref_choices);  
112 -this->ap.addChoices("stream-data", [this](char *x){c_main->streamData(x);}, true, stream_data_choices);  
113 -this->ap.addChoices("json", [this](char *x){c_main->json(x);}, false, json_version_choices); 82 +this->ap.addRequiredParameter("compression-level", [this](std::string const& x){c_main->compressionLevel(x);}, "level");
  83 +this->ap.addRequiredParameter("copy-encryption", [this](std::string const& x){c_main->copyEncryption(x);}, "file");
  84 +this->ap.addRequiredParameter("encryption-file-password", [this](std::string const& x){c_main->encryptionFilePassword(x);}, "password");
  85 +this->ap.addRequiredParameter("force-version", [this](std::string const& x){c_main->forceVersion(x);}, "version");
  86 +this->ap.addRequiredParameter("ii-min-bytes", [this](std::string const& x){c_main->iiMinBytes(x);}, "minimum");
  87 +this->ap.addRequiredParameter("job-json-file", [this](std::string const& x){c_main->jobJsonFile(x);}, "file");
  88 +this->ap.addRequiredParameter("json-object", [this](std::string const& x){c_main->jsonObject(x);}, "trailer");
  89 +this->ap.addRequiredParameter("keep-files-open-threshold", [this](std::string const& x){c_main->keepFilesOpenThreshold(x);}, "count");
  90 +this->ap.addRequiredParameter("linearize-pass1", [this](std::string const& x){c_main->linearizePass1(x);}, "filename");
  91 +this->ap.addRequiredParameter("min-version", [this](std::string const& x){c_main->minVersion(x);}, "version");
  92 +this->ap.addRequiredParameter("oi-min-area", [this](std::string const& x){c_main->oiMinArea(x);}, "minimum");
  93 +this->ap.addRequiredParameter("oi-min-height", [this](std::string const& x){c_main->oiMinHeight(x);}, "minimum");
  94 +this->ap.addRequiredParameter("oi-min-width", [this](std::string const& x){c_main->oiMinWidth(x);}, "minimum");
  95 +this->ap.addRequiredParameter("password", [this](std::string const& x){c_main->password(x);}, "password");
  96 +this->ap.addRequiredParameter("password-file", [this](std::string const& x){c_main->passwordFile(x);}, "password");
  97 +this->ap.addRequiredParameter("remove-attachment", [this](std::string const& x){c_main->removeAttachment(x);}, "attachment");
  98 +this->ap.addRequiredParameter("rotate", [this](std::string const& x){c_main->rotate(x);}, "[+|-]angle");
  99 +this->ap.addRequiredParameter("show-attachment", [this](std::string const& x){c_main->showAttachment(x);}, "attachment");
  100 +this->ap.addRequiredParameter("show-object", [this](std::string const& x){c_main->showObject(x);}, "trailer");
  101 +this->ap.addOptionalParameter("collate", [this](std::string const& x){c_main->collate(x);});
  102 +this->ap.addOptionalParameter("split-pages", [this](std::string const& x){c_main->splitPages(x);});
  103 +this->ap.addChoices("compress-streams", [this](std::string const& x){c_main->compressStreams(x);}, true, yn_choices);
  104 +this->ap.addChoices("decode-level", [this](std::string const& x){c_main->decodeLevel(x);}, true, decode_level_choices);
  105 +this->ap.addChoices("flatten-annotations", [this](std::string const& x){c_main->flattenAnnotations(x);}, true, flatten_choices);
  106 +this->ap.addChoices("json-key", [this](std::string const& x){c_main->jsonKey(x);}, true, json_key_choices);
  107 +this->ap.addChoices("keep-files-open", [this](std::string const& x){c_main->keepFilesOpen(x);}, true, yn_choices);
  108 +this->ap.addChoices("normalize-content", [this](std::string const& x){c_main->normalizeContent(x);}, true, yn_choices);
  109 +this->ap.addChoices("object-streams", [this](std::string const& x){c_main->objectStreams(x);}, true, object_streams_choices);
  110 +this->ap.addChoices("password-mode", [this](std::string const& x){c_main->passwordMode(x);}, true, password_mode_choices);
  111 +this->ap.addChoices("remove-unreferenced-resources", [this](std::string const& x){c_main->removeUnreferencedResources(x);}, true, remove_unref_choices);
  112 +this->ap.addChoices("stream-data", [this](std::string const& x){c_main->streamData(x);}, true, stream_data_choices);
  113 +this->ap.addChoices("json", [this](std::string const& x){c_main->json(x);}, false, json_version_choices);
114 this->ap.registerOptionTable("pages", b(&ArgParser::argEndPages)); 114 this->ap.registerOptionTable("pages", b(&ArgParser::argEndPages));
115 this->ap.addPositional(p(&ArgParser::argPagesPositional)); 115 this->ap.addPositional(p(&ArgParser::argPagesPositional));
116 this->ap.addRequiredParameter("password", p(&ArgParser::argPagesPassword), "password"); 116 this->ap.addRequiredParameter("password", p(&ArgParser::argPagesPassword), "password");
117 this->ap.registerOptionTable("encryption", b(&ArgParser::argEndEncryption)); 117 this->ap.registerOptionTable("encryption", b(&ArgParser::argEndEncryption));
118 this->ap.addPositional(p(&ArgParser::argEncPositional)); 118 this->ap.addPositional(p(&ArgParser::argEncPositional));
119 this->ap.registerOptionTable("40-bit encryption", b(&ArgParser::argEnd40BitEncryption)); 119 this->ap.registerOptionTable("40-bit encryption", b(&ArgParser::argEnd40BitEncryption));
120 -this->ap.addChoices("extract", [this](char *x){c_enc->extract(x);}, true, yn_choices);  
121 -this->ap.addChoices("annotate", [this](char *x){c_enc->annotate(x);}, true, yn_choices);  
122 -this->ap.addChoices("print", [this](char *x){c_enc->print(x);}, true, yn_choices);  
123 -this->ap.addChoices("modify", [this](char *x){c_enc->modify(x);}, true, yn_choices); 120 +this->ap.addChoices("extract", [this](std::string const& x){c_enc->extract(x);}, true, yn_choices);
  121 +this->ap.addChoices("annotate", [this](std::string const& x){c_enc->annotate(x);}, true, yn_choices);
  122 +this->ap.addChoices("print", [this](std::string const& x){c_enc->print(x);}, true, yn_choices);
  123 +this->ap.addChoices("modify", [this](std::string const& x){c_enc->modify(x);}, true, yn_choices);
124 this->ap.registerOptionTable("128-bit encryption", b(&ArgParser::argEnd128BitEncryption)); 124 this->ap.registerOptionTable("128-bit encryption", b(&ArgParser::argEnd128BitEncryption));
125 this->ap.addBare("cleartext-metadata", [this](){c_enc->cleartextMetadata();}); 125 this->ap.addBare("cleartext-metadata", [this](){c_enc->cleartextMetadata();});
126 this->ap.addBare("force-V4", [this](){c_enc->forceV4();}); 126 this->ap.addBare("force-V4", [this](){c_enc->forceV4();});
127 -this->ap.addChoices("accessibility", [this](char *x){c_enc->accessibility(x);}, true, yn_choices);  
128 -this->ap.addChoices("extract", [this](char *x){c_enc->extract(x);}, true, yn_choices);  
129 -this->ap.addChoices("print", [this](char *x){c_enc->print(x);}, true, print128_choices);  
130 -this->ap.addChoices("assemble", [this](char *x){c_enc->assemble(x);}, true, yn_choices);  
131 -this->ap.addChoices("annotate", [this](char *x){c_enc->annotate(x);}, true, yn_choices);  
132 -this->ap.addChoices("form", [this](char *x){c_enc->form(x);}, true, yn_choices);  
133 -this->ap.addChoices("modify-other", [this](char *x){c_enc->modifyOther(x);}, true, yn_choices);  
134 -this->ap.addChoices("modify", [this](char *x){c_enc->modify(x);}, true, modify128_choices);  
135 -this->ap.addChoices("use-aes", [this](char *x){c_enc->useAes(x);}, true, yn_choices); 127 +this->ap.addChoices("accessibility", [this](std::string const& x){c_enc->accessibility(x);}, true, yn_choices);
  128 +this->ap.addChoices("extract", [this](std::string const& x){c_enc->extract(x);}, true, yn_choices);
  129 +this->ap.addChoices("print", [this](std::string const& x){c_enc->print(x);}, true, print128_choices);
  130 +this->ap.addChoices("assemble", [this](std::string const& x){c_enc->assemble(x);}, true, yn_choices);
  131 +this->ap.addChoices("annotate", [this](std::string const& x){c_enc->annotate(x);}, true, yn_choices);
  132 +this->ap.addChoices("form", [this](std::string const& x){c_enc->form(x);}, true, yn_choices);
  133 +this->ap.addChoices("modify-other", [this](std::string const& x){c_enc->modifyOther(x);}, true, yn_choices);
  134 +this->ap.addChoices("modify", [this](std::string const& x){c_enc->modify(x);}, true, modify128_choices);
  135 +this->ap.addChoices("use-aes", [this](std::string const& x){c_enc->useAes(x);}, true, yn_choices);
136 this->ap.registerOptionTable("256-bit encryption", b(&ArgParser::argEnd256BitEncryption)); 136 this->ap.registerOptionTable("256-bit encryption", b(&ArgParser::argEnd256BitEncryption));
137 this->ap.addBare("cleartext-metadata", [this](){c_enc->cleartextMetadata();}); 137 this->ap.addBare("cleartext-metadata", [this](){c_enc->cleartextMetadata();});
138 this->ap.addBare("force-R5", [this](){c_enc->forceR5();}); 138 this->ap.addBare("force-R5", [this](){c_enc->forceR5();});
139 this->ap.addBare("allow-insecure", [this](){c_enc->allowInsecure();}); 139 this->ap.addBare("allow-insecure", [this](){c_enc->allowInsecure();});
140 -this->ap.addChoices("accessibility", [this](char *x){c_enc->accessibility(x);}, true, yn_choices);  
141 -this->ap.addChoices("extract", [this](char *x){c_enc->extract(x);}, true, yn_choices);  
142 -this->ap.addChoices("print", [this](char *x){c_enc->print(x);}, true, print128_choices);  
143 -this->ap.addChoices("assemble", [this](char *x){c_enc->assemble(x);}, true, yn_choices);  
144 -this->ap.addChoices("annotate", [this](char *x){c_enc->annotate(x);}, true, yn_choices);  
145 -this->ap.addChoices("form", [this](char *x){c_enc->form(x);}, true, yn_choices);  
146 -this->ap.addChoices("modify-other", [this](char *x){c_enc->modifyOther(x);}, true, yn_choices);  
147 -this->ap.addChoices("modify", [this](char *x){c_enc->modify(x);}, true, modify128_choices); 140 +this->ap.addChoices("accessibility", [this](std::string const& x){c_enc->accessibility(x);}, true, yn_choices);
  141 +this->ap.addChoices("extract", [this](std::string const& x){c_enc->extract(x);}, true, yn_choices);
  142 +this->ap.addChoices("print", [this](std::string const& x){c_enc->print(x);}, true, print128_choices);
  143 +this->ap.addChoices("assemble", [this](std::string const& x){c_enc->assemble(x);}, true, yn_choices);
  144 +this->ap.addChoices("annotate", [this](std::string const& x){c_enc->annotate(x);}, true, yn_choices);
  145 +this->ap.addChoices("form", [this](std::string const& x){c_enc->form(x);}, true, yn_choices);
  146 +this->ap.addChoices("modify-other", [this](std::string const& x){c_enc->modifyOther(x);}, true, yn_choices);
  147 +this->ap.addChoices("modify", [this](std::string const& x){c_enc->modify(x);}, true, modify128_choices);
148 this->ap.registerOptionTable("underlay/overlay", b(&ArgParser::argEndUnderlayOverlay)); 148 this->ap.registerOptionTable("underlay/overlay", b(&ArgParser::argEndUnderlayOverlay));
149 this->ap.addPositional(p(&ArgParser::argUOPositional)); 149 this->ap.addPositional(p(&ArgParser::argUOPositional));
150 -this->ap.addRequiredParameter("to", [this](char *x){c_uo->to(x);}, "page-range");  
151 -this->ap.addRequiredParameter("from", [this](char *x){c_uo->from(x);}, "page-range");  
152 -this->ap.addRequiredParameter("repeat", [this](char *x){c_uo->repeat(x);}, "page-range");  
153 -this->ap.addRequiredParameter("password", [this](char *x){c_uo->password(x);}, "password"); 150 +this->ap.addRequiredParameter("to", [this](std::string const& x){c_uo->to(x);}, "page-range");
  151 +this->ap.addRequiredParameter("from", [this](std::string const& x){c_uo->from(x);}, "page-range");
  152 +this->ap.addRequiredParameter("repeat", [this](std::string const& x){c_uo->repeat(x);}, "page-range");
  153 +this->ap.addRequiredParameter("password", [this](std::string const& x){c_uo->password(x);}, "password");
154 this->ap.registerOptionTable("attachment", b(&ArgParser::argEndAttachment)); 154 this->ap.registerOptionTable("attachment", b(&ArgParser::argEndAttachment));
155 this->ap.addPositional(p(&ArgParser::argAttPositional)); 155 this->ap.addPositional(p(&ArgParser::argAttPositional));
156 this->ap.addBare("replace", [this](){c_att->replace();}); 156 this->ap.addBare("replace", [this](){c_att->replace();});
157 -this->ap.addRequiredParameter("key", [this](char *x){c_att->key(x);}, "attachment-key");  
158 -this->ap.addRequiredParameter("filename", [this](char *x){c_att->filename(x);}, "filename");  
159 -this->ap.addRequiredParameter("creationdate", [this](char *x){c_att->creationdate(x);}, "creation-date");  
160 -this->ap.addRequiredParameter("moddate", [this](char *x){c_att->moddate(x);}, "modification-date");  
161 -this->ap.addRequiredParameter("mimetype", [this](char *x){c_att->mimetype(x);}, "mime/type");  
162 -this->ap.addRequiredParameter("description", [this](char *x){c_att->description(x);}, "description"); 157 +this->ap.addRequiredParameter("key", [this](std::string const& x){c_att->key(x);}, "attachment-key");
  158 +this->ap.addRequiredParameter("filename", [this](std::string const& x){c_att->filename(x);}, "filename");
  159 +this->ap.addRequiredParameter("creationdate", [this](std::string const& x){c_att->creationdate(x);}, "creation-date");
  160 +this->ap.addRequiredParameter("moddate", [this](std::string const& x){c_att->moddate(x);}, "modification-date");
  161 +this->ap.addRequiredParameter("mimetype", [this](std::string const& x){c_att->mimetype(x);}, "mime/type");
  162 +this->ap.addRequiredParameter("description", [this](std::string const& x){c_att->description(x);}, "description");
163 this->ap.registerOptionTable("copy attachment", b(&ArgParser::argEndCopyAttachment)); 163 this->ap.registerOptionTable("copy attachment", b(&ArgParser::argEndCopyAttachment));
164 this->ap.addPositional(p(&ArgParser::argCopyAttPositional)); 164 this->ap.addPositional(p(&ArgParser::argCopyAttPositional));
165 -this->ap.addRequiredParameter("prefix", [this](char *x){c_copy_att->prefix(x);}, "prefix");  
166 -this->ap.addRequiredParameter("password", [this](char *x){c_copy_att->password(x);}, "password"); 165 +this->ap.addRequiredParameter("prefix", [this](std::string const& x){c_copy_att->prefix(x);}, "prefix");
  166 +this->ap.addRequiredParameter("password", [this](std::string const& x){c_copy_att->password(x);}, "password");
libqpdf/qpdf/auto_job_json_init.hh
@@ -22,7 +22,7 @@ pushKey(&quot;password&quot;); @@ -22,7 +22,7 @@ pushKey(&quot;password&quot;);
22 setupPassword(); 22 setupPassword();
23 popHandler(); // key: password 23 popHandler(); // key: password
24 pushKey("passwordFile"); 24 pushKey("passwordFile");
25 -addParameter([this](char const* p) { c_main->passwordFile(p); }); 25 +addParameter([this](std::string const& p) { c_main->passwordFile(p); });
26 popHandler(); // key: passwordFile 26 popHandler(); // key: passwordFile
27 pushKey("empty"); 27 pushKey("empty");
28 setupEmpty(); 28 setupEmpty();
@@ -43,19 +43,19 @@ pushKey(&quot;newlineBeforeEndstream&quot;); @@ -43,19 +43,19 @@ pushKey(&quot;newlineBeforeEndstream&quot;);
43 addBare([this]() { c_main->newlineBeforeEndstream(); }); 43 addBare([this]() { c_main->newlineBeforeEndstream(); });
44 popHandler(); // key: newlineBeforeEndstream 44 popHandler(); // key: newlineBeforeEndstream
45 pushKey("normalizeContent"); 45 pushKey("normalizeContent");
46 -addChoices(yn_choices, true, [this](char const* p) { c_main->normalizeContent(p); }); 46 +addChoices(yn_choices, true, [this](std::string const& p) { c_main->normalizeContent(p); });
47 popHandler(); // key: normalizeContent 47 popHandler(); // key: normalizeContent
48 pushKey("streamData"); 48 pushKey("streamData");
49 -addChoices(stream_data_choices, true, [this](char const* p) { c_main->streamData(p); }); 49 +addChoices(stream_data_choices, true, [this](std::string const& p) { c_main->streamData(p); });
50 popHandler(); // key: streamData 50 popHandler(); // key: streamData
51 pushKey("compressStreams"); 51 pushKey("compressStreams");
52 -addChoices(yn_choices, true, [this](char const* p) { c_main->compressStreams(p); }); 52 +addChoices(yn_choices, true, [this](std::string const& p) { c_main->compressStreams(p); });
53 popHandler(); // key: compressStreams 53 popHandler(); // key: compressStreams
54 pushKey("recompressFlate"); 54 pushKey("recompressFlate");
55 addBare([this]() { c_main->recompressFlate(); }); 55 addBare([this]() { c_main->recompressFlate(); });
56 popHandler(); // key: recompressFlate 56 popHandler(); // key: recompressFlate
57 pushKey("decodeLevel"); 57 pushKey("decodeLevel");
58 -addChoices(decode_level_choices, true, [this](char const* p) { c_main->decodeLevel(p); }); 58 +addChoices(decode_level_choices, true, [this](std::string const& p) { c_main->decodeLevel(p); });
59 popHandler(); // key: decodeLevel 59 popHandler(); // key: decodeLevel
60 pushKey("decrypt"); 60 pushKey("decrypt");
61 addBare([this]() { c_main->decrypt(); }); 61 addBare([this]() { c_main->decrypt(); });
@@ -73,31 +73,31 @@ pushKey(&quot;noOriginalObjectIds&quot;); @@ -73,31 +73,31 @@ pushKey(&quot;noOriginalObjectIds&quot;);
73 addBare([this]() { c_main->noOriginalObjectIds(); }); 73 addBare([this]() { c_main->noOriginalObjectIds(); });
74 popHandler(); // key: noOriginalObjectIds 74 popHandler(); // key: noOriginalObjectIds
75 pushKey("copyEncryption"); 75 pushKey("copyEncryption");
76 -addParameter([this](char const* p) { c_main->copyEncryption(p); }); 76 +addParameter([this](std::string const& p) { c_main->copyEncryption(p); });
77 popHandler(); // key: copyEncryption 77 popHandler(); // key: copyEncryption
78 pushKey("encryptionFilePassword"); 78 pushKey("encryptionFilePassword");
79 -addParameter([this](char const* p) { c_main->encryptionFilePassword(p); }); 79 +addParameter([this](std::string const& p) { c_main->encryptionFilePassword(p); });
80 popHandler(); // key: encryptionFilePassword 80 popHandler(); // key: encryptionFilePassword
81 pushKey("linearize"); 81 pushKey("linearize");
82 addBare([this]() { c_main->linearize(); }); 82 addBare([this]() { c_main->linearize(); });
83 popHandler(); // key: linearize 83 popHandler(); // key: linearize
84 pushKey("linearizePass1"); 84 pushKey("linearizePass1");
85 -addParameter([this](char const* p) { c_main->linearizePass1(p); }); 85 +addParameter([this](std::string const& p) { c_main->linearizePass1(p); });
86 popHandler(); // key: linearizePass1 86 popHandler(); // key: linearizePass1
87 pushKey("objectStreams"); 87 pushKey("objectStreams");
88 -addChoices(object_streams_choices, true, [this](char const* p) { c_main->objectStreams(p); }); 88 +addChoices(object_streams_choices, true, [this](std::string const& p) { c_main->objectStreams(p); });
89 popHandler(); // key: objectStreams 89 popHandler(); // key: objectStreams
90 pushKey("minVersion"); 90 pushKey("minVersion");
91 -addParameter([this](char const* p) { c_main->minVersion(p); }); 91 +addParameter([this](std::string const& p) { c_main->minVersion(p); });
92 popHandler(); // key: minVersion 92 popHandler(); // key: minVersion
93 pushKey("forceVersion"); 93 pushKey("forceVersion");
94 -addParameter([this](char const* p) { c_main->forceVersion(p); }); 94 +addParameter([this](std::string const& p) { c_main->forceVersion(p); });
95 popHandler(); // key: forceVersion 95 popHandler(); // key: forceVersion
96 pushKey("progress"); 96 pushKey("progress");
97 addBare([this]() { c_main->progress(); }); 97 addBare([this]() { c_main->progress(); });
98 popHandler(); // key: progress 98 popHandler(); // key: progress
99 pushKey("splitPages"); 99 pushKey("splitPages");
100 -addParameter([this](char const* p) { c_main->splitPages(p); }); 100 +addParameter([this](std::string const& p) { c_main->splitPages(p); });
101 popHandler(); // key: splitPages 101 popHandler(); // key: splitPages
102 pushKey("encrypt"); 102 pushKey("encrypt");
103 beginDict(bindJSON(&Handlers::beginEncrypt), bindBare(&Handlers::endEncrypt)); // .encrypt 103 beginDict(bindJSON(&Handlers::beginEncrypt), bindBare(&Handlers::endEncrypt)); // .encrypt
@@ -110,82 +110,82 @@ popHandler(); // key: ownerPassword @@ -110,82 +110,82 @@ popHandler(); // key: ownerPassword
110 pushKey("40bit"); 110 pushKey("40bit");
111 beginDict(bindJSON(&Handlers::beginEncrypt40bit), bindBare(&Handlers::endEncrypt40bit)); // .encrypt.40bit 111 beginDict(bindJSON(&Handlers::beginEncrypt40bit), bindBare(&Handlers::endEncrypt40bit)); // .encrypt.40bit
112 pushKey("annotate"); 112 pushKey("annotate");
113 -addChoices(yn_choices, true, [this](char const* p) { c_enc->annotate(p); }); 113 +addChoices(yn_choices, true, [this](std::string const& p) { c_enc->annotate(p); });
114 popHandler(); // key: annotate 114 popHandler(); // key: annotate
115 pushKey("extract"); 115 pushKey("extract");
116 -addChoices(yn_choices, true, [this](char const* p) { c_enc->extract(p); }); 116 +addChoices(yn_choices, true, [this](std::string const& p) { c_enc->extract(p); });
117 popHandler(); // key: extract 117 popHandler(); // key: extract
118 pushKey("modify"); 118 pushKey("modify");
119 -addChoices(modify128_choices, true, [this](char const* p) { c_enc->modify(p); }); 119 +addChoices(modify128_choices, true, [this](std::string const& p) { c_enc->modify(p); });
120 popHandler(); // key: modify 120 popHandler(); // key: modify
121 pushKey("print"); 121 pushKey("print");
122 -addChoices(print128_choices, true, [this](char const* p) { c_enc->print(p); }); 122 +addChoices(print128_choices, true, [this](std::string const& p) { c_enc->print(p); });
123 popHandler(); // key: print 123 popHandler(); // key: print
124 popHandler(); // key: 40bit 124 popHandler(); // key: 40bit
125 pushKey("128bit"); 125 pushKey("128bit");
126 beginDict(bindJSON(&Handlers::beginEncrypt128bit), bindBare(&Handlers::endEncrypt128bit)); // .encrypt.128bit 126 beginDict(bindJSON(&Handlers::beginEncrypt128bit), bindBare(&Handlers::endEncrypt128bit)); // .encrypt.128bit
127 pushKey("accessibility"); 127 pushKey("accessibility");
128 -addChoices(yn_choices, true, [this](char const* p) { c_enc->accessibility(p); }); 128 +addChoices(yn_choices, true, [this](std::string const& p) { c_enc->accessibility(p); });
129 popHandler(); // key: accessibility 129 popHandler(); // key: accessibility
130 pushKey("annotate"); 130 pushKey("annotate");
131 -addChoices(yn_choices, true, [this](char const* p) { c_enc->annotate(p); }); 131 +addChoices(yn_choices, true, [this](std::string const& p) { c_enc->annotate(p); });
132 popHandler(); // key: annotate 132 popHandler(); // key: annotate
133 pushKey("assemble"); 133 pushKey("assemble");
134 -addChoices(yn_choices, true, [this](char const* p) { c_enc->assemble(p); }); 134 +addChoices(yn_choices, true, [this](std::string const& p) { c_enc->assemble(p); });
135 popHandler(); // key: assemble 135 popHandler(); // key: assemble
136 pushKey("cleartextMetadata"); 136 pushKey("cleartextMetadata");
137 addBare([this]() { c_enc->cleartextMetadata(); }); 137 addBare([this]() { c_enc->cleartextMetadata(); });
138 popHandler(); // key: cleartextMetadata 138 popHandler(); // key: cleartextMetadata
139 pushKey("extract"); 139 pushKey("extract");
140 -addChoices(yn_choices, true, [this](char const* p) { c_enc->extract(p); }); 140 +addChoices(yn_choices, true, [this](std::string const& p) { c_enc->extract(p); });
141 popHandler(); // key: extract 141 popHandler(); // key: extract
142 pushKey("form"); 142 pushKey("form");
143 -addChoices(yn_choices, true, [this](char const* p) { c_enc->form(p); }); 143 +addChoices(yn_choices, true, [this](std::string const& p) { c_enc->form(p); });
144 popHandler(); // key: form 144 popHandler(); // key: form
145 pushKey("modifyOther"); 145 pushKey("modifyOther");
146 -addChoices(yn_choices, true, [this](char const* p) { c_enc->modifyOther(p); }); 146 +addChoices(yn_choices, true, [this](std::string const& p) { c_enc->modifyOther(p); });
147 popHandler(); // key: modifyOther 147 popHandler(); // key: modifyOther
148 pushKey("modify"); 148 pushKey("modify");
149 -addChoices(modify128_choices, true, [this](char const* p) { c_enc->modify(p); }); 149 +addChoices(modify128_choices, true, [this](std::string const& p) { c_enc->modify(p); });
150 popHandler(); // key: modify 150 popHandler(); // key: modify
151 pushKey("print"); 151 pushKey("print");
152 -addChoices(print128_choices, true, [this](char const* p) { c_enc->print(p); }); 152 +addChoices(print128_choices, true, [this](std::string const& p) { c_enc->print(p); });
153 popHandler(); // key: print 153 popHandler(); // key: print
154 pushKey("forceV4"); 154 pushKey("forceV4");
155 addBare([this]() { c_enc->forceV4(); }); 155 addBare([this]() { c_enc->forceV4(); });
156 popHandler(); // key: forceV4 156 popHandler(); // key: forceV4
157 pushKey("useAes"); 157 pushKey("useAes");
158 -addChoices(yn_choices, true, [this](char const* p) { c_enc->useAes(p); }); 158 +addChoices(yn_choices, true, [this](std::string const& p) { c_enc->useAes(p); });
159 popHandler(); // key: useAes 159 popHandler(); // key: useAes
160 popHandler(); // key: 128bit 160 popHandler(); // key: 128bit
161 pushKey("256bit"); 161 pushKey("256bit");
162 beginDict(bindJSON(&Handlers::beginEncrypt256bit), bindBare(&Handlers::endEncrypt256bit)); // .encrypt.256bit 162 beginDict(bindJSON(&Handlers::beginEncrypt256bit), bindBare(&Handlers::endEncrypt256bit)); // .encrypt.256bit
163 pushKey("accessibility"); 163 pushKey("accessibility");
164 -addChoices(yn_choices, true, [this](char const* p) { c_enc->accessibility(p); }); 164 +addChoices(yn_choices, true, [this](std::string const& p) { c_enc->accessibility(p); });
165 popHandler(); // key: accessibility 165 popHandler(); // key: accessibility
166 pushKey("annotate"); 166 pushKey("annotate");
167 -addChoices(yn_choices, true, [this](char const* p) { c_enc->annotate(p); }); 167 +addChoices(yn_choices, true, [this](std::string const& p) { c_enc->annotate(p); });
168 popHandler(); // key: annotate 168 popHandler(); // key: annotate
169 pushKey("assemble"); 169 pushKey("assemble");
170 -addChoices(yn_choices, true, [this](char const* p) { c_enc->assemble(p); }); 170 +addChoices(yn_choices, true, [this](std::string const& p) { c_enc->assemble(p); });
171 popHandler(); // key: assemble 171 popHandler(); // key: assemble
172 pushKey("cleartextMetadata"); 172 pushKey("cleartextMetadata");
173 addBare([this]() { c_enc->cleartextMetadata(); }); 173 addBare([this]() { c_enc->cleartextMetadata(); });
174 popHandler(); // key: cleartextMetadata 174 popHandler(); // key: cleartextMetadata
175 pushKey("extract"); 175 pushKey("extract");
176 -addChoices(yn_choices, true, [this](char const* p) { c_enc->extract(p); }); 176 +addChoices(yn_choices, true, [this](std::string const& p) { c_enc->extract(p); });
177 popHandler(); // key: extract 177 popHandler(); // key: extract
178 pushKey("form"); 178 pushKey("form");
179 -addChoices(yn_choices, true, [this](char const* p) { c_enc->form(p); }); 179 +addChoices(yn_choices, true, [this](std::string const& p) { c_enc->form(p); });
180 popHandler(); // key: form 180 popHandler(); // key: form
181 pushKey("modifyOther"); 181 pushKey("modifyOther");
182 -addChoices(yn_choices, true, [this](char const* p) { c_enc->modifyOther(p); }); 182 +addChoices(yn_choices, true, [this](std::string const& p) { c_enc->modifyOther(p); });
183 popHandler(); // key: modifyOther 183 popHandler(); // key: modifyOther
184 pushKey("modify"); 184 pushKey("modify");
185 -addChoices(modify128_choices, true, [this](char const* p) { c_enc->modify(p); }); 185 +addChoices(modify128_choices, true, [this](std::string const& p) { c_enc->modify(p); });
186 popHandler(); // key: modify 186 popHandler(); // key: modify
187 pushKey("print"); 187 pushKey("print");
188 -addChoices(print128_choices, true, [this](char const* p) { c_enc->print(p); }); 188 +addChoices(print128_choices, true, [this](std::string const& p) { c_enc->print(p); });
189 popHandler(); // key: print 189 popHandler(); // key: print
190 pushKey("allowInsecure"); 190 pushKey("allowInsecure");
191 addBare([this]() { c_enc->allowInsecure(); }); 191 addBare([this]() { c_enc->allowInsecure(); });
@@ -220,7 +220,7 @@ pushKey(&quot;showNpages&quot;); @@ -220,7 +220,7 @@ pushKey(&quot;showNpages&quot;);
220 addBare([this]() { c_main->showNpages(); }); 220 addBare([this]() { c_main->showNpages(); });
221 popHandler(); // key: showNpages 221 popHandler(); // key: showNpages
222 pushKey("showObject"); 222 pushKey("showObject");
223 -addParameter([this](char const* p) { c_main->showObject(p); }); 223 +addParameter([this](std::string const& p) { c_main->showObject(p); });
224 popHandler(); // key: showObject 224 popHandler(); // key: showObject
225 pushKey("showPages"); 225 pushKey("showPages");
226 addBare([this]() { c_main->showPages(); }); 226 addBare([this]() { c_main->showPages(); });
@@ -235,29 +235,29 @@ pushKey(&quot;listAttachments&quot;); @@ -235,29 +235,29 @@ pushKey(&quot;listAttachments&quot;);
235 addBare([this]() { c_main->listAttachments(); }); 235 addBare([this]() { c_main->listAttachments(); });
236 popHandler(); // key: listAttachments 236 popHandler(); // key: listAttachments
237 pushKey("showAttachment"); 237 pushKey("showAttachment");
238 -addParameter([this](char const* p) { c_main->showAttachment(p); }); 238 +addParameter([this](std::string const& p) { c_main->showAttachment(p); });
239 popHandler(); // key: showAttachment 239 popHandler(); // key: showAttachment
240 pushKey("json"); 240 pushKey("json");
241 -addChoices(json_version_choices, false, [this](char const* p) { c_main->json(p); }); 241 +addChoices(json_version_choices, false, [this](std::string const& p) { c_main->json(p); });
242 popHandler(); // key: json 242 popHandler(); // key: json
243 pushKey("jsonKey"); 243 pushKey("jsonKey");
244 beginArray(bindJSON(&Handlers::beginJsonKeyArray), bindBare(&Handlers::endJsonKeyArray)); // .jsonKey[] 244 beginArray(bindJSON(&Handlers::beginJsonKeyArray), bindBare(&Handlers::endJsonKeyArray)); // .jsonKey[]
245 -addChoices(json_key_choices, true, [this](char const* p) { c_main->jsonKey(p); }); 245 +addChoices(json_key_choices, true, [this](std::string const& p) { c_main->jsonKey(p); });
246 popHandler(); // array: .jsonKey[] 246 popHandler(); // array: .jsonKey[]
247 popHandler(); // key: jsonKey 247 popHandler(); // key: jsonKey
248 pushKey("jsonObject"); 248 pushKey("jsonObject");
249 beginArray(bindJSON(&Handlers::beginJsonObjectArray), bindBare(&Handlers::endJsonObjectArray)); // .jsonObject[] 249 beginArray(bindJSON(&Handlers::beginJsonObjectArray), bindBare(&Handlers::endJsonObjectArray)); // .jsonObject[]
250 -addParameter([this](char const* p) { c_main->jsonObject(p); }); 250 +addParameter([this](std::string const& p) { c_main->jsonObject(p); });
251 popHandler(); // array: .jsonObject[] 251 popHandler(); // array: .jsonObject[]
252 popHandler(); // key: jsonObject 252 popHandler(); // key: jsonObject
253 pushKey("allowWeakCrypto"); 253 pushKey("allowWeakCrypto");
254 addBare([this]() { c_main->allowWeakCrypto(); }); 254 addBare([this]() { c_main->allowWeakCrypto(); });
255 popHandler(); // key: allowWeakCrypto 255 popHandler(); // key: allowWeakCrypto
256 pushKey("keepFilesOpen"); 256 pushKey("keepFilesOpen");
257 -addChoices(yn_choices, true, [this](char const* p) { c_main->keepFilesOpen(p); }); 257 +addChoices(yn_choices, true, [this](std::string const& p) { c_main->keepFilesOpen(p); });
258 popHandler(); // key: keepFilesOpen 258 popHandler(); // key: keepFilesOpen
259 pushKey("keepFilesOpenThreshold"); 259 pushKey("keepFilesOpenThreshold");
260 -addParameter([this](char const* p) { c_main->keepFilesOpenThreshold(p); }); 260 +addParameter([this](std::string const& p) { c_main->keepFilesOpenThreshold(p); });
261 popHandler(); // key: keepFilesOpenThreshold 261 popHandler(); // key: keepFilesOpenThreshold
262 pushKey("noWarn"); 262 pushKey("noWarn");
263 addBare([this]() { c_main->noWarn(); }); 263 addBare([this]() { c_main->noWarn(); });
@@ -272,7 +272,7 @@ pushKey(&quot;passwordIsHexKey&quot;); @@ -272,7 +272,7 @@ pushKey(&quot;passwordIsHexKey&quot;);
272 addBare([this]() { c_main->passwordIsHexKey(); }); 272 addBare([this]() { c_main->passwordIsHexKey(); });
273 popHandler(); // key: passwordIsHexKey 273 popHandler(); // key: passwordIsHexKey
274 pushKey("passwordMode"); 274 pushKey("passwordMode");
275 -addChoices(password_mode_choices, true, [this](char const* p) { c_main->passwordMode(p); }); 275 +addChoices(password_mode_choices, true, [this](std::string const& p) { c_main->passwordMode(p); });
276 popHandler(); // key: passwordMode 276 popHandler(); // key: passwordMode
277 pushKey("suppressPasswordRecovery"); 277 pushKey("suppressPasswordRecovery");
278 addBare([this]() { c_main->suppressPasswordRecovery(); }); 278 addBare([this]() { c_main->suppressPasswordRecovery(); });
@@ -284,16 +284,16 @@ pushKey(&quot;coalesceContents&quot;); @@ -284,16 +284,16 @@ pushKey(&quot;coalesceContents&quot;);
284 addBare([this]() { c_main->coalesceContents(); }); 284 addBare([this]() { c_main->coalesceContents(); });
285 popHandler(); // key: coalesceContents 285 popHandler(); // key: coalesceContents
286 pushKey("compressionLevel"); 286 pushKey("compressionLevel");
287 -addParameter([this](char const* p) { c_main->compressionLevel(p); }); 287 +addParameter([this](std::string const& p) { c_main->compressionLevel(p); });
288 popHandler(); // key: compressionLevel 288 popHandler(); // key: compressionLevel
289 pushKey("externalizeInlineImages"); 289 pushKey("externalizeInlineImages");
290 addBare([this]() { c_main->externalizeInlineImages(); }); 290 addBare([this]() { c_main->externalizeInlineImages(); });
291 popHandler(); // key: externalizeInlineImages 291 popHandler(); // key: externalizeInlineImages
292 pushKey("iiMinBytes"); 292 pushKey("iiMinBytes");
293 -addParameter([this](char const* p) { c_main->iiMinBytes(p); }); 293 +addParameter([this](std::string const& p) { c_main->iiMinBytes(p); });
294 popHandler(); // key: iiMinBytes 294 popHandler(); // key: iiMinBytes
295 pushKey("removeUnreferencedResources"); 295 pushKey("removeUnreferencedResources");
296 -addChoices(remove_unref_choices, true, [this](char const* p) { c_main->removeUnreferencedResources(p); }); 296 +addChoices(remove_unref_choices, true, [this](std::string const& p) { c_main->removeUnreferencedResources(p); });
297 popHandler(); // key: removeUnreferencedResources 297 popHandler(); // key: removeUnreferencedResources
298 pushKey("addAttachment"); 298 pushKey("addAttachment");
299 beginArray(bindJSON(&Handlers::beginAddAttachmentArray), bindBare(&Handlers::endAddAttachmentArray)); // .addAttachment[] 299 beginArray(bindJSON(&Handlers::beginAddAttachmentArray), bindBare(&Handlers::endAddAttachmentArray)); // .addAttachment[]
@@ -302,22 +302,22 @@ pushKey(&quot;file&quot;); @@ -302,22 +302,22 @@ pushKey(&quot;file&quot;);
302 setupAddAttachmentFile(); 302 setupAddAttachmentFile();
303 popHandler(); // key: file 303 popHandler(); // key: file
304 pushKey("creationdate"); 304 pushKey("creationdate");
305 -addParameter([this](char const* p) { c_att->creationdate(p); }); 305 +addParameter([this](std::string const& p) { c_att->creationdate(p); });
306 popHandler(); // key: creationdate 306 popHandler(); // key: creationdate
307 pushKey("description"); 307 pushKey("description");
308 -addParameter([this](char const* p) { c_att->description(p); }); 308 +addParameter([this](std::string const& p) { c_att->description(p); });
309 popHandler(); // key: description 309 popHandler(); // key: description
310 pushKey("filename"); 310 pushKey("filename");
311 -addParameter([this](char const* p) { c_att->filename(p); }); 311 +addParameter([this](std::string const& p) { c_att->filename(p); });
312 popHandler(); // key: filename 312 popHandler(); // key: filename
313 pushKey("key"); 313 pushKey("key");
314 -addParameter([this](char const* p) { c_att->key(p); }); 314 +addParameter([this](std::string const& p) { c_att->key(p); });
315 popHandler(); // key: key 315 popHandler(); // key: key
316 pushKey("mimetype"); 316 pushKey("mimetype");
317 -addParameter([this](char const* p) { c_att->mimetype(p); }); 317 +addParameter([this](std::string const& p) { c_att->mimetype(p); });
318 popHandler(); // key: mimetype 318 popHandler(); // key: mimetype
319 pushKey("moddate"); 319 pushKey("moddate");
320 -addParameter([this](char const* p) { c_att->moddate(p); }); 320 +addParameter([this](std::string const& p) { c_att->moddate(p); });
321 popHandler(); // key: moddate 321 popHandler(); // key: moddate
322 pushKey("replace"); 322 pushKey("replace");
323 addBare([this]() { c_att->replace(); }); 323 addBare([this]() { c_att->replace(); });
@@ -325,7 +325,7 @@ popHandler(); // key: replace @@ -325,7 +325,7 @@ popHandler(); // key: replace
325 popHandler(); // array: .addAttachment[] 325 popHandler(); // array: .addAttachment[]
326 popHandler(); // key: addAttachment 326 popHandler(); // key: addAttachment
327 pushKey("removeAttachment"); 327 pushKey("removeAttachment");
328 -addParameter([this](char const* p) { c_main->removeAttachment(p); }); 328 +addParameter([this](std::string const& p) { c_main->removeAttachment(p); });
329 popHandler(); // key: removeAttachment 329 popHandler(); // key: removeAttachment
330 pushKey("copyAttachmentsFrom"); 330 pushKey("copyAttachmentsFrom");
331 beginArray(bindJSON(&Handlers::beginCopyAttachmentsFromArray), bindBare(&Handlers::endCopyAttachmentsFromArray)); // .copyAttachmentsFrom[] 331 beginArray(bindJSON(&Handlers::beginCopyAttachmentsFromArray), bindBare(&Handlers::endCopyAttachmentsFromArray)); // .copyAttachmentsFrom[]
@@ -337,15 +337,15 @@ pushKey(&quot;password&quot;); @@ -337,15 +337,15 @@ pushKey(&quot;password&quot;);
337 setupCopyAttachmentsFromPassword(); 337 setupCopyAttachmentsFromPassword();
338 popHandler(); // key: password 338 popHandler(); // key: password
339 pushKey("prefix"); 339 pushKey("prefix");
340 -addParameter([this](char const* p) { c_copy_att->prefix(p); }); 340 +addParameter([this](std::string const& p) { c_copy_att->prefix(p); });
341 popHandler(); // key: prefix 341 popHandler(); // key: prefix
342 popHandler(); // array: .copyAttachmentsFrom[] 342 popHandler(); // array: .copyAttachmentsFrom[]
343 popHandler(); // key: copyAttachmentsFrom 343 popHandler(); // key: copyAttachmentsFrom
344 pushKey("collate"); 344 pushKey("collate");
345 -addParameter([this](char const* p) { c_main->collate(p); }); 345 +addParameter([this](std::string const& p) { c_main->collate(p); });
346 popHandler(); // key: collate 346 popHandler(); // key: collate
347 pushKey("flattenAnnotations"); 347 pushKey("flattenAnnotations");
348 -addChoices(flatten_choices, true, [this](char const* p) { c_main->flattenAnnotations(p); }); 348 +addChoices(flatten_choices, true, [this](std::string const& p) { c_main->flattenAnnotations(p); });
349 popHandler(); // key: flattenAnnotations 349 popHandler(); // key: flattenAnnotations
350 pushKey("flattenRotation"); 350 pushKey("flattenRotation");
351 addBare([this]() { c_main->flattenRotation(); }); 351 addBare([this]() { c_main->flattenRotation(); });
@@ -357,13 +357,13 @@ pushKey(&quot;keepInlineImages&quot;); @@ -357,13 +357,13 @@ pushKey(&quot;keepInlineImages&quot;);
357 addBare([this]() { c_main->keepInlineImages(); }); 357 addBare([this]() { c_main->keepInlineImages(); });
358 popHandler(); // key: keepInlineImages 358 popHandler(); // key: keepInlineImages
359 pushKey("oiMinArea"); 359 pushKey("oiMinArea");
360 -addParameter([this](char const* p) { c_main->oiMinArea(p); }); 360 +addParameter([this](std::string const& p) { c_main->oiMinArea(p); });
361 popHandler(); // key: oiMinArea 361 popHandler(); // key: oiMinArea
362 pushKey("oiMinHeight"); 362 pushKey("oiMinHeight");
363 -addParameter([this](char const* p) { c_main->oiMinHeight(p); }); 363 +addParameter([this](std::string const& p) { c_main->oiMinHeight(p); });
364 popHandler(); // key: oiMinHeight 364 popHandler(); // key: oiMinHeight
365 pushKey("oiMinWidth"); 365 pushKey("oiMinWidth");
366 -addParameter([this](char const* p) { c_main->oiMinWidth(p); }); 366 +addParameter([this](std::string const& p) { c_main->oiMinWidth(p); });
367 popHandler(); // key: oiMinWidth 367 popHandler(); // key: oiMinWidth
368 pushKey("optimizeImages"); 368 pushKey("optimizeImages");
369 addBare([this]() { c_main->optimizeImages(); }); 369 addBare([this]() { c_main->optimizeImages(); });
@@ -386,7 +386,7 @@ pushKey(&quot;removePageLabels&quot;); @@ -386,7 +386,7 @@ pushKey(&quot;removePageLabels&quot;);
386 addBare([this]() { c_main->removePageLabels(); }); 386 addBare([this]() { c_main->removePageLabels(); });
387 popHandler(); // key: removePageLabels 387 popHandler(); // key: removePageLabels
388 pushKey("rotate"); 388 pushKey("rotate");
389 -addParameter([this](char const* p) { c_main->rotate(p); }); 389 +addParameter([this](std::string const& p) { c_main->rotate(p); });
390 popHandler(); // key: rotate 390 popHandler(); // key: rotate
391 pushKey("overlay"); 391 pushKey("overlay");
392 beginDict(bindJSON(&Handlers::beginOverlay), bindBare(&Handlers::endOverlay)); // .overlay 392 beginDict(bindJSON(&Handlers::beginOverlay), bindBare(&Handlers::endOverlay)); // .overlay
@@ -397,13 +397,13 @@ pushKey(&quot;password&quot;); @@ -397,13 +397,13 @@ pushKey(&quot;password&quot;);
397 setupOverlayPassword(); 397 setupOverlayPassword();
398 popHandler(); // key: password 398 popHandler(); // key: password
399 pushKey("from"); 399 pushKey("from");
400 -addParameter([this](char const* p) { c_uo->from(p); }); 400 +addParameter([this](std::string const& p) { c_uo->from(p); });
401 popHandler(); // key: from 401 popHandler(); // key: from
402 pushKey("repeat"); 402 pushKey("repeat");
403 -addParameter([this](char const* p) { c_uo->repeat(p); }); 403 +addParameter([this](std::string const& p) { c_uo->repeat(p); });
404 popHandler(); // key: repeat 404 popHandler(); // key: repeat
405 pushKey("to"); 405 pushKey("to");
406 -addParameter([this](char const* p) { c_uo->to(p); }); 406 +addParameter([this](std::string const& p) { c_uo->to(p); });
407 popHandler(); // key: to 407 popHandler(); // key: to
408 popHandler(); // key: overlay 408 popHandler(); // key: overlay
409 pushKey("underlay"); 409 pushKey("underlay");
@@ -415,20 +415,20 @@ pushKey(&quot;password&quot;); @@ -415,20 +415,20 @@ pushKey(&quot;password&quot;);
415 setupUnderlayPassword(); 415 setupUnderlayPassword();
416 popHandler(); // key: password 416 popHandler(); // key: password
417 pushKey("from"); 417 pushKey("from");
418 -addParameter([this](char const* p) { c_uo->from(p); }); 418 +addParameter([this](std::string const& p) { c_uo->from(p); });
419 popHandler(); // key: from 419 popHandler(); // key: from
420 pushKey("repeat"); 420 pushKey("repeat");
421 -addParameter([this](char const* p) { c_uo->repeat(p); }); 421 +addParameter([this](std::string const& p) { c_uo->repeat(p); });
422 popHandler(); // key: repeat 422 popHandler(); // key: repeat
423 pushKey("to"); 423 pushKey("to");
424 -addParameter([this](char const* p) { c_uo->to(p); }); 424 +addParameter([this](std::string const& p) { c_uo->to(p); });
425 popHandler(); // key: to 425 popHandler(); // key: to
426 popHandler(); // key: underlay 426 popHandler(); // key: underlay
427 pushKey("warningExit0"); 427 pushKey("warningExit0");
428 addBare([this]() { c_main->warningExit0(); }); 428 addBare([this]() { c_main->warningExit0(); });
429 popHandler(); // key: warningExit0 429 popHandler(); // key: warningExit0
430 pushKey("jobJsonFile"); 430 pushKey("jobJsonFile");
431 -addParameter([this](char const* p) { c_main->jobJsonFile(p); }); 431 +addParameter([this](std::string const& p) { c_main->jobJsonFile(p); });
432 popHandler(); // key: jobJsonFile 432 popHandler(); // key: jobJsonFile
433 pushKey("preserveUnreferencedResources"); 433 pushKey("preserveUnreferencedResources");
434 addBare([this]() { c_main->preserveUnreferencedResources(); }); 434 addBare([this]() { c_main->preserveUnreferencedResources(); });
libqpdf/qpdfjob-c.cc
@@ -7,9 +7,10 @@ @@ -7,9 +7,10 @@
7 #include <cstdio> 7 #include <cstdio>
8 #include <cstring> 8 #include <cstring>
9 9
10 -int qpdfjob_run_from_argv(int argc, char* argv[]) 10 +int qpdfjob_run_from_argv(int argc, char const* const argv[])
11 { 11 {
12 - auto whoami = QUtil::getWhoami(argv[0]); 12 + auto whoami_p = QUtil::make_shared_cstr(argv[0]);
  13 + auto whoami = QUtil::getWhoami(whoami_p.get());
13 QUtil::setLineBuf(stdout); 14 QUtil::setLineBuf(stdout);
14 15
15 QPDFJob j; 16 QPDFJob j;
@@ -27,7 +28,7 @@ int qpdfjob_run_from_argv(int argc, char* argv[]) @@ -27,7 +28,7 @@ int qpdfjob_run_from_argv(int argc, char* argv[])
27 } 28 }
28 29
29 #ifndef QPDF_NO_WCHAR_T 30 #ifndef QPDF_NO_WCHAR_T
30 -int qpdfjob_run_from_wide_argv(int argc, wchar_t* argv[]) 31 +int qpdfjob_run_from_wide_argv(int argc, wchar_t const* const argv[])
31 { 32 {
32 return QUtil::call_main_from_wmain(argc, argv, qpdfjob_run_from_argv); 33 return QUtil::call_main_from_wmain(argc, argv, qpdfjob_run_from_argv);
33 } 34 }
libtests/arg_parser.cc
@@ -15,12 +15,12 @@ class ArgParser @@ -15,12 +15,12 @@ class ArgParser
15 15
16 private: 16 private:
17 void handlePotato(); 17 void handlePotato();
18 - void handleSalad(char* p);  
19 - void handleMoo(char* p);  
20 - void handleOink(char* p);  
21 - void handleQuack(char* p); 18 + void handleSalad(std::string const& p);
  19 + void handleMoo(std::string const& p);
  20 + void handleOink(std::string const& p);
  21 + void handleQuack(std::string const& p);
22 void startQuack(); 22 void startQuack();
23 - void getQuack(char* p); 23 + void getQuack(std::string const& p);
24 void endQuack(); 24 void endQuack();
25 void finalChecks(); 25 void finalChecks();
26 26
@@ -44,7 +44,7 @@ ArgParser::initOptions() @@ -44,7 +44,7 @@ ArgParser::initOptions()
44 auto b = [this](void (ArgParser::*f)()) { 44 auto b = [this](void (ArgParser::*f)()) {
45 return QPDFArgParser::bindBare(f, this); 45 return QPDFArgParser::bindBare(f, this);
46 }; 46 };
47 - auto p = [this](void (ArgParser::*f)(char *)) { 47 + auto p = [this](void (ArgParser::*f)(std::string const&)) {
48 return QPDFArgParser::bindParam(f, this); 48 return QPDFArgParser::bindParam(f, this);
49 }; 49 };
50 50
@@ -98,19 +98,19 @@ ArgParser::handlePotato() @@ -98,19 +98,19 @@ ArgParser::handlePotato()
98 } 98 }
99 99
100 void 100 void
101 -ArgParser::handleSalad(char* p) 101 +ArgParser::handleSalad(std::string const& p)
102 { 102 {
103 output(std::string("got salad=") + p); 103 output(std::string("got salad=") + p);
104 } 104 }
105 105
106 void 106 void
107 -ArgParser::handleMoo(char* p) 107 +ArgParser::handleMoo(std::string const& p)
108 { 108 {
109 - output(std::string("got moo=") + (p ? p : "(none)")); 109 + output(std::string("got moo=") + (p.empty() ? "(none)" : p));
110 } 110 }
111 111
112 void 112 void
113 -ArgParser::handleOink(char* p) 113 +ArgParser::handleOink(std::string const& p)
114 { 114 {
115 output(std::string("got oink=") + p); 115 output(std::string("got oink=") + p);
116 } 116 }
@@ -137,7 +137,7 @@ ArgParser::startQuack() @@ -137,7 +137,7 @@ ArgParser::startQuack()
137 } 137 }
138 138
139 void 139 void
140 -ArgParser::getQuack(char* p) 140 +ArgParser::getQuack(std::string const& p)
141 { 141 {
142 ++this->quacks; 142 ++this->quacks;
143 if (this->ap.isCompleting() && (this->ap.argsLeft() == 0)) 143 if (this->ap.isCompleting() && (this->ap.argsLeft() == 0))
@@ -210,7 +210,7 @@ ArgParser::test_exceptions() @@ -210,7 +210,7 @@ ArgParser::test_exceptions()
210 }); 210 });
211 err("invalid choice handler to unknown", [this]() { 211 err("invalid choice handler to unknown", [this]() {
212 ap.addInvalidChoiceHandler( 212 ap.addInvalidChoiceHandler(
213 - "elephant", [](char*){}); 213 + "elephant", [](std::string const&){});
214 }); 214 });
215 } 215 }
216 216
libtests/main_from_wmain.cc
@@ -4,17 +4,37 @@ @@ -4,17 +4,37 @@
4 #ifndef QPDF_NO_WCHAR_T 4 #ifndef QPDF_NO_WCHAR_T
5 void wmain_test() 5 void wmain_test()
6 { 6 {
  7 + // writable args and function args
7 auto realmain = [](int argc, char* argv[]) { 8 auto realmain = [](int argc, char* argv[]) {
8 - for (int i = 0; i < argc; ++i) {  
9 - std::cout << argv[i] << std::endl;  
10 - } return 0;  
11 - }; 9 + for (int i = 0; i < argc; ++i) {
  10 + std::cout << argv[i] << std::endl;
  11 + } return 0;
  12 + };
12 wchar_t* argv[3]; 13 wchar_t* argv[3];
  14 + // This works because call_main_from_wmain doesn't actually write
  15 + // to the arguments and neither does our function. Otherwise, this
  16 + // cast would be unsafe.
13 argv[0] = const_cast<wchar_t*>(L"ascii"); 17 argv[0] = const_cast<wchar_t*>(L"ascii");
14 argv[1] = const_cast<wchar_t*>(L"10 \xf7 2 = 5"); 18 argv[1] = const_cast<wchar_t*>(L"10 \xf7 2 = 5");
15 argv[2] = const_cast<wchar_t*>(L"qwww\xf7\x03c0"); 19 argv[2] = const_cast<wchar_t*>(L"qwww\xf7\x03c0");
16 QUtil::call_main_from_wmain(3, argv, realmain); 20 QUtil::call_main_from_wmain(3, argv, realmain);
17 } 21 }
  22 +
  23 +void cwmain_test()
  24 +{
  25 + // const args and function args
  26 + auto realmain = [](int argc, char const* const argv[]) {
  27 + for (int i = 0; i < argc; ++i) {
  28 + std::cout << "const " << argv[i] << std::endl;
  29 + } return 0;
  30 + };
  31 + wchar_t const* argv[3] = {
  32 + L"ascii",
  33 + L"10 \xf7 2 = 5",
  34 + L"qwww\xf7\x03c0",
  35 + };
  36 + QUtil::call_main_from_wmain(3, argv, realmain);
  37 +}
18 #endif // QPDF_NO_WCHAR_T 38 #endif // QPDF_NO_WCHAR_T
19 39
20 int main(int argc, char* argv[]) 40 int main(int argc, char* argv[])
@@ -23,6 +43,7 @@ int main(int argc, char* argv[]) @@ -23,6 +43,7 @@ int main(int argc, char* argv[])
23 try 43 try
24 { 44 {
25 wmain_test(); 45 wmain_test();
  46 + cwmain_test();
26 } 47 }
27 catch (std::exception& e) 48 catch (std::exception& e)
28 { 49 {
libtests/qtest/qutil/wmain.out
1 ascii 1 ascii
2 10 ÷ 2 = 5 2 10 ÷ 2 = 5
3 qwww÷π 3 qwww÷π
  4 +const ascii
  5 +const 10 ÷ 2 = 5
  6 +const qwww÷π
qpdf/qpdfjob-ctest.c
@@ -7,11 +7,11 @@ @@ -7,11 +7,11 @@
7 #ifndef QPDF_NO_WCHAR_T 7 #ifndef QPDF_NO_WCHAR_T
8 static void wide_test() 8 static void wide_test()
9 { 9 {
10 - wchar_t* argv[5];  
11 - argv[0] = (wchar_t*)(L"qpdfjob");  
12 - argv[1] = (wchar_t*)(L"minimal.pdf");  
13 - argv[2] = (wchar_t*)(L"a.pdf");  
14 - argv[3] = (wchar_t*)(L"--static-id"); 10 + wchar_t const* argv[5];
  11 + argv[0] = L"qpdfjob";
  12 + argv[1] = L"minimal.pdf";
  13 + argv[2] = L"a.pdf";
  14 + argv[3] = L"--static-id";
15 argv[4] = NULL; 15 argv[4] = NULL;
16 assert(qpdfjob_run_from_wide_argv(4, argv) == 0); 16 assert(qpdfjob_run_from_wide_argv(4, argv) == 0);
17 printf("wide test passed\n"); 17 printf("wide test passed\n");
@@ -22,11 +22,11 @@ static void run_tests() @@ -22,11 +22,11 @@ static void run_tests()
22 { 22 {
23 /* Be sure to use a different output file for each test. */ 23 /* Be sure to use a different output file for each test. */
24 24
25 - char* argv[5];  
26 - argv[0] = (char*)("qpdfjob");  
27 - argv[1] = (char*)("minimal.pdf");  
28 - argv[2] = (char*)("a.pdf");  
29 - argv[3] = (char*)("--deterministic-id"); 25 + char const* argv[5];
  26 + argv[0] = "qpdfjob";
  27 + argv[1] = "minimal.pdf";
  28 + argv[2] = "a.pdf";
  29 + argv[3] = "--deterministic-id";
30 argv[4] = NULL; 30 argv[4] = NULL;
31 assert(qpdfjob_run_from_argv(4, argv) == 0); 31 assert(qpdfjob_run_from_argv(4, argv) == 0);
32 printf("argv test passed\n"); 32 printf("argv test passed\n");