#include <config.h>
+#ifdef __linux__
#define _XOPEN_SOURCE
+#endif
+
+#include <sys/stat.h>
#include <cmath>
#include <cstdlib>
#include <cstring>
+#include <ctime>
-#ifdef HAVE_LCMS
-/*** color support enabled ***/
+#include <glib.h>
-#ifdef HAVE_LCMS2
-#include <lcms2.h>
-#else
-#include <lcms.h>
-#endif
+#if HAVE_LCMS
+/*** color support enabled ***/
+# if HAVE_LCMS2
+# include <lcms2.h>
+# else
+# include <lcms.h>
+# endif
#endif
-#include "main.h"
+#include "cache.h"
+#include "debug.h"
#include "exif.h"
-
#include "filecache.h"
+#include "filedata.h"
#include "glua.h"
-#include "ui-fileops.h"
-#include "cache.h"
+#include "intl.h"
#include "jpeg-parser.h"
+#include "main-defines.h"
#include "misc.h"
-#include "zonedetect.h"
+#include "third-party/zonedetect.h"
+#include "typedefs.h"
+#include "ui-fileops.h"
+struct ExifData;
+struct ExifItem;
+struct FileCacheData;
+struct ZoneDetect;
static gdouble exif_rational_to_double(ExifRational *r, gint sign)
gdouble xres = exif_get_rational_as_double(exif, "Exif.Photo.FocalPlaneXResolution");
gdouble yres = exif_get_rational_as_double(exif, "Exif.Photo.FocalPlaneYResolution");
gint res_unit;
- gint w, h;
- gdouble xsize, ysize, size, ratio;
+ gint w;
+ gint h;
+ gdouble xsize;
+ gdouble ysize;
+ gdouble size;
+ gdouble ratio;
if (xres == 0.0 || yres == 0.0) return 0.0;
if (ratio < 0.5 || ratio > 2.0) return 0.0; /* reasonable ratio */
- size = sqrt(xsize * xsize + ysize * ysize);
+ size = hypot(xsize, ysize);
if (size < 1.0 || size > 100.0) return 0.0; /* reasonable sensor size in mm */
- return sqrt(36*36+24*24) / size;
-
+ return hypot(36, 24) / size;
}
static gboolean remove_suffix(gchar *str, const gchar *suffix, gint suffix_len)
if (software)
{
- gint i, j;
+ gint i;
+ gint j;
g_strstrip(software);
static gchar *exif_build_formatted_FocalLength35mmFilm(ExifData *exif)
{
gint n;
- gdouble f, c;
+ gdouble f;
+ gdouble c;
if (exif_get_integer(exif, "Exif.Photo.FocalLengthIn35mmFilm", &n) && n != 0)
{
{
/* grr, flash is a bitmask... */
GString *string;
- gchar *text;
gint n;
gint v;
/* red-eye (bit 6) */
if ((n >> 5) & 0x01) string = append_comma_text(string, _("red-eye reduction"));
- text = string->str;
- g_string_free(string, FALSE);
- return text;
+ return g_string_free(string, FALSE);
}
static gchar *exif_build_formatted_Resolution(ExifData *exif)
{
- ExifRational *rx, *ry;
+ ExifRational *rx;
+ ExifRational *ry;
gchar *units;
gchar *text;
static gchar *exif_build_formatted_ColorProfile(ExifData *exif)
{
-#ifdef HAVE_LCMS2
+#if HAVE_LCMS2
cmsUInt8Number profileID[17];
#endif
const gchar *name = "";
else
{
source = _("embedded");
-#ifdef HAVE_LCMS
+#if HAVE_LCMS
{
cmsHPROFILE profile;
profile = cmsOpenProfileFromMem(profile_data, profile_len);
if (profile)
{
-#ifdef HAVE_LCMS2
+#if HAVE_LCMS2
profileID[16] = '\0';
cmsGetHeaderProfileID(profile, profileID);
name = reinterpret_cast<gchar *>(profileID);
static gchar *exif_build_formatted_GPSPosition(ExifData *exif)
{
GString *string;
- gchar *text, *ref;
+ gchar *ref;
ExifRational *value;
ExifItem *item;
guint i;
- gdouble p, p3;
- gulong p1, p2;
+ gdouble p;
+ gdouble p3;
+ gulong p1;
+ gulong p2;
string = g_string_new("");
g_string_append_printf(string, ", %0lu° %0lu' %0.2f\" %.1s", p1, p2, p3, ref);
} // if (item && ref)
- text = string->str;
- g_string_free(string, FALSE);
-
- return text;
+ return g_string_free(string, FALSE);
} // static gchar *exif_build_forma...
static gchar *exif_build_formatted_GPSAltitude(ExifData *exif)
* not writable directly, thus it should contain the most up-to-date version */
sidecar_path = nullptr;
-#ifdef HAVE_EXIV2
+#if HAVE_EXIV2
/* we are not able to handle XMP sidecars without exiv2 */
sidecar_path = cache_find_location(CACHE_TYPE_XMP_METADATA, fd->path);
static gchar *mode_number(mode_t m)
{
- gint mb, mu, mg, mo;
+ gint mb;
+ gint mu;
+ gint mg;
+ gint mo;
gchar pbuf[12];
mb = mu = mg = mo = 0;
return g_strdup_printf("%s (%d%d%d%d)", pbuf, mb, mu, mg, mo);
}
-gchar *metadata_file_info(FileData *fd, const gchar *key, MetadataFormat UNUSED(format))
+gchar *metadata_file_info(FileData *fd, const gchar *key, MetadataFormat)
{
gchar *page_n_of_m;
page_n_of_m = g_strdup_printf("[%d/%d]", fd->page_num + 1, fd->page_total);
return page_n_of_m;
}
- else
- {
- return nullptr;
- }
+
+ return nullptr;
}
return g_strdup("");
}
-#ifdef HAVE_LUA
-gchar *metadata_lua_info(FileData *fd, const gchar *key, MetadataFormat UNUSED(format))
+#if HAVE_LUA
+gchar *metadata_lua_info(FileData *fd, const gchar *key, MetadataFormat)
{
gchar *script_name;
gchar *script_name_utf8;