Link Here
|
0 |
- |
1 |
--- src/scan_exiv2.cpp.orig 2023-04-07 18:27:14 UTC |
|
|
2 |
+++ src/scan_exiv2.cpp |
3 |
@@ -33,6 +33,8 @@ |
4 |
#pragma GCC diagnostic ignored "-Weffc++" |
5 |
#endif |
6 |
|
7 |
+using std::string; |
8 |
+ |
9 |
#include <exiv2/image.hpp> |
10 |
#include <exiv2/exif.hpp> |
11 |
#include <exiv2/error.hpp> |
12 |
@@ -90,7 +92,7 @@ static string fix_gps(string s) |
13 |
std::vector<std::string> parts = split(s,' '); |
14 |
if(parts.size()!=3) return s; // return the original |
15 |
double res = rational(parts[0]) + rational(parts[1])/60.0 + rational(parts[2])/3600.0; |
16 |
- s = dtos(res); |
17 |
+ s = std::to_string(res); |
18 |
return s; |
19 |
} |
20 |
|
21 |
@@ -106,7 +108,7 @@ void scan_exiv2(struct scanner_params &sp) |
22 |
{ |
23 |
sp.check_version(); |
24 |
if(sp.phase==scanner_params::PHASE_INIT){ |
25 |
- sp.info.set_name("exiv2" ); |
26 |
+ sp.info->set_name("exiv2" ); |
27 |
sp.info->author = "Simson L. Garfinkel"; |
28 |
sp.info->description = "Searches for EXIF information using exiv2. Use exif scanner if this is not available or if this crashes."; |
29 |
sp.info->scanner_flags.default_enabled = false; |
30 |
@@ -117,7 +119,7 @@ void scan_exiv2(struct scanner_params &sp) |
31 |
} |
32 |
if(sp.phase==scanner_params::PHASE_SCAN){ |
33 |
|
34 |
- const sbuf_t &sbuf = sp.sbuf; |
35 |
+ const sbuf_t *sbuf = sp.sbuf; |
36 |
feature_recorder &exif_recorder = sp.named_feature_recorder("exif"); |
37 |
feature_recorder &gps_recorder = sp.named_feature_recorder("gps"); |
38 |
|
39 |
@@ -127,23 +129,23 @@ void scan_exiv2(struct scanner_params &sp) |
40 |
#endif |
41 |
|
42 |
size_t pos_max = 1; // by default, just scan 1 byte |
43 |
- if(sbuf.bufsize > min_exif_size){ |
44 |
- pos_max = sbuf.bufsize - min_exif_size; // we can scan more! |
45 |
+ if(sbuf->bufsize > min_exif_size){ |
46 |
+ pos_max = sbuf->bufsize - min_exif_size; // we can scan more! |
47 |
} |
48 |
|
49 |
/* Loop through all possible locations in the buffer */ |
50 |
for(size_t pos=0;pos<pos_max;pos++){ |
51 |
size_t count = exif_gulp_size; |
52 |
- count = min(count,sbuf.bufsize-pos); |
53 |
- //size_t count = sbuf.bufsize-pos; // use all to end |
54 |
+ count = min(count,sbuf->bufsize-pos); |
55 |
+ //size_t count = sbuf->bufsize-pos; // use all to end |
56 |
|
57 |
/* Explore the beginning of each 512-byte block as well as the starting location |
58 |
* of any JPEG on any boundary. This will cause processing of any multimedia file |
59 |
* that Exiv2 recognizes (for which I do not know all the headers. |
60 |
*/ |
61 |
- if(pos%512==0 || jpeg_start(sbuf+pos)){ |
62 |
+ if(pos%512==0 || jpeg_start(sbuf->slice(pos))){ |
63 |
try { |
64 |
- Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(sbuf.buf+pos,count); |
65 |
+ Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(sbuf->slice(pos).get_buf(),count); |
66 |
if(image->good()){ |
67 |
image->readMetadata(); |
68 |
|
69 |
@@ -153,8 +155,8 @@ void scan_exiv2(struct scanner_params &sp) |
70 |
/* |
71 |
* Create the MD5 of the first 4K to use as a unique identifier. |
72 |
*/ |
73 |
- sbuf_t tohash(sbuf,0,4096); |
74 |
- string md5_hex = exif_recorder->fs.hasher.func(tohash.buf,tohash.bufsize); |
75 |
+ sbuf_t tohash(*sbuf,0,4096); |
76 |
+ string md5_hex = exif_recorder.hash(tohash.slice(0, tohash.bufsize)); |
77 |
|
78 |
char xmlbuf[1024]; |
79 |
snprintf(xmlbuf,sizeof(xmlbuf), |
80 |
@@ -250,10 +252,10 @@ void scan_exiv2(struct scanner_params &sp) |
81 |
gps_lat = fix_gps(i->value().toString()); |
82 |
} else if(key=="Exif.GPSInfo.GPSAltitude"){ |
83 |
has_gps = true; |
84 |
- gps_ele = dtos(rational(i->value().toString())); |
85 |
+ gps_ele = std::to_string(rational(i->value().toString())); |
86 |
} else if(key=="Exif.GPSInfo.GPSSpeed"){ |
87 |
has_gps = true; |
88 |
- gps_speed = dtos(rational(i->value().toString())); |
89 |
+ gps_speed = std::to_string(rational(i->value().toString())); |
90 |
} else if(key=="Exif.GPSInfo.GPSTrack"){ |
91 |
has_gps = true; |
92 |
gps_course = i->value().toString(); |
93 |
@@ -262,20 +264,20 @@ void scan_exiv2(struct scanner_params &sp) |
94 |
xml.append("</exiv2>"); |
95 |
|
96 |
// record EXIF |
97 |
- exif_recorder->write(sp.sbuf.pos0+pos,md5_hex,xml); |
98 |
+ exif_recorder.write(sp.sbuf->pos0+pos,md5_hex,xml); |
99 |
|
100 |
// record GPS |
101 |
if (has_gps) { |
102 |
if (has_gps_date) { |
103 |
// record the GPS entry using the GPS date |
104 |
- gps_recorder->write(sp.sbuf.pos0+pos,md5_hex, |
105 |
+ gps_recorder.write(sp.sbuf->pos0+pos,md5_hex, |
106 |
gps_date+"T"+gps_time+","+gps_lat_ref+gps_lat+"," |
107 |
+gps_lon_ref+gps_lon+"," |
108 |
+gps_ele+","+gps_speed+","+gps_course); |
109 |
|
110 |
} else { |
111 |
// record the GPS entry using the date obtained from Photo |
112 |
- gps_recorder->write(sp.sbuf.pos0+pos,md5_hex, |
113 |
+ gps_recorder.write(sp.sbuf->pos0+pos,md5_hex, |
114 |
photo_time+","+gps_lat_ref+gps_lat+"," |
115 |
+gps_lon_ref+gps_lon+"," |
116 |
+gps_ele+","+gps_speed+","+gps_course); |
117 |
@@ -283,7 +285,7 @@ void scan_exiv2(struct scanner_params &sp) |
118 |
} |
119 |
} |
120 |
} |
121 |
- catch (Exiv2::AnyError &e) { } |
122 |
+ catch (Exiv2::Error &e) { } |
123 |
catch (std::exception &e) { } |
124 |
} |
125 |
} |