From 59f3e09edfc71556208a866bb97ed9e173bd827f Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Tue, 3 May 2022 17:43:07 -0400 Subject: Make Pipeline::write take an unsigned char const* (API change) --- include/qpdf/Pipeline.hh | 10 ++-------- include/qpdf/Pl_Buffer.hh | 2 +- include/qpdf/Pl_Concatenate.hh | 2 +- include/qpdf/Pl_Count.hh | 2 +- include/qpdf/Pl_DCT.hh | 2 +- include/qpdf/Pl_Discard.hh | 2 +- include/qpdf/Pl_Flate.hh | 4 ++-- include/qpdf/Pl_QPDFTokenizer.hh | 2 +- include/qpdf/Pl_RunLength.hh | 6 +++--- include/qpdf/Pl_StdioFile.hh | 2 +- include/qpdf/QPDFCryptoImpl.hh | 4 +++- 11 files changed, 17 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/qpdf/Pipeline.hh b/include/qpdf/Pipeline.hh index 09ec0925..8c1dfe17 100644 --- a/include/qpdf/Pipeline.hh +++ b/include/qpdf/Pipeline.hh @@ -63,15 +63,9 @@ class QPDF_DLL_CLASS Pipeline // Subclasses should implement write and finish to do their jobs // and then, if they are not end-of-line pipelines, call - // getNext()->write or getNext()->finish. It would be really nice - // if write could take unsigned char const*, but this would make - // it much more difficult to write pipelines around legacy - // interfaces whose calls don't want pointers to const data. As a - // rule, pipelines should generally not be modifying the data - // passed to them. They should, instead, create new data to pass - // downstream. + // getNext()->write or getNext()->finish. QPDF_DLL - virtual void write(unsigned char* data, size_t len) = 0; + virtual void write(unsigned char const* data, size_t len) = 0; QPDF_DLL virtual void finish() = 0; QPDF_DLL diff --git a/include/qpdf/Pl_Buffer.hh b/include/qpdf/Pl_Buffer.hh index d9aec078..7784286d 100644 --- a/include/qpdf/Pl_Buffer.hh +++ b/include/qpdf/Pl_Buffer.hh @@ -47,7 +47,7 @@ class QPDF_DLL_CLASS Pl_Buffer: public Pipeline QPDF_DLL virtual ~Pl_Buffer(); QPDF_DLL - virtual void write(unsigned char*, size_t); + virtual void write(unsigned char const*, size_t); QPDF_DLL virtual void finish(); diff --git a/include/qpdf/Pl_Concatenate.hh b/include/qpdf/Pl_Concatenate.hh index 1f4e2f40..4d6bef18 100644 --- a/include/qpdf/Pl_Concatenate.hh +++ b/include/qpdf/Pl_Concatenate.hh @@ -39,7 +39,7 @@ class QPDF_DLL_CLASS Pl_Concatenate: public Pipeline virtual ~Pl_Concatenate(); QPDF_DLL - virtual void write(unsigned char* data, size_t len); + virtual void write(unsigned char const* data, size_t len); QPDF_DLL virtual void finish(); diff --git a/include/qpdf/Pl_Count.hh b/include/qpdf/Pl_Count.hh index d0bf8cb3..1df32ebb 100644 --- a/include/qpdf/Pl_Count.hh +++ b/include/qpdf/Pl_Count.hh @@ -36,7 +36,7 @@ class QPDF_DLL_CLASS Pl_Count: public Pipeline QPDF_DLL virtual ~Pl_Count(); QPDF_DLL - virtual void write(unsigned char*, size_t); + virtual void write(unsigned char const*, size_t); QPDF_DLL virtual void finish(); // Returns the number of bytes written diff --git a/include/qpdf/Pl_DCT.hh b/include/qpdf/Pl_DCT.hh index 3503ac77..fcbf1c29 100644 --- a/include/qpdf/Pl_DCT.hh +++ b/include/qpdf/Pl_DCT.hh @@ -61,7 +61,7 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline virtual ~Pl_DCT(); QPDF_DLL - virtual void write(unsigned char* data, size_t len); + virtual void write(unsigned char const* data, size_t len); QPDF_DLL virtual void finish(); diff --git a/include/qpdf/Pl_Discard.hh b/include/qpdf/Pl_Discard.hh index c58c162a..ae63b8dc 100644 --- a/include/qpdf/Pl_Discard.hh +++ b/include/qpdf/Pl_Discard.hh @@ -38,7 +38,7 @@ class QPDF_DLL_CLASS Pl_Discard: public Pipeline QPDF_DLL virtual ~Pl_Discard(); QPDF_DLL - virtual void write(unsigned char*, size_t); + virtual void write(unsigned char const*, size_t); QPDF_DLL virtual void finish(); diff --git a/include/qpdf/Pl_Flate.hh b/include/qpdf/Pl_Flate.hh index daf05836..ee797180 100644 --- a/include/qpdf/Pl_Flate.hh +++ b/include/qpdf/Pl_Flate.hh @@ -43,7 +43,7 @@ class QPDF_DLL_CLASS Pl_Flate: public Pipeline virtual ~Pl_Flate(); QPDF_DLL - virtual void write(unsigned char* data, size_t len); + virtual void write(unsigned char const* data, size_t len); QPDF_DLL virtual void finish(); @@ -61,7 +61,7 @@ class QPDF_DLL_CLASS Pl_Flate: public Pipeline private: QPDF_DLL_PRIVATE - void handleData(unsigned char* data, size_t len, int flush); + void handleData(unsigned char const* data, size_t len, int flush); QPDF_DLL_PRIVATE void checkError(char const* prefix, int error_code); QPDF_DLL_PRIVATE diff --git a/include/qpdf/Pl_QPDFTokenizer.hh b/include/qpdf/Pl_QPDFTokenizer.hh index 20f36603..5dbaf788 100644 --- a/include/qpdf/Pl_QPDFTokenizer.hh +++ b/include/qpdf/Pl_QPDFTokenizer.hh @@ -55,7 +55,7 @@ class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline QPDF_DLL virtual ~Pl_QPDFTokenizer(); QPDF_DLL - virtual void write(unsigned char* buf, size_t len); + virtual void write(unsigned char const* buf, size_t len); QPDF_DLL virtual void finish(); diff --git a/include/qpdf/Pl_RunLength.hh b/include/qpdf/Pl_RunLength.hh index 47c72d65..92023f40 100644 --- a/include/qpdf/Pl_RunLength.hh +++ b/include/qpdf/Pl_RunLength.hh @@ -35,15 +35,15 @@ class QPDF_DLL_CLASS Pl_RunLength: public Pipeline virtual ~Pl_RunLength(); QPDF_DLL - virtual void write(unsigned char* data, size_t len); + virtual void write(unsigned char const* data, size_t len); QPDF_DLL virtual void finish(); private: QPDF_DLL_PRIVATE - void encode(unsigned char* data, size_t len); + void encode(unsigned char const* data, size_t len); QPDF_DLL_PRIVATE - void decode(unsigned char* data, size_t len); + void decode(unsigned char const* data, size_t len); QPDF_DLL_PRIVATE void flush_encode(); diff --git a/include/qpdf/Pl_StdioFile.hh b/include/qpdf/Pl_StdioFile.hh index 1dfb6c99..ae3a86e9 100644 --- a/include/qpdf/Pl_StdioFile.hh +++ b/include/qpdf/Pl_StdioFile.hh @@ -43,7 +43,7 @@ class QPDF_DLL_CLASS Pl_StdioFile: public Pipeline virtual ~Pl_StdioFile(); QPDF_DLL - virtual void write(unsigned char* buf, size_t len); + virtual void write(unsigned char const* buf, size_t len); QPDF_DLL virtual void finish(); diff --git a/include/qpdf/QPDFCryptoImpl.hh b/include/qpdf/QPDFCryptoImpl.hh index bf3c9087..a88b416a 100644 --- a/include/qpdf/QPDFCryptoImpl.hh +++ b/include/qpdf/QPDFCryptoImpl.hh @@ -78,7 +78,9 @@ class QPDF_DLL_CLASS QPDFCryptoImpl // out_data = 0 means to encrypt/decrypt in place QPDF_DLL virtual void RC4_process( - unsigned char* in_data, size_t len, unsigned char* out_data = 0) = 0; + unsigned char const* in_data, + size_t len, + unsigned char* out_data = 0) = 0; QPDF_DLL virtual void RC4_finalize() = 0; -- cgit v1.2.3-70-g09d2