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