5395f1176451a6e0caf12d9e2283722ac6218909
[geeqie.git] / src / format_fuji.c
1 /*
2  *  GQView
3  *  (C) 2005 John Ellis
4  *
5  *  Authors:
6  *    Original version 2005 Lars Ellenberg, base on dcraw by David coffin.
7  *
8  * This software is released under the GNU General Public License (GNU GPL).
9  * Please read the included file COPYING for more information.
10  * This software comes with no warranty of any kind, use at your own risk!
11  */
12
13 #ifdef HAVE_CONFIG_H
14 #  include "config.h"
15 #endif
16
17
18 #include <stdio.h>
19 #include <string.h>
20 #include <unistd.h>
21
22 #include <glib.h>
23
24 #include "intl.h"
25
26 #include "format_fuji.h"
27 #include "format_raw.h"
28
29
30 gint format_raw_test_fuji(const void *data, const guint len,
31                           guint *image_offset, guint *exif_offset)
32 {
33         guint io;
34         guint eo;
35
36         if (len < 128 ||
37             memcmp(data, "FUJIFILM", 8) != 0)
38                 {
39                 return FALSE;
40                 }
41
42         io = GUINT32_FROM_BE(*(guint32*)(data + 84));
43         eo = *image_offset + 12;
44
45         /* verify jpeg marker */
46         if (memcmp(data + io, "\xff\xd8\xff\xe1", 4) != 0)
47                 {
48                 return FALSE;
49                 }
50
51         if (image_offset) *image_offset = io;
52         if (exif_offset) *exif_offset = eo;
53
54         printf("raw Fuji format file\n");
55
56         return TRUE;
57 }
58
59