Effectively drop empty newlines at end of files (missing from rev 535)
[geeqie.git] / src / exif-int.h
1 /*
2  *  GQView
3  *  (C) 2006 John Ellis
4  *
5  *  Authors:
6  *    Support for Exif file format, originally written by Eric Swalens.
7  *    Modified by Quy Tonthat
8  *    Reimplemented with generic data storage by John Ellis
9  *
10
11     This program is free software; you can redistribute it and/or modify
12     it under the terms of the GNU General Public License as published by
13     the Free Software Foundation; either version 2 of the License, or
14     (at your option) any later version.
15
16     This program is distributed in the hope that it will be useful,
17     but WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19     GNU General Public License for more details.
20
21     You should have received a copy of the GNU General Public License
22     along with this program; if not, write to the Free Software
23     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26 #ifndef __EXIF_INT_H
27 #define __EXIF_INT_H
28
29 #include "exif.h"
30
31 /*
32  *-----------------------------------------------------------------------------
33  * Tag formats
34  *-----------------------------------------------------------------------------
35  */
36
37 typedef enum {
38         EXIF_BYTE_ORDER_INTEL,
39         EXIF_BYTE_ORDER_MOTOROLA
40 } ExifByteOrder;
41
42 typedef struct _ExifFormatAttrib ExifFormatAttrib;
43 struct _ExifFormatAttrib
44 {
45         ExifFormatType type;
46         guint size;
47         const gchar *short_name;
48         const gchar *description;
49 };
50
51 /* the list of known tag data formats */
52 extern ExifFormatAttrib ExifFormatList[];
53
54
55 /*
56  *-----------------------------------------------------------------------------
57  * Data storage
58  *-----------------------------------------------------------------------------
59  */
60
61 typedef struct _ExifMarker ExifMarker;
62 typedef struct _ExifTextList ExifTextList;
63
64 struct _ExifData
65 {
66         GList *items;   /* list of (ExifItem *) */
67         GList *current; /* for exif_get_next_item */
68 };
69
70
71 struct _ExifItem
72 {
73         ExifFormatType format;
74         guint tag;
75         const ExifMarker *marker;
76         guint elements;
77         gpointer data;
78         guint data_len;
79 };
80
81 struct _ExifMarker
82 {
83         guint           tag;
84         ExifFormatType  format;
85         gint            components;
86         gchar           *key;
87         gchar           *description;
88         ExifTextList    *list;
89 };
90
91 #define EXIF_MARKER_LIST_END { 0x0000, EXIF_FORMAT_UNKNOWN, 0, NULL, NULL, NULL }
92
93 struct _ExifTextList
94 {
95         gint value;
96         const gchar* description;
97 };
98
99 #define EXIF_TEXT_LIST_END { -1, NULL }
100
101
102
103
104 /*
105  *-----------------------------------------------------------------------------
106  * Data
107  *-----------------------------------------------------------------------------
108  */
109
110
111
112 /* the known exif tags list */
113 extern ExifMarker ExifKnownMarkersList[];
114
115 /* the unknown tags utilize this generic list */
116 extern ExifMarker ExifUnknownMarkersList[];
117
118 /* the list of specially formatted keys, for human readable output */
119 extern ExifFormattedText ExifFormattedList[];
120
121
122 /*
123  *-----------------------------------------------------------------------------
124  * functions
125  *-----------------------------------------------------------------------------
126  */
127
128
129 /* usually for debugging to stdout */
130 void exif_write_data_list(ExifData *exif, FILE *f, gint human_readable_list);
131
132
133
134 /* These funcs for use by makernote/tiff parsers only */
135
136 #define EXIF_TIFF_MAX_LEVELS 4
137
138 #define EXIF_TIFD_OFFSET_TAG 0
139 #define EXIF_TIFD_OFFSET_FORMAT 2
140 #define EXIF_TIFD_OFFSET_COUNT 4
141 #define EXIF_TIFD_OFFSET_DATA 8
142 #define EXIF_TIFD_SIZE 12
143
144
145 guint16 exif_byte_get_int16(unsigned char *f, ExifByteOrder bo);
146 guint32 exif_byte_get_int32(unsigned char *f, ExifByteOrder bo);
147 void exif_byte_put_int16(unsigned char *f, guint16 n, ExifByteOrder bo);
148 void exif_byte_put_int32(unsigned char *f, guint32 n, ExifByteOrder bo);
149
150 ExifItem *exif_item_new(ExifFormatType format, guint tag,
151                         guint elements, const ExifMarker *marker);
152 void exif_item_copy_data(ExifItem *item, void *src, guint len,
153                          ExifFormatType src_format, ExifByteOrder bo);
154
155 gint exif_parse_IFD_table(ExifData *exif,
156                           unsigned char *tiff, guint offset,
157                           guint size, ExifByteOrder bo,
158                           gint level,
159                           const ExifMarker *list);
160
161 gint exif_tiff_directory_offset(unsigned char *data, const guint len,
162                                 guint *offset, ExifByteOrder *bo);
163 gint exif_tiff_parse(ExifData *exif, unsigned char *tiff, guint size, ExifMarker *list);
164
165 gchar *exif_text_list_find_value(ExifTextList *list, guint value);
166
167 #endif