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.cc106
1 files changed, 100 insertions, 6 deletions
diff --git a/src/plugins/exiv2_extractor.cc b/src/plugins/exiv2_extractor.cc
index 78f9bda..d32ed6a 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.
@@ -172,7 +194,11 @@ virtual int munmap ();
172 * 194 *
173 * @return -1 on error 195 * @return -1 on error
174 */ 196 */
197#if EXIV2_TEST_VERSION(0,28,0)
198virtual size_t tell (void) const;
199#else
175virtual long int tell (void) const; 200virtual long int tell (void) const;
201#endif
176 202
177/** 203/**
178 * Return overall size of the file. 204 * Return overall size of the file.
@@ -213,7 +239,11 @@ virtual bool eof () const;
213 * 239 *
214 * @throws error 240 * @throws error
215 */ 241 */
242#if EXIV2_TEST_VERSION(0,28,0)
243virtual const std::string& path () const noexcept;
244#else
216virtual std::string path () const; 245virtual std::string path () const;
246#endif
217 247
218#ifdef EXV_UNICODE_PATH 248#ifdef EXV_UNICODE_PATH
219/** 249/**
@@ -230,7 +260,11 @@ virtual std::wstring wpath () const;
230 * 260 *
231 * @throws error 261 * @throws error
232 */ 262 */
263#if EXIV2_TEST_VERSION(0,28,0)
264virtual Exiv2::BasicIo::UniquePtr temporary () const;
265#else
233virtual Exiv2::BasicIo::AutoPtr temporary () const; 266virtual Exiv2::BasicIo::AutoPtr temporary () const;
267#endif
234 268
235}; 269};
236 270
@@ -266,7 +300,11 @@ ExtractorIO::close ()
266 * @return buffer with data read, empty buffer (!) on failure (!) 300 * @return buffer with data read, empty buffer (!) on failure (!)
267 */ 301 */
268Exiv2::DataBuf 302Exiv2::DataBuf
303#if EXIV2_TEST_VERSION (0,28,0)
304ExtractorIO::read (size_t rcount)
305#else
269ExtractorIO::read (long rcount) 306ExtractorIO::read (long rcount)
307#endif
270{ 308{
271 void *data; 309 void *data;
272 ssize_t ret; 310 ssize_t ret;
@@ -284,9 +322,15 @@ ExtractorIO::read (long rcount)
284 * @param rcount size of 'buf' 322 * @param rcount size of 'buf'
285 * @return number of bytes read successfully, 0 on failure (!) 323 * @return number of bytes read successfully, 0 on failure (!)
286 */ 324 */
325#if EXIV2_TEST_VERSION (0,28,0)
326size_t
327ExtractorIO::read (Exiv2::byte *buf,
328 size_t rcount)
329#else
287long 330long
288ExtractorIO::read (Exiv2::byte *buf, 331ExtractorIO::read (Exiv2::byte *buf,
289 long rcount) 332 long rcount)
333#endif
290{ 334{
291 void *data; 335 void *data;
292 ssize_t ret; 336 ssize_t ret;
@@ -305,6 +349,12 @@ ExtractorIO::read (Exiv2::byte *buf,
305 return got; 349 return got;
306} 350}
307 351
352#if EXIV2_TEST_VERSION (0,28,0)
353void ExtractorIO::populateFakeData()
354{
355 return;
356}
357#endif
308 358
309/** 359/**
310 * Read a single character. 360 * Read a single character.
@@ -319,7 +369,9 @@ ExtractorIO::getb ()
319 const unsigned char *r; 369 const unsigned char *r;
320 370
321 if (1 != ec->read (ec->cls, &data, 1)) 371 if (1 != ec->read (ec->cls, &data, 1))
322#if EXIV2_TEST_VERSION (0,27,0) 372#if EXIV2_TEST_VERSION(0,28,0)
373 throw Exiv2::Error (Exiv2::ErrorCode::kerDecodeLangAltQualifierFailed);
374#elif EXIV2_TEST_VERSION (0,27,0)
323 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); 375 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
324#else 376#else
325 throw Exiv2::BasicError<char> (42 /* error code */); 377 throw Exiv2::BasicError<char> (42 /* error code */);
@@ -336,9 +388,15 @@ ExtractorIO::getb ()
336 * @param wcount how many bytes to write 388 * @param wcount how many bytes to write
337 * @return -1 (always fails) 389 * @return -1 (always fails)
338 */ 390 */
391#if EXIV2_TEST_VERSION(0,28,0)
392size_t
393ExtractorIO::write (const Exiv2::byte *data,
394 size_t wcount)
395#else
339long 396long
340ExtractorIO::write (const Exiv2::byte *data, 397ExtractorIO::write (const Exiv2::byte *data,
341 long wcount) 398 long wcount)
399#endif
342{ 400{
343 return -1; 401 return -1;
344} 402}
@@ -350,7 +408,11 @@ ExtractorIO::write (const Exiv2::byte *data,
350 * @param src stream to copy 408 * @param src stream to copy
351 * @return -1 (always fails) 409 * @return -1 (always fails)
352 */ 410 */
411#if EXIV2_TEST_VERSION(0,28,0)
412size_t
413#else
353long 414long
415#endif
354ExtractorIO::write (Exiv2::BasicIo &src) 416ExtractorIO::write (Exiv2::BasicIo &src)
355{ 417{
356 return -1; 418 return -1;
@@ -378,7 +440,9 @@ ExtractorIO::putb (Exiv2::byte data)
378void 440void
379ExtractorIO::transfer (Exiv2::BasicIo& src) 441ExtractorIO::transfer (Exiv2::BasicIo& src)
380{ 442{
381#if EXIV2_TEST_VERSION (0,27,0) 443#if EXIV2_TEST_VERSION(0,28,0)
444 throw Exiv2::Error (Exiv2::ErrorCode::kerDecodeLangAltQualifierFailed);
445#elif EXIV2_TEST_VERSION (0,27,0)
382 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); 446 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
383#else 447#else
384 throw Exiv2::BasicError<char> (42 /* error code */); 448 throw Exiv2::BasicError<char> (42 /* error code */);
@@ -427,7 +491,9 @@ ExtractorIO::seek (long offset,
427Exiv2::byte * 491Exiv2::byte *
428ExtractorIO::mmap (bool isWritable) 492ExtractorIO::mmap (bool isWritable)
429{ 493{
430#if EXIV2_TEST_VERSION (0,27,0) 494#if EXIV2_TEST_VERSION (0,28,0)
495 throw Exiv2::Error (Exiv2::ErrorCode::kerDecodeLangAltQualifierFailed);
496#elif EXIV2_TEST_VERSION (0,27,0)
431 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); 497 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
432#else 498#else
433 throw Exiv2::BasicError<char> (42 /* error code */); 499 throw Exiv2::BasicError<char> (42 /* error code */);
@@ -452,7 +518,11 @@ ExtractorIO::munmap ()
452 * 518 *
453 * @return -1 on error 519 * @return -1 on error
454 */ 520 */
521#if EXIV2_TEST_VERSION(0,28,0)
522size_t
523#else
455long int 524long int
525#endif
456ExtractorIO::tell (void) const 526ExtractorIO::tell (void) const
457{ 527{
458 return (long) ec->seek (ec->cls, 0, SEEK_CUR); 528 return (long) ec->seek (ec->cls, 0, SEEK_CUR);
@@ -516,10 +586,17 @@ ExtractorIO::eof () const
516 * 586 *
517 * @throws error 587 * @throws error
518 */ 588 */
589#if EXIV2_TEST_VERSION (0,28,0)
590const std::string&
591ExtractorIO::path () const noexcept
592#else
519std::string 593std::string
520ExtractorIO::path () const 594ExtractorIO::path () const
595#endif
521{ 596{
522#if EXIV2_TEST_VERSION (0,27,0) 597#if EXIV2_TEST_VERSION (0,28,0)
598 throw Exiv2::Error (Exiv2::ErrorCode::kerDecodeLangAltQualifierFailed);
599#elif EXIV2_TEST_VERSION (0,27,0)
523 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); 600 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
524#else 601#else
525 throw Exiv2::BasicError<char> (42 /* error code */); 602 throw Exiv2::BasicError<char> (42 /* error code */);
@@ -536,7 +613,9 @@ ExtractorIO::path () const
536std::wstring 613std::wstring
537ExtractorIO::wpath () const 614ExtractorIO::wpath () const
538{ 615{
539#if EXIV2_TEST_VERSION (0,27,0) 616#if EXIV2_TEST_VERSION (0,28,0)
617 throw Exiv2::Error (Exiv2::ErrorCode::kerDecodeLangAltQualifierFailed);
618#elif EXIV2_TEST_VERSION (0,27,0)
540 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); 619 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
541#else 620#else
542 throw Exiv2::BasicError<char> (42 /* error code */); 621 throw Exiv2::BasicError<char> (42 /* error code */);
@@ -552,11 +631,17 @@ ExtractorIO::wpath () const
552 * 631 *
553 * @throws error 632 * @throws error
554 */ 633 */
634#if EXIV2_TEST_VERSION(0,28,0)
635Exiv2::BasicIo::UniquePtr
636#else
555Exiv2::BasicIo::AutoPtr 637Exiv2::BasicIo::AutoPtr
638#endif
556ExtractorIO::temporary () const 639ExtractorIO::temporary () const
557{ 640{
558 fprintf (stderr, "throwing temporary error\n"); 641 fprintf (stderr, "throwing temporary error\n");
559#if EXIV2_TEST_VERSION (0,27,0) 642#if EXIV2_TEST_VERSION(0,28,0)
643 throw Exiv2::Error (Exiv2::ErrorCode::kerDecodeLangAltQualifierFailed);
644#elif EXIV2_TEST_VERSION (0,27,0)
560 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); 645 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
561#else 646#else
562 throw Exiv2::BasicError<char> (42 /* error code */); 647 throw Exiv2::BasicError<char> (42 /* error code */);
@@ -737,8 +822,13 @@ EXTRACTOR_exiv2_extract_method (struct EXTRACTOR_ExtractContext *ec)
737#if ! EXIV2_TEST_VERSION (0,24,0) 822#if ! EXIV2_TEST_VERSION (0,24,0)
738 Exiv2::LogMsg::setLevel (Exiv2::LogMsg::mute); 823 Exiv2::LogMsg::setLevel (Exiv2::LogMsg::mute);
739#endif 824#endif
825#if EXIV2_TEST_VERSION(0,28,0)
826 std::unique_ptr<Exiv2::BasicIo> eio (new ExtractorIO (ec));
827 Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open (std::move(eio));
828#else
740 std::auto_ptr<Exiv2::BasicIo> eio (new ExtractorIO (ec)); 829 std::auto_ptr<Exiv2::BasicIo> eio (new ExtractorIO (ec));
741 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open (eio); 830 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open (eio);
831#endif
742 if (0 == image.get ()) 832 if (0 == image.get ())
743 return; 833 return;
744 image->readMetadata (); 834 image->readMetadata ();
@@ -822,7 +912,11 @@ EXTRACTOR_exiv2_extract_method (struct EXTRACTOR_ExtractContext *ec)
822 ADDXMP ("Xmp.lr.hierarchicalSubject", EXTRACTOR_METATYPE_SUBJECT); 912 ADDXMP ("Xmp.lr.hierarchicalSubject", EXTRACTOR_METATYPE_SUBJECT);
823 } 913 }
824 } 914 }
915#if EXIV2_TEST_VERSION (0,28,0)
916 catch (const Exiv2::Error& e)
917#else
825 catch (const Exiv2::AnyError& e) 918 catch (const Exiv2::AnyError& e)
919#endif
826 { 920 {
827#if DEBUG 921#if DEBUG
828 std::cerr << "Caught Exiv2 exception '" << e << "'\n"; 922 std::cerr << "Caught Exiv2 exception '" << e << "'\n";