diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-10-11 20:13:06 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-10-11 20:13:06 +0200 |
commit | 13b5956fbdc796bbd9f3b0449aee13b059d91bab (patch) | |
tree | 9cf18bf84a2df01e636f964e6574f8902be6cb6f | |
parent | c3e153fecd70a28e701771537ab4b4f0d5bc1267 (diff) | |
download | libextractor-13b5956fbdc796bbd9f3b0449aee13b059d91bab.tar.gz libextractor-13b5956fbdc796bbd9f3b0449aee13b059d91bab.zip |
make code compile against libexiv 0.26
-rw-r--r-- | src/plugins/exiv2_extractor.cc | 100 |
1 files changed, 54 insertions, 46 deletions
diff --git a/src/plugins/exiv2_extractor.cc b/src/plugins/exiv2_extractor.cc index ff90102..8741d40 100644 --- a/src/plugins/exiv2_extractor.cc +++ b/src/plugins/exiv2_extractor.cc | |||
@@ -55,7 +55,7 @@ public: | |||
55 | 55 | ||
56 | /** | 56 | /** |
57 | * Constructor. | 57 | * Constructor. |
58 | * | 58 | * |
59 | * @param s_ec extract context to wrap | 59 | * @param s_ec extract context to wrap |
60 | */ | 60 | */ |
61 | ExtractorIO (struct EXTRACTOR_ExtractContext *s_ec) | 61 | ExtractorIO (struct EXTRACTOR_ExtractContext *s_ec) |
@@ -73,18 +73,18 @@ public: | |||
73 | 73 | ||
74 | /** | 74 | /** |
75 | * Open stream. | 75 | * Open stream. |
76 | * | 76 | * |
77 | * @return 0 (always successful) | 77 | * @return 0 (always successful) |
78 | */ | 78 | */ |
79 | virtual int open (); | 79 | virtual int open (); |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * Close stream. | 82 | * Close stream. |
83 | * | 83 | * |
84 | * @return 0 (always successful) | 84 | * @return 0 (always successful) |
85 | */ | 85 | */ |
86 | virtual int close (); | 86 | virtual int close (); |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Read up to 'rcount' bytes into a buffer | 89 | * Read up to 'rcount' bytes into a buffer |
90 | * | 90 | * |
@@ -117,7 +117,7 @@ public: | |||
117 | * @param data data to write | 117 | * @param data data to write |
118 | * @param wcount how many bytes to write | 118 | * @param wcount how many bytes to write |
119 | * @return -1 (always fails) | 119 | * @return -1 (always fails) |
120 | */ | 120 | */ |
121 | virtual long write (const Exiv2::byte *data, | 121 | virtual long write (const Exiv2::byte *data, |
122 | long wcount); | 122 | long wcount); |
123 | 123 | ||
@@ -126,7 +126,7 @@ public: | |||
126 | * | 126 | * |
127 | * @param src stream to copy | 127 | * @param src stream to copy |
128 | * @return -1 (always fails) | 128 | * @return -1 (always fails) |
129 | */ | 129 | */ |
130 | virtual long write (Exiv2::BasicIo &src); | 130 | virtual long write (Exiv2::BasicIo &src); |
131 | 131 | ||
132 | /** | 132 | /** |
@@ -160,7 +160,7 @@ public: | |||
160 | * @throws error | 160 | * @throws error |
161 | */ | 161 | */ |
162 | virtual Exiv2::byte* mmap (bool isWritable); | 162 | virtual Exiv2::byte* mmap (bool isWritable); |
163 | 163 | ||
164 | /** | 164 | /** |
165 | * Not supported. | 165 | * Not supported. |
166 | * | 166 | * |
@@ -180,11 +180,15 @@ public: | |||
180 | * | 180 | * |
181 | * @return -1 on error | 181 | * @return -1 on error |
182 | */ | 182 | */ |
183 | #if EXIV2_VERSION >= EXIV2_MAKE_VERSION(0,26,0) | ||
184 | virtual size_t size (void) const; | ||
185 | #else | ||
183 | virtual long int size (void) const; | 186 | virtual long int size (void) const; |
187 | #endif | ||
184 | 188 | ||
185 | /** | 189 | /** |
186 | * Check if file is open. | 190 | * Check if file is open. |
187 | * | 191 | * |
188 | * @return true (always). | 192 | * @return true (always). |
189 | */ | 193 | */ |
190 | virtual bool isopen () const; | 194 | virtual bool isopen () const; |
@@ -198,7 +202,7 @@ public: | |||
198 | 202 | ||
199 | /** | 203 | /** |
200 | * Check if current position of the file is at the end | 204 | * Check if current position of the file is at the end |
201 | * | 205 | * |
202 | * @return true if at EOF, false if not. | 206 | * @return true if at EOF, false if not. |
203 | */ | 207 | */ |
204 | virtual bool eof () const; | 208 | virtual bool eof () const; |
@@ -218,7 +222,7 @@ public: | |||
218 | */ | 222 | */ |
219 | virtual std::wstring wpath () const; | 223 | virtual std::wstring wpath () const; |
220 | #endif | 224 | #endif |
221 | 225 | ||
222 | /** | 226 | /** |
223 | * Not supported. | 227 | * Not supported. |
224 | * | 228 | * |
@@ -227,14 +231,14 @@ public: | |||
227 | virtual Exiv2::BasicIo::AutoPtr temporary () const; | 231 | virtual Exiv2::BasicIo::AutoPtr temporary () const; |
228 | 232 | ||
229 | }; | 233 | }; |
230 | 234 | ||
231 | 235 | ||
232 | /** | 236 | /** |
233 | * Open stream. | 237 | * Open stream. |
234 | * | 238 | * |
235 | * @return 0 (always successful) | 239 | * @return 0 (always successful) |
236 | */ | 240 | */ |
237 | int | 241 | int |
238 | ExtractorIO::open () | 242 | ExtractorIO::open () |
239 | { | 243 | { |
240 | return 0; | 244 | return 0; |
@@ -242,10 +246,10 @@ ExtractorIO::open () | |||
242 | 246 | ||
243 | /** | 247 | /** |
244 | * Close stream. | 248 | * Close stream. |
245 | * | 249 | * |
246 | * @return 0 (always successful) | 250 | * @return 0 (always successful) |
247 | */ | 251 | */ |
248 | int | 252 | int |
249 | ExtractorIO::close () | 253 | ExtractorIO::close () |
250 | { | 254 | { |
251 | return 0; | 255 | return 0; |
@@ -277,7 +281,7 @@ ExtractorIO::read (long rcount) | |||
277 | * @param rcount size of 'buf' | 281 | * @param rcount size of 'buf' |
278 | * @return number of bytes read successfully, 0 on failure (!) | 282 | * @return number of bytes read successfully, 0 on failure (!) |
279 | */ | 283 | */ |
280 | long | 284 | long |
281 | ExtractorIO::read (Exiv2::byte *buf, | 285 | ExtractorIO::read (Exiv2::byte *buf, |
282 | long rcount) | 286 | long rcount) |
283 | { | 287 | { |
@@ -305,12 +309,12 @@ ExtractorIO::read (Exiv2::byte *buf, | |||
305 | * @return the character | 309 | * @return the character |
306 | * @throw exception on errors | 310 | * @throw exception on errors |
307 | */ | 311 | */ |
308 | int | 312 | int |
309 | ExtractorIO::getb () | 313 | ExtractorIO::getb () |
310 | { | 314 | { |
311 | void *data; | 315 | void *data; |
312 | const unsigned char *r; | 316 | const unsigned char *r; |
313 | 317 | ||
314 | if (1 != ec->read (ec->cls, &data, 1)) | 318 | if (1 != ec->read (ec->cls, &data, 1)) |
315 | throw Exiv2::BasicError<char> (42 /* error code */); | 319 | throw Exiv2::BasicError<char> (42 /* error code */); |
316 | r = (const unsigned char *) data; | 320 | r = (const unsigned char *) data; |
@@ -324,8 +328,8 @@ ExtractorIO::getb () | |||
324 | * @param data data to write | 328 | * @param data data to write |
325 | * @param wcount how many bytes to write | 329 | * @param wcount how many bytes to write |
326 | * @return -1 (always fails) | 330 | * @return -1 (always fails) |
327 | */ | 331 | */ |
328 | long | 332 | long |
329 | ExtractorIO::write (const Exiv2::byte *data, | 333 | ExtractorIO::write (const Exiv2::byte *data, |
330 | long wcount) | 334 | long wcount) |
331 | { | 335 | { |
@@ -338,8 +342,8 @@ ExtractorIO::write (const Exiv2::byte *data, | |||
338 | * | 342 | * |
339 | * @param src stream to copy | 343 | * @param src stream to copy |
340 | * @return -1 (always fails) | 344 | * @return -1 (always fails) |
341 | */ | 345 | */ |
342 | long | 346 | long |
343 | ExtractorIO::write (Exiv2::BasicIo &src) | 347 | ExtractorIO::write (Exiv2::BasicIo &src) |
344 | { | 348 | { |
345 | return -1; | 349 | return -1; |
@@ -352,7 +356,7 @@ ExtractorIO::write (Exiv2::BasicIo &src) | |||
352 | * @param data byte to write | 356 | * @param data byte to write |
353 | * @return -1 (always fails) | 357 | * @return -1 (always fails) |
354 | */ | 358 | */ |
355 | int | 359 | int |
356 | ExtractorIO::putb (Exiv2::byte data) | 360 | ExtractorIO::putb (Exiv2::byte data) |
357 | { | 361 | { |
358 | return -1; | 362 | return -1; |
@@ -378,12 +382,12 @@ ExtractorIO::transfer (Exiv2::BasicIo& src) | |||
378 | * @parma pos offset is relative to where? | 382 | * @parma pos offset is relative to where? |
379 | * @return -1 on failure, 0 on success | 383 | * @return -1 on failure, 0 on success |
380 | */ | 384 | */ |
381 | int | 385 | int |
382 | ExtractorIO::seek (long offset, | 386 | ExtractorIO::seek (long offset, |
383 | Exiv2::BasicIo::Position pos) | 387 | Exiv2::BasicIo::Position pos) |
384 | { | 388 | { |
385 | int rel; | 389 | int rel; |
386 | 390 | ||
387 | switch (pos) | 391 | switch (pos) |
388 | { | 392 | { |
389 | case beg: // Exiv2::BasicIo::beg: | 393 | case beg: // Exiv2::BasicIo::beg: |
@@ -445,7 +449,11 @@ ExtractorIO::tell (void) const | |||
445 | * | 449 | * |
446 | * @return -1 on error | 450 | * @return -1 on error |
447 | */ | 451 | */ |
448 | long int | 452 | #if EXIV2_VERSION >= EXIV2_MAKE_VERSION(0,26,0) |
453 | size_t | ||
454 | #else | ||
455 | long int | ||
456 | #endif | ||
449 | ExtractorIO::size (void) const | 457 | ExtractorIO::size (void) const |
450 | { | 458 | { |
451 | return (long) ec->get_size (ec->cls); | 459 | return (long) ec->get_size (ec->cls); |
@@ -454,10 +462,10 @@ ExtractorIO::size (void) const | |||
454 | 462 | ||
455 | /** | 463 | /** |
456 | * Check if file is open. | 464 | * Check if file is open. |
457 | * | 465 | * |
458 | * @return true (always). | 466 | * @return true (always). |
459 | */ | 467 | */ |
460 | bool | 468 | bool |
461 | ExtractorIO::isopen () const | 469 | ExtractorIO::isopen () const |
462 | { | 470 | { |
463 | return true; | 471 | return true; |
@@ -478,10 +486,10 @@ ExtractorIO::error () const | |||
478 | 486 | ||
479 | /** | 487 | /** |
480 | * Check if current position of the file is at the end | 488 | * Check if current position of the file is at the end |
481 | * | 489 | * |
482 | * @return true if at EOF, false if not. | 490 | * @return true if at EOF, false if not. |
483 | */ | 491 | */ |
484 | bool | 492 | bool |
485 | ExtractorIO::eof () const | 493 | ExtractorIO::eof () const |
486 | { | 494 | { |
487 | return size () == tell (); | 495 | return size () == tell (); |
@@ -559,7 +567,7 @@ add_exiv2_tag (const Exiv2::ExifData& exifData, | |||
559 | Exiv2::ExifKey ek (key); | 567 | Exiv2::ExifKey ek (key); |
560 | Exiv2::ExifData::const_iterator md = exifData.findKey (ek); | 568 | Exiv2::ExifData::const_iterator md = exifData.findKey (ek); |
561 | 569 | ||
562 | if (exifData.end () == md) | 570 | if (exifData.end () == md) |
563 | return 0; /* not found */ | 571 | return 0; /* not found */ |
564 | std::string ccstr = Exiv2::toString(*md); | 572 | std::string ccstr = Exiv2::toString(*md); |
565 | str = ccstr.c_str(); | 573 | str = ccstr.c_str(); |
@@ -595,14 +603,14 @@ add_iptc_data (const Exiv2::IptcData& iptcData, | |||
595 | Exiv2::IptcKey ek (key); | 603 | Exiv2::IptcKey ek (key); |
596 | Exiv2::IptcData::const_iterator md = iptcData.findKey (ek); | 604 | Exiv2::IptcData::const_iterator md = iptcData.findKey (ek); |
597 | 605 | ||
598 | while (iptcData.end () != md) | 606 | while (iptcData.end () != md) |
599 | { | 607 | { |
600 | if (0 != strcmp (Exiv2::toString (md->key ()).c_str (), key.c_str ())) | 608 | if (0 != strcmp (Exiv2::toString (md->key ()).c_str (), key.c_str ())) |
601 | break; | 609 | break; |
602 | std::string ccstr = Exiv2::toString (*md); | 610 | std::string ccstr = Exiv2::toString (*md); |
603 | str = ccstr.c_str (); | 611 | str = ccstr.c_str (); |
604 | /* skip over whitespace */ | 612 | /* skip over whitespace */ |
605 | while ((strlen (str) > 0) && isspace ((unsigned char) str[0])) | 613 | while ((strlen (str) > 0) && isspace ((unsigned char) str[0])) |
606 | str++; | 614 | str++; |
607 | if (strlen (str) > 0) | 615 | if (strlen (str) > 0) |
608 | ADD (str, type); | 616 | ADD (str, type); |
@@ -634,7 +642,7 @@ add_xmp_data (const Exiv2::XmpData& xmpData, | |||
634 | Exiv2::XmpKey ek (key); | 642 | Exiv2::XmpKey ek (key); |
635 | Exiv2::XmpData::const_iterator md = xmpData.findKey (ek); | 643 | Exiv2::XmpData::const_iterator md = xmpData.findKey (ek); |
636 | 644 | ||
637 | while (xmpData.end () != md) | 645 | while (xmpData.end () != md) |
638 | { | 646 | { |
639 | if (0 != strcmp (Exiv2::toString (md->key ()).c_str (), key.c_str ())) | 647 | if (0 != strcmp (Exiv2::toString (md->key ()).c_str (), key.c_str ())) |
640 | break; | 648 | break; |
@@ -680,7 +688,7 @@ add_xmp_data (const Exiv2::XmpData& xmpData, | |||
680 | 688 | ||
681 | 689 | ||
682 | /** | 690 | /** |
683 | * Main entry method for the 'exiv2' extraction plugin. | 691 | * Main entry method for the 'exiv2' extraction plugin. |
684 | * | 692 | * |
685 | * @param ec extraction context provided to the plugin | 693 | * @param ec extraction context provided to the plugin |
686 | */ | 694 | */ |
@@ -688,7 +696,7 @@ extern "C" void | |||
688 | EXTRACTOR_exiv2_extract_method (struct EXTRACTOR_ExtractContext *ec) | 696 | EXTRACTOR_exiv2_extract_method (struct EXTRACTOR_ExtractContext *ec) |
689 | { | 697 | { |
690 | try | 698 | try |
691 | { | 699 | { |
692 | #if EXIV2_MAKE_VERSION(0,23,0) <= EXIV2_VERSION | 700 | #if EXIV2_MAKE_VERSION(0,23,0) <= EXIV2_VERSION |
693 | Exiv2::LogMsg::setLevel (Exiv2::LogMsg::mute); | 701 | Exiv2::LogMsg::setLevel (Exiv2::LogMsg::mute); |
694 | #endif | 702 | #endif |
@@ -698,15 +706,15 @@ EXTRACTOR_exiv2_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
698 | return; | 706 | return; |
699 | image->readMetadata (); | 707 | image->readMetadata (); |
700 | Exiv2::ExifData &exifData = image->exifData (); | 708 | Exiv2::ExifData &exifData = image->exifData (); |
701 | if (! exifData.empty ()) | 709 | if (! exifData.empty ()) |
702 | { | 710 | { |
703 | ADDEXIV ("Exif.Image.Copyright", EXTRACTOR_METATYPE_COPYRIGHT); | 711 | ADDEXIV ("Exif.Image.Copyright", EXTRACTOR_METATYPE_COPYRIGHT); |
704 | ADDEXIV ("Exif.Photo.UserComment", EXTRACTOR_METATYPE_COMMENT); | 712 | ADDEXIV ("Exif.Photo.UserComment", EXTRACTOR_METATYPE_COMMENT); |
705 | ADDEXIV ("Exif.GPSInfo.GPSLatitudeRef", EXTRACTOR_METATYPE_GPS_LATITUDE_REF); | 713 | ADDEXIV ("Exif.GPSInfo.GPSLatitudeRef", EXTRACTOR_METATYPE_GPS_LATITUDE_REF); |
706 | ADDEXIV ("Exif.GPSInfo.GPSLatitude", EXTRACTOR_METATYPE_GPS_LATITUDE); | 714 | ADDEXIV ("Exif.GPSInfo.GPSLatitude", EXTRACTOR_METATYPE_GPS_LATITUDE); |
707 | ADDEXIV ("Exif.GPSInfo.GPSLongitudeRef", EXTRACTOR_METATYPE_GPS_LONGITUDE_REF); | 715 | ADDEXIV ("Exif.GPSInfo.GPSLongitudeRef", EXTRACTOR_METATYPE_GPS_LONGITUDE_REF); |
708 | ADDEXIV ("Exif.GPSInfo.GPSLongitude", EXTRACTOR_METATYPE_GPS_LONGITUDE); | 716 | ADDEXIV ("Exif.GPSInfo.GPSLongitude", EXTRACTOR_METATYPE_GPS_LONGITUDE); |
709 | ADDEXIV ("Exif.Image.Make", EXTRACTOR_METATYPE_CAMERA_MAKE); | 717 | ADDEXIV ("Exif.Image.Make", EXTRACTOR_METATYPE_CAMERA_MAKE); |
710 | ADDEXIV ("Exif.Image.Model", EXTRACTOR_METATYPE_CAMERA_MODEL); | 718 | ADDEXIV ("Exif.Image.Model", EXTRACTOR_METATYPE_CAMERA_MODEL); |
711 | ADDEXIV ("Exif.Image.Orientation", EXTRACTOR_METATYPE_ORIENTATION); | 719 | ADDEXIV ("Exif.Image.Orientation", EXTRACTOR_METATYPE_ORIENTATION); |
712 | ADDEXIV ("Exif.Photo.DateTimeOriginal", EXTRACTOR_METATYPE_CREATION_DATE); | 720 | ADDEXIV ("Exif.Photo.DateTimeOriginal", EXTRACTOR_METATYPE_CREATION_DATE); |
@@ -747,19 +755,19 @@ EXTRACTOR_exiv2_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
747 | ADDEXIV ("Exif.Panasonic.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE); | 755 | ADDEXIV ("Exif.Panasonic.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE); |
748 | ADDEXIV ("Exif.Photo.FNumber", EXTRACTOR_METATYPE_APERTURE); | 756 | ADDEXIV ("Exif.Photo.FNumber", EXTRACTOR_METATYPE_APERTURE); |
749 | ADDEXIV ("Exif.Photo.ExposureTime", EXTRACTOR_METATYPE_EXPOSURE); | 757 | ADDEXIV ("Exif.Photo.ExposureTime", EXTRACTOR_METATYPE_EXPOSURE); |
750 | } | 758 | } |
751 | 759 | ||
752 | Exiv2::IptcData &iptcData = image->iptcData(); | 760 | Exiv2::IptcData &iptcData = image->iptcData(); |
753 | if (! iptcData.empty()) | 761 | if (! iptcData.empty()) |
754 | { | 762 | { |
755 | ADDIPTC ("Iptc.Application2.Keywords", EXTRACTOR_METATYPE_KEYWORDS); | 763 | ADDIPTC ("Iptc.Application2.Keywords", EXTRACTOR_METATYPE_KEYWORDS); |
756 | ADDIPTC ("Iptc.Application2.City", EXTRACTOR_METATYPE_LOCATION_CITY); | 764 | ADDIPTC ("Iptc.Application2.City", EXTRACTOR_METATYPE_LOCATION_CITY); |
757 | ADDIPTC ("Iptc.Application2.SubLocation", EXTRACTOR_METATYPE_LOCATION_SUBLOCATION); | 765 | ADDIPTC ("Iptc.Application2.SubLocation", EXTRACTOR_METATYPE_LOCATION_SUBLOCATION); |
758 | ADDIPTC ("Iptc.Application2.CountryName", EXTRACTOR_METATYPE_LOCATION_COUNTRY); | 766 | ADDIPTC ("Iptc.Application2.CountryName", EXTRACTOR_METATYPE_LOCATION_COUNTRY); |
759 | } | 767 | } |
760 | 768 | ||
761 | Exiv2::XmpData &xmpData = image->xmpData(); | 769 | Exiv2::XmpData &xmpData = image->xmpData(); |
762 | if (! xmpData.empty()) | 770 | if (! xmpData.empty()) |
763 | { | 771 | { |
764 | ADDXMP ("Xmp.photoshop.Country", EXTRACTOR_METATYPE_LOCATION_COUNTRY); | 772 | ADDXMP ("Xmp.photoshop.Country", EXTRACTOR_METATYPE_LOCATION_COUNTRY); |
765 | ADDXMP ("Xmp.photoshop.City", EXTRACTOR_METATYPE_LOCATION_CITY); | 773 | ADDXMP ("Xmp.photoshop.City", EXTRACTOR_METATYPE_LOCATION_CITY); |
@@ -768,9 +776,9 @@ EXTRACTOR_exiv2_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
768 | ADDXMP ("Xmp.iptc.CountryCode", EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE); | 776 | ADDXMP ("Xmp.iptc.CountryCode", EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE); |
769 | ADDXMP ("Xmp.xmp.CreatorTool", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE); | 777 | ADDXMP ("Xmp.xmp.CreatorTool", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE); |
770 | ADDXMP ("Xmp.lr.hierarchicalSubject", EXTRACTOR_METATYPE_SUBJECT); | 778 | ADDXMP ("Xmp.lr.hierarchicalSubject", EXTRACTOR_METATYPE_SUBJECT); |
771 | } | 779 | } |
772 | } | 780 | } |
773 | catch (const Exiv2::AnyError& e) | 781 | catch (const Exiv2::AnyError& e) |
774 | { | 782 | { |
775 | #if DEBUG | 783 | #if DEBUG |
776 | std::cerr << "Caught Exiv2 exception '" << e << "'\n"; | 784 | std::cerr << "Caught Exiv2 exception '" << e << "'\n"; |