exif-content.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*! \file exif-content.h
  2. * \brief Handling EXIF IFDs
  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. #ifndef LIBEXIF_EXIF_CONTENT_H
  23. #define LIBEXIF_EXIF_CONTENT_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif /* __cplusplus */
  27. /*! Holds all EXIF tags in a single IFD */
  28. typedef struct _ExifContent ExifContent;
  29. typedef struct _ExifContentPrivate ExifContentPrivate;
  30. #include <libexif/exif-tag.h>
  31. #include <libexif/exif-entry.h>
  32. #include <libexif/exif-data.h>
  33. #include <libexif/exif-log.h>
  34. #include <libexif/exif-mem.h>
  35. struct _ExifContent
  36. {
  37. ExifEntry **entries;
  38. unsigned int count;
  39. /*! Data containing this content */
  40. ExifData *parent;
  41. ExifContentPrivate *priv;
  42. };
  43. /* Lifecycle */
  44. /*! Reserve memory for and initialize a new #ExifContent.
  45. *
  46. * \return new allocated #ExifContent, or NULL on error
  47. *
  48. * \see exif_content_new_mem, exif_content_unref
  49. */
  50. ExifContent *exif_content_new (void);
  51. /*! Reserve memory for and initialize new #ExifContent using the specified
  52. * memory allocator.
  53. *
  54. * \return new allocated #ExifContent, or NULL on error
  55. *
  56. * \see exif_content_new, exif_content_unref
  57. */
  58. ExifContent *exif_content_new_mem (ExifMem *);
  59. /*! Increase reference counter for #ExifContent.
  60. *
  61. * \param[in] content #ExifContent
  62. *
  63. * \see exif_content_unref
  64. */
  65. void exif_content_ref (ExifContent *content);
  66. /*! Decrease reference counter for #ExifContent.
  67. * When the reference count drops to zero, free the content.
  68. *
  69. * \param[in] content #ExifContent
  70. */
  71. void exif_content_unref (ExifContent *content);
  72. /*! Actually free the #ExifContent.
  73. *
  74. * \deprecated Should not be called directly. Use #exif_content_ref and
  75. * #exif_content_unref instead.
  76. *
  77. * \param[in] content #ExifContent
  78. */
  79. void exif_content_free (ExifContent *content);
  80. /*! Add an EXIF tag to an IFD.
  81. * If this tag already exists in the IFD, this function does nothing.
  82. * \pre The "tag" member of the entry must be set on entry.
  83. *
  84. * \param[out] c IFD
  85. * \param[in] entry EXIF entry to add
  86. */
  87. void exif_content_add_entry (ExifContent *c, ExifEntry *entry);
  88. /*! Remove an EXIF tag from an IFD.
  89. * If this tag does not exist in the IFD, this function does nothing.
  90. *
  91. * \param[out] c IFD
  92. * \param[in] e EXIF entry to remove
  93. */
  94. void exif_content_remove_entry (ExifContent *c, ExifEntry *e);
  95. /*! Return the #ExifEntry in this IFD corresponding to the given tag.
  96. * This is a pointer into a member of the #ExifContent array and must NOT be
  97. * freed or unrefed by the caller.
  98. *
  99. * \param[in] content EXIF content for an IFD
  100. * \param[in] tag EXIF tag to return
  101. * \return #ExifEntry of the tag, or NULL on error
  102. */
  103. ExifEntry *exif_content_get_entry (ExifContent *content, ExifTag tag);
  104. /*! Fix the IFD to bring it into specification. Call #exif_entry_fix on
  105. * each entry in this IFD to fix existing entries, create any new entries
  106. * that are mandatory in this IFD but do not yet exist, and remove any
  107. * entries that are not allowed in this IFD.
  108. *
  109. * \param[in,out] c EXIF content for an IFD
  110. */
  111. void exif_content_fix (ExifContent *c);
  112. typedef void (* ExifContentForeachEntryFunc) (ExifEntry *, void *user_data);
  113. /*! Executes function on each EXIF tag in this IFD in turn.
  114. * The tags will not necessarily be visited in numerical order.
  115. *
  116. * \param[in,out] content IFD over which to iterate
  117. * \param[in] func function to call for each entry
  118. * \param[in] user_data data to pass into func on each call
  119. */
  120. void exif_content_foreach_entry (ExifContent *content,
  121. ExifContentForeachEntryFunc func,
  122. void *user_data);
  123. /*! Return the IFD number in which the given #ExifContent is found.
  124. *
  125. * \param[in] c an #ExifContent*
  126. * \return IFD number, or #EXIF_IFD_COUNT on error
  127. */
  128. ExifIfd exif_content_get_ifd (ExifContent *c);
  129. /*! Return a textual representation of the EXIF data for a tag.
  130. *
  131. * \param[in] c #ExifContent* for an IFD
  132. * \param[in] t #ExifTag to return
  133. * \param[out] v char* buffer in which to store value
  134. * \param[in] m unsigned int length of the buffer v
  135. * \return the v pointer, or NULL on error
  136. */
  137. #define exif_content_get_value(c,t,v,m) \
  138. (exif_content_get_entry (c,t) ? \
  139. exif_entry_get_value (exif_content_get_entry (c,t),v,m) : NULL)
  140. /*! Dump contents of the IFD to stdout.
  141. * This is intended for diagnostic purposes only.
  142. *
  143. * \param[in] content IFD data
  144. * \param[in] indent how many levels deep to indent the data
  145. */
  146. void exif_content_dump (ExifContent *content, unsigned int indent);
  147. /*! Set the log message object for this IFD.
  148. *
  149. * \param[in] content IFD
  150. * \param[in] log #ExifLog*
  151. */
  152. void exif_content_log (ExifContent *content, ExifLog *log);
  153. #ifdef __cplusplus
  154. }
  155. #endif /* __cplusplus */
  156. #endif /* !defined(LIBEXIF_EXIF_CONTENT_H) */