diff options
Diffstat (limited to 'libqpdf/qpdf')
-rw-r--r-- | libqpdf/qpdf/BitStream.hh | 3 | ||||
-rw-r--r-- | libqpdf/qpdf/BitWriter.hh | 4 | ||||
-rw-r--r-- | libqpdf/qpdf/JSONHandler.hh | 27 | ||||
-rw-r--r-- | libqpdf/qpdf/MD5.hh | 3 | ||||
-rw-r--r-- | libqpdf/qpdf/NNTree.hh | 5 | ||||
-rw-r--r-- | libqpdf/qpdf/OffsetInputSource.hh | 4 | ||||
-rw-r--r-- | libqpdf/qpdf/Pl_AES_PDF.hh | 4 | ||||
-rw-r--r-- | libqpdf/qpdf/Pl_MD5.hh | 23 | ||||
-rw-r--r-- | libqpdf/qpdf/Pl_PNGFilter.hh | 8 | ||||
-rw-r--r-- | libqpdf/qpdf/Pl_SHA2.hh | 15 | ||||
-rw-r--r-- | libqpdf/qpdf/Pl_TIFFPredictor.hh | 4 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDFArgParser.hh | 122 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDFCrypto_gnutls.hh | 4 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDFObject_private.hh | 14 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_Dictionary.hh | 9 | ||||
-rw-r--r-- | libqpdf/qpdf/RC4.hh | 3 |
16 files changed, 104 insertions, 148 deletions
diff --git a/libqpdf/qpdf/BitStream.hh b/libqpdf/qpdf/BitStream.hh index b807f56c..329c486d 100644 --- a/libqpdf/qpdf/BitStream.hh +++ b/libqpdf/qpdf/BitStream.hh @@ -12,8 +12,7 @@ class BitStream void reset(); unsigned long long getBits(size_t nbits); long long getBitsSigned(size_t nbits); - // Only call getBitsInt when requesting a number of bits that will - // definitely fit in an int. + // Only call getBitsInt when requesting a number of bits that definitely fit in an int. int getBitsInt(size_t nbits); void skipToNextByte(); diff --git a/libqpdf/qpdf/BitWriter.hh b/libqpdf/qpdf/BitWriter.hh index 33fdd8f4..24c74162 100644 --- a/libqpdf/qpdf/BitWriter.hh +++ b/libqpdf/qpdf/BitWriter.hh @@ -10,8 +10,8 @@ class Pipeline; class BitWriter { public: - // Write bits to the pipeline. It is the caller's responsibility - // to eventually call finish on the pipeline. + // Write bits to the pipeline. It is the caller's responsibility to eventually call finish on + // the pipeline. BitWriter(Pipeline* pl); void writeBits(unsigned long long val, size_t bits); void writeBitsSigned(long long val, size_t bits); diff --git a/libqpdf/qpdf/JSONHandler.hh b/libqpdf/qpdf/JSONHandler.hh index e4a76af5..8fdcaee6 100644 --- a/libqpdf/qpdf/JSONHandler.hh +++ b/libqpdf/qpdf/JSONHandler.hh @@ -7,37 +7,32 @@ #include <memory> #include <string> -// This class allows a sax-like walk through a JSON object with -// functionality that mostly mirrors QPDFArgParser. It is primarily -// here to facilitate automatic generation of some of the code to help -// keep QPDFJob json consistent with command-line arguments. +// This class allows a sax-like walk through a JSON object with functionality that mostly mirrors +// QPDFArgParser. It is primarily here to facilitate automatic generation of some of the code to +// help keep QPDFJob json consistent with command-line arguments. class JSONHandler { public: - // A QPDFUsage exception is thrown if there are any errors - // validating the JSON object. + // A QPDFUsage exception is thrown if there are any errors validating the JSON object. JSONHandler(); ~JSONHandler() = default; - // Based on the type of handler, expect the object to be of a - // certain type. QPDFUsage is thrown otherwise. Multiple handlers - // may be registered, which allows the object to be of various - // types. If an anyHandler is added, no other handler will be - // called. There is no "final" handler -- if the top-level is a - // dictionary or array, just use its end handler. + // Based on the type of handler, expect the object to be of a certain type. QPDFUsage is thrown + // otherwise. Multiple handlers may be registered, which allows the object to be of various + // types. If an anyHandler is added, no other handler will be called. There is no "final" + // handler -- if the top-level is a dictionary or array, just use its end handler. typedef std::function<void(std::string const& path, JSON value)> json_handler_t; typedef std::function<void(std::string const& path)> void_handler_t; typedef std::function<void(std::string const& path, std::string const& value)> string_handler_t; typedef std::function<void(std::string const& path, bool value)> bool_handler_t; - // If an any handler is added, it will be called for any value - // including null, and no other handler will be called. + // If an any handler is added, it will be called for any value including null, and no other + // handler will be called. void addAnyHandler(json_handler_t fn); - // If any of the remaining handlers are registered, each - // registered handle will be called. + // If any of the remaining handlers are registered, each registered handle will be called. void addNullHandler(void_handler_t fn); void addStringHandler(string_handler_t fn); void addNumberHandler(string_handler_t fn); diff --git a/libqpdf/qpdf/MD5.hh b/libqpdf/qpdf/MD5.hh index 977cd4b5..be97edb5 100644 --- a/libqpdf/qpdf/MD5.hh +++ b/libqpdf/qpdf/MD5.hh @@ -29,8 +29,7 @@ class MD5 // computes a raw digest void digest(Digest); - // prints the digest to stdout terminated with \r\n (primarily for - // testing) + // prints the digest to stdout terminated with \r\n (primarily for testing) void print(); // returns the digest as a hexadecimal string diff --git a/libqpdf/qpdf/NNTree.hh b/libqpdf/qpdf/NNTree.hh index 6345b105..4b5ba200 100644 --- a/libqpdf/qpdf/NNTree.hh +++ b/libqpdf/qpdf/NNTree.hh @@ -104,9 +104,8 @@ class NNTreeImpl iterator insert(QPDFObjectHandle key, QPDFObjectHandle value); bool remove(QPDFObjectHandle key, QPDFObjectHandle* value = nullptr); - // Change the split threshold for easier testing. There's no real - // reason to expose this to downstream tree helpers, but it has to - // be public so we can call it from the test suite. + // Change the split threshold for easier testing. There's no real reason to expose this to + // downstream tree helpers, but it has to be public so we can call it from the test suite. void setSplitThreshold(int split_threshold); private: diff --git a/libqpdf/qpdf/OffsetInputSource.hh b/libqpdf/qpdf/OffsetInputSource.hh index 2d506f80..f9246363 100644 --- a/libqpdf/qpdf/OffsetInputSource.hh +++ b/libqpdf/qpdf/OffsetInputSource.hh @@ -1,8 +1,8 @@ #ifndef QPDF_OFFSETINPUTSOURCE_HH #define QPDF_OFFSETINPUTSOURCE_HH -// This class implements an InputSource that proxies for an underlying -// input source but offset a specific number of bytes. +// This class implements an InputSource that proxies for an underlying input source but offset a +// specific number of bytes. #include <qpdf/InputSource.hh> diff --git a/libqpdf/qpdf/Pl_AES_PDF.hh b/libqpdf/qpdf/Pl_AES_PDF.hh index b3fde312..32f4c351 100644 --- a/libqpdf/qpdf/Pl_AES_PDF.hh +++ b/libqpdf/qpdf/Pl_AES_PDF.hh @@ -5,8 +5,8 @@ #include <qpdf/QPDFCryptoImpl.hh> #include <memory> -// This pipeline implements AES-128 and AES-256 with CBC and block -// padding as specified in the PDF specification. +// This pipeline implements AES-128 and AES-256 with CBC and block padding as specified in the PDF +// specification. class Pl_AES_PDF: public Pipeline { diff --git a/libqpdf/qpdf/Pl_MD5.hh b/libqpdf/qpdf/Pl_MD5.hh index bd56f9c6..5763d6eb 100644 --- a/libqpdf/qpdf/Pl_MD5.hh +++ b/libqpdf/qpdf/Pl_MD5.hh @@ -1,13 +1,11 @@ #ifndef PL_MD5_HH #define PL_MD5_HH -// This pipeline sends its output to its successor unmodified. After -// calling finish, the MD5 checksum of the data that passed through -// the pipeline is available. +// This pipeline sends its output to its successor unmodified. After calling finish, the MD5 +// checksum of the data that passed through the pipeline is available. -// This pipeline is reusable; i.e., it is safe to call write() after -// calling finish(). The first call to write() after a call to -// finish() initializes a new MD5 object. +// This pipeline is reusable; i.e., it is safe to call write() after calling finish(). The first +// call to write() after a call to finish() initializes a new MD5 object. #include <qpdf/MD5.hh> #include <qpdf/Pipeline.hh> @@ -20,15 +18,12 @@ class Pl_MD5: public Pipeline virtual void write(unsigned char const*, size_t); virtual void finish(); std::string getHexDigest(); - // Enable/disable. Disabling the pipeline causes it to become a - // pass-through. This makes it possible to stick an MD5 pipeline - // in a pipeline when it may or may not be required. Disabling it - // avoids incurring the runtime overhead of doing needless - // digest computation. + // Enable/disable. Disabling the pipeline causes it to become a pass-through. This makes it + // possible to stick an MD5 pipeline in a pipeline when it may or may not be required. Disabling + // it avoids incurring the runtime overhead of doing needless digest computation. void enable(bool enabled); - // If persistAcrossFinish is called, calls to finish do not - // finalize the underlying md5 object. In this case, the object is - // not finalized until getHexDigest() is called. + // If persistAcrossFinish is called, calls to finish do not finalize the underlying md5 object. + // In this case, the object is not finalized until getHexDigest() is called. void persistAcrossFinish(bool); private: diff --git a/libqpdf/qpdf/Pl_PNGFilter.hh b/libqpdf/qpdf/Pl_PNGFilter.hh index 7ab7bf0d..ed8e1e9c 100644 --- a/libqpdf/qpdf/Pl_PNGFilter.hh +++ b/libqpdf/qpdf/Pl_PNGFilter.hh @@ -1,11 +1,11 @@ #ifndef PL_PNGFILTER_HH #define PL_PNGFILTER_HH -// This pipeline applies or reverses the application of a PNG filter -// as described in the PNG specification. +// This pipeline applies or reverses the application of a PNG filter as described in the PNG +// specification. -// NOTE: In its current implementation, this filter always encodes -// using the "up" filter, but it decodes all the filters. +// NOTE: In its current implementation, this filter always encodes using the "up" filter, but it +// decodes all the filters. #include <qpdf/Pipeline.hh> diff --git a/libqpdf/qpdf/Pl_SHA2.hh b/libqpdf/qpdf/Pl_SHA2.hh index 571271eb..9b3275f0 100644 --- a/libqpdf/qpdf/Pl_SHA2.hh +++ b/libqpdf/qpdf/Pl_SHA2.hh @@ -1,16 +1,13 @@ #ifndef PL_SHA2_HH #define PL_SHA2_HH -// Bits must be a supported number of bits, currently only 256, 384, -// or 512. Passing 0 as bits leaves the pipeline uncommitted, in -// which case resetBits must be called before the pipeline is used. -// If a next is provided, this pipeline sends its output to its -// successor unmodified. After calling finish, the SHA2 checksum of -// the data that passed through the pipeline is available. +// Bits must be a supported number of bits, currently only 256, 384, or 512. Passing 0 as bits +// leaves the pipeline uncommitted, in which case resetBits must be called before the pipeline is +// used. If a next is provided, this pipeline sends its output to its successor unmodified. After +// calling finish, the SHA2 checksum of the data that passed through the pipeline is available. -// This pipeline is reusable; i.e., it is safe to call write() after -// calling finish(). The first call to write() after a call to -// finish() initializes a new SHA2 object. resetBits may also be +// This pipeline is reusable; i.e., it is safe to call write() after calling finish(). The first +// call to write() after a call to finish() initializes a new SHA2 object. resetBits may also be // called between finish and the next call to write. #include <qpdf/Pipeline.hh> diff --git a/libqpdf/qpdf/Pl_TIFFPredictor.hh b/libqpdf/qpdf/Pl_TIFFPredictor.hh index 6bc48e72..21757593 100644 --- a/libqpdf/qpdf/Pl_TIFFPredictor.hh +++ b/libqpdf/qpdf/Pl_TIFFPredictor.hh @@ -1,8 +1,8 @@ #ifndef PL_TIFFPREDICTOR_HH #define PL_TIFFPREDICTOR_HH -// This pipeline reverses the application of a TIFF predictor as -// described in the TIFF specification. +// This pipeline reverses the application of a TIFF predictor as described in the TIFF +// specification. #include <qpdf/Pipeline.hh> diff --git a/libqpdf/qpdf/QPDFArgParser.hh b/libqpdf/qpdf/QPDFArgParser.hh index d9e33b5a..3b22a805 100644 --- a/libqpdf/qpdf/QPDFArgParser.hh +++ b/libqpdf/qpdf/QPDFArgParser.hh @@ -9,41 +9,33 @@ #include <string> #include <vector> -// This is not a general-purpose argument parser. It is tightly -// crafted to work with qpdf. qpdf's command-line syntax is very -// complex because of its long history, and it doesn't really follow -// any kind of normal standard for arguments, but it's important for -// backward compatibility to ensure we don't break what constitutes a -// valid command. This class handles the quirks of qpdf's argument -// parsing, bash/zsh completion, and support for @argfile to read -// arguments from a file. For the qpdf CLI, setup of QPDFArgParser is -// done mostly by automatically-generated code (one-off code for -// qpdf), though the handlers themselves are hand-coded. See -// generate_auto_job at the top of the source tree for details. +// This is not a general-purpose argument parser. It is tightly crafted to work with qpdf. qpdf's +// command-line syntax is very complex because of its long history, and it doesn't really follow any +// kind of normal standard for arguments, but it's important for backward compatibility to ensure we +// don't break what constitutes a valid command. This class handles the quirks of qpdf's argument +// parsing, bash/zsh completion, and support for @argfile to read arguments from a file. For the +// qpdf CLI, setup of QPDFArgParser is done mostly by automatically-generated code (one-off code for +// qpdf), though the handlers themselves are hand-coded. See generate_auto_job at the top of the +// source tree for details. class QPDFArgParser { public: - // progname_env is used to override argv[0] when figuring out the - // name of the executable for setting up completion. This may be - // needed if the program is invoked by a wrapper. + // progname_env is used to override argv[0] when figuring out the name of the executable for + // setting up completion. This may be needed if the program is invoked by a wrapper. QPDFArgParser(int argc, char const* const argv[], char const* progname_env); - // Calls exit(0) if a help option is given or if in completion - // mode. If there are argument parsing errors, QPDFUsage is - // thrown. + // Calls exit(0) if a help option is given or if in completion mode. If there are argument + // parsing errors, QPDFUsage is thrown. void parseArgs(); - // Return the program name as the last path element of the program - // executable. + // Return the program name as the last path element of the program executable. std::string getProgname(); - // Methods for registering arguments. QPDFArgParser starts off - // with the main option table selected. You can add handlers for - // arguments in the current option table, and you can select which - // option table is current. The help option table is special and - // contains arguments that are only valid as the first and only - // option. Named option tables are for subparsers and always start - // a series of options that end with `--`. + // Methods for registering arguments. QPDFArgParser starts off with the main option table + // selected. You can add handlers for arguments in the current option table, and you can select + // which option table is current. The help option table is special and contains arguments that + // are only valid as the first and only option. Named option tables are for subparsers and + // always start a series of options that end with `--`. typedef std::function<void()> bare_arg_handler_t; typedef std::function<void(std::string const&)> param_arg_handler_t; @@ -65,9 +57,8 @@ class QPDFArgParser void addChoices(std::string const& arg, param_arg_handler_t, bool required, char const** choices); - // The default behavior when an invalid choice is specified with - // an option that takes choices is to list all the choices. This - // may not be good if there are too many choices, so you can + // The default behavior when an invalid choice is specified with an option that takes choices is + // to list all the choices. This may not be good if there are too many choices, so you can // provide your own handler in this case. void addInvalidChoiceHandler(std::string const& arg, param_arg_handler_t); @@ -77,42 +68,33 @@ class QPDFArgParser // Help generation methods - // Help is available on topics and options. Options may be - // associated with topics. Users can run --help, --help=topic, or - // --help=--arg to get help. The top-level help tells the user how - // to run help and lists available topics. Help for a topic prints - // a short synopsis about the topic and lists any options that may - // be associated with the topic. Help for an option provides a - // short synopsis for that option. All help output is appended - // with a blurb (if supplied) directing the user to the full - // documentation. Help is not shown for options for which help has - // not been added. This makes it possible to have undocumented - // options for testing, backward-compatibility, etc. Also, it - // could be quite confusing to handle appropriate help for some - // inner options that may be repeated with different semantics - // inside different option tables. There is also no checking for - // whether an option that has help actually exists. In other - // words, it's up to the caller to ensure that help actually - // corresponds to the program's actual options. Rather than this - // being an intentional design decision, it is because this class - // is specifically for qpdf, qpdf generates its help and has other - // means to ensure consistency. + // Help is available on topics and options. Options may be associated with topics. Users can run + // --help, --help=topic, or --help=--arg to get help. The top-level help tells the user how + // to run help and lists available topics. Help for a topic prints a short synopsis about the + // topic and lists any options that may be associated with the topic. Help for an option + // provides a short synopsis for that option. All help output is appended with a blurb (if + // supplied) directing the user to the full documentation. Help is not shown for options for + // which help has not been added. This makes it possible to have undocumented options for + // testing, backward-compatibility, etc. Also, it could be quite confusing to handle appropriate + // help for some inner options that may be repeated with different semantics inside different + // option tables. There is also no checking for whether an option that has help actually exists. + // In other words, it's up to the caller to ensure that help actually corresponds to the + // program's actual options. Rather than this being an intentional design decision, it is + // because this class is specifically for qpdf, qpdf generates its help and has other means to + // ensure consistency. // Note about newlines: // - // short_text should fit easily after the topic/option on the same - // line and should not end with a newline. Keep it to around 40 to - // 60 characters. + // short_text should fit easily after the topic/option on the same line and should not end with + // a newline. Keep it to around 40 to 60 characters. // - // long_text and footer should end with a single newline. They can - // have embedded newlines. Keep lines to under 80 columns. + // long_text and footer should end with a single newline. They can have embedded newlines. Keep + // lines to under 80 columns. // - // QPDFArgParser does reformat the text, but it may add blank - // lines in some situations. Following the above conventions will - // keep the help looking uniform. + // QPDFArgParser does reformat the text, but it may add blank lines in some situations. + // Following the above conventions will keep the help looking uniform. - // If provided, this footer is appended to all help, separated by - // a blank line. + // If provided, this footer is appended to all help, separated by a blank line. void addHelpFooter(std::string const&); // Add a help topic along with the text for that topic @@ -126,14 +108,12 @@ class QPDFArgParser std::string const& short_text, std::string const& long_text); - // Return the help text for a topic or option. Passing a null - // pointer returns the top-level help information. Passing an - // unknown value returns a string directing the user to run the + // Return the help text for a topic or option. Passing a null pointer returns the top-level help + // information. Passing an unknown value returns a string directing the user to run the // top-level --help option. std::string getHelp(std::string const& topic_or_option); - // Convenience methods for adding member functions of a class as - // handlers. + // Convenience methods for adding member functions of a class as handlers. template <class T> static bare_arg_handler_t bindBare(void (T::*f)(), T* o) @@ -147,21 +127,19 @@ class QPDFArgParser return std::bind(std::mem_fn(f), o, std::placeholders::_1); } - // When processing arguments, indicate how many arguments remain - // after the one whose handler is being called. + // When processing arguments, indicate how many arguments remain after the one whose handler is + // being called. int argsLeft() const; // Indicate whether we are in completion mode. bool isCompleting() const; - // Insert a completion during argument parsing; useful for - // customizing completion in the position argument handler. Should - // only be used in completion mode. + // Insert a completion during argument parsing; useful for customizing completion in the + // position argument handler. Should only be used in completion mode. void insertCompletion(std::string const&); - // Throw a Usage exception with the given message. In completion - // mode, this just exits to prevent errors from partial commands - // or other error messages from messing up completion. + // Throw a Usage exception with the given message. In completion mode, this just exits to + // prevent errors from partial commands or other error messages from messing up completion. void usage(std::string const& message); private: diff --git a/libqpdf/qpdf/QPDFCrypto_gnutls.hh b/libqpdf/qpdf/QPDFCrypto_gnutls.hh index efec1bbf..00f25857 100644 --- a/libqpdf/qpdf/QPDFCrypto_gnutls.hh +++ b/libqpdf/qpdf/QPDFCrypto_gnutls.hh @@ -4,8 +4,8 @@ #include <qpdf/QPDFCryptoImpl.hh> #include <memory> -// gnutls headers must be last to prevent them from interfering with -// other headers. gnutls.h has to be included first. +// gnutls headers must be last to prevent them from interfering with other headers. gnutls.h has to +// be included first. #include <gnutls/gnutls.h> // This comment prevents clang-format from putting crypto.h before gnutls.h #include <gnutls/crypto.h> diff --git a/libqpdf/qpdf/QPDFObject_private.hh b/libqpdf/qpdf/QPDFObject_private.hh index bbd6ccf1..5e87c215 100644 --- a/libqpdf/qpdf/QPDFObject_private.hh +++ b/libqpdf/qpdf/QPDFObject_private.hh @@ -1,9 +1,8 @@ #ifndef QPDFOBJECT_HH #define QPDFOBJECT_HH -// NOTE: This file is called QPDFObject_private.hh instead of -// QPDFObject.hh because of include/qpdf/QPDFObject.hh. See comments -// there for an explanation. +// NOTE: This file is called QPDFObject_private.hh instead of QPDFObject.hh because of +// include/qpdf/QPDFObject.hh. See comments there for an explanation. #include <qpdf/Constants.h> #include <qpdf/DLL.h> @@ -51,8 +50,7 @@ class QPDFObject return value->type_code; } - // Return a string literal that describes the type, useful for - // debugging and testing + // Return a string literal that describes the type, useful for debugging and testing char const* getTypeName() const { @@ -146,14 +144,12 @@ class QPDFObject void disconnect() { - // Disconnect an object from its owning QPDF. This is called - // by QPDF's destructor. + // Disconnect an object from its owning QPDF. This is called by QPDF's destructor. value->disconnect(); value->qpdf = nullptr; value->og = QPDFObjGen(); } - // Mark an object as destroyed. Used by QPDF's destructor for its - // indirect objects. + // Mark an object as destroyed. Used by QPDF's destructor for its indirect objects. void destroy(); bool diff --git a/libqpdf/qpdf/QPDF_Dictionary.hh b/libqpdf/qpdf/QPDF_Dictionary.hh index bf3dfb2d..da38db7a 100644 --- a/libqpdf/qpdf/QPDF_Dictionary.hh +++ b/libqpdf/qpdf/QPDF_Dictionary.hh @@ -19,16 +19,15 @@ class QPDF_Dictionary: public QPDFValue virtual JSON getJSON(int json_version); virtual void disconnect(); - // hasKey() and getKeys() treat keys with null values as if they - // aren't there. getKey() returns null for the value of a - // non-existent key. This is as per the PDF spec. + // hasKey() and getKeys() treat keys with null values as if they aren't there. getKey() returns + // null for the value of a non-existent key. This is as per the PDF spec. bool hasKey(std::string const&); QPDFObjectHandle getKey(std::string const&); std::set<std::string> getKeys(); std::map<std::string, QPDFObjectHandle> const& getAsMap() const; - // If value is null, remove key; otherwise, replace the value of - // key, adding it if it does not exist. + // If value is null, remove key; otherwise, replace the value of key, adding it if it does not + // exist. void replaceKey(std::string const& key, QPDFObjectHandle value); // Remove key, doing nothing if key does not exist void removeKey(std::string const& key); diff --git a/libqpdf/qpdf/RC4.hh b/libqpdf/qpdf/RC4.hh index 257e6980..08bde7a3 100644 --- a/libqpdf/qpdf/RC4.hh +++ b/libqpdf/qpdf/RC4.hh @@ -11,8 +11,7 @@ class RC4 // key_len of -1 means treat key_data as a null-terminated string RC4(unsigned char const* key_data, int key_len = -1); - // It is safe to pass the same pointer to in_data and out_data to - // encrypt/decrypt in place + // It is safe to pass the same pointer to in_data and out_data to encrypt/decrypt in place void process(unsigned char const* in_data, size_t len, unsigned char* out_data); private: |