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