• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*! \file exif-utils.h
2  *  \brief EXIF data manipulation functions and types
3  */
4 /*
5  * Copyright (c) 2001 Lutz Mueller <lutz@users.sourceforge.net>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library 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 GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA  02110-1301  USA.
21  *
22  * SPDX-License-Identifier: LGPL-2.0-or-later
23  */
24 
25 #ifndef LIBEXIF_EXIF_UTILS_H
26 #define LIBEXIF_EXIF_UTILS_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31 
32 #include <libexif/exif-byte-order.h>
33 #include <libexif/exif-format.h>
34 #include <libexif/_stdint.h>
35 
36 
37 /* If these definitions don't work for you, please let us fix the
38  * macro generating _stdint.h */
39 
40 /*! EXIF Unsigned Byte data type */
41 typedef unsigned char	ExifByte;          /* 1 byte  */
42 
43 /*! EXIF Signed Byte data type */
44 typedef signed char	ExifSByte;         /* 1 byte  */
45 
46 /*! EXIF Text String data type */
47 typedef char *		ExifAscii;
48 
49 /*! EXIF Unsigned Short data type */
50 typedef uint16_t	ExifShort;         /* 2 bytes */
51 
52 /*! EXIF Signed Short data type */
53 typedef int16_t         ExifSShort;        /* 2 bytes */
54 
55 /*! EXIF Unsigned Long data type */
56 typedef uint32_t	ExifLong;          /* 4 bytes */
57 
58 /*! EXIF Signed Long data type */
59 typedef int32_t		ExifSLong;         /* 4 bytes */
60 
61 /*! EXIF Unsigned Rational data type */
62 typedef struct {ExifLong numerator; ExifLong denominator;} ExifRational;
63 
64 typedef char		ExifUndefined;     /* 1 byte  */
65 
66 /*! EXIF Signed Rational data type */
67 typedef struct {ExifSLong numerator; ExifSLong denominator;} ExifSRational;
68 
69 
70 /*! Retrieve an #ExifShort value from memory.
71  *
72  * \param[in] b pointer to raw EXIF value in memory
73  * \param[in] order byte order of raw value
74  * \return value
75  */
76 ExifShort     exif_get_short     (const unsigned char *b, ExifByteOrder order);
77 
78 /*! Retrieve an #ExifSShort value from memory.
79  *
80  * \param[in] b pointer to raw EXIF value in memory
81  * \param[in] order byte order of raw value
82  * \return value
83  */
84 ExifSShort    exif_get_sshort    (const unsigned char *b, ExifByteOrder order);
85 
86 /*! Retrieve an #ExifLong value from memory.
87  *
88  * \param[in] b pointer to raw EXIF value in memory
89  * \param[in] order byte order of raw value
90  * \return value
91  */
92 ExifLong      exif_get_long      (const unsigned char *b, ExifByteOrder order);
93 
94 /*! Retrieve an #ExifSLong value from memory.
95  *
96  * \param[in] b pointer to raw EXIF value in memory
97  * \param[in] order byte order of raw value
98  * \return value
99  */
100 ExifSLong     exif_get_slong     (const unsigned char *b, ExifByteOrder order);
101 
102 /*! Retrieve an #ExifRational value from memory.
103  *
104  * \param[in] b pointer to raw EXIF value in memory
105  * \param[in] order byte order of raw value
106  * \return value
107  */
108 ExifRational  exif_get_rational  (const unsigned char *b, ExifByteOrder order);
109 
110 /*! Retrieve an #ExifSRational value from memory.
111  *
112  * \param[in] b pointer to raw EXIF value in memory
113  * \param[in] order byte order of raw value
114  * \return value
115  */
116 ExifSRational exif_get_srational (const unsigned char *b, ExifByteOrder order);
117 
118 /*! Store an ExifShort value into memory in EXIF format.
119  *
120  * \param[out] b buffer in which to write raw value
121  * \param[in] order byte order to use
122  * \param[in] value data value to store
123  */
124 void exif_set_short     (unsigned char *b, ExifByteOrder order,
125 			 ExifShort value);
126 
127 /*! Store an ExifSShort value into memory in EXIF format.
128  *
129  * \param[out] b buffer in which to write raw value
130  * \param[in] order byte order to use
131  * \param[in] value data value to store
132  */
133 void exif_set_sshort    (unsigned char *b, ExifByteOrder order,
134 			 ExifSShort value);
135 
136 /*! Store an ExifLong value into memory in EXIF format.
137  *
138  * \param[out] b buffer in which to write raw value
139  * \param[in] order byte order to use
140  * \param[in] value data value to store
141  */
142 void exif_set_long      (unsigned char *b, ExifByteOrder order,
143 			 ExifLong value);
144 
145 /*! Store an ExifSLong value into memory in EXIF format.
146  *
147  * \param[out] b buffer in which to write raw value
148  * \param[in] order byte order to use
149  * \param[in] value data value to store
150  */
151 void exif_set_slong     (unsigned char *b, ExifByteOrder order,
152 			 ExifSLong value);
153 
154 /*! Store an ExifRational value into memory in EXIF format.
155  *
156  * \param[out] b buffer in which to write raw value
157  * \param[in] order byte order to use
158  * \param[in] value data value to store
159  */
160 void exif_set_rational  (unsigned char *b, ExifByteOrder order,
161 			 ExifRational value);
162 
163 /*! Store an ExifSRational value into memory in EXIF format.
164  *
165  * \param[out] b buffer in which to write raw value
166  * \param[in] order byte order to use
167  * \param[in] value data value to store
168  */
169 void exif_set_srational (unsigned char *b, ExifByteOrder order,
170 			 ExifSRational value);
171 
172 /*! \internal */
173 void exif_convert_utf16_to_utf8 (char *out, const unsigned char *in, int maxlen);
174 
175 /* Please do not use this function outside of the library. */
176 
177 /*! \internal */
178 void exif_array_set_byte_order (ExifFormat, unsigned char *, unsigned int,
179 		ExifByteOrder o_orig, ExifByteOrder o_new);
180 
181 #undef  MIN
182 #define MIN(a, b)  (((a) < (b)) ? (a) : (b))
183 
184 #undef  MAX
185 #define MAX(a, b)  (((a) > (b)) ? (a) : (b))
186 
187 /* For compatibility with older versions */
188 
189 /*! \deprecated Use EXIF_TAG_SUB_SEC_TIME instead. */
190 #define EXIF_TAG_SUBSEC_TIME EXIF_TAG_SUB_SEC_TIME
191 
192 #ifdef __cplusplus
193 }
194 #endif /* __cplusplus */
195 
196 #endif /* !defined(LIBEXIF_EXIF_UTILS_H) */
197