2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-19 18:32:21 +00:00

Remove methods of private classes from ABI

Prior to the cmake conversion, several private classes had methods
that were exported into the shared library so they could be tested
with libtests. With cmake, we build libtests using an object library,
so this is no longer necessary. The methods that are disappearing from
the ABI were never exposed through public headers, so no code should
be using them. Removal had to wait until the window for ABI-breaking
changes was open.
This commit is contained in:
Jay Berkenbilt 2022-04-09 17:24:26 -04:00
parent b6d1dffaaa
commit 07edf96440
24 changed files with 0 additions and 176 deletions

1
TODO
View File

@ -37,7 +37,6 @@ cmake
=====
* DLL.h
* Remove DLL.h and QPDF_DLL* from all private library classes.
* Change DLL_EXPORT to QPDF_EXPORT. Be sure to call attention to
this in the release notes. There should be a "migrating to cmake"
in the manual, and ./configure should draw attention to it.

View File

@ -3,25 +3,18 @@
#ifndef BITSTREAM_HH
#define BITSTREAM_HH
#include <qpdf/DLL.h>
#include <stddef.h>
class BitStream
{
public:
QPDF_DLL
BitStream(unsigned char const* p, size_t nbytes);
QPDF_DLL
void reset();
QPDF_DLL
unsigned long long getBits(size_t nbits);
QPDF_DLL
long long getBitsSigned(size_t nbits);
// Only call getBitsInt when requesting a number of bits that will
// definitely fit in an int.
QPDF_DLL
int getBitsInt(size_t nbits);
QPDF_DLL
void skipToNextByte();
private:

View File

@ -3,7 +3,6 @@
#ifndef BITWRITER_HH
#define BITWRITER_HH
#include <qpdf/DLL.h>
#include <stddef.h>
class Pipeline;
@ -13,16 +12,11 @@ class BitWriter
public:
// Write bits to the pipeline. It is the caller's responsibility
// to eventually call finish on the pipeline.
QPDF_DLL
BitWriter(Pipeline* pl);
QPDF_DLL
void writeBits(unsigned long long val, size_t bits);
QPDF_DLL
void writeBitsSigned(long long val, size_t bits);
QPDF_DLL
void writeBitsInt(int val, size_t bits);
// Force any partial byte to be written to the pipeline.
QPDF_DLL
void flush();
private:

View File

@ -1,21 +1,14 @@
#ifndef CRYPTORANDOMDATAPROVIDER_HH
#define CRYPTORANDOMDATAPROVIDER_HH
#include <qpdf/DLL.h>
#include <qpdf/RandomDataProvider.hh>
class CryptoRandomDataProvider: public RandomDataProvider
{
public:
QPDF_DLL
CryptoRandomDataProvider();
QPDF_DLL
virtual ~CryptoRandomDataProvider();
QPDF_DLL
virtual void provideRandomData(unsigned char* data, size_t len);
QPDF_DLL
static RandomDataProvider* getInstance();
};

View File

@ -1,21 +1,14 @@
#ifndef INSECURERANDOMDATAPROVIDER_HH
#define INSECURERANDOMDATAPROVIDER_HH
#include <qpdf/DLL.h>
#include <qpdf/RandomDataProvider.hh>
class InsecureRandomDataProvider: public RandomDataProvider
{
public:
QPDF_DLL
InsecureRandomDataProvider();
QPDF_DLL
virtual ~InsecureRandomDataProvider();
QPDF_DLL
virtual void provideRandomData(unsigned char* data, size_t len);
QPDF_DLL
static RandomDataProvider* getInstance();
private:

View File

@ -1,7 +1,6 @@
#ifndef JSONHANDLER_HH
#define JSONHANDLER_HH
#include <qpdf/DLL.h>
#include <qpdf/JSON.hh>
#include <functional>
#include <map>
@ -18,10 +17,7 @@ class JSONHandler
public:
// A QPDFUsage exception is thrown if there are any errors
// validating the JSON object.
QPDF_DLL
JSONHandler();
QPDF_DLL
~JSONHandler() = default;
// Based on the type of handler, expect the object to be of a
@ -42,36 +38,26 @@ class JSONHandler
// If an any handler is added, it will be called for any value
// including null, and no other handler will be called.
QPDF_DLL
void addAnyHandler(json_handler_t fn);
// If any of the remaining handlers are registered, each
// registered handle will be called.
QPDF_DLL
void addNullHandler(void_handler_t fn);
QPDF_DLL
void addStringHandler(string_handler_t fn);
QPDF_DLL
void addNumberHandler(string_handler_t fn);
QPDF_DLL
void addBoolHandler(bool_handler_t fn);
QPDF_DLL
void addDictHandlers(json_handler_t start_fn, void_handler_t end_fn);
QPDF_DLL
void
addDictKeyHandler(std::string const& key, std::shared_ptr<JSONHandler>);
QPDF_DLL
void addFallbackDictHandler(std::shared_ptr<JSONHandler>);
QPDF_DLL
void addArrayHandlers(
json_handler_t start_fn,
void_handler_t end_fn,
std::shared_ptr<JSONHandler> item_handlers);
// Apply handlers recursively to a JSON object.
QPDF_DLL
void handle(std::string const& path, JSON j);
private:
@ -115,7 +101,6 @@ class JSONHandler
friend class JSONHandler;
public:
QPDF_DLL
~Members() = default;
private:

View File

@ -1,7 +1,6 @@
#ifndef MD5_HH
#define MD5_HH
#include <qpdf/DLL.h>
#include <qpdf/QPDFCryptoImpl.hh>
#include <qpdf/Types.h>
#include <memory>
@ -12,50 +11,37 @@ class MD5
public:
typedef unsigned char Digest[16];
QPDF_DLL
MD5();
QPDF_DLL
void reset();
// encodes string and finalizes
QPDF_DLL
void encodeString(char const* input_string);
// encodes file and finalizes; offset < 0 reads whole file
QPDF_DLL
void encodeFile(char const* filename, qpdf_offset_t up_to_offset = -1);
// appends string to current md5 object
QPDF_DLL
void appendString(char const* input_string);
// appends arbitrary data to current md5 object
QPDF_DLL
void encodeDataIncrementally(char const* input_data, size_t len);
// computes a raw digest
QPDF_DLL
void digest(Digest);
// prints the digest to stdout terminated with \r\n (primarily for
// testing)
QPDF_DLL
void print();
// returns the digest as a hexadecimal string
QPDF_DLL
std::string unparse();
// Convenience functions
QPDF_DLL
static std::string getDataChecksum(char const* buf, size_t len);
QPDF_DLL
static std::string
getFileChecksum(char const* filename, qpdf_offset_t up_to_offset = -1);
QPDF_DLL
static bool
checkDataChecksum(char const* const checksum, char const* buf, size_t len);
QPDF_DLL
static bool checkFileChecksum(
char const* const checksum,
char const* filename,

View File

@ -11,7 +11,6 @@
class Pl_AES_PDF: public Pipeline
{
public:
QPDF_DLL
// key should be a pointer to key_bytes bytes of data
Pl_AES_PDF(
char const* identifier,
@ -19,30 +18,22 @@ class Pl_AES_PDF: public Pipeline
bool encrypt,
unsigned char const* key,
size_t key_bytes);
QPDF_DLL
virtual ~Pl_AES_PDF();
QPDF_DLL
virtual void write(unsigned char* data, size_t len);
QPDF_DLL
virtual void finish();
// Use zero initialization vector; needed for AESV3
QPDF_DLL
void useZeroIV();
// Disable padding; needed for AESV3
QPDF_DLL
void disablePadding();
// Specify an initialization vector, which will not be included in
// the output.
QPDF_DLL
void setIV(unsigned char const* iv, size_t bytes);
// For testing only; PDF always uses CBC
QPDF_DLL
void disableCBC();
// For testing only: use a fixed initialization vector for CBC
QPDF_DLL
static void useStaticIV();
private:

View File

@ -6,13 +6,9 @@
class Pl_ASCII85Decoder: public Pipeline
{
public:
QPDF_DLL
Pl_ASCII85Decoder(char const* identifier, Pipeline* next);
QPDF_DLL
virtual ~Pl_ASCII85Decoder();
QPDF_DLL
virtual void write(unsigned char* buf, size_t len);
QPDF_DLL
virtual void finish();
private:

View File

@ -6,13 +6,9 @@
class Pl_ASCIIHexDecoder: public Pipeline
{
public:
QPDF_DLL
Pl_ASCIIHexDecoder(char const* identifier, Pipeline* next);
QPDF_DLL
virtual ~Pl_ASCIIHexDecoder();
QPDF_DLL
virtual void write(unsigned char* buf, size_t len);
QPDF_DLL
virtual void finish();
private:

View File

@ -9,14 +9,10 @@
class Pl_LZWDecoder: public Pipeline
{
public:
QPDF_DLL
Pl_LZWDecoder(
char const* identifier, Pipeline* next, bool early_code_change);
QPDF_DLL
virtual ~Pl_LZWDecoder();
QPDF_DLL
virtual void write(unsigned char* buf, size_t len);
QPDF_DLL
virtual void finish();
private:

View File

@ -15,27 +15,20 @@
class Pl_MD5: public Pipeline
{
public:
QPDF_DLL
Pl_MD5(char const* identifier, Pipeline* next);
QPDF_DLL
virtual ~Pl_MD5();
QPDF_DLL
virtual void write(unsigned char*, size_t);
QPDF_DLL
virtual void finish();
QPDF_DLL
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.
QPDF_DLL
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.
QPDF_DLL
void persistAcrossFinish(bool);
private:

View File

@ -15,7 +15,6 @@ class Pl_PNGFilter: public Pipeline
// Encoding is only partially supported
enum action_e { a_encode, a_decode };
QPDF_DLL
Pl_PNGFilter(
char const* identifier,
Pipeline* next,
@ -23,12 +22,9 @@ class Pl_PNGFilter: public Pipeline
unsigned int columns,
unsigned int samples_per_pixel = 1,
unsigned int bits_per_sample = 8);
QPDF_DLL
virtual ~Pl_PNGFilter();
QPDF_DLL
virtual void write(unsigned char* data, size_t len);
QPDF_DLL
virtual void finish();
private:

View File

@ -11,19 +11,15 @@ class Pl_RC4: public Pipeline
static size_t const def_bufsize = 65536;
// key_len of -1 means treat key_data as a null-terminated string
QPDF_DLL
Pl_RC4(
char const* identifier,
Pipeline* next,
unsigned char const* key_data,
int key_len = -1,
size_t out_bufsize = def_bufsize);
QPDF_DLL
virtual ~Pl_RC4();
QPDF_DLL
virtual void write(unsigned char* data, size_t len);
QPDF_DLL
virtual void finish();
private:

View File

@ -20,19 +20,12 @@
class Pl_SHA2: public Pipeline
{
public:
QPDF_DLL
Pl_SHA2(int bits = 0, Pipeline* next = 0);
QPDF_DLL
virtual ~Pl_SHA2();
QPDF_DLL
virtual void write(unsigned char*, size_t);
QPDF_DLL
virtual void finish();
QPDF_DLL
void resetBits(int bits);
QPDF_DLL
std::string getHexDigest();
QPDF_DLL
std::string getRawDigest();
private:

View File

@ -11,7 +11,6 @@ class Pl_TIFFPredictor: public Pipeline
public:
enum action_e { a_encode, a_decode };
QPDF_DLL
Pl_TIFFPredictor(
char const* identifier,
Pipeline* next,
@ -19,12 +18,9 @@ class Pl_TIFFPredictor: public Pipeline
unsigned int columns,
unsigned int samples_per_pixel = 1,
unsigned int bits_per_sample = 8);
QPDF_DLL
virtual ~Pl_TIFFPredictor();
QPDF_DLL
virtual void write(unsigned char* data, size_t len);
QPDF_DLL
virtual void finish();
private:

View File

@ -1,7 +1,6 @@
#ifndef QPDFARGPARSER_HH
#define QPDFARGPARSER_HH
#include <qpdf/DLL.h>
#include <functional>
#include <map>
#include <memory>
@ -27,18 +26,15 @@ class QPDFArgParser
// 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.
QPDF_DLL
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.
QPDF_DLL
void parseArgs();
// Return the program name as the last path element of the program
// executable.
QPDF_DLL
std::string getProgname();
// Methods for registering arguments. QPDFArgParser starts off
@ -52,32 +48,23 @@ class QPDFArgParser
typedef std::function<void()> bare_arg_handler_t;
typedef std::function<void(std::string const&)> param_arg_handler_t;
QPDF_DLL
void selectMainOptionTable();
QPDF_DLL
void selectHelpOptionTable();
QPDF_DLL
void selectOptionTable(std::string const& name);
// Register a new options table. This also selects the option table.
QPDF_DLL
void registerOptionTable(
std::string const& name, bare_arg_handler_t end_handler);
// Add handlers for options in the current table
QPDF_DLL
void addPositional(param_arg_handler_t);
QPDF_DLL
void addBare(std::string const& arg, bare_arg_handler_t);
QPDF_DLL
void addRequiredParameter(
std::string const& arg,
param_arg_handler_t,
char const* parameter_name);
QPDF_DLL
void addOptionalParameter(std::string const& arg, param_arg_handler_t);
QPDF_DLL
void addChoices(
std::string const& arg,
param_arg_handler_t,
@ -88,12 +75,10 @@ class QPDFArgParser
// 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.
QPDF_DLL
void addInvalidChoiceHandler(std::string const& arg, param_arg_handler_t);
// The final check handler is called at the very end of argument
// parsing.
QPDF_DLL
void addFinalCheck(bare_arg_handler_t);
// Help generation methods
@ -134,18 +119,15 @@ class QPDFArgParser
// If provided, this footer is appended to all help, separated by
// a blank line.
QPDF_DLL
void addHelpFooter(std::string const&);
// Add a help topic along with the text for that topic
QPDF_DLL
void addHelpTopic(
std::string const& topic,
std::string const& short_text,
std::string const& long_text);
// Add help for an option, and associate it with a topic.
QPDF_DLL
void addOptionHelp(
std::string const& option_name,
std::string const& topic,
@ -156,7 +138,6 @@ class QPDFArgParser
// pointer returns the top-level help information. Passing an
// unknown value returns a string directing the user to run the
// top-level --help option.
QPDF_DLL
std::string getHelp(std::string const& topic_or_option);
// Convenience methods for adding member functions of a class as
@ -176,23 +157,19 @@ class QPDFArgParser
// When processing arguments, indicate how many arguments remain
// after the one whose handler is being called.
QPDF_DLL
int argsLeft() const;
// Indicate whether we are in completion mode.
QPDF_DLL
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.
QPDF_DLL
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.
QPDF_DLL
void usage(std::string const& message);
private:
@ -259,7 +236,6 @@ class QPDFArgParser
friend class QPDFArgParser;
public:
QPDF_DLL
~Members() = default;
private:

View File

@ -1,7 +1,6 @@
#ifndef QPDFCRYPTO_GNUTLS_HH
#define QPDFCRYPTO_GNUTLS_HH
#include <qpdf/DLL.h>
#include <qpdf/QPDFCryptoImpl.hh>
#include <memory>
@ -16,7 +15,6 @@ class QPDFCrypto_gnutls: public QPDFCryptoImpl
public:
QPDFCrypto_gnutls();
QPDF_DLL
virtual ~QPDFCrypto_gnutls();
virtual void provideRandomData(unsigned char* data, size_t len);

View File

@ -2,7 +2,6 @@
#define QPDFCRYPTO_NATIVE_HH
#include <qpdf/AES_PDF_native.hh>
#include <qpdf/DLL.h>
#include <qpdf/MD5_native.hh>
#include <qpdf/QPDFCryptoImpl.hh>
#include <qpdf/RC4_native.hh>
@ -14,7 +13,6 @@ class QPDFCrypto_native: public QPDFCryptoImpl
public:
QPDFCrypto_native() = default;
QPDF_DLL
virtual ~QPDFCrypto_native() = default;
virtual void provideRandomData(unsigned char* data, size_t len);

View File

@ -26,8 +26,6 @@ class QPDFCrypto_openssl: public QPDFCryptoImpl
{
public:
QPDFCrypto_openssl();
QPDF_DLL
~QPDFCrypto_openssl() override;
void provideRandomData(unsigned char* data, size_t len) override;

View File

@ -9,11 +9,9 @@ class RC4
{
public:
// key_len of -1 means treat key_data as a null-terminated string
QPDF_DLL
RC4(unsigned char const* key_data, int key_len = -1);
// out_data = 0 means to encrypt/decrypt in place
QPDF_DLL
void
process(unsigned char* in_data, size_t len, unsigned char* out_data = 0);

View File

@ -1,21 +1,14 @@
#ifndef SECURERANDOMDATAPROVIDER_HH
#define SECURERANDOMDATAPROVIDER_HH
#include <qpdf/DLL.h>
#include <qpdf/RandomDataProvider.hh>
class SecureRandomDataProvider: public RandomDataProvider
{
public:
QPDF_DLL
SecureRandomDataProvider();
QPDF_DLL
virtual ~SecureRandomDataProvider();
QPDF_DLL
virtual void provideRandomData(unsigned char* data, size_t len);
QPDF_DLL
static RandomDataProvider* getInstance();
};

View File

@ -7,30 +7,19 @@
class SparseOHArray
{
public:
QPDF_DLL
SparseOHArray();
QPDF_DLL
size_t size() const;
QPDF_DLL
void append(QPDFObjectHandle oh);
QPDF_DLL
QPDFObjectHandle at(size_t idx) const;
QPDF_DLL
void remove_last();
QPDF_DLL
void releaseResolved();
QPDF_DLL
void setAt(size_t idx, QPDFObjectHandle oh);
QPDF_DLL
void erase(size_t idx);
QPDF_DLL
void insert(size_t idx, QPDFObjectHandle oh);
typedef std::unordered_map<size_t, QPDFObjectHandle>::const_iterator
const_iterator;
QPDF_DLL
const_iterator begin() const;
QPDF_DLL
const_iterator end() const;
private:

View File

@ -50,28 +50,6 @@
#define ignore_class(cls)
#define print_size(cls) std::cout << #cls << " " << sizeof(cls) << std::endl
// These classes are not really public.
// ------
ignore_class(BitStream);
ignore_class(BitWriter);
ignore_class(CryptoRandomDataProvider);
ignore_class(InsecureRandomDataProvider);
ignore_class(JSONHandler);
ignore_class(MD5);
ignore_class(Pl_AES_PDF);
ignore_class(Pl_ASCII85Decoder);
ignore_class(Pl_ASCIIHexDecoder);
ignore_class(Pl_LZWDecoder);
ignore_class(Pl_MD5);
ignore_class(Pl_PNGFilter);
ignore_class(Pl_RC4);
ignore_class(Pl_SHA2);
ignore_class(Pl_TIFFPredictor);
ignore_class(QPDFArgParser);
ignore_class(RC4);
ignore_class(SecureRandomDataProvider);
ignore_class(SparseOHArray);
// This is public because of QPDF_DLL_CLASS on InputSource
// -------
ignore_class(InputSource::Members);