Include tooltip for Filter combo
[geeqie.git] / src / format-raw.cc
index a902432..ac78e20 100644 (file)
 
 #ifndef HAVE_EXIV2
 
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+#include <cstdio>
+#include <cstring>
 #include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include <glib.h>
 
 #include "format-olympus.h"
 
 
-typedef struct _FormatRawEntry FormatRawEntry;
-struct _FormatRawEntry {
+struct FormatRawEntry {
        const gchar *extension;
        FormatRawMatchType magic_type;
-       const guint magic_offset;
+       guint magic_offset;
        gconstpointer magic_pattern;
-       const guint magic_length;
-       const FormatRawExifType exif_type;
+       guint magic_length;
+       FormatRawExifType exif_type;
        FormatRawExifParseFunc exif_func;
        const gchar *description;
        FormatRawParseFunc func_parse;
@@ -66,15 +65,14 @@ static FormatRawEntry format_raw_list[] = {
        FORMAT_RAW_OLYMPUS,
        FORMAT_RAW_PENTAX,
        FORMAT_RAW_SAMSUNG,
-       { NULL, (FormatRawMatchType)0, 0, NULL, 0, (FormatRawExifType)0, NULL, NULL, NULL }
+       { nullptr, static_cast<FormatRawMatchType>(0), 0, nullptr, 0, static_cast<FormatRawExifType>(0), nullptr, nullptr, nullptr }
 };
 
 
-typedef struct _FormatExifEntry FormatExifEntry;
-struct _FormatExifEntry {
+struct FormatExifEntry {
        FormatExifMatchType header_type;
        gconstpointer header_pattern;
-       const guint header_length;
+       guint header_length;
        const gchar *description;
        FormatExifParseFunc func_parse;
 };
@@ -84,7 +82,7 @@ static FormatExifEntry format_exif_list[] = {
        FORMAT_EXIF_FUJI,
        FORMAT_EXIF_NIKON,
        FORMAT_EXIF_OLYMPUS,
-       { (FormatExifMatchType)0, NULL, 0, NULL, NULL }
+       { static_cast<FormatExifMatchType>(0), nullptr, 0, nullptr, nullptr }
 };
 
 
@@ -233,7 +231,7 @@ static FormatRawEntry *format_raw_find(guchar *data, const guint len)
                n++;
                }
 
-       return NULL;
+       return nullptr;
 }
 
 static gboolean format_raw_parse(FormatRawEntry *entry,
@@ -283,13 +281,13 @@ FormatRawExifType format_raw_exif_offset(guchar *data, const guint len, guint *e
 {
        FormatRawEntry *entry;
 
-       if (!data || len < 1) return (FormatRawExifType)FALSE;
+       if (!data || len < 1) return static_cast<FormatRawExifType>FALSE;
 
        entry = format_raw_find(data, len);
 
-       if (!entry || !entry->func_parse) return (FormatRawExifType)FALSE;
+       if (!entry || !entry->func_parse) return static_cast<FormatRawExifType>FALSE;
 
-       if (!format_raw_parse(entry, data, len, NULL, exif_offset)) return FORMAT_RAW_EXIF_NONE;
+       if (!format_raw_parse(entry, data, len, nullptr, exif_offset)) return FORMAT_RAW_EXIF_NONE;
 
        if (entry->exif_type == FORMAT_RAW_EXIF_PROPRIETARY && exif_parse_func)
                {
@@ -305,7 +303,7 @@ gboolean format_raw_img_exif_offsets_fd(gint fd, const gchar *path,
                                        guint *image_offset, guint *exif_offset)
 {
        FormatRawEntry *entry;
-       gpointer map_data = NULL;
+       gpointer map_data = nullptr;
        size_t map_len = 0;
        struct stat st;
        gboolean success;
@@ -353,14 +351,14 @@ gboolean format_raw_img_exif_offsets_fd(gint fd, const gchar *path,
                return FALSE;
                }
        map_len = st.st_size;
-       map_data = mmap(0, map_len, PROT_READ, MAP_PRIVATE, fd, 0);
+       map_data = mmap(nullptr, map_len, PROT_READ, MAP_PRIVATE, fd, 0);
        if (map_data == MAP_FAILED)
                {
                log_printf("Failed to mmap file %d\n", fd);
                return FALSE;
                }
 
-       success = format_raw_parse(entry, (guchar*)map_data, map_len, image_offset, exif_offset);
+       success = format_raw_parse(entry, static_cast<guchar*>(map_data), map_len, image_offset, exif_offset);
 
        if (munmap(map_data, map_len) == -1)
                {
@@ -369,7 +367,7 @@ gboolean format_raw_img_exif_offsets_fd(gint fd, const gchar *path,
 
        if (success && image_offset)
                {
-               if (lseek(fd, *image_offset, SEEK_SET) != (off_t) *image_offset)
+               if (lseek(fd, *image_offset, SEEK_SET) != static_cast<off_t>(*image_offset))
                        {
                        log_printf("Failed to seek to embedded image\n");
 
@@ -569,7 +567,7 @@ gboolean format_debug_tiff_raw(guchar *data, const guint len,
 }
 #endif
 #else
-typedef int dummy_variable;
+using dummy_variable = int;
 #endif
 /* not HAVE_EXIV2 */
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */