#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;
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;
};
FORMAT_EXIF_FUJI,
FORMAT_EXIF_NIKON,
FORMAT_EXIF_OLYMPUS,
- { (FormatExifMatchType)0, NULL, 0, NULL, NULL }
+ { static_cast<FormatExifMatchType>(0), nullptr, 0, nullptr, nullptr }
};
n++;
}
- return NULL;
+ return nullptr;
}
static gboolean format_raw_parse(FormatRawEntry *entry,
{
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)
{
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;
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)
{
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");
}
#endif
#else
-typedef int dummy_variable;
+using dummy_variable = int;
#endif
/* not HAVE_EXIV2 */
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */