OLD | NEW |
(Empty) | |
| 1 /*! \file exif-entry.h |
| 2 * \brief Handling EXIF entries |
| 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 |
| 23 #ifndef __EXIF_ENTRY_H__ |
| 24 #define __EXIF_ENTRY_H__ |
| 25 |
| 26 #ifdef __cplusplus |
| 27 extern "C" { |
| 28 #endif /* __cplusplus */ |
| 29 |
| 30 /*! Data found in one EXIF tag. |
| 31 * The #exif_entry_get_value function can provide access to the |
| 32 * formatted contents, or the struct members can be used directly to |
| 33 * access the raw contents. |
| 34 */ |
| 35 typedef struct _ExifEntry ExifEntry; |
| 36 typedef struct _ExifEntryPrivate ExifEntryPrivate; |
| 37 |
| 38 #include <libexif/exif-content.h> |
| 39 #include <libexif/exif-format.h> |
| 40 #include <libexif/exif-mem.h> |
| 41 |
| 42 /*! Data found in one EXIF tag */ |
| 43 struct _ExifEntry { |
| 44 /*! EXIF tag for this entry */ |
| 45 ExifTag tag; |
| 46 |
| 47 /*! Type of data in this entry */ |
| 48 ExifFormat format; |
| 49 |
| 50 /*! Number of elements in the array, if this is an array entry. |
| 51 * Contains 1 for non-array data types. */ |
| 52 unsigned long components; |
| 53 |
| 54 /*! Pointer to the raw EXIF data for this entry. It is allocated |
| 55 * by #exif_entry_initialize and is NULL beforehand. Data contained |
| 56 * here may be manipulated using the functions in exif-utils.h */ |
| 57 unsigned char *data; |
| 58 |
| 59 /*! Number of bytes in the buffer at \c data. This must be no less |
| 60 * than exif_format_get_size(format)*components */ |
| 61 unsigned int size; |
| 62 |
| 63 /*! #ExifContent containing this entry. |
| 64 * \see exif_entry_get_ifd */ |
| 65 ExifContent *parent; |
| 66 |
| 67 /*! Internal data to be used by libexif itself */ |
| 68 ExifEntryPrivate *priv; |
| 69 }; |
| 70 |
| 71 /* Lifecycle */ |
| 72 |
| 73 /*! Reserve memory for and initialize a new #ExifEntry. |
| 74 * No memory is allocated for the \c data element of the returned #ExifEntry. |
| 75 * |
| 76 * \return new allocated #ExifEntry, or NULL on error |
| 77 * |
| 78 * \see exif_entry_new_mem, exif_entry_unref |
| 79 */ |
| 80 ExifEntry *exif_entry_new (void); |
| 81 |
| 82 /*! Reserve memory for and initialize new #ExifEntry using the specified |
| 83 * memory allocator. |
| 84 * No memory is allocated for the \c data element of the returned #ExifEntry. |
| 85 * |
| 86 * \return new allocated #ExifEntry, or NULL on error |
| 87 * |
| 88 * \see exif_entry_new, exif_entry_unref |
| 89 */ |
| 90 ExifEntry *exif_entry_new_mem (ExifMem *); |
| 91 |
| 92 /*! Increase reference counter for #ExifEntry. |
| 93 * |
| 94 * \param[in] entry #ExifEntry |
| 95 * |
| 96 * \see exif_entry_unref |
| 97 */ |
| 98 void exif_entry_ref (ExifEntry *entry); |
| 99 |
| 100 /*! Decrease reference counter for #ExifEntry. |
| 101 * When the reference count drops to zero, free the entry. |
| 102 * |
| 103 * \param[in] entry #ExifEntry |
| 104 */ |
| 105 void exif_entry_unref (ExifEntry *entry); |
| 106 |
| 107 /*! Actually free the #ExifEntry. |
| 108 * |
| 109 * \deprecated Should not be called directly. Use #exif_entry_ref and |
| 110 * #exif_entry_unref instead. |
| 111 * |
| 112 * \param[in] entry EXIF entry |
| 113 */ |
| 114 void exif_entry_free (ExifEntry *entry); |
| 115 |
| 116 /*! Initialize an empty #ExifEntry with default data in the correct format |
| 117 * for the given tag. If the entry is already initialized, this function |
| 118 * does nothing. |
| 119 * This call allocates memory for the \c data element of the given #ExifEntry. |
| 120 * That memory is freed at the same time as the #ExifEntry. |
| 121 * |
| 122 * \param[out] e entry to initialize |
| 123 * \param[in] tag tag number to initialize as |
| 124 */ |
| 125 void exif_entry_initialize (ExifEntry *e, ExifTag tag); |
| 126 |
| 127 /*! Fix the type or format of the given EXIF entry to bring it into spec. |
| 128 * If the data for this EXIF tag is in of the wrong type or is in an invalid |
| 129 * format according to the EXIF specification, then it is converted to make it |
| 130 * valid. This may involve, for example, converting an EXIF_FORMAT_LONG into a |
| 131 * EXIF_FORMAT_SHORT. If the tag is unknown, its value is untouched. |
| 132 * |
| 133 * \note Unfortunately, some conversions are to a type with a more restricted |
| 134 * range, which could have the side effect that the converted data becomes |
| 135 * invalid. This is unlikely as the range of each tag in the standard is |
| 136 * designed to encompass all likely data. |
| 137 * |
| 138 * \param[in,out] entry EXIF entry |
| 139 */ |
| 140 void exif_entry_fix (ExifEntry *entry); |
| 141 |
| 142 |
| 143 /* For your convenience */ |
| 144 |
| 145 /*! Return a localized textual representation of the value of the EXIF entry. |
| 146 * This is meant for display to the user. The format of each tag is subject |
| 147 * to change between locales and in newer versions of libexif. Users who |
| 148 * require the tag data in an unambiguous form should access the data members |
| 149 * of the #ExifEntry structure directly. |
| 150 * |
| 151 * \warning The character set of the returned string may be in |
| 152 * the encoding of the current locale or the native encoding |
| 153 * of the camera. |
| 154 * \bug The EXIF_TAG_XP_* tags are currently always returned in UTF-8, |
| 155 * regardless of locale, and code points above U+FFFF are not |
| 156 * supported. |
| 157 * |
| 158 * \param[in] entry EXIF entry |
| 159 * \param[out] val buffer in which to store value |
| 160 * \param[in] maxlen length of the buffer val |
| 161 * \return val pointer |
| 162 */ |
| 163 const char *exif_entry_get_value (ExifEntry *entry, char *val, |
| 164 unsigned int maxlen); |
| 165 |
| 166 /*! Dump text representation of #ExifEntry to stdout. |
| 167 * This is intended for diagnostic purposes only. |
| 168 * |
| 169 * \param[in] entry EXIF tag data |
| 170 * \param[in] indent how many levels deep to indent the data |
| 171 */ |
| 172 void exif_entry_dump (ExifEntry *entry, unsigned int indent); |
| 173 |
| 174 /*! Return the IFD number of the given #ExifEntry |
| 175 * |
| 176 * \param[in] e an #ExifEntry* |
| 177 * \return #ExifIfd, or #EXIF_IFD_COUNT on error |
| 178 */ |
| 179 #define exif_entry_get_ifd(e) ((e)?exif_content_get_ifd((e)->parent):EXIF_IFD_CO
UNT) |
| 180 |
| 181 #ifdef __cplusplus |
| 182 } |
| 183 #endif /* __cplusplus */ |
| 184 |
| 185 #endif /* __EXIF_ENTRY_H__ */ |
OLD | NEW |