diff options
Diffstat (limited to 'src/plugins/exiv2_extractor.cc')
-rw-r--r-- | src/plugins/exiv2_extractor.cc | 117 |
1 files changed, 109 insertions, 8 deletions
diff --git a/src/plugins/exiv2_extractor.cc b/src/plugins/exiv2_extractor.cc index 78f9bda..c21e1cb 100644 --- a/src/plugins/exiv2_extractor.cc +++ b/src/plugins/exiv2_extractor.cc | |||
@@ -90,7 +90,11 @@ virtual int close (); | |||
90 | * @param rcount number of bytes to read | 90 | * @param rcount number of bytes to read |
91 | * @return buffer with data read, empty buffer (!) on failure (!) | 91 | * @return buffer with data read, empty buffer (!) on failure (!) |
92 | */ | 92 | */ |
93 | #if EXIV2_TEST_VERSION (0,28,0) | ||
94 | virtual Exiv2::DataBuf read (size_t rcount); | ||
95 | #else | ||
93 | virtual Exiv2::DataBuf read (long rcount); | 96 | virtual Exiv2::DataBuf read (long rcount); |
97 | #endif | ||
94 | 98 | ||
95 | /** | 99 | /** |
96 | * Read up to 'rcount' bytes into 'buf'. | 100 | * Read up to 'rcount' bytes into 'buf'. |
@@ -99,8 +103,17 @@ virtual Exiv2::DataBuf read (long rcount); | |||
99 | * @param rcount size of 'buf' | 103 | * @param rcount size of 'buf' |
100 | * @return number of bytes read successfully, 0 on failure (!) | 104 | * @return number of bytes read successfully, 0 on failure (!) |
101 | */ | 105 | */ |
106 | #if EXIV2_TEST_VERSION (0,28,0) | ||
107 | virtual size_t read (Exiv2::byte *buf, | ||
108 | size_t rcount); | ||
109 | #else | ||
102 | virtual long read (Exiv2::byte *buf, | 110 | virtual long read (Exiv2::byte *buf, |
103 | long rcount); | 111 | long rcount); |
112 | #endif | ||
113 | |||
114 | #if EXIV2_TEST_VERSION (0,28,0) | ||
115 | virtual void populateFakeData(); | ||
116 | #endif | ||
104 | 117 | ||
105 | /** | 118 | /** |
106 | * Read a single character. | 119 | * Read a single character. |
@@ -117,8 +130,13 @@ virtual int getb (); | |||
117 | * @param wcount how many bytes to write | 130 | * @param wcount how many bytes to write |
118 | * @return -1 (always fails) | 131 | * @return -1 (always fails) |
119 | */ | 132 | */ |
133 | #if EXIV2_TEST_VERSION(0,28,0) | ||
134 | virtual size_t write (const Exiv2::byte *data, | ||
135 | size_t wcount); | ||
136 | #else | ||
120 | virtual long write (const Exiv2::byte *data, | 137 | virtual long write (const Exiv2::byte *data, |
121 | long wcount); | 138 | long wcount); |
139 | #endif | ||
122 | 140 | ||
123 | /** | 141 | /** |
124 | * Write to stream. | 142 | * Write to stream. |
@@ -126,7 +144,11 @@ virtual long write (const Exiv2::byte *data, | |||
126 | * @param src stream to copy | 144 | * @param src stream to copy |
127 | * @return -1 (always fails) | 145 | * @return -1 (always fails) |
128 | */ | 146 | */ |
147 | #if EXIV2_TEST_VERSION(0,28,0) | ||
148 | virtual size_t write (Exiv2::BasicIo &src); | ||
149 | #else | ||
129 | virtual long write (Exiv2::BasicIo &src); | 150 | virtual long write (Exiv2::BasicIo &src); |
151 | #endif | ||
130 | 152 | ||
131 | /** | 153 | /** |
132 | * Write a single byte. | 154 | * Write a single byte. |
@@ -143,6 +165,13 @@ virtual int putb (Exiv2::byte data); | |||
143 | */ | 165 | */ |
144 | virtual void transfer (Exiv2::BasicIo& src); | 166 | virtual void transfer (Exiv2::BasicIo& src); |
145 | 167 | ||
168 | |||
169 | #if EXIV2_TEST_VERSION (0,28,0) | ||
170 | #define SEEK_OFFSET_TYPE int64_t | ||
171 | #else | ||
172 | #define SEEK_OFFSET_TYPE long | ||
173 | #endif | ||
174 | |||
146 | /** | 175 | /** |
147 | * Seek to the given offset. | 176 | * Seek to the given offset. |
148 | * | 177 | * |
@@ -150,7 +179,7 @@ virtual void transfer (Exiv2::BasicIo& src); | |||
150 | * @parma pos offset is relative to where? | 179 | * @parma pos offset is relative to where? |
151 | * @return -1 on failure, 0 on success | 180 | * @return -1 on failure, 0 on success |
152 | */ | 181 | */ |
153 | virtual int seek (long offset, | 182 | virtual int seek (SEEK_OFFSET_TYPE offset, |
154 | Exiv2::BasicIo::Position pos); | 183 | Exiv2::BasicIo::Position pos); |
155 | 184 | ||
156 | /** | 185 | /** |
@@ -172,7 +201,11 @@ virtual int munmap (); | |||
172 | * | 201 | * |
173 | * @return -1 on error | 202 | * @return -1 on error |
174 | */ | 203 | */ |
204 | #if EXIV2_TEST_VERSION(0,28,0) | ||
205 | virtual size_t tell (void) const; | ||
206 | #else | ||
175 | virtual long int tell (void) const; | 207 | virtual long int tell (void) const; |
208 | #endif | ||
176 | 209 | ||
177 | /** | 210 | /** |
178 | * Return overall size of the file. | 211 | * Return overall size of the file. |
@@ -213,7 +246,11 @@ virtual bool eof () const; | |||
213 | * | 246 | * |
214 | * @throws error | 247 | * @throws error |
215 | */ | 248 | */ |
249 | #if EXIV2_TEST_VERSION(0,28,0) | ||
250 | virtual const std::string& path () const noexcept; | ||
251 | #else | ||
216 | virtual std::string path () const; | 252 | virtual std::string path () const; |
253 | #endif | ||
217 | 254 | ||
218 | #ifdef EXV_UNICODE_PATH | 255 | #ifdef EXV_UNICODE_PATH |
219 | /** | 256 | /** |
@@ -230,7 +267,11 @@ virtual std::wstring wpath () const; | |||
230 | * | 267 | * |
231 | * @throws error | 268 | * @throws error |
232 | */ | 269 | */ |
270 | #if EXIV2_TEST_VERSION(0,28,0) | ||
271 | virtual Exiv2::BasicIo::UniquePtr temporary () const; | ||
272 | #else | ||
233 | virtual Exiv2::BasicIo::AutoPtr temporary () const; | 273 | virtual Exiv2::BasicIo::AutoPtr temporary () const; |
274 | #endif | ||
234 | 275 | ||
235 | }; | 276 | }; |
236 | 277 | ||
@@ -266,7 +307,11 @@ ExtractorIO::close () | |||
266 | * @return buffer with data read, empty buffer (!) on failure (!) | 307 | * @return buffer with data read, empty buffer (!) on failure (!) |
267 | */ | 308 | */ |
268 | Exiv2::DataBuf | 309 | Exiv2::DataBuf |
310 | #if EXIV2_TEST_VERSION (0,28,0) | ||
311 | ExtractorIO::read (size_t rcount) | ||
312 | #else | ||
269 | ExtractorIO::read (long rcount) | 313 | ExtractorIO::read (long rcount) |
314 | #endif | ||
270 | { | 315 | { |
271 | void *data; | 316 | void *data; |
272 | ssize_t ret; | 317 | ssize_t ret; |
@@ -284,9 +329,15 @@ ExtractorIO::read (long rcount) | |||
284 | * @param rcount size of 'buf' | 329 | * @param rcount size of 'buf' |
285 | * @return number of bytes read successfully, 0 on failure (!) | 330 | * @return number of bytes read successfully, 0 on failure (!) |
286 | */ | 331 | */ |
332 | #if EXIV2_TEST_VERSION (0,28,0) | ||
333 | size_t | ||
334 | ExtractorIO::read (Exiv2::byte *buf, | ||
335 | size_t rcount) | ||
336 | #else | ||
287 | long | 337 | long |
288 | ExtractorIO::read (Exiv2::byte *buf, | 338 | ExtractorIO::read (Exiv2::byte *buf, |
289 | long rcount) | 339 | long rcount) |
340 | #endif | ||
290 | { | 341 | { |
291 | void *data; | 342 | void *data; |
292 | ssize_t ret; | 343 | ssize_t ret; |
@@ -305,6 +356,12 @@ ExtractorIO::read (Exiv2::byte *buf, | |||
305 | return got; | 356 | return got; |
306 | } | 357 | } |
307 | 358 | ||
359 | #if EXIV2_TEST_VERSION (0,28,0) | ||
360 | void ExtractorIO::populateFakeData() | ||
361 | { | ||
362 | return; | ||
363 | } | ||
364 | #endif | ||
308 | 365 | ||
309 | /** | 366 | /** |
310 | * Read a single character. | 367 | * Read a single character. |
@@ -319,7 +376,9 @@ ExtractorIO::getb () | |||
319 | const unsigned char *r; | 376 | const unsigned char *r; |
320 | 377 | ||
321 | if (1 != ec->read (ec->cls, &data, 1)) | 378 | if (1 != ec->read (ec->cls, &data, 1)) |
322 | #if EXIV2_TEST_VERSION (0,27,0) | 379 | #if EXIV2_TEST_VERSION(0,28,0) |
380 | throw Exiv2::Error (Exiv2::ErrorCode::kerDecodeLangAltQualifierFailed); | ||
381 | #elif EXIV2_TEST_VERSION (0,27,0) | ||
323 | throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); | 382 | throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); |
324 | #else | 383 | #else |
325 | throw Exiv2::BasicError<char> (42 /* error code */); | 384 | throw Exiv2::BasicError<char> (42 /* error code */); |
@@ -336,9 +395,15 @@ ExtractorIO::getb () | |||
336 | * @param wcount how many bytes to write | 395 | * @param wcount how many bytes to write |
337 | * @return -1 (always fails) | 396 | * @return -1 (always fails) |
338 | */ | 397 | */ |
398 | #if EXIV2_TEST_VERSION(0,28,0) | ||
399 | size_t | ||
400 | ExtractorIO::write (const Exiv2::byte *data, | ||
401 | size_t wcount) | ||
402 | #else | ||
339 | long | 403 | long |
340 | ExtractorIO::write (const Exiv2::byte *data, | 404 | ExtractorIO::write (const Exiv2::byte *data, |
341 | long wcount) | 405 | long wcount) |
406 | #endif | ||
342 | { | 407 | { |
343 | return -1; | 408 | return -1; |
344 | } | 409 | } |
@@ -350,7 +415,11 @@ ExtractorIO::write (const Exiv2::byte *data, | |||
350 | * @param src stream to copy | 415 | * @param src stream to copy |
351 | * @return -1 (always fails) | 416 | * @return -1 (always fails) |
352 | */ | 417 | */ |
418 | #if EXIV2_TEST_VERSION(0,28,0) | ||
419 | size_t | ||
420 | #else | ||
353 | long | 421 | long |
422 | #endif | ||
354 | ExtractorIO::write (Exiv2::BasicIo &src) | 423 | ExtractorIO::write (Exiv2::BasicIo &src) |
355 | { | 424 | { |
356 | return -1; | 425 | return -1; |
@@ -378,7 +447,9 @@ ExtractorIO::putb (Exiv2::byte data) | |||
378 | void | 447 | void |
379 | ExtractorIO::transfer (Exiv2::BasicIo& src) | 448 | ExtractorIO::transfer (Exiv2::BasicIo& src) |
380 | { | 449 | { |
381 | #if EXIV2_TEST_VERSION (0,27,0) | 450 | #if EXIV2_TEST_VERSION(0,28,0) |
451 | throw Exiv2::Error (Exiv2::ErrorCode::kerDecodeLangAltQualifierFailed); | ||
452 | #elif EXIV2_TEST_VERSION (0,27,0) | ||
382 | throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); | 453 | throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); |
383 | #else | 454 | #else |
384 | throw Exiv2::BasicError<char> (42 /* error code */); | 455 | throw Exiv2::BasicError<char> (42 /* error code */); |
@@ -394,7 +465,7 @@ ExtractorIO::transfer (Exiv2::BasicIo& src) | |||
394 | * @return -1 on failure, 0 on success | 465 | * @return -1 on failure, 0 on success |
395 | */ | 466 | */ |
396 | int | 467 | int |
397 | ExtractorIO::seek (long offset, | 468 | ExtractorIO::seek (SEEK_OFFSET_TYPE offset, |
398 | Exiv2::BasicIo::Position pos) | 469 | Exiv2::BasicIo::Position pos) |
399 | { | 470 | { |
400 | int rel; | 471 | int rel; |
@@ -427,7 +498,9 @@ ExtractorIO::seek (long offset, | |||
427 | Exiv2::byte * | 498 | Exiv2::byte * |
428 | ExtractorIO::mmap (bool isWritable) | 499 | ExtractorIO::mmap (bool isWritable) |
429 | { | 500 | { |
430 | #if EXIV2_TEST_VERSION (0,27,0) | 501 | #if EXIV2_TEST_VERSION (0,28,0) |
502 | throw Exiv2::Error (Exiv2::ErrorCode::kerDecodeLangAltQualifierFailed); | ||
503 | #elif EXIV2_TEST_VERSION (0,27,0) | ||
431 | throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); | 504 | throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); |
432 | #else | 505 | #else |
433 | throw Exiv2::BasicError<char> (42 /* error code */); | 506 | throw Exiv2::BasicError<char> (42 /* error code */); |
@@ -452,7 +525,11 @@ ExtractorIO::munmap () | |||
452 | * | 525 | * |
453 | * @return -1 on error | 526 | * @return -1 on error |
454 | */ | 527 | */ |
528 | #if EXIV2_TEST_VERSION(0,28,0) | ||
529 | size_t | ||
530 | #else | ||
455 | long int | 531 | long int |
532 | #endif | ||
456 | ExtractorIO::tell (void) const | 533 | ExtractorIO::tell (void) const |
457 | { | 534 | { |
458 | return (long) ec->seek (ec->cls, 0, SEEK_CUR); | 535 | return (long) ec->seek (ec->cls, 0, SEEK_CUR); |
@@ -516,10 +593,17 @@ ExtractorIO::eof () const | |||
516 | * | 593 | * |
517 | * @throws error | 594 | * @throws error |
518 | */ | 595 | */ |
596 | #if EXIV2_TEST_VERSION (0,28,0) | ||
597 | const std::string& | ||
598 | ExtractorIO::path () const noexcept | ||
599 | #else | ||
519 | std::string | 600 | std::string |
520 | ExtractorIO::path () const | 601 | ExtractorIO::path () const |
602 | #endif | ||
521 | { | 603 | { |
522 | #if EXIV2_TEST_VERSION (0,27,0) | 604 | #if EXIV2_TEST_VERSION (0,28,0) |
605 | throw Exiv2::Error (Exiv2::ErrorCode::kerDecodeLangAltQualifierFailed); | ||
606 | #elif EXIV2_TEST_VERSION (0,27,0) | ||
523 | throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); | 607 | throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); |
524 | #else | 608 | #else |
525 | throw Exiv2::BasicError<char> (42 /* error code */); | 609 | throw Exiv2::BasicError<char> (42 /* error code */); |
@@ -536,7 +620,9 @@ ExtractorIO::path () const | |||
536 | std::wstring | 620 | std::wstring |
537 | ExtractorIO::wpath () const | 621 | ExtractorIO::wpath () const |
538 | { | 622 | { |
539 | #if EXIV2_TEST_VERSION (0,27,0) | 623 | #if EXIV2_TEST_VERSION (0,28,0) |
624 | throw Exiv2::Error (Exiv2::ErrorCode::kerDecodeLangAltQualifierFailed); | ||
625 | #elif EXIV2_TEST_VERSION (0,27,0) | ||
540 | throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); | 626 | throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); |
541 | #else | 627 | #else |
542 | throw Exiv2::BasicError<char> (42 /* error code */); | 628 | throw Exiv2::BasicError<char> (42 /* error code */); |
@@ -552,11 +638,17 @@ ExtractorIO::wpath () const | |||
552 | * | 638 | * |
553 | * @throws error | 639 | * @throws error |
554 | */ | 640 | */ |
641 | #if EXIV2_TEST_VERSION(0,28,0) | ||
642 | Exiv2::BasicIo::UniquePtr | ||
643 | #else | ||
555 | Exiv2::BasicIo::AutoPtr | 644 | Exiv2::BasicIo::AutoPtr |
645 | #endif | ||
556 | ExtractorIO::temporary () const | 646 | ExtractorIO::temporary () const |
557 | { | 647 | { |
558 | fprintf (stderr, "throwing temporary error\n"); | 648 | fprintf (stderr, "throwing temporary error\n"); |
559 | #if EXIV2_TEST_VERSION (0,27,0) | 649 | #if EXIV2_TEST_VERSION(0,28,0) |
650 | throw Exiv2::Error (Exiv2::ErrorCode::kerDecodeLangAltQualifierFailed); | ||
651 | #elif EXIV2_TEST_VERSION (0,27,0) | ||
560 | throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); | 652 | throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); |
561 | #else | 653 | #else |
562 | throw Exiv2::BasicError<char> (42 /* error code */); | 654 | throw Exiv2::BasicError<char> (42 /* error code */); |
@@ -737,8 +829,13 @@ EXTRACTOR_exiv2_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
737 | #if ! EXIV2_TEST_VERSION (0,24,0) | 829 | #if ! EXIV2_TEST_VERSION (0,24,0) |
738 | Exiv2::LogMsg::setLevel (Exiv2::LogMsg::mute); | 830 | Exiv2::LogMsg::setLevel (Exiv2::LogMsg::mute); |
739 | #endif | 831 | #endif |
832 | #if EXIV2_TEST_VERSION(0,28,0) | ||
833 | std::unique_ptr<Exiv2::BasicIo> eio (new ExtractorIO (ec)); | ||
834 | Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open (std::move(eio)); | ||
835 | #else | ||
740 | std::auto_ptr<Exiv2::BasicIo> eio (new ExtractorIO (ec)); | 836 | std::auto_ptr<Exiv2::BasicIo> eio (new ExtractorIO (ec)); |
741 | Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open (eio); | 837 | Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open (eio); |
838 | #endif | ||
742 | if (0 == image.get ()) | 839 | if (0 == image.get ()) |
743 | return; | 840 | return; |
744 | image->readMetadata (); | 841 | image->readMetadata (); |
@@ -822,7 +919,11 @@ EXTRACTOR_exiv2_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
822 | ADDXMP ("Xmp.lr.hierarchicalSubject", EXTRACTOR_METATYPE_SUBJECT); | 919 | ADDXMP ("Xmp.lr.hierarchicalSubject", EXTRACTOR_METATYPE_SUBJECT); |
823 | } | 920 | } |
824 | } | 921 | } |
922 | #if EXIV2_TEST_VERSION (0,28,0) | ||
923 | catch (const Exiv2::Error& e) | ||
924 | #else | ||
825 | catch (const Exiv2::AnyError& e) | 925 | catch (const Exiv2::AnyError& e) |
926 | #endif | ||
826 | { | 927 | { |
827 | #if DEBUG | 928 | #if DEBUG |
828 | std::cerr << "Caught Exiv2 exception '" << e << "'\n"; | 929 | std::cerr << "Caught Exiv2 exception '" << e << "'\n"; |