aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/exiv2_extractor.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/exiv2_extractor.cc')
-rw-r--r--src/plugins/exiv2_extractor.cc117
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)
94virtual Exiv2::DataBuf read (size_t rcount);
95#else
93virtual Exiv2::DataBuf read (long rcount); 96virtual 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)
107virtual size_t read (Exiv2::byte *buf,
108 size_t rcount);
109#else
102virtual long read (Exiv2::byte *buf, 110virtual long read (Exiv2::byte *buf,
103 long rcount); 111 long rcount);
112#endif
113
114#if EXIV2_TEST_VERSION (0,28,0)
115virtual 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)
134virtual size_t write (const Exiv2::byte *data,
135 size_t wcount);
136#else
120virtual long write (const Exiv2::byte *data, 137virtual 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)
148virtual size_t write (Exiv2::BasicIo &src);
149#else
129virtual long write (Exiv2::BasicIo &src); 150virtual 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 */
144virtual void transfer (Exiv2::BasicIo& src); 166virtual 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 */
153virtual int seek (long offset, 182virtual 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)
205virtual size_t tell (void) const;
206#else
175virtual long int tell (void) const; 207virtual 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)
250virtual const std::string& path () const noexcept;
251#else
216virtual std::string path () const; 252virtual 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)
271virtual Exiv2::BasicIo::UniquePtr temporary () const;
272#else
233virtual Exiv2::BasicIo::AutoPtr temporary () const; 273virtual 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 */
268Exiv2::DataBuf 309Exiv2::DataBuf
310#if EXIV2_TEST_VERSION (0,28,0)
311ExtractorIO::read (size_t rcount)
312#else
269ExtractorIO::read (long rcount) 313ExtractorIO::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)
333size_t
334ExtractorIO::read (Exiv2::byte *buf,
335 size_t rcount)
336#else
287long 337long
288ExtractorIO::read (Exiv2::byte *buf, 338ExtractorIO::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)
360void 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)
399size_t
400ExtractorIO::write (const Exiv2::byte *data,
401 size_t wcount)
402#else
339long 403long
340ExtractorIO::write (const Exiv2::byte *data, 404ExtractorIO::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)
419size_t
420#else
353long 421long
422#endif
354ExtractorIO::write (Exiv2::BasicIo &src) 423ExtractorIO::write (Exiv2::BasicIo &src)
355{ 424{
356 return -1; 425 return -1;
@@ -378,7 +447,9 @@ ExtractorIO::putb (Exiv2::byte data)
378void 447void
379ExtractorIO::transfer (Exiv2::BasicIo& src) 448ExtractorIO::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 */
396int 467int
397ExtractorIO::seek (long offset, 468ExtractorIO::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,
427Exiv2::byte * 498Exiv2::byte *
428ExtractorIO::mmap (bool isWritable) 499ExtractorIO::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)
529size_t
530#else
455long int 531long int
532#endif
456ExtractorIO::tell (void) const 533ExtractorIO::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)
597const std::string&
598ExtractorIO::path () const noexcept
599#else
519std::string 600std::string
520ExtractorIO::path () const 601ExtractorIO::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
536std::wstring 620std::wstring
537ExtractorIO::wpath () const 621ExtractorIO::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)
642Exiv2::BasicIo::UniquePtr
643#else
555Exiv2::BasicIo::AutoPtr 644Exiv2::BasicIo::AutoPtr
645#endif
556ExtractorIO::temporary () const 646ExtractorIO::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";