Signed-off-by: Michael Rasmussen <mir@datanom.net>
+static const char* LensMakers[] = {
+ "7Artisans",
+ "Canon",
+ "Carl Zeiss",
+ "Chinon",
+ "Cosina",
+ "Essilor",
+ "EssilorLuxottica",
+ "Fujifilm",
+ "Goerz",
+ "Hoya",
+ "Kenko",
+ "Konica",
+ "Leica",
+ "Leidolf",
+ "Lumix",
+ "Meopta",
+ "Meyer Optik Görlitz",
+ "Minolta",
+ "Nikon",
+ "Nisi",
+ "Olympus",
+ "OM Digital Solutions",
+ "Pentacon",
+ "Pentax",
+ "Pergear",
+ "Rodenstock",
+ "Samyang",
+ "Schneider Kreuznach",
+ "Seagull",
+ "Seiko",
+ "Sigma",
+ "Silor",
+ "Schneider Kreuznach",
+ "Soligor",
+ "Sony",
+ "Tamron",
+ "Tokina",
+ "Topcon",
+ "TTArtisan",
+ "Yongnuo",
+ "Viltrox",
+ "Voigtländer",
+ NULL
+};
+
static void print_all(gpointer key, gpointer value, gpointer user_data) {
cout << (gchar*)key << " = " << (gchar*)value << endl;
}
static void print_all(gpointer key, gpointer value, gpointer user_data) {
cout << (gchar*)key << " = " << (gchar*)value << endl;
}
string maker;
//g_hash_table_foreach(exif_tags, print_all, NULL);
string maker;
//g_hash_table_foreach(exif_tags, print_all, NULL);
- const gchar* lensId = (gchar *)g_hash_table_lookup(exif_tags, "LensMake");
+ gchar* lensId = g_strdup((gchar *)g_hash_table_lookup(exif_tags, "LensMake"));
gulong len = g_utf8_strlen(lensId, -1);
if (!lensId || g_strcmp0("Unknown (2822)", lensId) == 0 || len < 1) {
const gchar* s = (gchar *)g_hash_table_lookup(exif_tags, "LensID");
gulong len = g_utf8_strlen(lensId, -1);
if (!lensId || g_strcmp0("Unknown (2822)", lensId) == 0 || len < 1) {
const gchar* s = (gchar *)g_hash_table_lookup(exif_tags, "LensID");
//cout << pos << endl;
if (pos) {
//cout << "S length: " << strlen(s) << "POS length: " << strlen(pos) << endl;
//cout << pos << endl;
if (pos) {
//cout << "S length: " << strlen(s) << "POS length: " << strlen(pos) << endl;
lensId = g_strndup(s, strlen(s) - strlen(pos));
}
len = g_utf8_strlen(lensId, -1);
}
}
lensId = g_strndup(s, strlen(s) - strlen(pos));
}
len = g_utf8_strlen(lensId, -1);
}
}
+ if (match_maker(lensId) == false) {
+ g_free(lensId);
+ lensId = NULL;
+ }
+
if (!lensId || g_strcmp0("Unknown (2822)", lensId) == 0 || len < 1) {
const gchar* s = (gchar *)g_hash_table_lookup(exif_tags, "LensModel");
if (s) {
if (!lensId || g_strcmp0("Unknown (2822)", lensId) == 0 || len < 1) {
const gchar* s = (gchar *)g_hash_table_lookup(exif_tags, "LensModel");
if (s) {
//cout << pos << endl;
if (pos) {
//cout << "S length: " << strlen(s) << "POS length: " << strlen(pos) << endl;
//cout << pos << endl;
if (pos) {
//cout << "S length: " << strlen(s) << "POS length: " << strlen(pos) << endl;
lensId = g_strndup(s, strlen(s) - strlen(pos));
len = g_utf8_strlen(lensId, -1);
}
}
}
lensId = g_strndup(s, strlen(s) - strlen(pos));
len = g_utf8_strlen(lensId, -1);
}
}
}
+
+ if (match_maker(lensId) == false) {
+ g_free(lensId);
+ lensId = NULL;
+ }
+
- maker = get_cscring("Unknown");
+ maker = get_cstring("Unknown");
- maker = get_cscring(lensId);
+ maker = get_cstring(lensId);
+ g_free(lensId);
- sn = get_cscring("Unknown");
+ sn = get_cstring("Unknown");
}
if (!lensId || g_strcmp0("Unknown (2822)", lensId) == 0 || len < 1)
}
if (!lensId || g_strcmp0("Unknown (2822)", lensId) == 0 || len < 1)
- lens = get_cscring("Unknown");
+ lens = get_cstring("Unknown");
- lens = get_cscring(lensId);
+ lens = get_cstring(lensId);
-gchar* ExifScanner::get_cscring(string s) {
+gchar* ExifScanner::get_cstring(string s) {
gchar* cstring = g_strdup(s.c_str());
return cstring;
}
gchar* cstring = g_strdup(s.c_str());
return cstring;
}
+
+bool ExifScanner::match_maker(const gchar* maker) {
+ int i = 0;
+ const char* lensmaker = NULL;
+
+ if (maker == NULL) return false;
+
+ lensmaker = LensMakers[i];
+ while (lensmaker) {
+ if (g_ascii_strcasecmp(lensmaker, maker) == 0) {
+ return true;
+ }
+ i++;
+ lensmaker = LensMakers[i];
+ }
+
+ return false;
+}
std::string get_lens();
std::string get_serial_number();
std::string get_error();
std::string get_lens();
std::string get_serial_number();
std::string get_error();
- gchar* get_cscring(std::string s);
+ gchar* get_cstring(std::string s);
GHashTable* exif_tags;
void get_data_from_image();
GHashTable* exif_tags;
void get_data_from_image();
+ bool match_maker(const gchar* maker);
return NULL;
obj = static_cast<ExifScanner *>(s->obj);
return NULL;
obj = static_cast<ExifScanner *>(s->obj);
- return obj->get_cscring(obj->get_maker());
+ return obj->get_cstring(obj->get_maker());
}
gchar* get_lens_serial_number(Scanner_t* s) {
}
gchar* get_lens_serial_number(Scanner_t* s) {
return NULL;
obj = static_cast<ExifScanner *>(s->obj);
return NULL;
obj = static_cast<ExifScanner *>(s->obj);
- return obj->get_cscring(obj->get_serial_number());
+ return obj->get_cstring(obj->get_serial_number());
}
gchar* get_lens_info(Scanner_t* s) {
}
gchar* get_lens_info(Scanner_t* s) {
return NULL;
obj = static_cast<ExifScanner *>(s->obj);
return NULL;
obj = static_cast<ExifScanner *>(s->obj);
- return obj->get_cscring(obj->get_lens());
+ return obj->get_cstring(obj->get_lens());