Commit 748ab301d4f17c77393b08de4ef541b957bde275

Authored by Jay Berkenbilt
1 parent eff113fa

go back to function-based DLL_EXPORT rather than class-based to avoid creation o…

…f export files with executables under msvc

git-svn-id: svn+q:///qpdf/trunk@849 71b93d88-0707-0410-a8cf-f5a4172ac649
README.windows
... ... @@ -68,6 +68,12 @@ and then
68 68  
69 69 make
70 70  
  71 +NOTE: automated dependencies are not generated with the msvc build.
  72 +If you're planning on making modifications, you should probably work
  73 +with mingw. If there is a need, I can add dependency information to
  74 +the msvc build, but since I only use it for generating release
  75 +versions, I haven't bothered.
  76 +
71 77 The -DHAVE_VSNPRINTF is really only required for things that include
72 78 zutil.h from zlib. You don't have to worry about this when compiling
73 79 against qpdf with MSVC -- only when building zlib. It's harmless to
... ...
include/qpdf/Buffer.hh
... ... @@ -10,16 +10,24 @@
10 10  
11 11 #include <qpdf/DLL.h>
12 12  
13   -class DLL_EXPORT Buffer
  13 +class Buffer
14 14 {
15 15 public:
  16 + DLL_EXPORT
16 17 Buffer();
  18 + DLL_EXPORT
17 19 Buffer(unsigned long size);
  20 + DLL_EXPORT
18 21 Buffer(Buffer const&);
  22 + DLL_EXPORT
19 23 Buffer& operator=(Buffer const&);
  24 + DLL_EXPORT
20 25 ~Buffer();
  26 + DLL_EXPORT
21 27 unsigned long getSize() const;
  28 + DLL_EXPORT
22 29 unsigned char const* getBuffer() const;
  30 + DLL_EXPORT
23 31 unsigned char* getBuffer();
24 32  
25 33 private:
... ...
include/qpdf/Pipeline.hh
... ... @@ -33,20 +33,25 @@
33 33 #include <qpdf/DLL.h>
34 34 #include <string>
35 35  
36   -class DLL_EXPORT Pipeline
  36 +class Pipeline
37 37 {
38 38 public:
  39 + DLL_EXPORT
39 40 Pipeline(char const* identifier, Pipeline* next);
40 41  
  42 + DLL_EXPORT
41 43 virtual ~Pipeline();
42 44  
43 45 // Subclasses should implement write and finish to do their jobs
44 46 // and then, if they are not end-of-line pipelines, call
45 47 // getNext()->write or getNext()->finish.
  48 + DLL_EXPORT
46 49 virtual void write(unsigned char* data, int len) = 0;
  50 + DLL_EXPORT
47 51 virtual void finish() = 0;
48 52  
49 53 protected:
  54 + DLL_EXPORT
50 55 Pipeline* getNext(bool allow_null = false);
51 56 std::string identifier;
52 57  
... ...
include/qpdf/Pl_Buffer.hh
... ... @@ -24,17 +24,22 @@
24 24 #include <qpdf/Buffer.hh>
25 25 #include <list>
26 26  
27   -class DLL_EXPORT Pl_Buffer: public Pipeline
  27 +class Pl_Buffer: public Pipeline
28 28 {
29 29 public:
  30 + DLL_EXPORT
30 31 Pl_Buffer(char const* identifier, Pipeline* next = 0);
  32 + DLL_EXPORT
31 33 virtual ~Pl_Buffer();
  34 + DLL_EXPORT
32 35 virtual void write(unsigned char*, int);
  36 + DLL_EXPORT
33 37 virtual void finish();
34 38  
35 39 // Each call to getBuffer() resets this object -- see notes above.
36 40 // The caller is responsible for deleting the returned Buffer
37 41 // object.
  42 + DLL_EXPORT
38 43 Buffer* getBuffer();
39 44  
40 45 private:
... ...
include/qpdf/Pl_Count.hh
... ... @@ -13,17 +13,24 @@
13 13  
14 14 #include <qpdf/Pipeline.hh>
15 15  
16   -class DLL_EXPORT Pl_Count: public Pipeline
  16 +class Pl_Count: public Pipeline
17 17 {
18 18 public:
  19 + DLL_EXPORT
19 20 Pl_Count(char const* identifier, Pipeline* next);
  21 + DLL_EXPORT
20 22 virtual ~Pl_Count();
  23 + DLL_EXPORT
21 24 virtual void write(unsigned char*, int);
  25 + DLL_EXPORT
22 26 virtual void finish();
  27 + DLL_EXPORT
23 28 // Returns the number of bytes written
  29 + DLL_EXPORT
24 30 int getCount() const;
25 31 // Returns the last character written, or '\0' if no characters
26 32 // have been written (in which case getCount() returns 0)
  33 + DLL_EXPORT
27 34 unsigned char getLastChar() const;
28 35  
29 36 private:
... ...
include/qpdf/Pl_Discard.hh
... ... @@ -16,12 +16,16 @@
16 16  
17 17 #include <qpdf/Pipeline.hh>
18 18  
19   -class DLL_EXPORT Pl_Discard: public Pipeline
  19 +class Pl_Discard: public Pipeline
20 20 {
21 21 public:
  22 + DLL_EXPORT
22 23 Pl_Discard();
  24 + DLL_EXPORT
23 25 virtual ~Pl_Discard();
  26 + DLL_EXPORT
24 27 virtual void write(unsigned char*, int);
  28 + DLL_EXPORT
25 29 virtual void finish();
26 30 };
27 31  
... ...
include/qpdf/Pl_Flate.hh
... ... @@ -12,18 +12,22 @@
12 12  
13 13 #include <zlib.h>
14 14  
15   -class DLL_EXPORT Pl_Flate: public Pipeline
  15 +class Pl_Flate: public Pipeline
16 16 {
17 17 public:
18 18 static int const def_bufsize = 65536;
19 19  
20 20 enum action_e { a_inflate, a_deflate };
21 21  
  22 + DLL_EXPORT
22 23 Pl_Flate(char const* identifier, Pipeline* next,
23 24 action_e action, int out_bufsize = def_bufsize);
  25 + DLL_EXPORT
24 26 virtual ~Pl_Flate();
25 27  
  28 + DLL_EXPORT
26 29 virtual void write(unsigned char* data, int len);
  30 + DLL_EXPORT
27 31 virtual void finish();
28 32  
29 33 private:
... ...
include/qpdf/Pl_StdioFile.hh
... ... @@ -18,15 +18,19 @@
18 18 // This pipeline is reusable.
19 19 //
20 20  
21   -class DLL_EXPORT Pl_StdioFile: public Pipeline
  21 +class Pl_StdioFile: public Pipeline
22 22 {
23 23 public:
24 24 // f is externally maintained; this class just writes to and
25 25 // flushes it. It does not close it.
  26 + DLL_EXPORT
26 27 Pl_StdioFile(char const* identifier, FILE* f);
  28 + DLL_EXPORT
27 29 virtual ~Pl_StdioFile();
28 30  
  31 + DLL_EXPORT
29 32 virtual void write(unsigned char* buf, int len);
  33 + DLL_EXPORT
30 34 virtual void finish();
31 35  
32 36 private:
... ...
include/qpdf/QPDF.hh
... ... @@ -25,10 +25,12 @@ class BitStream;
25 25 class BitWriter;
26 26 class QPDFExc;
27 27  
28   -class DLL_EXPORT QPDF
  28 +class QPDF
29 29 {
30 30 public:
  31 + DLL_EXPORT
31 32 QPDF();
  33 + DLL_EXPORT
32 34 ~QPDF();
33 35  
34 36 // Associate a file with a QPDF object and do initial parsing of
... ... @@ -41,6 +43,7 @@ class DLL_EXPORT QPDF
41 43 // encrypted,either a null password or an empty password can be
42 44 // used. If the file is encrypted, either the user password or
43 45 // the owner password may be supplied.
  46 + DLL_EXPORT
44 47 void processFile(char const* filename, char const* password = 0);
45 48  
46 49 // Parameter settings
... ... @@ -49,18 +52,21 @@ class DLL_EXPORT QPDF
49 52 // (one that contains both cross-reference streams and
50 53 // cross-reference tables). This can be useful for testing to
51 54 // ensure that a hybrid file would work with an older reader.
  55 + DLL_EXPORT
52 56 void setIgnoreXRefStreams(bool);
53 57  
54 58 // By default, any warnings are issued to stderr as they are
55 59 // encountered. If this is called with a true value, reporting of
56 60 // warnings is suppressed. You may still retrieve warnings by
57 61 // calling getWarnings.
  62 + DLL_EXPORT
58 63 void setSuppressWarnings(bool);
59 64  
60 65 // By default, QPDF will try to recover if it finds certain types
61 66 // of errors in PDF files. If turned off, it will throw an
62 67 // exception on the first such problem it finds without attempting
63 68 // recovery.
  69 + DLL_EXPORT
64 70 void setAttemptRecovery(bool);
65 71  
66 72 // Other public methods
... ... @@ -70,19 +76,26 @@ class DLL_EXPORT QPDF
70 76 // throws an exception. Note that if setSuppressWarnings was not
71 77 // called or was called with a false value, any warnings retrieved
72 78 // here will have already been issued to stderr.
  79 + DLL_EXPORT
73 80 std::vector<QPDFExc> getWarnings();
74 81  
  82 + DLL_EXPORT
75 83 std::string getFilename() const;
  84 + DLL_EXPORT
76 85 std::string getPDFVersion() const;
  86 + DLL_EXPORT
77 87 QPDFObjectHandle getTrailer();
  88 + DLL_EXPORT
78 89 QPDFObjectHandle getRoot();
79 90  
80 91 // Install this object handle as an indirect object and return an
81 92 // indirect reference to it.
  93 + DLL_EXPORT
82 94 QPDFObjectHandle makeIndirectObject(QPDFObjectHandle);
83 95  
84 96 // Retrieve an object by object ID and generation. Returns an
85 97 // indirect reference to it.
  98 + DLL_EXPORT
86 99 QPDFObjectHandle getObjectByID(int objid, int generation);
87 100  
88 101 // Encryption support
... ... @@ -115,31 +128,46 @@ class DLL_EXPORT QPDF
115 128 bool encrypt_metadata;
116 129 };
117 130  
  131 + DLL_EXPORT
118 132 bool isEncrypted() const;
119 133  
  134 + DLL_EXPORT
120 135 bool isEncrypted(int& R, int& P);
121 136  
122 137 // Encryption permissions -- not enforced by QPDF
  138 + DLL_EXPORT
123 139 bool allowAccessibility();
  140 + DLL_EXPORT
124 141 bool allowExtractAll();
  142 + DLL_EXPORT
125 143 bool allowPrintLowRes();
  144 + DLL_EXPORT
126 145 bool allowPrintHighRes();
  146 + DLL_EXPORT
127 147 bool allowModifyAssembly();
  148 + DLL_EXPORT
128 149 bool allowModifyForm();
  150 + DLL_EXPORT
129 151 bool allowModifyAnnotation();
  152 + DLL_EXPORT
130 153 bool allowModifyOther();
  154 + DLL_EXPORT
131 155 bool allowModifyAll();
132 156  
133 157 // Helper function to trim padding from user password. Calling
134 158 // trim_user_password on the result of getPaddedUserPassword gives
135 159 // getTrimmedUserPassword's result.
  160 + DLL_EXPORT
136 161 static void trim_user_password(std::string& user_password);
  162 + DLL_EXPORT
137 163 static std::string compute_data_key(
138 164 std::string const& encryption_key, int objid, int generation,
139 165 bool use_aes);
  166 + DLL_EXPORT
140 167 static std::string compute_encryption_key(
141 168 std::string const& password, EncryptionData const& data);
142 169  
  170 + DLL_EXPORT
143 171 static void compute_encryption_O_U(
144 172 char const* user_password, char const* owner_password,
145 173 int V, int R, int key_len, int P, bool encrypt_metadata,
... ... @@ -148,19 +176,23 @@ class DLL_EXPORT QPDF
148 176 // Return the full user password as stored in the PDF file. If
149 177 // you are attempting to recover the user password in a
150 178 // user-presentable form, call getTrimmedUserPassword() instead.
  179 + DLL_EXPORT
151 180 std::string const& getPaddedUserPassword() const;
152 181 // Return human-readable form of user password.
  182 + DLL_EXPORT
153 183 std::string getTrimmedUserPassword() const;
154 184  
155 185 // Linearization support
156 186  
157 187 // Returns true iff the file starts with a linearization parameter
158 188 // dictionary. Does no additional validation.
  189 + DLL_EXPORT
159 190 bool isLinearized();
160 191  
161 192 // Performs various sanity checks on a linearized file. Return
162 193 // true if no errors or warnings. Otherwise, return false and
163 194 // output errors and warnings to stdout.
  195 + DLL_EXPORT
164 196 bool checkLinearization();
165 197  
166 198 // Calls checkLinearization() and, if possible, prints normalized
... ... @@ -168,9 +200,11 @@ class DLL_EXPORT QPDF
168 200 // includes adding min values to delta values and adjusting
169 201 // offsets based on the location and size of the primary hint
170 202 // stream.
  203 + DLL_EXPORT
171 204 void showLinearizationData();
172 205  
173 206 // Shows the contents of the cross-reference table
  207 + DLL_EXPORT
174 208 void showXRefTable();
175 209  
176 210 // Optimization support -- see doc/optimization. Implemented in
... ... @@ -184,26 +218,31 @@ class DLL_EXPORT QPDF
184 218 // This is available so that the test suite can make sure that a
185 219 // linearized file is already optimized. When called in this way,
186 220 // optimize() still populates the object <-> user maps
  221 + DLL_EXPORT
187 222 void optimize(std::map<int, int> const& object_stream_data,
188 223 bool allow_changes = true);
189 224  
190 225 // Replace all references to indirect objects that are "scalars"
191 226 // (i.e., things that don't have children: not arrays, streams, or
192 227 // dictionaries) with direct objects.
  228 + DLL_EXPORT
193 229 void flattenScalarReferences();
194 230  
195 231 // Decode all streams, discarding the output. Used to check
196 232 // correctness of stream encoding.
  233 + DLL_EXPORT
197 234 void decodeStreams();
198 235  
199 236 // For QPDFWriter:
200 237  
201 238 // Remove /ID, /Encrypt, and /Prev keys from the trailer
202 239 // dictionary since these are regenerated during write.
  240 + DLL_EXPORT
203 241 void trimTrailerForWrite();
204 242  
205 243 // Get lists of all objects in order according to the part of a
206 244 // linearized file that they belong to.
  245 + DLL_EXPORT
207 246 void getLinearizedParts(
208 247 std::map<int, int> const& object_stream_data,
209 248 std::vector<QPDFObjectHandle>& part4,
... ... @@ -212,6 +251,7 @@ class DLL_EXPORT QPDF
212 251 std::vector<QPDFObjectHandle>& part8,
213 252 std::vector<QPDFObjectHandle>& part9);
214 253  
  254 + DLL_EXPORT
215 255 void generateHintStream(std::map<int, QPDFXRefEntry> const& xref,
216 256 std::map<int, size_t> const& lengths,
217 257 std::map<int, int> const& obj_renumber,
... ... @@ -219,15 +259,18 @@ class DLL_EXPORT QPDF
219 259 int& S, int& O);
220 260  
221 261 // Map object to object stream that contains it
  262 + DLL_EXPORT
222 263 void getObjectStreamData(std::map<int, int>&);
223 264 // Get a list of objects that would be permitted in an object
224 265 // stream
  266 + DLL_EXPORT
225 267 std::vector<int> getCompressibleObjects();
226 268  
227 269 // Convenience routines for common functions. See also
228 270 // QPDFObjectHandle.hh for additional convenience routines.
229 271  
230 272 // Traverse page tree return all /Page objects.
  273 + DLL_EXPORT
231 274 std::vector<QPDFObjectHandle> const& getAllPages();
232 275  
233 276 // Resolver class is restricted to QPDFObjectHandle so that only
... ...
include/qpdf/QPDFExc.hh
... ... @@ -12,14 +12,16 @@
12 12 #include <qpdf/Constants.h>
13 13 #include <stdexcept>
14 14  
15   -class DLL_EXPORT QPDFExc: public std::runtime_error
  15 +class QPDFExc: public std::runtime_error
16 16 {
17 17 public:
  18 + DLL_EXPORT
18 19 QPDFExc(qpdf_error_code_e error_code,
19 20 std::string const& filename,
20 21 std::string const& object,
21 22 off_t offset,
22 23 std::string const& message);
  24 + DLL_EXPORT
23 25 virtual ~QPDFExc() throw ();
24 26  
25 27 // To get a complete error string, call what(), provided by
... ... @@ -32,10 +34,15 @@ class DLL_EXPORT QPDFExc: public std::runtime_error
32 34 // the underlying issue, but it is more programmer-friendly than
33 35 // trying to parse a string that is subject to change.
34 36  
  37 + DLL_EXPORT
35 38 qpdf_error_code_e getErrorCode() const;
  39 + DLL_EXPORT
36 40 std::string const& getFilename() const;
  41 + DLL_EXPORT
37 42 std::string const& getObject() const;
  43 + DLL_EXPORT
38 44 off_t getFilePosition() const;
  45 + DLL_EXPORT
39 46 std::string const& getMessageDetail() const;
40 47  
41 48 private:
... ...
include/qpdf/QPDFObject.hh
... ... @@ -12,7 +12,7 @@
12 12  
13 13 #include <string>
14 14  
15   -class DLL_EXPORT QPDFObject
  15 +class QPDFObject
16 16 {
17 17 public:
18 18 virtual ~QPDFObject() {}
... ...
include/qpdf/QPDFObjectHandle.hh
... ... @@ -23,40 +23,61 @@
23 23 class Pipeline;
24 24 class QPDF;
25 25  
26   -class DLL_EXPORT QPDFObjectHandle
  26 +class QPDFObjectHandle
27 27 {
28 28 public:
  29 + DLL_EXPORT
29 30 QPDFObjectHandle();
  31 + DLL_EXPORT
30 32 bool isInitialized() const;
31 33  
32 34 // Exactly one of these will return true for any object.
  35 + DLL_EXPORT
33 36 bool isBool();
  37 + DLL_EXPORT
34 38 bool isNull();
  39 + DLL_EXPORT
35 40 bool isInteger();
  41 + DLL_EXPORT
36 42 bool isReal();
  43 + DLL_EXPORT
37 44 bool isName();
  45 + DLL_EXPORT
38 46 bool isString();
  47 + DLL_EXPORT
39 48 bool isArray();
  49 + DLL_EXPORT
40 50 bool isDictionary();
  51 + DLL_EXPORT
41 52 bool isStream();
42 53  
43 54 // This returns true in addition to the query for the specific
44 55 // type for indirect objects.
  56 + DLL_EXPORT
45 57 bool isIndirect();
46 58  
47 59 // True for everything except array, dictionary, and stream
  60 + DLL_EXPORT
48 61 bool isScalar();
49 62  
50 63 // Public factory methods
51 64  
  65 + DLL_EXPORT
52 66 static QPDFObjectHandle newNull();
  67 + DLL_EXPORT
53 68 static QPDFObjectHandle newBool(bool value);
  69 + DLL_EXPORT
54 70 static QPDFObjectHandle newInteger(int value);
  71 + DLL_EXPORT
55 72 static QPDFObjectHandle newReal(std::string const& value);
  73 + DLL_EXPORT
56 74 static QPDFObjectHandle newName(std::string const& name);
  75 + DLL_EXPORT
57 76 static QPDFObjectHandle newString(std::string const& str);
  77 + DLL_EXPORT
58 78 static QPDFObjectHandle newArray(
59 79 std::vector<QPDFObjectHandle> const& items);
  80 + DLL_EXPORT
60 81 static QPDFObjectHandle newDictionary(
61 82 std::map<std::string, QPDFObjectHandle> const& items);
62 83  
... ... @@ -65,58 +86,78 @@ class DLL_EXPORT QPDFObjectHandle
65 86 // type, an exception is thrown.
66 87  
67 88 // Methods for bool objects
  89 + DLL_EXPORT
68 90 bool getBoolValue();
69 91  
70 92 // Methods for integer objects
  93 + DLL_EXPORT
71 94 int getIntValue();
72 95  
73 96 // Methods for real objects
  97 + DLL_EXPORT
74 98 std::string getRealValue();
75 99  
76 100 // Methods that work for both integer and real objects
  101 + DLL_EXPORT
77 102 bool isNumber();
  103 + DLL_EXPORT
78 104 double getNumericValue();
79 105  
80 106 // Methods for name objects; see also name and array objects
  107 + DLL_EXPORT
81 108 std::string getName();
82 109  
83 110 // Methods for string objects
  111 + DLL_EXPORT
84 112 std::string getStringValue();
  113 + DLL_EXPORT
85 114 std::string getUTF8Value();
86 115  
87 116 // Methods for array objects; see also name and array objects
  117 + DLL_EXPORT
88 118 int getArrayNItems();
  119 + DLL_EXPORT
89 120 QPDFObjectHandle getArrayItem(int n);
90 121  
91 122 // Methods for dictionary objects
  123 + DLL_EXPORT
92 124 bool hasKey(std::string const&);
  125 + DLL_EXPORT
93 126 QPDFObjectHandle getKey(std::string const&);
  127 + DLL_EXPORT
94 128 std::set<std::string> getKeys();
95 129  
96 130 // Methods for name and array objects
  131 + DLL_EXPORT
97 132 bool isOrHasName(std::string const&);
98 133  
99 134 // Mutator methods. Use with caution.
100 135  
101 136 // Recursively copy this object, making it direct. Throws an
102 137 // exception if a loop is detected or any sub-object is a stream.
  138 + DLL_EXPORT
103 139 void makeDirect();
104 140  
105 141 // Mutator methods for array objects
  142 + DLL_EXPORT
106 143 void setArrayItem(int, QPDFObjectHandle const&);
107 144  
108 145 // Mutator methods for dictionary objects
109 146  
110 147 // Replace value of key, adding it if it does not exist
  148 + DLL_EXPORT
111 149 void replaceKey(std::string const& key, QPDFObjectHandle const&);
112 150 // Remove key, doing nothing if key does not exist
  151 + DLL_EXPORT
113 152 void removeKey(std::string const& key);
114 153  
115 154 // Methods for stream objects
  155 + DLL_EXPORT
116 156 QPDFObjectHandle getDict();
117 157  
118 158 // Returns filtered (uncompressed) stream data. Throws an
119 159 // exception if the stream is filtered and we can't decode it.
  160 + DLL_EXPORT
120 161 PointerHolder<Buffer> getStreamData();
121 162  
122 163 // Write stream data through the given pipeline. A null pipeline
... ... @@ -136,14 +177,19 @@ class DLL_EXPORT QPDFObjectHandle
136 177 // value of this function to determine whether or not the /Filter
137 178 // and /DecodeParms keys in the stream dictionary should be
138 179 // replaced if writing a new stream object.
  180 + DLL_EXPORT
139 181 bool pipeStreamData(Pipeline*, bool filter,
140 182 bool normalize, bool compress);
141 183  
142 184 // return 0 for direct objects
  185 + DLL_EXPORT
143 186 int getObjectID() const;
  187 + DLL_EXPORT
144 188 int getGeneration() const;
145 189  
  190 + DLL_EXPORT
146 191 std::string unparse();
  192 + DLL_EXPORT
147 193 std::string unparseResolved();
148 194  
149 195 // Convenience routines for commonly performed functions
... ... @@ -153,6 +199,7 @@ class DLL_EXPORT QPDFObjectHandle
153 199 // function does not presently support inherited resources. See
154 200 // comment in the source for details. Return value is a map from
155 201 // XObject name to the image object, which is always a stream.
  202 + DLL_EXPORT
156 203 std::map<std::string, QPDFObjectHandle> getPageImages();
157 204  
158 205 // Throws an exception if this is not a Page object. Returns a
... ... @@ -160,6 +207,7 @@ class DLL_EXPORT QPDFObjectHandle
160 207 // the given page. This routine allows the caller to not care
161 208 // whether there are one or more than one content streams for a
162 209 // page.
  210 + DLL_EXPORT
163 211 std::vector<QPDFObjectHandle> getPageContents();
164 212  
165 213 // Initializers for objects. This Factory class gives the QPDF
... ...
include/qpdf/QPDFTokenizer.hh
... ... @@ -13,7 +13,7 @@
13 13 #include <string>
14 14 #include <stdio.h>
15 15  
16   -class DLL_EXPORT QPDFTokenizer
  16 +class QPDFTokenizer
17 17 {
18 18 public:
19 19 enum token_type_e
... ... @@ -84,6 +84,7 @@ class DLL_EXPORT QPDFTokenizer
84 84 std::string error_message;
85 85 };
86 86  
  87 + DLL_EXPORT
87 88 QPDFTokenizer();
88 89  
89 90 // PDF files with version < 1.2 allowed the pound character
... ... @@ -91,6 +92,7 @@ class DLL_EXPORT QPDFTokenizer
91 92 // character was allowed only when followed by two hexadecimal
92 93 // digits. This method should be called when parsing a PDF file
93 94 // whose version is older than 1.2.
  95 + DLL_EXPORT
94 96 void allowPoundAnywhereInName();
95 97  
96 98 // Mode of operation:
... ... @@ -101,19 +103,23 @@ class DLL_EXPORT QPDFTokenizer
101 103  
102 104 // It these are called when a token is available, an exception
103 105 // will be thrown.
  106 + DLL_EXPORT
104 107 void presentCharacter(char ch);
  108 + DLL_EXPORT
105 109 void presentEOF();
106 110  
107 111 // If a token is available, return true and initialize token with
108 112 // the token, unread_char with whether or not we have to unread
109 113 // the last character, and if unread_char, ch with the character
110 114 // to unread.
  115 + DLL_EXPORT
111 116 bool getToken(Token& token, bool& unread_char, char& ch);
112 117  
113 118 // This function returns true of the current character is between
114 119 // tokens (i.e., white space that is not part of a string) or is
115 120 // part of a comment. A tokenizing filter can call this to
116 121 // determine whether to output the character.
  122 + DLL_EXPORT
117 123 bool betweenTokens();
118 124  
119 125 private:
... ...
include/qpdf/QPDFWriter.hh
... ... @@ -32,7 +32,7 @@ class QPDF;
32 32 class QPDFObjectHandle;
33 33 class Pl_Count;
34 34  
35   -class DLL_EXPORT QPDFWriter
  35 +class QPDFWriter
36 36 {
37 37 public:
38 38 // Passing null as filename means write to stdout. QPDFWriter
... ... @@ -42,7 +42,9 @@ class DLL_EXPORT QPDFWriter
42 42 // useful for tracking down problems. If your application doesn't
43 43 // want the partially written file to be left behind, you should
44 44 // delete it the eventual call to write fails.
  45 + DLL_EXPORT
45 46 QPDFWriter(QPDF& pdf, char const* filename);
  47 + DLL_EXPORT
46 48 ~QPDFWriter();
47 49  
48 50 // Set the value of object stream mode. In disable mode, we never
... ... @@ -52,6 +54,7 @@ class DLL_EXPORT QPDFWriter
52 54 // generate a conventional cross-reference table if there are no
53 55 // object streams and a cross-reference stream if there are object
54 56 // streams. The default is o_preserve.
  57 + DLL_EXPORT
55 58 void setObjectStreamMode(qpdf_object_stream_e);
56 59  
57 60 // Set value of stream data mode. In uncompress mode, we attempt
... ... @@ -59,6 +62,7 @@ class DLL_EXPORT QPDFWriter
59 62 // preserve any filtering applied to streams. In compress mode,
60 63 // if we can apply all filters and the stream is not already
61 64 // optimally compressed, recompress the stream.
  65 + DLL_EXPORT
62 66 void setStreamDataMode(qpdf_stream_data_e);
63 67  
64 68 // Set value of content stream normalization. The default is
... ... @@ -68,6 +72,7 @@ class DLL_EXPORT QPDFWriter
68 72 // damage the content stream. This flag should be used only for
69 73 // debugging and experimenting with PDF content streams. Never
70 74 // use it for production files.
  75 + DLL_EXPORT
71 76 void setContentNormalization(bool);
72 77  
73 78 // Set QDF mode. QDF mode causes special "pretty printing" of
... ... @@ -75,6 +80,7 @@ class DLL_EXPORT QPDFWriter
75 80 // Resulting PDF files can be edited in a text editor and then run
76 81 // through fix-qdf to update cross reference tables and stream
77 82 // lengths.
  83 + DLL_EXPORT
78 84 void setQDFMode(bool);
79 85  
80 86 // Set the minimum PDF version. If the PDF version of the input
... ... @@ -86,6 +92,7 @@ class DLL_EXPORT QPDFWriter
86 92 // QPDFWriter automatically sets the minimum version to 1.4 when
87 93 // R3 encryption parameters are used, and to 1.5 when object
88 94 // streams are used.
  95 + DLL_EXPORT
89 96 void setMinimumPDFVersion(std::string const&);
90 97  
91 98 // Force the PDF version of the output file to be a given version.
... ... @@ -103,27 +110,32 @@ class DLL_EXPORT QPDFWriter
103 110 // that type of encryption will explicitly disable decryption.
104 111 // Additionally, forcing to a version below 1.5 will disable
105 112 // object streams.
  113 + DLL_EXPORT
106 114 void forcePDFVersion(std::string const&);
107 115  
108 116 // Cause a static /ID value to be generated. Use only in test
109 117 // suites.
  118 + DLL_EXPORT
110 119 void setStaticID(bool);
111 120  
112 121 // Use a fixed initialization vector for AES-CBC encryption. This
113 122 // is not secure. It should be used only in test suites for
114 123 // creating predictable encrypted output.
  124 + DLL_EXPORT
115 125 void setStaticAesIV(bool);
116 126  
117 127 // Suppress inclusion of comments indicating original object IDs
118 128 // when writing QDF files. This can also be useful for testing,
119 129 // particularly when using comparison of two qdf files to
120 130 // determine whether two PDF files have identical content.
  131 + DLL_EXPORT
121 132 void setSuppressOriginalObjectIDs(bool);
122 133  
123 134 // Preserve encryption. The default is true unless prefilering,
124 135 // content normalization, or qdf mode has been selected in which
125 136 // case encryption is never preserved. Encryption is also not
126 137 // preserved if we explicitly set encryption parameters.
  138 + DLL_EXPORT
127 139 void setPreserveEncryption(bool);
128 140  
129 141 // Set up for encrypted output. Disables stream prefiltering and
... ... @@ -132,14 +144,17 @@ class DLL_EXPORT QPDFWriter
132 144 // encryption parameters pushes the PDF version number to at least
133 145 // 1.4, and setting R4 parameters pushes the version to at least
134 146 // 1.5, or if AES is used, 1.6.
  147 + DLL_EXPORT
135 148 void setR2EncryptionParameters(
136 149 char const* user_password, char const* owner_password,
137 150 bool allow_print, bool allow_modify,
138 151 bool allow_extract, bool allow_annotate);
  152 + DLL_EXPORT
139 153 void setR3EncryptionParameters(
140 154 char const* user_password, char const* owner_password,
141 155 bool allow_accessibility, bool allow_extract,
142 156 qpdf_r3_print_e print, qpdf_r3_modify_e modify);
  157 + DLL_EXPORT
143 158 void setR4EncryptionParameters(
144 159 char const* user_password, char const* owner_password,
145 160 bool allow_accessibility, bool allow_extract,
... ... @@ -148,11 +163,16 @@ class DLL_EXPORT QPDFWriter
148 163  
149 164 // Create linearized output. Disables qdf mode, content
150 165 // normalization, and stream prefiltering.
  166 + DLL_EXPORT
151 167 void setLinearization(bool);
152 168  
  169 + DLL_EXPORT
153 170 void write();
154 171  
155 172 private:
  173 + QPDFWriter(QPDFWriter const&);
  174 + QPDFWriter& operator=(QPDFWriter const&);
  175 +
156 176 // flags used by unparseObject
157 177 static int const f_stream = 1 << 0;
158 178 static int const f_filtered = 1 << 1;
... ...
include/qpdf/QPDFXRefEntry.hh
... ... @@ -10,7 +10,7 @@
10 10  
11 11 #include <qpdf/DLL.h>
12 12  
13   -class DLL_EXPORT QPDFXRefEntry
  13 +class QPDFXRefEntry
14 14 {
15 15 public:
16 16 // Type constants are from the PDF spec section
... ... @@ -19,12 +19,18 @@ class DLL_EXPORT QPDFXRefEntry
19 19 // 1 = "uncompressed"; field 1 = offset
20 20 // 2 = "compressed"; field 1 = object stream number, field 2 = index
21 21  
  22 + DLL_EXPORT
22 23 QPDFXRefEntry();
  24 + DLL_EXPORT
23 25 QPDFXRefEntry(int type, int field1, int field2);
24 26  
  27 + DLL_EXPORT
25 28 int getType() const;
  29 + DLL_EXPORT
26 30 int getOffset() const; // only for type 1
  31 + DLL_EXPORT
27 32 int getObjStreamNumber() const; // only for type 2
  33 + DLL_EXPORT
28 34 int getObjStreamIndex() const; // only for type 2
29 35  
30 36 private:
... ...
libqpdf/qpdf/BitStream.hh
... ... @@ -5,12 +5,16 @@
5 5  
6 6 #include <qpdf/DLL.h>
7 7  
8   -class DLL_EXPORT BitStream
  8 +class BitStream
9 9 {
10 10 public:
  11 + DLL_EXPORT
11 12 BitStream(unsigned char const* p, int nbytes);
  13 + DLL_EXPORT
12 14 void reset();
  15 + DLL_EXPORT
13 16 unsigned long getBits(int nbits);
  17 + DLL_EXPORT
14 18 void skipToNextByte();
15 19  
16 20 private:
... ...
libqpdf/qpdf/BitWriter.hh
... ... @@ -7,14 +7,17 @@
7 7  
8 8 class Pipeline;
9 9  
10   -class DLL_EXPORT BitWriter
  10 +class BitWriter
11 11 {
12 12 public:
13 13 // Write bits to the pipeline. It is the caller's responsibility
14 14 // to eventually call finish on the pipeline.
  15 + DLL_EXPORT
15 16 BitWriter(Pipeline* pl);
  17 + DLL_EXPORT
16 18 void writeBits(unsigned long val, int bits);
17 19 // Force any partial byte to be written to the pipeline.
  20 + DLL_EXPORT
18 21 void flush();
19 22  
20 23 private:
... ...
libqpdf/qpdf/MD5.hh
... ... @@ -8,41 +8,55 @@
8 8 # include <inttypes.h>
9 9 #endif
10 10  
11   -class DLL_EXPORT MD5
  11 +class MD5
12 12 {
13 13 public:
14 14 typedef unsigned char Digest[16];
15 15  
  16 + DLL_EXPORT
16 17 MD5();
  18 + DLL_EXPORT
17 19 void reset();
18 20  
19 21 // encodes string and finalizes
  22 + DLL_EXPORT
20 23 void encodeString(char const* input_string);
21 24  
22 25 // encodes file and finalizes
  26 + DLL_EXPORT
23 27 void encodeFile(char const* filename, int up_to_size = -1);
24 28  
25 29 // appends string to current md5 object
  30 + DLL_EXPORT
26 31 void appendString(char const* input_string);
27 32  
28 33 // appends arbitrary data to current md5 object
  34 + DLL_EXPORT
29 35 void encodeDataIncrementally(char const* input_data, int len);
30 36  
31 37 // computes a raw digest
  38 + DLL_EXPORT
32 39 void digest(Digest);
33 40  
34 41 // prints the digest to stdout terminated with \r\n (primarily for
35 42 // testing)
  43 + DLL_EXPORT
36 44 void print();
37 45  
38 46 // returns the digest as a hexadecimal string
  47 + DLL_EXPORT
39 48 std::string unparse();
40 49  
41 50 // Convenience functions
  51 + DLL_EXPORT
42 52 static std::string getDataChecksum(char const* buf, int len);
43   - static std::string getFileChecksum(char const* filename, int up_to_size = -1);
  53 + DLL_EXPORT
  54 + static std::string getFileChecksum(char const* filename,
  55 + int up_to_size = -1);
  56 + DLL_EXPORT
44 57 static bool checkDataChecksum(char const* const checksum,
45 58 char const* buf, int len);
  59 + DLL_EXPORT
46 60 static bool checkFileChecksum(char const* const checksum,
47 61 char const* filename, int up_to_size = -1);
48 62  
... ...
libqpdf/qpdf/PCRE.hh
... ... @@ -17,7 +17,7 @@
17 17 // Note: this class does not encapsulate all features of the PCRE
18 18 // package -- only those that I actually need right now are here.
19 19  
20   -class DLL_EXPORT PCRE
  20 +class PCRE
21 21 {
22 22 public:
23 23 // This is thrown when an attempt is made to access a non-existent
... ... @@ -25,6 +25,7 @@ class DLL_EXPORT PCRE
25 25 class NoBackref: public std::logic_error
26 26 {
27 27 public:
  28 + DLL_EXPORT
28 29 NoBackref();
29 30 virtual ~NoBackref() throw() {}
30 31 };
... ... @@ -33,10 +34,15 @@ class DLL_EXPORT PCRE
33 34 {
34 35 friend class PCRE;
35 36 public:
  37 + DLL_EXPORT
36 38 Match(int nbackrefs, char const* subject);
  39 + DLL_EXPORT
37 40 Match(Match const&);
  41 + DLL_EXPORT
38 42 Match& operator=(Match const&);
  43 + DLL_EXPORT
39 44 ~Match();
  45 + DLL_EXPORT
40 46 operator bool();
41 47  
42 48 // All the back reference accessing routines may throw the
... ... @@ -48,9 +54,13 @@ class DLL_EXPORT PCRE
48 54 // and not matching at all.
49 55  
50 56 // see getMatch flags below
  57 + DLL_EXPORT
51 58 std::string getMatch(int n, int flags = 0);
  59 + DLL_EXPORT
52 60 void getOffsetLength(int n, int& offset, int& length);
  61 + DLL_EXPORT
53 62 int getOffset(int n);
  63 + DLL_EXPORT
54 64 int getLength(int n);
55 65  
56 66 // nMatches returns the number of available matches including
... ... @@ -60,6 +70,7 @@ class DLL_EXPORT PCRE
60 70 // will return the whole string, getMatch(1) will return the
61 71 // text that matched the backreference, and getMatch(2) will
62 72 // throw an exception because it is out of range.
  73 + DLL_EXPORT
63 74 int nMatches() const;
64 75  
65 76 // Flags for getMatch
... ... @@ -82,12 +93,16 @@ class DLL_EXPORT PCRE
82 93  
83 94 // The value passed in as options is passed to pcre_exec. See man
84 95 // pcreapi for details.
  96 + DLL_EXPORT
85 97 PCRE(char const* pattern, int options = 0);
  98 + DLL_EXPORT
86 99 ~PCRE();
87 100  
  101 + DLL_EXPORT
88 102 Match match(char const* subject, int options = 0, int startoffset = 0,
89 103 int size = -1);
90 104  
  105 + DLL_EXPORT
91 106 static void test(int n = 0);
92 107  
93 108 private:
... ...
libqpdf/qpdf/Pl_AES_PDF.hh
... ... @@ -7,21 +7,27 @@
7 7 // This pipeline implements AES-128 with CBC and block padding as
8 8 // specified in the PDF specification.
9 9  
10   -class DLL_EXPORT Pl_AES_PDF: public Pipeline
  10 +class Pl_AES_PDF: public Pipeline
11 11 {
12 12 public:
13 13 // key_data should be a pointer to key_size bytes of data
14 14 static unsigned int const key_size = 16;
  15 + DLL_EXPORT
15 16 Pl_AES_PDF(char const* identifier, Pipeline* next,
16 17 bool encrypt, unsigned char const key[key_size]);
  18 + DLL_EXPORT
17 19 virtual ~Pl_AES_PDF();
18 20  
  21 + DLL_EXPORT
19 22 virtual void write(unsigned char* data, int len);
  23 + DLL_EXPORT
20 24 virtual void finish();
21 25  
22 26 // For testing only; PDF always uses CBC
  27 + DLL_EXPORT
23 28 void disableCBC();
24 29 // For testing only: use a fixed initialization vector for CBC
  30 + DLL_EXPORT
25 31 static void useStaticIV();
26 32  
27 33 private:
... ...
libqpdf/qpdf/Pl_ASCII85Decoder.hh
... ... @@ -3,12 +3,16 @@
3 3  
4 4 #include <qpdf/Pipeline.hh>
5 5  
6   -class DLL_EXPORT Pl_ASCII85Decoder: public Pipeline
  6 +class Pl_ASCII85Decoder: public Pipeline
7 7 {
8 8 public:
  9 + DLL_EXPORT
9 10 Pl_ASCII85Decoder(char const* identifier, Pipeline* next);
  11 + DLL_EXPORT
10 12 virtual ~Pl_ASCII85Decoder();
  13 + DLL_EXPORT
11 14 virtual void write(unsigned char* buf, int len);
  15 + DLL_EXPORT
12 16 virtual void finish();
13 17  
14 18 private:
... ...
libqpdf/qpdf/Pl_ASCIIHexDecoder.hh
... ... @@ -3,12 +3,16 @@
3 3  
4 4 #include <qpdf/Pipeline.hh>
5 5  
6   -class DLL_EXPORT Pl_ASCIIHexDecoder: public Pipeline
  6 +class Pl_ASCIIHexDecoder: public Pipeline
7 7 {
8 8 public:
  9 + DLL_EXPORT
9 10 Pl_ASCIIHexDecoder(char const* identifier, Pipeline* next);
  11 + DLL_EXPORT
10 12 virtual ~Pl_ASCIIHexDecoder();
  13 + DLL_EXPORT
11 14 virtual void write(unsigned char* buf, int len);
  15 + DLL_EXPORT
12 16 virtual void finish();
13 17  
14 18 private:
... ...
libqpdf/qpdf/Pl_LZWDecoder.hh
... ... @@ -6,13 +6,17 @@
6 6 #include <qpdf/Buffer.hh>
7 7 #include <vector>
8 8  
9   -class DLL_EXPORT Pl_LZWDecoder: public Pipeline
  9 +class Pl_LZWDecoder: public Pipeline
10 10 {
11 11 public:
  12 + DLL_EXPORT
12 13 Pl_LZWDecoder(char const* identifier, Pipeline* next,
13 14 bool early_code_change);
  15 + DLL_EXPORT
14 16 virtual ~Pl_LZWDecoder();
  17 + DLL_EXPORT
15 18 virtual void write(unsigned char* buf, int len);
  19 + DLL_EXPORT
16 20 virtual void finish();
17 21  
18 22 private:
... ...
libqpdf/qpdf/Pl_MD5.hh
... ... @@ -12,13 +12,18 @@
12 12 #include <qpdf/Pipeline.hh>
13 13 #include <qpdf/MD5.hh>
14 14  
15   -class DLL_EXPORT Pl_MD5: public Pipeline
  15 +class Pl_MD5: public Pipeline
16 16 {
17 17 public:
  18 + DLL_EXPORT
18 19 Pl_MD5(char const* identifier, Pipeline* next);
  20 + DLL_EXPORT
19 21 virtual ~Pl_MD5();
  22 + DLL_EXPORT
20 23 virtual void write(unsigned char*, int);
  24 + DLL_EXPORT
21 25 virtual void finish();
  26 + DLL_EXPORT
22 27 std::string getHexDigest();
23 28  
24 29 private:
... ...
libqpdf/qpdf/Pl_PNGFilter.hh
... ... @@ -16,18 +16,22 @@
16 16  
17 17 #include <qpdf/Pipeline.hh>
18 18  
19   -class DLL_EXPORT Pl_PNGFilter: public Pipeline
  19 +class Pl_PNGFilter: public Pipeline
20 20 {
21 21 public:
22 22 // Encoding is not presently supported
23 23 enum action_e { a_encode, a_decode };
24 24  
  25 + DLL_EXPORT
25 26 Pl_PNGFilter(char const* identifier, Pipeline* next,
26 27 action_e action, unsigned int columns,
27 28 unsigned int bytes_per_pixel);
  29 + DLL_EXPORT
28 30 virtual ~Pl_PNGFilter();
29 31  
  32 + DLL_EXPORT
30 33 virtual void write(unsigned char* data, int len);
  34 + DLL_EXPORT
31 35 virtual void finish();
32 36  
33 37 private:
... ...
libqpdf/qpdf/Pl_RC4.hh
... ... @@ -5,18 +5,22 @@
5 5  
6 6 #include <qpdf/RC4.hh>
7 7  
8   -class DLL_EXPORT Pl_RC4: public Pipeline
  8 +class Pl_RC4: public Pipeline
9 9 {
10 10 public:
11 11 static int const def_bufsize = 65536;
12 12  
13 13 // key_len of -1 means treat key_data as a null-terminated string
  14 + DLL_EXPORT
14 15 Pl_RC4(char const* identifier, Pipeline* next,
15 16 unsigned char const* key_data, int key_len = -1,
16 17 int out_bufsize = def_bufsize);
  18 + DLL_EXPORT
17 19 virtual ~Pl_RC4();
18 20  
  21 + DLL_EXPORT
19 22 virtual void write(unsigned char* data, int len);
  23 + DLL_EXPORT
20 24 virtual void finish();
21 25  
22 26 private:
... ...